FFmpeg
cbs_mpeg2.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 #ifndef AVCODEC_CBS_MPEG2_H
20 #define AVCODEC_CBS_MPEG2_H
21 
22 #include <stddef.h>
23 #include <stdint.h>
24 
25 #include "libavutil/buffer.h"
26 
27 
28 enum {
38 };
39 
40 #define MPEG2_START_IS_SLICE(type) \
41  ((type) >= MPEG2_START_SLICE_MIN && \
42  (type) <= MPEG2_START_SLICE_MAX)
43 
44 enum {
56 };
57 
58 
59 typedef struct MPEG2RawSequenceHeader {
61 
65  uint8_t frame_rate_code;
66  uint32_t bit_rate_value;
69 
75 
76 typedef struct MPEG2RawUserData {
78 
79  uint8_t *user_data;
83 
84 typedef struct MPEG2RawSequenceExtension {
87  uint8_t chroma_format;
92  uint8_t low_delay;
96 
98  uint8_t video_format;
99 
104 
108 
111 
112  uint32_t time_code;
113  uint8_t closed_gop;
114  uint8_t broken_link;
116 
117 typedef struct MPEG2RawExtraInformation {
122 
123 typedef struct MPEG2RawPictureHeader {
125 
128  uint16_t vbv_delay;
129 
131  uint8_t forward_f_code;
134 
137 
139  uint8_t f_code[2][2];
140 
146  uint8_t q_scale_type;
148  uint8_t alternate_scan;
152 
154  uint8_t v_axis;
155  uint8_t field_sequence;
156  uint8_t sub_carrier;
160 
171 
176 
177 typedef struct MPEG2RawExtensionData {
180 
181  union {
187  } data;
189 
190 typedef struct MPEG2RawSliceHeader {
192 
195 
197 
199  uint8_t intra_slice;
202 
205 
206 typedef struct MPEG2RawSlice {
208 
209  uint8_t *data;
211  size_t data_size;
213 } MPEG2RawSlice;
214 
215 typedef struct MPEG2RawSequenceEnd {
218 
219 
221  // Elements stored in headers which are required for other decoding.
222  uint16_t horizontal_size;
223  uint16_t vertical_size;
224  uint8_t scalable;
225  uint8_t scalable_mode;
229 
230 
231 #endif /* AVCODEC_CBS_MPEG2_H */
MPEG2RawExtraInformation::extra_information_length
size_t extra_information_length
Definition: cbs_mpeg2.h:120
MPEG2_EXTENSION_PICTURE_SPATIAL_SCALABLE
@ MPEG2_EXTENSION_PICTURE_SPATIAL_SCALABLE
Definition: cbs_mpeg2.h:52
MPEG2RawPictureCodingExtension
Definition: cbs_mpeg2.h:138
MPEG2RawUserData::user_data_start_code
uint8_t user_data_start_code
Definition: cbs_mpeg2.h:77
MPEG2_EXTENSION_ITU_T
@ MPEG2_EXTENSION_ITU_T
Definition: cbs_mpeg2.h:55
MPEG2RawSliceHeader::priority_breakpoint
uint8_t priority_breakpoint
Definition: cbs_mpeg2.h:194
MPEG2RawPictureHeader::extra_information_picture
MPEG2RawExtraInformation extra_information_picture
Definition: cbs_mpeg2.h:135
MPEG2RawPictureHeader
Definition: cbs_mpeg2.h:123
MPEG2RawSliceHeader::extra_information_slice
MPEG2RawExtraInformation extra_information_slice
Definition: cbs_mpeg2.h:203
MPEG2RawExtensionData::sequence_display
MPEG2RawSequenceDisplayExtension sequence_display
Definition: cbs_mpeg2.h:183
MPEG2RawPictureCodingExtension::alternate_scan
uint8_t alternate_scan
Definition: cbs_mpeg2.h:148
MPEG2RawSequenceExtension::vbv_buffer_size_extension
uint8_t vbv_buffer_size_extension
Definition: cbs_mpeg2.h:91
MPEG2_EXTENSION_PICTURE_DISPLAY
@ MPEG2_EXTENSION_PICTURE_DISPLAY
Definition: cbs_mpeg2.h:50
MPEG2RawSequenceExtension::vertical_size_extension
uint8_t vertical_size_extension
Definition: cbs_mpeg2.h:89
MPEG2RawExtensionData
Definition: cbs_mpeg2.h:177
MPEG2RawSequenceDisplayExtension::display_horizontal_size
uint16_t display_horizontal_size
Definition: cbs_mpeg2.h:105
MPEG2RawSliceHeader::slice_vertical_position_extension
uint8_t slice_vertical_position_extension
Definition: cbs_mpeg2.h:193
MPEG2_START_SEQUENCE_ERROR
@ MPEG2_START_SEQUENCE_ERROR
Definition: cbs_mpeg2.h:34
MPEG2RawSequenceHeader::load_intra_quantiser_matrix
uint8_t load_intra_quantiser_matrix
Definition: cbs_mpeg2.h:70
MPEG2RawUserData
Definition: cbs_mpeg2.h:76
MPEG2RawSequenceHeader::frame_rate_code
uint8_t frame_rate_code
Definition: cbs_mpeg2.h:65
MPEG2RawPictureCodingExtension::q_scale_type
uint8_t q_scale_type
Definition: cbs_mpeg2.h:146
MPEG2_START_SLICE_MAX
@ MPEG2_START_SLICE_MAX
Definition: cbs_mpeg2.h:31
MPEG2_START_SEQUENCE_END
@ MPEG2_START_SEQUENCE_END
Definition: cbs_mpeg2.h:36
MPEG2RawSlice::data
uint8_t * data
Definition: cbs_mpeg2.h:209
MPEG2RawSliceHeader::slice_picture_id
uint8_t slice_picture_id
Definition: cbs_mpeg2.h:201
MPEG2RawSlice
Definition: cbs_mpeg2.h:206
MPEG2_START_GROUP
@ MPEG2_START_GROUP
Definition: cbs_mpeg2.h:37
MPEG2RawSequenceHeader::intra_quantiser_matrix
uint8_t intra_quantiser_matrix[64]
Definition: cbs_mpeg2.h:71
MPEG2RawGroupOfPicturesHeader
Definition: cbs_mpeg2.h:109
MPEG2RawPictureCodingExtension::frame_pred_frame_dct
uint8_t frame_pred_frame_dct
Definition: cbs_mpeg2.h:144
MPEG2RawExtensionData::extension_start_code
uint8_t extension_start_code
Definition: cbs_mpeg2.h:178
MPEG2_START_USER_DATA
@ MPEG2_START_USER_DATA
Definition: cbs_mpeg2.h:32
MPEG2RawPictureCodingExtension::chroma_420_type
uint8_t chroma_420_type
Definition: cbs_mpeg2.h:150
MPEG2RawPictureCodingExtension::concealment_motion_vectors
uint8_t concealment_motion_vectors
Definition: cbs_mpeg2.h:145
MPEG2RawSequenceDisplayExtension::colour_description
uint8_t colour_description
Definition: cbs_mpeg2.h:100
MPEG2RawSequenceHeader::non_intra_quantiser_matrix
uint8_t non_intra_quantiser_matrix[64]
Definition: cbs_mpeg2.h:73
MPEG2RawGroupOfPicturesHeader::time_code
uint32_t time_code
Definition: cbs_mpeg2.h:112
MPEG2RawPictureCodingExtension::field_sequence
uint8_t field_sequence
Definition: cbs_mpeg2.h:155
MPEG2RawSequenceExtension
Definition: cbs_mpeg2.h:84
MPEG2RawPictureCodingExtension::composite_display_flag
uint8_t composite_display_flag
Definition: cbs_mpeg2.h:153
CodedBitstreamMPEG2Context::scalable_mode
uint8_t scalable_mode
Definition: cbs_mpeg2.h:225
MPEG2_EXTENSION_PICTURE_CODING
@ MPEG2_EXTENSION_PICTURE_CODING
Definition: cbs_mpeg2.h:51
MPEG2RawSliceHeader::slice_picture_id_enable
uint8_t slice_picture_id_enable
Definition: cbs_mpeg2.h:200
MPEG2RawExtraInformation::extra_information_ref
AVBufferRef * extra_information_ref
Definition: cbs_mpeg2.h:119
MPEG2RawSequenceDisplayExtension
Definition: cbs_mpeg2.h:97
MPEG2RawQuantMatrixExtension::intra_quantiser_matrix
uint8_t intra_quantiser_matrix[64]
Definition: cbs_mpeg2.h:163
MPEG2RawSequenceHeader::constrained_parameters_flag
uint8_t constrained_parameters_flag
Definition: cbs_mpeg2.h:68
MPEG2RawSlice::header
MPEG2RawSliceHeader header
Definition: cbs_mpeg2.h:207
MPEG2RawPictureHeader::forward_f_code
uint8_t forward_f_code
Definition: cbs_mpeg2.h:131
MPEG2RawPictureDisplayExtension::frame_centre_horizontal_offset
int16_t frame_centre_horizontal_offset[3]
Definition: cbs_mpeg2.h:173
MPEG2RawSequenceDisplayExtension::video_format
uint8_t video_format
Definition: cbs_mpeg2.h:98
MPEG2RawSequenceHeader::vertical_size_value
uint16_t vertical_size_value
Definition: cbs_mpeg2.h:63
MPEG2RawPictureDisplayExtension::frame_centre_vertical_offset
int16_t frame_centre_vertical_offset[3]
Definition: cbs_mpeg2.h:174
MPEG2RawSequenceExtension::horizontal_size_extension
uint8_t horizontal_size_extension
Definition: cbs_mpeg2.h:88
MPEG2RawExtraInformation
Definition: cbs_mpeg2.h:117
MPEG2RawSequenceDisplayExtension::colour_primaries
uint8_t colour_primaries
Definition: cbs_mpeg2.h:101
MPEG2RawSequenceEnd::sequence_end_code
uint8_t sequence_end_code
Definition: cbs_mpeg2.h:216
MPEG2RawSequenceExtension::chroma_format
uint8_t chroma_format
Definition: cbs_mpeg2.h:87
MPEG2RawPictureHeader::full_pel_backward_vector
uint8_t full_pel_backward_vector
Definition: cbs_mpeg2.h:132
MPEG2RawGroupOfPicturesHeader::broken_link
uint8_t broken_link
Definition: cbs_mpeg2.h:114
MPEG2RawPictureCodingExtension::repeat_first_field
uint8_t repeat_first_field
Definition: cbs_mpeg2.h:149
MPEG2RawSequenceExtension::bit_rate_extension
uint16_t bit_rate_extension
Definition: cbs_mpeg2.h:90
MPEG2RawUserData::user_data_ref
AVBufferRef * user_data_ref
Definition: cbs_mpeg2.h:80
MPEG2RawQuantMatrixExtension::non_intra_quantiser_matrix
uint8_t non_intra_quantiser_matrix[64]
Definition: cbs_mpeg2.h:165
MPEG2_EXTENSION_SEQUENCE
@ MPEG2_EXTENSION_SEQUENCE
Definition: cbs_mpeg2.h:45
MPEG2RawQuantMatrixExtension::load_chroma_non_intra_quantiser_matrix
uint8_t load_chroma_non_intra_quantiser_matrix
Definition: cbs_mpeg2.h:168
MPEG2RawGroupOfPicturesHeader::closed_gop
uint8_t closed_gop
Definition: cbs_mpeg2.h:113
MPEG2RawQuantMatrixExtension::load_non_intra_quantiser_matrix
uint8_t load_non_intra_quantiser_matrix
Definition: cbs_mpeg2.h:164
MPEG2RawUserData::user_data
uint8_t * user_data
Definition: cbs_mpeg2.h:79
MPEG2RawSequenceDisplayExtension::matrix_coefficients
uint8_t matrix_coefficients
Definition: cbs_mpeg2.h:103
CodedBitstreamMPEG2Context::horizontal_size
uint16_t horizontal_size
Definition: cbs_mpeg2.h:222
MPEG2RawSequenceHeader::horizontal_size_value
uint16_t horizontal_size_value
Definition: cbs_mpeg2.h:62
MPEG2RawExtensionData::sequence
MPEG2RawSequenceExtension sequence
Definition: cbs_mpeg2.h:182
MPEG2RawUserData::user_data_length
size_t user_data_length
Definition: cbs_mpeg2.h:81
CodedBitstreamMPEG2Context::number_of_frame_centre_offsets
uint8_t number_of_frame_centre_offsets
Definition: cbs_mpeg2.h:227
MPEG2_EXTENSION_PICTURE_TEMPORAL_SCALABLE
@ MPEG2_EXTENSION_PICTURE_TEMPORAL_SCALABLE
Definition: cbs_mpeg2.h:53
MPEG2_EXTENSION_CAMERA_PARAMETERS
@ MPEG2_EXTENSION_CAMERA_PARAMETERS
Definition: cbs_mpeg2.h:54
MPEG2RawExtensionData::picture_display
MPEG2RawPictureDisplayExtension picture_display
Definition: cbs_mpeg2.h:186
MPEG2RawExtensionData::extension_start_code_identifier
uint8_t extension_start_code_identifier
Definition: cbs_mpeg2.h:179
MPEG2_EXTENSION_SEQUENCE_SCALABLE
@ MPEG2_EXTENSION_SEQUENCE_SCALABLE
Definition: cbs_mpeg2.h:49
MPEG2_START_PICTURE
@ MPEG2_START_PICTURE
Definition: cbs_mpeg2.h:29
MPEG2RawSliceHeader::intra_slice
uint8_t intra_slice
Definition: cbs_mpeg2.h:199
MPEG2RawExtensionData::data
union MPEG2RawExtensionData::@35 data
buffer.h
MPEG2RawPictureCodingExtension::sub_carrier
uint8_t sub_carrier
Definition: cbs_mpeg2.h:156
MPEG2RawSequenceEnd
Definition: cbs_mpeg2.h:215
MPEG2RawSequenceHeader
Definition: cbs_mpeg2.h:59
MPEG2RawPictureHeader::temporal_reference
uint16_t temporal_reference
Definition: cbs_mpeg2.h:126
MPEG2RawQuantMatrixExtension::chroma_intra_quantiser_matrix
uint8_t chroma_intra_quantiser_matrix[64]
Definition: cbs_mpeg2.h:167
MPEG2RawSlice::data_bit_start
int data_bit_start
Definition: cbs_mpeg2.h:212
MPEG2RawQuantMatrixExtension::load_chroma_intra_quantiser_matrix
uint8_t load_chroma_intra_quantiser_matrix
Definition: cbs_mpeg2.h:166
MPEG2RawSequenceExtension::low_delay
uint8_t low_delay
Definition: cbs_mpeg2.h:92
MPEG2RawSequenceExtension::progressive_sequence
uint8_t progressive_sequence
Definition: cbs_mpeg2.h:86
MPEG2RawSequenceExtension::profile_and_level_indication
uint8_t profile_and_level_indication
Definition: cbs_mpeg2.h:85
MPEG2_EXTENSION_COPYRIGHT
@ MPEG2_EXTENSION_COPYRIGHT
Definition: cbs_mpeg2.h:48
CodedBitstreamMPEG2Context::progressive_sequence
uint8_t progressive_sequence
Definition: cbs_mpeg2.h:226
MPEG2RawSequenceHeader::sequence_header_code
uint8_t sequence_header_code
Definition: cbs_mpeg2.h:60
MPEG2RawQuantMatrixExtension::load_intra_quantiser_matrix
uint8_t load_intra_quantiser_matrix
Definition: cbs_mpeg2.h:162
MPEG2RawSequenceHeader::aspect_ratio_information
uint8_t aspect_ratio_information
Definition: cbs_mpeg2.h:64
CodedBitstreamMPEG2Context::vertical_size
uint16_t vertical_size
Definition: cbs_mpeg2.h:223
MPEG2RawQuantMatrixExtension::chroma_non_intra_quantiser_matrix
uint8_t chroma_non_intra_quantiser_matrix[64]
Definition: cbs_mpeg2.h:169
MPEG2RawSequenceDisplayExtension::transfer_characteristics
uint8_t transfer_characteristics
Definition: cbs_mpeg2.h:102
MPEG2_EXTENSION_QUANT_MATRIX
@ MPEG2_EXTENSION_QUANT_MATRIX
Definition: cbs_mpeg2.h:47
CodedBitstreamMPEG2Context
Definition: cbs_mpeg2.h:220
MPEG2RawSliceHeader::slice_vertical_position
uint8_t slice_vertical_position
Definition: cbs_mpeg2.h:191
MPEG2RawExtraInformation::extra_information
uint8_t * extra_information
Definition: cbs_mpeg2.h:118
MPEG2RawPictureCodingExtension::burst_amplitude
uint8_t burst_amplitude
Definition: cbs_mpeg2.h:157
MPEG2_EXTENSION_SEQUENCE_DISPLAY
@ MPEG2_EXTENSION_SEQUENCE_DISPLAY
Definition: cbs_mpeg2.h:46
MPEG2RawQuantMatrixExtension
Definition: cbs_mpeg2.h:161
MPEG2RawPictureHeader::full_pel_forward_vector
uint8_t full_pel_forward_vector
Definition: cbs_mpeg2.h:130
MPEG2RawExtensionData::picture_coding
MPEG2RawPictureCodingExtension picture_coding
Definition: cbs_mpeg2.h:185
MPEG2RawPictureHeader::picture_start_code
uint8_t picture_start_code
Definition: cbs_mpeg2.h:124
MPEG2RawPictureHeader::picture_coding_type
uint8_t picture_coding_type
Definition: cbs_mpeg2.h:127
MPEG2RawPictureHeader::backward_f_code
uint8_t backward_f_code
Definition: cbs_mpeg2.h:133
MPEG2RawPictureCodingExtension::v_axis
uint8_t v_axis
Definition: cbs_mpeg2.h:154
MPEG2_START_SLICE_MIN
@ MPEG2_START_SLICE_MIN
Definition: cbs_mpeg2.h:30
MPEG2RawPictureCodingExtension::picture_structure
uint8_t picture_structure
Definition: cbs_mpeg2.h:142
MPEG2RawSlice::data_ref
AVBufferRef * data_ref
Definition: cbs_mpeg2.h:210
MPEG2RawSequenceDisplayExtension::display_vertical_size
uint16_t display_vertical_size
Definition: cbs_mpeg2.h:106
MPEG2RawPictureHeader::vbv_delay
uint16_t vbv_delay
Definition: cbs_mpeg2.h:128
MPEG2RawExtensionData::quant_matrix
MPEG2RawQuantMatrixExtension quant_matrix
Definition: cbs_mpeg2.h:184
MPEG2RawSliceHeader
Definition: cbs_mpeg2.h:190
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:84
CodedBitstreamMPEG2Context::scalable
uint8_t scalable
Definition: cbs_mpeg2.h:224
MPEG2RawSequenceHeader::vbv_buffer_size_value
uint16_t vbv_buffer_size_value
Definition: cbs_mpeg2.h:67
MPEG2_START_EXTENSION
@ MPEG2_START_EXTENSION
Definition: cbs_mpeg2.h:35
MPEG2_START_SEQUENCE_HEADER
@ MPEG2_START_SEQUENCE_HEADER
Definition: cbs_mpeg2.h:33
MPEG2RawPictureCodingExtension::intra_dc_precision
uint8_t intra_dc_precision
Definition: cbs_mpeg2.h:141
MPEG2RawPictureCodingExtension::f_code
uint8_t f_code[2][2]
Definition: cbs_mpeg2.h:139
MPEG2RawSequenceExtension::frame_rate_extension_n
uint8_t frame_rate_extension_n
Definition: cbs_mpeg2.h:93
MPEG2RawPictureCodingExtension::intra_vlc_format
uint8_t intra_vlc_format
Definition: cbs_mpeg2.h:147
MPEG2RawPictureDisplayExtension
Definition: cbs_mpeg2.h:172
MPEG2RawGroupOfPicturesHeader::group_start_code
uint8_t group_start_code
Definition: cbs_mpeg2.h:110
MPEG2RawSliceHeader::slice_extension_flag
uint8_t slice_extension_flag
Definition: cbs_mpeg2.h:198
MPEG2RawSequenceExtension::frame_rate_extension_d
uint8_t frame_rate_extension_d
Definition: cbs_mpeg2.h:94
MPEG2RawSlice::data_size
size_t data_size
Definition: cbs_mpeg2.h:211
MPEG2RawSequenceHeader::bit_rate_value
uint32_t bit_rate_value
Definition: cbs_mpeg2.h:66
MPEG2RawPictureCodingExtension::sub_carrier_phase
uint8_t sub_carrier_phase
Definition: cbs_mpeg2.h:158
MPEG2RawPictureCodingExtension::top_field_first
uint8_t top_field_first
Definition: cbs_mpeg2.h:143
MPEG2RawSliceHeader::quantiser_scale_code
uint8_t quantiser_scale_code
Definition: cbs_mpeg2.h:196
MPEG2RawPictureCodingExtension::progressive_frame
uint8_t progressive_frame
Definition: cbs_mpeg2.h:151
MPEG2RawSequenceHeader::load_non_intra_quantiser_matrix
uint8_t load_non_intra_quantiser_matrix
Definition: cbs_mpeg2.h:72