- // Now update the frame
- mlt_properties_set_data( properties, "image", output, owidth * oheight * bpp, free, NULL );
- mlt_properties_set_int( properties, "width", owidth );
- mlt_properties_set_int( properties, "height", oheight );
-
- // Return the output
- *image = output;
+ // Extract YUV422 and alpha
+ if ( bpp == 4 )
+ {
+ // Allocate the alpha mask
+ uint8_t *alpha = mlt_pool_alloc( owidth * ( oheight + 1 ) );
+
+ // Convert the image and extract alpha
+ mlt_convert_rgb24a_to_yuv422( gdk_pixbuf_get_pixels( scaled ), owidth, oheight, gdk_pixbuf_get_rowstride( scaled ), output, alpha );
+
+ mlt_properties_set_data( properties, "alpha", alpha, owidth * ( oheight + 1 ), ( mlt_destructor )mlt_pool_release, NULL );
+ }
+ else
+ {
+ // No alpha to extract
+ mlt_convert_rgb24_to_yuv422( gdk_pixbuf_get_pixels( scaled ), owidth, oheight, gdk_pixbuf_get_rowstride( scaled ), output );
+ }
+ g_object_unref( scaled );
+ }
+ else
+ {
+ // Extract YUV422 and alpha
+ if ( bpp == 4 )
+ {
+ // Allocate the alpha mask
+ uint8_t *alpha = mlt_pool_alloc( owidth * ( oheight + 1 ) );
+
+ // Convert the image and extract alpha
+ mlt_convert_rgb24a_to_yuv422( *image, owidth, oheight, owidth * 4, output, alpha );
+
+ mlt_properties_set_data( properties, "alpha", alpha, owidth * ( oheight + 1 ), ( mlt_destructor )mlt_pool_release, NULL );
+ }
+ else
+ {
+ // No alpha to extract
+ mlt_convert_rgb24_to_yuv422( *image, owidth, oheight, owidth * 3, output );
+ }