diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-04-11 11:23:21 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-04-17 12:01:40 +0200 |
commit | 0c44db4646e42aae8054769f5c1976289c7d9bb3 (patch) | |
tree | cd4cd4edce1cb09f06baf976902dd5becea25e04 | |
parent | 4358d4d8e71bc5ff205f43daac8448fc4953c794 (diff) | |
download | ffmpeg-0c44db4646e42aae8054769f5c1976289c7d9bb3.tar.gz |
fftools/ffmpeg: drop unnecessary indirection
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.
-rw-r--r-- | fftools/ffmpeg.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 054a9ce88a..0ceb25fed0 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); |