linux/include/media/v4l2-h264.h
Ezequiel Garcia d935856317 media: uapi: h264: Clean slice invariants syntax elements
The H.264 specification requires in section 7.4.3 "Slice header semantics",
that the following values shall be the same in all slice headers:

  pic_parameter_set_id
  frame_num
  field_pic_flag
  bottom_field_flag
  idr_pic_id
  pic_order_cnt_lsb
  delta_pic_order_cnt_bottom
  delta_pic_order_cnt[ 0 ]
  delta_pic_order_cnt[ 1 ]
  sp_for_switch_flag
  slice_group_change_cycle

These bitstream fields are part of the slice header, and therefore
passed redundantly on each slice. The purpose of the redundancy
is to make the codec fault-tolerant in network scenarios.

This is of course not needed to be reflected in the V4L2 controls,
given the bitstream has already been parsed by applications.
Therefore, move the redundant fields to the per-frame decode
parameters control (DECODE_PARAMS).

Field 'pic_parameter_set_id' is simply removed in this case,
because the PPS control must currently contain the active PPS.

Syntax elements dec_ref_pic_marking() and those related
to pic order count, remain invariant as well, and therefore,
the fields dec_ref_pic_marking_bit_size and pic_order_cnt_bit_size
are also common to all slices.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-01 14:13:28 +02:00

85 lines
2.9 KiB
C

/* 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
#include <media/h264-ctrls.h>
/**
* struct v4l2_h264_reflist_builder - Reference list builder object
*
* @refs.pic_order_count: reference picture order count
* @refs.frame_num: reference frame number
* @refs.pic_num: reference picture 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
* @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 {
s32 pic_order_count;
int frame_num;
u32 pic_num;
u16 longterm : 1;
} refs[V4L2_H264_NUM_DPB_ENTRIES];
s32 cur_pic_order_count;
u8 unordered_reflist[V4L2_H264_NUM_DPB_ENTRIES];
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
* @b0_reflist: 16-bytes array used to store the B0 reference list. Each entry
* is an index in the DPB
* @b1_reflist: 16-bytes array used to store the B1 reference list. Each entry
* is an index in the DPB
*
* 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,
u8 *b0_reflist, u8 *b1_reflist);
/**
* v4l2_h264_build_b_ref_lists() - Build the P reference list
*
* @builder: reference list builder context
* @p_reflist: 16-bytes array used to store the P reference list. Each entry
* is an index in the DPB
*
* 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,
u8 *reflist);
#endif /* _MEDIA_V4L2_H264_H */