[FFmpeg-cvslog] fftools/ffmpeg: add InputStream.index
Anton Khirnov
git at videolan.org
Sun May 28 11:52:46 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri May 19 09:53:57 2023 +0200| [6abb4a28ef8309ff49cea2b81d3a8e8f38fbc6f7] | committer: Anton Khirnov
fftools/ffmpeg: add InputStream.index
This allows to avoid access to the underlying AVStream in many places.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6abb4a28ef8309ff49cea2b81d3a8e8f38fbc6f7
---
fftools/ffmpeg.c | 6 +++---
fftools/ffmpeg.h | 2 ++
fftools/ffmpeg_dec.c | 6 +++---
fftools/ffmpeg_demux.c | 1 +
fftools/ffmpeg_filter.c | 10 +++++-----
fftools/ffmpeg_mux_init.c | 2 +-
6 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 1fc13b3e29..0539a45856 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -539,7 +539,7 @@ OutputStream *ost_iter(OutputStream *prev)
InputStream *ist_iter(InputStream *prev)
{
int if_idx = prev ? prev->file_index : 0;
- int ist_idx = prev ? prev->st->index + 1 : 0;
+ int ist_idx = prev ? prev->index + 1 : 0;
for (; if_idx < nb_input_files; if_idx++) {
InputFile *f = input_files[if_idx];
@@ -937,7 +937,7 @@ static void print_stream_maps(void)
for (int j = 0; j < ist->nb_filters; j++) {
if (!filtergraph_is_simple(ist->filters[j]->graph)) {
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s",
- ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?",
+ ist->file_index, ist->index, ist->dec ? ist->dec->name : "?",
ist->filters[j]->name);
if (nb_filtergraphs > 1)
av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
@@ -967,7 +967,7 @@ static void print_stream_maps(void)
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
ost->ist->file_index,
- ost->ist->st->index,
+ ost->ist->index,
ost->file_index,
ost->index);
if (ost->enc_ctx) {
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index d9cac95710..95334825ef 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -330,6 +330,8 @@ typedef struct InputStream {
const AVClass *class;
int file_index;
+ int index;
+
AVStream *st;
int discard; /* true if stream data should be discarded */
int user_set_discard;
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index b750c83806..c89630512a 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -475,7 +475,7 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
update_benchmark(NULL);
ret = avcodec_receive_frame(dec, frame);
update_benchmark("decode_%s %d.%d", type_desc,
- ist->file_index, ist->st->index);
+ ist->file_index, ist->index);
if (ret == AVERROR(EAGAIN)) {
av_assert0(pkt); // should never happen during flushing
@@ -533,7 +533,7 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
ret = video_frame_process(ist, frame);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL, "Error while processing the decoded "
- "data for stream #%d:%d\n", ist->file_index, ist->st->index);
+ "data for stream #%d:%d\n", ist->file_index, ist->index);
exit_program(1);
}
}
@@ -582,7 +582,7 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat
"%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->st->index);
+ ist->file_index, ist->index);
return AV_PIX_FMT_NONE;
}
continue;
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index e02bdc3b96..828a1182f0 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1025,6 +1025,7 @@ static DemuxStream *demux_stream_alloc(Demuxer *d, AVStream *st)
ds->ist.st = st;
ds->ist.file_index = f->index;
+ ds->ist.index = st->index;
ds->ist.class = &input_stream_class;
snprintf(ds->log_name, sizeof(ds->log_name), "%cist#%d:%d/%s",
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 640ecec067..f37b867b31 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1073,7 +1073,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
if (fr.num && fr.den)
av_bprintf(&args, ":frame_rate=%d/%d", fr.num, fr.den);
snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
- ist->file_index, ist->st->index);
+ ist->file_index, ist->index);
if ((ret = avfilter_graph_create_filter(&ifilter->filter, buffer_filt, name,
@@ -1127,7 +1127,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
}
snprintf(name, sizeof(name), "trim_in_%d_%d",
- ist->file_index, ist->st->index);
+ ist->file_index, ist->index);
if (copy_ts) {
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
@@ -1180,7 +1180,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
} else
av_bprintf(&args, ":channels=%d", ifp->ch_layout.nb_channels);
snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
- ist->file_index, ist->st->index);
+ ist->file_index, ist->index);
if ((ret = avfilter_graph_create_filter(&ifilter->filter, abuffer_filt,
name, args.str, NULL,
@@ -1189,7 +1189,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
last_filter = ifilter->filter;
snprintf(name, sizeof(name), "trim for input stream %d:%d",
- ist->file_index, ist->st->index);
+ ist->file_index, ist->index);
if (copy_ts) {
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
@@ -1574,7 +1574,7 @@ int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb)
ifp->type_src == AVMEDIA_TYPE_VIDEO)) {
av_log(NULL, AV_LOG_ERROR,
"Cannot determine format of input stream %d:%d after EOF\n",
- ifp->ist->file_index, ifp->ist->st->index);
+ ifp->ist->file_index, ifp->ist->index);
return AVERROR_INVALIDDATA;
}
}
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 56f9d1215c..dc33d225df 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -792,7 +792,7 @@ static void new_stream_audio(Muxer *mux, const OptionsContext *o,
ist = ost->ist;
}
- if (!ist || (ist->file_index == map->file_idx && ist->st->index == map->stream_idx)) {
+ if (!ist || (ist->file_index == map->file_idx && ist->index == map->stream_idx)) {
if (av_reallocp_array(&ost->audio_channels_map,
ost->audio_channels_mapped + 1,
sizeof(*ost->audio_channels_map)
More information about the ffmpeg-cvslog
mailing list