aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2018-04-25 13:07:34 +0200
committerPaul B Mahol <onemda@gmail.com>2018-04-26 16:44:15 +0200
commit330215830ef94f4bf45fd8af0025b10f59a051a6 (patch)
tree06a45c49341842eedc23c94e04636c8db67fbe62
parenta5172dcab67fe83685d35bb6c2b0674070f2bde2 (diff)
downloadffmpeg-330215830ef94f4bf45fd8af0025b10f59a051a6.tar.gz
avfilter/vf_mix: clip output pixel values
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r--libavfilter/vf_mix.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c
index 23385dbb05..7644b7170a 100644
--- a/libavfilter/vf_mix.c
+++ b/libavfilter/vf_mix.c
@@ -44,6 +44,7 @@ typedef struct MixContext {
int nb_frames;
int depth;
+ int max;
int nb_planes;
int linesize[4];
int height[4];
@@ -137,7 +138,7 @@ static void mix_frames(MixContext *s, AVFrame **in, AVFrame *out)
val += src * s->weights[i];
}
- dst[x] = val * s->wfactor;
+ dst[x] = av_clip_uint8(val * s->wfactor);
}
dst += out->linesize[p];
@@ -157,7 +158,7 @@ static void mix_frames(MixContext *s, AVFrame **in, AVFrame *out)
val += src * s->weights[i];
}
- dst[x] = val * s->wfactor;
+ dst[x] = av_clip(val * s->wfactor, 0, s->max);
}
dst += out->linesize[p] / 2;
@@ -216,6 +217,7 @@ static int config_output(AVFilterLink *outlink)
return AVERROR_BUG;
s->nb_planes = av_pix_fmt_count_planes(outlink->format);
s->depth = s->desc->comp[0].depth;
+ s->max = (1 << s->depth) - 1;
if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
return ret;