58f5ecc5a9fe495172d9e757f68b403fc09c69c5
[libav.git] / libavcodec / h264_sei.h
1 /*
2 * This file is part of Libav.
3 *
4 * Libav 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 * Libav 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 Libav; 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
24 /**
25 * SEI message types
26 */
27 typedef enum {
28 SEI_TYPE_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1)
29 SEI_TYPE_PIC_TIMING = 1, ///< picture timing
30 SEI_TYPE_USER_DATA_REGISTERED = 4, ///< registered user data as specified by Rec. ITU-T T.35
31 SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data
32 SEI_TYPE_RECOVERY_POINT = 6, ///< recovery point (frame # to decoder sync)
33 SEI_TYPE_FRAME_PACKING = 45, ///< frame packing arrangement
34 SEI_TYPE_DISPLAY_ORIENTATION = 47, ///< display orientation
35 } SEI_Type;
36
37 /**
38 * pic_struct in picture timing SEI message
39 */
40 typedef enum {
41 SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame
42 SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field
43 SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field
44 SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order
45 SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order
46 SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order
47 SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order
48 SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling
49 SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling
50 } SEI_PicStructType;
51
52 typedef struct H264SEIPictureTiming {
53 SEI_PicStructType pic_struct;
54
55 /**
56 * Bit set of clock types for fields/frames in picture timing SEI message.
57 * For each found ct_type, appropriate bit is set (e.g., bit 1 for
58 * interlaced).
59 */
60 int ct_type;
61
62 /**
63 * dpb_output_delay in picture timing SEI message, see H.264 C.2.2
64 */
65 int dpb_output_delay;
66
67 /**
68 * cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
69 */
70 int cpb_removal_delay;
71 } H264SEIPictureTiming;
72
73 typedef struct H264SEIAFD {
74 int present;
75 uint8_t active_format_description;
76 } H264SEIAFD;
77
78 typedef struct H264SEIA53Caption {
79 int a53_caption_size;
80 uint8_t *a53_caption;
81 } H264SEIA53Caption;
82
83 typedef struct H264SEIUnregistered {
84 int x264_build;
85 } H264SEIUnregistered;
86
87 typedef struct H264SEIRecoveryPoint {
88 /**
89 * recovery_frame_cnt
90 *
91 * Set to -1 if no recovery point SEI message found or to number of frames
92 * before playback synchronizes. Frames having recovery point are key
93 * frames.
94 */
95 int recovery_frame_cnt;
96 } H264SEIRecoveryPoint;
97
98 typedef struct H264SEIBufferingPeriod {
99 int present; ///< Buffering period SEI flag
100 int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
101 } H264SEIBufferingPeriod;
102
103 typedef struct H264SEIFramePacking {
104 int present;
105 int arrangement_type;
106 int content_interpretation_type;
107 int quincunx_subsampling;
108 } H264SEIFramePacking;
109
110 typedef struct H264SEIDisplayOrientation {
111 int present;
112 int anticlockwise_rotation;
113 int hflip, vflip;
114 } H264SEIDisplayOrientation;
115
116 typedef struct H264SEIContext {
117 H264SEIPictureTiming picture_timing;
118 H264SEIAFD afd;
119 H264SEIA53Caption a53_caption;
120 H264SEIUnregistered unregistered;
121 H264SEIRecoveryPoint recovery_point;
122 H264SEIBufferingPeriod buffering_period;
123 H264SEIFramePacking frame_packing;
124 H264SEIDisplayOrientation display_orientation;
125 } H264SEIContext;
126
127 struct H264ParamSets;
128
129 int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
130 const struct H264ParamSets *ps, void *logctx);
131
132 /**
133 * Reset SEI values at the beginning of the frame.
134 */
135 void ff_h264_sei_uninit(H264SEIContext *h);
136
137 #endif /* AVCODEC_H264_SEI_H */