⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sei.c

📁 H.264编码解码器源码(c语言).zip
💻 C
📖 第 1 页 / 共 4 页
字号:
 *     the image pointer
 *    
 ************************************************************************
 */
void interpret_user_data_registered_itu_t_t35_info( byte* payload, int size, ImageParameters *img )
{
  int offset = 0;
  byte itu_t_t35_country_code, itu_t_t35_country_code_extension_byte, payload_byte;

  itu_t_t35_country_code = payload[offset];
  offset++;
#ifdef PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO
  printf("User data registered by ITU-T T.35 SEI message\n");
  printf(" itu_t_t35_country_code = %d \n", itu_t_t35_country_code);
#endif
  if(itu_t_t35_country_code == 0xFF) 
  {
    itu_t_t35_country_code_extension_byte = payload[offset];
    offset++;
#ifdef PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO
    printf(" ITU_T_T35_COUNTRTY_CODE_EXTENSION_BYTE %d \n", itu_t_t35_country_code_extension_byte);
#endif
  }
  while (offset < size)
  {
    payload_byte = payload[offset];
    offset ++;
#ifdef PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO
    printf("itu_t_t35 payload_byte = %d\n", payload_byte);
#endif
  }
#ifdef PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO
#undef PRINT_USER_DATA_REGISTERED_ITU_T_T35_INFO
#endif
}


