2020-04-03 18:13:41 -04:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/*
|
|
|
|
* Helper functions for H264 codecs.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2019 Collabora, Ltd.
|
|
|
|
*
|
|
|
|
* Author: Boris Brezillon <boris.brezillon@collabora.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MEDIA_V4L2_H264_H
|
|
|
|
#define _MEDIA_V4L2_H264_H
|
|
|
|
|
2020-11-26 04:36:10 -05:00
|
|
|
#include <media/v4l2-ctrls.h>
|
2020-04-03 18:13:41 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct v4l2_h264_reflist_builder - Reference list builder object
|
|
|
|
*
|
2022-05-13 16:29:06 -04:00
|
|
|
* @refs.top_field_order_cnt: top field order count
|
|
|
|
* @refs.bottom_field_order_cnt: bottom field order count
|
2020-04-03 18:13:41 -04:00
|
|
|
* @refs.frame_num: reference frame number
|
|
|
|
* @refs.longterm: set to true for a long term reference
|
|
|
|
* @refs: array of references
|
|
|
|
* @cur_pic_order_count: picture order count of the frame being decoded
|
2022-05-13 16:29:05 -04:00
|
|
|
* @cur_pic_fields: fields present in the frame being decoded
|
2020-04-03 18:13:41 -04:00
|
|
|
* @unordered_reflist: unordered list of references. Will be used to generate
|
|
|
|
* ordered P/B0/B1 lists
|
|
|
|
* @num_valid: number of valid references in the refs array
|
|
|
|
*
|
|
|
|
* This object stores the context of the P/B0/B1 reference list builder.
|
|
|
|
* This procedure is described in section '8.2.4 Decoding process for reference
|
|
|
|
* picture lists construction' of the H264 spec.
|
|
|
|
*/
|
|
|
|
struct v4l2_h264_reflist_builder {
|
|
|
|
struct {
|
2022-05-13 16:29:06 -04:00
|
|
|
s32 top_field_order_cnt;
|
|
|
|
s32 bottom_field_order_cnt;
|
2020-04-03 18:13:41 -04:00
|
|
|
int frame_num;
|
|
|
|
u16 longterm : 1;
|
|
|
|
} refs[V4L2_H264_NUM_DPB_ENTRIES];
|
2022-05-13 16:29:05 -04:00
|
|
|
|
2020-04-03 18:13:41 -04:00
|
|
|
s32 cur_pic_order_count;
|
2022-05-13 16:29:05 -04:00
|
|
|
u8 cur_pic_fields;
|
|
|
|
|
2022-05-13 16:29:04 -04:00
|
|
|
struct v4l2_h264_reference unordered_reflist[V4L2_H264_REF_LIST_LEN];
|
2020-04-03 18:13:41 -04:00
|
|
|
u8 num_valid;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
|
|
|
|
const struct v4l2_ctrl_h264_decode_params *dec_params,
|
|
|
|
const struct v4l2_ctrl_h264_sps *sps,
|
|
|
|
const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* v4l2_h264_build_b_ref_lists() - Build the B0/B1 reference lists
|
|
|
|
*
|
|
|
|
* @builder: reference list builder context
|
2022-05-13 16:29:04 -04:00
|
|
|
* @b0_reflist: 32 sized array used to store the B0 reference list. Each entry
|
2022-05-13 16:29:03 -04:00
|
|
|
* is a v4l2_h264_reference structure
|
2022-05-13 16:29:04 -04:00
|
|
|
* @b1_reflist: 32 sized array used to store the B1 reference list. Each entry
|
2022-05-13 16:29:03 -04:00
|
|
|
* is a v4l2_h264_reference structure
|
2020-04-03 18:13:41 -04:00
|
|
|
*
|
|
|
|
* This functions builds the B0/B1 reference lists. This procedure is described
|
|
|
|
* in section '8.2.4 Decoding process for reference picture lists construction'
|
|
|
|
* of the H264 spec. This function can be used by H264 decoder drivers that
|
|
|
|
* need to pass B0/B1 reference lists to the hardware.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder,
|
2022-05-13 16:29:03 -04:00
|
|
|
struct v4l2_h264_reference *b0_reflist,
|
|
|
|
struct v4l2_h264_reference *b1_reflist);
|
2020-04-03 18:13:41 -04:00
|
|
|
|
|
|
|
/**
|
2021-03-09 06:48:20 -05:00
|
|
|
* v4l2_h264_build_p_ref_list() - Build the P reference list
|
2020-04-03 18:13:41 -04:00
|
|
|
*
|
|
|
|
* @builder: reference list builder context
|
2022-05-13 16:29:04 -04:00
|
|
|
* @reflist: 32 sized array used to store the P reference list. Each entry
|
2022-05-13 16:29:03 -04:00
|
|
|
* is a v4l2_h264_reference structure
|
2020-04-03 18:13:41 -04:00
|
|
|
*
|
|
|
|
* This functions builds the P reference lists. This procedure is describe in
|
|
|
|
* section '8.2.4 Decoding process for reference picture lists construction'
|
|
|
|
* of the H264 spec. This function can be used by H264 decoder drivers that
|
|
|
|
* need to pass a P reference list to the hardware.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
v4l2_h264_build_p_ref_list(const struct v4l2_h264_reflist_builder *builder,
|
2022-05-13 16:29:03 -04:00
|
|
|
struct v4l2_h264_reference *reflist);
|
2020-04-03 18:13:41 -04:00
|
|
|
|
|
|
|
#endif /* _MEDIA_V4L2_H264_H */
|