On Tue, Mar 4, 2014 at 7:30 PM, Luca Barbato <lu_z...@gentoo.org> wrote: > From: Sebastien Zwickert <dilar...@gmail.com> > > Fix a buffer leak when seeking occurs. > > Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > --- > libavcodec/vda_h264.c | 25 ++++++++++++++++++++++++- > libavcodec/version.h | 4 ++-- > 2 files changed, 26 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/vda_h264.c b/libavcodec/vda_h264.c > index e9c4af6..a7183c6 100644 > --- a/libavcodec/vda_h264.c > +++ b/libavcodec/vda_h264.c > @@ -107,6 +107,12 @@ static int vda_h264_decode_slice(AVCodecContext *avctx, > return 0; > } > > +static void vda_h264_release_buffer(void *opaque, uint8_t *data) > +{ > + CVPixelBufferRef cv_buffer = opaque; > + CVPixelBufferRelease(cv_buffer); > +} > + > static int vda_h264_end_frame(AVCodecContext *avctx) > { > H264Context *h = avctx->priv_data; > @@ -120,8 +126,25 @@ static int vda_h264_end_frame(AVCodecContext *avctx) > status = vda_sync_decode(vda_ctx); > frame->data[3] = (void*)vda_ctx->cv_buffer; > > - if (status) > + if (status) { > av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status); > + return status; > + } > + > + /* VDA workaround to release properly each core video buffer: > + * we need to create an extra av_buffer with a custom freeing callback > + * to avoid potential memory leaks. */ > + h->cur_pic_ptr->hwaccel_priv_buf = av_buffer_create(frame->data[0], > + 0, > + > vda_h264_release_buffer, > + vda_ctx->cv_buffer, > + 0); > + if (!h->cur_pic_ptr->hwaccel_priv_buf) { > + CVPixelBufferRelease(vda_ctx->cv_buffer); > + return AVERROR(ENOMEM); > + } > + > + h->cur_pic_ptr->hwaccel_picture_private = > h->cur_pic_ptr->hwaccel_priv_buf->data; > > return status; > } > diff --git a/libavcodec/version.h b/libavcodec/version.h > index cdd5a61..a813fc9 100644 > --- a/libavcodec/version.h > +++ b/libavcodec/version.h > @@ -29,8 +29,8 @@ > #include "libavutil/version.h" > > #define LIBAVCODEC_VERSION_MAJOR 55 > -#define LIBAVCODEC_VERSION_MINOR 34 > -#define LIBAVCODEC_VERSION_MICRO 1 > +#define LIBAVCODEC_VERSION_MINOR 35 > +#define LIBAVCODEC_VERSION_MICRO 0 > > #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ > LIBAVCODEC_VERSION_MINOR, \ > --
Is this patch still needed? -- Vittorio _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel