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().
Showing the changes to libavcodec/vaapi_encode.c (1 of 7 files). Show all
Unified · Split
| @@ -2366,7 +2366,6 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx) · 2365 unmodified lines | ||
| 2366 | 2366 | return 0; |
| 2367 | 2367 | |
| 2368 | 2368 | fail: |
| 2369 | − ff_vaapi_encode_close(avctx); | |
| 2370 | 2369 | return err; |
| 2371 | 2370 | } |
| 2372 | 2371 | |