[FFmpeg-cvslog] Revert "vf_interlace: deprecate lowpass option"

Vittorio Giovara git at videolan.org
Fri Aug 1 16:44:52 CEST 2014


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Wed Jul 30 21:12:14 2014 +0100| [52269f48e835a52023656f8330262ae70e6061c4] | committer: Vittorio Giovara

Revert "vf_interlace: deprecate lowpass option"

This reverts commit 35b05c5184fb3aa1191e2d1e7f1cae1e11f344a4.
A warning is introduced in case this option is used.

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

 doc/filters.texi           |    7 +++--
 libavfilter/version.h      |    3 --
 libavfilter/vf_interlace.c |   69 ++++++++++++++++++++++----------------------
 3 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5f9d1f8..28e3292 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1600,8 +1600,7 @@ A floating point number which specifies chroma temporal strength. It defaults to
 
 Simple interlacing filter from progressive contents. This interleaves upper (or
 lower) lines from odd frames with lower (or upper) lines from even frames,
-halving the frame rate and preserving image height. A vertical lowpass filter
-is always applied in order to avoid twitter effects and reduce moiré patterns.
+halving the frame rate and preserving image height.
 
 @example
    Original        Original             New Frame
@@ -1621,6 +1620,10 @@ It accepts the following optional parameters:
 @item scan
 This determines whether the interlaced frame is taken from the even
 (tff - default) or odd (bff) lines of the progressive frame.
+
+ at item lowpass
+Enable (default) or disable the vertical lowpass filter to avoid twitter
+interlacing and reduce moire patterns.
 @end table
 
 @section lut, lutrgb, lutyuv
diff --git a/libavfilter/version.h b/libavfilter/version.h
index de64b8b..d16f666 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -71,8 +71,5 @@
 #ifndef FF_API_NOCONST_GET_NAME
 #define FF_API_NOCONST_GET_NAME             (LIBAVFILTER_VERSION_MAJOR < 5)
 #endif
-#ifndef FF_API_INTERLACE_LOWPASS_SET
-#define FF_API_INTERLACE_LOWPASS_SET        (LIBAVFILTER_VERSION_MAJOR < 5)
-#endif
 
 #endif /* AVFILTER_VERSION_H */
diff --git a/libavfilter/vf_interlace.c b/libavfilter/vf_interlace.c
index fa3415d..c534b0b 100644
--- a/libavfilter/vf_interlace.c
+++ b/libavfilter/vf_interlace.c
@@ -29,7 +29,6 @@
 #include "formats.h"
 #include "avfilter.h"
 #include "internal.h"
-#include "version.h"
 #include "video.h"
 
 enum ScanMode {
@@ -45,9 +44,7 @@ enum FieldType {
 typedef struct InterlaceContext {
     const AVClass *class;
     enum ScanMode scan;    // top or bottom field first scanning
-#if FF_API_INTERLACE_LOWPASS_SET
     int lowpass;           // enable or disable low pass filterning
-#endif
     AVFrame *cur, *next;   // the two frames from which the new one is obtained
     int got_output;        // signal an output frame is reday to request_frame()
 } InterlaceContext;
@@ -61,10 +58,8 @@ static const AVOption options[] = {
         AV_OPT_TYPE_CONST, {.i64 = MODE_TFF }, INT_MIN, INT_MAX, .flags = V, .unit = "scan" },
     { "bff", "bottom field first", 0,
         AV_OPT_TYPE_CONST, {.i64 = MODE_BFF }, INT_MIN, INT_MAX, .flags = V, .unit = "scan" },
-#if FF_API_INTERLACE_LOWPASS_SET
-    { "lowpass", "(deprecated, this option is always set)", OFFSET(lowpass),
+    { "lowpass", "enable vertical low-pass filter", OFFSET(lowpass),
         AV_OPT_TYPE_INT,   {.i64 = 1 },        0, 1, .flags = V },
-#endif
     { NULL }
 };
 
@@ -105,15 +100,15 @@ static int config_out_props(AVFilterLink *outlink)
     AVFilterLink *inlink = outlink->src->inputs[0];
     InterlaceContext *s = ctx->priv;
 
-#if FF_API_INTERLACE_LOWPASS_SET
-    if (!s->lowpass)
-        av_log(ctx, AV_LOG_WARNING, "This option is deprecated and always set.\n");
-#endif
-
     if (inlink->h < 2) {
         av_log(ctx, AV_LOG_ERROR, "input video height is too small\n");
         return AVERROR_INVALIDDATA;
     }
+
+    if (!s->lowpass)
+        av_log(ctx, AV_LOG_WARNING, "***warning*** Lowpass filter is disabled, "
+               "the resulting video will be aliased rather than interlaced.\n");
+
     // same input size
     outlink->w = inlink->w;
     outlink->h = inlink->h;
@@ -121,14 +116,15 @@ static int config_out_props(AVFilterLink *outlink)
     // half framerate
     outlink->time_base.num *= 2;
 
-    av_log(ctx, AV_LOG_VERBOSE, "%s interlacing\n",
-           s->scan == MODE_TFF ? "tff" : "bff");
+    av_log(ctx, AV_LOG_VERBOSE, "%s interlacing %s lowpass filter\n",
+           s->scan == MODE_TFF ? "tff" : "bff", (s->lowpass) ? "with" : "without");
 
     return 0;
 }
 
 static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame,
-                               AVFilterLink *inlink, enum FieldType field_type)
+                               AVFilterLink *inlink, enum FieldType field_type,
+                               int lowpass)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
     int vsub = desc->log2_chroma_h;
