/* SPDX-License-Identifier: GPL-2.0-or-later */1/*2* Helper functions for H264 codecs.3*4* Copyright (c) 2019 Collabora, Ltd.5*6* Author: Boris Brezillon <[email protected]>7*/89#ifndef _MEDIA_V4L2_H264_H10#define _MEDIA_V4L2_H264_H1112#include <media/v4l2-ctrls.h>1314/**15* struct v4l2_h264_reflist_builder - Reference list builder object16*17* @refs.top_field_order_cnt: top field order count18* @refs.bottom_field_order_cnt: bottom field order count19* @refs.frame_num: reference frame number20* @refs.longterm: set to true for a long term reference21* @refs: array of references22* @cur_pic_order_count: picture order count of the frame being decoded23* @cur_pic_fields: fields present in the frame being decoded24* @unordered_reflist: unordered list of references. Will be used to generate25* ordered P/B0/B1 lists26* @num_valid: number of valid references in the refs array27*28* This object stores the context of the P/B0/B1 reference list builder.29* This procedure is described in section '8.2.4 Decoding process for reference30* picture lists construction' of the H264 spec.31*/32struct v4l2_h264_reflist_builder {33struct {34s32 top_field_order_cnt;35s32 bottom_field_order_cnt;36int frame_num;37u16 longterm : 1;38} refs[V4L2_H264_NUM_DPB_ENTRIES];3940s32 cur_pic_order_count;41u8 cur_pic_fields;4243struct v4l2_h264_reference unordered_reflist[V4L2_H264_REF_LIST_LEN];44u8 num_valid;45};4647void48v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,49const struct v4l2_ctrl_h264_decode_params *dec_params,50const struct v4l2_ctrl_h264_sps *sps,51const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]);5253/**54* v4l2_h264_build_b_ref_lists() - Build the B0/B1 reference lists55*56* @builder: reference list builder context57* @b0_reflist: 32 sized array used to store the B0 reference list. Each entry58* is a v4l2_h264_reference structure59* @b1_reflist: 32 sized array used to store the B1 reference list. Each entry60* is a v4l2_h264_reference structure61*62* This functions builds the B0/B1 reference lists. This procedure is described63* in section '8.2.4 Decoding process for reference picture lists construction'64* of the H264 spec. This function can be used by H264 decoder drivers that65* need to pass B0/B1 reference lists to the hardware.66*/67void68v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder,69struct v4l2_h264_reference *b0_reflist,70struct v4l2_h264_reference *b1_reflist);7172/**73* v4l2_h264_build_p_ref_list() - Build the P reference list74*75* @builder: reference list builder context76* @reflist: 32 sized array used to store the P reference list. Each entry77* is a v4l2_h264_reference structure78*79* This functions builds the P reference lists. This procedure is describe in80* section '8.2.4 Decoding process for reference picture lists construction'81* of the H264 spec. This function can be used by H264 decoder drivers that82* need to pass a P reference list to the hardware.83*/84void85v4l2_h264_build_p_ref_list(const struct v4l2_h264_reflist_builder *builder,86struct v4l2_h264_reference *reflist);8788#endif /* _MEDIA_V4L2_H264_H */899091