📄 sei.c
字号:
/*!
************************************************************************
* \brief
* Interpret the Progressive refinement segment end SEI message
* \param payload
* a pointer that point to the sei payload
* \param size
* the size of the sei message
* \param img
* the image pointer
*
************************************************************************
*/
void interpret_progressive_refinement_end_info( byte* payload, int size, ImageParameters *img )
{
int progressive_refinement_id;
Bitstream* buf;
buf = malloc(sizeof(Bitstream));
buf->bitstream_length = size;
buf->streamBuffer = payload;
buf->frame_bitoffset = 0;
UsedBits = 0;
progressive_refinement_id = ue_v("SEI: progressive_refinement_id" , buf);
#ifdef PRINT_PROGRESSIVE_REFINEMENT_END_INFO
printf("Progressive refinement segment end SEI message\n");
printf("progressive_refinement_id = %d\n", progressive_refinement_id);
#endif
free (buf);
#ifdef PRINT_PROGRESSIVE_REFINEMENT_END_INFO
#undef PRINT_PROGRESSIVE_REFINEMENT_END_INFO
#endif
}
/*!
************************************************************************
* \brief
* Interpret the Motion-constrained slice group set SEI message
* \param payload
* a pointer that point to the sei payload
* \param size
* the size of the sei message
* \param img
* the image pointer
*
************************************************************************
*/
void interpret_motion_constrained_slice_group_set_info( byte* payload, int size, ImageParameters *img )
{
int num_slice_groups_minus1, slice_group_id, exact_match_flag, pan_scan_rect_flag, pan_scan_rect_id;
int i;
Bitstream* buf;
buf = malloc(sizeof(Bitstream));
buf->bitstream_length = size;
buf->streamBuffer = payload;
buf->frame_bitoffset = 0;
UsedBits = 0;
num_slice_groups_minus1 = ue_v("SEI: num_slice_groups_minus1" , buf);
#ifdef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
printf("Motion-constrained slice group set SEI message\n");
printf("num_slice_groups_minus1 = %d\n", num_slice_groups_minus1);
#endif
for (i=0; i<=num_slice_groups_minus1;i++)
{
slice_group_id = ue_v("SEI: slice_group_id" , buf);
#ifdef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
printf("slice_group_id = %d\n", slice_group_id);
#endif
}
exact_match_flag = u_1("SEI: exact_match_flag" , buf);
pan_scan_rect_flag = u_1("SEI: pan_scan_rect_flag" , buf);
#ifdef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
printf("exact_match_flag = %d\n", exact_match_flag);
printf("pan_scan_rect_flag = %d\n", pan_scan_rect_flag);
#endif
if (pan_scan_rect_flag)
{
pan_scan_rect_id = ue_v("SEI: pan_scan_rect_id" , buf);
#ifdef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
printf("pan_scan_rect_id = %d\n", pan_scan_rect_id);
#endif
}
free (buf);
#ifdef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
#undef PRINT_MOTION_CONST_SLICE_GROUP_SET_INFO
#endif
}
/*!
************************************************************************
* \brief
* Interpret the Reserved SEI message
* \param payload
* a pointer that point to the sei payload
* \param size
* the size of the sei message
* \param img
* the image pointer
*
************************************************************************
*/
void interpret_reserved_info( byte* payload, int size, ImageParameters *img )
{
int offset = 0;
byte payload_byte;
#ifdef PRINT_RESERVED_INFO
printf("Reserved SEI message\n");
#endif
assert (size<16);
while (offset < size)
{
payload_byte = payload[offset];
offset ++;
#ifdef PRINT_RESERVED_INFO
printf("reserved_sei_message_payload_byte = %d\n", payload_byte);
#endif
}
#ifdef PRINT_RESERVED_INFO
#undef PRINT_RESERVED_INFO
#endif
}
/*!
************************************************************************
* \brief
* Interpret the Buffering period SEI message
* \param payload
* a pointer that point to the sei payload
* \param size
* the size of the sei message
* \param img
* the image pointer
*
************************************************************************
*/
void interpret_buffering_period_info( byte* payload, int size, ImageParameters *img )
{
int seq_parameter_set_id, initial_cpb_removal_delay, initial_cpb_removal_delay_offset;
unsigned int k;
Bitstream* buf;
seq_parameter_set_rbsp_t *sps;
buf = malloc(sizeof(Bitstream));
buf->bitstream_length = size;
buf->streamBuffer = payload;
buf->frame_bitoffset = 0;
UsedBits = 0;
seq_parameter_set_id = ue_v("SEI: seq_parameter_set_id" , buf);
sps = &SeqParSet[seq_parameter_set_id];
#ifdef PRINT_BUFFERING_PERIOD_INFO
printf("Buffering period SEI message\n");
printf("seq_parameter_set_id = %d\n", seq_parameter_set_id);
#endif
if (sps->vui_seq_parameters.nal_hrd_parameters_present_flag)
{
for (k=0; k<sps->vui_seq_parameters.nal_hrd_parameters.cpb_cnt; k++)
{
initial_cpb_removal_delay = u_v(sps->vui_seq_parameters.nal_hrd_parameters.cpb_removal_delay_length_minus1+1,
"SEI: initial_cpb_removal_delay" , buf);
initial_cpb_removal_delay_offset = u_v(sps->vui_seq_parameters.nal_hrd_parameters.cpb_removal_delay_length_minus1+1,
"SEI: initial_cpb_removal_delay_offset" , buf);
#ifdef PRINT_BUFFERING_PERIOD_INFO
printf("nal initial_cpb_removal_delay[%d] = %d\n", k, initial_cpb_removal_delay);
printf("nal initial_cpb_removal_delay_offset[%d] = %d\n", k, initial_cpb_removal_delay_offset);
#endif
}
}
if (sps->vui_seq_parameters.vcl_hrd_parameters_present_flag)
{
for (k=0; k<sps->vui_seq_parameters.vcl_hrd_parameters.cpb_cnt; k++)
{
initial_cpb_removal_delay = u_v(sps->vui_seq_parameters.vcl_hrd_parameters.cpb_removal_delay_length_minus1+1,
"SEI: initial_cpb_removal_delay" , buf);
initial_cpb_removal_delay_offset = u_v(sps->vui_seq_parameters.vcl_hrd_parameters.cpb_removal_delay_length_minus1+1,
"SEI: initial_cpb_removal_delay_offset" , buf);
#ifdef PRINT_BUFFERING_PERIOD_INFO
printf("vcl initial_cpb_removal_delay[%d] = %d\n", k, initial_cpb_removal_delay);
printf("vcl initial_cpb_removal_delay_offset[%d] = %d\n", k, initial_cpb_removal_delay_offset);
#endif
}
}
free (buf);
#ifdef PRINT_BUFFERING_PERIOD_INFO
#undef PRINT_BUFFERING_PERIOD_INFO
#endif
}
/*!
************************************************************************
* \brief
* Interpret the Picture timing SEI message
* \param payload
* a pointer that point to the sei payload
* \param size
* the size of the sei message
* \param img
* the image pointer
*
************************************************************************
*/
void interpret_picture_timing_info( byte* payload, int size, ImageParameters *img )
{
int cpb_removal_delay, dpb_output_delay, picture_structure_present_flag, picture_structure;
int clock_time_stamp_flag;
int ct_type, nuit_field_based_flag, counting_type, full_timestamp_flag, discontinuity_flag, cnt_dropped_flag, nframes;
int seconds_value, minutes_value, hours_value, seconds_flag, minutes_flag, hours_flag, time_offset;
int NumClockTs = 0;
int i;
Bitstream* buf;
buf = malloc(sizeof(Bitstream));
buf->bitstream_length = size;
buf->streamBuffer = payload;
buf->frame_bitoffset = 0;
UsedBits = 0;
assert (NULL!=active_sps);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("Picture timing SEI message\n");
#endif
if ((active_sps->vui_seq_parameters.nal_hrd_parameters_present_flag)||
(active_sps->vui_seq_parameters.vcl_hrd_parameters_present_flag))
{
cpb_removal_delay = ue_v("SEI: cpb_removal_delay" , buf);
dpb_output_delay = ue_v("SEI: dpb_output_delay" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("cpb_removal_delay = %d\n",cpb_removal_delay);
printf("dpb_output_delay = %d\n",dpb_output_delay);
#endif
}
picture_structure_present_flag = u_1("SEI: picture_structure_present_flag" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("picture_structure_present_flag = %d\n",picture_structure_present_flag);
#endif
if (picture_structure_present_flag)
{
picture_structure = u_v(3, "SEI: picture_structure" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("picture_structure = %d\n",picture_structure);
#endif
switch (picture_structure)
{
case 0:
case 1:
case 2:
NumClockTs = 1;
break;
case 3:
case 4:
case 7:
NumClockTs = 2;
break;
case 5:
case 6:
case 8:
NumClockTs = 3;
break;
default:
error("reserved picture_structure used (can't determine NumClockTs)", 500);
}
for (i=0; i<NumClockTs; i++)
{
clock_time_stamp_flag = u_1("SEI: clock_time_stamp_flag" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("clock_time_stamp_flag = %d\n",clock_time_stamp_flag);
#endif
if (clock_time_stamp_flag)
{
ct_type = u_v(2, "SEI: ct_type" , buf);
nuit_field_based_flag = u_1( "SEI: nuit_field_based_flag" , buf);
counting_type = u_v(5, "SEI: counting_type" , buf);
full_timestamp_flag = u_1( "SEI: full_timestamp_flag" , buf);
discontinuity_flag = u_1( "SEI: discontinuity_flag" , buf);
cnt_dropped_flag = u_1( "SEI: cnt_dropped_flag" , buf);
nframes = u_v(8, "SEI: nframes" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("ct_type = %d\n",ct_type);
printf("nuit_field_based_flag = %d\n",nuit_field_based_flag);
printf("full_timestamp_flag = %d\n",full_timestamp_flag);
printf("discontinuity_flag = %d\n",discontinuity_flag);
printf("cnt_dropped_flag = %d\n",cnt_dropped_flag);
printf("nframes = %d\n",nframes);
#endif
if (full_timestamp_flag)
{
seconds_value = u_v(6, "SEI: seconds_value" , buf);
minutes_value = u_v(6, "SEI: minutes_value" , buf);
hours_value = u_v(5, "SEI: hours_value" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("seconds_value = %d\n",seconds_value);
printf("minutes_value = %d\n",minutes_value);
printf("hours_value = %d\n",hours_value);
#endif
}
else
{
seconds_flag = u_1( "SEI: seconds_flag" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("seconds_flag = %d\n",seconds_flag);
#endif
if (seconds_flag)
{
seconds_value = u_v(6, "SEI: seconds_value" , buf);
minutes_flag = u_1( "SEI: minutes_flag" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("seconds_value = %d\n",seconds_value);
printf("minutes_flag = %d\n",minutes_flag);
#endif
if(minutes_flag)
{
minutes_value = u_v(6, "SEI: minutes_value" , buf);
hours_flag = u_1( "SEI: hours_flag" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("minutes_value = %d\n",minutes_value);
printf("hours_flag = %d\n",hours_flag);
#endif
if(hours_flag)
{
hours_value = u_v(5, "SEI: hours_value" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("hours_value = %d\n",hours_value);
#endif
}
}
}
}
if(active_sps->vui_seq_parameters.nal_hrd_parameters.time_offset_length) //!KS which HRD params shall be used?
{
time_offset=0;
// time_offset = i_v(active_sps->vui_seq_parameters.nal_hrd_parameters.time_offset_length, "SEI: time_offset" , buf);
#ifdef PRINT_PCITURE_TIMING_INFO
printf("time_offset = %d\n",time_offset);
#endif
}
}
}
}
free (buf);
#ifdef PRINT_PCITURE_TIMING_INFO
#undef PRINT_PCITURE_TIMING_INFO
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -