[FFmpeg-devel] [PATCH] Fixing small memory leak when wrapping texture in AVD3D11FrameDescriptor

Aaron Levinson alevinsn_dev at levland.net
Wed Nov 8 03:50:41 EET 2017


On 11/4/2017 9:43 PM, Greg Wessels wrote:
> ---
>   libavutil/hwcontext_d3d11va.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
> index 52683b9..65dd665 100644
> --- a/libavutil/hwcontext_d3d11va.c
> +++ b/libavutil/hwcontext_d3d11va.c
> @@ -123,6 +123,7 @@ static void d3d11va_frames_uninit(AVHWFramesContext *ctx)
>   static void free_texture(void *opaque, uint8_t *data)
>   {
>       ID3D11Texture2D_Release((ID3D11Texture2D *)opaque);
> +    av_free(data);
>   }
>   
>   static AVBufferRef *wrap_texture_buf(ID3D11Texture2D *tex, int index)
> 

LGTM.  I've also noticed a memory leak with hardware-accelerated D3D11 
H.264 decoding, and this patch fixes the issue.  The actual memory leak 
originates from wrap_texture_buf() in the same file from the following line:

     AVD3D11FrameDescriptor *desc = av_mallocz(sizeof(*desc));

and there will be one leak per surface per hardware decoding session. 
The number of surfaces can vary, but for H.264 and HEVC, it is equal to 
20 (4 + 16).  So, for H.264, there will be 20 leaks per decoding session.

It would be helpful to see this committed soon.  Additionally, I looked 
at the libav source base, and this issue exists there as well.

Aaron Levinson


More information about the ffmpeg-devel mailing list