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 8D1A145E69 for ; Thu, 13 Apr 2023 14:18:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 93B0668BECF; Thu, 13 Apr 2023 17:16:12 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B629168BE3D for ; Thu, 13 Apr 2023 17:15:59 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9DBBE2404F5 for ; Thu, 13 Apr 2023 16:15:57 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id aNab4FFy4iq9 for ; Thu, 13 Apr 2023 16:15:57 +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 50F7A2406CB for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1A6703A0586 for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 16:12:05 +0200 Message-Id: <20230413141223.17245-7-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413141223.17245-1-anton@khirnov.net> References: <20230413141223.17245-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/25] fftools/ffmpeg: drop unnecessary indirection 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: init_input_stream() can print log messages directly, there is no need to ship them to the caller. Also, log errors to the InputStream and avoid duplicate information in the message. --- fftools/ffmpeg.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 4d4cbf6aaf..57bdc12473 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1907,15 +1907,16 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat return *p; } -static int init_input_stream(InputStream *ist, char *error, int error_len) +static int init_input_stream(InputStream *ist) { int ret; if (ist->decoding_needed) { const AVCodec *codec = ist->dec; if (!codec) { - snprintf(error, error_len, "Decoder (codec %s) not found for input stream #%d:%d", - avcodec_get_name(ist->dec_ctx->codec_id), ist->file_index, ist->st->index); + av_log(ist, AV_LOG_ERROR, + "Decoding requested, but no decoder found for: %s\n", + avcodec_get_name(ist->dec_ctx->codec_id)); return AVERROR(EINVAL); } @@ -1941,9 +1942,9 @@ static int init_input_stream(InputStream *ist, char *error, int error_len) ret = hw_device_setup_for_decode(ist); if (ret < 0) { - snprintf(error, error_len, "Device setup failed for " - "decoder on input stream #%d:%d : %s", - ist->file_index, ist->st->index, av_err2str(ret)); + av_log(ist, AV_LOG_ERROR, + "Hardware device setup failed for decoder: %s\n", + av_err2str(ret)); return ret; } @@ -1951,10 +1952,8 @@ static int init_input_stream(InputStream *ist, char *error, int error_len) if (ret == AVERROR_EXPERIMENTAL) abort_codec_experimental(codec, 0); - snprintf(error, error_len, - "Error while opening decoder for input stream " - "#%d:%d : %s", - ist->file_index, ist->st->index, av_err2str(ret)); + av_log(ist, AV_LOG_ERROR, "Error while opening decoder: %s\n", + av_err2str(ret)); return ret; } assert_avoptions(ist->decoder_opts); @@ -1983,7 +1982,6 @@ static int init_output_stream_nofilter(OutputStream *ost) static int transcode_init(void) { int ret = 0; - char error[1024] = {0}; /* init framerate emulation */ for (int i = 0; i < nb_input_files; i++) { @@ -1995,7 +1993,7 @@ static int transcode_init(void) /* init input streams */ for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) - if ((ret = init_input_stream(ist, error, sizeof(error))) < 0) + if ((ret = init_input_stream(ist)) < 0) goto dump_format; /* @@ -2105,10 +2103,8 @@ static int transcode_init(void) av_log(NULL, AV_LOG_INFO, "\n"); } - if (ret) { - av_log(NULL, AV_LOG_ERROR, "%s\n", error); + if (ret) return ret; - } atomic_store(&transcode_init_done, 1); -- 2.39.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".