[FFmpeg-cvslog] lavfi/pp: switch to an AVOptions-based system.

Clément Bœsch git at videolan.org
Wed Apr 10 23:34:36 CEST 2013


ffmpeg | branch: master | Clément Bœsch <ubitux at gmail.com> | Wed Apr 10 22:43:25 2013 +0200| [8da1fff85a90b2fad1310e629ed2056d6c43f50e] | committer: Clément Bœsch

lavfi/pp: switch to an AVOptions-based system.

Also add and use the '|' separator instead of ':' since it's
incompatible with the new option system...

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

 doc/filters.texi          |   31 +++++++++++++++++++------------
 libavfilter/avfilter.c    |    1 +
 libavfilter/vf_pp.c       |   18 ++++++++++++++----
 libpostproc/postprocess.c |    2 +-
 libpostproc/version.h     |    2 +-
 tests/lavfi-regression.sh |    4 ++--
 6 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 00a804a..ed19218 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -4605,6 +4605,13 @@ Subfilters must be separated by '/' and can be disabled by prepending a '-'.
 Each subfilter and some options have a short and a long name that can be used
 interchangeably, i.e. dr/dering are the same.
 
+The filters accept the following options:
+
+ at table @option
+ at item subfilters
+Set postprocessing subfilters string.
+ at end table
+
 All subfilters share common options to determine their scope:
 
 @table @option
@@ -4621,12 +4628,12 @@ Do luminance filtering only (no chrominance).
 Do chrominance filtering only (no luminance).
 @end table
 
-These options can be appended after the subfilter name, separated by a ':'.
+These options can be appended after the subfilter name, separated by a '|'.
 
 Available subfilters are:
 
 @table @option
- at item hb/hdeblock[:difference[:flatness]]
+ at item hb/hdeblock[|difference[|flatness]]
 Horizontal deblocking filter
 @table @option
 @item difference
@@ -4635,7 +4642,7 @@ Difference factor where higher values mean more deblocking (default: @code{32}).
 Flatness threshold where lower values mean more deblocking (default: @code{39}).
 @end table
 
- at item vb/vdeblock[:difference[:flatness]]
+ at item vb/vdeblock[|difference[|flatness]]
 Vertical deblocking filter
 @table @option
 @item difference
@@ -4644,7 +4651,7 @@ Difference factor where higher values mean more deblocking (default: @code{32}).
 Flatness threshold where lower values mean more deblocking (default: @code{39}).
 @end table
 
- at item ha/hadeblock[:difference[:flatness]]
+ at item ha/hadeblock[|difference[|flatness]]
 Accurate horizontal deblocking filter
 @table @option
 @item difference
@@ -4653,7 +4660,7 @@ Difference factor where higher values mean more deblocking (default: @code{32}).
 Flatness threshold where lower values mean more deblocking (default: @code{39}).
 @end table
 
- at item va/vadeblock[:difference[:flatness]]
+ at item va/vadeblock[|difference[|flatness]]
 Accurate vertical deblocking filter
 @table @option
 @item difference
@@ -4677,7 +4684,7 @@ Experimental vertical deblocking filter
 @item dr/dering
 Deringing filter
 
- at item tn/tmpnoise[:threshold1[:threshold2[:threshold3]]], temporal noise reducer
+ at item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer
 @table @option
 @item threshold1
 larger -> stronger filtering
@@ -4717,7 +4724,7 @@ second line with a @code{(-1 4 2 4 -1)} filter.
 Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given
 block by filtering all lines with a @code{(-1 2 6 2 -1)} filter.
 
- at item fq/forceQuant[:quantizer]
+ at item fq/forceQuant[|quantizer]
 Overrides the quantizer table from the input with the constant quantizer you
 specify.
 @table @option
@@ -4726,13 +4733,13 @@ Quantizer to use
 @end table
 
 @item de/default
-Default pp filter combination (@code{hb:a,vb:a,dr:a})
+Default pp filter combination (@code{hb|a,vb|a,dr|a})
 
 @item fa/fast
-Fast pp filter combination (@code{h1:a,v1:a,dr:a})
+Fast pp filter combination (@code{h1|a,v1|a,dr|a})
 
 @item ac
-High quality pp filter combination (@code{ha:a:128:7,va:a,dr:a})
+High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a})
 @end table
 
 @subsection Examples
@@ -4754,14 +4761,14 @@ pp=de/-al
 @item
 Apply default filters and temporal denoiser:
 @example
-pp=default/tmpnoise:1:2:3
+pp=default/tmpnoise|1|2|3
 @end example
 
 @item
 Apply deblocking on luminance only, and switch vertical deblocking on or off
 automatically depending on available CPU time:
 @example
