1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Helper functions for H264 codecs.
5 * Copyright (c) 2019 Collabora, Ltd.
7 * Author: Boris Brezillon <boris.brezillon@collabora.com>
10 #ifndef _MEDIA_V4L2_H264_H
11 #define _MEDIA_V4L2_H264_H
13 #include <media/v4l2-ctrls.h>
16 * struct v4l2_h264_reflist_builder - Reference list builder object
18 * @refs.pic_order_count: reference picture order count
19 * @refs.frame_num: reference frame number
20 * @refs.pic_num: reference picture number
21 * @refs.longterm: set to true for a long term reference
22 * @refs: array of references
23 * @cur_pic_order_count: picture order count of the frame being decoded
24 * @unordered_reflist: unordered list of references. Will be used to generate
25 * ordered P/B0/B1 lists
26 * @num_valid: number of valid references in the refs array
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 reference
30 * picture lists construction' of the H264 spec.
32 struct v4l2_h264_reflist_builder {
38 } refs[V4L2_H264_NUM_DPB_ENTRIES];
39 s32 cur_pic_order_count;
40 u8 unordered_reflist[V4L2_H264_NUM_DPB_ENTRIES];
45 v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
46 const struct v4l2_ctrl_h264_decode_params *dec_params,
47 const struct v4l2_ctrl_h264_sps *sps,
48 const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]);
51 * v4l2_h264_build_b_ref_lists() - Build the B0/B1 reference lists
53 * @builder: reference list builder context
54 * @b0_reflist: 16-bytes array used to store the B0 reference list. Each entry
55 * is an index in the DPB
56 * @b1_reflist: 16-bytes array used to store the B1 reference list. Each entry
57 * is an index in the DPB
59 * This functions builds the B0/B1 reference lists. This procedure is described
60 * in section '8.2.4 Decoding process for reference picture lists construction'
61 * of the H264 spec. This function can be used by H264 decoder drivers that
62 * need to pass B0/B1 reference lists to the hardware.
65 v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder,
66 u8 *b0_reflist, u8 *b1_reflist);
69 * v4l2_h264_build_b_ref_lists() - Build the P reference list
71 * @builder: reference list builder context
72 * @p_reflist: 16-bytes array used to store the P reference list. Each entry
73 * is an index in the DPB
75 * This functions builds the P reference lists. This procedure is describe in
76 * section '8.2.4 Decoding process for reference picture lists construction'
77 * of the H264 spec. This function can be used by H264 decoder drivers that
78 * need to pass a P reference list to the hardware.
81 v4l2_h264_build_p_ref_list(const struct v4l2_h264_reflist_builder *builder,
84 #endif /* _MEDIA_V4L2_H264_H */