FFmpeg
h264_sei.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_H264_SEI_H
20 #define AVCODEC_H264_SEI_H
21 
22 #include "get_bits.h"
23 #include "h264_ps.h"
24 
25 /**
26  * SEI message types
27  */
28 typedef enum {
29  H264_SEI_TYPE_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1)
30  H264_SEI_TYPE_PIC_TIMING = 1, ///< picture timing
31  H264_SEI_TYPE_PAN_SCAN_RECT = 2, ///< pan-scan rectangle
32  H264_SEI_TYPE_FILLER_PAYLOAD = 3, ///< filler data
33  H264_SEI_TYPE_USER_DATA_REGISTERED = 4, ///< registered user data as specified by Rec. ITU-T T.35
34  H264_SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data
35  H264_SEI_TYPE_RECOVERY_POINT = 6, ///< recovery point (frame # to decoder sync)
36  H264_SEI_TYPE_FRAME_PACKING = 45, ///< frame packing arrangement
37  H264_SEI_TYPE_DISPLAY_ORIENTATION = 47, ///< display orientation
38  H264_SEI_TYPE_GREEN_METADATA = 56, ///< GreenMPEG information
39  H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME = 137, ///< mastering display properties
40  H264_SEI_TYPE_ALTERNATIVE_TRANSFER = 147, ///< alternative transfer
42 
43 /**
44  * pic_struct in picture timing SEI message
45  */
46 typedef enum {
47  H264_SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame
48  H264_SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field
49  H264_SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field
50  H264_SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order
51  H264_SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order
52  H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order
53  H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order
54  H264_SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling
55  H264_SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling
57 
58 /**
59  * frame_packing_arrangement types
60  */
61 typedef enum {
70 
71 typedef struct H264SEITimeCode {
72  /* When not continuously receiving full timecodes, we have to reference
73  the previous timecode received */
74  int full;
75  int frame;
76  int seconds;
77  int minutes;
78  int hours;
79  int dropframe;
81 
82 typedef struct H264SEIPictureTiming {
83  // maximum size of pic_timing according to the spec should be 274 bits
86 
87  int present;
89 
90  /**
91  * Bit set of clock types for fields/frames in picture timing SEI message.
92  * For each found ct_type, appropriate bit is set (e.g., bit 1 for
93  * interlaced).
94  */
95  int ct_type;
96 
97  /**
98  * dpb_output_delay in picture timing SEI message, see H.264 C.2.2
99  */
101 
102  /**
103  * cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
104  */
106 
107  /**
108  * Maximum three timecodes in a pic_timing SEI.
109  */
111 
112  /**
113  * Number of timecode in use
114  */
117 
118 typedef struct H264SEIAFD {
119  int present;
121 } H264SEIAFD;
122 
123 typedef struct H264SEIA53Caption {
126 
127 typedef struct H264SEIUnregistered {
130 
131 typedef struct H264SEIRecoveryPoint {
132  /**
133  * recovery_frame_cnt
134  *
135  * Set to -1 if no recovery point SEI message found or to number of frames
136  * before playback synchronizes. Frames having recovery point are key
137  * frames.
138  */
141 
142 typedef struct H264SEIBufferingPeriod {
143  int present; ///< Buffering period SEI flag
144  int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
146 
147 typedef struct H264SEIFramePacking {
148  int present;
150  int arrangement_cancel_flag; ///< is previous arrangement canceled, -1 if never received
157 
159  int present;
161  int hflip, vflip;
163 
164 typedef struct H264SEIGreenMetaData {
167  uint16_t num_seconds;
168  uint16_t num_pictures;
176 
178  int present;
181 
182 typedef struct H264SEIContext {
194 
195 struct H264ParamSets;
196 
198  const struct H264ParamSets *ps, void *logctx);
199 
200 /**
201  * Reset SEI values at the beginning of the frame.
202  */
204 
205 /**
206  * Get stereo_mode string from the h264 frame_packing_arrangement
207  */
208 const char *ff_h264_sei_stereo_mode(const H264SEIFramePacking *h);
209 
210 /**
211  * Parse the contents of a picture timing message given an active SPS.
212  */
214  void *logctx);
215 
216 #endif /* AVCODEC_H264_SEI_H */
H264SEIAFD::present
int present
Definition: h264_sei.h:119
H264SEIPictureTiming::pic_struct
H264_SEI_PicStructType pic_struct
Definition: h264_sei.h:88
H264_SEI_TYPE_BUFFERING_PERIOD
@ H264_SEI_TYPE_BUFFERING_PERIOD
buffering period (H.264, D.1.1)
Definition: h264_sei.h:29
H264_SEI_TYPE_GREEN_METADATA
@ H264_SEI_TYPE_GREEN_METADATA
GreenMPEG information.
Definition: h264_sei.h:38
H264SEIDisplayOrientation::hflip
int hflip
Definition: h264_sei.h:161
H264SEIContext::afd
H264SEIAFD afd
Definition: h264_sei.h:184
H264SEITimeCode::seconds
int seconds
Definition: h264_sei.h:76
H264SEIAlternativeTransfer::present
int present
Definition: h264_sei.h:178
H264SEITimeCode::full
int full
Definition: h264_sei.h:74
H264_SEI_FpaType
H264_SEI_FpaType
frame_packing_arrangement types
Definition: h264_sei.h:61
ff_h264_sei_uninit
void ff_h264_sei_uninit(H264SEIContext *h)
Reset SEI values at the beginning of the frame.
Definition: h264_sei.c:41
H264_SEI_TYPE_RECOVERY_POINT
@ H264_SEI_TYPE_RECOVERY_POINT
recovery point (frame # to decoder sync)
Definition: h264_sei.h:35
H264SEIRecoveryPoint::recovery_frame_cnt
int recovery_frame_cnt
recovery_frame_cnt
Definition: h264_sei.h:139
H264SEIPictureTiming::timecode_cnt
int timecode_cnt
Number of timecode in use.
Definition: h264_sei.h:115
H264_SEI_PIC_STRUCT_TOP_BOTTOM
@ H264_SEI_PIC_STRUCT_TOP_BOTTOM
3: top field, bottom field, in that order
Definition: h264_sei.h:50
H264SEIFramePacking::arrangement_repetition_period
int arrangement_repetition_period
Definition: h264_sei.h:152
H264_SEI_FPA_TYPE_CHECKERBOARD
@ H264_SEI_FPA_TYPE_CHECKERBOARD
Definition: h264_sei.h:62
H264SEIContext::a53_caption
H264SEIA53Caption a53_caption
Definition: h264_sei.h:185
H264SEIGreenMetaData::xsd_metric_value
uint16_t xsd_metric_value
Definition: h264_sei.h:174
H264SEIGreenMetaData::period_type
uint8_t period_type
Definition: h264_sei.h:166
H264SEITimeCode::minutes
int minutes
Definition: h264_sei.h:77
H264_SEI_TYPE_USER_DATA_REGISTERED
@ H264_SEI_TYPE_USER_DATA_REGISTERED
registered user data as specified by Rec. ITU-T T.35
Definition: h264_sei.h:33
H264SEIAFD
Definition: h264_sei.h:118
H264SEIGreenMetaData::percent_non_zero_macroblocks
uint8_t percent_non_zero_macroblocks
Definition: h264_sei.h:169
H264SEIA53Caption
Definition: h264_sei.h:123
GetBitContext
Definition: get_bits.h:61
H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME
@ H264_SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME
mastering display properties
Definition: h264_sei.h:39
H264SEIPictureTiming::present
int present
Definition: h264_sei.h:87
H264_SEI_FPA_TYPE_SIDE_BY_SIDE
@ H264_SEI_FPA_TYPE_SIDE_BY_SIDE
Definition: h264_sei.h:65
H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL
@ H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL
Definition: h264_sei.h:67
H264SEIAlternativeTransfer
Definition: h264_sei.h:177
ff_h264_sei_decode
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, const struct H264ParamSets *ps, void *logctx)
H264_SEI_FPA_TYPE_TOP_BOTTOM
@ H264_SEI_FPA_TYPE_TOP_BOTTOM
Definition: h264_sei.h:66
H264SEIFramePacking::arrangement_cancel_flag
int arrangement_cancel_flag
is previous arrangement canceled, -1 if never received
Definition: h264_sei.h:150
H264SEIA53Caption::buf_ref
AVBufferRef * buf_ref
Definition: h264_sei.h:124
H264SEIBufferingPeriod::present
int present
Buffering period SEI flag.
Definition: h264_sei.h:143
H264SEIBufferingPeriod::initial_cpb_removal_delay
int initial_cpb_removal_delay[32]
Initial timestamps for CPBs.
Definition: h264_sei.h:144
get_bits.h
H264SEIContext::alternative_transfer
H264SEIAlternativeTransfer alternative_transfer
Definition: h264_sei.h:192
H264SEIGreenMetaData::percent_alpha_point_deblocking_instance
uint8_t percent_alpha_point_deblocking_instance
Definition: h264_sei.h:172
H264SEIFramePacking::arrangement_type
H264_SEI_FpaType arrangement_type
Definition: h264_sei.h:151
H264SEIPictureTiming::dpb_output_delay
int dpb_output_delay
dpb_output_delay in picture timing SEI message, see H.264 C.2.2
Definition: h264_sei.h:100
H264SEIContext::recovery_point
H264SEIRecoveryPoint recovery_point
Definition: h264_sei.h:187
H264SEIContext
Definition: h264_sei.h:182
H264SEIFramePacking::arrangement_id
int arrangement_id
Definition: h264_sei.h:149
H264SEIUnregistered
Definition: h264_sei.h:127
SPS
Sequence parameter set.
Definition: h264_ps.h:44
H264SEIFramePacking::quincunx_sampling_flag
int quincunx_sampling_flag
Definition: h264_sei.h:154
H264SEIPictureTiming::ct_type
int ct_type
Bit set of clock types for fields/frames in picture timing SEI message.
Definition: h264_sei.h:95
H264SEIFramePacking::content_interpretation_type
int content_interpretation_type
Definition: h264_sei.h:153
H264SEIGreenMetaData
Definition: h264_sei.h:164
H264SEIRecoveryPoint
Definition: h264_sei.h:131
H264SEIGreenMetaData::percent_intra_coded_macroblocks
uint8_t percent_intra_coded_macroblocks
Definition: h264_sei.h:170
h264_ps.h
H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM
@ H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM
6: bottom field, top field, bottom field repeated, in that order
Definition: h264_sei.h:53
H264SEIPictureTiming
Definition: h264_sei.h:82
H264SEIContext::frame_packing
H264SEIFramePacking frame_packing
Definition: h264_sei.h:189
H264SEIGreenMetaData::percent_six_tap_filtering
uint8_t percent_six_tap_filtering
Definition: h264_sei.h:171
H264SEIGreenMetaData::num_seconds
uint16_t num_seconds
Definition: h264_sei.h:167
H264SEIFramePacking
Definition: h264_sei.h:147
H264SEIUnregistered::x264_build
int x264_build
Definition: h264_sei.h:128
H264SEIFramePacking::present
int present
Definition: h264_sei.h:148
H264SEIAFD::active_format_description
uint8_t active_format_description
Definition: h264_sei.h:120
H264_SEI_PIC_STRUCT_BOTTOM_TOP
@ H264_SEI_PIC_STRUCT_BOTTOM_TOP
4: bottom field, top field, in that order
Definition: h264_sei.h:51
H264SEIGreenMetaData::green_metadata_type
uint8_t green_metadata_type
Definition: h264_sei.h:165
H264SEITimeCode::frame
int frame
Definition: h264_sei.h:75
H264_SEI_FPA_TYPE_INTERLEAVE_COLUMN
@ H264_SEI_FPA_TYPE_INTERLEAVE_COLUMN
Definition: h264_sei.h:63
H264_SEI_TYPE_USER_DATA_UNREGISTERED
@ H264_SEI_TYPE_USER_DATA_UNREGISTERED
unregistered user data
Definition: h264_sei.h:34
H264_SEI_TYPE_FILLER_PAYLOAD
@ H264_SEI_TYPE_FILLER_PAYLOAD
filler data
Definition: h264_sei.h:32
H264_SEI_TYPE_FRAME_PACKING
@ H264_SEI_TYPE_FRAME_PACKING
frame packing arrangement
Definition: h264_sei.h:36
H264SEIDisplayOrientation::anticlockwise_rotation
int anticlockwise_rotation
Definition: h264_sei.h:160
H264SEIContext::green_metadata
H264SEIGreenMetaData green_metadata
Definition: h264_sei.h:191
H264_SEI_PIC_STRUCT_FRAME
@ H264_SEI_PIC_STRUCT_FRAME
0: frame
Definition: h264_sei.h:47
H264_SEI_PIC_STRUCT_FRAME_TRIPLING
@ H264_SEI_PIC_STRUCT_FRAME_TRIPLING
8: frame tripling
Definition: h264_sei.h:55
H264SEITimeCode
Definition: h264_sei.h:71
H264_SEI_PIC_STRUCT_FRAME_DOUBLING
@ H264_SEI_PIC_STRUCT_FRAME_DOUBLING
7: frame doubling
Definition: h264_sei.h:54
uint8_t
uint8_t
Definition: audio_convert.c:194
H264SEIBufferingPeriod
Definition: h264_sei.h:142
H264SEIContext::buffering_period
H264SEIBufferingPeriod buffering_period
Definition: h264_sei.h:188
H264_SEI_FPA_TYPE_INTERLEAVE_ROW
@ H264_SEI_FPA_TYPE_INTERLEAVE_ROW
Definition: h264_sei.h:64
H264_SEI_TYPE_DISPLAY_ORIENTATION
@ H264_SEI_TYPE_DISPLAY_ORIENTATION
display orientation
Definition: h264_sei.h:37
H264_SEI_TYPE_PAN_SCAN_RECT
@ H264_SEI_TYPE_PAN_SCAN_RECT
pan-scan rectangle
Definition: h264_sei.h:31
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:260
H264SEIPictureTiming::payload_size_bits
int payload_size_bits
Definition: h264_sei.h:85
H264SEITimeCode::hours
int hours
Definition: h264_sei.h:78
H264ParamSets
Definition: h264_ps.h:143
H264SEIDisplayOrientation::vflip
int vflip
Definition: h264_sei.h:161
H264SEIDisplayOrientation
Definition: h264_sei.h:158
H264SEIFramePacking::current_frame_is_frame0_flag
int current_frame_is_frame0_flag
Definition: h264_sei.h:155
H264SEIContext::display_orientation
H264SEIDisplayOrientation display_orientation
Definition: h264_sei.h:190
H264SEIDisplayOrientation::present
int present
Definition: h264_sei.h:159
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:81
ff_h264_sei_process_picture_timing
int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps, void *logctx)
Parse the contents of a picture timing message given an active SPS.
Definition: h264_sei.c:57
H264_SEI_TYPE_PIC_TIMING
@ H264_SEI_TYPE_PIC_TIMING
picture timing
Definition: h264_sei.h:30
H264_SEI_Type
H264_SEI_Type
SEI message types.
Definition: h264_sei.h:28
H264SEIAlternativeTransfer::preferred_transfer_characteristics
int preferred_transfer_characteristics
Definition: h264_sei.h:179
H264_SEI_PIC_STRUCT_BOTTOM_FIELD
@ H264_SEI_PIC_STRUCT_BOTTOM_FIELD
2: bottom field
Definition: h264_sei.h:49
H264_SEI_FPA_TYPE_2D
@ H264_SEI_FPA_TYPE_2D
Definition: h264_sei.h:68
H264SEITimeCode::dropframe
int dropframe
Definition: h264_sei.h:79
H264SEIContext::unregistered
H264SEIUnregistered unregistered
Definition: h264_sei.h:186
H264SEIPictureTiming::cpb_removal_delay
int cpb_removal_delay
cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
Definition: h264_sei.h:105
H264SEIPictureTiming::payload
uint8_t payload[40]
Definition: h264_sei.h:84
H264_SEI_PicStructType
H264_SEI_PicStructType
pic_struct in picture timing SEI message
Definition: h264_sei.h:46
h
h
Definition: vp9dsp_template.c:2038
H264SEIGreenMetaData::num_pictures
uint16_t num_pictures
Definition: h264_sei.h:168
ff_h264_sei_stereo_mode
const char * ff_h264_sei_stereo_mode(const H264SEIFramePacking *h)
Get stereo_mode string from the h264 frame_packing_arrangement.
Definition: h264_sei.c:498
H264_SEI_PIC_STRUCT_TOP_FIELD
@ H264_SEI_PIC_STRUCT_TOP_FIELD
1: top field
Definition: h264_sei.h:48
H264_SEI_TYPE_ALTERNATIVE_TRANSFER
@ H264_SEI_TYPE_ALTERNATIVE_TRANSFER
alternative transfer
Definition: h264_sei.h:40
H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP
@ H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP
5: top field, bottom field, top field repeated, in that order
Definition: h264_sei.h:52
H264SEIPictureTiming::timecode
H264SEITimeCode timecode[3]
Maximum three timecodes in a pic_timing SEI.
Definition: h264_sei.h:110
H264SEIContext::picture_timing
H264SEIPictureTiming picture_timing
Definition: h264_sei.h:183
H264SEIGreenMetaData::xsd_metric_type
uint8_t xsd_metric_type
Definition: h264_sei.h:173