mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 20:42:30 +00:00
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
This commit is contained in:
parent
14ab3972ef
commit
b0ae6a5221
1 changed files with 5 additions and 7 deletions
|
@ -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); \
|
||||
\
|
||||
|
|
Loading…
Reference in a new issue