From 3e0b29ccd075039d4494cafd4738bdf8322068b0 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 16 Oct 2012 23:50:06 +0200 Subject: ffmpeg: Make video filter graph reinit user selectable Signed-off-by: Michael Niedermayer --- ffmpeg.c | 5 +++-- ffmpeg.h | 4 ++++ ffmpeg_opt.c | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 97a1e4dff5..e69eb89311 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1610,12 +1610,13 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) ist->resample_height = decoded_frame->height; ist->resample_pix_fmt = decoded_frame->format; - for (i = 0; i < nb_filtergraphs; i++) - if (ist_in_filtergraph(filtergraphs[i], ist) && + for (i = 0; i < nb_filtergraphs; i++) { + if (ist_in_filtergraph(filtergraphs[i], ist) && ist->reinit_filters && configure_filtergraph(filtergraphs[i]) < 0) { av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n"); exit(1); } + } } frame_sample_aspect= av_opt_ptr(avcodec_get_frame_class(), decoded_frame, "sample_aspect_ratio"); diff --git a/ffmpeg.h b/ffmpeg.h index e1b223fc02..292670a59f 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -161,6 +161,8 @@ typedef struct OptionsContext { int nb_copy_prior_start; SpecifierOpt *filters; int nb_filters; + SpecifierOpt *reinit_filters; + int nb_reinit_filters; SpecifierOpt *fix_sub_duration; int nb_fix_sub_duration; SpecifierOpt *pass; @@ -253,6 +255,8 @@ typedef struct InputStream { * currently video and audio only */ InputFilter **filters; int nb_filters; + + int reinit_filters; } InputStream; typedef struct InputFile { diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index fefb785945..1d0cff20d7 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -579,6 +579,9 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) ist->dec = choose_decoder(o, ic, st); + ist->reinit_filters = -1; + MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st); + switch (dec->codec_type) { case AVMEDIA_TYPE_VIDEO: if(!ist->dec) @@ -2341,6 +2344,8 @@ const OptionDef options[] = { "set profile", "profile" }, { "filter", HAS_ARG | OPT_STRING | OPT_SPEC, { .off = OFFSET(filters) }, "set stream filterchain", "filter_list" }, + { "reinit_filter", HAS_ARG | OPT_INT | OPT_SPEC, { .off = OFFSET(reinit_filters) }, + "reinit filtergraph on input parameter changes", "" }, { "filter_complex", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex }, "create a complex filtergraph", "graph_description" }, { "stats", OPT_BOOL, { &print_stats }, -- cgit v1.2.3