]> git.sesse.net Git - mlt/blobdiff - src/modules/videostab/transform_image.c
Fix videostab2 interpolation.
[mlt] / src / modules / videostab / transform_image.c
index a2e6de561243464d1cbb16de1512bbdc788bcc8b..ae4b1d9e820b81a949c04af597f57dfcb849e8eb 100644 (file)
@@ -74,7 +74,7 @@ void interpolateBiLinBorder(unsigned char *rv, float x, float y,
                  |-1, 3,-3, 1 |  |a3|
 */
 static short bicub_kernel(float t, short a0, short a1, short a2, short a3){
-    return (2*a1 + t*((-a0+a2) + t*((2*a0-5*a1+4*a2-a3) + t*(-a0+3*a1-3*a2+a3) )) ) / 2;
+  return (2*a1 + t*((-a0+a2) + t*((2*a0-5*a1+4*a2-a3) + t*(-a0+3*a1-3*a2+a3) )) ) / 2;
 }
 
 /** interpolateBiCub: bi-cubic interpolation function using 4x4 pixel, see interpolate */
@@ -82,7 +82,7 @@ void interpolateBiCub(unsigned char *rv, float x, float y,
                       unsigned char* img, int width, int height, unsigned char def,unsigned char N, unsigned char channel)
 {
     // do a simple linear interpolation at the border
-    if (x < 1 || x > width-2 || y < 1 || y > height - 2) {
+    if (x < 1 || x >= width-2 || y < 1 || y >= height - 2) {
         interpolateBiLinBorder(rv, x,y,img,width,height,def,N,channel);
     } else {
         int x_f = myfloor(x);
@@ -116,7 +116,7 @@ void interpolateBiCub(unsigned char *rv, float x, float y,
 void interpolateSqr(unsigned char *rv, float x, float y,
                     unsigned char* img, int width, int height, unsigned char def,unsigned char N, unsigned char channel)
 {
-    if (x < 0 || x > width-1 || y < 0 || y > height - 1) {
+    if (x < 0 || x >= width-1 || y < 0 || y >= height-1) {
         interpolateBiLinBorder(rv, x, y, img, width, height, def,N,channel);
     } else {
         int x_f = myfloor(x);
@@ -141,7 +141,7 @@ void interpolateBiLin(unsigned char *rv, float x, float y,
                       unsigned char* img, int width, int height,
                       unsigned char def,unsigned char N, unsigned char channel)
 {
-    if (x < 0 || x > width-1 || y < 0 || y > height - 1) {
+    if (x < 0 || x >= width-1 || y < 0 || y >= height - 1) {
         interpolateBiLinBorder(rv, x, y, img, width, height, def,N,channel);
     } else {
         int x_f = myfloor(x);
@@ -266,7 +266,7 @@ int transformRGB(TransformData* td)
                     + zcos_a * y_d1 + c_s_y -t.y;
                 for (z = 0; z < 3; z++) { // iterate over colors
                     unsigned char* dest = &D_2[(x + y * td->width_dest)*3+z];
-                    interpolate(dest, myfloor(x_s), myfloor(y_s), D_1,
+                    interpolate(dest, x_s, y_s, D_1,
                                  td->width_src, td->height_src,
                                  td->crop ? 16 : *dest,3,z);
                 }