1 |
14 |
jamey.hick |
/*!
|
2 |
|
|
************************************************************************
|
3 |
|
|
* \file sei.c
|
4 |
|
|
*
|
5 |
|
|
* \brief
|
6 |
|
|
* Functions to implement SEI messages
|
7 |
|
|
*
|
8 |
|
|
* \author
|
9 |
|
|
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
10 |
|
|
* - Dong Tian <tian@cs.tut.fi>
|
11 |
|
|
* - Karsten Suehring <suehring@hhi.de>
|
12 |
|
|
************************************************************************
|
13 |
|
|
*/
|
14 |
|
|
|
15 |
|
|
#include "contributors.h"
|
16 |
|
|
|
17 |
|
|
#include <stdlib.h>
|
18 |
|
|
#include <assert.h>
|
19 |
|
|
#include <string.h>
|
20 |
|
|
|
21 |
|
|
#include "global.h"
|
22 |
|
|
#include "memalloc.h"
|
23 |
|
|
#include "sei.h"
|
24 |
|
|
#include "vlc.h"
|
25 |
|
|
#include "header.h"
|
26 |
|
|
#include "mbuffer.h"
|
27 |
|
|
#include "parset.h"
|
28 |
|
|
|
29 |
|
|
extern int UsedBits;
|
30 |
|
|
|
31 |
|
|
extern seq_parameter_set_rbsp_t SeqParSet[MAXSPS];
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
// #define PRINT_BUFFERING_PERIOD_INFO // uncomment to print buffering period SEI info
|
35 |
|
|
// #define PRINT_PCITURE_TIMING_INFO // uncomment to print picture timing SEI info
|
36 |
|
|
// #define WRITE_MAP_IMAGE // uncomment to write spare picture map
|
37 |
|
|
// #define PRINT_SUBSEQUENCE_INFO // uncomment to print sub-sequence SEI info
|
38 |
|
|
// #define PRINT_SUBSEQUENCE_LAYER_CHAR // uncomment to print sub-sequence layer characteristics SEI info
|
39 |
|
|
// #define PRINT_SUBSEQUENCE_CHAR // uncomment to print sub-sequence characteristics SEI info
|
40 |
|
|
// #define PRINT_SCENE_INFORMATION // uncomment to print scene information SEI info
|
41 |
|
|
// #define PRINT_PAN_SCAN_RECT // uncomment to print pan-scan rectangle SEI info
|
42 |
|
|
// #define PRINT_RECOVERY_POINT // uncomment to print random access point SEI info
|
43 |
|
|
// #define PRINT_FILLER_PAYLOAD_INFO // uncomment to print filler payload SEI info
|
44 |
|
|
// #define PRINT_DEC_REF_PIC_MARKING // uncomment to print decoded picture buffer management repetition SEI info
|
45 |
|
|
// #define PRINT_RESERVED_INFO // uncomment to print reserved SEI info
|
46 |
|
|
// #define PRINT_USER_DATA_UNREGISTERED_INFO // uncomment to print unregistered user data SEI info
|
47 |
|
|
// #define PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO // uncomment to print ITU-T T.35 user data SEI info
|
48 |
|
|
// #define PRINT_FULL_FRAME_FREEZE_INFO // uncomment to print full-frame freeze SEI info
|
49 |
|
|
// #define PRINT_FULL_FRAME_FREEZE_RELEASE_INFO // uncomment to print full-frame freeze release SEI info
|
50 |
|
|
// #define PRINT_FULL_FRAME_SNAPSHOT_INFO // uncomment to print full-frame snapshot SEI info
|
51 |
|
|
// #define PRINT_PROGRESSIVE_REFINEMENT_END_INFO // uncomment to print Progressive refinement segment start SEI info
|
52 |
|
|
// #define PRINT_PROGRESSIVE_REFINEMENT_END_INFO // uncomment to print Progressive refinement segment end SEI info
|
53 |
|
|
// #define PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO // uncomment to print Motion-constrained slice group set SEI info
|
54 |
|
|
// #define PRINT_FILM_GRAIN_CHARACTERISTICS_INFO // uncomment to print Film grain characteristics SEI info
|
55 |
|
|
// #define PRINT_DEBLOCKING_FILTER_DISPLAY_PREFERENCE_INFO // uncomment to print deblocking filter display preference SEI info
|
56 |
|
|
// #define PRINT_STEREO_VIDEO_INFO_INFO // uncomment to print stero video SEI info
|
57 |
|
|
|
58 |
|
|
/*!
|
59 |
|
|
************************************************************************
|
60 |
|
|
* \brief
|
61 |
|
|
* Interpret the SEI rbsp
|
62 |
|
|
* \param msg
|
63 |
|
|
* a pointer that point to the sei message.
|
64 |
|
|
* \param size
|
65 |
|
|
* the size of the sei message
|
66 |
|
|
* \param img
|
67 |
|
|
* the image pointer
|
68 |
|
|
*
|
69 |
|
|
************************************************************************
|
70 |
|
|
*/
|
71 |
|
|
void InterpretSEIMessage(byte* msg, int size, ImageParameters *img)
|
72 |
|
|
{
|
73 |
|
|
int payload_type = 0;
|
74 |
|
|
int payload_size = 0;
|
75 |
|
|
int offset = 1;
|
76 |
|
|
byte tmp_byte;
|
77 |
|
|
do
|
78 |
|
|
{
|
79 |
|
|
// sei_message();
|
80 |
|
|
payload_type = 0;
|
81 |
|
|
tmp_byte = msg[offset++];
|
82 |
|
|
while (tmp_byte == 0xFF)
|
83 |
|
|
{
|
84 |
|
|
payload_type += 255;
|
85 |
|
|
tmp_byte = msg[offset++];
|
86 |
|
|
}
|
87 |
|
|
payload_type += tmp_byte; // this is the last byte
|
88 |
|
|
|
89 |
|
|
payload_size = 0;
|
90 |
|
|
tmp_byte = msg[offset++];
|
91 |
|
|
while (tmp_byte == 0xFF)
|
92 |
|
|
{
|
93 |
|
|
payload_size += 255;
|
94 |
|
|
tmp_byte = msg[offset++];
|
95 |
|
|
}
|
96 |
|
|
payload_size += tmp_byte; // this is the last byte
|
97 |
|
|
|
98 |
|
|
switch ( payload_type ) // sei_payload( type, size );
|
99 |
|
|
{
|
100 |
|
|
case SEI_BUFFERING_PERIOD:
|
101 |
|
|
interpret_buffering_period_info( msg+offset, payload_size, img );
|
102 |
|
|
break;
|
103 |
|
|
case SEI_PIC_TIMING:
|
104 |
|
|
interpret_picture_timing_info( msg+offset, payload_size, img );
|
105 |
|
|
break;
|
106 |
|
|
case SEI_PAN_SCAN_RECT:
|
107 |
|
|
interpret_pan_scan_rect_info( msg+offset, payload_size, img );
|
108 |
|
|
break;
|
109 |
|
|
case SEI_FILLER_PAYLOAD:
|
110 |
|
|
interpret_filler_payload_info( msg+offset, payload_size, img );
|
111 |
|
|
break;
|
112 |
|
|
case SEI_USER_DATA_REGISTERED_ITU_T_T35:
|
113 |
|
|
interpret_user_data_registered_itu_t_t35_info( msg+offset, payload_size, img );
|
114 |
|
|
break;
|
115 |
|
|
case SEI_USER_DATA_UNREGISTERED:
|
116 |
|
|
interpret_user_data_unregistered_info( msg+offset, payload_size, img );
|
117 |
|
|
break;
|
118 |
|
|
case SEI_RECOVERY_POINT:
|
119 |
|
|
interpret_recovery_point_info( msg+offset, payload_size, img );
|
120 |
|
|
break;
|
121 |
|
|
case SEI_DEC_REF_PIC_MARKING_REPETITION:
|
122 |
|
|
interpret_dec_ref_pic_marking_repetition_info( msg+offset, payload_size, img );
|
123 |
|
|
break;
|
124 |
|
|
case SEI_SPARE_PIC:
|
125 |
|
|
interpret_spare_pic( msg+offset, payload_size, img );
|
126 |
|
|
break;
|
127 |
|
|
case SEI_SCENE_INFO:
|
128 |
|
|
interpret_scene_information( msg+offset, payload_size, img );
|
129 |
|
|
break;
|
130 |
|
|
case SEI_SUB_SEQ_INFO:
|
131 |
|
|
interpret_subsequence_info( msg+offset, payload_size, img );
|
132 |
|
|
break;
|
133 |
|
|
case SEI_SUB_SEQ_LAYER_CHARACTERISTICS:
|
134 |
|
|
interpret_subsequence_layer_characteristics_info( msg+offset, payload_size, img );
|
135 |
|
|
break;
|
136 |
|
|
case SEI_SUB_SEQ_CHARACTERISTICS:
|
137 |
|
|
interpret_subsequence_characteristics_info( msg+offset, payload_size, img );
|
138 |
|
|
break;
|
139 |
|
|
case SEI_FULL_FRAME_FREEZE:
|
140 |
|
|
interpret_full_frame_freeze_info( msg+offset, payload_size, img );
|
141 |
|
|
break;
|
142 |
|
|
case SEI_FULL_FRAME_FREEZE_RELEASE:
|
143 |
|
|
interpret_full_frame_freeze_release_info( msg+offset, payload_size, img );
|
144 |
|
|
break;
|
145 |
|
|
case SEI_FULL_FRAME_SNAPSHOT:
|
146 |
|
|
interpret_full_frame_snapshot_info( msg+offset, payload_size, img );
|
147 |
|
|
break;
|
148 |
|
|
case SEI_PROGRESSIVE_REFINEMENT_SEGMENT_START:
|
149 |
|
|
interpret_progressive_refinement_end_info( msg+offset, payload_size, img );
|
150 |
|
|
break;
|
151 |
|
|
case SEI_PROGRESSIVE_REFINEMENT_SEGMENT_END:
|
152 |
|
|
interpret_progressive_refinement_end_info( msg+offset, payload_size, img );
|
153 |
|
|
break;
|
154 |
|
|
case SEI_MOTION_CONSTRAINED_SLICE_GROUP_SET:
|
155 |
|
|
interpret_motion_constrained_slice_group_set_info( msg+offset, payload_size, img );
|
156 |
|
|
case SEI_FILM_GRAIN_CHARACTERISTICS:
|
157 |
|
|
interpret_film_grain_characteristics_info ( msg+offset, payload_size, img );
|
158 |
|
|
break;
|
159 |
|
|
case SEI_DEBLOCKING_FILTER_DISPLAY_PREFERENCE:
|
160 |
|
|
interpret_deblocking_filter_display_preference_info ( msg+offset, payload_size, img );
|
161 |
|
|
break;
|
162 |
|
|
case SEI_STEREO_VIDEO_INFO:
|
163 |
|
|
interpret_stereo_video_info_info ( msg+offset, payload_size, img );
|
164 |
|
|
break;
|
165 |
|
|
default:
|
166 |
|
|
interpret_reserved_info( msg+offset, payload_size, img );
|
167 |
|
|
break;
|
168 |
|
|
}
|
169 |
|
|
offset += payload_size;
|
170 |
|
|
|
171 |
|
|
} while( msg[offset] != 0x80 ); // more_rbsp_data() msg[offset] != 0x80
|
172 |
|
|
// ignore the trailing bits rbsp_trailing_bits();
|
173 |
|
|
assert(msg[offset] == 0x80); // this is the trailing bits
|
174 |
|
|
assert( offset+1 == size );
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
/*!
|
179 |
|
|
************************************************************************
|
180 |
|
|
* \brief
|
181 |
|
|
* Interpret the spare picture SEI message
|
182 |
|
|
* \param payload
|
183 |
|
|
* a pointer that point to the sei payload
|
184 |
|
|
* \param size
|
185 |
|
|
* the size of the sei message
|
186 |
|
|
* \param img
|
187 |
|
|
* the image pointer
|
188 |
|
|
*
|
189 |
|
|
************************************************************************
|
190 |
|
|
*/
|
191 |
|
|
void interpret_spare_pic( byte* payload, int size, ImageParameters *img )
|
192 |
|
|
{
|
193 |
|
|
int i,x,y;
|
194 |
|
|
Bitstream* buf;
|
195 |
|
|
int bit0, bit1, bitc, no_bit0;
|
196 |
|
|
int target_frame_num = 0;
|
197 |
|
|
int num_spare_pics;
|
198 |
|
|
int delta_spare_frame_num, CandidateSpareFrameNum, SpareFrameNum = 0;
|
199 |
|
|
int ref_area_indicator;
|
200 |
|
|
|
201 |
|
|
int m, n, left, right, top, bottom,directx, directy;
|
202 |
|
|
byte ***map;
|
203 |
|
|
|
204 |
|
|
#ifdef WRITE_MAP_IMAGE
|
205 |
|
|
int symbol_size_in_bytes = img->pic_unit_bitsize_on_disk/8;
|
206 |
|
|
int j, k, i0, j0, tmp, kk;
|
207 |
|
|
char filename[20] = "map_dec.yuv";
|
208 |
|
|
FILE *fp;
|
209 |
|
|
imgpel** Y;
|
210 |
|
|
static int old_pn=-1;
|
211 |
|
|
static int first = 1;
|
212 |
|
|
|
213 |
|
|
printf("Spare picture SEI message\n");
|
214 |
|
|
#endif
|
215 |
|
|
|
216 |
|
|
UsedBits = 0;
|
217 |
|
|
|
218 |
|
|
assert( payload!=NULL);
|
219 |
|
|
assert( img!=NULL);
|
220 |
|
|
|
221 |
|
|
buf = malloc(sizeof(Bitstream));
|
222 |
|
|
buf->bitstream_length = size;
|
223 |
|
|
buf->streamBuffer = payload;
|
224 |
|
|
buf->frame_bitoffset = 0;
|
225 |
|
|
|
226 |
|
|
target_frame_num = ue_v("SEI: target_frame_num", buf);
|
227 |
|
|
|
228 |
|
|
#ifdef WRITE_MAP_IMAGE
|
229 |
|
|
printf( "target_frame_num is %d\n", target_frame_num );
|
230 |
|
|
#endif
|
231 |
|
|
|
232 |
|
|
num_spare_pics = 1 + ue_v("SEI: num_spare_pics_minus1", buf);
|
233 |
|
|
|
234 |
|
|
#ifdef WRITE_MAP_IMAGE
|
235 |
|
|
printf( "num_spare_pics is %d\n", num_spare_pics );
|
236 |
|
|
#endif
|
237 |
|
|
|
238 |
|
|
get_mem3D(&map, num_spare_pics, img->height/16, img->width/16);
|
239 |
|
|
|
240 |
|
|
for (i=0; i<num_spare_pics; i++)
|
241 |
|
|
{
|
242 |
|
|
if (i==0)
|
243 |
|
|
{
|
244 |
|
|
CandidateSpareFrameNum = target_frame_num - 1;
|
245 |
|
|
if ( CandidateSpareFrameNum < 0 ) CandidateSpareFrameNum = MAX_FN - 1;
|
246 |
|
|
}
|
247 |
|
|
else
|
248 |
|
|
CandidateSpareFrameNum = SpareFrameNum;
|
249 |
|
|
|
250 |
|
|
delta_spare_frame_num = ue_v("SEI: delta_spare_frame_num", buf);
|
251 |
|
|
|
252 |
|
|
SpareFrameNum = CandidateSpareFrameNum - delta_spare_frame_num;
|
253 |
|
|
if( SpareFrameNum < 0 )
|
254 |
|
|
SpareFrameNum = MAX_FN + SpareFrameNum;
|
255 |
|
|
|
256 |
|
|
ref_area_indicator = ue_v("SEI: ref_area_indicator", buf);
|
257 |
|
|
|
258 |
|
|
switch ( ref_area_indicator )
|
259 |
|
|
{
|
260 |
|
|
case 0: // The whole frame can serve as spare picture
|
261 |
|
|
for (y=0; y<img->height/16; y++)
|
262 |
|
|
for (x=0; x<img->width/16; x++)
|
263 |
|
|
map[i][y][x] = 0;
|
264 |
|
|
break;
|
265 |
|
|
case 1: // The map is not compressed
|
266 |
|
|
for (y=0; y<img->height/16; y++)
|
267 |
|
|
for (x=0; x<img->width/16; x++)
|
268 |
|
|
{
|
269 |
|
|
map[i][y][x] = u_1("SEI: ref_mb_indicator", buf);
|
270 |
|
|
}
|
271 |
|
|
break;
|
272 |
|
|
case 2: // The map is compressed
|
273 |
|
|
//!KS: could not check this function, description is unclear (as stated in Ed. Note)
|
274 |
|
|
bit0 = 0;
|
275 |
|
|
bit1 = 1;
|
276 |
|
|
bitc = bit0;
|
277 |
|
|
no_bit0 = -1;
|
278 |
|
|
|
279 |
|
|
x = ( img->width/16 - 1 ) / 2;
|
280 |
|
|
y = ( img->height/16 - 1 ) / 2;
|
281 |
|
|
left = right = x;
|
282 |
|
|
top = bottom = y;
|
283 |
|
|
directx = 0;
|
284 |
|
|
directy = 1;
|
285 |
|
|
|
286 |
|
|
for (m=0; m<img->height/16; m++)
|
287 |
|
|
for (n=0; n<img->width/16; n++)
|
288 |
|
|
{
|
289 |
|
|
|
290 |
|
|
if (no_bit0<0)
|
291 |
|
|
{
|
292 |
|
|
no_bit0 = ue_v("SEI: zero_run_length", buf);
|
293 |
|
|
}
|
294 |
|
|
if (no_bit0>0) map[i][y][x] = bit0;
|
295 |
|
|
else map[i][y][x] = bit1;
|
296 |
|
|
no_bit0--;
|
297 |
|
|
|
298 |
|
|
// go to the next mb:
|
299 |
|
|
if ( directx == -1 && directy == 0 )
|
300 |
|
|
{
|
301 |
|
|
if (x > left) x--;
|
302 |
|
|
else if (x == 0)
|
303 |
|
|
{
|
304 |
|
|
y = bottom + 1;
|
305 |
|
|
bottom++;
|
306 |
|
|
directx = 1;
|
307 |
|
|
directy = 0;
|
308 |
|
|
}
|
309 |
|
|
else if (x == left)
|
310 |
|
|
{
|
311 |
|
|
x--;
|
312 |
|
|
left--;
|
313 |
|
|
directx = 0;
|
314 |
|
|
directy = 1;
|
315 |
|
|
}
|
316 |
|
|
}
|
317 |
|
|
else if ( directx == 1 && directy == 0 )
|
318 |
|
|
{
|
319 |
|
|
if (x < right) x++;
|
320 |
|
|
else if (x == img->width/16 - 1)
|
321 |
|
|
{
|
322 |
|
|
y = top - 1;
|
323 |
|
|
top--;
|
324 |
|
|
directx = -1;
|
325 |
|
|
directy = 0;
|
326 |
|
|
}
|
327 |
|
|
else if (x == right)
|
328 |
|
|
{
|
329 |
|
|
x++;
|
330 |
|
|
right++;
|
331 |
|
|
directx = 0;
|
332 |
|
|
directy = -1;
|
333 |
|
|
}
|
334 |
|
|
}
|
335 |
|
|
else if ( directx == 0 && directy == -1 )
|
336 |
|
|
{
|
337 |
|
|
if ( y > top) y--;
|
338 |
|
|
else if (y == 0)
|
339 |
|
|
{
|
340 |
|
|
x = left - 1;
|
341 |
|
|
left--;
|
342 |
|
|
directx = 0;
|
343 |
|
|
directy = 1;
|
344 |
|
|
}
|
345 |
|
|
else if (y == top)
|
346 |
|
|
{
|
347 |
|
|
y--;
|
348 |
|
|
top--;
|
349 |
|
|
directx = -1;
|
350 |
|
|
directy = 0;
|
351 |
|
|
}
|
352 |
|
|
}
|
353 |
|
|
else if ( directx == 0 && directy == 1 )
|
354 |
|
|
{
|
355 |
|
|
if (y < bottom) y++;
|
356 |
|
|
else if (y == img->height/16 - 1)
|
357 |
|
|
{
|
358 |
|
|
x = right+1;
|
359 |
|
|
right++;
|
360 |
|
|
directx = 0;
|
361 |
|
|
directy = -1;
|
362 |
|
|
}
|
363 |
|
|
else if (y == bottom)
|
364 |
|
|
{
|
365 |
|
|
y++;
|
366 |
|
|
bottom++;
|
367 |
|
|
directx = 1;
|
368 |
|
|
directy = 0;
|
369 |
|
|
}
|
370 |
|
|
}
|
371 |
|
|
|
372 |
|
|
|
373 |
|
|
}
|
374 |
|
|
break;
|
375 |
|
|
default:
|
376 |
|
|
printf( "Wrong ref_area_indicator %d!\n", ref_area_indicator );
|
377 |
|
|
exit(0);
|
378 |
|
|
break;
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
} // end of num_spare_pics
|
382 |
|
|
|
383 |
|
|
#ifdef WRITE_MAP_IMAGE
|
384 |
|
|
// begin to write map seq
|
385 |
|
|
if ( old_pn != img->number )
|
386 |
|
|
{
|
387 |
|
|
old_pn = img->number;
|
388 |
|
|
get_mem2Dpel(&Y, img->height, img->width);
|
389 |
|
|
if (first)
|
390 |
|
|
{
|
391 |
|
|
fp = fopen( filename, "wb" );
|
392 |
|
|
first = 0;
|
393 |
|
|
}
|
394 |
|
|
else
|
395 |
|
|
fp = fopen( filename, "ab" );
|
396 |
|
|
assert( fp != NULL );
|
397 |
|
|
for (kk=0; kk<num_spare_pics; kk++)
|
398 |
|
|
{
|
399 |
|
|
for (i=0; i < img->height/16; i++)
|
400 |
|
|
for (j=0; j < img->width/16; j++)
|
401 |
|
|
{
|
402 |
|
|
tmp=map[kk][i][j]==0? img->max_imgpel_value : 0;
|
403 |
|
|
for (i0=0; i0<16; i0++)
|
404 |
|
|
for (j0=0; j0<16; j0++)
|
405 |
|
|
Y[i*16+i0][j*16+j0]=tmp;
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
// write the map image
|
409 |
|
|
for (i=0; i < img->height; i++)
|
410 |
|
|
for (j=0; j < img->width; j++)
|
411 |
|
|
fwrite(&(Y[i][j]), symbol_size_in_bytes, 1, p_out);
|
412 |
|
|
|
413 |
|
|
for (k=0; k < 2; k++)
|
414 |
|
|
for (i=0; i < img->height/2; i++)
|
415 |
|
|
for (j=0; j < img->width/2; j++)
|
416 |
|
|
fwrite(&(img->dc_pred_value_chroma), symbol_size_in_bytes, 1, p_out);
|
417 |
|
|
}
|
418 |
|
|
fclose( fp );
|
419 |
|
|
free_mem2Dpel( Y );
|
420 |
|
|
}
|
421 |
|
|
// end of writing map image
|
422 |
|
|
#undef WRITE_MAP_IMAGE
|
423 |
|
|
#endif
|
424 |
|
|
|
425 |
|
|
free_mem3D( map, num_spare_pics );
|
426 |
|
|
|
427 |
|
|
free(buf);
|
428 |
|
|
}
|
429 |
|
|
|
430 |
|
|
|
431 |
|
|
/*!
|
432 |
|
|
************************************************************************
|
433 |
|
|
* \brief
|
434 |
|
|
* Interpret the Sub-sequence information SEI message
|
435 |
|
|
* \param payload
|
436 |
|
|
* a pointer that point to the sei payload
|
437 |
|
|
* \param size
|
438 |
|
|
* the size of the sei message
|
439 |
|
|
* \param img
|
440 |
|
|
* the image pointer
|
441 |
|
|
*
|
442 |
|
|
************************************************************************
|
443 |
|
|
*/
|
444 |
|
|
void interpret_subsequence_info( byte* payload, int size, ImageParameters *img )
|
445 |
|
|
{
|
446 |
|
|
Bitstream* buf;
|
447 |
|
|
int sub_seq_layer_num, sub_seq_id, first_ref_pic_flag, leading_non_ref_pic_flag, last_pic_flag,
|
448 |
|
|
sub_seq_frame_num_flag, sub_seq_frame_num;
|
449 |
|
|
|
450 |
|
|
buf = malloc(sizeof(Bitstream));
|
451 |
|
|
buf->bitstream_length = size;
|
452 |
|
|
buf->streamBuffer = payload;
|
453 |
|
|
buf->frame_bitoffset = 0;
|
454 |
|
|
|
455 |
|
|
UsedBits = 0;
|
456 |
|
|
|
457 |
|
|
sub_seq_layer_num = ue_v("SEI: sub_seq_layer_num" , buf);
|
458 |
|
|
sub_seq_id = ue_v("SEI: sub_seq_id" , buf);
|
459 |
|
|
first_ref_pic_flag = u_1 ("SEI: first_ref_pic_flag" , buf);
|
460 |
|
|
leading_non_ref_pic_flag = u_1 ("SEI: leading_non_ref_pic_flag", buf);
|
461 |
|
|
last_pic_flag = u_1 ("SEI: last_pic_flag" , buf);
|
462 |
|
|
sub_seq_frame_num_flag = u_1 ("SEI: sub_seq_frame_num_flag" , buf);
|
463 |
|
|
if (sub_seq_frame_num_flag)
|
464 |
|
|
{
|
465 |
|
|
sub_seq_frame_num = ue_v("SEI: sub_seq_frame_num" , buf);
|
466 |
|
|
}
|
467 |
|
|
|
468 |
|
|
#ifdef PRINT_SUBSEQUENCE_INFO
|
469 |
|
|
printf("Sub-sequence information SEI message\n");
|
470 |
|
|
printf("sub_seq_layer_num = %d\n", sub_seq_layer_num );
|
471 |
|
|
printf("sub_seq_id = %d\n", sub_seq_id);
|
472 |
|
|
printf("first_ref_pic_flag = %d\n", first_ref_pic_flag);
|
473 |
|
|
printf("leading_non_ref_pic_flag = %d\n", leading_non_ref_pic_flag);
|
474 |
|
|
printf("last_pic_flag = %d\n", last_pic_flag);
|
475 |
|
|
printf("sub_seq_frame_num_flag = %d\n", sub_seq_frame_num_flag);
|
476 |
|
|
if (sub_seq_frame_num_flag)
|
477 |
|
|
{
|
478 |
|
|
printf("sub_seq_frame_num = %d\n", sub_seq_frame_num);
|
479 |
|
|
}
|
480 |
|
|
#endif
|
481 |
|
|
|
482 |
|
|
free(buf);
|
483 |
|
|
#ifdef PRINT_SUBSEQUENCE_INFO
|
484 |
|
|
#undef PRINT_SUBSEQUENCE_INFO
|
485 |
|
|
#endif
|
486 |
|
|
}
|
487 |
|
|
|
488 |
|
|
/*!
|
489 |
|
|
************************************************************************
|
490 |
|
|
* \brief
|
491 |
|
|
* Interpret the Sub-sequence layer characteristics SEI message
|
492 |
|
|
* \param payload
|
493 |
|
|
* a pointer that point to the sei payload
|
494 |
|
|
* \param size
|
495 |
|
|
* the size of the sei message
|
496 |
|
|
* \param img
|
497 |
|
|
* the image pointer
|
498 |
|
|
*
|
499 |
|
|
************************************************************************
|
500 |
|
|
*/
|
501 |
|
|
void interpret_subsequence_layer_characteristics_info( byte* payload, int size, ImageParameters *img )
|
502 |
|
|
{
|
503 |
|
|
Bitstream* buf;
|
504 |
|
|
long num_sub_layers, accurate_statistics_flag, average_bit_rate, average_frame_rate;
|
505 |
|
|
int i;
|
506 |
|
|
|
507 |
|
|
buf = malloc(sizeof(Bitstream));
|
508 |
|
|
buf->bitstream_length = size;
|
509 |
|
|
buf->streamBuffer = payload;
|
510 |
|
|
buf->frame_bitoffset = 0;
|
511 |
|
|
|
512 |
|
|
UsedBits = 0;
|
513 |
|
|
|
514 |
|
|
num_sub_layers = 1 + ue_v("SEI: num_sub_layers_minus1", buf);
|
515 |
|
|
|
516 |
|
|
#ifdef PRINT_SUBSEQUENCE_LAYER_CHAR
|
517 |
|
|
printf("Sub-sequence layer characteristics SEI message\n");
|
518 |
|
|
printf("num_sub_layers_minus1 = %d\n", num_sub_layers - 1);
|
519 |
|
|
#endif
|
520 |
|
|
|
521 |
|
|
for (i=0; i<num_sub_layers; i++)
|
522 |
|
|
{
|
523 |
|
|
accurate_statistics_flag = u_1( "SEI: accurate_statistics_flag", buf);
|
524 |
|
|
average_bit_rate = u_v(16,"SEI: average_bit_rate" , buf);
|
525 |
|
|
average_frame_rate = u_v(16,"SEI: average_frame_rate" , buf);
|
526 |
|
|
|
527 |
|
|
#ifdef PRINT_SUBSEQUENCE_LAYER_CHAR
|
528 |
|
|
printf("layer %d: accurate_statistics_flag = %ld \n", i, accurate_statistics_flag);
|
529 |
|
|
printf("layer %d: average_bit_rate = %ld \n", i, average_bit_rate);
|
530 |
|
|
printf("layer %d: average_frame_rate = %ld \n", i, average_frame_rate);
|
531 |
|
|
#endif
|
532 |
|
|
}
|
533 |
|
|
free (buf);
|
534 |
|
|
}
|
535 |
|
|
|
536 |
|
|
|
537 |
|
|
/*!
|
538 |
|
|
************************************************************************
|
539 |
|
|
* \brief
|
540 |
|
|
* Interpret the Sub-sequence characteristics SEI message
|
541 |
|
|
* \param payload
|
542 |
|
|
* a pointer that point to the sei payload
|
543 |
|
|
* \param size
|
544 |
|
|
* the size of the sei message
|
545 |
|
|
* \param img
|
546 |
|
|
* the image pointer
|
547 |
|
|
*
|
548 |
|
|
************************************************************************
|
549 |
|
|
*/
|
550 |
|
|
void interpret_subsequence_characteristics_info( byte* payload, int size, ImageParameters *img )
|
551 |
|
|
{
|
552 |
|
|
Bitstream* buf;
|
553 |
|
|
int i;
|
554 |
|
|
int sub_seq_layer_num, sub_seq_id, duration_flag, average_rate_flag, accurate_statistics_flag;
|
555 |
|
|
unsigned long sub_seq_duration, average_bit_rate, average_frame_rate;
|
556 |
|
|
int num_referenced_subseqs, ref_sub_seq_layer_num, ref_sub_seq_id, ref_sub_seq_direction;
|
557 |
|
|
|
558 |
|
|
buf = malloc(sizeof(Bitstream));
|
559 |
|
|
buf->bitstream_length = size;
|
560 |
|
|
buf->streamBuffer = payload;
|
561 |
|
|
buf->frame_bitoffset = 0;
|
562 |
|
|
|
563 |
|
|
UsedBits = 0;
|
564 |
|
|
|
565 |
|
|
sub_seq_layer_num = ue_v("SEI: sub_seq_layer_num", buf);
|
566 |
|
|
sub_seq_id = ue_v("SEI: sub_seq_id", buf);
|
567 |
|
|
duration_flag = u_1 ("SEI: duration_flag", buf);
|
568 |
|
|
|
569 |
|
|
#ifdef PRINT_SUBSEQUENCE_CHAR
|
570 |
|
|
printf("Sub-sequence characteristics SEI message\n");
|
571 |
|
|
printf("sub_seq_layer_num = %d\n", sub_seq_layer_num );
|
572 |
|
|
printf("sub_seq_id = %d\n", sub_seq_id);
|
573 |
|
|
printf("duration_flag = %d\n", duration_flag);
|
574 |
|
|
#endif
|
575 |
|
|
|
576 |
|
|
if ( duration_flag )
|
577 |
|
|
{
|
578 |
|
|
sub_seq_duration = u_v (32, "SEI: duration_flag", buf);
|
579 |
|
|
#ifdef PRINT_SUBSEQUENCE_CHAR
|
580 |
|
|
printf("sub_seq_duration = %ld\n", sub_seq_duration);
|
581 |
|
|
#endif
|
582 |
|
|
}
|
583 |
|
|
|
584 |
|
|
average_rate_flag = u_1 ("SEI: average_rate_flag", buf);
|
585 |
|
|
|
586 |
|
|
#ifdef PRINT_SUBSEQUENCE_CHAR
|
587 |
|
|
printf("average_rate_flag = %d\n", average_rate_flag);
|
588 |
|
|
#endif
|
589 |
|
|
|
590 |
|
|
if ( average_rate_flag )
|
591 |
|
|
{
|
592 |
|
|
accurate_statistics_flag = u_1 ( "SEI: accurate_statistics_flag", buf);
|
593 |
|
|
average_bit_rate = u_v (16, "SEI: average_bit_rate", buf);
|
594 |
|
|
average_frame_rate = u_v (16, "SEI: average_frame_rate", buf);
|
595 |
|
|
|
596 |
|
|
#ifdef PRINT_SUBSEQUENCE_CHAR
|
597 |
|
|
printf("accurate_statistics_flag = %d\n", accurate_statistics_flag);
|
598 |
|
|
printf("average_bit_rate = %ld\n", average_bit_rate);
|
599 |
|
|
printf("average_frame_rate = %ld\n", average_frame_rate);
|
600 |
|
|
#endif
|
601 |
|
|
}
|
602 |
|
|
|
603 |
|
|
num_referenced_subseqs = ue_v("SEI: num_referenced_subseqs", buf);
|
604 |
|
|
|
605 |
|
|
#ifdef PRINT_SUBSEQUENCE_CHAR
|
606 |
|
|
printf("num_referenced_subseqs = %d\n", num_referenced_subseqs);
|
607 |
|
|
#endif
|
608 |
|
|
|
609 |
|
|
for (i=0; i<num_referenced_subseqs; i++)
|
610 |
|
|
{
|
611 |
|
|
ref_sub_seq_layer_num = ue_v("SEI: ref_sub_seq_layer_num", buf);
|
612 |
|
|
ref_sub_seq_id = ue_v("SEI: ref_sub_seq_id", buf);
|
613 |
|
|
ref_sub_seq_direction = u_1 ("SEI: ref_sub_seq_direction", buf);
|
614 |
|
|
|
615 |
|
|
#ifdef PRINT_SUBSEQUENCE_CHAR
|
616 |
|
|
printf("ref_sub_seq_layer_num = %d\n", ref_sub_seq_layer_num);
|
617 |
|
|
printf("ref_sub_seq_id = %d\n", ref_sub_seq_id);
|
618 |
|
|
printf("ref_sub_seq_direction = %d\n", ref_sub_seq_direction);
|
619 |
|
|
#endif
|
620 |
|
|
}
|
621 |
|
|
|
622 |
|
|
free( buf );
|
623 |
|
|
#ifdef PRINT_SUBSEQUENCE_CHAR
|
624 |
|
|
#undef PRINT_SUBSEQUENCE_CHAR
|
625 |
|
|
#endif
|
626 |
|
|
}
|
627 |
|
|
|
628 |
|
|
|
629 |
|
|
/*!
|
630 |
|
|
************************************************************************
|
631 |
|
|
* \brief
|
632 |
|
|
* Interpret the Scene information SEI message
|
633 |
|
|
* \param payload
|
634 |
|
|
* a pointer that point to the sei payload
|
635 |
|
|
* \param size
|
636 |
|
|
* the size of the sei message
|
637 |
|
|
* \param img
|
638 |
|
|
* the image pointer
|
639 |
|
|
*
|
640 |
|
|
************************************************************************
|
641 |
|
|
*/
|
642 |
|
|
void interpret_scene_information( byte* payload, int size, ImageParameters *img )
|
643 |
|
|
{
|
644 |
|
|
Bitstream* buf;
|
645 |
|
|
int scene_id, scene_transition_type, second_scene_id;
|
646 |
|
|
|
647 |
|
|
buf = malloc(sizeof(Bitstream));
|
648 |
|
|
buf->bitstream_length = size;
|
649 |
|
|
buf->streamBuffer = payload;
|
650 |
|
|
buf->frame_bitoffset = 0;
|
651 |
|
|
|
652 |
|
|
UsedBits = 0;
|
653 |
|
|
|
654 |
|
|
scene_id = ue_v("SEI: scene_id" , buf);
|
655 |
|
|
scene_transition_type = ue_v("SEI: scene_transition_type", buf);
|
656 |
|
|
if ( scene_transition_type > 3 )
|
657 |
|
|
{
|
658 |
|
|
second_scene_id = ue_v("SEI: scene_transition_type", buf);;
|
659 |
|
|
}
|
660 |
|
|
|
661 |
|
|
#ifdef PRINT_SCENE_INFORMATION
|
662 |
|
|
printf("Scene information SEI message\n");
|
663 |
|
|
printf("scene_transition_type = %d\n", scene_transition_type);
|
664 |
|
|
printf("scene_id = %d\n", scene_id);
|
665 |
|
|
if ( scene_transition_type > 3 )
|
666 |
|
|
{
|
667 |
|
|
printf("second_scene_id = %d\n", second_scene_id);
|
668 |
|
|
}
|
669 |
|
|
#endif
|
670 |
|
|
free( buf );
|
671 |
|
|
#ifdef PRINT_SCENE_INFORMATION
|
672 |
|
|
#undef PRINT_SCENE_INFORMATION
|
673 |
|
|
#endif
|
674 |
|
|
}
|
675 |
|
|
|
676 |
|
|
|
677 |
|
|
/*!
|
678 |
|
|
************************************************************************
|
679 |
|
|
* \brief
|
680 |
|
|
* Interpret the Filler payload SEI message
|
681 |
|
|
* \param payload
|
682 |
|
|
* a pointer that point to the sei payload
|
683 |
|
|
* \param size
|
684 |
|
|
* the size of the sei message
|
685 |
|
|
* \param img
|
686 |
|
|
* the image pointer
|
687 |
|
|
*
|
688 |
|
|
************************************************************************
|
689 |
|
|
*/
|
690 |
|
|
void interpret_filler_payload_info( byte* payload, int size, ImageParameters *img )
|
691 |
|
|
{
|
692 |
|
|
int payload_cnt = 0;
|
693 |
|
|
|
694 |
|
|
while (payload_cnt<size)
|
695 |
|
|
{
|
696 |
|
|
if (payload[payload_cnt] == 0xFF)
|
697 |
|
|
{
|
698 |
|
|
payload_cnt++;
|
699 |
|
|
}
|
700 |
|
|
}
|
701 |
|
|
|
702 |
|
|
|
703 |
|
|
#ifdef PRINT_FILLER_PAYLOAD_INFO
|
704 |
|
|
printf("Filler payload SEI message\n");
|
705 |
|
|
if (payload_cnt==size)
|
706 |
|
|
{
|
707 |
|
|
printf("read %d bytes of filler payload\n", payload_cnt);
|
708 |
|
|
}
|
709 |
|
|
else
|
710 |
|
|
{
|
711 |
|
|
printf("error reading filler payload: not all bytes are 0xFF (%d of %d)\n", payload_cnt, size);
|
712 |
|
|
}
|
713 |
|
|
#endif
|
714 |
|
|
|
715 |
|
|
#ifdef PRINT_FILLER_PAYLOAD_INFO
|
716 |
|
|
#undef PRINT_FILLER_PAYLOAD_INFO
|
717 |
|
|
#endif
|
718 |
|
|
}
|
719 |
|
|
|
720 |
|
|
|
721 |
|
|
/*!
|
722 |
|
|
************************************************************************
|
723 |
|
|
* \brief
|
724 |
|
|
* Interpret the User data unregistered SEI message
|
725 |
|
|
* \param payload
|
726 |
|
|
* a pointer that point to the sei payload
|
727 |
|
|
* \param size
|
728 |
|
|
* the size of the sei message
|
729 |
|
|
* \param img
|
730 |
|
|
* the image pointer
|
731 |
|
|
*
|
732 |
|
|
************************************************************************
|
733 |
|
|
*/
|
734 |
|
|
void interpret_user_data_unregistered_info( byte* payload, int size, ImageParameters *img )
|
735 |
|
|
{
|
736 |
|
|
int offset = 0;
|
737 |
|
|
byte payload_byte;
|
738 |
|
|
|
739 |
|
|
#ifdef PRINT_USER_DATA_UNREGISTERED_INFO
|
740 |
|
|
printf("User data unregistered SEI message\n");
|
741 |
|
|
printf("uuid_iso_11578 = 0x");
|
742 |
|
|
#endif
|
743 |
|
|
assert (size>=16);
|
744 |
|
|
|
745 |
|
|
for (offset = 0; offset < 16; offset++)
|
746 |
|
|
{
|
747 |
|
|
#ifdef PRINT_USER_DATA_UNREGISTERED_INFO
|
748 |
|
|
printf("%02x",payload[offset]);
|
749 |
|
|
#endif
|
750 |
|
|
}
|
751 |
|
|
|
752 |
|
|
#ifdef PRINT_USER_DATA_UNREGISTERED_INFO
|
753 |
|
|
printf("\n");
|
754 |
|
|
#endif
|
755 |
|
|
|
756 |
|
|
while (offset < size)
|
757 |
|
|
{
|
758 |
|
|
payload_byte = payload[offset];
|
759 |
|
|
offset ++;
|
760 |
|
|
#ifdef PRINT_USER_DATA_UNREGISTERED_INFO
|
761 |
|
|
printf("Unreg data payload_byte = %d\n", payload_byte);
|
762 |
|
|
#endif
|
763 |
|
|
}
|
764 |
|
|
#ifdef PRINT_USER_DATA_UNREGISTERED_INFO
|
765 |
|
|
#undef PRINT_USER_DATA_UNREGISTERED_INFO
|
766 |
|
|
#endif
|
767 |
|
|
}
|
768 |
|
|
|
769 |
|
|
|
770 |
|
|
/*!
|
771 |
|
|
************************************************************************
|
772 |
|
|
* \brief
|
773 |
|
|
* Interpret the User data registered by ITU-T T.35 SEI message
|
774 |
|
|
* \param payload
|
775 |
|
|
* a pointer that point to the sei payload
|
776 |
|
|
* \param size
|
777 |
|
|
* the size of the sei message
|
778 |
|
|
* \param img
|
779 |
|
|
* the image pointer
|
780 |
|
|
*
|
781 |
|
|
************************************************************************
|
782 |
|
|
*/
|
783 |
|
|
void interpret_user_data_registered_itu_t_t35_info( byte* payload, int size, ImageParameters *img )
|
784 |
|
|
{
|
785 |
|
|
int offset = 0;
|
786 |
|
|
byte itu_t_t35_country_code, itu_t_t35_country_code_extension_byte, payload_byte;
|
787 |
|
|
|
788 |
|
|
itu_t_t35_country_code = payload[offset];
|
789 |
|
|
offset++;
|
790 |
|
|
#ifdef PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO
|
791 |
|
|
printf("User data registered by ITU-T T.35 SEI message\n");
|
792 |
|
|
printf(" itu_t_t35_country_code = %d \n", itu_t_t35_country_code);
|
793 |
|
|
#endif
|
794 |
|
|
if(itu_t_t35_country_code == 0xFF)
|
795 |
|
|
{
|
796 |
|
|
itu_t_t35_country_code_extension_byte = payload[offset];
|
797 |
|
|
offset++;
|
798 |
|
|
#ifdef PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO
|
799 |
|
|
printf(" ITU_T_T35_COUNTRY_CODE_EXTENSION_BYTE %d \n", itu_t_t35_country_code_extension_byte);
|
800 |
|
|
#endif
|
801 |
|
|
}
|
802 |
|
|
while (offset < size)
|
803 |
|
|
{
|
804 |
|
|
payload_byte = payload[offset];
|
805 |
|
|
offset ++;
|
806 |
|
|
#ifdef PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO
|
807 |
|
|
printf("itu_t_t35 payload_byte = %d\n", payload_byte);
|
808 |
|
|
#endif
|
809 |
|
|
}
|
810 |
|
|
#ifdef PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO
|
811 |
|
|
#undef PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO
|
812 |
|
|
#endif
|
813 |
|
|
}
|
814 |
|
|
|
815 |
|
|
|
816 |
|
|
/*!
|
817 |
|
|
************************************************************************
|
818 |
|
|
* \brief
|
819 |
|
|
* Interpret the Pan scan rectangle SEI message
|
820 |
|
|
* \param payload
|
821 |
|
|
* a pointer that point to the sei payload
|
822 |
|
|
* \param size
|
823 |
|
|
* the size of the sei message
|
824 |
|
|
* \param img
|
825 |
|
|
* the image pointer
|
826 |
|
|
*
|
827 |
|
|
************************************************************************
|
828 |
|
|
*/
|
829 |
|
|
void interpret_pan_scan_rect_info( byte* payload, int size, ImageParameters *img )
|
830 |
|
|
{
|
831 |
|
|
int pan_scan_rect_cancel_flag;
|
832 |
|
|
int pan_scan_cnt_minus1, i;
|
833 |
|
|
int pan_scan_rect_repetition_period;
|
834 |
|
|
int pan_scan_rect_id, pan_scan_rect_left_offset, pan_scan_rect_right_offset;
|
835 |
|
|
int pan_scan_rect_top_offset, pan_scan_rect_bottom_offset;
|
836 |
|
|
|
837 |
|
|
Bitstream* buf;
|
838 |
|
|
|
839 |
|
|
buf = malloc(sizeof(Bitstream));
|
840 |
|
|
buf->bitstream_length = size;
|
841 |
|
|
buf->streamBuffer = payload;
|
842 |
|
|
buf->frame_bitoffset = 0;
|
843 |
|
|
|
844 |
|
|
UsedBits = 0;
|
845 |
|
|
|
846 |
|
|
pan_scan_rect_id = ue_v("SEI: pan_scan_rect_id", buf);
|
847 |
|
|
|
848 |
|
|
pan_scan_rect_cancel_flag = u_1("SEI: pan_scan_rect_cancel_flag", buf);
|
849 |
|
|
if (!pan_scan_rect_cancel_flag) {
|
850 |
|
|
pan_scan_cnt_minus1 = ue_v("SEI: pan_scan_cnt_minus1", buf);
|
851 |
|
|
for (i = 0; i <= pan_scan_cnt_minus1; i++) {
|
852 |
|
|
pan_scan_rect_left_offset = se_v("SEI: pan_scan_rect_left_offset" , buf);
|
853 |
|
|
pan_scan_rect_right_offset = se_v("SEI: pan_scan_rect_right_offset" , buf);
|
854 |
|
|
pan_scan_rect_top_offset = se_v("SEI: pan_scan_rect_top_offset" , buf);
|
855 |
|
|
pan_scan_rect_bottom_offset = se_v("SEI: pan_scan_rect_bottom_offset", buf);
|
856 |
|
|
#ifdef PRINT_PAN_SCAN_RECT
|
857 |
|
|
printf("Pan scan rectangle SEI message %d/%d\n", i, pan_scan_cnt_minus1);
|
858 |
|
|
printf("pan_scan_rect_id = %d\n", pan_scan_rect_id);
|
859 |
|
|
printf("pan_scan_rect_left_offset = %d\n", pan_scan_rect_left_offset);
|
860 |
|
|
printf("pan_scan_rect_right_offset = %d\n", pan_scan_rect_right_offset);
|
861 |
|
|
printf("pan_scan_rect_top_offset = %d\n", pan_scan_rect_top_offset);
|
862 |
|
|
printf("pan_scan_rect_bottom_offset = %d\n", pan_scan_rect_bottom_offset);
|
863 |
|
|
#endif
|
864 |
|
|
}
|
865 |
|
|
pan_scan_rect_repetition_period = ue_v("SEI: pan_scan_rect_repetition_period", buf);
|
866 |
|
|
}
|
867 |
|
|
|
868 |
|
|
free (buf);
|
869 |
|
|
#ifdef PRINT_PAN_SCAN_RECT
|
870 |
|
|
#undef PRINT_PAN_SCAN_RECT
|
871 |
|
|
#endif
|
872 |
|
|
}
|
873 |
|
|
|
874 |
|
|
|
875 |
|
|
/*!
|
876 |
|
|
************************************************************************
|
877 |
|
|
* \brief
|
878 |
|
|
* Interpret the Random access point SEI message
|
879 |
|
|
* \param payload
|
880 |
|
|
* a pointer that point to the sei payload
|
881 |
|
|
* \param size
|
882 |
|
|
* the size of the sei message
|
883 |
|
|
* \param img
|
884 |
|
|
* the image pointer
|
885 |
|
|
*
|
886 |
|
|
************************************************************************
|
887 |
|
|
*/
|
888 |
|
|
void interpret_recovery_point_info( byte* payload, int size, ImageParameters *img )
|
889 |
|
|
{
|
890 |
|
|
int recovery_frame_cnt, exact_match_flag, broken_link_flag, changing_slice_group_idc;
|
891 |
|
|
|
892 |
|
|
|
893 |
|
|
Bitstream* buf;
|
894 |
|
|
|
895 |
|
|
|
896 |
|
|
buf = malloc(sizeof(Bitstream));
|
897 |
|
|
buf->bitstream_length = size;
|
898 |
|
|
buf->streamBuffer = payload;
|
899 |
|
|
buf->frame_bitoffset = 0;
|
900 |
|
|
|
901 |
|
|
UsedBits = 0;
|
902 |
|
|
|
903 |
|
|
recovery_frame_cnt = ue_v( "SEI: recovery_frame_cnt" , buf);
|
904 |
|
|
exact_match_flag = u_1 ( "SEI: exact_match_flag" , buf);
|
905 |
|
|
broken_link_flag = u_1 ( "SEI: broken_link_flag" , buf);
|
906 |
|
|
changing_slice_group_idc = u_v ( 2, "SEI: changing_slice_group_idc", buf);
|
907 |
|
|
|
908 |
|
|
img->recovery_point = 1;
|
909 |
|
|
img->recovery_frame_cnt = recovery_frame_cnt;
|
910 |
|
|
|
911 |
|
|
#ifdef PRINT_RECOVERY_POINT
|
912 |
|
|
printf("Recovery point SEI message\n");
|
913 |
|
|
printf("recovery_frame_cnt = %d\n", recovery_frame_cnt);
|
914 |
|
|
printf("exact_match_flag = %d\n", exact_match_flag);
|
915 |
|
|
printf("broken_link_flag = %d\n", broken_link_flag);
|
916 |
|
|
printf("changing_slice_group_idc = %d\n", changing_slice_group_idc);
|
917 |
|
|
#endif
|
918 |
|
|
free (buf);
|
919 |
|
|
#ifdef PRINT_RECOVERY_POINT
|
920 |
|
|
#undef PRINT_RECOVERY_POINT
|
921 |
|
|
#endif
|
922 |
|
|
}
|
923 |
|
|
|
924 |
|
|
|
925 |
|
|
/*!
|
926 |
|
|
************************************************************************
|
927 |
|
|
* \brief
|
928 |
|
|
* Interpret the Decoded Picture Buffer Management Repetition SEI message
|
929 |
|
|
* \param payload
|
930 |
|
|
* a pointer that point to the sei payload
|
931 |
|
|
* \param size
|
932 |
|
|
* the size of the sei message
|
933 |
|
|
* \param img
|
934 |
|
|
* the image pointer
|
935 |
|
|
*
|
936 |
|
|
************************************************************************
|
937 |
|
|
*/
|
938 |
|
|
void interpret_dec_ref_pic_marking_repetition_info( byte* payload, int size, ImageParameters *img )
|
939 |
|
|
{
|
940 |
|
|
int original_idr_flag, original_frame_num;
|
941 |
|
|
|
942 |
|
|
DecRefPicMarking_t *tmp_drpm;
|
943 |
|
|
|
944 |
|
|
DecRefPicMarking_t *old_drpm;
|
945 |
|
|
int old_idr_flag , old_no_output_of_prior_pics_flag, old_long_term_reference_flag , old_adaptive_ref_pic_buffering_flag;
|
946 |
|
|
|
947 |
|
|
|
948 |
|
|
Bitstream* buf;
|
949 |
|
|
|
950 |
|
|
buf = malloc(sizeof(Bitstream));
|
951 |
|
|
buf->bitstream_length = size;
|
952 |
|
|
buf->streamBuffer = payload;
|
953 |
|
|
buf->frame_bitoffset = 0;
|
954 |
|
|
|
955 |
|
|
UsedBits = 0;
|
956 |
|
|
|
957 |
|
|
original_idr_flag = u_1 ( "SEI: original_idr_flag" , buf);
|
958 |
|
|
original_frame_num = ue_v( "SEI: original_frame_num" , buf);
|
959 |
|
|
|
960 |
|
|
#ifdef PRINT_DEC_REF_PIC_MARKING
|
961 |
|
|
printf("Decoded Picture Buffer Management Repetition SEI message\n");
|
962 |
|
|
printf("original_idr_flag = %d\n", original_idr_flag);
|
963 |
|
|
printf("original_frame_num = %d\n", original_frame_num);
|
964 |
|
|
#endif
|
965 |
|
|
|
966 |
|
|
// we need to save everything that is probably overwritten in dec_ref_pic_marking()
|
967 |
|
|
old_drpm = img->dec_ref_pic_marking_buffer;
|
968 |
|
|
old_idr_flag = img->idr_flag;
|
969 |
|
|
|
970 |
|
|
old_no_output_of_prior_pics_flag = img->no_output_of_prior_pics_flag;
|
971 |
|
|
old_long_term_reference_flag = img->long_term_reference_flag;
|
972 |
|
|
old_adaptive_ref_pic_buffering_flag = img->adaptive_ref_pic_buffering_flag;
|
973 |
|
|
|
974 |
|
|
// set new initial values
|
975 |
|
|
img->idr_flag = original_idr_flag;
|
976 |
|
|
img->dec_ref_pic_marking_buffer = NULL;
|
977 |
|
|
|
978 |
|
|
dec_ref_pic_marking(buf);
|
979 |
|
|
|
980 |
|
|
// print out decoded values
|
981 |
|
|
#ifdef PRINT_DEC_REF_PIC_MARKING
|
982 |
|
|
if (img->idr_flag)
|
983 |
|
|
{
|
984 |
|
|
printf("no_output_of_prior_pics_flag = %d\n", img->no_output_of_prior_pics_flag);
|
985 |
|
|
printf("long_term_reference_flag = %d\n", img->long_term_reference_flag);
|
986 |
|
|
}
|
987 |
|
|
else
|
988 |
|
|
{
|
989 |
|
|
printf("adaptive_ref_pic_buffering_flag = %d\n", img->adaptive_ref_pic_buffering_flag);
|
990 |
|
|
if (img->adaptive_ref_pic_buffering_flag)
|
991 |
|
|
{
|
992 |
|
|
tmp_drpm=img->dec_ref_pic_marking_buffer;
|
993 |
|
|
while (tmp_drpm != NULL)
|
994 |
|
|
{
|
995 |
|
|
printf("memory_management_control_operation = %d\n", tmp_drpm->memory_management_control_operation);
|
996 |
|
|
|
997 |
|
|
if ((tmp_drpm->memory_management_control_operation==1)||(tmp_drpm->memory_management_control_operation==3))
|
998 |
|
|
{
|
999 |
|
|
printf("difference_of_pic_nums_minus1 = %d\n", tmp_drpm->difference_of_pic_nums_minus1);
|
1000 |
|
|
}
|
1001 |
|
|
if (tmp_drpm->memory_management_control_operation==2)
|
1002 |
|
|
{
|
1003 |
|
|
printf("long_term_pic_num = %d\n", tmp_drpm->long_term_pic_num);
|
1004 |
|
|
}
|
1005 |
|
|
if ((tmp_drpm->memory_management_control_operation==3)||(tmp_drpm->memory_management_control_operation==6))
|
1006 |
|
|
{
|
1007 |
|
|
printf("long_term_frame_idx = %d\n", tmp_drpm->long_term_frame_idx);
|
1008 |
|
|
}
|
1009 |
|
|
if (tmp_drpm->memory_management_control_operation==4)
|
1010 |
|
|
{
|
1011 |
|
|
printf("max_long_term_pic_idx_plus1 = %d\n", tmp_drpm->max_long_term_frame_idx_plus1);
|
1012 |
|
|
}
|
1013 |
|
|
tmp_drpm = tmp_drpm->Next;
|
1014 |
|
|
}
|
1015 |
|
|
}
|
1016 |
|
|
}
|
1017 |
|
|
#endif
|
1018 |
|
|
|
1019 |
|
|
while (img->dec_ref_pic_marking_buffer)
|
1020 |
|
|
{
|
1021 |
|
|
tmp_drpm=img->dec_ref_pic_marking_buffer;
|
1022 |
|
|
|
1023 |
|
|
img->dec_ref_pic_marking_buffer=tmp_drpm->Next;
|
1024 |
|
|
free (tmp_drpm);
|
1025 |
|
|
}
|
1026 |
|
|
|
1027 |
|
|
// restore old values in img
|
1028 |
|
|
img->dec_ref_pic_marking_buffer = old_drpm;
|
1029 |
|
|
img->idr_flag = old_idr_flag;
|
1030 |
|
|
img->no_output_of_prior_pics_flag = old_no_output_of_prior_pics_flag;
|
1031 |
|
|
img->long_term_reference_flag = old_long_term_reference_flag;
|
1032 |
|
|
img->adaptive_ref_pic_buffering_flag = old_adaptive_ref_pic_buffering_flag;
|
1033 |
|
|
|
1034 |
|
|
free (buf);
|
1035 |
|
|
#ifdef PRINT_DEC_REF_PIC_MARKING
|
1036 |
|
|
#undef PRINT_DEC_REF_PIC_MARKING
|
1037 |
|
|
#endif
|
1038 |
|
|
}
|
1039 |
|
|
|
1040 |
|
|
/*!
|
1041 |
|
|
************************************************************************
|
1042 |
|
|
* \brief
|
1043 |
|
|
* Interpret the Full-frame freeze SEI message
|
1044 |
|
|
* \param payload
|
1045 |
|
|
* a pointer that point to the sei payload
|
1046 |
|
|
* \param size
|
1047 |
|
|
* the size of the sei message
|
1048 |
|
|
* \param img
|
1049 |
|
|
* the image pointer
|
1050 |
|
|
*
|
1051 |
|
|
************************************************************************
|
1052 |
|
|
*/
|
1053 |
|
|
void interpret_full_frame_freeze_info( byte* payload, int size, ImageParameters *img )
|
1054 |
|
|
{
|
1055 |
|
|
#ifdef PRINT_FULL_FRAME_FREEZE_INFO
|
1056 |
|
|
printf("Full-frame freeze SEI message\n");
|
1057 |
|
|
if (size)
|
1058 |
|
|
{
|
1059 |
|
|
printf("payload size of this message should be zero, but is %d bytes.\n", size);
|
1060 |
|
|
}
|
1061 |
|
|
#endif
|
1062 |
|
|
|
1063 |
|
|
#ifdef PRINT_FULL_FRAME_FREEZE_INFO
|
1064 |
|
|
#undef PRINT_FULL_FRAME_FREEZE_INFO
|
1065 |
|
|
#endif
|
1066 |
|
|
}
|
1067 |
|
|
|
1068 |
|
|
|
1069 |
|
|
/*!
|
1070 |
|
|
************************************************************************
|
1071 |
|
|
* \brief
|
1072 |
|
|
* Interpret the Full-frame freeze release SEI message
|
1073 |
|
|
* \param payload
|
1074 |
|
|
* a pointer that point to the sei payload
|
1075 |
|
|
* \param size
|
1076 |
|
|
* the size of the sei message
|
1077 |
|
|
* \param img
|
1078 |
|
|
* the image pointer
|
1079 |
|
|
*
|
1080 |
|
|
************************************************************************
|
1081 |
|
|
*/
|
1082 |
|
|
void interpret_full_frame_freeze_release_info( byte* payload, int size, ImageParameters *img )
|
1083 |
|
|
{
|
1084 |
|
|
#ifdef PRINT_FULL_FRAME_FREEZE_RELEASE_INFO
|
1085 |
|
|
printf("Full-frame freeze release SEI message\n");
|
1086 |
|
|
if (size)
|
1087 |
|
|
{
|
1088 |
|
|
printf("payload size of this message should be zero, but is %d bytes.\n", size);
|
1089 |
|
|
}
|
1090 |
|
|
#endif
|
1091 |
|
|
|
1092 |
|
|
#ifdef PRINT_FULL_FRAME_FREEZE_RELEASE_INFO
|
1093 |
|
|
#undef PRINT_FULL_FRAME_FREEZE_RELEASE_INFO
|
1094 |
|
|
#endif
|
1095 |
|
|
}
|
1096 |
|
|
|
1097 |
|
|
/*!
|
1098 |
|
|
************************************************************************
|
1099 |
|
|
* \brief
|
1100 |
|
|
* Interpret the Full-frame snapshot SEI message
|
1101 |
|
|
* \param payload
|
1102 |
|
|
* a pointer that point to the sei payload
|
1103 |
|
|
* \param size
|
1104 |
|
|
* the size of the sei message
|
1105 |
|
|
* \param img
|
1106 |
|
|
* the image pointer
|
1107 |
|
|
*
|
1108 |
|
|
************************************************************************
|
1109 |
|
|
*/
|
1110 |
|
|
void interpret_full_frame_snapshot_info( byte* payload, int size, ImageParameters *img )
|
1111 |
|
|
{
|
1112 |
|
|
int snapshot_id;
|
1113 |
|
|
|
1114 |
|
|
Bitstream* buf;
|
1115 |
|
|
|
1116 |
|
|
buf = malloc(sizeof(Bitstream));
|
1117 |
|
|
buf->bitstream_length = size;
|
1118 |
|
|
buf->streamBuffer = payload;
|
1119 |
|
|
buf->frame_bitoffset = 0;
|
1120 |
|
|
|
1121 |
|
|
UsedBits = 0;
|
1122 |
|
|
|
1123 |
|
|
snapshot_id = ue_v("SEI: snapshot_id", buf);
|
1124 |
|
|
|
1125 |
|
|
#ifdef PRINT_FULL_FRAME_SNAPSHOT_INFO
|
1126 |
|
|
printf("Full-frame snapshot SEI message\n");
|
1127 |
|
|
printf("snapshot_id = %d\n", snapshot_id);
|
1128 |
|
|
#endif
|
1129 |
|
|
free (buf);
|
1130 |
|
|
#ifdef PRINT_FULL_FRAME_SNAPSHOT_INFO
|
1131 |
|
|
#undef PRINT_FULL_FRAME_SNAPSHOT_INFO
|
1132 |
|
|
#endif
|
1133 |
|
|
}
|
1134 |
|
|
|
1135 |
|
|
/*!
|
1136 |
|
|
************************************************************************
|
1137 |
|
|
* \brief
|
1138 |
|
|
* Interpret the Progressive refinement segment start SEI message
|
1139 |
|
|
* \param payload
|
1140 |
|
|
* a pointer that point to the sei payload
|
1141 |
|
|
* \param size
|
1142 |
|
|
* the size of the sei message
|
1143 |
|
|
* \param img
|
1144 |
|
|
* the image pointer
|
1145 |
|
|
*
|
1146 |
|
|
************************************************************************
|
1147 |
|
|
*/
|
1148 |
|
|
void interpret_progressive_refinement_start_info( byte* payload, int size, ImageParameters *img )
|
1149 |
|
|
{
|
1150 |
|
|
int progressive_refinement_id, num_refinement_steps_minus1;
|
1151 |
|
|
|
1152 |
|
|
Bitstream* buf;
|
1153 |
|
|
|
1154 |
|
|
buf = malloc(sizeof(Bitstream));
|
1155 |
|
|
buf->bitstream_length = size;
|
1156 |
|
|
buf->streamBuffer = payload;
|
1157 |
|
|
buf->frame_bitoffset = 0;
|
1158 |
|
|
|
1159 |
|
|
UsedBits = 0;
|
1160 |
|
|
|
1161 |
|
|
progressive_refinement_id = ue_v("SEI: progressive_refinement_id" , buf);
|
1162 |
|
|
num_refinement_steps_minus1 = ue_v("SEI: num_refinement_steps_minus1", buf);
|
1163 |
|
|
|
1164 |
|
|
#ifdef PRINT_PROGRESSIVE_REFINEMENT_START_INFO
|
1165 |
|
|
printf("Progressive refinement segment start SEI message\n");
|
1166 |
|
|
printf("progressive_refinement_id = %d\n", progressive_refinement_id);
|
1167 |
|
|
printf("num_refinement_steps_minus1 = %d\n", num_refinement_steps_minus1);
|
1168 |
|
|
#endif
|
1169 |
|
|
free (buf);
|
1170 |
|
|
#ifdef PRINT_PROGRESSIVE_REFINEMENT_START_INFO
|
1171 |
|
|
#undef PRINT_PROGRESSIVE_REFINEMENT_START_INFO
|
1172 |
|
|
#endif
|
1173 |
|
|
}
|
1174 |
|
|
|
1175 |
|
|
|
1176 |
|
|
/*!
|
1177 |
|
|
************************************************************************
|
1178 |
|
|
* \brief
|
1179 |
|
|
* Interpret the Progressive refinement segment end SEI message
|
1180 |
|
|
* \param payload
|
1181 |
|
|
* a pointer that point to the sei payload
|
1182 |
|
|
* \param size
|
1183 |
|
|
* the size of the sei message
|
1184 |
|
|
* \param img
|
1185 |
|
|
* the image pointer
|
1186 |
|
|
*
|
1187 |
|
|
************************************************************************
|
1188 |
|
|
*/
|
1189 |
|
|
void interpret_progressive_refinement_end_info( byte* payload, int size, ImageParameters *img )
|
1190 |
|
|
{
|
1191 |
|
|
int progressive_refinement_id;
|
1192 |
|
|
|
1193 |
|
|
Bitstream* buf;
|
1194 |
|
|
|
1195 |
|
|
buf = malloc(sizeof(Bitstream));
|
1196 |
|
|
buf->bitstream_length = size;
|
1197 |
|
|
buf->streamBuffer = payload;
|
1198 |
|
|
buf->frame_bitoffset = 0;
|
1199 |
|
|
|
1200 |
|
|
UsedBits = 0;
|
1201 |
|
|
|
1202 |
|
|
progressive_refinement_id = ue_v("SEI: progressive_refinement_id" , buf);
|
1203 |
|
|
|
1204 |
|
|
#ifdef PRINT_PROGRESSIVE_REFINEMENT_END_INFO
|
1205 |
|
|
printf("Progressive refinement segment end SEI message\n");
|
1206 |
|
|
printf("progressive_refinement_id = %d\n", progressive_refinement_id);
|
1207 |
|
|
#endif
|
1208 |
|
|
free (buf);
|
1209 |
|
|
#ifdef PRINT_PROGRESSIVE_REFINEMENT_END_INFO
|
1210 |
|
|
#undef PRINT_PROGRESSIVE_REFINEMENT_END_INFO
|
1211 |
|
|
#endif
|
1212 |
|
|
}
|
1213 |
|
|
|
1214 |
|
|
|
1215 |
|
|
/*!
|
1216 |
|
|
************************************************************************
|
1217 |
|
|
* \brief
|
1218 |
|
|
* Interpret the Motion-constrained slice group set SEI message
|
1219 |
|
|
* \param payload
|
1220 |
|
|
* a pointer that point to the sei payload
|
1221 |
|
|
* \param size
|
1222 |
|
|
* the size of the sei message
|
1223 |
|
|
* \param img
|
1224 |
|
|
* the image pointer
|
1225 |
|
|
*
|
1226 |
|
|
************************************************************************
|
1227 |
|
|
*/
|
1228 |
|
|
void interpret_motion_constrained_slice_group_set_info( byte* payload, int size, ImageParameters *img )
|
1229 |
|
|
{
|
1230 |
|
|
int num_slice_groups_minus1, slice_group_id, exact_match_flag, pan_scan_rect_flag, pan_scan_rect_id;
|
1231 |
|
|
int i;
|
1232 |
|
|
int sliceGroupSize;
|
1233 |
|
|
|
1234 |
|
|
Bitstream* buf;
|
1235 |
|
|
|
1236 |
|
|
buf = malloc(sizeof(Bitstream));
|
1237 |
|
|
buf->bitstream_length = size;
|
1238 |
|
|
buf->streamBuffer = payload;
|
1239 |
|
|
buf->frame_bitoffset = 0;
|
1240 |
|
|
|
1241 |
|
|
UsedBits = 0;
|
1242 |
|
|
|
1243 |
|
|
num_slice_groups_minus1 = ue_v("SEI: num_slice_groups_minus1" , buf);
|
1244 |
|
|
sliceGroupSize = CeilLog2( num_slice_groups_minus1 + 1 );
|
1245 |
|
|
#ifdef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
|
1246 |
|
|
printf("Motion-constrained slice group set SEI message\n");
|
1247 |
|
|
printf("num_slice_groups_minus1 = %d\n", num_slice_groups_minus1);
|
1248 |
|
|
#endif
|
1249 |
|
|
|
1250 |
|
|
for (i=0; i<=num_slice_groups_minus1;i++)
|
1251 |
|
|
{
|
1252 |
|
|
|
1253 |
|
|
slice_group_id = u_v (sliceGroupSize, "SEI: slice_group_id" , buf) ;
|
1254 |
|
|
#ifdef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
|
1255 |
|
|
printf("slice_group_id = %d\n", slice_group_id);
|
1256 |
|
|
#endif
|
1257 |
|
|
}
|
1258 |
|
|
|
1259 |
|
|
exact_match_flag = u_1("SEI: exact_match_flag" , buf);
|
1260 |
|
|
pan_scan_rect_flag = u_1("SEI: pan_scan_rect_flag" , buf);
|
1261 |
|
|
|
1262 |
|
|
#ifdef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
|
1263 |
|
|
printf("exact_match_flag = %d\n", exact_match_flag);
|
1264 |
|
|
printf("pan_scan_rect_flag = %d\n", pan_scan_rect_flag);
|
1265 |
|
|
#endif
|
1266 |
|
|
|
1267 |
|
|
if (pan_scan_rect_flag)
|
1268 |
|
|
{
|
1269 |
|
|
pan_scan_rect_id = ue_v("SEI: pan_scan_rect_id" , buf);
|
1270 |
|
|
#ifdef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
|
1271 |
|
|
printf("pan_scan_rect_id = %d\n", pan_scan_rect_id);
|
1272 |
|
|
#endif
|
1273 |
|
|
}
|
1274 |
|
|
|
1275 |
|
|
free (buf);
|
1276 |
|
|
#ifdef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
|
1277 |
|
|
#undef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
|
1278 |
|
|
#endif
|
1279 |
|
|
}
|
1280 |
|
|
|
1281 |
|
|
/*!
|
1282 |
|
|
************************************************************************
|
1283 |
|
|
* \brief
|
1284 |
|
|
* Interpret the film grain characteristics SEI message
|
1285 |
|
|
* \param payload
|
1286 |
|
|
* a pointer that point to the sei payload
|
1287 |
|
|
* \param size
|
1288 |
|
|
* the size of the sei message
|
1289 |
|
|
* \param img
|
1290 |
|
|
* the image pointer
|
1291 |
|
|
*
|
1292 |
|
|
************************************************************************
|
1293 |
|
|
*/
|
1294 |
|
|
void interpret_film_grain_characteristics_info( byte* payload, int size, ImageParameters *img )
|
1295 |
|
|
{
|
1296 |
|
|
int film_grain_characteristics_cancel_flag;
|
1297 |
|
|
int model_id, separate_colour_description_present_flag;
|
1298 |
|
|
int film_grain_bit_depth_luma_minus8, film_grain_bit_depth_chroma_minus8, film_grain_full_range_flag, film_grain_colour_primaries, film_grain_transfer_characteristics, film_grain_matrix_coefficients;
|
1299 |
|
|
int blending_mode_id, log2_scale_factor, comp_model_present_flag[3];
|
1300 |
|
|
int num_intensity_intervals_minus1, num_model_values_minus1;
|
1301 |
|
|
int intensity_interval_lower_bound, intensity_interval_upper_bound;
|
1302 |
|
|
int comp_model_value;
|
1303 |
|
|
int film_grain_characteristics_repetition_period;
|
1304 |
|
|
|
1305 |
|
|
int c, i, j;
|
1306 |
|
|
|
1307 |
|
|
Bitstream* buf;
|
1308 |
|
|
|
1309 |
|
|
buf = malloc(sizeof(Bitstream));
|
1310 |
|
|
buf->bitstream_length = size;
|
1311 |
|
|
buf->streamBuffer = payload;
|
1312 |
|
|
buf->frame_bitoffset = 0;
|
1313 |
|
|
|
1314 |
|
|
film_grain_characteristics_cancel_flag = u_1("SEI: film_grain_characteristics_cancel_flag", buf);
|
1315 |
|
|
#ifdef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1316 |
|
|
printf("film_grain_characteristics_cancel_flag = %d\n", film_grain_characteristics_cancel_flag);
|
1317 |
|
|
#endif
|
1318 |
|
|
if(!film_grain_characteristics_cancel_flag)
|
1319 |
|
|
{
|
1320 |
|
|
|
1321 |
|
|
model_id = u_v(2, "SEI: model_id", buf);
|
1322 |
|
|
separate_colour_description_present_flag = u_1("SEI: separate_colour_description_present_flag", buf);
|
1323 |
|
|
#ifdef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1324 |
|
|
printf("model_id = %d\n", model_id);
|
1325 |
|
|
printf("separate_colour_description_present_flag = %d\n", separate_colour_description_present_flag);
|
1326 |
|
|
#endif
|
1327 |
|
|
if (separate_colour_description_present_flag)
|
1328 |
|
|
{
|
1329 |
|
|
film_grain_bit_depth_luma_minus8 = u_v(3, "SEI: film_grain_bit_depth_luma_minus8", buf);
|
1330 |
|
|
film_grain_bit_depth_chroma_minus8 = u_v(3, "SEI: film_grain_bit_depth_chroma_minus8", buf);
|
1331 |
|
|
film_grain_full_range_flag = u_v(1, "SEI: film_grain_full_range_flag", buf);
|
1332 |
|
|
film_grain_colour_primaries = u_v(8, "SEI: film_grain_colour_primaries", buf);
|
1333 |
|
|
film_grain_transfer_characteristics = u_v(8, "SEI: film_grain_transfer_characteristics", buf);
|
1334 |
|
|
film_grain_matrix_coefficients = u_v(8, "SEI: film_grain_matrix_coefficients", buf);
|
1335 |
|
|
#ifdef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1336 |
|
|
printf("film_grain_bit_depth_luma_minus8 = %d\n", film_grain_bit_depth_luma_minus8);
|
1337 |
|
|
printf("film_grain_bit_depth_chroma_minus8 = %d\n", film_grain_bit_depth_chroma_minus8);
|
1338 |
|
|
printf("film_grain_full_range_flag = %d\n", film_grain_full_range_flag);
|
1339 |
|
|
printf("film_grain_colour_primaries = %d\n", film_grain_colour_primaries);
|
1340 |
|
|
printf("film_grain_transfer_characteristics = %d\n", film_grain_transfer_characteristics);
|
1341 |
|
|
printf("film_grain_matrix_coefficients = %d\n", film_grain_matrix_coefficients);
|
1342 |
|
|
#endif
|
1343 |
|
|
}
|
1344 |
|
|
blending_mode_id = u_v(2, "SEI: blending_mode_id", buf);
|
1345 |
|
|
log2_scale_factor = u_v(4, "SEI: log2_scale_factor", buf);
|
1346 |
|
|
#ifdef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1347 |
|
|
printf("blending_mode_id = %d\n", blending_mode_id);
|
1348 |
|
|
printf("log2_scale_factor = %d\n", log2_scale_factor);
|
1349 |
|
|
#endif
|
1350 |
|
|
for (c = 0; c < 3; c ++)
|
1351 |
|
|
{
|
1352 |
|
|
comp_model_present_flag[c] = u_1("SEI: comp_model_present_flag", buf);
|
1353 |
|
|
#ifdef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1354 |
|
|
printf("comp_model_present_flag = %d\n", comp_model_present_flag[c]);
|
1355 |
|
|
#endif
|
1356 |
|
|
}
|
1357 |
|
|
for (c = 0; c < 3; c ++)
|
1358 |
|
|
if (comp_model_present_flag[c])
|
1359 |
|
|
{
|
1360 |
|
|
num_intensity_intervals_minus1 = u_v(8, "SEI: num_intensity_intervals_minus1", buf);
|
1361 |
|
|
num_model_values_minus1 = u_v(3, "SEI: num_model_values_minus1", buf);
|
1362 |
|
|
#ifdef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1363 |
|
|
printf("num_intensity_intervals_minus1 = %d\n", num_intensity_intervals_minus1);
|
1364 |
|
|
printf("num_model_values_minus1 = %d\n", num_model_values_minus1);
|
1365 |
|
|
#endif
|
1366 |
|
|
for (i = 0; i <= num_intensity_intervals_minus1; i ++)
|
1367 |
|
|
{
|
1368 |
|
|
intensity_interval_lower_bound = u_v(8, "SEI: intensity_interval_lower_bound", buf);
|
1369 |
|
|
intensity_interval_upper_bound = u_v(8, "SEI: intensity_interval_upper_bound", buf);
|
1370 |
|
|
#ifdef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1371 |
|
|
printf("intensity_interval_lower_bound = %d\n", intensity_interval_lower_bound);
|
1372 |
|
|
printf("intensity_interval_upper_bound = %d\n", intensity_interval_upper_bound);
|
1373 |
|
|
#endif
|
1374 |
|
|
for (j = 0; j <= num_model_values_minus1; j++)
|
1375 |
|
|
{
|
1376 |
|
|
comp_model_value = se_v("SEI: comp_model_value", buf);
|
1377 |
|
|
#ifdef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1378 |
|
|
printf("comp_model_value = %d\n", comp_model_value);
|
1379 |
|
|
#endif
|
1380 |
|
|
}
|
1381 |
|
|
}
|
1382 |
|
|
}
|
1383 |
|
|
film_grain_characteristics_repetition_period = ue_v("SEI: film_grain_characteristics_repetition_period", buf);
|
1384 |
|
|
#ifdef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1385 |
|
|
printf("film_grain_characteristics_repetition_period = %d\n", film_grain_characteristics_repetition_period);
|
1386 |
|
|
#endif
|
1387 |
|
|
}
|
1388 |
|
|
|
1389 |
|
|
free (buf);
|
1390 |
|
|
#ifdef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1391 |
|
|
#undef PRINT_FILM_GRAIN_CHARACTERISTICS_INFO
|
1392 |
|
|
#endif
|
1393 |
|
|
}
|
1394 |
|
|
|
1395 |
|
|
/*!
|
1396 |
|
|
************************************************************************
|
1397 |
|
|
* \brief
|
1398 |
|
|
* Interpret the deblocking filter display preference SEI message
|
1399 |
|
|
* \param payload
|
1400 |
|
|
* a pointer that point to the sei payload
|
1401 |
|
|
* \param size
|
1402 |
|
|
* the size of the sei message
|
1403 |
|
|
* \param img
|
1404 |
|
|
* the image pointer
|
1405 |
|
|
*
|
1406 |
|
|
************************************************************************
|
1407 |
|
|
*/
|
1408 |
|
|
void interpret_deblocking_filter_display_preference_info( byte* payload, int size, ImageParameters *img )
|
1409 |
|
|
{
|
1410 |
|
|
int deblocking_display_preference_cancel_flag;
|
1411 |
|
|
int display_prior_to_deblocking_preferred_flag, dec_frame_buffering_constraint_flag, deblocking_display_preference_repetition_period;
|
1412 |
|
|
|
1413 |
|
|
Bitstream* buf;
|
1414 |
|
|
|
1415 |
|
|
buf = malloc(sizeof(Bitstream));
|
1416 |
|
|
buf->bitstream_length = size;
|
1417 |
|
|
buf->streamBuffer = payload;
|
1418 |
|
|
buf->frame_bitoffset = 0;
|
1419 |
|
|
|
1420 |
|
|
deblocking_display_preference_cancel_flag = u_1("SEI: deblocking_display_preference_cancel_flag", buf);
|
1421 |
|
|
#ifdef PRINT_DEBLOCKING_FILTER_DISPLAY_PREFERENCE_INFO
|
1422 |
|
|
printf("deblocking_display_preference_cancel_flag = %d\n", deblocking_display_preference_cancel_flag);
|
1423 |
|
|
#endif
|
1424 |
|
|
if(!deblocking_display_preference_cancel_flag)
|
1425 |
|
|
{
|
1426 |
|
|
display_prior_to_deblocking_preferred_flag = u_1("SEI: display_prior_to_deblocking_preferred_flag", buf);
|
1427 |
|
|
dec_frame_buffering_constraint_flag = u_1("SEI: dec_frame_buffering_constraint_flag", buf);
|
1428 |
|
|
deblocking_display_preference_repetition_period = ue_v("SEI: deblocking_display_preference_repetition_period", buf);
|
1429 |
|
|
#ifdef PRINT_DEBLOCKING_FILTER_DISPLAY_PREFERENCE_INFO
|
1430 |
|
|
printf("display_prior_to_deblocking_preferred_flag = %d\n", display_prior_to_deblocking_preferred_flag);
|
1431 |
|
|
printf("dec_frame_buffering_constraint_flag = %d\n", dec_frame_buffering_constraint_flag);
|
1432 |
|
|
printf("deblocking_display_preference_repetition_period = %d\n", deblocking_display_preference_repetition_period);
|
1433 |
|
|
#endif
|
1434 |
|
|
}
|
1435 |
|
|
|
1436 |
|
|
free (buf);
|
1437 |
|
|
#ifdef PRINT_DEBLOCKING_FILTER_DISPLAY_PREFERENCE_INFO
|
1438 |
|
|
#undef PRINT_DEBLOCKING_FILTER_DISPLAY_PREFERENCE_INFO
|
1439 |
|
|
#endif
|
1440 |
|
|
}
|
1441 |
|
|
|
1442 |
|
|
/*!
|
1443 |
|
|
************************************************************************
|
1444 |
|
|
* \brief
|
1445 |
|
|
* Interpret the stereo video info SEI message
|
1446 |
|
|
* \param payload
|
1447 |
|
|
* a pointer that point to the sei payload
|
1448 |
|
|
* \param size
|
1449 |
|
|
* the size of the sei message
|
1450 |
|
|
* \param img
|
1451 |
|
|
* the image pointer
|
1452 |
|
|
*
|
1453 |
|
|
************************************************************************
|
1454 |
|
|
*/
|
1455 |
|
|
void interpret_stereo_video_info_info( byte* payload, int size, ImageParameters *img )
|
1456 |
|
|
{
|
1457 |
|
|
int field_views_flags;
|
1458 |
|
|
int top_field_is_left_view_flag, current_frame_is_left_view_flag, next_frame_is_second_view_flag;
|
1459 |
|
|
int left_view_self_contained_flag;
|
1460 |
|
|
int right_view_self_contained_flag;
|
1461 |
|
|
|
1462 |
|
|
Bitstream* buf;
|
1463 |
|
|
|
1464 |
|
|
buf = malloc(sizeof(Bitstream));
|
1465 |
|
|
buf->bitstream_length = size;
|
1466 |
|
|
buf->streamBuffer = payload;
|
1467 |
|
|
buf->frame_bitoffset = 0;
|
1468 |
|
|
|
1469 |
|
|
field_views_flags = u_1("SEI: field_views_flags", buf);
|
1470 |
|
|
#ifdef PRINT_STEREO_VIDEO_INFO_INFO
|
1471 |
|
|
printf("field_views_flags = %d\n", field_views_flags);
|
1472 |
|
|
#endif
|
1473 |
|
|
if (field_views_flags)
|
1474 |
|
|
{
|
1475 |
|
|
top_field_is_left_view_flag = u_1("SEI: top_field_is_left_view_flag", buf);
|
1476 |
|
|
#ifdef PRINT_STEREO_VIDEO_INFO_INFO
|
1477 |
|
|
printf("top_field_is_left_view_flag = %d\n", top_field_is_left_view_flag);
|
1478 |
|
|
#endif
|
1479 |
|
|
}
|
1480 |
|
|
else
|
1481 |
|
|
{
|
1482 |
|
|
current_frame_is_left_view_flag = u_1("SEI: current_frame_is_left_view_flag", buf);
|
1483 |
|
|
next_frame_is_second_view_flag = u_1("SEI: next_frame_is_second_view_flag", buf);
|
1484 |
|
|
#ifdef PRINT_STEREO_VIDEO_INFO_INFO
|
1485 |
|
|
printf("current_frame_is_left_view_flag = %d\n", current_frame_is_left_view_flag);
|
1486 |
|
|
printf("next_frame_is_second_view_flag = %d\n", next_frame_is_second_view_flag);
|
1487 |
|
|
#endif
|
1488 |
|
|
}
|
1489 |
|
|
|
1490 |
|
|
left_view_self_contained_flag = u_1("SEI: left_view_self_contained_flag", buf);
|
1491 |
|
|
right_view_self_contained_flag = u_1("SEI: right_view_self_contained_flag", buf);
|
1492 |
|
|
#ifdef PRINT_STEREO_VIDEO_INFO_INFO
|
1493 |
|
|
printf("left_view_self_contained_flag = %d\n", left_view_self_contained_flag);
|
1494 |
|
|
printf("right_view_self_contained_flag = %d\n", right_view_self_contained_flag);
|
1495 |
|
|
#endif
|
1496 |
|
|
|
1497 |
|
|
free (buf);
|
1498 |
|
|
#ifdef PRINT_STEREO_VIDEO_INFO_INFO
|
1499 |
|
|
#undef PRINT_STEREO_VIDEO_INFO_INFO
|
1500 |
|
|
#endif
|
1501 |
|
|
}
|
1502 |
|
|
|
1503 |
|
|
/*!
|
1504 |
|
|
************************************************************************
|
1505 |
|
|
* \brief
|
1506 |
|
|
* Interpret the Reserved SEI message
|
1507 |
|
|
* \param payload
|
1508 |
|
|
* a pointer that point to the sei payload
|
1509 |
|
|
* \param size
|
1510 |
|
|
* the size of the sei message
|
1511 |
|
|
* \param img
|
1512 |
|
|
* the image pointer
|
1513 |
|
|
*
|
1514 |
|
|
************************************************************************
|
1515 |
|
|
*/
|
1516 |
|
|
void interpret_reserved_info( byte* payload, int size, ImageParameters *img )
|
1517 |
|
|
{
|
1518 |
|
|
int offset = 0;
|
1519 |
|
|
byte payload_byte;
|
1520 |
|
|
|
1521 |
|
|
#ifdef PRINT_RESERVED_INFO
|
1522 |
|
|
printf("Reserved SEI message\n");
|
1523 |
|
|
#endif
|
1524 |
|
|
|
1525 |
|
|
while (offset < size)
|
1526 |
|
|
{
|
1527 |
|
|
payload_byte = payload[offset];
|
1528 |
|
|
offset ++;
|
1529 |
|
|
#ifdef PRINT_RESERVED_INFO
|
1530 |
|
|
printf("reserved_sei_message_payload_byte = %d\n", payload_byte);
|
1531 |
|
|
#endif
|
1532 |
|
|
}
|
1533 |
|
|
#ifdef PRINT_RESERVED_INFO
|
1534 |
|
|
#undef PRINT_RESERVED_INFO
|
1535 |
|
|
#endif
|
1536 |
|
|
}
|
1537 |
|
|
|
1538 |
|
|
|
1539 |
|
|
/*!
|
1540 |
|
|
************************************************************************
|
1541 |
|
|
* \brief
|
1542 |
|
|
* Interpret the Buffering period SEI message
|
1543 |
|
|
* \param payload
|
1544 |
|
|
* a pointer that point to the sei payload
|
1545 |
|
|
* \param size
|
1546 |
|
|
* the size of the sei message
|
1547 |
|
|
* \param img
|
1548 |
|
|
* the image pointer
|
1549 |
|
|
*
|
1550 |
|
|
************************************************************************
|
1551 |
|
|
*/
|
1552 |
|
|
void interpret_buffering_period_info( byte* payload, int size, ImageParameters *img )
|
1553 |
|
|
{
|
1554 |
|
|
int seq_parameter_set_id, initial_cpb_removal_delay, initial_cpb_removal_delay_offset;
|
1555 |
|
|
unsigned int k;
|
1556 |
|
|
|
1557 |
|
|
Bitstream* buf;
|
1558 |
|
|
seq_parameter_set_rbsp_t *sps;
|
1559 |
|
|
|
1560 |
|
|
|
1561 |
|
|
buf = malloc(sizeof(Bitstream));
|
1562 |
|
|
buf->bitstream_length = size;
|
1563 |
|
|
buf->streamBuffer = payload;
|
1564 |
|
|
buf->frame_bitoffset = 0;
|
1565 |
|
|
|
1566 |
|
|
UsedBits = 0;
|
1567 |
|
|
|
1568 |
|
|
seq_parameter_set_id = ue_v("SEI: seq_parameter_set_id" , buf);
|
1569 |
|
|
|
1570 |
|
|
sps = &SeqParSet[seq_parameter_set_id];
|
1571 |
|
|
|
1572 |
|
|
activate_sps(sps);
|
1573 |
|
|
|
1574 |
|
|
#ifdef PRINT_BUFFERING_PERIOD_INFO
|
1575 |
|
|
printf("Buffering period SEI message\n");
|
1576 |
|
|
printf("seq_parameter_set_id = %d\n", seq_parameter_set_id);
|
1577 |
|
|
#endif
|
1578 |
|
|
|
1579 |
|
|
// Note: NalHrdBpPresentFlag and CpbDpbDelaysPresentFlag can also be set "by some means not specified in this Recommendation | International Standard"
|
1580 |
|
|
if (sps->vui_parameters_present_flag)
|
1581 |
|
|
{
|
1582 |
|
|
|
1583 |
|
|
if (sps->vui_seq_parameters.nal_hrd_parameters_present_flag)
|
1584 |
|
|
{
|
1585 |
|
|
for (k=0; k<sps->vui_seq_parameters.nal_hrd_parameters.cpb_cnt_minus1+1; k++)
|
1586 |
|
|
{
|
1587 |
|
|
initial_cpb_removal_delay = u_v(sps->vui_seq_parameters.nal_hrd_parameters.initial_cpb_removal_delay_length_minus1+1, "SEI: initial_cpb_removal_delay" , buf);
|
1588 |
|
|
initial_cpb_removal_delay_offset = u_v(sps->vui_seq_parameters.nal_hrd_parameters.initial_cpb_removal_delay_length_minus1+1, "SEI: initial_cpb_removal_delay_offset" , buf);
|
1589 |
|
|
|
1590 |
|
|
#ifdef PRINT_BUFFERING_PERIOD_INFO
|
1591 |
|
|
printf("nal initial_cpb_removal_delay[%d] = %d\n", k, initial_cpb_removal_delay);
|
1592 |
|
|
printf("nal initial_cpb_removal_delay_offset[%d] = %d\n", k, initial_cpb_removal_delay_offset);
|
1593 |
|
|
#endif
|
1594 |
|
|
}
|
1595 |
|
|
}
|
1596 |
|
|
|
1597 |
|
|
if (sps->vui_seq_parameters.vcl_hrd_parameters_present_flag)
|
1598 |
|
|
{
|
1599 |
|
|
for (k=0; k<sps->vui_seq_parameters.vcl_hrd_parameters.cpb_cnt_minus1+1; k++)
|
1600 |
|
|
{
|
1601 |
|
|
initial_cpb_removal_delay = u_v(sps->vui_seq_parameters.vcl_hrd_parameters.initial_cpb_removal_delay_length_minus1+1, "SEI: initial_cpb_removal_delay" , buf);
|
1602 |
|
|
initial_cpb_removal_delay_offset = u_v(sps->vui_seq_parameters.vcl_hrd_parameters.initial_cpb_removal_delay_length_minus1+1, "SEI: initial_cpb_removal_delay_offset" , buf);
|
1603 |
|
|
|
1604 |
|
|
#ifdef PRINT_BUFFERING_PERIOD_INFO
|
1605 |
|
|
printf("vcl initial_cpb_removal_delay[%d] = %d\n", k, initial_cpb_removal_delay);
|
1606 |
|
|
printf("vcl initial_cpb_removal_delay_offset[%d] = %d\n", k, initial_cpb_removal_delay_offset);
|
1607 |
|
|
#endif
|
1608 |
|
|
}
|
1609 |
|
|
}
|
1610 |
|
|
}
|
1611 |
|
|
|
1612 |
|
|
free (buf);
|
1613 |
|
|
#ifdef PRINT_BUFFERING_PERIOD_INFO
|
1614 |
|
|
#undef PRINT_BUFFERING_PERIOD_INFO
|
1615 |
|
|
#endif
|
1616 |
|
|
}
|
1617 |
|
|
|
1618 |
|
|
|
1619 |
|
|
/*!
|
1620 |
|
|
************************************************************************
|
1621 |
|
|
* \brief
|
1622 |
|
|
* Interpret the Picture timing SEI message
|
1623 |
|
|
* \param payload
|
1624 |
|
|
* a pointer that point to the sei payload
|
1625 |
|
|
* \param size
|
1626 |
|
|
* the size of the sei message
|
1627 |
|
|
* \param img
|
1628 |
|
|
* the image pointer
|
1629 |
|
|
*
|
1630 |
|
|
************************************************************************
|
1631 |
|
|
*/
|
1632 |
|
|
void interpret_picture_timing_info( byte* payload, int size, ImageParameters *img )
|
1633 |
|
|
{
|
1634 |
|
|
int cpb_removal_delay, dpb_output_delay, picture_structure_present_flag, picture_structure;
|
1635 |
|
|
int clock_time_stamp_flag;
|
1636 |
|
|
int ct_type, nuit_field_based_flag, counting_type, full_timestamp_flag, discontinuity_flag, cnt_dropped_flag, nframes;
|
1637 |
|
|
int seconds_value, minutes_value, hours_value, seconds_flag, minutes_flag, hours_flag, time_offset;
|
1638 |
|
|
int NumClockTs = 0;
|
1639 |
|
|
int i;
|
1640 |
|
|
|
1641 |
|
|
int cpb_removal_len = 24;
|
1642 |
|
|
int dpb_output_len = 24;
|
1643 |
|
|
|
1644 |
|
|
Boolean CpbDpbDelaysPresentFlag;
|
1645 |
|
|
|
1646 |
|
|
Bitstream* buf;
|
1647 |
|
|
|
1648 |
|
|
if (NULL==active_sps)
|
1649 |
|
|
{
|
1650 |
|
|
fprintf (stderr, "Warning: no active SPS, timing SEI cannot be parsed\n");
|
1651 |
|
|
return;
|
1652 |
|
|
}
|
1653 |
|
|
|
1654 |
|
|
buf = malloc(sizeof(Bitstream));
|
1655 |
|
|
buf->bitstream_length = size;
|
1656 |
|
|
buf->streamBuffer = payload;
|
1657 |
|
|
buf->frame_bitoffset = 0;
|
1658 |
|
|
|
1659 |
|
|
UsedBits = 0;
|
1660 |
|
|
|
1661 |
|
|
|
1662 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1663 |
|
|
printf("Picture timing SEI message\n");
|
1664 |
|
|
#endif
|
1665 |
|
|
|
1666 |
|
|
// CpbDpbDelaysPresentFlag can also be set "by some means not specified in this Recommendation | International Standard"
|
1667 |
|
|
CpbDpbDelaysPresentFlag = (Boolean) (active_sps->vui_parameters_present_flag
|
1668 |
|
|
&& ( (active_sps->vui_seq_parameters.nal_hrd_parameters_present_flag != 0)
|
1669 |
|
|
||(active_sps->vui_seq_parameters.vcl_hrd_parameters_present_flag != 0)));
|
1670 |
|
|
|
1671 |
|
|
if (CpbDpbDelaysPresentFlag )
|
1672 |
|
|
{
|
1673 |
|
|
if (active_sps->vui_parameters_present_flag)
|
1674 |
|
|
{
|
1675 |
|
|
if (active_sps->vui_seq_parameters.nal_hrd_parameters_present_flag)
|
1676 |
|
|
{
|
1677 |
|
|
cpb_removal_len = active_sps->vui_seq_parameters.nal_hrd_parameters.cpb_removal_delay_length_minus1 + 1;
|
1678 |
|
|
dpb_output_len = active_sps->vui_seq_parameters.nal_hrd_parameters.dpb_output_delay_length_minus1 + 1;
|
1679 |
|
|
}
|
1680 |
|
|
else if (active_sps->vui_seq_parameters.vcl_hrd_parameters_present_flag)
|
1681 |
|
|
{
|
1682 |
|
|
cpb_removal_len = active_sps->vui_seq_parameters.vcl_hrd_parameters.cpb_removal_delay_length_minus1 + 1;
|
1683 |
|
|
dpb_output_len = active_sps->vui_seq_parameters.vcl_hrd_parameters.dpb_output_delay_length_minus1 + 1;
|
1684 |
|
|
}
|
1685 |
|
|
}
|
1686 |
|
|
|
1687 |
|
|
if ((active_sps->vui_seq_parameters.nal_hrd_parameters_present_flag)||
|
1688 |
|
|
(active_sps->vui_seq_parameters.vcl_hrd_parameters_present_flag))
|
1689 |
|
|
{
|
1690 |
|
|
cpb_removal_delay = u_v(cpb_removal_len, "SEI: cpb_removal_delay" , buf);
|
1691 |
|
|
dpb_output_delay = u_v(dpb_output_len, "SEI: dpb_output_delay" , buf);
|
1692 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1693 |
|
|
printf("cpb_removal_delay = %d\n",cpb_removal_delay);
|
1694 |
|
|
printf("dpb_output_delay = %d\n",dpb_output_delay);
|
1695 |
|
|
#endif
|
1696 |
|
|
}
|
1697 |
|
|
}
|
1698 |
|
|
|
1699 |
|
|
if (!active_sps->vui_parameters_present_flag)
|
1700 |
|
|
{
|
1701 |
|
|
picture_structure_present_flag = 0;
|
1702 |
|
|
}
|
1703 |
|
|
else
|
1704 |
|
|
{
|
1705 |
|
|
picture_structure_present_flag = active_sps->vui_seq_parameters.pic_struct_present_flag;
|
1706 |
|
|
}
|
1707 |
|
|
|
1708 |
|
|
if (picture_structure_present_flag)
|
1709 |
|
|
{
|
1710 |
|
|
picture_structure = u_v(4, "SEI: pic_struct" , buf);
|
1711 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1712 |
|
|
printf("picture_structure = %d\n",picture_structure);
|
1713 |
|
|
#endif
|
1714 |
|
|
switch (picture_structure)
|
1715 |
|
|
{
|
1716 |
|
|
case 0:
|
1717 |
|
|
case 1:
|
1718 |
|
|
case 2:
|
1719 |
|
|
NumClockTs = 1;
|
1720 |
|
|
break;
|
1721 |
|
|
case 3:
|
1722 |
|
|
case 4:
|
1723 |
|
|
case 7:
|
1724 |
|
|
NumClockTs = 2;
|
1725 |
|
|
break;
|
1726 |
|
|
case 5:
|
1727 |
|
|
case 6:
|
1728 |
|
|
case 8:
|
1729 |
|
|
NumClockTs = 3;
|
1730 |
|
|
break;
|
1731 |
|
|
default:
|
1732 |
|
|
error("reserved picture_structure used (can't determine NumClockTs)", 500);
|
1733 |
|
|
}
|
1734 |
|
|
for (i=0; i<NumClockTs; i++)
|
1735 |
|
|
{
|
1736 |
|
|
clock_time_stamp_flag = u_1("SEI: clock_time_stamp_flag" , buf);
|
1737 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1738 |
|
|
printf("clock_time_stamp_flag = %d\n",clock_time_stamp_flag);
|
1739 |
|
|
#endif
|
1740 |
|
|
if (clock_time_stamp_flag)
|
1741 |
|
|
{
|
1742 |
|
|
ct_type = u_v(2, "SEI: ct_type" , buf);
|
1743 |
|
|
nuit_field_based_flag = u_1( "SEI: nuit_field_based_flag" , buf);
|
1744 |
|
|
counting_type = u_v(5, "SEI: counting_type" , buf);
|
1745 |
|
|
full_timestamp_flag = u_1( "SEI: full_timestamp_flag" , buf);
|
1746 |
|
|
discontinuity_flag = u_1( "SEI: discontinuity_flag" , buf);
|
1747 |
|
|
cnt_dropped_flag = u_1( "SEI: cnt_dropped_flag" , buf);
|
1748 |
|
|
nframes = u_v(8, "SEI: nframes" , buf);
|
1749 |
|
|
|
1750 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1751 |
|
|
printf("ct_type = %d\n",ct_type);
|
1752 |
|
|
printf("nuit_field_based_flag = %d\n",nuit_field_based_flag);
|
1753 |
|
|
printf("full_timestamp_flag = %d\n",full_timestamp_flag);
|
1754 |
|
|
printf("discontinuity_flag = %d\n",discontinuity_flag);
|
1755 |
|
|
printf("cnt_dropped_flag = %d\n",cnt_dropped_flag);
|
1756 |
|
|
printf("nframes = %d\n",nframes);
|
1757 |
|
|
#endif
|
1758 |
|
|
if (full_timestamp_flag)
|
1759 |
|
|
{
|
1760 |
|
|
seconds_value = u_v(6, "SEI: seconds_value" , buf);
|
1761 |
|
|
minutes_value = u_v(6, "SEI: minutes_value" , buf);
|
1762 |
|
|
hours_value = u_v(5, "SEI: hours_value" , buf);
|
1763 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1764 |
|
|
printf("seconds_value = %d\n",seconds_value);
|
1765 |
|
|
printf("minutes_value = %d\n",minutes_value);
|
1766 |
|
|
printf("hours_value = %d\n",hours_value);
|
1767 |
|
|
#endif
|
1768 |
|
|
}
|
1769 |
|
|
else
|
1770 |
|
|
{
|
1771 |
|
|
seconds_flag = u_1( "SEI: seconds_flag" , buf);
|
1772 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1773 |
|
|
printf("seconds_flag = %d\n",seconds_flag);
|
1774 |
|
|
#endif
|
1775 |
|
|
if (seconds_flag)
|
1776 |
|
|
{
|
1777 |
|
|
seconds_value = u_v(6, "SEI: seconds_value" , buf);
|
1778 |
|
|
minutes_flag = u_1( "SEI: minutes_flag" , buf);
|
1779 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1780 |
|
|
printf("seconds_value = %d\n",seconds_value);
|
1781 |
|
|
printf("minutes_flag = %d\n",minutes_flag);
|
1782 |
|
|
#endif
|
1783 |
|
|
if(minutes_flag)
|
1784 |
|
|
{
|
1785 |
|
|
minutes_value = u_v(6, "SEI: minutes_value" , buf);
|
1786 |
|
|
hours_flag = u_1( "SEI: hours_flag" , buf);
|
1787 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1788 |
|
|
printf("minutes_value = %d\n",minutes_value);
|
1789 |
|
|
printf("hours_flag = %d\n",hours_flag);
|
1790 |
|
|
#endif
|
1791 |
|
|
if(hours_flag)
|
1792 |
|
|
{
|
1793 |
|
|
hours_value = u_v(5, "SEI: hours_value" , buf);
|
1794 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1795 |
|
|
printf("hours_value = %d\n",hours_value);
|
1796 |
|
|
#endif
|
1797 |
|
|
}
|
1798 |
|
|
}
|
1799 |
|
|
}
|
1800 |
|
|
}
|
1801 |
|
|
{
|
1802 |
|
|
int time_offset_length;
|
1803 |
|
|
if (active_sps->vui_seq_parameters.vcl_hrd_parameters_present_flag)
|
1804 |
|
|
time_offset_length = active_sps->vui_seq_parameters.vcl_hrd_parameters.time_offset_length;
|
1805 |
|
|
else if (active_sps->vui_seq_parameters.nal_hrd_parameters_present_flag)
|
1806 |
|
|
time_offset_length = active_sps->vui_seq_parameters.nal_hrd_parameters.time_offset_length;
|
1807 |
|
|
else
|
1808 |
|
|
time_offset_length = 24;
|
1809 |
|
|
if (time_offset_length)
|
1810 |
|
|
time_offset = u_v(time_offset_length, "SEI: time_offset" , buf); // TODO interpretation is unsigned, need signed interpretation (i_v)
|
1811 |
|
|
else
|
1812 |
|
|
time_offset = 0;
|
1813 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1814 |
|
|
printf("time_offset = %d\n",time_offset);
|
1815 |
|
|
#endif
|
1816 |
|
|
}
|
1817 |
|
|
}
|
1818 |
|
|
}
|
1819 |
|
|
}
|
1820 |
|
|
|
1821 |
|
|
free (buf);
|
1822 |
|
|
#ifdef PRINT_PCITURE_TIMING_INFO
|
1823 |
|
|
#undef PRINT_PCITURE_TIMING_INFO
|
1824 |
|
|
#endif
|
1825 |
|
|
}
|