@@ -139,8 +135,6 @@ static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame,
         int linesize = av_image_get_linesize(inlink->format, inlink->w, plane);
         uint8_t *dstp = dst_frame->data[plane];
         const uint8_t *srcp = src_frame->data[plane];
-        int srcp_linesize;
-        int dstp_linesize;
 
         av_assert0(linesize >= 0);
 
@@ -149,24 +143,29 @@ static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame,
             srcp += src_frame->linesize[plane];
         if (field_type == FIELD_LOWER)
             dstp += dst_frame->linesize[plane];
-
-        srcp_linesize = src_frame->linesize[plane] * 2;
-        dstp_linesize = dst_frame->linesize[plane] * 2;
-        for (j = lines; j > 0; j--) {
-            const uint8_t *srcp_above = srcp - src_frame->linesize[plane];
-            const uint8_t *srcp_below = srcp + src_frame->linesize[plane];
-            if (j == lines)
-                srcp_above = srcp; // there is no line above
-            if (j == 1)
-                srcp_below = srcp; // there is no line below
-            for (i = 0; i < linesize; i++) {
-                // this calculation is an integer representation of
-                // '0.5 * current + 0.25 * above + 0.25 * below'
-                // '1 +' is for rounding.
-                dstp[i] = (1 + srcp[i] + srcp[i] + srcp_above[i] + srcp_below[i]) >> 2;
+        if (lowpass) {
+            int srcp_linesize = src_frame->linesize[plane] * 2;
+            int dstp_linesize = dst_frame->linesize[plane] * 2;
+            for (j = lines; j > 0; j--) {
+                const uint8_t *srcp_above = srcp - src_frame->linesize[plane];
+                const uint8_t *srcp_below = srcp + src_frame->linesize[plane];
+                if (j == lines)
+                    srcp_above = srcp; // there is no line above
+                if (j == 1)
+                    srcp_below = srcp; // there is no line below
+                for (i = 0; i < linesize; i++) {
+                    // this calculation is an integer representation of
+                    // '0.5 * current + 0.25 * above + 0.25 * below'
+                    // '1 +' is for rounding.
+                    dstp[i] = (1 + srcp[i] + srcp[i] + srcp_above[i] + srcp_below[i]) >> 2;
+                }
+                dstp += dstp_linesize;
+                srcp += srcp_linesize;
             }
-            dstp += dstp_linesize;
-            srcp += srcp_linesize;
+        } else {
+            av_image_copy_plane(dstp, dst_frame->linesize[plane] * 2,
+                                srcp, src_frame->linesize[plane] * 2,
+                                linesize, lines);
         }
     }
 }
@@ -210,11 +209,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
     out->pts             /= 2;  // adjust pts to new framerate
 
     /* copy upper/lower field from cur */
-    copy_picture_field(s->cur, out, inlink, tff ? FIELD_UPPER : FIELD_LOWER);
+    copy_picture_field(s->cur, out, inlink, tff ? FIELD_UPPER : FIELD_LOWER, s->lowpass);
     av_frame_free(&s->cur);
 
     /* copy lower/upper field from next */
-    copy_picture_field(s->next, out, inlink, tff ? FIELD_LOWER : FIELD_UPPER);
+    copy_picture_field(s->next, out, inlink, tff ? FIELD_LOWER : FIELD_UPPER, s->lowpass);
     av_frame_free(&s->next);
 
     ret = ff_filter_frame(outlink, out);



More information about the ffmpeg-cvslog mailing list