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 "libavutil/buffer.h" 27 28 #include "get_bits.h" 29 #include "hevc.h" 30 #include "sei.h" 31 32 33 typedef enum { 34 HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING = 7, 35 HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING = 8 36 } HEVC_SEI_PicStructType; 37 38 typedef struct HEVCSEIPictureHash { 39 uint8_t md5[3][16]; 40 uint8_t is_md5; 41 } HEVCSEIPictureHash; 42 43 typedef struct HEVCSEIFramePacking { 44 int present; 45 int arrangement_type; 46 int content_interpretation_type; 47 int quincunx_subsampling; 48 int current_frame_is_frame0_flag; 49 } HEVCSEIFramePacking; 50 51 typedef struct HEVCSEIDisplayOrientation { 52 int present; 53 int anticlockwise_rotation; 54 int hflip, vflip; 55 } HEVCSEIDisplayOrientation; 56 57 typedef struct HEVCSEIPictureTiming { 58 int picture_struct; 59 } HEVCSEIPictureTiming; 60 61 typedef struct HEVCSEIA53Caption { 62 AVBufferRef *buf_ref; 63 } HEVCSEIA53Caption; 64 65 typedef struct HEVCSEIUnregistered { 66 AVBufferRef **buf_ref; 67 int nb_buf_ref; 68 } HEVCSEIUnregistered; 69 70 typedef struct HEVCSEIMasteringDisplay { 71 int present; 72 uint16_t display_primaries[3][2]; 73 uint16_t white_point[2]; 74 uint32_t max_luminance; 75 uint32_t min_luminance; 76 } HEVCSEIMasteringDisplay; 77 78 typedef struct HEVCSEIDynamicHDRPlus { 79 AVBufferRef *info; 80 } HEVCSEIDynamicHDRPlus; 81 82 typedef struct HEVCSEIDynamicHDRVivid { 83 AVBufferRef *info; 84 } HEVCSEIDynamicHDRVivid; 85 86 typedef struct HEVCSEIContentLight { 87 int present; 88 uint16_t max_content_light_level; 89 uint16_t max_pic_average_light_level; 90 } HEVCSEIContentLight; 91 92 typedef struct HEVCSEIAlternativeTransfer { 93 int present; 94 int preferred_transfer_characteristics; 95 } HEVCSEIAlternativeTransfer; 96 97 typedef struct HEVCSEITimeCode { 98 int present; 99 uint8_t num_clock_ts; 100 uint8_t clock_timestamp_flag[3]; 101 uint8_t units_field_based_flag[3]; 102 uint8_t counting_type[3]; 103 uint8_t full_timestamp_flag[3]; 104 uint8_t discontinuity_flag[3]; 105 uint8_t cnt_dropped_flag[3]; 106 uint16_t n_frames[3]; 107 uint8_t seconds_value[3]; 108 uint8_t minutes_value[3]; 109 uint8_t hours_value[3]; 110 uint8_t seconds_flag[3]; 111 uint8_t minutes_flag[3]; 112 uint8_t hours_flag[3]; 113 uint8_t time_offset_length[3]; 114 int32_t time_offset_value[3]; 115 } HEVCSEITimeCode; 116 117 typedef struct HEVCSEIFilmGrainCharacteristics { 118 int present; 119 int model_id; 120 int separate_colour_description_present_flag; 121 int bit_depth_luma; 122 int bit_depth_chroma; 123 int full_range; 124 int color_primaries; 125 int transfer_characteristics; 126 int matrix_coeffs; 127 int blending_mode_id; 128 int log2_scale_factor; 129 int comp_model_present_flag[3]; 130 uint16_t num_intensity_intervals[3]; 131 uint8_t num_model_values[3]; 132 uint8_t intensity_interval_lower_bound[3][256]; 133 uint8_t intensity_interval_upper_bound[3][256]; 134 int16_t comp_model_value[3][256][6]; 135 int persistence_flag; 136 } HEVCSEIFilmGrainCharacteristics; 137 138 typedef struct HEVCSEI { 139 HEVCSEIPictureHash picture_hash; 140 HEVCSEIFramePacking frame_packing; 141 HEVCSEIDisplayOrientation display_orientation; 142 HEVCSEIPictureTiming picture_timing; 143 HEVCSEIA53Caption a53_caption; 144 HEVCSEIUnregistered unregistered; 145 HEVCSEIMasteringDisplay mastering_display; 146 HEVCSEIDynamicHDRPlus dynamic_hdr_plus; 147 HEVCSEIDynamicHDRVivid dynamic_hdr_vivid; 148 HEVCSEIContentLight content_light; 149 int active_seq_parameter_set_id; 150 HEVCSEIAlternativeTransfer alternative_transfer; 151 HEVCSEITimeCode timecode; 152 HEVCSEIFilmGrainCharacteristics film_grain_characteristics; 153 } HEVCSEI; 154 155 struct HEVCParamSets; 156 157 int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s, 158 const struct HEVCParamSets *ps, enum HEVCNALUnitType type); 159 160 /** 161 * Reset SEI values that are stored on the Context. 162 * e.g. Caption data that was extracted during NAL 163 * parsing. 164 * 165 * @param s HEVCContext. 166 */ 167 void ff_hevc_reset_sei(HEVCSEI *s); 168 169 #endif /* AVCODEC_HEVC_SEI_H */ 170