diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 5a96899d50..db8226f9b3 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -39,6 +39,7 @@ #include "decode.h" #include "encode.h" #include "frame_thread_encoder.h" +#include "hwconfig.h" #include "internal.h" #include "thread.h" @@ -459,9 +460,7 @@ av_cold int avcodec_close(AVCodecContext *avctx) av_buffer_unref(&avci->pool); - if (avctx->hwaccel && avctx->hwaccel->uninit) - avctx->hwaccel->uninit(avctx); - av_freep(&avci->hwaccel_priv_data); + ff_hwaccel_uninit(avctx); av_bsf_free(&avci->bsf); diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 18d85cf46f..d75f831a74 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1145,7 +1145,7 @@ static int hwaccel_init(AVCodecContext *avctx, return 0; } -static void hwaccel_uninit(AVCodecContext *avctx) +void ff_hwaccel_uninit(AVCodecContext *avctx) { if (avctx->hwaccel && avctx->hwaccel->uninit) avctx->hwaccel->uninit(avctx); @@ -1184,7 +1184,7 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) for (;;) { // Remove the previous hwaccel, if there was one. - hwaccel_uninit(avctx); + ff_hwaccel_uninit(avctx); user_choice = avctx->get_format(avctx, choices); if (user_choice == AV_PIX_FMT_NONE) { diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h index 721424912c..f03b744cdf 100644 --- a/libavcodec/hwconfig.h +++ b/libavcodec/hwconfig.h @@ -39,6 +39,7 @@ typedef struct AVCodecHWConfigInternal { const AVHWAccel *hwaccel; } AVCodecHWConfigInternal; +void ff_hwaccel_uninit(AVCodecContext *avctx); // These macros are used to simplify AVCodecHWConfigInternal definitions.