fftools/ffmpeg: add InputStream.index
This allows to avoid access to the underlying AVStream in many places.
This commit is contained in:
parent
cad59cccaf
commit
6abb4a28ef
@ -539,7 +539,7 @@ OutputStream *ost_iter(OutputStream *prev)
|
|||||||
InputStream *ist_iter(InputStream *prev)
|
InputStream *ist_iter(InputStream *prev)
|
||||||
{
|
{
|
||||||
int if_idx = prev ? prev->file_index : 0;
|
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++) {
|
for (; if_idx < nb_input_files; if_idx++) {
|
||||||
InputFile *f = 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++) {
|
for (int j = 0; j < ist->nb_filters; j++) {
|
||||||
if (!filtergraph_is_simple(ist->filters[j]->graph)) {
|
if (!filtergraph_is_simple(ist->filters[j]->graph)) {
|
||||||
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s",
|
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);
|
ist->filters[j]->name);
|
||||||
if (nb_filtergraphs > 1)
|
if (nb_filtergraphs > 1)
|
||||||
av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
|
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",
|
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
|
||||||
ost->ist->file_index,
|
ost->ist->file_index,
|
||||||
ost->ist->st->index,
|
ost->ist->index,
|
||||||
ost->file_index,
|
ost->file_index,
|
||||||
ost->index);
|
ost->index);
|
||||||
if (ost->enc_ctx) {
|
if (ost->enc_ctx) {
|
||||||
|
@ -330,6 +330,8 @@ typedef struct InputStream {
|
|||||||
const AVClass *class;
|
const AVClass *class;
|
||||||
|
|
||||||
int file_index;
|
int file_index;
|
||||||
|
int index;
|
||||||
|
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
int discard; /* true if stream data should be discarded */
|
int discard; /* true if stream data should be discarded */
|
||||||
int user_set_discard;
|
int user_set_discard;
|
||||||
|
@ -475,7 +475,7 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
|
|||||||
update_benchmark(NULL);
|
update_benchmark(NULL);
|
||||||
ret = avcodec_receive_frame(dec, frame);
|
ret = avcodec_receive_frame(dec, frame);
|
||||||
update_benchmark("decode_%s %d.%d", type_desc,
|
update_benchmark("decode_%s %d.%d", type_desc,
|
||||||
ist->file_index, ist->st->index);
|
ist->file_index, ist->index);
|
||||||
|
|
||||||
if (ret == AVERROR(EAGAIN)) {
|
if (ret == AVERROR(EAGAIN)) {
|
||||||
av_assert0(pkt); // should never happen during flushing
|
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);
|
ret = video_frame_process(ist, frame);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_log(NULL, AV_LOG_FATAL, "Error while processing the decoded "
|
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);
|
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, "
|
"%s hwaccel requested for input stream #%d:%d, "
|
||||||
"but cannot be initialized.\n",
|
"but cannot be initialized.\n",
|
||||||
av_hwdevice_get_type_name(config->device_type),
|
av_hwdevice_get_type_name(config->device_type),
|
||||||
ist->file_index, ist->st->index);
|
ist->file_index, ist->index);
|
||||||
return AV_PIX_FMT_NONE;
|
return AV_PIX_FMT_NONE;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -1025,6 +1025,7 @@ static DemuxStream *demux_stream_alloc(Demuxer *d, AVStream *st)
|
|||||||
|
|
||||||
ds->ist.st = st;
|
ds->ist.st = st;
|
||||||
ds->ist.file_index = f->index;
|
ds->ist.file_index = f->index;
|
||||||
|
ds->ist.index = st->index;
|
||||||
ds->ist.class = &input_stream_class;
|
ds->ist.class = &input_stream_class;
|
||||||
|
|
||||||
snprintf(ds->log_name, sizeof(ds->log_name), "%cist#%d:%d/%s",
|
snprintf(ds->log_name, sizeof(ds->log_name), "%cist#%d:%d/%s",
|
||||||
|
@ -1073,7 +1073,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
|||||||
if (fr.num && fr.den)
|
if (fr.num && fr.den)
|
||||||
av_bprintf(&args, ":frame_rate=%d/%d", 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,
|
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,
|
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",
|
snprintf(name, sizeof(name), "trim_in_%d_%d",
|
||||||
ist->file_index, ist->st->index);
|
ist->file_index, ist->index);
|
||||||
if (copy_ts) {
|
if (copy_ts) {
|
||||||
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
|
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
|
||||||
if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
|
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
|
} else
|
||||||
av_bprintf(&args, ":channels=%d", ifp->ch_layout.nb_channels);
|
av_bprintf(&args, ":channels=%d", ifp->ch_layout.nb_channels);
|
||||||
snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
|
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,
|
if ((ret = avfilter_graph_create_filter(&ifilter->filter, abuffer_filt,
|
||||||
name, args.str, NULL,
|
name, args.str, NULL,
|
||||||
@ -1189,7 +1189,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
|||||||
last_filter = ifilter->filter;
|
last_filter = ifilter->filter;
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "trim for input stream %d:%d",
|
snprintf(name, sizeof(name), "trim for input stream %d:%d",
|
||||||
ist->file_index, ist->st->index);
|
ist->file_index, ist->index);
|
||||||
if (copy_ts) {
|
if (copy_ts) {
|
||||||
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
|
tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time;
|
||||||
if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE)
|
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)) {
|
ifp->type_src == AVMEDIA_TYPE_VIDEO)) {
|
||||||
av_log(NULL, AV_LOG_ERROR,
|
av_log(NULL, AV_LOG_ERROR,
|
||||||
"Cannot determine format of input stream %d:%d after EOF\n",
|
"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;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -792,7 +792,7 @@ static void new_stream_audio(Muxer *mux, const OptionsContext *o,
|
|||||||
ist = ost->ist;
|
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,
|
if (av_reallocp_array(&ost->audio_channels_map,
|
||||||
ost->audio_channels_mapped + 1,
|
ost->audio_channels_mapped + 1,
|
||||||
sizeof(*ost->audio_channels_map)
|
sizeof(*ost->audio_channels_map)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user