/***** convenience functions *****/
+int mlt_convert_yuv422_to_rgb24a( uint8_t *yuv, uint8_t *rgba, unsigned int total )
+{
+ int ret = 0;
+ int yy, uu, vv, ug_plus_vg, ub, vr;
+ int r,g,b;
+ total /= 2;
+ while (total--)
+ {
+ yy = yuv[0] << 8;
+ uu = yuv[1] - 128;
+ vv = yuv[3] - 128;
+ ug_plus_vg = uu * 88 + vv * 183;
+ ub = uu * 454;
+ vr = vv * 359;
+ r = (yy + vr) >> 8;
+ g = (yy - ug_plus_vg) >> 8;
+ b = (yy + ub) >> 8;
+ rgba[0] = r < 0 ? 0 : (r > 255 ? 255 : (unsigned char)r);
+ rgba[1] = g < 0 ? 0 : (g > 255 ? 255 : (unsigned char)g);
+ rgba[2] = b < 0 ? 0 : (b > 255 ? 255 : (unsigned char)b);
+ rgba[3] = 255;
+ yy = yuv[2] << 8;
+ r = (yy + vr) >> 8;
+ g = (yy - ug_plus_vg) >> 8;
+ b = (yy + ub) >> 8;
+ rgba[4] = r < 0 ? 0 : (r > 255 ? 255 : (unsigned char)r);
+ rgba[5] = g < 0 ? 0 : (g > 255 ? 255 : (unsigned char)g);
+ rgba[6] = b < 0 ? 0 : (b > 255 ? 255 : (unsigned char)b);
+ rgba[7] = 255;
+ yuv += 4;
+ rgba += 8;
+ }
+ return ret;
+}
+
int mlt_convert_rgb24a_to_yuv422( uint8_t *rgba, int width, int height, int stride, uint8_t *yuv, uint8_t *alpha )
{
int ret = 0;
extern void mlt_frame_close( mlt_frame self );
/* convenience functions */
+extern int mlt_convert_yuv422_to_rgb24a( uint8_t *yuv, uint8_t *rgba, unsigned int total );
extern int mlt_convert_rgb24a_to_yuv422( uint8_t *rgba, int width, int height, int stride, uint8_t *yuv, uint8_t *alpha );
extern int mlt_convert_rgb24_to_yuv422( uint8_t *rgb, int width, int height, int stride, uint8_t *yuv );
extern int mlt_convert_bgr24a_to_yuv422( uint8_t *rgba, int width, int height, int stride, uint8_t *yuv, uint8_t *alpha );
static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index );
static void producer_close( mlt_producer parent );
+
mlt_producer producer_pixbuf_init( char *filename )
{
producer_pixbuf this = calloc( sizeof( struct producer_pixbuf_s ), 1 );
// The fault is not in the design of mlt, but in the implementation of the pixbuf producer...
if ( *buffer != NULL )
{
- // Clone the image and the alpha
- uint8_t *image_copy = mlt_pool_alloc( image_size );
- uint8_t *alpha_copy = mlt_pool_alloc( alpha_size );
- memcpy( image_copy, *buffer, image_size );
+ if ( *format == mlt_image_yuv422 || *format == mlt_image_yuv420p )
+ {
+ // Clone the image and the alpha
+ uint8_t *image_copy = mlt_pool_alloc( image_size );
+ uint8_t *alpha_copy = mlt_pool_alloc( alpha_size );
- // Copy or default the alpha
- if ( alpha != NULL )
- memcpy( alpha_copy, alpha, alpha_size );
- else
- memset( alpha_copy, 255, alpha_size );
+ memcpy( image_copy, *buffer, image_size );
- // Now update properties so we free the copy after
- mlt_properties_set_data( properties, "image", image_copy, image_size, mlt_pool_release, NULL );
- mlt_properties_set_data( properties, "alpha", alpha_copy, alpha_size, mlt_pool_release, NULL );
+ // Copy or default the alpha
+ if ( alpha != NULL )
+ memcpy( alpha_copy, alpha, alpha_size );
+ else
+ memset( alpha_copy, 255, alpha_size );
- // We're going to pass the copy on
- *buffer = image_copy;
+ // Now update properties so we free the copy after
+ mlt_properties_set_data( properties, "image", image_copy, image_size, mlt_pool_release, NULL );
+ mlt_properties_set_data( properties, "alpha", alpha_copy, alpha_size, mlt_pool_release, NULL );
+
+ // We're going to pass the copy on
+ *buffer = image_copy;
+ }
+ else if ( *format == mlt_image_rgb24a )
+ {
+ // Clone the image and the alpha
+ image_size = *width * ( *height + 1 ) * 4;
+ alpha_size = *width * ( *height + 1 );
+ uint8_t *image_copy = mlt_pool_alloc( image_size );
+ uint8_t *alpha_copy = mlt_pool_alloc( alpha_size );
+
+ mlt_convert_yuv422_to_rgb24a(*buffer, image_copy, (*width)*(*height));
+
+ // Now update properties so we free the copy after
+ mlt_properties_set_data( properties, "image", image_copy, image_size, mlt_pool_release, NULL );
+ mlt_properties_set_data( properties, "alpha", alpha_copy, alpha_size, mlt_pool_release, NULL );
+
+ // We're going to pass the copy on
+ *buffer = image_copy;
+ }
}
else
{
return 0;
}
+
static uint8_t *producer_get_alpha_mask( mlt_frame this )
{
// Obtain properties of frame