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