X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Ff_streamselect.c;h=b3ae4bed62e189f24bb95d1fcc396ff72b427ab6;hb=c67d2a287502845baadf986a9c63e6117a25be3f;hp=923deb1a85486ed5d76cb6e66551453c5e1b34cb;hpb=409e684e79b6ee0c511292326f09b13fe230e58e;p=ffmpeg diff --git a/libavfilter/f_streamselect.c b/libavfilter/f_streamselect.c index 923deb1a854..b3ae4bed62e 100644 --- a/libavfilter/f_streamselect.c +++ b/libavfilter/f_streamselect.c @@ -21,6 +21,7 @@ #include "libavutil/opt.h" #include "avfilter.h" #include "audio.h" +#include "filters.h" #include "formats.h" #include "framesync.h" #include "internal.h" @@ -40,9 +41,10 @@ typedef struct StreamSelectContext { #define OFFSET(x) offsetof(StreamSelectContext, x) #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM +#define TFLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_RUNTIME_PARAM static const AVOption streamselect_options[] = { { "inputs", "number of input streams", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=2}, 2, INT_MAX, .flags=FLAGS }, - { "map", "input indexes to remap to outputs", OFFSET(map_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags=FLAGS }, + { "map", "input indexes to remap to outputs", OFFSET(map_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags=TFLAGS }, { NULL } }; @@ -53,7 +55,7 @@ static int process_frame(FFFrameSync *fs) AVFilterContext *ctx = fs->parent; StreamSelectContext *s = fs->opaque; AVFrame **in = s->frames; - int i, j, ret = 0; + int i, j, ret = 0, have_out = 0; for (i = 0; i < ctx->nb_inputs; i++) { if ((ret = ff_framesync_get_frame(&s->fs, i, &in[i], 0)) < 0) @@ -75,12 +77,15 @@ static int process_frame(FFFrameSync *fs) out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, ctx->outputs[i]->time_base); s->last_pts[j] = in[j]->pts; ret = ff_filter_frame(ctx->outputs[i], out); + have_out = 1; if (ret < 0) return ret; } } } + if (!have_out) + ff_filter_set_ready(ctx, 100); return ret; } @@ -290,6 +295,12 @@ static av_cold void uninit(AVFilterContext *ctx) av_freep(&s->map); av_freep(&s->frames); ff_framesync_uninit(&s->fs); + + for (int i = 0; i < ctx->nb_inputs; i++) + av_freep(&ctx->input_pads[i].name); + + for (int i = 0; i < ctx->nb_outputs; i++) + av_freep(&ctx->output_pads[i].name); } static int query_formats(AVFilterContext *ctx)