iwidth = iwidth - ( iwidth % 4 );
- // Coordinates (0,0 is middle of output)
- int y, x;
-
// Derived coordinates
int dy, dx;
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
// 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;
// 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 )
{
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 );
}
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;
}
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" ) ||
}
// 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 );
}
}