请教个问题,我的MFC 输入的第一帧数据是一个完整的 IDR FRAME,得到的输出图像不正确,如果同样的数据送给FFMPEG 的 avcodec_decode_video2 是可以得到正确的图像的。请问MFC 的输入时需要对数据做处理吗。
我的数据源是用RTP 从PC 传过来的,组包后,将各个 FRAME 存成连续的文件,用STREAM EYE 是可以正常播放的,
看了下文件信息,每个包的起始均是 00 00 00 01 ,STREAM EYE提示的每帧长度也是同我的每个包长度一致的,
请看下面代码的蓝色部分,是不是我送给MFC的数据不应该是整个 FRAME ,要提前处理么?
static void *DecodeVideoh264Stream(void* pkt,long *size)
{
long framesize = 0;
void *VideoBuffer = NULL;
int GotPicture = 0;
if(size)
*size = framesize;
memcpy(Ocx.m_pHwVideoStreamBuffer,pkt1->size);
if(HwDecodeExe(Ocx.m_bOpenHWHandle, pkt1->size + offsetHw - offsetPk) >= 0)
{
VideoBuffer = (void*)HwDecodeOutBuffer(Ocx.m_bOpenHWHandle,&framesize);
ms_warning("FRANK: OK: HwDecodeOutBuffer \n");
}
else
{
ms_warning("FRANK: ERROR: HwDecodeOutBuffer \n");
HwDecodeDeInit(Ocx.m_bOpenHWHandle);
Ocx.m_bOpenHWHandle = NULL;
Ocx.m_bHEnable = FALSE;
Ocx.m_bHWFormat = SSBSIPMFCDEC_NONE;
//// Ocx.m_pHwVideoStreamBuffer = (uint8_t*)CMMAllocMemory(Ocx.m_bVideoBufferSize);
if(!Ocx.m_pHwVideoStreamBuffer)
{
av_free_packet(pkt1);
return NULL;
}
goto SoftDec;
}
}
}
else
SoftDec:
{
#if 0
AVFrame *AVFrameUse = avcodec_alloc_frame();
void *SrcData = pkt1->data;
avcodec_decode_video2(Ocx.m_pVideoSt->codec, AVFrameUse, &GotPicture, pkt1);
if (GotPicture != 0)
{
framesize = Ocx.m_bVideoBufferSize;
VideoBuffer = (void*)Ocx.m_pHwVideoStreamBuffer;
}
Ocx.m_bRepeat = AVFrameUse->repeat_pict;
pkt1->data = SrcData;
av_free(AVFrameUse);
#endif
}
if(size)
*size = framesize;
av_free_packet(pkt1);
return VideoBuffer;
}