diff options
author | Martin Vignali <martin.vignali@gmail.com> | 2018-03-31 15:50:19 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2018-04-01 15:39:57 +0200 |
commit | 4152413dde1cf851c4556459e3e1b3a5669f3a5e (patch) | |
tree | 4853d83ce312cc6cc35d8c2e526877e04e15145f /libavfilter/avf_showvolume.c | |
parent | a1b91b0cc28ac9d7ca77f21a3010233edeee457c (diff) | |
download | ffmpeg-4152413dde1cf851c4556459e3e1b3a5669f3a5e.tar.gz |
avfilter/showvolume : move clear picture part to a func
and use it if fade == 0.
Diffstat (limited to 'libavfilter/avf_showvolume.c')
-rw-r--r-- | libavfilter/avf_showvolume.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c index 267020e163..92dfc24435 100644 --- a/libavfilter/avf_showvolume.c +++ b/libavfilter/avf_showvolume.c @@ -245,13 +245,24 @@ static void drawtext(AVFrame *pic, int x, int y, const char *txt, int o) } } +static void clear_picture(ShowVolumeContext *s, AVFilterLink *outlink) { + int i, j; + const uint32_t bg = (uint32_t)(s->bgopacity * 255) << 24; + + for (i = 0; i < outlink->h; i++) { + uint32_t *dst = (uint32_t *)(s->out->data[0] + i * s->out->linesize[0]); + for (j = 0; j < outlink->w; j++) + AV_WN32A(dst + j, bg); + } +} + static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowVolumeContext *s = ctx->priv; const int step = s->step; - int c, i, j, k; + int c, j, k; AVFrame *out; if (!s->out || s->out->width != outlink->w || @@ -262,18 +273,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) av_frame_free(&insamples); return AVERROR(ENOMEM); } - - for (i = 0; i < outlink->h; i++) { - uint32_t *dst = (uint32_t *)(s->out->data[0] + i * s->out->linesize[0]); - const uint32_t bg = (uint32_t)(s->bgopacity * 255) << 24; - - for (j = 0; j < outlink->w; j++) - AV_WN32A(dst + j, bg); - } + clear_picture(s, outlink); } s->out->pts = insamples->pts; - if (s->f < 1.) { + if ((s->f < 1.) && (s->f > 0.)) { for (j = 0; j < outlink->h; j++) { uint8_t *dst = s->out->data[0] + j * s->out->linesize[0]; const uint32_t alpha = s->bgopacity * 255; @@ -285,6 +289,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) dst[k * 4 + 3] = FFMAX(dst[k * 4 + 3] * s->f, alpha); } } + } else if (s->f == 0.) { + clear_picture(s, outlink); } if (s->orientation) { /* vertical */ |