18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Helper functions for H264 codecs. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2019 Collabora, Ltd. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Author: Boris Brezillon <boris.brezillon@collabora.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef _MEDIA_V4L2_H264_H 118c2ecf20Sopenharmony_ci#define _MEDIA_V4L2_H264_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <media/h264-ctrls.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/** 168c2ecf20Sopenharmony_ci * struct v4l2_h264_reflist_builder - Reference list builder object 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * @refs.pic_order_count: reference picture order count 198c2ecf20Sopenharmony_ci * @refs.frame_num: reference frame number 208c2ecf20Sopenharmony_ci * @refs.pic_num: reference picture number 218c2ecf20Sopenharmony_ci * @refs.longterm: set to true for a long term reference 228c2ecf20Sopenharmony_ci * @refs: array of references 238c2ecf20Sopenharmony_ci * @cur_pic_order_count: picture order count of the frame being decoded 248c2ecf20Sopenharmony_ci * @unordered_reflist: unordered list of references. Will be used to generate 258c2ecf20Sopenharmony_ci * ordered P/B0/B1 lists 268c2ecf20Sopenharmony_ci * @num_valid: number of valid references in the refs array 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * This object stores the context of the P/B0/B1 reference list builder. 298c2ecf20Sopenharmony_ci * This procedure is described in section '8.2.4 Decoding process for reference 308c2ecf20Sopenharmony_ci * picture lists construction' of the H264 spec. 318c2ecf20Sopenharmony_ci */ 328c2ecf20Sopenharmony_cistruct v4l2_h264_reflist_builder { 338c2ecf20Sopenharmony_ci struct { 348c2ecf20Sopenharmony_ci s32 pic_order_count; 358c2ecf20Sopenharmony_ci int frame_num; 368c2ecf20Sopenharmony_ci u32 pic_num; 378c2ecf20Sopenharmony_ci u16 longterm : 1; 388c2ecf20Sopenharmony_ci } refs[V4L2_H264_NUM_DPB_ENTRIES]; 398c2ecf20Sopenharmony_ci s32 cur_pic_order_count; 408c2ecf20Sopenharmony_ci u8 unordered_reflist[V4L2_H264_NUM_DPB_ENTRIES]; 418c2ecf20Sopenharmony_ci u8 num_valid; 428c2ecf20Sopenharmony_ci}; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_civoid 458c2ecf20Sopenharmony_civ4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b, 468c2ecf20Sopenharmony_ci const struct v4l2_ctrl_h264_decode_params *dec_params, 478c2ecf20Sopenharmony_ci const struct v4l2_ctrl_h264_sps *sps, 488c2ecf20Sopenharmony_ci const struct v4l2_h264_dpb_entry dpb[V4L2_H264_NUM_DPB_ENTRIES]); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/** 518c2ecf20Sopenharmony_ci * v4l2_h264_build_b_ref_lists() - Build the B0/B1 reference lists 528c2ecf20Sopenharmony_ci * 538c2ecf20Sopenharmony_ci * @builder: reference list builder context 548c2ecf20Sopenharmony_ci * @b0_reflist: 16-bytes array used to store the B0 reference list. Each entry 558c2ecf20Sopenharmony_ci * is an index in the DPB 568c2ecf20Sopenharmony_ci * @b1_reflist: 16-bytes array used to store the B1 reference list. Each entry 578c2ecf20Sopenharmony_ci * is an index in the DPB 588c2ecf20Sopenharmony_ci * 598c2ecf20Sopenharmony_ci * This functions builds the B0/B1 reference lists. This procedure is described 608c2ecf20Sopenharmony_ci * in section '8.2.4 Decoding process for reference picture lists construction' 618c2ecf20Sopenharmony_ci * of the H264 spec. This function can be used by H264 decoder drivers that 628c2ecf20Sopenharmony_ci * need to pass B0/B1 reference lists to the hardware. 638c2ecf20Sopenharmony_ci */ 648c2ecf20Sopenharmony_civoid 658c2ecf20Sopenharmony_civ4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder, 668c2ecf20Sopenharmony_ci u8 *b0_reflist, u8 *b1_reflist); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/** 698c2ecf20Sopenharmony_ci * v4l2_h264_build_b_ref_lists() - Build the P reference list 708c2ecf20Sopenharmony_ci * 718c2ecf20Sopenharmony_ci * @builder: reference list builder context 728c2ecf20Sopenharmony_ci * @p_reflist: 16-bytes array used to store the P reference list. Each entry 738c2ecf20Sopenharmony_ci * is an index in the DPB 748c2ecf20Sopenharmony_ci * 758c2ecf20Sopenharmony_ci * This functions builds the P reference lists. This procedure is describe in 768c2ecf20Sopenharmony_ci * section '8.2.4 Decoding process for reference picture lists construction' 778c2ecf20Sopenharmony_ci * of the H264 spec. This function can be used by H264 decoder drivers that 788c2ecf20Sopenharmony_ci * need to pass a P reference list to the hardware. 798c2ecf20Sopenharmony_ci */ 808c2ecf20Sopenharmony_civoid 818c2ecf20Sopenharmony_civ4l2_h264_build_p_ref_list(const struct v4l2_h264_reflist_builder *builder, 828c2ecf20Sopenharmony_ci u8 *reflist); 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#endif /* _MEDIA_V4L2_H264_H */ 85