[FFmpeg-cvslog] avfilter/vf_premultiply: add planes option

Paul B Mahol git at videolan.org
Sun Apr 23 19:23:22 EEST 2017


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Apr 23 18:19:40 2017 +0200| [710c97d5f6a880597701ea7b3ad56920cd0fb731] | committer: Paul B Mahol

avfilter/vf_premultiply: add planes option

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

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

 doc/filters.texi             |  8 ++++++++
 libavfilter/vf_premultiply.c | 13 ++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ac32995dea..4c733f016e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11077,6 +11077,14 @@ of second stream as alpha.
 
 Both streams must have same dimensions and same pixel format.
 
+The filter accepts the following option:
+
+ at table @option
+ at item planes
+Set which planes will be processed, unprocessed planes will be copied.
+By default value 0xf, all planes will be processed.
+ at end table
+
 @section prewitt
 Apply prewitt operator to input video stream.
 
diff --git a/libavfilter/vf_premultiply.c b/libavfilter/vf_premultiply.c
index e1b79ab779..8a5f9eac64 100644
--- a/libavfilter/vf_premultiply.c
+++ b/libavfilter/vf_premultiply.c
@@ -30,6 +30,7 @@
 typedef struct PreMultiplyContext {
     const AVClass *class;
     int width[4], height[4];
+    int linesize[4];
     int nb_planes;
     int planes;
     int half, depth, offset;
@@ -47,6 +48,7 @@ typedef struct PreMultiplyContext {
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
 static const AVOption premultiply_options[] = {
+    { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 0, 0xF, FLAGS },
     { NULL }
 };
 
@@ -269,6 +271,12 @@ static int process_frame(FFFrameSync *fs)
         }
 
         for (p = 0; p < s->nb_planes; p++) {
+            if (!((1 << p) & s->planes)) {
+                av_image_copy_plane(out->data[p], out->linesize[p], base->data[p], base->linesize[p],
+                                    s->linesize[p], s->height[p]);
+                continue;
+            }
+
             s->premultiply[p](base->data[p], alpha->data[0],
                               out->data[p],
                               base->linesize[p], alpha->linesize[0],
@@ -287,10 +295,13 @@ static int config_input(AVFilterLink *inlink)
     AVFilterContext *ctx = inlink->dst;
     PreMultiplyContext *s = ctx->priv;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-    int vsub, hsub;
+    int vsub, hsub, ret;
 
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
 
+    if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
+        return ret;
+
     hsub = desc->log2_chroma_w;
     vsub = desc->log2_chroma_h;
     s->height[1] = s->height[2] = AV_CEIL_RSHIFT(inlink->h, vsub);



More information about the ffmpeg-cvslog mailing list