1 #define H264_PARSE_SEI_C
2
3 #ifdef H264_PARSE_SEI_C
4
5 #include "h264.h"
6 #include "h264parse.h"
7 #include "h264parse_dpb.h"
8
9 #include "viddec_parser_ops.h"
10
11 #include "viddec_fw_item_types.h"
12 #include "viddec_fw_workload.h"
13
14 //////////////////////////////////////////////////////////////////////////////
15 // avc_sei_stream_initialise ()
16 //
17 //
18
h264_sei_stream_initialise(h264_Info * pInfo)19 void h264_sei_stream_initialise (h264_Info* pInfo)
20 {
21 pInfo->sei_information.capture_POC = 0;
22 pInfo->sei_information.disp_frozen = 0;
23 pInfo->sei_information.release_POC = 0;
24 pInfo->sei_information.capture_fn = 0;
25 pInfo->sei_information.recovery_fn = 0xFFFFFFFF;
26 pInfo->sei_information.scan_format = 0;
27 pInfo->sei_information.broken_link_pic = 0;
28 return;
29 }
30 /* ------------------------------------------------------------------------------------------ */
31 /* ------------------------------------------------------------------------------------------ */
32 /* ------------------------------------------------------------------------------------------ */
h264_sei_buffering_period(void * parent,h264_Info * pInfo)33 h264_Status h264_sei_buffering_period(void *parent,h264_Info* pInfo)
34 {
35 h264_Status ret = H264_STATUS_SEI_ERROR;
36
37 h264_SEI_buffering_period_t* sei_msg_ptr;
38 h264_SEI_buffering_period_t sei_buffering_period;
39 int32_t SchedSelIdx;
40 int num_bits = 0;
41
42 sei_msg_ptr = (h264_SEI_buffering_period_t *)(&sei_buffering_period);
43
44 do{
45 if(pInfo->active_SPS.sps_disp.vui_seq_parameters.nal_hrd_parameters_present_flag == 1)
46 {
47 num_bits = pInfo->active_SPS.sps_disp.vui_seq_parameters.nal_hrd_initial_cpb_removal_delay_length_minus1 + 1;
48 }
49 else if(pInfo->active_SPS.sps_disp.vui_seq_parameters.vcl_hrd_parameters_present_flag)
50 {
51 num_bits = pInfo->active_SPS.sps_disp.vui_seq_parameters.nal_hrd_initial_cpb_removal_delay_length_minus1 + 1;
52 }
53
54 sei_msg_ptr->seq_param_set_id = h264_GetVLCElement(parent, pInfo, false);
55 if(sei_msg_ptr->seq_param_set_id >= NUM_SPS)
56 break;
57
58 //check if this id is same as the id of the current SPS //fix
59
60 if(pInfo->active_SPS.sps_disp.vui_seq_parameters.nal_hrd_parameters_present_flag == 1)
61 {
62 if(pInfo->active_SPS.sps_disp.vui_seq_parameters.nal_hrd_cpb_cnt_minus1 >= MAX_CPB_CNT)
63 break;
64
65 for(SchedSelIdx = 0; SchedSelIdx <= pInfo->active_SPS.sps_disp.vui_seq_parameters.nal_hrd_cpb_cnt_minus1; SchedSelIdx++)
66 {
67 viddec_pm_get_bits(parent, (uint32_t *)&sei_msg_ptr->initial_cpb_removal_delay_nal, num_bits);
68 viddec_pm_get_bits(parent, (uint32_t *)&sei_msg_ptr->initial_cpb_removal_delay_offset_nal, num_bits);
69 }
70 }
71
72 if(pInfo->active_SPS.sps_disp.vui_seq_parameters.vcl_hrd_parameters_present_flag == 1)
73 {
74 if(pInfo->active_SPS.sps_disp.vui_seq_parameters.vcl_hrd_cpb_cnt_minus1 >= MAX_CPB_CNT)
75 break;
76
77 for(SchedSelIdx = 0; SchedSelIdx <= pInfo->active_SPS.sps_disp.vui_seq_parameters.vcl_hrd_cpb_cnt_minus1; SchedSelIdx++)
78 {
79 viddec_pm_get_bits(parent, (uint32_t *)&sei_msg_ptr->initial_cpb_removal_delay_vcl, num_bits);
80 viddec_pm_get_bits(parent, (uint32_t *)&sei_msg_ptr->initial_cpb_removal_delay_offset_vcl, num_bits);
81 }
82 }
83
84 ret = H264_STATUS_OK;
85 } while (0);
86
87 return H264_STATUS_OK;
88 }
89 /* ------------------------------------------------------------------------------------------ */
90 /* ------------------------------------------------------------------------------------------ */
91 /* ------------------------------------------------------------------------------------------ */
h264_sei_pic_timing(void * parent,h264_Info * pInfo)92 h264_Status h264_sei_pic_timing(void *parent,h264_Info* pInfo)
93 {
94 int32_t CpbDpbDelaysPresentFlag = 0;
95 h264_SEI_pic_timing_t* sei_msg_ptr;
96 h264_SEI_pic_timing_t sei_pic_timing;
97 int32_t num_bits_cpb = 0, num_bits_dpb = 0, time_offset_length = 0;
98 uint32_t code;
99 uint32_t clock_timestamp_flag = 0;
100 uint32_t full_timestamp_flag = 0;
101 uint32_t seconds_flag = 0;
102 uint32_t minutes_flag = 0;
103 uint32_t hours_flag = 0;
104 uint32_t time_offset = 0;
105
106
107
108
109 sei_msg_ptr = (h264_SEI_pic_timing_t *)(&sei_pic_timing);
110
111 if(pInfo->active_SPS.sps_disp.vui_seq_parameters.nal_hrd_parameters_present_flag)
112 {
113 num_bits_cpb = pInfo->active_SPS.sps_disp.vui_seq_parameters.nal_hrd_cpb_removal_delay_length_minus1 +1;
114 num_bits_dpb = pInfo->active_SPS.sps_disp.vui_seq_parameters.nal_hrd_dpb_output_delay_length_minus1 + 1;
115 time_offset_length = pInfo->active_SPS.sps_disp.vui_seq_parameters.nal_hrd_time_offset_length;
116 }
117 else if(pInfo->active_SPS.sps_disp.vui_seq_parameters.vcl_hrd_parameters_present_flag)
118 {
119 num_bits_cpb = pInfo->active_SPS.sps_disp.vui_seq_parameters.vcl_hrd_cpb_removal_delay_length_minus1 +1;
120 num_bits_dpb = pInfo->active_SPS.sps_disp.vui_seq_parameters.vcl_hrd_dpb_output_delay_length_minus1 + 1;
121 }
122
123
124 CpbDpbDelaysPresentFlag = 1; // as per amphion code
125 if(CpbDpbDelaysPresentFlag)
126 {
127 viddec_pm_get_bits(parent, (uint32_t *)&sei_msg_ptr->cpb_removal_delay, num_bits_cpb);
128 viddec_pm_get_bits(parent, (uint32_t *)&sei_msg_ptr->dpb_output_delay, num_bits_dpb);
129 }
130
131 if(pInfo->active_SPS.sps_disp.vui_seq_parameters.pic_struct_present_flag)
132 {
133 int32_t i = 0, NumClockTS = 0;
134
135 viddec_workload_item_t wi;
136
137 wi.vwi_payload[0] = wi.vwi_payload[1] = wi.vwi_payload[2] = 0;
138 viddec_pm_get_bits(parent, &code , 4);
139 sei_msg_ptr->pic_struct = (uint8_t)code;
140
141
142 if((sei_msg_ptr->pic_struct == 0) || (sei_msg_ptr->pic_struct == 7) || (sei_msg_ptr->pic_struct == 8)) {
143 pInfo->sei_information.scan_format = SEI_SCAN_FORMAT_PROGRESSIVE;
144 } else {
145 pInfo->sei_information.scan_format = SEI_SCAN_FORMAT_INTERLACED;
146 }
147
148 wi.vwi_type = VIDDEC_WORKLOAD_SEI_PIC_TIMING;
149 wi.h264_sei_pic_timing.pic_struct = sei_msg_ptr->pic_struct;
150
151 #ifndef VBP
152 //Push to current if we are in first frame, or we do not detect previous frame end
153 if( (pInfo->Is_first_frame_in_stream)||(!pInfo->is_current_workload_done) ) {
154 viddec_pm_append_workitem( parent, &wi );
155 } else {
156 viddec_pm_append_workitem_next( parent, &wi );
157 }
158 #endif
159
160 if(sei_msg_ptr->pic_struct < 3) {
161 NumClockTS = 1;
162 } else if((sei_msg_ptr->pic_struct < 5) || (sei_msg_ptr->pic_struct == 7)) {
163 NumClockTS = 2;
164 } else {
165 NumClockTS = 3;
166 }
167
168 for(i = 0; i < NumClockTS; i++)
169 {
170 viddec_pm_get_bits(parent, &code , 1);
171 clock_timestamp_flag = code;
172 //sei_msg_ptr->clock_timestamp_flag[i] = (uint8_t)code;
173
174 if(clock_timestamp_flag)
175 {
176 viddec_pm_get_bits(parent, &code , 2);
177 //sei_msg_ptr->ct_type[i] = (uint8_t)code;
178
179 viddec_pm_get_bits(parent, &code , 1);
180 //sei_msg_ptr->nuit_field_based_flag[i] = (uint8_t)code;
181
182 viddec_pm_get_bits(parent, &code , 5);
183 //sei_msg_ptr->counting_type[i] = (uint8_t)code;
184
185 viddec_pm_get_bits(parent, &code , 1);
186 //sei_msg_ptr->full_timestamp_flag[i] = (uint8_t)code;
187 full_timestamp_flag = code;
188
189 viddec_pm_get_bits(parent, &code , 1);
190 //sei_msg_ptr->discontinuity_flag[i] = (uint8_t)code;
191
192 viddec_pm_get_bits(parent, &code , 1);
193 //sei_msg_ptr->cnt_dropped_flag[i] = (uint8_t)code;
194
195 viddec_pm_get_bits(parent, &code , 8);
196 //sei_msg_ptr->n_frames[i] = (uint8_t)code;
197
198
199 if(full_timestamp_flag)
200 {
201 viddec_pm_get_bits(parent, &code , 6);
202 //sei_msg_ptr->seconds_value[i] = (uint8_t)code;
203
204 viddec_pm_get_bits(parent, &code , 6);
205 //sei_msg_ptr->minutes_value[i] = (uint8_t)code;
206
207 viddec_pm_get_bits(parent, &code , 5);
208 //sei_msg_ptr->hours_value[i] = (uint8_t)code;
209 }
210 else
211 {
212 viddec_pm_get_bits(parent, &code , 1);
213 //sei_msg_ptr->seconds_flag[i] = (uint8_t)code;
214 seconds_flag = code;
215
216 if(seconds_flag)
217 {
218 viddec_pm_get_bits(parent, &code , 6);
219 //sei_msg_ptr->seconds_value[i] = (uint8_t)code;
220
221 viddec_pm_get_bits(parent, &code , 1);
222 //sei_msg_ptr->minutes_flag[i] = (uint8_t)code;
223 minutes_flag = code;
224
225 if(minutes_flag)
226 {
227 viddec_pm_get_bits(parent, &code , 6);
228 //sei_msg_ptr->minutes_value[i] = (uint8_t)code;
229
230 viddec_pm_get_bits(parent, &code , 1);
231 //sei_msg_ptr->hours_flag[i] = (uint8_t)code;
232 hours_flag = code;
233
234 if(hours_flag){
235 viddec_pm_get_bits(parent, &code , 6);
236 //sei_msg_ptr->hours_value[i] = (uint8_t)code;
237 }
238 }
239 }
240 }
241
242 if(time_offset_length > 0)
243 {
244 viddec_pm_get_bits(parent, (uint32_t *)&time_offset, time_offset_length);
245 }
246 }
247 }
248 }
249
250
251 return H264_STATUS_OK;
252 }
253 /* ------------------------------------------------------------------------------------------ */
254 /* ------------------------------------------------------------------------------------------ */
255 /* ------------------------------------------------------------------------------------------ */
h264_sei_pan_scan(void * parent,h264_Info * pInfo)256 h264_Status h264_sei_pan_scan(void *parent,h264_Info* pInfo)
257 {
258 h264_SEI_pan_scan_rectangle_t* sei_msg_ptr;
259 h264_SEI_pan_scan_rectangle_t sei_pan_scan;
260 uint32_t code;
261
262 viddec_workload_item_t wi;
263
264 h264_memset( &(sei_pan_scan), 0x0, sizeof(h264_SEI_pan_scan_rectangle_t) );
265
266 viddec_fw_reset_workload_item(&wi);
267 wi.vwi_type = VIDDEC_WORKLOAD_H264_PAN_SCAN;
268
269 sei_msg_ptr = (h264_SEI_pan_scan_rectangle_t *)(&sei_pan_scan);
270
271 sei_msg_ptr->pan_scan_rect_id = h264_GetVLCElement(parent, pInfo, false);
272
273 wi.h264_sei_pan_scan.pan_scan_rect_id = sei_msg_ptr->pan_scan_rect_id;
274
275 viddec_pm_get_bits(parent, &code , 1);
276 sei_msg_ptr->pan_scan_rect_cancel_flag = (uint8_t)code;
277 viddec_fw_h264_sei_pan_scan_set_cancel_flag(&(wi.h264_sei_pan_scan), sei_msg_ptr->pan_scan_rect_cancel_flag);
278
279 if(!sei_msg_ptr->pan_scan_rect_cancel_flag)
280 {
281 int32_t i;
282 sei_msg_ptr->pan_scan_cnt_minus1 = h264_GetVLCElement(parent, pInfo, false);
283
284 viddec_fw_h264_sei_pan_scan_set_cnt_minus1(&(wi.h264_sei_pan_scan), sei_msg_ptr->pan_scan_cnt_minus1);
285 if(sei_msg_ptr->pan_scan_cnt_minus1 > MAX_PAN_SCAN_CNT -1)
286 {
287 return H264_STATUS_SEI_ERROR;
288 }
289 for(i=0; i<= sei_msg_ptr->pan_scan_cnt_minus1; i++)
290 {
291 sei_msg_ptr->pan_scan_rect_left_offset[i] = h264_GetVLCElement(parent, pInfo, true);
292 sei_msg_ptr->pan_scan_rect_right_offset[i] = h264_GetVLCElement(parent, pInfo, true);
293 sei_msg_ptr->pan_scan_rect_top_offset[i] = h264_GetVLCElement(parent, pInfo, true);
294 sei_msg_ptr->pan_scan_rect_bottom_offset[i] = h264_GetVLCElement(parent, pInfo, true);
295 }
296 sei_msg_ptr->pan_scan_rect_repetition_period = h264_GetVLCElement(parent, pInfo, false);
297 wi.h264_sei_pan_scan.pan_scan_rect_repetition_period = sei_msg_ptr->pan_scan_rect_repetition_period;
298 }
299
300 #ifndef VBP
301 if((pInfo->Is_first_frame_in_stream)||(!pInfo->is_current_workload_done)) //cur is first frame
302 {
303 viddec_pm_append_workitem( parent, &wi );
304 }
305 else
306 {
307 viddec_pm_append_workitem_next( parent, &wi );
308 }
309 #endif
310
311 if(!sei_msg_ptr->pan_scan_rect_cancel_flag)
312 {
313 int32_t i;
314
315 viddec_fw_reset_workload_item(&wi);
316 wi.vwi_type = VIDDEC_WORKLOAD_SEI_PAN_SCAN_RECT;
317
318 for(i=0; i<= sei_msg_ptr->pan_scan_cnt_minus1; i++)
319 {
320 viddec_fw_h264_pan_scan_set_left(&(wi.h264_pan_scan_rect), sei_msg_ptr->pan_scan_rect_left_offset[i]);
321 viddec_fw_h264_pan_scan_set_right(&(wi.h264_pan_scan_rect), sei_msg_ptr->pan_scan_rect_right_offset[i]);
322 viddec_fw_h264_pan_scan_set_top(&(wi.h264_pan_scan_rect), sei_msg_ptr->pan_scan_rect_top_offset[i]);
323 viddec_fw_h264_pan_scan_set_bottom(&(wi.h264_pan_scan_rect), sei_msg_ptr->pan_scan_rect_bottom_offset[i]);
324
325 #ifndef VBP
326 if(pInfo->Is_first_frame_in_stream) { //cur is first frame
327 viddec_pm_append_workitem( parent, &wi );
328 } else {
329 viddec_pm_append_workitem_next( parent, &wi );
330 }
331 #endif
332 }
333 }
334
335 return H264_STATUS_OK;
336 }
337 /* ------------------------------------------------------------------------------------------ */
338 /* ------------------------------------------------------------------------------------------ */
339 /* ------------------------------------------------------------------------------------------ */
h264_sei_filler_payload(void * parent,h264_Info * pInfo,uint32_t payload_size)340 h264_Status h264_sei_filler_payload(void *parent,h264_Info* pInfo, uint32_t payload_size)
341 {
342
343 h264_SEI_filler_payload_t* sei_msg_ptr;
344 h264_SEI_filler_payload_t sei_filler_payload;
345 uint32_t k;
346 uint32_t code;
347
348 //remove warning
349 pInfo = pInfo;
350
351 sei_msg_ptr = (h264_SEI_filler_payload_t *)(&sei_filler_payload);
352 for(k=0; k < payload_size; k++)
353 {
354 viddec_pm_get_bits(parent, &code , 8);
355 sei_msg_ptr->ff_byte = (uint8_t)code;
356 }
357
358 return H264_STATUS_OK;
359 }
360 /* ------------------------------------------------------------------------------------------ */
361 /* ------------------------------------------------------------------------------------------ */
362 /* ------------------------------------------------------------------------------------------ */
h264_sei_userdata_reg(void * parent,h264_Info * pInfo,uint32_t payload_size)363 h264_Status h264_sei_userdata_reg(void *parent,h264_Info* pInfo, uint32_t payload_size)
364 {
365
366 h264_SEI_userdata_registered_t* sei_msg_ptr;
367 h264_SEI_userdata_registered_t sei_userdata_registered;
368 uint32_t i;
369 int32_t byte = 0;
370 uint32_t code = 0;
371 viddec_workload_item_t wi;
372
373 wi.vwi_type = VIDDEC_WORKLOAD_SEI_USER_DATA_REGISTERED;
374 wi.vwi_payload[0] = wi.vwi_payload[1] = wi.vwi_payload[2] = 0;
375 //remove warning
376 pInfo = pInfo;
377
378 sei_msg_ptr = (h264_SEI_userdata_registered_t *)(&sei_userdata_registered);
379
380 viddec_pm_get_bits(parent, &code , 8);
381 sei_msg_ptr->itu_t_t35_country_code = (uint8_t)code;
382
383 if(sei_msg_ptr->itu_t_t35_country_code != 0xff) {
384 i = 1;
385 } else {
386 viddec_pm_get_bits(parent, &code , 8);
387 sei_msg_ptr->itu_t_t35_country_code_extension_byte = (uint8_t)code;
388 i = 2;
389 }
390
391
392 wi.user_data.size =0;
393 do
394 {
395
396 viddec_pm_get_bits(parent, (uint32_t *)&byte, 8);
397
398 wi.user_data.data_payload[wi.user_data.size]=(uint8_t)byte;
399 wi.user_data.size++;
400
401 if(11 == wi.user_data.size)
402 {
403 viddec_pm_setup_userdata(&wi);
404 #ifndef VBP
405 if((pInfo->Is_first_frame_in_stream)||(!pInfo->is_current_workload_done)) //cur is first frame
406 {
407 viddec_pm_append_workitem( parent, &wi );
408 }
409 else
410 {
411 viddec_pm_append_workitem_next( parent, &wi );
412 }
413 #endif
414 wi.user_data.size =0;
415 }
416
417 i++;
418 }while(i < payload_size);
419
420 if(0!=wi.user_data.size)
421 {
422 viddec_pm_setup_userdata(&wi);
423
424 #ifndef VBP
425 if(pInfo->Is_first_frame_in_stream) //cur is first frame
426 {
427 viddec_pm_append_workitem( parent, &wi );
428 }
429 else
430 {
431 viddec_pm_append_workitem_next( parent, &wi );
432 }
433 #endif
434 }
435
436 return H264_STATUS_OK;
437 }
438 /* ------------------------------------------------------------------------------------------ */
439 /* ------------------------------------------------------------------------------------------ */
440 /* ------------------------------------------------------------------------------------------ */
h264_sei_userdata_unreg(void * parent,h264_Info * pInfo,uint32_t payload_size)441 h264_Status h264_sei_userdata_unreg(void *parent, h264_Info* pInfo, uint32_t payload_size)
442 {
443
444 h264_SEI_userdata_unregistered_t* sei_msg_ptr;
445 h264_SEI_userdata_unregistered_t sei_userdata_unregistered;
446 uint32_t i;
447 int32_t byte = 0;
448 uint32_t code;
449
450 viddec_workload_item_t wi;
451
452 wi.vwi_type = VIDDEC_WORKLOAD_SEI_USER_DATA_UNREGISTERED;
453
454 //remove warning
455 pInfo = pInfo;
456
457 sei_msg_ptr = (h264_SEI_userdata_unregistered_t *)(&sei_userdata_unregistered);
458
459 for (i = 0; i < 4; i++)
460 {
461 viddec_pm_get_bits(parent, &code , 32);
462 sei_msg_ptr->uuid_iso_iec_11578[i] = (uint8_t)code;
463 }
464
465 wi.user_data.size =0;
466 for(i = 16; i < payload_size; i++)
467 {
468
469 viddec_pm_get_bits(parent, (uint32_t *)&byte, 8);
470
471 wi.user_data.data_payload[wi.user_data.size]=(uint8_t)byte;
472 wi.user_data.size++;
473
474 if(11 == wi.user_data.size)
475 {
476 viddec_pm_setup_userdata(&wi);
477 if((pInfo->Is_first_frame_in_stream)||(!pInfo->is_current_workload_done)) //cur is first frame
478 {
479 viddec_pm_append_workitem( parent, &wi );
480 }
481 else
482 {
483 viddec_pm_append_workitem_next( parent, &wi );
484 }
485
486 wi.user_data.size =0;
487 }
488 }
489
490 if(0!=wi.user_data.size)
491 {
492 viddec_pm_setup_userdata(&wi);
493 if(pInfo->Is_first_frame_in_stream) //cur is first frame
494 {
495 viddec_pm_append_workitem( parent, &wi );
496 }
497 else
498 {
499 viddec_pm_append_workitem_next( parent, &wi );
500 }
501 }
502
503 return H264_STATUS_OK;
504 }
505 /* ------------------------------------------------------------------------------------------ */
506 /* ------------------------------------------------------------------------------------------ */
507 /* ------------------------------------------------------------------------------------------ */
h264_sei_recovery_point(void * parent,h264_Info * pInfo)508 h264_Status h264_sei_recovery_point(void *parent, h264_Info* pInfo)
509 {
510
511 h264_SEI_recovery_point_t* sei_msg_ptr;
512 h264_SEI_recovery_point_t sei_recovery_point;
513 uint32_t code;
514 viddec_workload_item_t wi;
515
516
517 sei_msg_ptr = (h264_SEI_recovery_point_t *)(&sei_recovery_point);
518
519 sei_msg_ptr->recovery_frame_cnt = h264_GetVLCElement(parent, pInfo, false);
520
521 viddec_pm_get_bits(parent, &code , 1);
522 sei_msg_ptr->exact_match_flag = (uint8_t)code;
523
524 viddec_pm_get_bits(parent, &code , 1);
525 sei_msg_ptr->broken_link_flag = (uint8_t)code;
526
527 viddec_pm_get_bits(parent, &code , 2);
528 sei_msg_ptr->changing_slice_group_idc = (uint8_t)code;
529
530 pInfo->sei_information.recovery_point = 1;
531 pInfo->sei_information.recovery_frame_cnt = (int32_t) sei_msg_ptr->recovery_frame_cnt;
532 pInfo->sei_information.capture_fn = 1;
533 pInfo->sei_information.broken_link_pic = sei_msg_ptr->broken_link_flag;
534
535 if(pInfo->got_start) {
536 pInfo->img.recovery_point_found |= 2;
537
538 //// Enable the RP recovery if no IDR ---Cisco
539 if((pInfo->img.recovery_point_found & 1)==0)
540 pInfo->sei_rp_received = 1;
541 }
542
543 //
544 /// Append workload for SEI
545 //
546 viddec_fw_reset_workload_item(&wi);
547 wi.vwi_type = VIDDEC_WORKLOAD_SEI_RECOVERY_POINT;
548 wi.h264_sei_recovery_point.recovery_frame_cnt = sei_msg_ptr->recovery_frame_cnt;
549 viddec_fw_h264_h264_sei_recovery_set_exact_match_flag(&(wi.h264_sei_recovery_point), sei_msg_ptr->exact_match_flag);
550 viddec_fw_h264_h264_sei_recovery_set_broken_link_flag(&(wi.h264_sei_recovery_point), sei_msg_ptr->broken_link_flag);
551 wi.h264_sei_recovery_point.changing_slice_group_idc = sei_msg_ptr->changing_slice_group_idc;
552
553 if((pInfo->Is_first_frame_in_stream)||(!pInfo->is_current_workload_done)) //cur is first frame
554 {
555 viddec_pm_append_workitem( parent, &wi );
556 }
557 else
558 {
559 viddec_pm_append_workitem_next( parent, &wi );
560 }
561
562 return H264_STATUS_OK;
563 }
564 /* ------------------------------------------------------------------------------------------ */
565 /* ------------------------------------------------------------------------------------------ */
566 /* ------------------------------------------------------------------------------------------ */
h264_sei_dec_ref_pic_marking_rep(void * parent,h264_Info * pInfo)567 h264_Status h264_sei_dec_ref_pic_marking_rep(void *parent,h264_Info* pInfo)
568 {
569
570 h264_SEI_decoded_ref_pic_marking_repetition_t* sei_msg_ptr;
571 h264_SEI_decoded_ref_pic_marking_repetition_t sei_ref_pic;
572 uint32_t code;
573
574 sei_msg_ptr = (h264_SEI_decoded_ref_pic_marking_repetition_t *)(&sei_ref_pic);
575
576 viddec_pm_get_bits(parent, &code , 1);
577 sei_msg_ptr->original_idr_flag = (uint8_t)code;
578
579 sei_msg_ptr->original_frame_num = h264_GetVLCElement(parent, pInfo, false);
580
581 if(!(pInfo->active_SPS.sps_disp.frame_mbs_only_flag))
582 {
583 viddec_pm_get_bits(parent, &code , 1);
584 sei_msg_ptr->orignal_field_pic_flag = (uint8_t)code;
585
586 if(sei_msg_ptr->orignal_field_pic_flag)
587 {
588 viddec_pm_get_bits(parent, &code , 1);
589 sei_msg_ptr->original_bottom_field_pic_flag = (uint8_t)code;
590 }
591 }
592 h264_Parse_Dec_Ref_Pic_Marking(parent, pInfo, &pInfo->SliceHeader);
593 return H264_STATUS_OK;
594 }
595 /* ------------------------------------------------------------------------------------------ */
596 /* ------------------------------------------------------------------------------------------ */
597 /* ------------------------------------------------------------------------------------------ */
h264_sei_spare_pic(void * parent,h264_Info * pInfo)598 h264_Status h264_sei_spare_pic(void *parent,h264_Info* pInfo)
599 {
600
601 //h264_SEI_spare_picture_t* sei_msg_ptr;
602
603 //remove warning
604 pInfo = pInfo;
605 parent = parent;
606
607 //sei_msg_ptr = (h264_SEI_spare_picture_t *)(&user_data->user_data[0]);
608
609 //OS_INFO("Not supported SEI\n");
610 return H264_STATUS_OK;
611 }
612 /* ------------------------------------------------------------------------------------------ */
613 /* ------------------------------------------------------------------------------------------ */
614 /* ------------------------------------------------------------------------------------------ */
h264_sei_scene_info(void * parent,h264_Info * pInfo)615 h264_Status h264_sei_scene_info(void *parent,h264_Info* pInfo)
616 {
617
618 h264_SEI_scene_info_t* sei_msg_ptr;
619 h264_SEI_scene_info_t sei_scene_info;
620 uint32_t code;
621
622 sei_msg_ptr = (h264_SEI_scene_info_t*)(&sei_scene_info);
623
624 viddec_pm_get_bits(parent, &code , 1);
625 sei_msg_ptr->scene_info_present_flag = (uint8_t)code;
626
627 if(sei_msg_ptr->scene_info_present_flag)
628 {
629 sei_msg_ptr->scene_id = h264_GetVLCElement(parent, pInfo, false);
630 sei_msg_ptr->scene_transitioning_type= h264_GetVLCElement(parent, pInfo, false);
631 if(sei_msg_ptr->scene_transitioning_type > 3)
632 {
633 sei_msg_ptr->second_scene_id = h264_GetVLCElement(parent, pInfo, false);
634 }
635 }
636
637 return H264_STATUS_OK;
638 }
639 /* ------------------------------------------------------------------------------------------ */
640 /* ------------------------------------------------------------------------------------------ */
641 /* ------------------------------------------------------------------------------------------ */
h264_sei_sub_seq_info(void * parent,h264_Info * pInfo)642 h264_Status h264_sei_sub_seq_info(void *parent,h264_Info* pInfo)
643 {
644
645 h264_SEI_sub_sequence_info_t* sei_msg_ptr;
646 h264_SEI_sub_sequence_info_t sei_sub_sequence_info;
647 uint32_t code;
648
649 sei_msg_ptr = (h264_SEI_sub_sequence_info_t *)(&sei_sub_sequence_info);
650
651 sei_msg_ptr->sub_seq_layer_num = h264_GetVLCElement(parent, pInfo,false);
652 sei_msg_ptr->sub_seq_id= h264_GetVLCElement(parent, pInfo,false);
653
654 viddec_pm_get_bits(parent, &code , 1);
655 sei_msg_ptr->first_ref_pic_flag = (uint8_t)code;
656
657 viddec_pm_get_bits(parent, &code , 1);
658 sei_msg_ptr->leading_non_ref_pic_flag = (uint8_t)code;
659
660 viddec_pm_get_bits(parent, &code , 1);
661 sei_msg_ptr->last_pic_flag = (uint8_t)code;
662
663 viddec_pm_get_bits(parent, &code , 1);
664 sei_msg_ptr->sub_seq_frame_num_flag = (uint8_t)code;
665
666
667 if(sei_msg_ptr->sub_seq_frame_num_flag)
668 {
669 sei_msg_ptr->sub_seq_frame_num = h264_GetVLCElement(parent, pInfo,false);
670 }
671 return H264_STATUS_OK;
672 }
673 /* ------------------------------------------------------------------------------------------ */
674 /* ------------------------------------------------------------------------------------------ */
675 /* ------------------------------------------------------------------------------------------ */
h264_sei_sub_seq_layer(void * parent,h264_Info * pInfo)676 h264_Status h264_sei_sub_seq_layer(void *parent,h264_Info* pInfo)
677 {
678
679 h264_SEI_sub_sequence_layer_t* sei_msg_ptr;
680 h264_SEI_sub_sequence_layer_t sei_sub_sequence_layer;
681 int32_t layer;
682 uint32_t code;
683
684 sei_msg_ptr = (h264_SEI_sub_sequence_layer_t *)(&sei_sub_sequence_layer);
685 sei_msg_ptr->num_sub_seq_layers_minus1 = h264_GetVLCElement(parent, pInfo,false);
686
687 if(sei_msg_ptr->num_sub_seq_layers_minus1 >= MAX_SUB_SEQ_LAYERS)
688 {
689 return H264_STATUS_SEI_ERROR;
690 }
691
692 for(layer = 0;layer <= sei_msg_ptr->num_sub_seq_layers_minus1; layer++)
693 {
694 viddec_pm_get_bits(parent, &code , 1);
695 sei_msg_ptr->accurate_statistics_flag[layer] = (uint8_t)code;
696
697 viddec_pm_get_bits(parent, &code , 16);
698 sei_msg_ptr->average_bit_rate[layer] = (uint16_t)code;
699
700 viddec_pm_get_bits(parent, &code , 16);
701 sei_msg_ptr->average_frame_rate[layer] = (uint16_t)code;
702
703 }
704
705 return H264_STATUS_OK;
706 }
707 /* ------------------------------------------------------------------------------------------ */
708 /* ------------------------------------------------------------------------------------------ */
709 /* ------------------------------------------------------------------------------------------ */
h264_sei_sub_seq(void * parent,h264_Info * pInfo)710 h264_Status h264_sei_sub_seq(void *parent,h264_Info* pInfo)
711 {
712 int32_t n;
713 uint32_t code;
714
715 h264_SEI_sub_sequence_t* sei_msg_ptr;
716 h264_SEI_sub_sequence_t sei_sub_sequence;
717
718 sei_msg_ptr = (h264_SEI_sub_sequence_t *)(&sei_sub_sequence);
719
720 sei_msg_ptr->sub_seq_layer_num = h264_GetVLCElement(parent, pInfo, false);
721 sei_msg_ptr->sub_seq_id= h264_GetVLCElement(parent, pInfo, false);
722
723 viddec_pm_get_bits(parent, &code , 1);
724 sei_msg_ptr->duration_flag = (uint8_t)code;
725
726 if(sei_msg_ptr->duration_flag)
727 {
728 viddec_pm_get_bits(parent, (uint32_t *)&sei_msg_ptr->sub_seq_duration, 32);
729 }
730
731 viddec_pm_get_bits(parent, &code , 1);
732 sei_msg_ptr->average_rate_flag = (uint8_t)code;
733
734 if(sei_msg_ptr->average_rate_flag)
735 {
736 viddec_pm_get_bits(parent, &code , 1);
737 sei_msg_ptr->average_statistics_flag = (uint8_t)code;
738
739 viddec_pm_get_bits(parent, &code , 16);
740 sei_msg_ptr->average_bit_rate = (uint8_t)code;
741
742 viddec_pm_get_bits(parent, &code , 16);
743 sei_msg_ptr->average_frame_rate = (uint8_t)code;
744
745 }
746 sei_msg_ptr->num_referenced_subseqs = h264_GetVLCElement(parent, pInfo, false);
747 if(sei_msg_ptr->num_referenced_subseqs >= MAX_NUM_REF_SUBSEQS)
748 {
749 return H264_STATUS_SEI_ERROR;
750 }
751
752 for(n = 0; n < sei_msg_ptr->num_referenced_subseqs; n++)
753 {
754 sei_msg_ptr->ref_sub_seq_layer_num= h264_GetVLCElement(parent, pInfo, false);
755 sei_msg_ptr->ref_sub_seq_id= h264_GetVLCElement(parent, pInfo, false);
756
757 viddec_pm_get_bits(parent, &code , 1);
758 sei_msg_ptr->ref_sub_seq_direction = (uint8_t)code;
759 }
760 return H264_STATUS_OK;
761 }
762 /* ------------------------------------------------------------------------------------------ */
763 /* ------------------------------------------------------------------------------------------ */
764 /* ------------------------------------------------------------------------------------------ */
h264_sei_full_frame_freeze(void * parent,h264_Info * pInfo)765 h264_Status h264_sei_full_frame_freeze(void *parent,h264_Info* pInfo)
766 {
767
768 h264_SEI_full_frame_freeze_t* sei_msg_ptr;
769 h264_SEI_full_frame_freeze_t sei_full_frame_freeze;
770
771 sei_msg_ptr = (h264_SEI_full_frame_freeze_t *)(&sei_full_frame_freeze);
772
773 sei_msg_ptr->full_frame_freeze_repetition_period= h264_GetVLCElement(parent, pInfo, false);
774
775 pInfo->sei_information.capture_POC = 1;
776 pInfo->sei_information.freeze_rep_period = sei_msg_ptr->full_frame_freeze_repetition_period;
777 //pInfo->img.sei_freeze_this_image = 1;
778
779 return H264_STATUS_OK;
780 }
781 /* ------------------------------------------------------------------------------------------ */
782 /* ------------------------------------------------------------------------------------------ */
783 /* ------------------------------------------------------------------------------------------ */
h264_sei_full_frame_freeze_release(void * parent,h264_Info * pInfo)784 h264_Status h264_sei_full_frame_freeze_release(void *parent,h264_Info* pInfo)
785 {
786 //remove warning
787 parent = parent;
788 pInfo = pInfo;
789
790
791 return H264_STATUS_OK;
792 }
793 /* ------------------------------------------------------------------------------------------ */
794 /* ------------------------------------------------------------------------------------------ */
795 /* ------------------------------------------------------------------------------------------ */
h264_sei_full_frame_snapshot(void * parent,h264_Info * pInfo)796 h264_Status h264_sei_full_frame_snapshot(void *parent,h264_Info* pInfo)
797 {
798
799 h264_SEI_full_frame_snapshot_t* sei_msg_ptr;
800 h264_SEI_full_frame_snapshot_t sei_full_frame_snapshot;
801
802 sei_msg_ptr = (h264_SEI_full_frame_snapshot_t *)(&sei_full_frame_snapshot);
803
804 sei_msg_ptr->snapshot_id = h264_GetVLCElement(parent, pInfo, false);
805 return H264_STATUS_OK;
806 }
807 /* ------------------------------------------------------------------------------------------ */
808 /* ------------------------------------------------------------------------------------------ */
809 /* ------------------------------------------------------------------------------------------ */
h264_sei_progressive_segement_start(void * parent,h264_Info * pInfo)810 h264_Status h264_sei_progressive_segement_start(void *parent,h264_Info* pInfo)
811 {
812
813 h264_SEI_progressive_segment_start_t* sei_msg_ptr;
814 h264_SEI_progressive_segment_start_t sei_progressive_segment_start;
815
816 sei_msg_ptr = (h264_SEI_progressive_segment_start_t *)(&sei_progressive_segment_start);
817
818 sei_msg_ptr->progressive_refinement_id= h264_GetVLCElement(parent, pInfo, false);
819 sei_msg_ptr->num_refinement_steps_minus1= h264_GetVLCElement(parent, pInfo, false);
820 return H264_STATUS_OK;
821 }
822 /* ------------------------------------------------------------------------------------------ */
823 /* ------------------------------------------------------------------------------------------ */
824 /* ------------------------------------------------------------------------------------------ */
h264_sei_progressive_segment_end(void * parent,h264_Info * pInfo)825 h264_Status h264_sei_progressive_segment_end(void *parent,h264_Info* pInfo)
826 {
827
828 h264_SEI_progressive_segment_end_t* sei_msg_ptr;
829 h264_SEI_progressive_segment_end_t sei_progressive_segment_end;
830
831 sei_msg_ptr = (h264_SEI_progressive_segment_end_t *)(&sei_progressive_segment_end);
832
833 sei_msg_ptr->progressive_refinement_id = h264_GetVLCElement(parent, pInfo, false);
834 return H264_STATUS_OK;
835 }
836 /* ------------------------------------------------------------------------------------------ */
837 /* ------------------------------------------------------------------------------------------ */
838 /* ------------------------------------------------------------------------------------------ */
h264_sei_motion_constrained_slice_grp_set(void * parent,h264_Info * pInfo)839 h264_Status h264_sei_motion_constrained_slice_grp_set(void *parent, h264_Info* pInfo)
840 {
841 int32_t i;
842 uint32_t code;
843 h264_SEI_motion_constrained_slice_group_t* sei_msg_ptr;
844 h264_SEI_motion_constrained_slice_group_t sei_motion_constrained_slice_group;
845
846 sei_msg_ptr = (h264_SEI_motion_constrained_slice_group_t *)(&sei_motion_constrained_slice_group);
847
848 sei_msg_ptr->num_slice_groups_in_set_minus1= h264_GetVLCElement(parent, pInfo, false);
849 if(sei_msg_ptr->num_slice_groups_in_set_minus1 >= MAX_NUM_SLICE_GRPS)
850 {
851 return H264_STATUS_SEI_ERROR;
852 }
853
854 for(i=0; i<= sei_msg_ptr->num_slice_groups_in_set_minus1; i++)
855 {
856 viddec_pm_get_bits(parent, &code , 1);
857 sei_msg_ptr->slice_group_id[i] = (uint8_t)code;
858 }
859 viddec_pm_get_bits(parent, &code , 1);
860 sei_msg_ptr->exact_sample_value_match_flag = (uint8_t)code;
861
862 viddec_pm_get_bits(parent, &code , 1);
863 sei_msg_ptr->pan_scan_rect_flag = (uint8_t)code;
864
865
866 if(sei_msg_ptr->pan_scan_rect_flag)
867 {
868 sei_msg_ptr->pan_scan_rect_id= h264_GetVLCElement(parent, pInfo, false);
869 }
870 return H264_STATUS_OK;
871 }
872 /* ------------------------------------------------------------------------------------------ */
873 /* ------------------------------------------------------------------------------------------ */
874 /* ------------------------------------------------------------------------------------------ */
h264_sei_film_grain_characteristics(void * parent,h264_Info * pInfo)875 h264_Status h264_sei_film_grain_characteristics(void *parent,h264_Info* pInfo)
876 {
877 //OS_INFO("Not supported SEI\n");
878
879 //remove warning
880 parent = parent;
881 pInfo = pInfo;
882
883
884
885
886 return H264_STATUS_OK;
887 }
888 /* ------------------------------------------------------------------------------------------ */
889 /* ------------------------------------------------------------------------------------------ */
890 /* ------------------------------------------------------------------------------------------ */
h264_sei_deblocking_filter_display_preferences(void * parent,h264_Info * pInfo)891 h264_Status h264_sei_deblocking_filter_display_preferences(void *parent,h264_Info* pInfo)
892 {
893
894 //h264_SEI_deblocking_filter_display_pref_t* sei_msg_ptr;
895
896 //remove warning
897 parent = parent;
898 pInfo = pInfo;
899
900 //sei_msg_ptr = (h264_SEI_deblocking_filter_display_pref_t *)(&user_data->user_data[0]);
901
902 //OS_INFO("Not supported SEI\n");
903 return H264_STATUS_OK;
904 }
905 /* ------------------------------------------------------------------------------------------ */
906 /* ------------------------------------------------------------------------------------------ */
907 /* ------------------------------------------------------------------------------------------ */
h264_sei_stereo_video_info(void * parent,h264_Info * pInfo)908 h264_Status h264_sei_stereo_video_info(void *parent,h264_Info* pInfo)
909 {
910
911 //h264_SEI_stereo_video_info_t* sei_msg_ptr;
912
913 //remove warning
914 parent = parent;
915 pInfo = pInfo;
916
917
918 //sei_msg_ptr = (h264_SEI_stereo_video_info_t *)(&user_data->user_data[0]);
919
920 //OS_INFO("Not supported SEI\n");
921 return H264_STATUS_OK;
922 }
923 /* ------------------------------------------------------------------------------------------ */
924 /* ------------------------------------------------------------------------------------------ */
925 /* ------------------------------------------------------------------------------------------ */
h264_sei_reserved_sei_message(void * parent,h264_Info * pInfo,uint32_t payload_size)926 h264_Status h264_sei_reserved_sei_message(void *parent, h264_Info* pInfo, uint32_t payload_size)
927 {
928 int32_t k, byte_index, user_data_byte_index;
929 uint32_t i;
930 int32_t word, bits;
931 uint32_t user_data;
932 //h264_SEI_reserved_t* sei_msg_ptr;
933 //h264_SEI_reserved_t sei_reserved;
934
935 //remove warning
936 pInfo = pInfo;
937
938 //sei_msg_ptr = (h264_SEI_reserved_t *)(&sei_reserved);
939
940 byte_index = 0;
941 word = 0;
942 user_data_byte_index = 0x0;
943
944 for(i = 0, k = 0; i < payload_size; i++)
945 {
946 if(byte_index == 0) word = 0;
947 viddec_pm_get_bits(parent, (uint32_t *)&bits, 8);
948
949 switch (byte_index)
950 {
951 case 1:
952 word = (bits << 8) | word;
953 break;
954 case 2:
955 word = (bits << 16) | word;
956 break;
957 case 3:
958 word = (bits << 24) | word;
959 break;
960 default :
961 word = bits;
962 break;
963 }
964
965 if(byte_index == 3)
966 {
967 byte_index = 0;
968 user_data = word;
969 k++;
970 }
971 else
972 {
973 byte_index++;
974 }
975
976 user_data_byte_index++;
977 if ( user_data_byte_index == MAX_USER_DATA_SIZE)
978 {
979 //user_data->user_data_size = user_data_byte_index;
980 //sei_msg_ptr = (h264_SEI_reserved_t *)(&user_data->user_data[0]);
981 byte_index = 0;
982 word = 0;
983 user_data_byte_index = 0x0;
984 }
985 }
986
987 if(byte_index)
988 user_data = word;
989
990 //user_data->user_data_size = user_data_byte_index;
991
992 return user_data_byte_index;
993
994 return H264_STATUS_OK;
995 }
996
997 ////// TODO
998 /* ------------------------------------------------------------------------------------------ */
999 /* ------------------------------------------------------------------------------------------ */
1000 /* ------------------------------------------------------------------------------------------ */
h264_SEI_payload(void * parent,h264_Info * pInfo,h264_sei_payloadtype payloadType,int32_t payloadSize)1001 h264_Status h264_SEI_payload(void *parent, h264_Info* pInfo, h264_sei_payloadtype payloadType, int32_t payloadSize)
1002 {
1003 //int32_t bit_equal_to_zero;
1004 h264_Status status = H264_STATUS_OK;
1005
1006 //removing warning
1007 payloadSize = payloadSize;
1008
1009 switch(payloadType)
1010 {
1011 case SEI_BUF_PERIOD:
1012 status = h264_sei_buffering_period(parent, pInfo);
1013 break;
1014 case SEI_PIC_TIMING:
1015 status = h264_sei_pic_timing(parent, pInfo);
1016 break;
1017 case SEI_PAN_SCAN:
1018 status = h264_sei_pan_scan(parent, pInfo);
1019 break;
1020 case SEI_FILLER_PAYLOAD:
1021 status = h264_sei_filler_payload(parent, pInfo, payloadSize);
1022 break;
1023 case SEI_REG_USERDATA:
1024 status = h264_sei_userdata_reg(parent, pInfo, payloadSize);
1025 break;
1026 case SEI_UNREG_USERDATA:
1027 status = h264_sei_userdata_unreg(parent, pInfo, payloadSize);
1028 break;
1029 case SEI_RECOVERY_POINT:
1030 h264_sei_recovery_point(parent, pInfo);
1031 break;
1032 case SEI_DEC_REF_PIC_MARKING_REP:
1033 status = h264_sei_dec_ref_pic_marking_rep(parent, pInfo);
1034 break;
1035 case SEI_SPARE_PIC:
1036 status = h264_sei_spare_pic(parent, pInfo);
1037 break;
1038 case SEI_SCENE_INFO:
1039 status = h264_sei_scene_info(parent, pInfo);
1040 break;
1041 case SEI_SUB_SEQ_INFO:
1042 status = h264_sei_sub_seq_info(parent, pInfo);
1043 break;
1044 case SEI_SUB_SEQ_LAYER:
1045 status = h264_sei_sub_seq_layer(parent, pInfo);
1046 break;
1047 case SEI_SUB_SEQ:
1048 status = h264_sei_sub_seq(parent, pInfo);
1049 break;
1050 case SEI_FULL_FRAME_FREEZE:
1051 status = h264_sei_full_frame_freeze(parent, pInfo);
1052 break;
1053 case SEI_FULL_FRAME_FREEZE_RELEASE:
1054 h264_sei_full_frame_freeze_release(parent, pInfo);
1055 break;
1056 case SEI_FULL_FRAME_SNAPSHOT:
1057 status = h264_sei_full_frame_snapshot(parent, pInfo);
1058 break;
1059 case SEI_PROGRESSIVE_SEGMENT_START:
1060 status = h264_sei_progressive_segement_start(parent, pInfo);
1061 break;
1062 case SEI_PROGRESSIVE_SEGMENT_END:
1063 status = h264_sei_progressive_segment_end(parent, pInfo);
1064 break;
1065 case SEI_MOTION_CONSTRAINED_SLICE_GRP_SET:
1066 status = h264_sei_motion_constrained_slice_grp_set(parent, pInfo);
1067 break;
1068 case SEI_FILM_GRAIN_CHARACTERISTICS:
1069 status = h264_sei_film_grain_characteristics(parent, pInfo);
1070 break;
1071 case SEI_DEBLK_FILTER_DISPLAY_PREFERENCE:
1072 status = h264_sei_deblocking_filter_display_preferences(parent, pInfo);
1073 break;
1074 case SEI_STEREO_VIDEO_INFO:
1075 status = h264_sei_stereo_video_info(parent, pInfo);
1076 break;
1077 default:
1078 status = h264_sei_reserved_sei_message(parent, pInfo, payloadSize);
1079 break;
1080 }
1081
1082 /*
1083 viddec_pm_get_bits(parent, (uint32_t *)&tmp, 1);
1084
1085 if(tmp == 0x1) // if byte is not aligned
1086 {
1087 while(pInfo->bitoff != 0)
1088 {
1089 viddec_pm_get_bits(parent, (uint32_t *)&bit_equal_to_zero, 1);
1090 }
1091 }
1092 */
1093 return status;
1094 }
1095
1096 /* ------------------------------------------------------------------------------------------ */
1097 /* ------------------------------------------------------------------------------------------ */
1098 /* ------------------------------------------------------------------------------------------ */
h264_Parse_Supplemental_Enhancement_Information_Message(void * parent,h264_Info * pInfo)1099 h264_Status h264_Parse_Supplemental_Enhancement_Information_Message(void *parent, h264_Info* pInfo)
1100 {
1101 h264_Status status = H264_STATUS_OK;
1102 int32_t payload_type, payload_size;
1103 uint32_t next_8_bits = 0,bits_offset=0,byte_offset = 0;
1104 uint8_t is_emul = 0;
1105 int32_t bits_operation_result = 0;
1106
1107 do {
1108 //// payload_type
1109 payload_type = 0;
1110 viddec_pm_get_bits(parent, (uint32_t *)&next_8_bits, 8);
1111 while (next_8_bits == 0xFF)
1112 {
1113 bits_operation_result = viddec_pm_get_bits(parent, (uint32_t *)&next_8_bits, 8);
1114 if(-1 == bits_operation_result)
1115 {
1116 status = H264_STATUS_SEI_ERROR;
1117 return status;
1118 }
1119 payload_type += 255;
1120
1121 }
1122 //viddec_pm_get_bits(parent, (uint32_t *)&next_8_bits, 8);
1123 payload_type += next_8_bits;
1124
1125 //// payload_size
1126 payload_size = 0;
1127 viddec_pm_get_bits(parent, (uint32_t *)&next_8_bits, 8);
1128 while (next_8_bits == 0xFF)
1129 {
1130 payload_size += 255;
1131 bits_operation_result = viddec_pm_get_bits(parent, (uint32_t *)&next_8_bits, 8);
1132 if(-1 == bits_operation_result)
1133 {
1134 status = H264_STATUS_SEI_ERROR;
1135 return status;
1136 }
1137 }
1138 //viddec_pm_get_bits(parent, (uint32_t *)&next_8_bits, 8);
1139 payload_size += next_8_bits;
1140
1141 //PRINTF(MFD_NONE, " SEI: payload type = %d, payload size = %d \n", payload_type, payload_size);
1142
1143
1144 /////////////////////////////////
1145 // Parse SEI payloads
1146 /////////////////////////////////
1147 status = h264_SEI_payload(parent, pInfo, payload_type, payload_size);
1148 if(status != H264_STATUS_OK)
1149 break;
1150
1151 viddec_pm_get_au_pos(parent, &bits_offset, &byte_offset, &is_emul);
1152 // OS_INFO("SEI byte_offset 3= %d, bits_offset=%d\n", byte_offset, bits_offset);
1153
1154 if(bits_offset!=0)
1155 {
1156 viddec_pm_get_bits(parent, (uint32_t *)&next_8_bits, 8-bits_offset);
1157 }
1158
1159 bits_operation_result = viddec_pm_peek_bits(parent, (uint32_t *)&next_8_bits, 8);
1160 if(-1 == bits_operation_result)
1161 {
1162 status = H264_STATUS_SEI_ERROR;
1163 return status;
1164 }
1165
1166 // OS_INFO("next_8_bits = %08x\n", next_8_bits);
1167
1168 }while(next_8_bits != 0x80);
1169
1170 //} while (h264_More_RBSP_Data(parent, pInfo) && status == H264_STATUS_OK);
1171
1172 return status;
1173 }
1174
1175 #endif
1176
1177