[FFmpeg-devel] [PATCH] lavformat/utils: Fix a memleak that st->codec->hw_frames_ctx

wm4 nfxjfg at googlemail.com
Fri Jan 20 11:56:48 EET 2017


On Fri, 20 Jan 2017 17:35:33 +0800
Chao Liu <chaox.a.liu at gmail.com> wrote:

> Have you ever used valgrind? Please just run the command below:
> valgrind --leak-check=full --log-file=out.log ffmpeg -hwaccel qsv
> -qsv_device /dev/dri/renderD128 -c:v h264_qsv -i a.h264 -c:v h264_qsv -b:v
> 2M  -y out.h264
> 
> See line 3323 of ffmpeg.c,
>         ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx);
> and see what have been done in avcodec_copy_context:
>     if (src->hw_frames_ctx) {
>         dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);
>         if (!dest->hw_frames_ctx)
>             goto fail;
>     }
> However, that is not freed when calling avformat_free_context.
> 

The hardware decoder should never be created in the demuxer.


More information about the ffmpeg-devel mailing list