Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Helper functions for H264 codecs.
0004  *
0005  * Copyright (c) 2019 Collabora, Ltd.
0006  *
0007  * Author: Boris Brezillon <boris.brezillon@collabora.com>
0008  */
0009 
0010 #ifndef _MEDIA_V4L2_H264_H
0011 #define _MEDIA_V4L2_H264_H
0012 
0013 #include <media/v4l2-ctrls.h>
0014 
0015 /**
0016  * struct v4l2_h264_reflist_builder - Reference list builder object
0017  *
0018  * @refs.top_field_order_cnt: top field order count
0019  * @refs.bottom_field_order_cnt: bottom field order count
0020  * @refs.frame_num: reference frame number
0021  * @refs.longterm: set to true for a long term reference
0022  * @refs: array of references
0023  * @cur_pic_order_count: picture order count of the frame being decoded
0024  * @cur_pic_fields: fields present in the frame being decoded
0025  * @unordered_reflist: unordered list of references. Will be used to generate
0026  *             ordered P/B0/B1 lists
0027  * @num_valid: number of valid references in the refs array
0028  *
0029  * This object stores the context of the P/B0/B1 reference list builder.
0030  * This procedure is described in section '8.2.4 Decoding process for reference
0031  * picture lists construction' of the H264 spec.
0032  */
0033 struct v4l2_h264_reflist_builder {
0034     struct {
0035         s32 top_field_order_cnt;
0036         s32 bottom_field_order_cnt;
0037         int frame_num;
0038         u16 longterm : 1;
0039     } refs[V4L2_H264_NUM_DPB_ENTRIES];
0040 
0041     s32 cur_pic_order_count;
0042     u8 cur_pic_fields;
0043 
0044     struct v4l2_h264_reference unordered_reflist[V4L2_H264_REF_LIST_LEN];
0045     u8 num_valid;
0046 };
0047 
0048 void
0049 v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
0050         const struct v4l2_ctrl_h264_decode_params *dec_params,
0051         const struct v4l2_ctrl_h264_sps *sps,
0052         const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]);
0053 
0054 /**
0055  * v4l2_h264_build_b_ref_lists() - Build the B0/B1 reference lists
0056  *
0057  * @builder: reference list builder context
0058  * @b0_reflist: 32 sized array used to store the B0 reference list. Each entry
0059  *      is a v4l2_h264_reference structure
0060  * @b1_reflist: 32 sized array used to store the B1 reference list. Each entry
0061  *      is a v4l2_h264_reference structure
0062  *
0063  * This functions builds the B0/B1 reference lists. This procedure is described
0064  * in section '8.2.4 Decoding process for reference picture lists construction'
0065  * of the H264 spec. This function can be used by H264 decoder drivers that
0066  * need to pass B0/B1 reference lists to the hardware.
0067  */
0068 void
0069 v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder,
0070                 struct v4l2_h264_reference *b0_reflist,
0071                 struct v4l2_h264_reference *b1_reflist);
0072 
0073 /**
0074  * v4l2_h264_build_p_ref_list() - Build the P reference list
0075  *
0076  * @builder: reference list builder context
0077  * @reflist: 32 sized array used to store the P reference list. Each entry
0078  *       is a v4l2_h264_reference structure
0079  *
0080  * This functions builds the P reference lists. This procedure is describe in
0081  * section '8.2.4 Decoding process for reference picture lists construction'
0082  * of the H264 spec. This function can be used by H264 decoder drivers that
0083  * need to pass a P reference list to the hardware.
0084  */
0085 void
0086 v4l2_h264_build_p_ref_list(const struct v4l2_h264_reflist_builder *builder,
0087                struct v4l2_h264_reference *reflist);
0088 
0089 #endif /* _MEDIA_V4L2_H264_H */