Re: Re: [Ffmpeg-devel] problem of decoding mpeg4 ps streamwithlibavformatand libavcodec
楚材
keweixiao
Tue Aug 22 08:30:54 CEST 2006
Here is my code, please help me to find the error.thanks!!!
these code is in a thread function.
CSlot* pThis = (CSlot*)lParam;
AVProbeData pd;
ByteIOContext ByteIOCtx;
//Wait for enough data to begin demux
WaitForSingleObject(pThis->m_hStartEvent,INFINITE);
av_register_all();
if(!pThis->m_bStart) return TRUE;
pThis->m_bDecoding = TRUE;
pd.buf = new unsigned char[MIN_PROBE_SIZE];
pd.buf_size = MIN_PROBE_SIZE;
pd.filename = "";
int hr = fifo_read(&pThis->m_recvBuffer,pd.buf,MIN_PROBE_SIZE,NULL);
AVInputFormat* fmt = av_probe_input_format(&pd,1);
if(!fmt)
{
TRACE("av_probe_input_format failed!\n");
delete [] pd.buf;
pd.buf_size = 0;
return FALSE;
}
TRACE("stream type:%s\n",fmt->long_name);
delete [] pd.buf;
fmt->flags |= AVFMT_NOFILE;
init_put_byte(&ByteIOCtx,pThis->m_pReadBuffer,FILE_READ_SIZE,0,pThis,IORead,NULL,IOSeek);
AVFormatContext* pFormatCtx = NULL;
if(av_open_input_stream(&pFormatCtx,&ByteIOCtx,"",fmt,NULL) < 0)
{
TRACE("av_open_input_stream failed!\n");
return FALSE;
}
if(av_find_stream_info(pFormatCtx) < 0)
{
TRACE("av_find_stream_info ????????!\n");
return FALSE;
}
TRACE("av_find_stream_info result:%d\n",pFormatCtx->nb_streams);
#if defined(_DEBUG)
AVCodecContext* pCodecCtx = pFormatCtx->streams[0]->codec;
TRACE("coded_width=%d,coded_height=%d\n",pCodecCtx->coded_width,pCodecCtx->coded_height);
#endif
...... ...... ...... ......
------------------
??
2006-08-22
av_open_input_file() calls av_open_input_stream() to actually open the
file. Whatever works with one should work with the other, if you're
using them properly.
--
M?ns Rullg?rd
mru at inprovide.com
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at mplayerhq.hu
http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list