diff -Naur cinelerra-5.1.orig/cinelerra/affine.C cinelerra-5.1/cinelerra/affine.C
--- cinelerra-5.1.orig/cinelerra/affine.C	2019-06-16 01:47:50.000000000 +0700
+++ cinelerra-5.1/cinelerra/affine.C	2020-07-20 20:27:35.790041180 +0700
@@ -185,7 +185,7 @@
 	double w;
 
 	w = values[2][0] * x + values[2][1] * y + values[2][2];
-	w = !w ? 1 : 1/w;
+	w = ((w == 0.0) ? 1.0 : 1.0/w);
 
 	*newx = (values[0][0] * x + values[0][1] * y + values[0][2]) * w;
 	*newy = (values[1][0] * x + values[1][1] * y + values[1][2]) * w;
@@ -242,8 +242,8 @@
 	AffinePackage *pkg = (AffinePackage*)package;
 	int min_in_x = server->in_x;
 	int min_in_y = server->in_y;
-	int max_in_x = server->in_x + server->in_w - 1;
-	int max_in_y = server->in_y + server->in_h - 1;
+	int max_in_x = server->in_x + server->in_w;
+	int max_in_y = server->in_y + server->in_h;
 
 
 // printf("AffineUnit::process_package %d %d %d %d %d\n",
@@ -690,10 +690,10 @@
 
 void AffineEngine::init_packages()
 {
-	int y1 = 0, npkgs = get_total_packages();
+	int y1 = out_y, y2 = out_y, npkgs = get_total_packages();
 	for( int i=0; i<npkgs; ) {
 		AffinePackage *package = (AffinePackage*)get_package(i);
-		int y2 = out_y + (out_h * ++i / npkgs);
+		y2 = out_y + (out_h * ++i / npkgs);
 		package->y1 = y1;  package->y2 = y2;  y1 = y2;
 	}
 }
@@ -829,7 +829,7 @@
 	x4 = ((in_pivot_x - in_x) - sin(angle4) * radius4) * 100 / in_w;
 	y4 = ((in_pivot_y - in_y) + cos(angle4) * radius4) * 100 / in_h;
 
-// printf("AffineEngine::rotate angle=%f\n",
+// printf("AffineEngine::rotate use_opengl=%d angle=%f\n", use_opengl,
 // angle);
 
 //
@@ -841,10 +841,10 @@
 // radius1, radius2, radius3, radius4);
 //
 // printf("	x1=%f y1=%f x2=%f y2=%f x3=%f y3=%f x4=%f y4=%f\n",
-// x1 * w / 100, y1 * h / 100,
-// x2 * w / 100, y2 * h / 100,
-// x3 * w / 100, y3 * h / 100,
-// x4 * w / 100, y4 * h / 100);
+// x1 * in_w / 100, y1 * in_h / 100,
+// x2 * in_w / 100, y2 * in_h / 100,
+// x3 * in_w / 100, y3 * in_h / 100,
+// x4 * in_w / 100, y4 * in_h / 100);
 
 	if(use_opengl) {
 		set_package_count(1);
diff -Naur cinelerra-5.1.orig/cinelerra/interp.h cinelerra-5.1/cinelerra/interp.h
--- cinelerra-5.1.orig/cinelerra/interp.h	2019-06-16 01:47:50.000000000 +0700
+++ cinelerra-5.1/cinelerra/interp.h	2020-07-20 20:27:54.880041556 +0700
@@ -51,7 +51,7 @@
 
 
 #define nearest_SETUP(typ, components, tx, ty) \
-	int itx = (tx), ity = (ty), in_comps = (components); \
+	int itx = (int)(tx), ity = (int)(ty), in_comps = (components); \
 	int c0 = itx+0, r0 = ity+0; \
 	typ *r0p = r0>=in_min_y && r0<in_max_y ? ((typ**)interp_rows)[r0] : 0
 
@@ -64,10 +64,8 @@
 
 
 #define bi_linear_SETUP(typ, components, tx, ty) \
-	float dx = (tx)-0.5, dy = (ty)-0.5; \
-	int itx = dx, ity = dy, in_comps = (components); \
-	if( (dx -= itx) < 0 ) dx += 1; \
-	if( (dy -= ity) < 0 ) dy += 1; \
+	int itx = (int)(tx), ity = (int)(ty), in_comps = (components); \
+	float dx = (tx)-itx, dy = (ty)-ity; \
 	int c0 = itx+0, c1 = itx+1, r0 = ity+0, r1 = ity+1; \
 	typ *r0p = r0>=in_min_y && r0<in_max_y ? ((typ**)interp_rows)[r0] : 0; \
 	typ *r1p = r1>=in_min_y && r1<in_max_y ? ((typ**)interp_rows)[r1] : 0
@@ -83,10 +81,8 @@
 
 
 #define bi_cubic_SETUP(typ, components, tx, ty) \
-	float dx = (tx)-0.5, dy = (ty)-0.5; \
-	int itx = dx, ity = dy, in_comps = (components); \
-	if( (dx -= itx) < 0 ) dx += 1; \
-	if( (dy -= ity) < 0 ) dy += 1; \
+	int itx = (int)(tx), ity = (int)(ty), in_comps = (components); \
+	float dx = (tx)-itx, dy = (ty)-ity; \
 	int cp = itx-1, c0 = itx+0, c1 = itx+1, c2 = itx+2; \
 	int rp = ity-1, r0 = ity+0, r1 = ity+1, r2 = ity+2; \
 	typ *rpp = rp>=in_min_y && rp<in_max_y ? ((typ**)interp_rows)[rp] : 0; \
