Hi All,
It's always bugged me that when zooming into interlaced material, there
is a type of moire effect, or you end up zooming into two bars.
Some time ago, I proposed the idea of zooming for two frames, the odd
and the even frames.
Here is that idea somewhat implemented for the nearest neibour method.
The patch isn't complete, (since it doesn't have an on/off button, not
take advantage of the interlace settings that should be set)
Just wondering what people think about this idea..
To test it:
1. apply the patch (patch -p 1 < nearest_...patch ), make etc..
2. get some interlaced material. Load it up, Select "Nearest neighbor
enlarge and reduce" from preference->playback.
3. zoom in, and pan around. After rendering the results. reverse the
patch, (patch -R -p1 < nearest..patch) , make etc.. and compare.
A (VERY SHORT) sample comparison is available at:
http://cvs.cinelerra.org/~pmdumuid/interzoom/myzoom.mov
http://cvs.cinelerra.org/~pmdumuid/interzoom/origzoom.mov
I suggest playing them with mplayer using:
mplayer -vf pp=lb -speed .5 myzoom.mov
mplayer -vf pp=lb -speed .5 origzoom.mov
diff --git a/cinelerra/overlayframe.C b/cinelerra/overlayframe.C
index 64400ce..3ddc389 100644
--- a/cinelerra/overlayframe.C
+++ b/cinelerra/overlayframe.C
@@ -2255,7 +2255,7 @@ ScaleTranslateUnit::~ScaleTranslateUnit(
{
}
-void ScaleTranslateUnit::scale_array_f(int* &table,
+void ScaleTranslateUnit::scale_array_x_f(int* &table,
int out_x1,
int out_x2,
float in_x1,
@@ -2269,6 +2269,31 @@ void ScaleTranslateUnit::scale_array_f(i
table[i] = (int)((float)i / scale + in_x1);
}
+void ScaleTranslateUnit::scale_array_y_f(int* &table,
+ int out_y1,
+ int out_y2,
+ float in_y1,
+ float in_y2,
+ int interpolate)
+{
+ float scale = (float)(out_y2 - out_y1) / (in_y2 - in_y1);
+
+ float scale2 = (float)(in_y2 - in_y1) / (out_y2 - out_y1);
+ table = new int[(int)out_y2 - out_y1];
+ int tmp = (int)in_y1 + out_y1;
+
+ if (1)
+ for(int i = 0; i < out_y2 - out_y1; i++)
+ table[i] = (int)( (float)i * scale2/2 ) * 2 + (int) in_y1 + (tmp + i & 0x01);
+ else
+ for(int i = 0; i < out_y2 - out_y1; i++)
+ table[i] = (int)((float)i / scale + in_y1);
+
+// for(int i = 0; i < out_y2 - out_y1; i++)
+// printf("table: %d %d %d\n", i, out_y1 + i, table[i]);
+
+}
+
void ScaleTranslateUnit::process_package(LoadPackage *package)
{
ScaleTranslatePackage *pkg = (ScaleTranslatePackage*)package;
@@ -2298,17 +2323,18 @@ void ScaleTranslateUnit::process_package
//printf("ScaleTranslateUnit::process_package 1 %d\n", mode);
if(out_w != in_x2 - in_x1)
{
- scale_array_f(x_table,
+ scale_array_x_f(x_table,
out_x1,
out_x2,
scale_translate->in_x1,
scale_translate->in_x2);
}
- scale_array_f(y_table,
+ scale_array_y_f(y_table,
out_y1,
out_y2,
scale_translate->in_y1,
- scale_translate->in_y2);
+ scale_translate->in_y2,
+ 0);
if (mode == TRANSFER_REPLACE && (out_w == in_x2 - in_x1))
diff --git a/cinelerra/overlayframe.h b/cinelerra/overlayframe.h
index 7e2c14d..32dac4a 100644
--- a/cinelerra/overlayframe.h
+++ b/cinelerra/overlayframe.h
@@ -269,12 +269,19 @@ public:
~ScaleTranslateUnit();
void process_package(LoadPackage *package);
- void scale_array_f(int* &table,
+ void scale_array_x_f(int* &table,
int out_x1,
int out_x2,
float in_x1,
float in_x2);
+ void scale_array_y_f(int* &table,
+ int out_x1,
+ int out_x2,
+ float in_x1,
+ float in_x2,
+ int interpolate);
+
OverlayFrame *overlay;
ScaleTranslateEngine *scale_translate;
};