1 /*
2 * HEVC Supplementary Enhancement Information messages
3 *
4 * Copyright (C) 2012 - 2013 Guillaume Martres
5 * Copyright (C) 2012 - 2013 Gildas Cocherel
6 * Copyright (C) 2013 Vittorio Giovara
7 *
8 * This file is part of FFmpeg.
9 *
10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
29
32 {
33 int cIdx;
34 uint8_t hash_type;
35 //uint16_t picture_crc;
36 //uint32_t picture_checksum;
37 hash_type = bytestream2_get_byte(gb);
38
39 for (cIdx = 0; cIdx < 3/*((s->sps->chroma_format_idc == 0) ? 1 : 3)*/; cIdx++) {
40 if (hash_type == 0) {
43 } else if (hash_type == 1) {
44 // picture_crc = get_bits(gb, 16);
45 } else if (hash_type == 2) {
46 // picture_checksum = get_bits_long(gb, 32);
47 }
48 }
49 return 0;
50 }
51
54 {
57
60
61 if (
sps->vui.frame_field_info_present_flag) {
64 if (pic_struct == 2 || pic_struct == 10 || pic_struct == 12) {
67 } else if (pic_struct == 1 || pic_struct == 9 || pic_struct == 11) {
70 } else if (pic_struct == 7) {
73 } else if (pic_struct == 8) {
76 }
77 }
78
79 return 0;
80 }
81
83 {
84 int num_sps_ids_minus1;
85 unsigned active_seq_parameter_set_id;
86
87 get_bits(gb, 4);
// active_video_parameter_set_id
88 get_bits(gb, 1);
// self_contained_cvs_flag
89 get_bits(gb, 1);
// num_sps_ids_minus1
91
92 if (num_sps_ids_minus1 < 0 || num_sps_ids_minus1 > 15) {
95 }
96
99 av_log(logctx,
AV_LOG_ERROR,
"active_parameter_set_id %d invalid\n", active_seq_parameter_set_id);
101 }
102 s->active_seq_parameter_set_id = active_seq_parameter_set_id;
103
104 return 0;
105 }
106
108 {
110
111 for (
int i = 0;
i <
s->num_clock_ts;
i++) {
113
114 if (
s->clock_timestamp_flag[
i]) {
115 s->units_field_based_flag[
i] =
get_bits(gb, 1);
120
122
123 if (
s->full_timestamp_flag[
i]) {
127 } else {
129 if (
s->seconds_flag[
i]) {
132 if (
s->minutes_flag[
i]) {
135 if (
s->hours_flag[
i]) {
137 }
138 }
139 }
140 }
141
143 if (
s->time_offset_length[
i] > 0) {
145 }
146 }
147 }
148
150 return 0;
151 }
152
154 {
156 if (
s->prec_ref_display_width > 31)
159 if (
s->ref_viewing_distance_flag) {
161 if (
s->prec_ref_viewing_dist > 31)
163 }
165 if (
s->num_ref_displays > 31)
167 s->num_ref_displays += 1;
168
169 for (
int i = 0;
i <
s->num_ref_displays;
i++) {
170 int length;
173 s->exponent_ref_display_width[
i] =
get_bits(gb, 6);
174 if (
s->exponent_ref_display_width[
i] > 62)
176 else if (!
s->exponent_ref_display_width[
i])
177 length =
FFMAX(0, (
int)
s->prec_ref_display_width - 30);
178 else
179 length =
FFMAX(0, (
int)
s->exponent_ref_display_width[
i] +
180 (
int)
s->prec_ref_display_width - 31);
182 if (
s->ref_viewing_distance_flag) {
183 s->exponent_ref_viewing_distance[
i] =
get_bits(gb, 6);
184 if (
s->exponent_ref_viewing_distance[
i] > 62)
186 else if (!
s->exponent_ref_viewing_distance[
i])
187 length =
FFMAX(0, (
int)
s->prec_ref_viewing_dist - 30);
188 else
189 length =
FFMAX(0, (
int)
s->exponent_ref_viewing_distance[
i] +
190 (
int)
s->prec_ref_viewing_dist - 31);
192 }
193 s->additional_shift_present_flag[
i] =
get_bits1(gb);
194 if (
s->additional_shift_present_flag[
i]) {
196 if (
s->num_sample_shift[
i] > 1023)
198 s->num_sample_shift[
i] -= 512;
199 }
200 }
201 s->three_dimensional_reference_displays_extension_flag =
get_bits1(gb);
202
203 return 0;
204 }
205
209 {
211 case 256: // Mismatched value from HM 8.1
221 default: {
223 gb, gbyte, logctx);
227 }
228 }
229 }
230
233 {
237 default:
239 return 0;
240 }
241 }
242
245 {
248 int payload_type = 0;
249 int payload_size = 0;
250 int byte = 0xFF;
253
254 while (byte == 0xFF) {
257 byte = bytestream2_get_byteu(gb);
258 payload_type +=
byte;
259 }
260 byte = 0xFF;
261 while (byte == 0xFF) {
264 byte = bytestream2_get_byteu(gb);
265 payload_size +=
byte;
266 }
275 logctx,
s, ps, payload_type);
276 } else { /* nal_unit_type == NAL_SEI_SUFFIX */
278 logctx,
s, payload_type);
279 }
280 }
281
284 {
287
291
292 do {
297 return 1;
298 }