H264标准协议基础3

参考博文

上一篇H264标准协议基础2
1.解码视频帧的poc计算
poc计算主要是由于视频帧解码的顺序和显示次序是不一致的,这个时候就需要对编码的视频帧做编号处理。 常见的处理方式就是通过pic_order_cnt_lsb + pic_order_cnt_msb的方式进行。
  • pic_order_cnt_type: 首先解析sps的时候就会就会指明类型值,具体为0,1,2中的一种;
    具体计算还需要配合源码进行解读:
void decode_poc(struct img_par *img)
{
   
   
  int i;
  // for POC mode 0:
  unsigned int        MaxPicOrderCntLsb = (1<<(active_sps->log2_max_pic_order_cnt_lsb_minus4+4));

  switch ( active_sps->pic_order_cnt_type )
  {
   
   
  case 0: // POC MODE 0
    // 1st
    if(img->idr_flag)
    {
   
   
      img->PrevPicOrderCntMsb = 0;
      img->PrevPicOrderCntLsb = 0;
    }
    else
    {
   
   
      if (img->last_has_mmco_5) 
      {
   
   
        if (img->last_pic_bottom_field)
        {
   
   
          img->PrevPicOrderCntMsb = 0;
          img->PrevPicOrderCntLsb = 0;
        }
        else
        {
   
   
          img->PrevPicOrderCntMsb = 0;
          img->PrevPicOrderCntLsb = img->toppoc;
        }
      }
    }
    // Calculate the MSBs of current picture
    if( img->pic_order_cnt_lsb  <  img->PrevPicOrderCntLsb  &&  
      ( img->PrevPicOrderCntLsb - img->pic_order_cnt_lsb )  >=  ( MaxPicOrderCntLsb / 2 ) )
      img->PicOrderCntMsb = img->PrevPicOrderCntMsb + MaxPicOrderCntLsb;
    else if ( img->pic_order_cnt_lsb  >  img->PrevPicOrderCntLsb  &&
      ( img->pic_order_cnt_lsb - img->PrevPicOrderCntLsb )  >  ( MaxPicOrderCntLsb / 2 ) )
      img->PicOrderCntMsb = img->PrevPicOrderCntMsb - MaxPicOrderCntLsb;
    else
      img->PicOrderCntMsb = img->PrevPicOrderCntMsb;
    
    // 2nd

    if ((!img->field_pic_flag)||(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值