H264解码深度解析——DM8168 OMX从H264文件读取一帧数据(do chunking of h264)

 

源码来源:TI - DM8168 - EZSDK - OMX - examples - decode_display

 

基本执行流程如下:

 


Decode_GetNextFrameSize(H264_ParsingCtx *pc)函数源码(加注释)如下:

 

/*****************************************************************************\
*     Decode_GetNextFrameSize Function Declaration
\*****************************************************************************/
/**
*
* @brief    Gets the size of thenext frame, It is doing chunking of h264
*           elementary bitstream and providing frames to OMX component.
*
* @param in:
*           pc: Pointer to H264_ParsingCtx structure
*
* @param Out:
*           None
*
* @return   uint32_t - Frame Size
*
*/
 
unsigned int Decode_GetNextFrameSize(H264_ParsingCtx *pc)
{
 FILE *fp = pc->fp; // pc->fp指向的是H264文件
 unsigned char *readBuf = pc->readBuf;
 H264_ChunkingCtx *ctx = &pc->ctx;
 AVChunk_Buf *inBuf = &pc->inBuf;
 AVChunk_Buf *outBuf = &pc->outBuf;
 
 unsigned char termCond = 1;
  if(pc->firstParse == 1) // pc->firstParse的初始化值就是1
   termCond = 0;
 
 while ((!feof (fp)) ||
        ((((pc->firstParse == 0) && (pc->bytes != 0))
          && (pc->bytes <= READSIZE) && (pc->tmp <=pc->bytes))))
  {
   if (pc->firstParse == 1)
    {
     pc->bytes = fread (readBuf, 1, READSIZE, fp);//将H264比特流读取到readBuf
     if (!pc->bytes)
     {
       return 0;
     }
     inBuf->ptr = readBuf;  // inBuf->ptr也指向了H264比特流数据
     pc->tmp = 0;
     pc->firstParse = 0;
    }
   else
    {
     if (pc->bytes <= pc->tmp)
     {
       pc->bytes = fread (readBuf, 1, READSIZE, fp);
       if (!pc->bytes)
       {
         return 0;
       }
       inBuf->ptr = readBuf;
       pc->tmp = 0;
     }
    }
 
   while (pc->bytes > pc->tmp)
    {
     inBuf->bufsize =
       ((pc->bytes - pc->tmp) > 184) ? 184 : (pc->bytes -pc->tmp)
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值