Hi,

I've patched the transcode source to support 2 more zoom filters. Especially the Cubic4 filter produced very good results for me. Attached is the patch file, use "patch -p1 < ../transcode-1.0.2-filters.patch" to apply it. It's for a slightly older version of transcode but worked also with later versions. It has been some months since I've wrote this but I just thought it could be useful for others, too.

Regards
Johannes

diff -Naur transcode-1.0.2-orig/src/transcode.c transcode-1.0.2/src/transcode.c
--- transcode-1.0.2-orig/src/transcode.c        2005-10-02 03:38:22.000000000 
+0200
+++ transcode-1.0.2/src/transcode.c     2006-06-30 23:10:54.000000000 +0200
@@ -1848,8 +1848,24 @@
              vob->zoom_support=Triangle_support; 
              zoom_filter="Triangle";
              break;
+            }
+
+           if(strncasecmp(optarg,"cubicK4",1)==0) {
+             vob->zoom_filter=CubicKeys4_filter;
+             vob->zoom_support=CubicKeys4_support; 
+             zoom_filter="CubicKeys4";
+             break;
+             
+           }
+
+           if(strncasecmp(optarg,"sinc8",1)==0) {
+             vob->zoom_filter=Sinc8_filter;
+             vob->zoom_support=Sinc8_support; 
+             zoom_filter="sinc:8";
+             break;
+             
            }
-           tc_error("invalid argument for --zoom_filter option\nmethod: 
L[anczos] M[itchell] T[riangle] H[ermite] B[_spline] bell box");
+           tc_error("invalid argument for --zoom_filter option\nmethod: 
L[anczos] M[itchell] T[riangle] H[ermite] B[_spline] bell box cubicK4 sinc8");
            tc_error("invalid filter selection for --zoom_filter");
            
          } else  tc_error("invalid parameter for option --zoom_filter");
diff -Naur transcode-1.0.2-orig/src/zoom.c transcode-1.0.2/src/zoom.c
--- transcode-1.0.2-orig/src/zoom.c     2005-07-04 09:09:35.000000000 +0200
+++ transcode-1.0.2/src/zoom.c  2006-06-30 23:11:46.000000000 +0200
@@ -279,6 +279,32 @@
     return(0.0);
 }
 
+double CubicKeys4_filter(double t) // Keys 4th-order Cubic
+{
+    if (t < 0.0) t = -t;
+    if (t < 1.0) 
+      return (3.0 + (t * t * (-7.0 + (t * 4.0)))) / 3.0;
+    if (t < 2.0) 
+      return (30.0 + (t * (-59.0 + (t * (36.0 + (t * -7.0)))))) / 12.0;
+    if (t < 3.0)
+      return (-18.0 + (t * (21.0 + (t * (-8.0 + t))))) / 12.0;
+    return 0.0;
+}
+
+#define PI 3.1415926535897932384626433832795029L
+double Sinc8_filter(double t) // Sinc with Lanczos window, 8 cycles
+{
+    if (t < 0.0) t = -t;
+    if (t == 0.0) {
+      return 1.0;
+    } else if (t < 8.0) {
+      double w = sin(PI*t / 8.0) / (PI*t / 8.0);
+      return w * sin(t*PI) / (t*PI);
+    } else {
+      return 0.0;
+    }
+}
+
 /*
  *  image rescaling routine
  */
diff -Naur transcode-1.0.2-orig/src/zoom.h transcode-1.0.2/src/zoom.h
--- transcode-1.0.2-orig/src/zoom.h     2005-07-04 09:15:59.000000000 +0200
+++ transcode-1.0.2/src/zoom.h  2006-06-30 23:10:06.000000000 +0200
@@ -105,5 +105,8 @@
 extern double Mitchell_filter(double t);
 #define       Lanczos3_support  (3.0)
 extern double Lanczos3_filter(double t);
-
+#define       CubicKeys4_support  (3.0)
+extern double CubicKeys4_filter(double t);
+#define       Sinc8_support  (8.0)
+extern double Sinc8_filter(double t);
 #endif

Reply via email to