summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2018-07-20 16:25:02 +0300
committerSebastian Dröge <sebastian@centricular.com>2018-07-23 18:59:33 +0300
commitb0ae6a522186d5c123612eedc847b04eeeed6b65 (patch)
treeb83e496baaf37e7885209a2f5cd298e72e2a09a6 /gst
parent14ab3972ef46ae6c36c975254875cb8bd65848c5 (diff)
compositor: Use 255 as maximum alpha instead of 256
255 will easily become 0 in the blending function as they expect the maximum value to be 255. Can be reproduce with gst-launch-1.0 videotestsrc pattern=ball ! c.sink_0 \ videotestsrc pattern=snow ! c.sink_1 \ compositor name=c \ sink_0::zorder=0 sink_1::zorder=1 sink_0::crossfade-ratio=0.5 \ background=black ! \ videoconvert ! xvimagesink crossfade-ratio +/- 0.001 makes it work correctly and the same happens at e.g. 0.25, 0.75, N*0.0625 https://bugzilla.gnome.org/show_bug.cgi?id=796846
Diffstat (limited to 'gst')
-rw-r--r--gst/compositor/blend.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/gst/compositor/blend.c b/gst/compositor/blend.c
index b36c16465..416f78cfb 100644
--- a/gst/compositor/blend.c
+++ b/gst/compositor/blend.c
@@ -33,8 +33,6 @@
#include <gst/video/video.h>
-#define BLEND(D,S,alpha) (((D) * (256 - (alpha)) + (S) * (alpha)) >> 8)
-
GST_DEBUG_CATEGORY_STATIC (gst_compositor_blend_debug);
#define GST_CAT_DEFAULT gst_compositor_blend_debug
@@ -61,7 +59,7 @@ method##_ ##name (GstVideoFrame * srcframe, gint xpos, gint ypos, \
dest_width = GST_VIDEO_FRAME_COMP_WIDTH (destframe, 0); \
dest_height = GST_VIDEO_FRAME_COMP_HEIGHT (destframe, 0); \
\
- s_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \
+ s_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255); \
\
/* If it's completely transparent... we just return */ \
if (G_UNLIKELY (s_alpha == 0)) \
@@ -247,7 +245,7 @@ _blend_##format_name (const guint8 * src, guint8 * dest, \
return; \
} \
\
- b_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \
+ b_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255); \
\
BLENDLOOP(dest, dest_stride, src, src_stride, b_alpha, src_width, src_height);\
} \
@@ -492,7 +490,7 @@ _blend_##format_name (const guint8 * src, guint8 * dest, \
return; \
} \
\
- b_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \
+ b_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255); \
\
BLENDLOOP(dest, dest_stride, src, src_stride, b_alpha, src_width, src_height); \
} \
@@ -691,7 +689,7 @@ blend_##name (GstVideoFrame * srcframe, gint xpos, gint ypos, \
src_stride = GST_VIDEO_FRAME_COMP_STRIDE (srcframe, 0); \
dest_stride = GST_VIDEO_FRAME_COMP_STRIDE (destframe, 0); \
\
- b_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \
+ b_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255); \
\
/* adjust src pointers for negative sizes */ \
if (xpos < 0) { \
@@ -857,7 +855,7 @@ blend_##name (GstVideoFrame * srcframe, gint xpos, gint ypos, \
src_stride = GST_VIDEO_FRAME_COMP_STRIDE (srcframe, 0); \
dest_stride = GST_VIDEO_FRAME_COMP_STRIDE (destframe, 0); \
\
- b_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \
+ b_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255); \
\
xpos = GST_ROUND_UP_2 (xpos); \
\