fage2014 2015-08-05 03:29
浏览 1938

ffmpeg解码h264视频流的问题

先上代码:
int VideoDecoder_Decode(X264_H dwHandle, uint8_t *pDataIn, int nInSize, uint8_t *pDataOut, int nOutSize, int *nWidth, int *nHeight)//nOutSize
{
X264_Decoder_Handle *pHandle;
//*i_frame_size = 0;
if (dwHandle == 0)
{
return -1;
}
pHandle = (X264_Decoder_Handle *)dwHandle;

//pHandle->inbuf_ptr = pDataIn;
//pHandle->inSize = nInSize;
pHandle->avpkt.size = nInSize;
pHandle->avpkt.data = pDataIn;
while (pHandle->avpkt.size > 0) {
//LOGI("avcodec_decode_video2\n");
//pHandle->outSize = avcodec_decode_video2(pHandle->c, pHandle->picture, &pHandle->got_picture,
// pHandle->inbuf_ptr, pHandle->inSize);
pHandle->comsumedSize = avcodec_decode_video2(pHandle->c, pHandle->picture, &pHandle->got_picture, &(pHandle->avpkt));
if (pHandle->comsumedSize < 0) {

//LOGE("Error while decoding frame InSize = %d comsumedSize = %d\n", pHandle->avpkt.size,pHandle->comsumedSize);
//exit(1);
printf("222222222222222222222222222222222222222222222222222222222222222");
return -1;
}
if (pHandle->got_picture) {
//printf("saving frame %3d\n", pHandle->frame);
fflush(stdout);

/* the picture is allocated by the decoder. no need to
free it /
*nWidth = pHandle->c->width;
*nHeight = pHandle->c->height;
if(nOutSize >= (pHandle->c->width)
(pHandle->c->height)*3/2)
{
pgm_save2(pHandle->picture->data[0], pHandle->picture->linesize[0],pHandle->c->width, pHandle->c->height,pDataOut);
pgm_save2(pHandle->picture->data[1], pHandle->picture->linesize[1],pHandle->c->width/2, pHandle->c->height/2,pDataOut +pHandle->c->width * pHandle->c->height);
pgm_save2(pHandle->picture->data[2], pHandle->picture->linesize[2],pHandle->c->width/2, pHandle->c->height/2,pDataOut +pHandle->c->width * pHandle->c->height*5/4);
}

pHandle->frame_count++;
}
if (pHandle->avpkt.data) {
pHandle->avpkt.size -= pHandle->comsumedSize;
pHandle->avpkt.data += pHandle->comsumedSize;
}
}
printf("nOutSize: %d (pHandle->c->width)*(pHandle->c->height)*3/2: %d",nOutSize,(pHandle->c->width)*(pHandle->c->height)*3/2);
if(nOutSize < (pHandle->c->width)*(pHandle->c->height)*3/2)
{
printf("33333333333333333333333333333333333333333333333333333333333333");
// printf("nOutSize: %d (pHandle->c->width)*(pHandle->c->height)*3/2: %d",nOutSize,(pHandle->c->width)*(pHandle->c->height)*3/2);
return -1;
}
return 0;
}

用ffmpeg支持64的解码库解码时,这段解码代码在iphone5及以下(32位设备)解码时没问题,但在iphone5以上设备(64位设备)上解码时在以下代码处崩溃了,有人说是地址不匹配:
pHandle->avpkt.size = nInSize;
pHandle->avpkt.data = pDataIn;
崩溃信息如下:
图片说明

到底是什么原因呢,又该怎么解决,哪位大神能够帮忙解答一下,不胜感激....

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥30 python代码,帮调试,帮帮忙吧
    • ¥15 #MATLAB仿真#车辆换道路径规划