aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-03-21 17:21:46 +0100
committerAnton Khirnov <anton@khirnov.net>2022-08-08 16:20:58 +0200
commitcc2b7f4625497cab303a0b5dd9f47d366a619a64 (patch)
treeee6bbe0a52c7e5cbecf26b535708a35de7ae6db2
parent9139ea4c8d1c1539f96c516b224922097d16a5b4 (diff)
downloadffmpeg-cc2b7f4625497cab303a0b5dd9f47d366a619a64.tar.gz
fftools/ffmpeg: store the input file index in InputFile
Use it to simplify some code and fix two off-by-one errors. Similar to what was previously done for OutputFile.
-rw-r--r--fftools/ffmpeg.h2
-rw-r--r--fftools/ffmpeg_opt.c9
2 files changed, 7 insertions, 4 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6b09846825..23b249780b 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -408,6 +408,8 @@ typedef struct InputStream {
} InputStream;
typedef struct InputFile {
+ int index;
+
AVFormatContext *ctx;
int eof_reached; /* true if eof reached */
int eagain; /* true if last read attempt returned EAGAIN */
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index bd3a34960c..25aa9aaff5 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1383,6 +1383,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
f = ALLOC_ARRAY_ELEM(input_files, nb_input_files);
f->ctx = ic;
+ f->index = nb_input_files - 1;
f->ist_index = nb_input_streams - ic->nb_streams;
f->start_time = o->start_time;
f->recording_time = o->recording_time;
@@ -1398,11 +1399,11 @@ static int open_input_file(OptionsContext *o, const char *filename)
f->readrate = o->readrate ? o->readrate : 0.0;
if (f->readrate < 0.0f) {
- av_log(NULL, AV_LOG_ERROR, "Option -readrate for Input #%d is %0.3f; it must be non-negative.\n", nb_input_files, f->readrate);
+ av_log(NULL, AV_LOG_ERROR, "Option -readrate for Input #%d is %0.3f; it must be non-negative.\n", f->index, f->readrate);
exit_program(1);
}
if (f->readrate && f->rate_emu) {
- av_log(NULL, AV_LOG_WARNING, "Both -readrate and -re set for Input #%d. Using -readrate %0.3f.\n", nb_input_files, f->readrate);
+ av_log(NULL, AV_LOG_WARNING, "Both -readrate and -re set for Input #%d. Using -readrate %0.3f.\n", f->index, f->readrate);
f->rate_emu = 0;
}
@@ -1435,7 +1436,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
if (!(option->flags & AV_OPT_FLAG_DECODING_PARAM)) {
av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
"input file #%d (%s) is not a decoding option.\n", e->key,
- option->help ? option->help : "", nb_input_files - 1,
+ option->help ? option->help : "", f->index,
filename);
exit_program(1);
}
@@ -1445,7 +1446,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
"likely reason is either wrong type (e.g. a video option with "
"no video streams) or that it is a private option of some decoder "
"which was not actually used for any stream.\n", e->key,
- option->help ? option->help : "", nb_input_files - 1, filename);
+ option->help ? option->help : "", f->index, filename);
}
av_dict_free(&unused_opts);