1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

fftools/ffmpeg: add InputStream.index

This allows to avoid access to the underlying AVStream in many places.
This commit is contained in:
Anton Khirnov 2023-05-19 09:53:57 +02:00
parent cad59cccaf
commit 6abb4a28ef
6 changed files with 15 additions and 12 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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",

View File

@ -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;
}
}

View File

@ -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)