From patchwork Wed Mar 10 12:03:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 26304 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CCC7744B739 for ; Wed, 10 Mar 2021 14:03:53 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B290E68A8BD; Wed, 10 Mar 2021 14:03:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DEC6A68A5CC for ; Wed, 10 Mar 2021 14:03:44 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 753A2240692 for ; Wed, 10 Mar 2021 13:03:44 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id d28prFzzqlVU for ; Wed, 10 Mar 2021 13:03:44 +0100 (CET) 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 mail0.khirnov.net (Postfix) with ESMTPS id C1D52240693 for ; Wed, 10 Mar 2021 13:03:41 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 921643A039B; Wed, 10 Mar 2021 13:03:41 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Mar 2021 13:03:29 +0100 Message-Id: <20210310120332.27225-4-anton@khirnov.net> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310120332.27225-1-anton@khirnov.net> References: <20210310120332.27225-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/7] lavc: move decoder bsf init into decoder-specific code X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/decode.c | 8 +++++++- libavcodec/decode.h | 6 ------ libavcodec/utils.c | 6 ------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index e5a301ec58..d25b15e95a 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -184,7 +184,7 @@ static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt) return 0; } -int ff_decode_bsfs_init(AVCodecContext *avctx) +static int decode_bsfs_init(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; int ret; @@ -2010,6 +2010,8 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) int ff_decode_preinit(AVCodecContext *avctx) { + int ret = 0; + /* if the decoder init function was already called previously, * free the already allocated subtitle_header before overwriting it */ av_freep(&avctx->subtitle_header); @@ -2046,5 +2048,9 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->export_side_data |= AV_CODEC_EXPORT_DATA_MVS; } + ret = decode_bsfs_init(avctx); + if (ret < 0) + return ret; + return 0; } diff --git a/libavcodec/decode.h b/libavcodec/decode.h index a865fe954f..1467b1eb33 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -69,12 +69,6 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt); */ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame); -/** - * Called during avcodec_open2() to initialize avctx->internal->bsf. - * The bsf should be freed with av_bsf_free(). - */ -int ff_decode_bsfs_init(AVCodecContext *avctx); - /** * Make sure avctx.hw_frames_ctx is set. If it's not set, the function will * try to allocate it from hw_device_ctx. If that is not possible, an error diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 6d5aeb4eaf..918cb1b4d1 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -730,12 +730,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code goto free_and_end; } - if (av_codec_is_decoder(avctx->codec)) { - ret = ff_decode_bsfs_init(avctx); - if (ret < 0) - goto free_and_end; - } - if (HAVE_THREADS && !(avci->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) { ret = ff_thread_init(avctx);