[FFmpeg-cvslog] lavfi/transpose: add passthrough option

Stefano Sabatini git at videolan.org
Tue Oct 2 09:44:55 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Sun Sep 30 13:46:01 2012 +0200| [c053f486625419494856486c2866d550023f828c] | committer: Stefano Sabatini

lavfi/transpose: add passthrough option

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

 doc/filters.texi           |   19 +++++++++++++++++--
 libavfilter/version.h      |    2 +-
 libavfilter/vf_transpose.c |   36 +++++++++++++++++++++++++++---------
 3 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index e5774a1..69a8ee1 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3559,8 +3559,23 @@ l.r     l.L
 @end example
 @end table
 
-For values between 4-7 transposition is only done if the input video
-geometry is portrait and not landscape.
+For values between 4-7, the transposition is only done if the input
+video geometry is portrait and not landscape. These values are
+deprecated, the @code{passthrough} option should be used instead.
+
+ at item passthrough
+Do not apply the transposition if the input geometry matches the one
+specified by the specified value. It accepts the following values:
+ at table @samp
+ at item none
+Always apply transposition.
+ at item portrait
+Preserve portrait geometry (when @var{height} >= @var{width}).
+ at item landscape
+Preserve landscape geometry (when @var{width} >= @var{height}).
+ at end table
+
+Default value is @code{none}.
 @end table
 
 @section unsharp
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 0475bc4..212010b 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR  3
 #define LIBAVFILTER_VERSION_MINOR  19
-#define LIBAVFILTER_VERSION_MICRO 101
+#define LIBAVFILTER_VERSION_MICRO 102
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index 41ca062..2671c58 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -37,6 +37,12 @@
 #include "internal.h"
 #include "video.h"
 
+typedef enum {
+    TRANSPOSE_PT_TYPE_NONE,
+    TRANSPOSE_PT_TYPE_LANDSCAPE,
+    TRANSPOSE_PT_TYPE_PORTRAIT,
+} PassthroughType;
+
 typedef struct {
     const AVClass *class;
     int hsub, vsub;
@@ -47,7 +53,7 @@ typedef struct {
     /* 2    Rotate by 90 degrees counterclockwise.           */
     /* 3    Rotate by 90 degrees clockwise and vflip.        */
     int dir;
-    int passthrough; ///< landscape passthrough mode enabled
+    PassthroughType passthrough; ///< landscape passthrough mode enabled
 } TransContext;
 
 #define OFFSET(x) offsetof(TransContext, x)
@@ -55,6 +61,13 @@ typedef struct {
 
 static const AVOption transpose_options[] = {
     { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, {.i64=0},  0, 7, FLAGS },
+
+    { "passthrough", "do not apply transposition if the input matches the specified geometry",
+      OFFSET(passthrough), AV_OPT_TYPE_INT, {.i64=TRANSPOSE_PT_TYPE_NONE},  0, INT_MAX, FLAGS, "passthrough" },
+    { "none",      "always apply transposition",   0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_NONE},      INT_MIN, INT_MAX, FLAGS, "passthrough" },
+    { "portrait",  "preserve portrait geometry",   0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_PORTRAIT},  INT_MIN, INT_MAX, FLAGS, "passthrough" },
+    { "landscape", "preserve landscape geometry",  0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_LANDSCAPE}, INT_MIN, INT_MAX, FLAGS, "passthrough" },
+
     { NULL },
 };
 
@@ -63,7 +76,7 @@ AVFILTER_DEFINE_CLASS(transpose);
 static av_cold int init(AVFilterContext *ctx, const char *args)
 {
     TransContext *trans = ctx->priv;
-    const char *shorthand[] = { "dir", NULL };
+    const char *shorthand[] = { "dir", "passthrough", NULL };
 
     trans->class = &transpose_class;
     av_opt_set_defaults(trans);
@@ -106,15 +119,20 @@ static int config_props_output(AVFilterLink *outlink)
     const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[outlink->format];
 
     if (trans->dir&4) {
+        av_log(ctx, AV_LOG_WARNING,
+               "dir values greater than 3 are deprecated, use the passthrough option instead\n");
         trans->dir &= 3;
-        if (inlink->w >= inlink->h) {
-            trans->passthrough = 1;
+        trans->passthrough = TRANSPOSE_PT_TYPE_LANDSCAPE;
+    }
 
-            av_log(ctx, AV_LOG_VERBOSE,
-                   "w:%d h:%d -> w:%d h:%d (landscape passthrough mode)\n",
-                   inlink->w, inlink->h, outlink->w, outlink->h);
-            return 0;
-        }
+    if ((inlink->w >= inlink->h && trans->passthrough == TRANSPOSE_PT_TYPE_LANDSCAPE) ||
+        (inlink->w <= inlink->h && trans->passthrough == TRANSPOSE_PT_TYPE_PORTRAIT)) {
+        av_log(ctx, AV_LOG_VERBOSE,
+               "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
+               inlink->w, inlink->h, inlink->w, inlink->h);
+        return 0;
+    } else {
+        trans->passthrough = TRANSPOSE_PT_TYPE_NONE;
     }
 
     trans->hsub = av_pix_fmt_descriptors[inlink->format].log2_chroma_w;



More information about the ffmpeg-cvslog mailing list