From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 7492C47B6C for ; Thu, 1 Feb 2024 08:30:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E5B0C68D060; Thu, 1 Feb 2024 10:29:59 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 675EF68CD11 for ; Thu, 1 Feb 2024 10:29:49 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=lOfECq/T; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 0636A115 for ; Thu, 1 Feb 2024 09:29:49 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id CyeOpJJK1DvG for ; Thu, 1 Feb 2024 09:29:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1706776187; bh=RcWM/Jow98Tk49pmkYjQCHB4+Fd0Fc+um5iAdWhavLo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lOfECq/TmwbBw2l7Iwu3oAD53Jaw+ZLYhJO3DOm/cs2M0F/Wa2JVay5GO9KFDEzeQ pX/6vVeoJsZxMvUrtDleHLBVenHKcQQFIYiiZVN0d4SmfhVDOipduQA7FmuudvPllo /2T9VZkrmEbCHzjlcn3lchofaJnx5XPNdzoHljj5IaBebWhgWv2JDPAWE3CrbEqnjQ CghSMcEhUrlYHqCueAwthivmKUcgv7knUAdSg2VtECZ/+ZaL/xiJrKj6e7Qgi69SSp sSZ2B28UOaj8HdaOFcvwjkwQxC2WS17IlQSN2mi0sZhOcYjP7hO+t5amJpkbWjjP+q L7leKQ1Fxt2hg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 67669DFD for ; Thu, 1 Feb 2024 09:29:47 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2D9793A0A68 for ; Thu, 1 Feb 2024 09:29:41 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 1 Feb 2024 09:29:38 +0100 Message-ID: <20240201082938.16687-4-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240201082938.16687-1-anton@khirnov.net> References: <20240201082938.16687-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] lavc: deprecate avcodec_close() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Its use has been discouraged since 2016, but now is no longer used in avformat, so there is no reason to keep it public. --- libavcodec/avcodec.c | 12 +++++++++--- libavcodec/avcodec.h | 5 ++++- libavcodec/avcodec_internal.h | 2 ++ libavcodec/frame_thread_encoder.c | 5 +++-- libavcodec/options.c | 3 ++- libavcodec/version_major.h | 1 + 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index a6c8629f6c..b6d27ada21 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -377,7 +377,7 @@ end: return ret; free_and_end: - avcodec_close(avctx); + ff_codec_close(avctx); goto end; } @@ -432,12 +432,12 @@ void avsubtitle_free(AVSubtitle *sub) memset(sub, 0, sizeof(*sub)); } -av_cold int avcodec_close(AVCodecContext *avctx) +av_cold void ff_codec_close(AVCodecContext *avctx) { int i; if (!avctx) - return 0; + return; if (avcodec_is_open(avctx)) { AVCodecInternal *avci = avctx->internal; @@ -497,9 +497,15 @@ av_cold int avcodec_close(AVCodecContext *avctx) avctx->codec = NULL; avctx->active_thread_type = 0; +} +#if FF_API_AVCODEC_CLOSE +int avcodec_close(AVCodecContext *avctx) +{ + ff_codec_close(avctx); return 0; } +#endif static const char *unknown_if_null(const char *str) { diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7fb44e28f4..0018ccbb0c 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2411,6 +2411,7 @@ int avcodec_parameters_to_context(AVCodecContext *codec, */ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); +#if FF_API_AVCODEC_CLOSE /** * Close a given AVCodecContext and free all the data associated with it * (but not the AVCodecContext itself). @@ -2419,12 +2420,14 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **op * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL * codec. Subsequent calls will do nothing. * - * @note Do not use this function. Use avcodec_free_context() to destroy a + * @deprecated Do not use this function. Use avcodec_free_context() to destroy a * codec context (either open or closed). Opening and closing a codec context * multiple times is not supported anymore -- use multiple codec contexts * instead. */ +attribute_deprecated int avcodec_close(AVCodecContext *avctx); +#endif /** * Free all allocated data in the given subtitle struct. diff --git a/libavcodec/avcodec_internal.h b/libavcodec/avcodec_internal.h index 9b93ff3d81..4d1cb3a314 100644 --- a/libavcodec/avcodec_internal.h +++ b/libavcodec/avcodec_internal.h @@ -56,4 +56,6 @@ void ff_encode_flush_buffers(struct AVCodecContext *avctx); struct AVCodecInternal *ff_decode_internal_alloc(void); struct AVCodecInternal *ff_encode_internal_alloc(void); +void ff_codec_close(struct AVCodecContext *avctx); + #endif // AVCODEC_AVCODEC_INTERNAL_H diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c index 62d9580ad4..cda5158117 100644 --- a/libavcodec/frame_thread_encoder.c +++ b/libavcodec/frame_thread_encoder.c @@ -27,6 +27,7 @@ #include "libavutil/opt.h" #include "libavutil/thread.h" #include "avcodec.h" +#include "avcodec_internal.h" #include "encode.h" #include "internal.h" #include "pthread_internal.h" @@ -110,7 +111,7 @@ static void * attribute_align_arg worker(void *v){ pthread_mutex_unlock(&c->finished_task_mutex); } end: - avcodec_close(avctx); + ff_codec_close(avctx); av_freep(&avctx); return NULL; } @@ -230,7 +231,7 @@ av_cold int ff_frame_thread_encoder_init(AVCodecContext *avctx) return 0; fail: - avcodec_close(thread_avctx); + ff_codec_close(thread_avctx); av_freep(&thread_avctx); avctx->thread_count = i; av_log(avctx, AV_LOG_ERROR, "ff_frame_thread_encoder_init failed\n"); diff --git a/libavcodec/options.c b/libavcodec/options.c index a9b35ee1c3..05a355fb45 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -27,6 +27,7 @@ #include "config_components.h" #include "avcodec.h" +#include "avcodec_internal.h" #include "codec_internal.h" #include "libavutil/avassert.h" #include "libavutil/internal.h" @@ -172,7 +173,7 @@ void avcodec_free_context(AVCodecContext **pavctx) if (!avctx) return; - avcodec_close(avctx); + ff_codec_close(avctx); av_freep(&avctx->extradata); av_freep(&avctx->subtitle_header); diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h index b9164fe5c6..45209c0a4f 100644 --- a/libavcodec/version_major.h +++ b/libavcodec/version_major.h @@ -52,6 +52,7 @@ #define FF_API_AVFFT (LIBAVCODEC_VERSION_MAJOR < 62) #define FF_API_FF_PROFILE_LEVEL (LIBAVCODEC_VERSION_MAJOR < 62) +#define FF_API_AVCODEC_CLOSE (LIBAVCODEC_VERSION_MAJOR < 62) // reminder to remove CrystalHD decoders on next major bump #define FF_CODEC_CRYSTAL_HD (LIBAVCODEC_VERSION_MAJOR < 61) -- 2.42.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".