[FFmpeg-cvslog] avfilter/vf_mix: make setting weights more user friendly

Paul B Mahol git at videolan.org
Sun Apr 29 20:40:22 EEST 2018


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Apr 29 19:27:15 2018 +0200| [c0f2abcc8d2acfc95e675a05303db958c3866b03] | committer: Paul B Mahol

avfilter/vf_mix: make setting weights more user friendly

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c0f2abcc8d2acfc95e675a05303db958c3866b03
---

 doc/filters.texi     | 8 ++++++--
 libavfilter/vf_mix.c | 7 ++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 249d88265c..f31747ebf5 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11177,7 +11177,9 @@ The number of inputs. If unspecified, it defaults to 2.
 
 @item weights
 Specify weight of each input video stream as sequence.
-Each weight is separated by space.
+Each weight is separated by space. If number of weights
+is smaller than number of @var{frames} last specified
+weight will be used for all remaining unset weights.
 
 @item scale
 Specify scale, if it is set it will be multiplied with sum
@@ -15603,7 +15605,9 @@ The number of successive frames to mix. If unspecified, it defaults to 3.
 
 @item weights
 Specify weight of each input video frame.
-Each weight is separated by space.
+Each weight is separated by space. If number of weights is smaller than
+number of @var{frames} last specified weight will be used for all remaining
+unset weights.
 
 @item scale
 Specify scale, if it is set it will be multiplied with sum
diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c
index 9ae61c59d2..14e0f19e2d 100644
--- a/libavfilter/vf_mix.c
+++ b/libavfilter/vf_mix.c
@@ -74,7 +74,7 @@ static av_cold int init(AVFilterContext *ctx)
 {
     MixContext *s = ctx->priv;
     char *p, *arg, *saveptr = NULL;
-    int i, ret;
+    int i, ret, last;
 
     s->tmix = !strcmp(ctx->filter->name, "tmix");
 
@@ -110,6 +110,11 @@ static av_cold int init(AVFilterContext *ctx)
         p = NULL;
         sscanf(arg, "%f", &s->weights[i]);
         s->wfactor += s->weights[i];
+        last = i;
+    }
+    for (; i < s->nb_inputs; i++) {
+        s->weights[i] = s->weights[last];
+        s->wfactor += s->weights[i];
     }
     if (s->scale == 0) {
         s->wfactor = 1 / s->wfactor;



More information about the ffmpeg-cvslog mailing list