-int mlt_convert_rgb24a_to_yuv422( uint8_t *rgba, int width, int height, int stride, uint8_t *yuv, uint8_t *alpha )
-{
- int ret = 0;
- register int y0, y1, u0, u1, v0, v1;
- register int r, g, b;
- register uint8_t *d = yuv;
- register int i, j;
-
- for ( i = 0; i < height; i++ )
- {
- register uint8_t *s = rgba + ( stride * i );
- for ( j = 0; j < ( width / 2 ); j++ )
- {
- r = *s++;
- g = *s++;
- b = *s++;
- *alpha++ = *s++;
- RGB2YUV (r, g, b, y0, u0 , v0);
- r = *s++;
- g = *s++;
- b = *s++;
- *alpha++ = *s++;
- RGB2YUV (r, g, b, y1, u1 , v1);
- *d++ = y0;
- *d++ = (u0+u1) >> 1;
- *d++ = y1;
- *d++ = (v0+v1) >> 1;
- }
- if ( width % 2 )
- {
- r = *s++;
- g = *s++;
- b = *s++;
- *alpha++ = *s++;
- RGB2YUV (r, g, b, y0, u0 , v0);
- *d++ = y0;
- *d++ = u0;
- }
- }
- return ret;
-}
-
-int mlt_convert_rgb24_to_yuv422( uint8_t *rgb, int width, int height, int stride, uint8_t *yuv )
-{
- int ret = 0;
- register int y0, y1, u0, u1, v0, v1;
- register int r, g, b;
- register uint8_t *d = yuv;
- register int i, j;
-
- for ( i = 0; i < height; i++ )
- {
- register uint8_t *s = rgb + ( stride * i );
- for ( j = 0; j < ( width / 2 ); j++ )
- {
- r = *s++;
- g = *s++;
- b = *s++;
- RGB2YUV (r, g, b, y0, u0 , v0);
- r = *s++;
- g = *s++;
- b = *s++;
- RGB2YUV (r, g, b, y1, u1 , v1);
- *d++ = y0;
- *d++ = (u0+u1) >> 1;
- *d++ = y1;
- *d++ = (v0+v1) >> 1;
- }
- if ( width % 2 )
- {
- r = *s++;
- g = *s++;
- b = *s++;
- RGB2YUV (r, g, b, y0, u0 , v0);
- *d++ = y0;
- *d++ = u0;
- }
- }
- return ret;
-}
-
-int mlt_convert_yuv420p_to_yuv422( uint8_t *yuv420p, int width, int height, int stride, uint8_t *yuv )
-{
- int ret = 0;
- register int i, j;
-
- int half = width >> 1;
-
- uint8_t *Y = yuv420p;
- uint8_t *U = Y + width * height;
- uint8_t *V = U + width * height / 4;
-
- register uint8_t *d = yuv;
-
- for ( i = 0; i < height; i++ )
- {
- register uint8_t *u = U + ( i / 2 ) * ( half );
- register uint8_t *v = V + ( i / 2 ) * ( half );
-
- for ( j = 0; j < half; j++ )
- {
- *d ++ = *Y ++;
- *d ++ = *u ++;
- *d ++ = *Y ++;
- *d ++ = *v ++;
- }
- }
- return ret;
-}
-
-void mlt_resize_yuv422( uint8_t *output, int owidth, int oheight, uint8_t *input, int iwidth, int iheight )
-{
- // Calculate strides
- int istride = iwidth * 2;
- int ostride = owidth * 2;
-
- iwidth = iwidth - ( iwidth % 4 );
- owidth = owidth - ( owidth % 4 );
- iheight = iheight - ( iheight % 2 );
- oheight = oheight - ( oheight % 2 );
-
- // Optimisation point
- if ( iwidth == owidth && iheight == oheight )
- memcpy( output, input, iheight * istride );
-
- // Coordinates (0,0 is middle of output)
- int y;
-
- // Calculate ranges
- int out_x_range = owidth / 2;
- int out_y_range = oheight / 2;
- int in_x_range = iwidth / 2 < out_x_range ? iwidth / 2 : out_x_range;
- int in_y_range = iheight / 2 < out_y_range ? iheight / 2 : out_y_range;
-
- // Output pointers
- uint8_t *out_line = output;
- uint8_t *out_ptr = out_line;
-
- // Calculate a middle and possibly invalid pointer in the input
- uint8_t *in_middle = input + istride * ( iheight / 2 ) + ( iwidth / 2 ) * 2;
- int in_line = - in_y_range * istride - in_x_range * 2;
-
- int elements;
-
- // Fill whole section with black
- y = out_y_range - ( iheight / 2 );
- int blank_elements = ostride * y / 2;
- elements = blank_elements;
- while ( elements -- )
- {
- *out_line ++ = 16;
- *out_line ++ = 128;
- }
-
- int active_width = 2 * iwidth;
- int inactive_width = out_x_range - in_x_range;
- uint8_t *p = NULL;
- uint8_t *end = NULL;
-
- // Loop for the entirety of our output height.
- while ( iheight -- )
- {
- // Start at the beginning of the line
- out_ptr = out_line;
-
- // Fill the outer part with black
- elements = inactive_width;
- while ( elements -- )
- {
- *out_ptr ++ = 16;
- *out_ptr ++ = 128;
- }
-
- // We're in the input range for this row.
- p = in_middle + in_line;
- end = out_ptr + active_width;
- while ( out_ptr != end )
- {
- *out_ptr ++ = *p ++;
- *out_ptr ++ = *p ++;
- }
-
- // Fill the outer part with black
- elements = inactive_width;
- while ( elements -- )
- {
- *out_ptr ++ = 16;
- *out_ptr ++ = 128;
- }
-
- // Move to next input line
- in_line += istride;
-
- // Move to next output line
- out_line += ostride;
- }
-
- // Fill whole section with black
- elements = blank_elements;
- while ( elements -- )
- {
- *out_line ++ = 16;
- *out_line ++ = 128;
- }
-}
-
-/** A resizing function for yuv422 frames - this does not rescale, but simply
- resizes. It assumes yuv422 images available on the frame so use with care.
-*/
-
-uint8_t *mlt_frame_resize_yuv422( mlt_frame this, int owidth, int oheight )
-{
- // Get properties
- mlt_properties properties = mlt_frame_properties( this );
-
- // Get the input image, width and height
- uint8_t *input = mlt_properties_get_data( properties, "image", NULL );
- int iwidth = mlt_properties_get_int( properties, "width" );
- int iheight = mlt_properties_get_int( properties, "height" );
-
- // If width and height are correct, don't do anything
- if ( iwidth != owidth || iheight != oheight )
- {
- // Create the output image
- uint8_t *output = mlt_pool_alloc( owidth * ( oheight + 1 ) * 2 );
-
- // Call the generic resize
- mlt_resize_yuv422( output, owidth, oheight, input, iwidth, iheight );
-
- // Now update the frame
- mlt_properties_set_data( properties, "image", output, owidth * ( oheight + 1 ) * 2, ( mlt_destructor )mlt_pool_release, NULL );
- mlt_properties_set_int( properties, "width", owidth );
- mlt_properties_set_int( properties, "height", oheight );
-
- // Return the output
- return output;
- }
- // No change, return input
- return input;
-}
-
-/** A rescaling function for yuv422 frames - low quality, and provided for testing
- only. It assumes yuv422 images available on the frame so use with care.
-*/