-pp=hb:y/vb:a
+pp=hb|y/vb|a
 @end example
 @end itemize
 
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index cd47f47..13e9ac9 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -686,6 +686,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
         !strcmp(filter->filter->name,   "format") ||
         !strcmp(filter->filter->name, "noformat") ||
         !strcmp(filter->filter->name, "perms")  ||
+        !strcmp(filter->filter->name, "pp"   )  ||
         !strcmp(filter->filter->name, "aperms") ||
         !strcmp(filter->filter->name, "resample") ||
         !strcmp(filter->filter->name, "showspectrum") ||
diff --git a/libavfilter/vf_pp.c b/libavfilter/vf_pp.c
index b7f35d3..7dfb448 100644
--- a/libavfilter/vf_pp.c
+++ b/libavfilter/vf_pp.c
@@ -31,21 +31,29 @@
 #include "libpostproc/postprocess.h"
 
 typedef struct {
+    const AVClass *class;
+    char *subfilters;
     int mode_id;
     pp_mode *modes[PP_QUALITY_MAX + 1];
     void *pp_ctx;
 } PPFilterContext;
 
+#define OFFSET(x) offsetof(PPFilterContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+static const AVOption pp_options[] = {
+    { "subfilters", "set postprocess subfilters", OFFSET(subfilters), AV_OPT_TYPE_STRING, {.str="de"}, .flags = FLAGS },
+    { NULL }
+};
+
+AVFILTER_DEFINE_CLASS(pp);
+
 static av_cold int pp_init(AVFilterContext *ctx, const char *args)
 {
     int i;
     PPFilterContext *pp = ctx->priv;
 
-    if (!args || !*args)
-        args = "de";
-
     for (i = 0; i <= PP_QUALITY_MAX; i++) {
-        pp->modes[i] = pp_get_mode_by_name_and_quality(args, i);
+        pp->modes[i] = pp_get_mode_by_name_and_quality(pp->subfilters, i);
         if (!pp->modes[i])
             return AVERROR_EXTERNAL;
     }
@@ -171,4 +179,6 @@ AVFilter avfilter_vf_pp = {
     .inputs          = pp_inputs,
     .outputs         = pp_outputs,
     .process_command = pp_process_command,
+    .priv_class      = &pp_class,
+
 };
diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c
index facfd2c..b34943f 100644
--- a/libpostproc/postprocess.c
+++ b/libpostproc/postprocess.c
@@ -666,7 +666,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality)
     char temp[GET_MODE_BUFFER_SIZE];
     char *p= temp;
     static const char filterDelimiters[] = ",/";
-    static const char optionDelimiters[] = ":";
+    static const char optionDelimiters[] = ":|";
     struct PPMode *ppMode;
     char *filterToken;
 
diff --git a/libpostproc/version.h b/libpostproc/version.h
index d0d3d43..111db44 100644
--- a/libpostproc/version.h
+++ b/libpostproc/version.h
@@ -29,7 +29,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBPOSTPROC_VERSION_MAJOR 52
-#define LIBPOSTPROC_VERSION_MINOR  2
+#define LIBPOSTPROC_VERSION_MINOR  3
 #define LIBPOSTPROC_VERSION_MICRO 100
 
 #define LIBPOSTPROC_VERSION_INT AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, \
diff --git a/tests/lavfi-regression.sh b/tests/lavfi-regression.sh
index bb023e4..9076e4f 100755
--- a/tests/lavfi-regression.sh
+++ b/tests/lavfi-regression.sh
@@ -52,8 +52,8 @@ do_lavfi "overlay_yuv420"     "split[m],scale=88:72,pad=96:80:4:4[o2];[m]fifo[o1
 do_lavfi "overlay_yuv444"     "split[m],scale=88:72,pad=96:80:4:4[o2];[m]fifo[o1],[o1][o2]overlay=240:16:format=yuv444"
 do_lavfi "pad"                "pad=iw*1.5:ih*1.5:iw*0.3:ih*0.2"
 do_lavfi "pp"                 "pp=be/hb/vb/tn/l5/al"
-do_lavfi "pp2"                "pp=be/fq:16/h1/v1/lb"
-do_lavfi "pp3"                "pp=be/fq:8/ha:128:7/va/li"
+do_lavfi "pp2"                "pp=be/fq|16/h1/v1/lb"
+do_lavfi "pp3"                "pp=be/fq|8/ha|128|7/va/li"
 do_lavfi "pp4"                "pp=be/ci"
 do_lavfi "pp5"                "pp=md"
 do_lavfi "pp6"                "pp=be/fd"



More information about the ffmpeg-cvslog mailing list