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 "h2645_sei.h"
24 #include "h264_ps.h"
25 #include "sei.h"
26 
27 
28 /**
29  * pic_struct in picture timing SEI message
30  */
31 typedef enum {
32  H264_SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame
33  H264_SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field
34  H264_SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field
35  H264_SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order
36  H264_SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order
37  H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order
38  H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order
39  H264_SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling
40  H264_SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling
42 
43 typedef struct H264SEITimeCode {
44  /* When not continuously receiving full timecodes, we have to reference
45  the previous timecode received */
46  int full;
47  int frame;
48  int seconds;
49  int minutes;
50  int hours;
51  int dropframe;
53 
54 typedef struct H264SEIPictureTiming {
55  // maximum size of pic_timing according to the spec should be 274 bits
56  uint8_t payload[40];
58 
59  int present;
61 
62  /**
63  * Bit set of clock types for fields/frames in picture timing SEI message.
64  * For each found ct_type, appropriate bit is set (e.g., bit 1 for
65  * interlaced).
66  */
67  int ct_type;
68 
69  /**
70  * dpb_output_delay in picture timing SEI message, see H.264 C.2.2
71  */
73 
74  /**
75  * cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
76  */
78 
79  /**
80  * Maximum three timecodes in a pic_timing SEI.
81  */
83 
84  /**
85  * Number of timecode in use
86  */
89 
90 typedef struct H264SEIRecoveryPoint {
91  /**
92  * recovery_frame_cnt
93  *
94  * Set to -1 if no recovery point SEI message found or to number of frames
95  * before playback synchronizes. Frames having recovery point are key
96  * frames.
97  */
100 
101 typedef struct H264SEIBufferingPeriod {
102  int present; ///< Buffering period SEI flag
103  int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
105 
106 typedef struct H264SEIGreenMetaData {
108  uint8_t period_type;
109  uint16_t num_seconds;
110  uint16_t num_pictures;
118 
119 typedef struct H264SEIContext {
126 
127 struct H264ParamSets;
128 
130  const struct H264ParamSets *ps, void *logctx);
131 
132 /**
133  * Reset SEI values at the beginning of the frame.
134  */
136 
137 /**
138  * Get stereo_mode string from the h264 frame_packing_arrangement
139  */
141 
142 /**
143  * Parse the contents of a picture timing message given an active SPS.
144  */
146  void *logctx);
147 
148 #endif /* AVCODEC_H264_SEI_H */
H264SEIPictureTiming::pic_struct
H264_SEI_PicStructType pic_struct
Definition: h264_sei.h:60
H264SEITimeCode::seconds
int seconds
Definition: h264_sei.h:48
H2645SEIFramePacking
Definition: h2645_sei.h:63
H264SEITimeCode::full
int full
Definition: h264_sei.h:46
ff_h264_sei_uninit
void ff_h264_sei_uninit(H264SEIContext *h)
Reset SEI values at the beginning of the frame.
Definition: h264_sei.c:48
H264SEIRecoveryPoint::recovery_frame_cnt
int recovery_frame_cnt
recovery_frame_cnt
Definition: h264_sei.h:98
H264SEIPictureTiming::timecode_cnt
int timecode_cnt
Number of timecode in use.
Definition: h264_sei.h:87
H264_SEI_PIC_STRUCT_TOP_BOTTOM
@ H264_SEI_PIC_STRUCT_TOP_BOTTOM
3: top field, bottom field, in that order
Definition: h264_sei.h:35
H264SEIGreenMetaData::xsd_metric_value
uint16_t xsd_metric_value
Definition: h264_sei.h:116
H264SEIGreenMetaData::period_type
uint8_t period_type
Definition: h264_sei.h:108
H264SEITimeCode::minutes
int minutes
Definition: h264_sei.h:49
H264SEIGreenMetaData::percent_non_zero_macroblocks
uint8_t percent_non_zero_macroblocks
Definition: h264_sei.h:111
GetBitContext
Definition: get_bits.h:108
H264SEIPictureTiming::present
int present
Definition: h264_sei.h:59
ff_h264_sei_decode
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, const struct H264ParamSets *ps, void *logctx)
H264SEIBufferingPeriod::present
int present
Buffering period SEI flag.
Definition: h264_sei.h:102
H264SEIBufferingPeriod::initial_cpb_removal_delay
int initial_cpb_removal_delay[32]
Initial timestamps for CPBs.
Definition: h264_sei.h:103
get_bits.h
H264SEIGreenMetaData::percent_alpha_point_deblocking_instance
uint8_t percent_alpha_point_deblocking_instance
Definition: h264_sei.h:114
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:72
H264SEIContext::recovery_point
H264SEIRecoveryPoint recovery_point
Definition: h264_sei.h:122
H264SEIContext
Definition: h264_sei.h:119
SPS
Sequence parameter set.
Definition: h264_ps.h:44
ff_h264_sei_stereo_mode
const char * ff_h264_sei_stereo_mode(const H2645SEIFramePacking *h)
Get stereo_mode string from the h264 frame_packing_arrangement.
Definition: h264_sei.c:305
sei.h
H2645SEI
Definition: h2645_sei.h:128
H264SEIPictureTiming::ct_type
int ct_type
Bit set of clock types for fields/frames in picture timing SEI message.
Definition: h264_sei.h:67
H264SEIGreenMetaData
Definition: h264_sei.h:106
H264SEIRecoveryPoint
Definition: h264_sei.h:90
H264SEIGreenMetaData::percent_intra_coded_macroblocks
uint8_t percent_intra_coded_macroblocks
Definition: h264_sei.h:112
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:38
H264SEIPictureTiming
Definition: h264_sei.h:54
H264SEIGreenMetaData::percent_six_tap_filtering
uint8_t percent_six_tap_filtering
Definition: h264_sei.h:113
H264SEIGreenMetaData::num_seconds
uint16_t num_seconds
Definition: h264_sei.h:109
h2645_sei.h
H264_SEI_PIC_STRUCT_BOTTOM_TOP
@ H264_SEI_PIC_STRUCT_BOTTOM_TOP
4: bottom field, top field, in that order
Definition: h264_sei.h:36
H264SEIGreenMetaData::green_metadata_type
uint8_t green_metadata_type
Definition: h264_sei.h:107
H264SEITimeCode::frame
int frame
Definition: h264_sei.h:47
H264SEIContext::green_metadata
H264SEIGreenMetaData green_metadata
Definition: h264_sei.h:124
H264_SEI_PIC_STRUCT_FRAME
@ H264_SEI_PIC_STRUCT_FRAME
0: frame
Definition: h264_sei.h:32
H264_SEI_PIC_STRUCT_FRAME_TRIPLING
@ H264_SEI_PIC_STRUCT_FRAME_TRIPLING
8: frame tripling
Definition: h264_sei.h:40
H264SEITimeCode
Definition: h264_sei.h:43
H264_SEI_PIC_STRUCT_FRAME_DOUBLING
@ H264_SEI_PIC_STRUCT_FRAME_DOUBLING
7: frame doubling
Definition: h264_sei.h:39
H264SEIBufferingPeriod
Definition: h264_sei.h:101
H264SEIContext::buffering_period
H264SEIBufferingPeriod buffering_period
Definition: h264_sei.h:123
H264SEIContext::common
H2645SEI common
Definition: h264_sei.h:120
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:260
H264SEIPictureTiming::payload_size_bytes
int payload_size_bytes
Definition: h264_sei.h:57
H264SEITimeCode::hours
int hours
Definition: h264_sei.h:50
H264ParamSets
Definition: h264_ps.h:144
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:64
H264_SEI_PIC_STRUCT_BOTTOM_FIELD
@ H264_SEI_PIC_STRUCT_BOTTOM_FIELD
2: bottom field
Definition: h264_sei.h:34
H264SEITimeCode::dropframe
int dropframe
Definition: h264_sei.h:51
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:77
H264SEIPictureTiming::payload
uint8_t payload[40]
Definition: h264_sei.h:56
H264_SEI_PicStructType
H264_SEI_PicStructType
pic_struct in picture timing SEI message
Definition: h264_sei.h:31
h
h
Definition: vp9dsp_template.c:2070
H264SEIGreenMetaData::num_pictures
uint16_t num_pictures
Definition: h264_sei.h:110
H264_SEI_PIC_STRUCT_TOP_FIELD
@ H264_SEI_PIC_STRUCT_TOP_FIELD
1: top field
Definition: h264_sei.h:33
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:37
H264SEIPictureTiming::timecode
H264SEITimeCode timecode[3]
Maximum three timecodes in a pic_timing SEI.
Definition: h264_sei.h:82
H264SEIContext::picture_timing
H264SEIPictureTiming picture_timing
Definition: h264_sei.h:121
H264SEIGreenMetaData::xsd_metric_type
uint8_t xsd_metric_type
Definition: h264_sei.h:115