FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
h264_ps.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /**
20  * @file
21  * H.264 parameter set handling
22  */
23 
24 #ifndef AVCODEC_H264_PS_H
25 #define AVCODEC_H264_PS_H
26 
27 #include <stdint.h>
28 
29 #include "libavutil/buffer.h"
30 #include "libavutil/pixfmt.h"
31 #include "libavutil/rational.h"
32 
33 #include "avcodec.h"
34 #include "get_bits.h"
35 #include "h264.h"
36 
37 #define MAX_SPS_COUNT 32
38 #define MAX_PPS_COUNT 256
39 #define MAX_LOG2_MAX_FRAME_NUM (12 + 4)
40 
41 /**
42  * Sequence parameter set
43  */
44 typedef struct SPS {
45  unsigned int sps_id;
47  int level_idc;
49  int transform_bypass; ///< qpprime_y_zero_transform_bypass_flag
50  int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4
51  int poc_type; ///< pic_order_cnt_type
52  int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4
56  int poc_cycle_length; ///< num_ref_frames_in_pic_order_cnt_cycle
57  int ref_frame_count; ///< num_ref_frames
59  int mb_width; ///< pic_width_in_mbs_minus1 + 1
60  ///< (pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag)
61  int mb_height;
63  int mb_aff; ///< mb_adaptive_frame_field_flag
65  int crop; ///< frame_cropping_flag
66 
67  /* those 4 are already in luma samples */
68  unsigned int crop_left; ///< frame_cropping_rect_left_offset
69  unsigned int crop_right; ///< frame_cropping_rect_right_offset
70  unsigned int crop_top; ///< frame_cropping_rect_top_offset
71  unsigned int crop_bottom; ///< frame_cropping_rect_bottom_offset
82  uint32_t time_scale;
84  short offset_for_ref_frame[256]; // FIXME dyn aloc?
94  int cpb_cnt; ///< See H.264 E.1.2
95  int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1
96  int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1
97  int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1
98  int bit_depth_luma; ///< bit_depth_luma_minus8 + 8
99  int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8
100  int residual_color_transform_flag; ///< residual_colour_transform_flag
101  int constraint_set_flags; ///< constraint_set[0-3]_flag
102  uint8_t data[4096];
103  size_t data_size;
104 } SPS;
105 
106 /**
107  * Picture parameter set
108  */
109 typedef struct PPS {
110  unsigned int sps_id;
111  int cabac; ///< entropy_coding_mode_flag
112  int pic_order_present; ///< pic_order_present_flag
113  int slice_group_count; ///< num_slice_groups_minus1 + 1
115  unsigned int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1
116  int weighted_pred; ///< weighted_pred_flag
118  int init_qp; ///< pic_init_qp_minus26 + 26
119  int init_qs; ///< pic_init_qs_minus26 + 26
121  int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag
122  int constrained_intra_pred; ///< constrained_intra_pred_flag
123  int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag
124  int transform_8x8_mode; ///< transform_8x8_mode_flag
127  uint8_t chroma_qp_table[2][QP_MAX_NUM+1]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
129  uint8_t data[4096];
130  size_t data_size;
131 
132  uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16];
133  uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
134  uint32_t(*dequant4_coeff[6])[16];
135  uint32_t(*dequant8_coeff[6])[64];
136 } PPS;
137 
138 typedef struct H264ParamSets {
141 
144  /* currently active parameters sets */
145  const PPS *pps;
146  const SPS *sps;
147 } H264ParamSets;
148 
149 /**
150  * Decode SPS
151  */
153  H264ParamSets *ps, int ignore_truncation);
154 
155 /**
156  * Decode PPS
157  */
159  H264ParamSets *ps, int bit_length);
160 
161 /**
162  * Uninit H264 param sets structure.
163  */
165 
166 #endif /* AVCODEC_H264_PS_H */
int chroma_format_idc
Definition: h264_ps.h:48
int video_signal_type_present_flag
Definition: h264_ps.h:74
#define MAX_SPS_COUNT
Definition: h264_ps.h:37
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
int weighted_bipred_idc
Definition: h264_ps.h:117
int chroma_qp_index_offset[2]
Definition: h264_ps.h:120
AVBufferRef * sps_list[MAX_SPS_COUNT]
Definition: h264_ps.h:139
int scaling_matrix_present
Definition: h264_ps.h:87
uint8_t scaling_matrix4[6][16]
Definition: h264_ps.h:88
Sequence parameter set.
Definition: h264_ps.h:44
int bitstream_restriction_flag
Definition: h264_ps.h:85
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
Definition: h264_ps.h:115
Picture parameter set.
Definition: h264_ps.h:109
int frame_mbs_only_flag
Definition: h264_ps.h:62
int chroma_qp_diff
Definition: h264_ps.h:128
uint32_t num_units_in_tick
Definition: h264_ps.h:81
int profile_idc
Definition: h264_ps.h:46
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:464
unsigned int crop_top
frame_cropping_rect_top_offset
Definition: h264_ps.h:70
int fixed_frame_rate_flag
Definition: h264_ps.h:83
uint8_t scaling_matrix4[6][16]
Definition: h264_ps.h:125
int deblocking_filter_parameters_present
deblocking_filter_parameters_present_flag
Definition: h264_ps.h:121
const PPS * pps
Definition: h264_ps.h:145
uint8_t
int full_range
Definition: h264_ps.h:75
unsigned int crop_left
frame_cropping_rect_left_offset
Definition: h264_ps.h:68
int offset_for_non_ref_pic
Definition: h264_ps.h:54
int gaps_in_frame_num_allowed_flag
Definition: h264_ps.h:58
int bit_depth_chroma
bit_depth_chroma_minus8 + 8
Definition: h264_ps.h:99
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:493
enum AVColorPrimaries color_primaries
Definition: h264_ps.h:77
int cabac
entropy_coding_mode_flag
Definition: h264_ps.h:111
unsigned int crop_right
frame_cropping_rect_right_offset
Definition: h264_ps.h:69
uint32_t(*[6] dequant4_coeff)[16]
Definition: h264_ps.h:134
#define MAX_PPS_COUNT
Definition: h264_ps.h:38
int transform_bypass
qpprime_y_zero_transform_bypass_flag
Definition: h264_ps.h:49
uint32_t(*[6] dequant8_coeff)[64]
Definition: h264_ps.h:135
int redundant_pic_cnt_present
redundant_pic_cnt_present_flag
Definition: h264_ps.h:123
bitstream reader API header.
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:440
H.264 common definitions.
enum AVColorTransferCharacteristic color_trc
Definition: h264_ps.h:78
int mb_aff
mb_adaptive_frame_field_flag
Definition: h264_ps.h:63
AVBufferRef * sps_ref
Definition: h264_ps.h:143
int poc_type
pic_order_cnt_type
Definition: h264_ps.h:51
int constrained_intra_pred
constrained_intra_pred_flag
Definition: h264_ps.h:122
int num_reorder_frames
Definition: h264_ps.h:86
int time_offset_length
Definition: h264_ps.h:93
int weighted_pred
weighted_pred_flag
Definition: h264_ps.h:116
int residual_color_transform_flag
residual_colour_transform_flag
Definition: h264_ps.h:100
int delta_pic_order_always_zero_flag
Definition: h264_ps.h:53
int offset_for_top_to_bottom_field
Definition: h264_ps.h:55
int crop
frame_cropping_flag
Definition: h264_ps.h:65
uint8_t scaling_matrix8[6][64]
Definition: h264_ps.h:126
size_t data_size
Definition: h264_ps.h:103
int ref_frame_count
num_ref_frames
Definition: h264_ps.h:57
int initial_cpb_removal_delay_length
initial_cpb_removal_delay_length_minus1 + 1
Definition: h264_ps.h:95
int poc_cycle_length
num_ref_frames_in_pic_order_cnt_cycle
Definition: h264_ps.h:56
int colour_description_present_flag
Definition: h264_ps.h:76
AVRational sar
Definition: h264_ps.h:73
uint8_t chroma_qp_table[2][QP_MAX_NUM+1]
pre-scaled (with chroma_qp_index_offset) version of qp_table
Definition: h264_ps.h:127
int init_qp
pic_init_qp_minus26 + 26
Definition: h264_ps.h:118
int direct_8x8_inference_flag
Definition: h264_ps.h:64
uint8_t scaling_matrix8[6][64]
Definition: h264_ps.h:89
unsigned int sps_id
Definition: h264_ps.h:45
int pic_order_present
pic_order_present_flag
Definition: h264_ps.h:112
short offset_for_ref_frame[256]
Definition: h264_ps.h:84
int timing_info_present_flag
Definition: h264_ps.h:80
int vcl_hrd_parameters_present_flag
Definition: h264_ps.h:91
Libavcodec external API header.
AVBufferRef * pps_list[MAX_PPS_COUNT]
Definition: h264_ps.h:140
main external API structure.
Definition: avcodec.h:1540
int dpb_output_delay_length
dpb_output_delay_length_minus1 + 1
Definition: h264_ps.h:97
int vui_parameters_present_flag
Definition: h264_ps.h:72
#define QP_MAX_NUM
Definition: h264.h:27
int constraint_set_flags
constraint_set[0-3]_flag
Definition: h264_ps.h:101
Rational number (pair of numerator and denominator).
Definition: rational.h:58
refcounted data buffer API
const SPS * sps
Definition: h264_ps.h:146
unsigned int sps_id
Definition: h264_ps.h:110
int log2_max_poc_lsb
log2_max_pic_order_cnt_lsb_minus4
Definition: h264_ps.h:52
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int ignore_truncation)
Decode SPS.
Definition: h264_ps.c:333
uint32_t time_scale
Definition: h264_ps.h:82
int transform_8x8_mode
transform_8x8_mode_flag
Definition: h264_ps.h:124
int pic_struct_present_flag
Definition: h264_ps.h:92
A reference to a data buffer.
Definition: buffer.h:81
int mb_height
Definition: h264_ps.h:61
int init_qs
pic_init_qs_minus26 + 26
Definition: h264_ps.h:119
Utilties for rational number calculation.
AVBufferRef * pps_ref
Definition: h264_ps.h:142
int nal_hrd_parameters_present_flag
Definition: h264_ps.h:90
size_t data_size
Definition: h264_ps.h:130
int log2_max_frame_num
log2_max_frame_num_minus4 + 4
Definition: h264_ps.h:50
int bit_depth_luma
bit_depth_luma_minus8 + 8
Definition: h264_ps.h:98
pixel format definitions
int mb_width
pic_width_in_mbs_minus1 + 1
Definition: h264_ps.h:59
int slice_group_count
num_slice_groups_minus1 + 1
Definition: h264_ps.h:113
int cpb_cnt
See H.264 E.1.2.
Definition: h264_ps.h:94
uint32_t dequant4_buffer[6][QP_MAX_NUM+1][16]
Definition: h264_ps.h:132
uint32_t dequant8_buffer[6][QP_MAX_NUM+1][64]
Definition: h264_ps.h:133
int cpb_removal_delay_length
cpb_removal_delay_length_minus1 + 1
Definition: h264_ps.h:96
int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int bit_length)
Decode PPS.
Definition: h264_ps.c:724
unsigned int crop_bottom
frame_cropping_rect_bottom_offset
Definition: h264_ps.h:71
int level_idc
Definition: h264_ps.h:47
void ff_h264_ps_uninit(H264ParamSets *ps)
Uninit H264 param sets structure.
Definition: h264_ps.c:316
int mb_slice_group_map_type
Definition: h264_ps.h:114
enum AVColorSpace colorspace
Definition: h264_ps.h:79