/*!
 ************************************************************************
 *  \brief
 *     Interpret the Pan scan rectangle 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_pan_scan_rect_info( byte* payload, int size, ImageParameters *img )
{
  int pan_scan_rect_id, pan_scan_rect_left_offset, pan_scan_rect_right_offset;
  int pan_scan_rect_top_offset, pan_scan_rect_bottom_offset;

  Bitstream* buf;

  buf = malloc(sizeof(Bitstream));
  buf->bitstream_length = size;
  buf->streamBuffer = payload;
  buf->frame_bitoffset = 0;

  UsedBits = 0;

  pan_scan_rect_id = ue_v("SEI: pan_scan_rect_id", buf);

  pan_scan_rect_left_offset   = se_v("SEI: pan_scan_rect_left_offset"  , buf);
  pan_scan_rect_right_offset  = se_v("SEI: pan_scan_rect_right_offset" , buf);
  pan_scan_rect_top_offset    = se_v("SEI: pan_scan_rect_top_offset"   , buf);
  pan_scan_rect_bottom_offset = se_v("SEI: pan_scan_rect_bottom_offset", buf);

#ifdef PRINT_PAN_SCAN_RECT
  printf("Pan scan rectangle SEI message\n");
  printf("pan_scan_rect_id            = %d\n", pan_scan_rect_id);
  printf("pan_scan_rect_left_offset   = %d\n", pan_scan_rect_left_offset);
  printf("pan_scan_rect_right_offset  = %d\n", pan_scan_rect_right_offset);
  printf("pan_scan_rect_top_offset    = %d\n", pan_scan_rect_top_offset);
  printf("pan_scan_rect_bottom_offset = %d\n", pan_scan_rect_bottom_offset);
#endif
  free (buf);
#ifdef PRINT_PAN_SCAN_RECT
#undef PRINT_PAN_SCAN_RECT
#endif
}


/*!
 ************************************************************************
 *  \brief
 *     Interpret the Random access point 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_random_access_info( byte* payload, int size, ImageParameters *img )
{
  int recovery_frame_cnt, exact_match_flag, broken_link_flag, changing_slice_group_idc;


  Bitstream* buf;


  buf = malloc(sizeof(Bitstream));
  buf->bitstream_length = size;
  buf->streamBuffer = payload;
  buf->frame_bitoffset = 0;

  UsedBits = 0;

  recovery_frame_cnt       = ue_v(    "SEI: recovery_frame_cnt"      , buf);
  exact_match_flag         = u_1 (    "SEI: exact_match_flag"        , buf);
  broken_link_flag         = u_1 (    "SEI: broken_link_flag"        , buf);
  changing_slice_group_idc = u_v ( 2, "SEI: changing_slice_group_idc", buf);

#ifdef PRINT_RANDOM_ACCESS
  printf("Random access point SEI message\n");
  printf("recovery_frame_cnt       = %d\n", recovery_frame_cnt);
  printf("exact_match_flag         = %d\n", exact_match_flag);
  printf("broken_link_flag         = %d\n", broken_link_flag);
  printf("changing_slice_group_idc = %d\n", changing_slice_group_idc);
#endif
  free (buf);
#ifdef PRINT_RANDOM_ACCESS
#undef PRINT_RANDOM_ACCESS
#endif
}


/*!
 ************************************************************************
 *  \brief
 *     Interpret the Decoded Picture Buffer Management Repetition 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_dec_ref_pic_marking_repetition_info( byte* payload, int size, ImageParameters *img )
{
  int original_idr_flag, original_frame_num;

  DecRefPicMarking_t *tmp_drpm;

  DecRefPicMarking_t *old_drpm;
  int old_idr_flag , old_no_output_of_prior_pics_flag, old_long_term_reference_flag , old_adaptive_ref_pic_buffering_flag;


  Bitstream* buf;

  buf = malloc(sizeof(Bitstream));
  buf->bitstream_length = size;
  buf->streamBuffer = payload;
  buf->frame_bitoffset = 0;

  UsedBits = 0;

  original_idr_flag     = u_1 (    "SEI: original_idr_flag"    , buf);
  original_frame_num    = ue_v(    "SEI: original_frame_num"   , buf);

#ifdef PRINT_DEC_REF_PIC_MARKING
  printf("Decoded Picture Buffer Management Repetition SEI message\n");
  printf("original_idr_flag       = %d\n", original_idr_flag);
  printf("original_frame_num      = %d\n", original_frame_num);
#endif

  // we need to save everything that is probably overwritten in dec_ref_pic_marking()
  old_drpm = img->dec_ref_pic_marking_buffer;
  old_idr_flag = img->idr_flag;

  old_no_output_of_prior_pics_flag = img->no_output_of_prior_pics_flag;
  old_long_term_reference_flag = img->long_term_reference_flag;
  old_adaptive_ref_pic_buffering_flag = img->adaptive_ref_pic_buffering_flag;

  // set new initial values
  img->idr_flag = original_idr_flag;
  img->dec_ref_pic_marking_buffer = NULL;

  dec_ref_pic_marking(buf);

  // print out decoded values
#ifdef PRINT_DEC_REF_PIC_MARKING
  if (img->idr_flag)
  {
    printf("no_output_of_prior_pics_flag = %d\n", img->no_output_of_prior_pics_flag);
    printf("long_term_reference_flag     = %d\n", img->long_term_reference_flag);
  }
  else
  {
    printf("adaptive_ref_pic_buffering_flag  = %d\n", img->adaptive_ref_pic_buffering_flag);
    if (img->adaptive_ref_pic_buffering_flag)
    {
      tmp_drpm=img->dec_ref_pic_marking_buffer;
      while (tmp_drpm != NULL)
      {
        printf("memory_management_control_operation  = %d\n", tmp_drpm->memory_management_control_operation);
        
        if ((tmp_drpm->memory_management_control_operation==1)||(tmp_drpm->memory_management_control_operation==3)) 
        {
          printf("difference_of_pic_nums_minus1        = %d\n", tmp_drpm->difference_of_pic_nums_minus1);
        }
        if (tmp_drpm->memory_management_control_operation==2)
        {
          printf("long_term_pic_num                    = %d\n", tmp_drpm->long_term_pic_num);
        }
        if ((tmp_drpm->memory_management_control_operation==3)||(tmp_drpm->memory_management_control_operation==6))
        {
          printf("long_term_frame_idx                  = %d\n", tmp_drpm->long_term_frame_idx);
        }
        if (tmp_drpm->memory_management_control_operation==4)
        {
          printf("max_long_term_pic_idx_plus1          = %d\n", tmp_drpm->max_long_term_frame_idx_plus1);
        }
        tmp_drpm = tmp_drpm->Next;
      }
      
    }
  }
#endif

  while (img->dec_ref_pic_marking_buffer)
  {
    tmp_drpm = img->dec_ref_pic_marking_buffer->Next;
    free (tmp_drpm);
  }

  // restore old values in img
  img->dec_ref_pic_marking_buffer = old_drpm;
  img->idr_flag = old_idr_flag;
  img->no_output_of_prior_pics_flag = old_no_output_of_prior_pics_flag;
  img->long_term_reference_flag = old_long_term_reference_flag;
  img->adaptive_ref_pic_buffering_flag = old_adaptive_ref_pic_buffering_flag;
  
   
  free (buf);
#ifdef PRINT_DEC_REF_PIC_MARKING
#undef PRINT_DEC_REF_PIC_MARKING
#endif
}

/*!
 ************************************************************************
 *  \brief
 *     Interpret the Full-frame freeze 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_full_frame_freeze_info( byte* payload, int size, ImageParameters *img )
{
#ifdef PRINT_FULL_FRAME_FREEZE_INFO
  printf("Full-frame freeze SEI message\n");
  if (size)
  {
    printf("payload size of this message should be zero, but is %d bytes.\n", size);
  }
#endif

#ifdef PRINT_FULL_FRAME_FREEZE_INFO
#undef PRINT_FULL_FRAME_FREEZE_INFO
#endif
}


/*!
 ************************************************************************
 *  \brief
 *     Interpret the Full-frame freeze release 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_full_frame_freeze_release_info( byte* payload, int size, ImageParameters *img )
{
#ifdef PRINT_FULL_FRAME_FREEZE_RELEASE_INFO
  printf("Full-frame freeze release SEI message\n");
  if (size)
  {
    printf("payload size of this message should be zero, but is %d bytes.\n", size);
  }
#endif

#ifdef PRINT_FULL_FRAME_FREEZE_RELEASE_INFO
#undef PRINT_FULL_FRAME_FREEZE_RELEASE_INFO
#endif
}

/*!
 ************************************************************************
 *  \brief
 *     Interpret the Full-frame snapshot 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_full_frame_snapshot_info( byte* payload, int size, ImageParameters *img )
{
  int snapshot_id;

  Bitstream* buf;

  buf = malloc(sizeof(Bitstream));
  buf->bitstream_length = size;
  buf->streamBuffer = payload;
  buf->frame_bitoffset = 0;

  UsedBits = 0;

  snapshot_id = ue_v("SEI: snapshot_id", buf);

#ifdef PRINT_FULL_FRAME_SNAPSHOT_INFO
  printf("Full-frame snapshot SEI message\n");
  printf("snapshot_id = %d\n", snapshot_id);
#endif
  free (buf);
#ifdef PRINT_FULL_FRAME_SNAPSHOT_INFO
#undef PRINT_FULL_FRAME_SNAPSHOT_INFO
#endif
}

/*!
 ************************************************************************
 *  \brief
 *     Interpret the Progressive refinement segment start 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_start_info( byte* payload, int size, ImageParameters *img )
{
  int progressive_refinement_id, num_refinement_steps_minus1;

  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);
  num_refinement_steps_minus1 = ue_v("SEI: num_refinement_steps_minus1", buf);

#ifdef PRINT_PROGRESSIVE_REFINEMENT_START_INFO
  printf("Progressive refinement segment start SEI message\n");
  printf("progressive_refinement_id   = %d\n", progressive_refinement_id);
  printf("num_refinement_steps_minus1 = %d\n", num_refinement_steps_minus1);
#endif
  free (buf);
#ifdef PRINT_PROGRESSIVE_REFINEMENT_START_INFO
#undef PRINT_PROGRESSIVE_REFINEMENT_START_INFO
#endif
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -