Linux Audio

Check our new training course

Loading...
v5.9
 1/* SPDX-License-Identifier: GPL-2.0-or-later */
 2/*
 3 * Helper functions for H264 codecs.
 4 *
 5 * Copyright (c) 2019 Collabora, Ltd.
 6 *
 7 * Author: Boris Brezillon <boris.brezillon@collabora.com>
 8 */
 9
10#ifndef _MEDIA_V4L2_H264_H
11#define _MEDIA_V4L2_H264_H
12
13#include <media/h264-ctrls.h>
14
15/**
16 * struct v4l2_h264_reflist_builder - Reference list builder object
17 *
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
27 *
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.
31 */
32struct v4l2_h264_reflist_builder {
33	struct {
34		s32 pic_order_count;
 
35		int frame_num;
36		u16 pic_num;
37		u16 longterm : 1;
38	} refs[V4L2_H264_NUM_DPB_ENTRIES];
 
39	s32 cur_pic_order_count;
40	u8 unordered_reflist[V4L2_H264_NUM_DPB_ENTRIES];
 
 
41	u8 num_valid;
42};
43
44void
45v4l2_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_slice_params *slice_params,
48		const struct v4l2_ctrl_h264_sps *sps,
49		const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]);
50
51/**
52 * v4l2_h264_build_b_ref_lists() - Build the B0/B1 reference lists
53 *
54 * @builder: reference list builder context
55 * @b0_reflist: 16-bytes array used to store the B0 reference list. Each entry
56 *		is an index in the DPB
57 * @b1_reflist: 16-bytes array used to store the B1 reference list. Each entry
58 *		is an index in the DPB
59 *
60 * This functions builds the B0/B1 reference lists. This procedure is described
61 * in section '8.2.4 Decoding process for reference picture lists construction'
62 * of the H264 spec. This function can be used by H264 decoder drivers that
63 * need to pass B0/B1 reference lists to the hardware.
64 */
65void
66v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder,
67			    u8 *b0_reflist, u8 *b1_reflist);
 
68
69/**
70 * v4l2_h264_build_b_ref_lists() - Build the P reference list
71 *
72 * @builder: reference list builder context
73 * @p_reflist: 16-bytes array used to store the P reference list. Each entry
74 *	       is an index in the DPB
75 *
76 * This functions builds the P reference lists. This procedure is describe in
77 * section '8.2.4 Decoding process for reference picture lists construction'
78 * of the H264 spec. This function can be used by H264 decoder drivers that
79 * need to pass a P reference list to the hardware.
80 */
81void
82v4l2_h264_build_p_ref_list(const struct v4l2_h264_reflist_builder *builder,
83			   u8 *reflist);
84
85#endif /* _MEDIA_V4L2_H264_H */
v6.9.4
 1/* SPDX-License-Identifier: GPL-2.0-or-later */
 2/*
 3 * Helper functions for H264 codecs.
 4 *
 5 * Copyright (c) 2019 Collabora, Ltd.
 6 *
 7 * Author: Boris Brezillon <boris.brezillon@collabora.com>
 8 */
 9
10#ifndef _MEDIA_V4L2_H264_H
11#define _MEDIA_V4L2_H264_H
12
13#include <media/v4l2-ctrls.h>
14
15/**
16 * struct v4l2_h264_reflist_builder - Reference list builder object
17 *
18 * @refs.top_field_order_cnt: top field order count
19 * @refs.bottom_field_order_cnt: bottom field order count
20 * @refs.frame_num: reference frame 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 * @cur_pic_fields: fields present in the frame being decoded
25 * @unordered_reflist: unordered list of references. Will be used to generate
26 *		       ordered P/B0/B1 lists
27 * @num_valid: number of valid references in the refs array
28 *
29 * This object stores the context of the P/B0/B1 reference list builder.
30 * This procedure is described in section '8.2.4 Decoding process for reference
31 * picture lists construction' of the H264 spec.
32 */
33struct v4l2_h264_reflist_builder {
34	struct {
35		s32 top_field_order_cnt;
36		s32 bottom_field_order_cnt;
37		int frame_num;
 
38		u16 longterm : 1;
39	} refs[V4L2_H264_NUM_DPB_ENTRIES];
40
41	s32 cur_pic_order_count;
42	u8 cur_pic_fields;
43
44	struct v4l2_h264_reference unordered_reflist[V4L2_H264_REF_LIST_LEN];
45	u8 num_valid;
46};
47
48void
49v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
50		const struct v4l2_ctrl_h264_decode_params *dec_params,
 
51		const struct v4l2_ctrl_h264_sps *sps,
52		const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]);
53
54/**
55 * v4l2_h264_build_b_ref_lists() - Build the B0/B1 reference lists
56 *
57 * @builder: reference list builder context
58 * @b0_reflist: 32 sized array used to store the B0 reference list. Each entry
59 *		is a v4l2_h264_reference structure
60 * @b1_reflist: 32 sized array used to store the B1 reference list. Each entry
61 *		is a v4l2_h264_reference structure
62 *
63 * This functions builds the B0/B1 reference lists. This procedure is described
64 * in section '8.2.4 Decoding process for reference picture lists construction'
65 * of the H264 spec. This function can be used by H264 decoder drivers that
66 * need to pass B0/B1 reference lists to the hardware.
67 */
68void
69v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder,
70			    struct v4l2_h264_reference *b0_reflist,
71			    struct v4l2_h264_reference *b1_reflist);
72
73/**
74 * v4l2_h264_build_p_ref_list() - Build the P reference list
75 *
76 * @builder: reference list builder context
77 * @reflist: 32 sized array used to store the P reference list. Each entry
78 *	     is a v4l2_h264_reference structure
79 *
80 * This functions builds the P reference lists. This procedure is describe in
81 * section '8.2.4 Decoding process for reference picture lists construction'
82 * of the H264 spec. This function can be used by H264 decoder drivers that
83 * need to pass a P reference list to the hardware.
84 */
85void
86v4l2_h264_build_p_ref_list(const struct v4l2_h264_reflist_builder *builder,
87			   struct v4l2_h264_reference *reflist);
88
89#endif /* _MEDIA_V4L2_H264_H */