On date Saturday 2008-06-21 01:14:13 +0200, Stefano Falasca wrote:
> Hi,
>
> I've a problem using CODEC_ID_WMV3 decode. On avcodec_open it fail. I can't
> understand why. I use below function for other codec and work.
>
> Thanks
>
> Stefano
>
>
>
> int CFFDecode::Init(int codec_id, int width, int height, int fps)
>
> {
>
> if ((width & 1) == 1) return E_INVALIDARG;
>
> if ((height & 1) == 1) return E_INVALIDARG;
>
>
>
> strcpy_s(m_fileNamePic, pFileNameThumbBmp);
>
> DbgOut(m_fileNamePic);
>
> m_codec = avcodec_find_decoder((CodecID)codec_id);
>
> if (m_codec == NULL) {DbgOut("FFINIT OK");return E_FAIL;}
>
>
>
> m_c = avcodec_alloc_context();
>
> if (m_c == NULL) {DbgOut("avcodec_alloc_context error");return
> E_OUTOFMEMORY;}
>
>
>
> avcodec_get_context_defaults2(m_c, CODEC_TYPE_VIDEO);
>
> avcodec_get_frame_defaults(&m_picture);
>
>
>
> m_c->codec_id = (CodecID) codec_id;
>
> m_c->codec_type = CODEC_TYPE_VIDEO;
>
> m_c->strict_std_compliance = 0;
>
>
>
> /* put sample parameters */
>
> //m_c->bit_rate = bitrate;
Doesn't make sense setting the bitrate for the *decoder*.
>
> /* resolution must be a multiple of two */
>
> m_c->width = width;
>
> m_c->height = height;
>
> /* time base: this is the fundamental unit of time (in seconds) in
> terms
>
> of which frame timestamps are represented. for fixed-fps content,
>
> timebase should be 1/framerate and timestamp increments should be
>
> identically 1. */
>
> m_c->time_base.den = fps;
>
> m_c->time_base.num = 1;
>
> m_c->gop_size = 12; /* emit one intra frame every twelve frames at
> most */
Again doesn't make sense setting the gop for the *decoder*, this will
be simply ignored.
> m_c->pix_fmt = PIX_FMT_BGR24;
Again it is useless, the input/output pixel format is set by
libavcodec, so this value I think will be overriden.
> int iRetOpen = avcodec_open(m_c, m_codec);
>
> if ( iRetOpen < 0) {
>
> DbgOutInt("avcodec_open error:",iRetOpen);
>
> return E_FAIL;
>
> }
avcodec_open() should say you why it failed using av_log(), it is
usually a problem related to the parameters used, every codec supports
a different subset of acceptable values, so the same values which are
perfectly valid for one codec may not be valid for another one.
Regards.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user