videomixer: scale and clamp

Scale and clamp to the max alpha values.
This commit is contained in:
Wim Taymans 2009-12-24 22:59:09 +01:00 committed by Wim Taymans
parent 0620797a18
commit 4f9ded7742
4 changed files with 9 additions and 9 deletions

View file

@ -185,7 +185,7 @@ gst_videomixer_blend_ayuv_ayuv (guint8 * src, gint xpos, gint ypos,
gint src_width, gint src_height, gdouble src_alpha, gint src_width, gint src_height, gdouble src_alpha,
guint8 * dest, gint dest_width, gint dest_height) guint8 * dest, gint dest_width, gint dest_height)
{ {
gint alpha, b_alpha; gint alpha, s_alpha;
gint i, j; gint i, j;
gint src_stride, dest_stride; gint src_stride, dest_stride;
gint src_add, dest_add; gint src_add, dest_add;
@ -194,7 +194,7 @@ gst_videomixer_blend_ayuv_ayuv (guint8 * src, gint xpos, gint ypos,
src_stride = src_width * 4; src_stride = src_width * 4;
dest_stride = dest_width * 4; dest_stride = dest_width * 4;
b_alpha = (gint) (src_alpha * 255); s_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256);
/* adjust src pointers for negative sizes */ /* adjust src pointers for negative sizes */
if (xpos < 0) { if (xpos < 0) {
@ -222,7 +222,7 @@ gst_videomixer_blend_ayuv_ayuv (guint8 * src, gint xpos, gint ypos,
for (i = 0; i < src_height; i++) { for (i = 0; i < src_height; i++) {
for (j = 0; j < src_width; j++) { for (j = 0; j < src_width; j++) {
alpha = (src[0] * b_alpha) >> 8; alpha = (src[0] * s_alpha) >> 8;
BLEND_MODE (dest[1], dest[2], dest[3], src[1], src[2], src[3], BLEND_MODE (dest[1], dest[2], dest[3], src[1], src[2], src[3],
alpha, Y, U, V); alpha, Y, U, V);
dest[0] = 0xff; dest[0] = 0xff;
@ -254,7 +254,7 @@ gst_videomixer_blend_ayuv_ayuv_mmx (guint8 * src, gint xpos, gint ypos,
src_stride = src_width * 4; src_stride = src_width * 4;
dest_stride = dest_width * 4; dest_stride = dest_width * 4;
b_alpha = (gint) (src_alpha * 255); b_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255);
/* adjust src pointers for negative sizes */ /* adjust src pointers for negative sizes */
if (xpos < 0) { if (xpos < 0) {

View file

@ -32,7 +32,7 @@ gst_videomixer_blend_##name##_##name (guint8 * src, gint xpos, gint ypos, \
gint src_width, gint src_height, gdouble src_alpha, \ gint src_width, gint src_height, gdouble src_alpha, \
guint8 * dest, gint dest_width, gint dest_height) \ guint8 * dest, gint dest_width, gint dest_height) \
{ \ { \
gint alpha, b_alpha; \ gint alpha, s_alpha; \
gint i, j; \ gint i, j; \
gint src_stride, dest_stride; \ gint src_stride, dest_stride; \
gint src_add, dest_add; \ gint src_add, dest_add; \
@ -41,7 +41,7 @@ gst_videomixer_blend_##name##_##name (guint8 * src, gint xpos, gint ypos, \
src_stride = src_width * 4; \ src_stride = src_width * 4; \
dest_stride = dest_width * 4; \ dest_stride = dest_width * 4; \
\ \
b_alpha = (gint) (src_alpha * 255); \ s_alpha = CLAMP ((gint) (src_alpha * 256), 0, 256); \
\ \
/* adjust src pointers for negative sizes */ \ /* adjust src pointers for negative sizes */ \
if (xpos < 0) { \ if (xpos < 0) { \
@ -69,7 +69,7 @@ gst_videomixer_blend_##name##_##name (guint8 * src, gint xpos, gint ypos, \
\ \
for (i = 0; i < src_height; i++) { \ for (i = 0; i < src_height; i++) { \
for (j = 0; j < src_width; j++) { \ for (j = 0; j < src_width; j++) { \
alpha = (src[a] * b_alpha) >> 8; \ alpha = (src[a] * s_alpha) >> 8; \
BLEND_MODE (dest[b], dest[g], dest[r], src[b], src[g], src[r], \ BLEND_MODE (dest[b], dest[g], dest[r], src[b], src[g], src[r], \
B, G, R, alpha); \ B, G, R, alpha); \
dest[b] = B; \ dest[b] = B; \

View file

@ -209,7 +209,7 @@ gst_i420_do_blend (guint8 * src, guint8 * dest,
return; return;
} }
b_alpha = (gint) (src_alpha * 255); b_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255);
for (i = 0; i < src_height; i++) { for (i = 0; i < src_height; i++) {
for (j = 0; j < src_width; j++) { for (j = 0; j < src_width; j++) {

View file

@ -45,7 +45,7 @@ gst_videomixer_blend_##name##_##name (guint8 * src, gint xpos, gint ypos, \
src_stride = GST_ROUND_UP_4 (src_width * bpp); \ src_stride = GST_ROUND_UP_4 (src_width * bpp); \
dest_stride = GST_ROUND_UP_4 (dest_width * bpp); \ dest_stride = GST_ROUND_UP_4 (dest_width * bpp); \
\ \
b_alpha = (gint) (src_alpha * 255); \ b_alpha = CLAMP ((gint) (src_alpha * 255), 0, 255); \
\ \
/* adjust src pointers for negative sizes */ \ /* adjust src pointers for negative sizes */ \
if (xpos < 0) { \ if (xpos < 0) { \