Hi. I recently acknowledged Kdenlive issue 2708 (bug in composite transition opacity): http://www.kdenlive.org/mantis/view.php?id=2708
Quite surprising, but there really is a problem with alpha calculation (using the non SSE version). The problem can be reproduced with the following command: melt noise: -track color:#a1a1a1 -transition composite progressive=1 in=0 out=0 -consumer avformat:bug.png f=image2 progressive=1 If you open the bug.png image and modify the contrast with an image editor (using levels for example), you will see that the noise effect is slightly visible which should not be the case. You can see the resulting image here: http://kdenlive.org/images/bug2708_levels.png (I increased the contrast, original untouched rendering is at http://kdenlive.org/images/bug2708.png ). Looking at the code, I was able to fix the problem (restore full opacity) with the patch below. Basically, I adjusted the alpha value so that the maximum goes to 256 and not 255, same for weight that should go up to 65536. So in our case - when there is no luma file and alpha is full opacity (255), the mix calculation which is basically: ( weight * alpha ) >> 8 gives a result of 256 That way, the sample_mix calculating the new pixel which is: ( src * mix + dest * ( ( 1 << 16 ) - mix ) ) >> 16; Correctly returns src without any trace of dest. My patch fixes the original issue, but I am not an expert in those logical operations, so waiting for your feedback. regards jb diff --git a/src/modules/core/transition_composite.c b/src/modules/core/transition_composite.c index 49d01f5..5aca27a 100644 --- a/src/modules/core/transition_composite.c +++ b/src/modules/core/transition_composite.c @@ -355,7 +355,7 @@ static void luma_read_yuv422( uint8_t *image, uint16_t **map, int width, int hei static inline int calculate_mix( uint16_t *luma, int j, int softness, int weight, int alpha, uint32_t step ) { - return ( ( luma ? smoothstep( luma[ j ], luma[ j ] + softness, step ) : weight ) * alpha ) >> 8; + return ( ( luma ? smoothstep( luma[ j ], luma[ j ] + softness, step ) : weight ) * ( alpha + 1 ) ) >> 8; } static inline uint8_t sample_mix( uint8_t dest, uint8_t src, int mix ) @@ -460,7 +460,7 @@ static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, uint int stride_src = geometry.sw * bpp; int stride_dest = width_dest * bpp; int i_softness = ( 1 << 16 ) * softness; - int weight = ( ( ( 1 << 16 ) - 1 ) * geometry.item.mix + 50 ) / 100; + int weight = ( ( ( 1 << 16 ) ) * geometry.item.mix + 50 ) / 100; uint32_t luma_step = ( ( ( 1 << 16 ) - 1 ) * geometry.item.mix + 50 ) / 100 * ( 1.0 + softness ); // Adjust to consumer scale ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Mlt-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mlt-devel
