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 B29CC462B6 for ; Wed, 14 Jun 2023 16:51:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B05DF68C4A2; Wed, 14 Jun 2023 19:50:09 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C043168C461 for ; Wed, 14 Jun 2023 19:50:02 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 8E5172404F5 for ; Wed, 14 Jun 2023 18:50:02 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 9LcflLnL_yjY for ; Wed, 14 Jun 2023 18:50:02 +0200 (CEST) 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 113902406CF for ; Wed, 14 Jun 2023 18:49:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 7058E3A0664 for ; Wed, 14 Jun 2023 18:49:47 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Jun 2023 18:48:54 +0200 Message-Id: <20230614164908.28712-7-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230614164908.28712-1-anton@khirnov.net> References: <20230614164908.28712-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/21] fftools/ffmpeg_hw: inline hwaccel_decode_init() into its caller 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: The function is now trivial and cannot fail, so all error handling in its caller can be removed. --- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_dec.c | 15 +-------------- fftools/ffmpeg_hw.c | 11 +---------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7189629ad4..aeecf92fe6 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -805,7 +805,7 @@ void hw_device_free_all(void); */ AVBufferRef *hw_device_for_filter(void); -int hwaccel_decode_init(AVCodecContext *avctx); +int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input); int dec_open(InputStream *ist); void dec_free(Decoder **pdec); diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 6582917a39..ca9fbb9bd8 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -538,7 +538,6 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat { InputStream *ist = s->opaque; const enum AVPixelFormat *p; - int ret; for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p); @@ -562,19 +561,7 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat } } if (config && config->device_type == ist->hwaccel_device_type) { - ret = hwaccel_decode_init(s); - if (ret < 0) { - if (ist->hwaccel_id == HWACCEL_GENERIC) { - av_log(NULL, AV_LOG_FATAL, - "%s hwaccel requested for input stream #%d:%d, " - "but cannot be initialized.\n", - av_hwdevice_get_type_name(config->device_type), - ist->file_index, ist->index); - return AV_PIX_FMT_NONE; - } - continue; - } - + ist->hwaccel_retrieve_data = hwaccel_retrieve_data; ist->hwaccel_pix_fmt = *p; break; } diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index 4a0b346fe1..46bc7e39c2 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -297,7 +297,7 @@ void hw_device_free_all(void) nb_hw_devices = 0; } -static int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input) +int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input) { InputStream *ist = avctx->opaque; AVFrame *output = NULL; @@ -339,15 +339,6 @@ fail: return err; } -int hwaccel_decode_init(AVCodecContext *avctx) -{ - InputStream *ist = avctx->opaque; - - ist->hwaccel_retrieve_data = &hwaccel_retrieve_data; - - return 0; -} - AVBufferRef *hw_device_for_filter(void) { // Pick the last hardware device if the user doesn't pick the device for -- 2.40.1 _______________________________________________ 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".