]> git.sesse.net Git - ffmpeg/blob - libavcodec/hevc_sei.h
avformat/hlsenc: reindent the code
[ffmpeg] / libavcodec / hevc_sei.h
1 /*
2  * HEVC Supplementary Enhancement Information messages
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef AVCODEC_HEVC_SEI_H
22 #define AVCODEC_HEVC_SEI_H
23
24 #include <stdint.h>
25
26 #include "get_bits.h"
27
28 /**
29  * SEI message types
30  */
31 typedef enum {
32     HEVC_SEI_TYPE_BUFFERING_PERIOD                     = 0,
33     HEVC_SEI_TYPE_PICTURE_TIMING                       = 1,
34     HEVC_SEI_TYPE_PAN_SCAN_RECT                        = 2,
35     HEVC_SEI_TYPE_FILLER_PAYLOAD                       = 3,
36     HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35       = 4,
37     HEVC_SEI_TYPE_USER_DATA_UNREGISTERED               = 5,
38     HEVC_SEI_TYPE_RECOVERY_POINT                       = 6,
39     HEVC_SEI_TYPE_SCENE_INFO                           = 9,
40     HEVC_SEI_TYPE_FULL_FRAME_SNAPSHOT                  = 15,
41     HEVC_SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
42     HEVC_SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
43     HEVC_SEI_TYPE_FILM_GRAIN_CHARACTERISTICS           = 19,
44     HEVC_SEI_TYPE_POST_FILTER_HINT                     = 22,
45     HEVC_SEI_TYPE_TONE_MAPPING_INFO                    = 23,
46     HEVC_SEI_TYPE_FRAME_PACKING                        = 45,
47     HEVC_SEI_TYPE_DISPLAY_ORIENTATION                  = 47,
48     HEVC_SEI_TYPE_SOP_DESCRIPTION                      = 128,
49     HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS                = 129,
50     HEVC_SEI_TYPE_DECODING_UNIT_INFO                   = 130,
51     HEVC_SEI_TYPE_TEMPORAL_LEVEL0_INDEX                = 131,
52     HEVC_SEI_TYPE_DECODED_PICTURE_HASH                 = 132,
53     HEVC_SEI_TYPE_SCALABLE_NESTING                     = 133,
54     HEVC_SEI_TYPE_REGION_REFRESH_INFO                  = 134,
55     HEVC_SEI_TYPE_TIME_CODE                            = 136,
56     HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO               = 137,
57     HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO             = 144,
58     HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147,
59     HEVC_SEI_TYPE_ALPHA_CHANNEL_INFO                   = 165,
60 } HEVC_SEI_Type;
61
62 typedef enum {
63         HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING = 7,
64         HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING = 8
65 } HEVC_SEI_PicStructType;
66
67 typedef struct HEVCSEIPictureHash {
68     uint8_t       md5[3][16];
69     uint8_t is_md5;
70 } HEVCSEIPictureHash;
71
72 typedef struct HEVCSEIFramePacking {
73     int present;
74     int arrangement_type;
75     int content_interpretation_type;
76     int quincunx_subsampling;
77     int current_frame_is_frame0_flag;
78 } HEVCSEIFramePacking;
79
80 typedef struct HEVCSEIDisplayOrientation {
81     int present;
82     int anticlockwise_rotation;
83     int hflip, vflip;
84 } HEVCSEIDisplayOrientation;
85
86 typedef struct HEVCSEIPictureTiming {
87     int picture_struct;
88 } HEVCSEIPictureTiming;
89
90 typedef struct HEVCSEIA53Caption {
91     AVBufferRef *buf_ref;
92 } HEVCSEIA53Caption;
93
94 typedef struct HEVCSEIUnregistered {
95     AVBufferRef **buf_ref;
96     int nb_buf_ref;
97 } HEVCSEIUnregistered;
98
99 typedef struct HEVCSEIMasteringDisplay {
100     int present;
101     uint16_t display_primaries[3][2];
102     uint16_t white_point[2];
103     uint32_t max_luminance;
104     uint32_t min_luminance;
105 } HEVCSEIMasteringDisplay;
106
107 typedef struct HEVCSEIDynamicHDRPlus {
108     AVBufferRef *info;
109 } HEVCSEIDynamicHDRPlus;
110
111 typedef struct HEVCSEIContentLight {
112     int present;
113     uint16_t max_content_light_level;
114     uint16_t max_pic_average_light_level;
115 } HEVCSEIContentLight;
116
117 typedef struct HEVCSEIAlternativeTransfer {
118     int present;
119     int preferred_transfer_characteristics;
120 } HEVCSEIAlternativeTransfer;
121
122 typedef struct HEVCSEITimeCode {
123     int      present;
124     uint8_t  num_clock_ts;
125     uint8_t  clock_timestamp_flag[3];
126     uint8_t  units_field_based_flag[3];
127     uint8_t  counting_type[3];
128     uint8_t  full_timestamp_flag[3];
129     uint8_t  discontinuity_flag[3];
130     uint8_t  cnt_dropped_flag[3];
131     uint16_t n_frames[3];
132     uint8_t  seconds_value[3];
133     uint8_t  minutes_value[3];
134     uint8_t  hours_value[3];
135     uint8_t  seconds_flag[3];
136     uint8_t  minutes_flag[3];
137     uint8_t  hours_flag[3];
138     uint8_t  time_offset_length[3];
139     int32_t  time_offset_value[3];
140 } HEVCSEITimeCode;
141
142 typedef struct HEVCSEI {
143     HEVCSEIPictureHash picture_hash;
144     HEVCSEIFramePacking frame_packing;
145     HEVCSEIDisplayOrientation display_orientation;
146     HEVCSEIPictureTiming picture_timing;
147     HEVCSEIA53Caption a53_caption;
148     HEVCSEIUnregistered unregistered;
149     HEVCSEIMasteringDisplay mastering_display;
150     HEVCSEIDynamicHDRPlus dynamic_hdr_plus;
151     HEVCSEIContentLight content_light;
152     int active_seq_parameter_set_id;
153     HEVCSEIAlternativeTransfer alternative_transfer;
154     HEVCSEITimeCode timecode;
155 } HEVCSEI;
156
157 struct HEVCParamSets;
158
159 int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
160                            const struct HEVCParamSets *ps, int type);
161
162 /**
163  * Reset SEI values that are stored on the Context.
164  * e.g. Caption data that was extracted during NAL
165  * parsing.
166  *
167  * @param s HEVCContext.
168  */
169 void ff_hevc_reset_sei(HEVCSEI *s);
170
171 #endif /* AVCODEC_HEVC_SEI_H */