mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
fftools/ffmpeg: return error codes from ist_*_add()
Will be useful in future commits.
This commit is contained in:
parent
ede6794d6a
commit
dfa29ba955
@ -879,8 +879,8 @@ void ifile_close(InputFile **f);
|
||||
*/
|
||||
int ifile_get_packet(InputFile *f, AVPacket **pkt);
|
||||
|
||||
void ist_output_add(InputStream *ist, OutputStream *ost);
|
||||
void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple);
|
||||
int ist_output_add(InputStream *ist, OutputStream *ost);
|
||||
int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple);
|
||||
|
||||
/**
|
||||
* Find an unused input stream of given type.
|
||||
|
@ -844,7 +844,7 @@ void ifile_close(InputFile **pf)
|
||||
av_freep(pf);
|
||||
}
|
||||
|
||||
static void ist_use(InputStream *ist, int decoding_needed)
|
||||
static int ist_use(InputStream *ist, int decoding_needed)
|
||||
{
|
||||
DemuxStream *ds = ds_from_ist(ist);
|
||||
|
||||
@ -856,23 +856,33 @@ static void ist_use(InputStream *ist, int decoding_needed)
|
||||
if (decoding_needed && !avcodec_is_open(ist->dec_ctx)) {
|
||||
int ret = dec_open(ist);
|
||||
if (ret < 0)
|
||||
report_and_exit(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ist_output_add(InputStream *ist, OutputStream *ost)
|
||||
{
|
||||
ist_use(ist, ost->enc ? DECODING_FOR_OST : 0);
|
||||
|
||||
GROW_ARRAY(ist->outputs, ist->nb_outputs);
|
||||
ist->outputs[ist->nb_outputs - 1] = ost;
|
||||
}
|
||||
|
||||
void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple)
|
||||
int ist_output_add(InputStream *ist, OutputStream *ost)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER);
|
||||
ret = ist_use(ist, ost->enc ? DECODING_FOR_OST : 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
GROW_ARRAY(ist->outputs, ist->nb_outputs);
|
||||
ist->outputs[ist->nb_outputs - 1] = ost;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = ifilter;
|
||||
@ -880,7 +890,9 @@ void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple)
|
||||
// initialize fallback parameters for filtering
|
||||
ret = ifilter_parameters_from_dec(ifilter, ist->dec_ctx);
|
||||
if (ret < 0)
|
||||
report_and_exit(ret);
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream *st,
|
||||
|
@ -334,6 +334,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
FilterGraph *fg;
|
||||
OutputFilter *ofilter;
|
||||
InputFilter *ifilter;
|
||||
int ret;
|
||||
|
||||
fg = fg_create(NULL);
|
||||
if (!fg)
|
||||
@ -347,7 +348,9 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
ifilter = ifilter_alloc(fg);
|
||||
ifilter->ist = ist;
|
||||
|
||||
ist_filter_add(ist, ifilter, 1);
|
||||
ret = ist_filter_add(ist, ifilter, 1);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -375,7 +378,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
InputStream *ist = NULL;
|
||||
enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx);
|
||||
InputFilter *ifilter;
|
||||
int i;
|
||||
int i, ret;
|
||||
|
||||
// TODO: support other filter types
|
||||
if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) {
|
||||
@ -435,7 +438,13 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
ifilter->type = ist->st->codecpar->codec_type;
|
||||
ifilter->name = describe_filter_link(fg, in, 1);
|
||||
|
||||
ist_filter_add(ist, ifilter, 0);
|
||||
ret = ist_filter_add(ist, ifilter, 0);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Error binding an input stream to complex filtergraph input %s.\n",
|
||||
in->name ? in->name : "");
|
||||
exit_program(1);
|
||||
}
|
||||
}
|
||||
|
||||
static int read_binary(const char *path, uint8_t **data, int *len)
|
||||
|
@ -1225,8 +1225,14 @@ static OutputStream *ost_add(Muxer *mux, const OptionsContext *o,
|
||||
"Error initializing a simple filtergraph\n");
|
||||
exit_program(1);
|
||||
}
|
||||
} else
|
||||
ist_output_add(ost->ist, ost);
|
||||
} else {
|
||||
ret = ist_output_add(ost->ist, ost);
|
||||
if (ret < 0) {
|
||||
av_log(ost, AV_LOG_ERROR,
|
||||
"Error binding an input stream\n");
|
||||
exit_program(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ost->ist && !ost->enc) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user