From 2b3206891649f317c20993411efef4bee39ae784 Mon Sep 17 00:00:00 2001 From: Linjie Fu Date: Tue, 31 Mar 2020 23:34:00 +0800 Subject: lavc/vaapi_encode: add FF_CODEC_CAP_INIT_CLEANUP caps for encoders ff_vaapi_encode_close() is not enough to free the resources like cbs if initialization failure happens after codec->configure (except for vp8/vp9). We need to call avctx->codec->close() to deallocate, otherwise memory leak happens. Add FF_CODEC_CAP_INIT_CLEANUP for vaapi encoders and deallocate the resources at free_and_end inside avcodec_open2(). Reviewed-by: Timo Rothenpieler Signed-off-by: Linjie Fu --- libavcodec/vaapi_encode_vp9.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libavcodec/vaapi_encode_vp9.c') diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index d05319ef39..8514b85991 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -291,6 +291,7 @@ AVCodec ff_vp9_vaapi_encoder = { .close = &ff_vaapi_encode_close, .priv_class = &vaapi_encode_vp9_class, .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .defaults = vaapi_encode_vp9_defaults, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_VAAPI, -- cgit v1.2.3