[Ffmpeg-devel] Problem with returned AVCodecContext

Ahmad Zaidee bin Abu zaidee
Mon Oct 3 15:32:51 CEST 2005

Hi all,

I'm quite beginner with ffmpeg. I have some problems with AVCodecContext.

I'm using C++ .Net with libavcodec/libavformat CVS 09/29/05.

In main() i do

//FFMPEG Initialization

// Register all formats and codecs




(have to do avcodec_init & avcodec_register_all, otherwise codec not found)

AVCodecContext *CodecContext; //=NULL;

AVFrame *Picture;

CreateH263Decoder(CodecContext, Picture);


I used 3 functions as below:

int CreateH263Decoder(AVCodecContext *c, AVFrame *picture)


AVCodec *codec; 

/* find the h263 video decoder */

codec = avcodec_find_decoder(CODEC_ID_H263); 

if (!codec) {

// Codec NOT Found

return H263_NOT_FOUND; //my own error / success detection macro


c = avcodec_alloc_context();

picture= avcodec_alloc_frame();

if (!picture)


return H263_NO_MEMORY_FOR_BUFFERS; //my own error / success detection macro


/* open it */

if (avcodec_open(c, codec) < 0) {

//Open Failed!

return H263_OPEN_FAIL; //my own error / success detection macro


return H263_OK; // return ok if successful.


int DecodeH263(AVCodecContext *c, AVFrame *picture, unsigned char *videobuffer, int buffsize)


int got_picture, len;

len = avcodec_decode_video(c, picture, &got_picture, videobuffer, buffsize);

if (got_picture)


return H263_OK;







void DestroyH263Decoder(AVCodecContext *c, AVFrame *picture) {

//Close & free context and free picture (frame)





When I call CreateH263Decoder, AVCodecContext reurn NULL (0). When i trace inside the function,

the value of "c" before return H263_OK;  are as expected, but value of "CodecContext" in main are not as I expected.

What could be the problem? Did I miss anything.

Thank you.


The information contained in this Internet message is confidential 
and intended only for the use of the individual or entity 
identified. If the reader of this message is not the intended 
recipient, any dissemination, distribution or copying of the 
information contained in this Internet message is strictly 
prohibited. If you received this message in error, please notify 
the sender immediately. 

More information about the ffmpeg-devel mailing list