History

lavc: deprecate avcodec_close()

Its use has been discouraged since 2016, but now is no longer used in avformat, so there is no reason to keep it public.

Anton Khirnov committed 2 years ago

Commit 1cc24d71 parent ca18bb56 files · +21 −7Browse files

Unified · Split

6 files
  1. libavcodec/avcodec.c +9 −3
  2. libavcodec/avcodec.h +4 −1
  3. libavcodec/avcodec_internal.h +2 −0
  4. libavcodec/frame_thread_encoder.c +3 −2
  5. libavcodec/options.c +2 −1
  6. libavcodec/version_major.h +1 −0
libavcodec/avcodec.c+9−3
@@ -377,7 +377,7 @@ end: · 376 unmodified lines
377377
378378 return ret;
379379 free_and_end:
380− avcodec_close(avctx);
380+ ff_codec_close(avctx);
381381 goto end;
382382 }
383383
@@ -432,12 +432,12 @@ void avsubtitle_free(AVSubtitle *sub) · 48 unmodified lines
432432 memset(sub, 0, sizeof(*sub));
433433 }
434434
435−av_cold int avcodec_close(AVCodecContext *avctx)
435+av_cold void ff_codec_close(AVCodecContext *avctx)
436436 {
437437 int i;
438438
439439 if (!avctx)
440− return 0;
440+ return;
441441
442442 if (avcodec_is_open(avctx)) {
443443 AVCodecInternal *avci = avctx->internal;
@@ -497,9 +497,15 @@ av_cold int avcodec_close(AVCodecContext *avctx) · 53 unmodified lines
497497
498498 avctx->codec = NULL;
499499 avctx->active_thread_type = 0;
500+}
500501
502+#if FF_API_AVCODEC_CLOSE
503+int avcodec_close(AVCodecContext *avctx)
504+{
505+ ff_codec_close(avctx);
501506 return 0;
502507 }
508+#endif
503509
504510 static const char *unknown_if_null(const char *str)
505511 {
libavcodec/avcodec.h+4−1
@@ -2411,6 +2411,7 @@ int avcodec_parameters_to_context(AVCodecContext *codec, · 2410 unmodified lines
24112411 */
24122412 int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
24132413
2414+#if FF_API_AVCODEC_CLOSE
24142415 /**
24152416 * Close a given AVCodecContext and free all the data associated with it
24162417 * (but not the AVCodecContext itself).
@@ -2419,12 +2420,14 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **op · 2 unmodified lines
24192420 * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL
24202421 * codec. Subsequent calls will do nothing.
24212422 *
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
24232424 * codec context (either open or closed). Opening and closing a codec context
24242425 * multiple times is not supported anymore -- use multiple codec contexts
24252426 * instead.
24262427 */
2428+attribute_deprecated
24272429 int avcodec_close(AVCodecContext *avctx);
2430+#endif
24282431
24292432 /**
24302433 * Free all allocated data in the given subtitle struct.
libavcodec/avcodec_internal.h+2−0
@@ -56,4 +56,6 @@ void ff_encode_flush_buffers(struct AVCodecContext *avctx); · 55 unmodified lines
5656 struct AVCodecInternal *ff_decode_internal_alloc(void);
5757 struct AVCodecInternal *ff_encode_internal_alloc(void);
5858
59+void ff_codec_close(struct AVCodecContext *avctx);
60+
5961 #endif // AVCODEC_AVCODEC_INTERNAL_H
libavcodec/frame_thread_encoder.c+3−2
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "libavutil/opt.h"
2828 #include "libavutil/thread.h"
2929 #include "avcodec.h"
30+#include "avcodec_internal.h"
3031 #include "encode.h"
3132 #include "internal.h"
3233 #include "pthread_internal.h"
@@ -110,7 +111,7 @@ static void * attribute_align_arg worker(void *v){ · 77 unmodified lines
110111 pthread_mutex_unlock(&c->finished_task_mutex);
111112 }
112113 end:
113− avcodec_close(avctx);
114+ ff_codec_close(avctx);
114115 av_freep(&avctx);
115116 return NULL;
116117 }
@@ -230,7 +231,7 @@ av_cold int ff_frame_thread_encoder_init(AVCodecContext *avctx) · 113 unmodified lines
230231
231232 return 0;
232233 fail:
233− avcodec_close(thread_avctx);
234+ ff_codec_close(thread_avctx);
234235 av_freep(&thread_avctx);
235236 avctx->thread_count = i;
236237 av_log(avctx, AV_LOG_ERROR, "ff_frame_thread_encoder_init failed\n");
libavcodec/options.c+2−1
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "config_components.h"
2828
2929 #include "avcodec.h"
30+#include "avcodec_internal.h"
3031 #include "codec_internal.h"
3132 #include "libavutil/avassert.h"
3233 #include "libavutil/internal.h"
@@ -172,7 +173,7 @@ void avcodec_free_context(AVCodecContext **pavctx) · 139 unmodified lines
172173 if (!avctx)
173174 return;
174175
175− avcodec_close(avctx);
176+ ff_codec_close(avctx);
176177
177178 av_freep(&avctx->extradata);
178179 av_freep(&avctx->subtitle_header);
libavcodec/version_major.h+1−0
@@ -52,6 +52,7 @@ · 51 unmodified lines
5252
5353 #define FF_API_AVFFT (LIBAVCODEC_VERSION_MAJOR < 62)
5454 #define FF_API_FF_PROFILE_LEVEL (LIBAVCODEC_VERSION_MAJOR < 62)
55+#define FF_API_AVCODEC_CLOSE (LIBAVCODEC_VERSION_MAJOR < 62)
5556
5657 // reminder to remove CrystalHD decoders on next major bump
5758 #define FF_CODEC_CRYSTAL_HD (LIBAVCODEC_VERSION_MAJOR < 61)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t