*format = output_format;
mlt_properties_set_data( properties, "image", output, size, mlt_pool_release, NULL );
mlt_properties_set_int( properties, "format", output_format );
+
+ if ( output_format == mlt_image_rgb24a || output_format == mlt_image_opengl )
+ {
+ register int len = width * height;
+ uint8_t *alpha = mlt_frame_get_alpha_mask( frame );
+
+ if ( alpha )
+ {
+ // Merge the alpha mask from into the RGBA image using Duff's Device
+ register uint8_t *s = alpha;
+ register uint8_t *d = *image + 3; // start on the alpha component
+ register int n = ( len + 7 ) / 8;
+
+ switch ( len % 8 )
+ {
+ case 0: do { *d = *s++; d += 4;
+ case 7: *d = *s++; d += 4;
+ case 6: *d = *s++; d += 4;
+ case 5: *d = *s++; d += 4;
+ case 4: *d = *s++; d += 4;
+ case 3: *d = *s++; d += 4;
+ case 2: *d = *s++; d += 4;
+ case 1: *d = *s++; d += 4;
+ }
+ while ( --n > 0 );
+ }
+ }
+ }
}
return error;
}
rgba[0] = r;
rgba[1] = g;
rgba[2] = b;
- rgba[3] = 255;
+ rgba[3] = *alpha++;
yy = yuv[2];
YUV2RGB_601( yy, uu, vv, r, g, b );
rgba[4] = r;
rgba[5] = g;
rgba[6] = b;
- rgba[7] = 255;
+ rgba[7] = *alpha++;
yuv += 4;
rgba += 8;
}
uint8_t *alpha = ( *format == mlt_image_rgb24a ||
*format == mlt_image_opengl )
? mlt_pool_alloc( width * height ) : NULL;
+ if ( requested_format == mlt_image_rgb24a || requested_format == mlt_image_opengl )
+ alpha = mlt_frame_get_alpha_mask( frame );
if ( !( error = converter( *buffer, image, alpha, width, height ) ) )
{
mlt_properties_set_data( properties, "image", image, size, mlt_pool_release, NULL );
- if ( alpha )
+ if ( alpha && ( *format == mlt_image_rgb24a || *format == mlt_image_opengl ) )
mlt_properties_set_data( properties, "alpha", alpha, width * height, mlt_pool_release, NULL );
*buffer = image;
*format = requested_format;