From: lilo_booter Date: Fri, 27 Feb 2004 12:38:49 +0000 (+0000) Subject: Scaling experimentation X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=00db7ed91dfa61f9e144b6d5548350a5954deb61;p=melted Scaling experimentation git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@174 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index c0d75d6..60dfb28 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -592,9 +592,6 @@ uint8_t *mlt_frame_rescale_yuv422( mlt_frame this, int owidth, int oheight ) iwidth = iwidth - ( iwidth % 4 ); - // Coordinates (0,0 is middle of output) - int y, x; - // Derived coordinates int dy, dx; @@ -605,41 +602,44 @@ uint8_t *mlt_frame_rescale_yuv422( mlt_frame this, int owidth, int oheight ) int in_y_range = iheight / 2; // Output pointers - uint8_t *out_line = output; - uint8_t *out_ptr; + register uint8_t *out_line = output; + register uint8_t *out_ptr; // Calculate a middle pointer uint8_t *in_middle = input + istride * in_y_range + in_x_range * 2; uint8_t *in_line; - uint8_t *in_ptr; // Generate the affine transform scaling values - int scale_width = ( iwidth << 16 ) / owidth; - int scale_height = ( iheight << 16 ) / oheight; + register int scale_width = ( iwidth << 16 ) / owidth; + register int scale_height = ( iheight << 16 ) / oheight; + register int base = 0; + + int outer = out_x_range * scale_width; + int bottom = out_y_range * scale_height; // Loop for the entirety of our output height. - for ( y = - out_y_range; y < out_y_range ; y ++ ) + for ( dy = - bottom; dy < bottom; dy += scale_height ) { - // Calculate the derived y value - dy = ( scale_height * y ) >> 16; - // Start at the beginning of the line out_ptr = out_line; // Pointer to the middle of the input line - in_line = in_middle + dy * istride; - + in_line = in_middle + ( dy >> 16 ) * istride; + // Loop for the entirety of our output row. - for ( x = - out_x_range; x < out_x_range; x += 1 ) + for ( dx = - outer; dx < outer; dx += scale_width ) { - // Calculated the derived x - dx = ( scale_width * x ) >> 16; - - // We're in the input range for this row. - in_ptr = in_line + ( dx << 1 ); - *out_ptr ++ = *in_ptr ++; - in_ptr = in_line + ( ( dx >> 1 ) << 2 ) + ( ( x & 1 ) << 1 ) + 1; - *out_ptr ++ = *in_ptr; + base = dx >> 15; + base &= 0xfffffffe; + *out_ptr ++ = *( in_line + base ); + base &= 0xfffffffc; + *out_ptr ++ = *( in_line + base + 1 ); + dx += scale_width; + base = dx >> 15; + base &= 0xfffffffe; + *out_ptr ++ = *( in_line + base ); + base &= 0xfffffffc; + *out_ptr ++ = *( in_line + base + 3 ); } // Move to next output line diff --git a/src/modules/core/filter_resize.c b/src/modules/core/filter_resize.c index a511eb2..4122d8f 100644 --- a/src/modules/core/filter_resize.c +++ b/src/modules/core/filter_resize.c @@ -36,6 +36,9 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * // Get the properties from the frame mlt_properties properties = mlt_frame_properties( this ); + // Pop the top of stack now + mlt_filter filter = mlt_frame_pop_service( this ); + // Assign requested width/height from our subordinate int owidth = *width; int oheight = *height; @@ -82,6 +85,9 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * // We only know how to process yuv422 at the moment if ( error == 0 && *format == mlt_image_yuv422 ) { + // Get the requested scale operation + char *op = mlt_properties_get( mlt_filter_properties( filter ), "scale" ); + // Correct field order if needed if ( mlt_properties_get_int( properties, "top_field_first" ) == 1 ) { @@ -103,11 +109,11 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * mlt_properties_set_int( properties, "top_field_first", 0 ); } - if ( !strcmp( mlt_properties_get( properties, "resize.scale" ), "affine" ) ) + if ( !strcmp( op, "affine" ) ) { *image = mlt_frame_rescale_yuv422( this, *width, *height ); } - else if ( strcmp( mlt_properties_get( properties, "resize.scale" ), "none" ) != 0 ) + else if ( strcmp( op, "none" ) != 0 ) { *image = mlt_frame_resize_yuv422( this, *width, *height ); } @@ -126,8 +132,12 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) { + // Push this on to the service stack + mlt_frame_push_service( frame, this ); + + // Push the get_image method on to the stack mlt_frame_push_get_image( frame, filter_get_image ); - mlt_properties_set( mlt_frame_properties( frame ), "resize.scale", mlt_properties_get( mlt_filter_properties( this ), "scale" ) ); + return frame; } diff --git a/src/modules/dv/consumer_libdv.c b/src/modules/dv/consumer_libdv.c index 3b57638..15fa136 100644 --- a/src/modules/dv/consumer_libdv.c +++ b/src/modules/dv/consumer_libdv.c @@ -207,14 +207,10 @@ static int consumer_encode_video( mlt_consumer this, uint8_t *dv_frame, mlt_fram int width = mlt_properties_get_int( this_properties, "width" ); int height = mlt_properties_get_int( this_properties, "height" ); uint8_t *image = NULL; - int is_test = 0; // Get the image mlt_frame_get_image( frame, &image, &fmt, &width, &height, 0 ); - // determine if this a test card - is_test = mlt_frame_is_test_card( frame ); - // Check that we get what we expected if ( fmt != mlt_image_yuv422 || width != mlt_properties_get_int( this_properties, "width" ) || @@ -231,16 +227,10 @@ static int consumer_encode_video( mlt_consumer this, uint8_t *dv_frame, mlt_fram } // Process the frame - if ( size != 0 && !( mlt_properties_get_int( this_properties, "was_test_card" ) && is_test ) ) + if ( size != 0 ) { - if ( mlt_properties_get_int( mlt_frame_properties( frame ), "top_field_first" ) ) - image += width * 2; - // Encode the image dv_encode_full_frame( encoder, &image, e_dv_color_yuv, dv_frame ); - - // Note test card status - mlt_properties_set_int( this_properties, "was_test_card", is_test ); } }