libavcodec/rawdec.c and avctx->get_buffer problem

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

libavcodec/rawdec.c and avctx->get_buffer problem

Stefano Sabatini
Hi all,

in an application I need to do something everytime a new video frame
has been decoded.

In order to do so, I define a my_get_buffer() function, which calls
the libavcodec/utils.c:avcodec_default_get_buffer() function, and
which is setted in the avcodec decoder context like this:

avctx->get_buffer= my_get_buffer;

during the initialization stage of the codec context.

This works fine with most decoders, but not with rawdec.c. In this
case the decoder won't just call the avctx->get_buffer function, so
my_get_buffer() won't be executed, resulting in a segfault when a not
initialized variable is accessed lately.

As a workaround I tried to patch rawdec.c, simply defining at the end
of this function:

    *data_size = sizeof(AVPicture);
+    avctx->get_buffer(avctx, (AVFrame*)frame);
    return buf_size;

In this way my_get_buffer() gets called, still I get many error messages
[rawvideo @ 0x846ffc0]pic->data[0]!=NULL in avcodec_default_get_buffer

nonetheless the application works, indeed the my_get_buffer calls the
avcodec_default_get_buffer() but ignores the return value, -1 in this

My question is: is every decoder supposed to call the
avctx->get_buffer function?

In this case is the libavcodec/rawdec.c implementation to be
considered bugged?

Eventually could you suggest a clean fix to this problem?

Many thanks in advance.
ffmpeg-user random tip #5
FF-mpeg documentation:
ffmpeg-user mailing list
[hidden email]