mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
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 <timo@rothenpieler.org> Signed-off-by: Linjie Fu <linjie.fu@intel.com>
This commit is contained in:
parent
5767a2ed74
commit
2b32068916
@ -2366,7 +2366,6 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
ff_vaapi_encode_close(avctx);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -1356,6 +1356,7 @@ AVCodec ff_h264_vaapi_encoder = {
|
||||
.close = &vaapi_encode_h264_close,
|
||||
.priv_class = &vaapi_encode_h264_class,
|
||||
.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
|
||||
.defaults = vaapi_encode_h264_defaults,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||
AV_PIX_FMT_VAAPI,
|
||||
|
@ -1292,6 +1292,7 @@ AVCodec ff_hevc_vaapi_encoder = {
|
||||
.close = &vaapi_encode_h265_close,
|
||||
.priv_class = &vaapi_encode_h265_class,
|
||||
.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
|
||||
.defaults = vaapi_encode_h265_defaults,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||
AV_PIX_FMT_VAAPI,
|
||||
|
@ -565,6 +565,7 @@ AVCodec ff_mjpeg_vaapi_encoder = {
|
||||
.priv_class = &vaapi_encode_mjpeg_class,
|
||||
.capabilities = AV_CODEC_CAP_HARDWARE |
|
||||
AV_CODEC_CAP_INTRA_ONLY,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
|
||||
.defaults = vaapi_encode_mjpeg_defaults,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||
AV_PIX_FMT_VAAPI,
|
||||
|
@ -702,6 +702,7 @@ AVCodec ff_mpeg2_vaapi_encoder = {
|
||||
.close = &vaapi_encode_mpeg2_close,
|
||||
.priv_class = &vaapi_encode_mpeg2_class,
|
||||
.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
|
||||
.defaults = vaapi_encode_mpeg2_defaults,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||
AV_PIX_FMT_VAAPI,
|
||||
|
@ -257,6 +257,7 @@ AVCodec ff_vp8_vaapi_encoder = {
|
||||
.close = &ff_vaapi_encode_close,
|
||||
.priv_class = &vaapi_encode_vp8_class,
|
||||
.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
|
||||
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
|
||||
.defaults = vaapi_encode_vp8_defaults,
|
||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||
AV_PIX_FMT_VAAPI,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user