From a1c0987f26ed2c7671eceb903b99324c25d600b8 Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Sun, 27 Oct 2013 23:10:49 -0700 Subject: [PATCH] Fix videostab2 interpolation. This filter uses RGB mode, for which bicubic is broken. vid.stab still to this day uses bilinear with packed pixel formats. In order to fix bilinear, needed to remove extra calls to floor function. --- src/modules/videostab/filter_videostab2.c | 8 +------- src/modules/videostab/transform_image.c | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/modules/videostab/filter_videostab2.c b/src/modules/videostab/filter_videostab2.c index f78d38e3..85da5956 100644 --- a/src/modules/videostab/filter_videostab2.c +++ b/src/modules/videostab/filter_videostab2.c @@ -172,7 +172,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format // Load analysis results from property data->initialized = 2; - int interp = 2; + int interp = 2; // default to bilinear float scale_zoom=1.0; if ( *width != mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "meta.media.width" ) ) scale_zoom = (float) *width / (float) mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "meta.media.width" ); @@ -180,12 +180,6 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format interp = 0; else if ( strcmp( interps, "tiles" ) == 0 || strcmp( interps, "fast_bilinear" ) == 0 ) interp = 1; - else if ( strcmp( interps, "bilinear" ) == 0 ) - interp = 2; - else if ( strcmp( interps, "bicubic" ) == 0 ) - interp = 3; - else if ( strcmp( interps, "bicublin" ) == 0 ) - interp = 4; data->trans->interpoltype = interp; data->trans->smoothing = mlt_properties_get_int( MLT_FILTER_PROPERTIES(filter), "smoothing" ); diff --git a/src/modules/videostab/transform_image.c b/src/modules/videostab/transform_image.c index c0a8751a..ae4b1d9e 100644 --- a/src/modules/videostab/transform_image.c +++ b/src/modules/videostab/transform_image.c @@ -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 */ @@ -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); } -- 2.39.2