On Mon, 18 Feb 2013 13:59:56 +0100, Janne Grunau <[email protected]> wrote: > On 2013-02-16 10:50:33 +0100, Anton Khirnov wrote: > > --- > > libavcodec/zerocodec.c | 36 ++++++++---------------------------- > > 1 file changed, 8 insertions(+), 28 deletions(-) > > > > diff --git a/libavcodec/zerocodec.c b/libavcodec/zerocodec.c > > index 8122cca..e503aa7 100644 > > --- a/libavcodec/zerocodec.c > > +++ b/libavcodec/zerocodec.c > > @@ -31,14 +31,12 @@ static int zerocodec_decode_frame(AVCodecContext > > *avctx, void *data, > > int *got_frame, AVPacket *avpkt) > > { > > ZeroCodecContext *zc = avctx->priv_data; > > - AVFrame *pic = avctx->coded_frame; > > + AVFrame *pic = data; > > AVFrame *prev_pic = &zc->previous_frame; > > z_stream *zstream = &zc->zstream; > > uint8_t *prev = prev_pic->data[0]; > > uint8_t *dst; > > - int i, j, zret; > > - > > - pic->reference = 3; > > + int i, j, zret, ret; > > > > if (avpkt->flags & AV_PKT_FLAG_KEY) { > > pic->key_frame = 1; > > @@ -61,7 +59,7 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, > > void *data, > > return AVERROR_INVALIDDATA; > > } > > > > - if (ff_get_buffer(avctx, pic) < 0) { > > + if (ff_get_buffer(avctx, pic, AV_GET_BUFFER_FLAG_REF) < 0) { > > av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n"); > > return AVERROR(ENOMEM); > > } > > @@ -82,7 +80,6 @@ static int zerocodec_decode_frame(AVCodecContext *avctx, > > void *data, > > > > zret = inflate(zstream, Z_SYNC_FLUSH); > > if (zret != Z_OK && zret != Z_STREAM_END) { > > - avctx->release_buffer(avctx, pic); > > av_log(avctx, AV_LOG_ERROR, > > "Inflate failed with return code: %d.\n", zret); > > return AVERROR_INVALIDDATA; > > Don't we need to unref pic here or is user/util code expected to handle > frames with references even though decode() didn't set got_picture? >
The code in avcodec_decode_video/audio() checks for that and unrefs the frame if an error is returned. -- Anton Khirnov _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
