[FFmpeg-devel] libavcodec/rawdec.c and avctx->get_buffer problem

Michael Niedermayer michaelni
Tue Jan 8 12:13:45 CET 2008


On Tue, Jan 08, 2008 at 10:10:10AM +0100, Stefano Sabatini wrote:
> Hi all,
> 
> I already posted this to ffmpeg-user without to get a reply, so I'm
> reposting it here because it has development implications.
> 
> This is the problem I'm facing: in an application I need to do
> something everytime a new video frame has been completely decoded.
> 
> In order to do this, 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 struct pointer is accessed later.
> 
> 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
> saying:
> [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
> case.
> 
> So my question is:
> is every decoder supposed to call the avctx->get_buffer function?

no

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080108/d4fcc033/attachment.pgp>



More information about the ffmpeg-devel mailing list