Its use has been discouraged since 2016, but now is no longer used in avformat, so there is no reason to keep it public.
Unified · Split
| @@ -377,7 +377,7 @@ end: · 376 unmodified lines | |||
| 377 | 377 | ||
| 378 | return ret; | 378 | return ret; |
| 379 | free_and_end: | 379 | free_and_end: |
| 380 | avcodec_close(avctx); | 380 | ff_codec_close(avctx); |
| 381 | goto end; | 381 | goto end; |
| 382 | } | 382 | } |
| 383 | 383 | ||
| @@ -432,12 +432,12 @@ void avsubtitle_free(AVSubtitle *sub) · 48 unmodified lines | |||
| 432 | memset(sub, 0, sizeof(*sub)); | 432 | memset(sub, 0, sizeof(*sub)); |
| 433 | } | 433 | } |
| 434 | 434 | ||
| 435 | av_cold int avcodec_close(AVCodecContext *avctx) | 435 | av_cold void ff_codec_close(AVCodecContext *avctx) |
| 436 | { | 436 | { |
| 437 | int i; | 437 | int i; |
| 438 | 438 | ||
| 439 | if (!avctx) | 439 | if (!avctx) |
| 440 | return 0; | 440 | return; |
| 441 | 441 | ||
| 442 | if (avcodec_is_open(avctx)) { | 442 | if (avcodec_is_open(avctx)) { |
| 443 | AVCodecInternal *avci = avctx->internal; | 443 | AVCodecInternal *avci = avctx->internal; |
| @@ -497,9 +497,15 @@ av_cold int avcodec_close(AVCodecContext *avctx) · 53 unmodified lines | |||
| 497 | 497 | ||
| 498 | avctx->codec = NULL; | 498 | avctx->codec = NULL; |
| 499 | avctx->active_thread_type = 0; | 499 | avctx->active_thread_type = 0; |
| 500 | } | ||
| 500 | 501 | ||
| 502 | #if FF_API_AVCODEC_CLOSE | ||
| 503 | int avcodec_close(AVCodecContext *avctx) | ||
| 504 | { | ||
| 505 | ff_codec_close(avctx); | ||
| 501 | return 0; | 506 | return 0; |
| 502 | } | 507 | } |
| 508 | #endif | ||
| 503 | 509 | ||
| 504 | static const char *unknown_if_null(const char *str) | 510 | static const char *unknown_if_null(const char *str) |
| 505 | { | 511 | { |
| @@ -2411,6 +2411,7 @@ int avcodec_parameters_to_context(AVCodecContext *codec, · 2410 unmodified lines | |||
| 2411 | */ | 2411 | */ |
| 2412 | int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); | 2412 | int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); |
| 2413 | 2413 | ||
| 2414 | #if FF_API_AVCODEC_CLOSE | ||
| 2414 | /** | 2415 | /** |
| 2415 | * Close a given AVCodecContext and free all the data associated with it | 2416 | * Close a given AVCodecContext and free all the data associated with it |
| 2416 | * (but not the AVCodecContext itself). | 2417 | * (but not the AVCodecContext itself). |
| @@ -2419,12 +2420,14 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **op · 2 unmodified lines | |||
| 2419 | * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL | 2420 | * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL |
| 2420 | * codec. Subsequent calls will do nothing. | 2421 | * codec. Subsequent calls will do nothing. |
| 2421 | * | 2422 | * |
| 2422 | * @note Do not use this function. Use avcodec_free_context() to destroy a | 2423 | * @deprecated Do not use this function. Use avcodec_free_context() to destroy a |
| 2423 | * codec context (either open or closed). Opening and closing a codec context | 2424 | * codec context (either open or closed). Opening and closing a codec context |
| 2424 | * multiple times is not supported anymore -- use multiple codec contexts | 2425 | * multiple times is not supported anymore -- use multiple codec contexts |
| 2425 | * instead. | 2426 | * instead. |
| 2426 | */ | 2427 | */ |
| 2428 | attribute_deprecated | ||
| 2427 | int avcodec_close(AVCodecContext *avctx); | 2429 | int avcodec_close(AVCodecContext *avctx); |
| 2430 | #endif | ||
| 2428 | 2431 | ||
| 2429 | /** | 2432 | /** |
| 2430 | * Free all allocated data in the given subtitle struct. | 2433 | * Free all allocated data in the given subtitle struct. |
| @@ -56,4 +56,6 @@ void ff_encode_flush_buffers(struct AVCodecContext *avctx); · 55 unmodified lines | |||
| 56 | struct AVCodecInternal *ff_decode_internal_alloc(void); | 56 | struct AVCodecInternal *ff_decode_internal_alloc(void); |
| 57 | struct AVCodecInternal *ff_encode_internal_alloc(void); | 57 | struct AVCodecInternal *ff_encode_internal_alloc(void); |
| 58 | 58 | ||
| 59 | void ff_codec_close(struct AVCodecContext *avctx); | ||
| 60 | |||
| 59 | #endif // AVCODEC_AVCODEC_INTERNAL_H | 61 | #endif // AVCODEC_AVCODEC_INTERNAL_H |
| @@ -27,6 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include "libavutil/opt.h" | 27 | #include "libavutil/opt.h" |
| 28 | #include "libavutil/thread.h" | 28 | #include "libavutil/thread.h" |
| 29 | #include "avcodec.h" | 29 | #include "avcodec.h" |
| 30 | #include "avcodec_internal.h" | ||
| 30 | #include "encode.h" | 31 | #include "encode.h" |
| 31 | #include "internal.h" | 32 | #include "internal.h" |
| 32 | #include "pthread_internal.h" | 33 | #include "pthread_internal.h" |
| @@ -110,7 +111,7 @@ static void * attribute_align_arg worker(void *v){ · 77 unmodified lines | |||
| 110 | pthread_mutex_unlock(&c->finished_task_mutex); | 111 | pthread_mutex_unlock(&c->finished_task_mutex); |
| 111 | } | 112 | } |
| 112 | end: | 113 | end: |
| 113 | avcodec_close(avctx); | 114 | ff_codec_close(avctx); |
| 114 | av_freep(&avctx); | 115 | av_freep(&avctx); |
| 115 | return NULL; | 116 | return NULL; |
| 116 | } | 117 | } |
| @@ -230,7 +231,7 @@ av_cold int ff_frame_thread_encoder_init(AVCodecContext *avctx) · 113 unmodified lines | |||
| 230 | 231 | ||
| 231 | return 0; | 232 | return 0; |
| 232 | fail: | 233 | fail: |
| 233 | avcodec_close(thread_avctx); | 234 | ff_codec_close(thread_avctx); |
| 234 | av_freep(&thread_avctx); | 235 | av_freep(&thread_avctx); |
| 235 | avctx->thread_count = i; | 236 | avctx->thread_count = i; |
| 236 | av_log(avctx, AV_LOG_ERROR, "ff_frame_thread_encoder_init failed\n"); | 237 | av_log(avctx, AV_LOG_ERROR, "ff_frame_thread_encoder_init failed\n"); |
| @@ -27,6 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include "config_components.h" | 27 | #include "config_components.h" |
| 28 | 28 | ||
| 29 | #include "avcodec.h" | 29 | #include "avcodec.h" |
| 30 | #include "avcodec_internal.h" | ||
| 30 | #include "codec_internal.h" | 31 | #include "codec_internal.h" |
| 31 | #include "libavutil/avassert.h" | 32 | #include "libavutil/avassert.h" |
| 32 | #include "libavutil/internal.h" | 33 | #include "libavutil/internal.h" |
| @@ -172,7 +173,7 @@ void avcodec_free_context(AVCodecContext **pavctx) · 139 unmodified lines | |||
| 172 | if (!avctx) | 173 | if (!avctx) |
| 173 | return; | 174 | return; |
| 174 | 175 | ||
| 175 | avcodec_close(avctx); | 176 | ff_codec_close(avctx); |
| 176 | 177 | ||
| 177 | av_freep(&avctx->extradata); | 178 | av_freep(&avctx->extradata); |
| 178 | av_freep(&avctx->subtitle_header); | 179 | av_freep(&avctx->subtitle_header); |
| @@ -52,6 +52,7 @@ · 51 unmodified lines | |||
| 52 | 52 | ||
| 53 | #define FF_API_AVFFT (LIBAVCODEC_VERSION_MAJOR < 62) | 53 | #define FF_API_AVFFT (LIBAVCODEC_VERSION_MAJOR < 62) |
| 54 | #define FF_API_FF_PROFILE_LEVEL (LIBAVCODEC_VERSION_MAJOR < 62) | 54 | #define FF_API_FF_PROFILE_LEVEL (LIBAVCODEC_VERSION_MAJOR < 62) |
| 55 | #define FF_API_AVCODEC_CLOSE (LIBAVCODEC_VERSION_MAJOR < 62) | ||
| 55 | 56 | ||
| 56 | // reminder to remove CrystalHD decoders on next major bump | 57 | // reminder to remove CrystalHD decoders on next major bump |
| 57 | #define FF_CODEC_CRYSTAL_HD (LIBAVCODEC_VERSION_MAJOR < 61) | 58 | #define FF_CODEC_CRYSTAL_HD (LIBAVCODEC_VERSION_MAJOR < 61) |