forked from FFmpeg/FFmpeg
fftools/ffmpeg: stop setting InputStream fields from muxing/filtering code
Set InputStream.decoding_needed/discard/etc. only from ist_{filter,output},add() functions. Reduces the knowledge of InputStream internals in muxing/filtering code.
This commit is contained in:
parent
ae071c9e39
commit
ff92ecad2f
4 changed files with 15 additions and 14 deletions
|
@ -880,7 +880,7 @@ void ifile_close(InputFile **f);
|
||||||
int ifile_get_packet(InputFile *f, AVPacket **pkt);
|
int ifile_get_packet(InputFile *f, AVPacket **pkt);
|
||||||
|
|
||||||
void ist_output_add(InputStream *ist, OutputStream *ost);
|
void ist_output_add(InputStream *ist, OutputStream *ost);
|
||||||
void ist_filter_add(InputStream *ist, InputFilter *ifilter);
|
void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple);
|
||||||
|
|
||||||
/* iterate over all input streams in all input files;
|
/* iterate over all input streams in all input files;
|
||||||
* pass NULL to start iteration */
|
* pass NULL to start iteration */
|
||||||
|
|
|
@ -561,14 +561,25 @@ void ifile_close(InputFile **pf)
|
||||||
av_freep(pf);
|
av_freep(pf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ist_use(InputStream *ist, int decoding_needed)
|
||||||
|
{
|
||||||
|
ist->discard = 0;
|
||||||
|
ist->st->discard = ist->user_set_discard;
|
||||||
|
ist->decoding_needed |= decoding_needed;
|
||||||
|
}
|
||||||
|
|
||||||
void ist_output_add(InputStream *ist, OutputStream *ost)
|
void ist_output_add(InputStream *ist, OutputStream *ost)
|
||||||
{
|
{
|
||||||
|
ist_use(ist, ost->enc ? DECODING_FOR_OST : 0);
|
||||||
|
|
||||||
GROW_ARRAY(ist->outputs, ist->nb_outputs);
|
GROW_ARRAY(ist->outputs, ist->nb_outputs);
|
||||||
ist->outputs[ist->nb_outputs - 1] = ost;
|
ist->outputs[ist->nb_outputs - 1] = ost;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ist_filter_add(InputStream *ist, InputFilter *ifilter)
|
void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple)
|
||||||
{
|
{
|
||||||
|
ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER);
|
||||||
|
|
||||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||||
ist->filters[ist->nb_filters - 1] = ifilter;
|
ist->filters[ist->nb_filters - 1] = ifilter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||||
GROW_ARRAY(filtergraphs, nb_filtergraphs);
|
GROW_ARRAY(filtergraphs, nb_filtergraphs);
|
||||||
filtergraphs[nb_filtergraphs - 1] = fg;
|
filtergraphs[nb_filtergraphs - 1] = fg;
|
||||||
|
|
||||||
ist_filter_add(ist, ifilter);
|
ist_filter_add(ist, ifilter, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -303,10 +303,6 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||||
}
|
}
|
||||||
av_assert0(ist);
|
av_assert0(ist);
|
||||||
|
|
||||||
ist->discard = 0;
|
|
||||||
ist->decoding_needed |= DECODING_FOR_FILTER;
|
|
||||||
ist->st->discard = AVDISCARD_NONE;
|
|
||||||
|
|
||||||
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||||
ifilter->ist = ist;
|
ifilter->ist = ist;
|
||||||
ifilter->graph = fg;
|
ifilter->graph = fg;
|
||||||
|
@ -318,7 +314,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||||
if (!ifilter->frame_queue)
|
if (!ifilter->frame_queue)
|
||||||
report_and_exit(AVERROR(ENOMEM));
|
report_and_exit(AVERROR(ENOMEM));
|
||||||
|
|
||||||
ist_filter_add(ist, ifilter);
|
ist_filter_add(ist, ifilter, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_binary(const char *path, uint8_t **data, int *len)
|
static int read_binary(const char *path, uint8_t **data, int *len)
|
||||||
|
|
|
@ -1218,12 +1218,6 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ost->ist) {
|
if (ost->ist) {
|
||||||
ost->ist->discard = 0;
|
|
||||||
ost->ist->st->discard = ost->ist->user_set_discard;
|
|
||||||
|
|
||||||
if (ost->enc)
|
|
||||||
ost->ist->decoding_needed |= DECODING_FOR_OST;
|
|
||||||
|
|
||||||
if (ost->enc &&
|
if (ost->enc &&
|
||||||
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
(type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
|
||||||
ret = init_simple_filtergraph(ost->ist, ost);
|
ret = init_simple_filtergraph(ost->ist, ost);
|
||||||
|
|
Loading…
Add table
Reference in a new issue