[FFmpeg-soc] [soc]: r4135 - libavfilter/vf_scale.c

stefano subversion at mplayerhq.hu
Tue Feb 24 00:24:47 CET 2009


Author: stefano
Date: Tue Feb 24 00:24:47 2009
New Revision: 4135

Log:
Make the flags for the SwsContext, used for rescaling, configurable.

Add support for parsing a key/value pair sws_flags=VAL in the sws_opts
of the args. The value of sws_flags is set in the SwsContext using
av_opt_string3().

Modified:
   libavfilter/vf_scale.c

Modified: libavfilter/vf_scale.c
==============================================================================
--- libavfilter/vf_scale.c	Tue Feb 24 00:12:14 2009	(r4134)
+++ libavfilter/vf_scale.c	Tue Feb 24 00:24:47 2009	(r4135)
@@ -22,6 +22,7 @@
 #include <stdio.h>
 
 #include "avfilter.h"
+#include "libavcodec/opt.h"
 #include "libswscale/swscale.h"
 
 typedef struct
@@ -42,6 +43,7 @@ static av_cold int init(AVFilterContext 
 {
     ScaleContext *scale = ctx->priv;
     char sws_opts[256];
+    char *p;
 
     /* default to no scaling */
     scale->w =
@@ -53,6 +55,22 @@ static av_cold int init(AVFilterContext 
     if(args)
         sscanf(args, "%d:%d:%255s", &scale->w, &scale->h, sws_opts);
 
+    if ((p = strstr(sws_opts, "sws_flags="))) {
+        char sws_flags[256];
+        int i = 0;
+        p = strchr(sws_opts, '=');
+        p++;
+        while (*p && *p != ':' && i < sizeof(sws_flags) - 1)
+            sws_flags[i++] = *p++;
+        sws_flags[i] = 0;
+
+        if (av_set_string3(scale->sws, "sws_flags", sws_flags, 1, NULL) < 0) {
+            sws_freeContext(scale->sws);
+            scale->sws = NULL;
+            return -1;
+        }
+    }
+
     /* sanity check parms */
     if(scale->w <  -1 || scale->h <  -1)
         return -1;
@@ -98,12 +116,11 @@ static int config_props(AVFilterLink *li
     if(w == -1) w = scale->h*link->src->inputs[0]->w/link->src->inputs[0]->h;
     if(h == -1) h = scale->w*link->src->inputs[0]->h/link->src->inputs[0]->w;
 
-    /* TODO: make algorithm configurable */
     scale->sws = sws_getCachedContext(scale->sws,
                                       link->src->inputs[0]->w,
                                       link->src->inputs[0]->h,
                                       link->src->inputs[0]->format,
-                                      w, h, link->format, SWS_BILINEAR,
+                                      w, h, link->format, av_get_int(scale->sws, "sws_flags", NULL),
                                       NULL, NULL, NULL);
 
     link->w = w;



More information about the FFmpeg-soc mailing list