diff -u base/cinelerra/overlayframe.C hvirtual-1.1.6/cinelerra/overlayframe.C
--- base/cinelerra/overlayframe.C	2003-08-09 21:52:12.000000000 +0200
+++ hvirtual-1.1.6/cinelerra/overlayframe.C	2003-08-09 22:26:01.000000000 +0200
@@ -2580,10 +2580,10 @@
 }
 
 // components is always 4
-#define BLEND_ONLY_4_NORMAL(temp_type, type, max, chroma_offset) \
+#define BLEND_ONLY_4_NORMAL(temp_type, type, chroma_offset, maxbits) \
 { \
-	temp_type opacity = (temp_type)(alpha * max + 0.5); \
-	temp_type maxsq = ((temp_type)max) * max; \
+	temp_type opacity = (temp_type)(alpha * (((temp_type) 1) << maxbits) + 0.5); \
+	temp_type maxsq = ((temp_type) 1) << (maxbits * 2) ; \
  \
 	type** output_rows = (type**)output->get_rows(); \
 	type** input_rows = (type**)input->get_rows(); \
@@ -2603,14 +2603,14 @@
 		 \
 		 \
 			output[0] = (type)(((temp_type)in_row[0] * pixel_opacity + \
-				(temp_type)output[0] * pixel_transparency) / max / max); \
-			output[1] = (type)((((temp_type)in_row[1] - chroma_offset) * pixel_opacity + \
+				(temp_type)output[0] * pixel_transparency) >> (maxbits * 2)); \
+			output[1] = (type)(((((temp_type)in_row[1] - chroma_offset) * pixel_opacity + \
 				((temp_type)output[1] - chroma_offset) * pixel_transparency) \
-				/ max / max + \
+				>> (maxbits * 2)) + \
 				chroma_offset); \
-			output[2] = (type)((((temp_type)in_row[2] - chroma_offset) * pixel_opacity + \
+			output[2] = (type)(((((temp_type)in_row[2] - chroma_offset) * pixel_opacity + \
 				((temp_type)output[2] - chroma_offset) * pixel_transparency) \
-				/ max / max + \
+				>> (maxbits * 2)) + \
 				chroma_offset); \
 			output[3] = (type)(in_row[3] > output[3] ? in_row[3] : output[3]); \
  \
@@ -2621,10 +2621,10 @@
 }
 
 // components is always 3
-#define BLEND_ONLY_3_NORMAL(temp_type, type, max, chroma_offset) \
+#define BLEND_ONLY_3_NORMAL(temp_type, type, chroma_offset, maxbits) \
 { \
-	temp_type opacity = (temp_type)(alpha * max + 0.5); \
-	temp_type transparency = max - opacity; \
+	temp_type opacity = (temp_type)(alpha * (((temp_type) 1) << maxbits) + 0.5); \
+	temp_type transparency = (((temp_type) 1) << maxbits) - opacity; \
  \
 	type** output_rows = (type**)output->get_rows(); \
 	type** input_rows = (type**)input->get_rows(); \
@@ -2638,7 +2638,7 @@
  \
 		for(int j = 0; j < w; j++) /* w = 3x width! */ \
 		{ \
-			*output = (type)CLIP(((temp_type)*in_row * opacity + *output * transparency) / max, 0, max); \
+			*output = (type)((temp_type)*in_row * opacity + *output * transparency) >> maxbits; \
 			in_row ++; \
 			output ++; \
 		} \
@@ -2664,6 +2664,7 @@
 	VFrame *output = blend_engine->output;
 	VFrame *input = blend_engine->input;
 	float alpha = blend_engine->alpha;
+	if (alpha > 1.0) alpha = 1.0;
 	int mode = blend_engine->mode;
 //	Timer a;
 //	a.update();
@@ -2692,28 +2693,28 @@
 		switch(input->get_color_model())
 		{
 			case BC_RGB888:
-				BLEND_ONLY_3_NORMAL(uint32_t, unsigned char, 0xff, 0);
+				BLEND_ONLY_3_NORMAL(uint32_t, unsigned char, 0, 8);
 				break;
 			case BC_YUV888:
-				BLEND_ONLY_3_NORMAL(int32_t, unsigned char, 0xff, 0x80);
+				BLEND_ONLY_3_NORMAL(int32_t, unsigned char, 0x80, 8);
 				break;
 			case BC_RGBA8888:
-				BLEND_ONLY_4_NORMAL(uint32_t, unsigned char, 0xff, 0);
+				BLEND_ONLY_4_NORMAL(uint32_t, unsigned char, 0, 8);
 				break;
 			case BC_YUVA8888:
-				BLEND_ONLY_4_NORMAL(int32_t, unsigned char, 0xff, 0x80);
+				BLEND_ONLY_4_NORMAL(int32_t, unsigned char, 0x80, 8);
 				break;
 			case BC_RGB161616:
-				BLEND_ONLY_3_NORMAL(uint64_t, uint16_t, 0xffff, 0);
+				BLEND_ONLY_3_NORMAL(uint64_t, uint16_t, 0, 16);
 				break;
 			case BC_YUV161616:
-				BLEND_ONLY_3_NORMAL(int64_t, uint16_t, 0xffff, 0x8000);
+				BLEND_ONLY_3_NORMAL(int64_t, uint16_t, 0x8000, 16);
 				break;
 			case BC_RGBA16161616:
-				BLEND_ONLY_4_NORMAL(uint64_t, uint16_t, 0xffff, 0);
+				BLEND_ONLY_4_NORMAL(uint64_t, uint16_t, 0, 16);
 				break;
 			case BC_YUVA16161616:
-				BLEND_ONLY_4_NORMAL(int64_t, uint16_t, 0xffff, 0x8000);
+				BLEND_ONLY_4_NORMAL(int64_t, uint16_t, 0x8000, 16);
 				break;
 		}
 	} else
