// SPDX-License-Identifier: GPL-2.0 /* * Rockchip RK3288 VPU codec driver * * Copyright (c) 2014 Rockchip Electronics Co., Ltd. * Hertz Wong <[email protected]> * Herman Chen <[email protected]> * * Copyright (C) 2014 Google, Inc. * Tomasz Figa <[email protected]> */ #include <linux/types.h> #include <media/v4l2-h264.h> #include <media/v4l2-mem2mem.h> #include "hantro.h" #include "hantro_hw.h" /* Size with u32 units. */ #define CABAC_INIT_BUFFER_SIZE … #define POC_BUFFER_SIZE … #define SCALING_LIST_SIZE … /* * For valid and long term reference marking, index are reversed, so bit 31 * indicates the status of the picture 0. */ #define REF_BIT(i) … /* Data structure describing auxiliary buffer format. */ struct hantro_h264_dec_priv_tbl { … }; /* * Constant CABAC table. * From drivers/media/platform/rk3288-vpu/rk3288_vpu_hw_h264d.c * in https://chromium.googlesource.com/chromiumos/third_party/kernel, * chromeos-3.14 branch. */ static const u32 h264_cabac_table[] = …; static void assemble_scaling_list(struct hantro_ctx *ctx) { … } static void prepare_table(struct hantro_ctx *ctx) { … } static bool dpb_entry_match(const struct v4l2_h264_dpb_entry *a, const struct v4l2_h264_dpb_entry *b) { … } static void update_dpb(struct hantro_ctx *ctx) { … } dma_addr_t hantro_h264_get_ref_buf(struct hantro_ctx *ctx, unsigned int dpb_idx) { … } u16 hantro_h264_get_ref_nbr(struct hantro_ctx *ctx, unsigned int dpb_idx) { … } /* * Removes all references with the same parity as the current picture from the * reference list. The remaining list will have references with the opposite * parity. This is effectively a deduplication of references since each buffer * stores two fields. For this reason, each buffer is found twice in the * reference list. * * This technique has been chosen through trial and error. This simple approach * resulted in the highest conformance score. Note that this method may suffer * worse quality in the case an opposite reference frame has been lost. If this * becomes a problem in the future, it should be possible to add a preprocessing * to identify un-paired fields and avoid removing them. */ static void deduplicate_reflist(struct v4l2_h264_reflist_builder *b, struct v4l2_h264_reference *reflist) { … } int hantro_h264_dec_prepare_run(struct hantro_ctx *ctx) { … } void hantro_h264_dec_exit(struct hantro_ctx *ctx) { … } int hantro_h264_dec_init(struct hantro_ctx *ctx) { … }