diff mbox series

[FFmpeg-devel] hw_base_encode: Free pictures on close

Message ID 20241015145007.289027-2-nowrep@gmail.com
State New
Headers show
Series [FFmpeg-devel] hw_base_encode: Free pictures on close | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed

Commit Message

David Rosca Oct. 15, 2024, 2:49 p.m. UTC
Fixes leaking recon surfaces with VAAPI.
---
 libavcodec/hw_base_encode.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Lynne Oct. 15, 2024, 3:51 p.m. UTC | #1
On 15/10/2024 16:49, David Rosca wrote:
> Fixes leaking recon surfaces with VAAPI.
> ---
>   libavcodec/hw_base_encode.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c
> index 7b6ec97d3b..912c707a68 100644
> --- a/libavcodec/hw_base_encode.c
> +++ b/libavcodec/hw_base_encode.c
> @@ -804,6 +804,11 @@ int ff_hw_base_encode_init(AVCodecContext *avctx, FFHWBaseEncodeContext *ctx)
>   
>   int ff_hw_base_encode_close(FFHWBaseEncodeContext *ctx)
>   {
> +    FFHWBaseEncodePicture *pic;
> +
> +    for (pic = ctx->pic_start; pic; pic = pic->next)
> +        base_encode_pic_free(pic);
> +
>       av_fifo_freep2(&ctx->encode_fifo);
>   
>       av_frame_free(&ctx->frame);

I've noticed this happening with Vulkan as well.

LGTM, I'll push this after testing it in a few hours
diff mbox series

Patch

diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c
index 7b6ec97d3b..912c707a68 100644
--- a/libavcodec/hw_base_encode.c
+++ b/libavcodec/hw_base_encode.c
@@ -804,6 +804,11 @@  int ff_hw_base_encode_init(AVCodecContext *avctx, FFHWBaseEncodeContext *ctx)
 
 int ff_hw_base_encode_close(FFHWBaseEncodeContext *ctx)
 {
+    FFHWBaseEncodePicture *pic;
+
+    for (pic = ctx->pic_start; pic; pic = pic->next)
+        base_encode_pic_free(pic);
+
     av_fifo_freep2(&ctx->encode_fifo);
 
     av_frame_free(&ctx->frame);