summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Dennedy <dan@dennedy.org>2015-11-18 06:23:09 (GMT)
committer Dan Dennedy <dan@dennedy.org>2015-11-18 06:23:09 (GMT)
commit63808414a36882b8bdd397aa24d5f61450151c4c (patch)
tree8da728308facb6f576f3c026df7c84967939c2bd
parent129eeac85fb5a992dfb20c79192848795082ba75 (diff)
Fix cairo mixers second image bleeding.
The second image would appear as the background into tranparent areas of the first image. See MLT bug: https://sourceforge.net/p/mlt/bugs/234/
-rw-r--r--include/frei0r_cairo.h4
-rw-r--r--src/mixer2/cairoaffineblend/cairoaffineblend.c4
-rw-r--r--src/mixer2/cairoblend/cairoblend.c4
3 files changed, 7 insertions, 5 deletions
diff --git a/include/frei0r_cairo.h b/include/frei0r_cairo.h
index c4e9eaf..cffbb0b 100644
--- a/include/frei0r_cairo.h
+++ b/include/frei0r_cairo.h
@@ -225,9 +225,10 @@ double frei0r_cairo_get_scale (double norm_scale)
*
* \param rgba the image buffer with format F0R_COLOR_MODEL_RGBA8888
* \param pixels the size of the image buffer in number of pixels
+ * \param alpha if >= 0, the alpha channel will be set to this value
* \see frei0r_cairo_unpremultiply_rgba
*/
-void frei0r_cairo_premultiply_rgba (unsigned char *rgba, int pixels)
+void frei0r_cairo_premultiply_rgba (unsigned char *rgba, int pixels, int alpha)
{
int i = pixels + 1;
while ( --i ) {
@@ -235,6 +236,7 @@ void frei0r_cairo_premultiply_rgba (unsigned char *rgba, int pixels)
rgba[0] = ( rgba[0] * a ) >> 8;
rgba[1] = ( rgba[1] * a ) >> 8;
rgba[2] = ( rgba[2] * a ) >> 8;
+ if (alpha >= 0) rgba[3] = alpha;
rgba += 4;
}
}
diff --git a/src/mixer2/cairoaffineblend/cairoaffineblend.c b/src/mixer2/cairoaffineblend/cairoaffineblend.c
index 390e50e..3a77f0a 100644
--- a/src/mixer2/cairoaffineblend/cairoaffineblend.c
+++ b/src/mixer2/cairoaffineblend/cairoaffineblend.c
@@ -303,8 +303,8 @@ void f0r_update2(f0r_instance_t instance, double time, const uint32_t* inframe1,
unsigned char* out = (unsigned char*)outframe;
int pixels = inst->width * inst->height;
- frei0r_cairo_premultiply_rgba (src, pixels);
- frei0r_cairo_premultiply_rgba (dst, pixels);
+ frei0r_cairo_premultiply_rgba (src, pixels, 0xff);
+ frei0r_cairo_premultiply_rgba (dst, pixels, -1);
draw_composite (inst, out, src, dst, time);
frei0r_cairo_unpremultiply_rgba (out, pixels);
}
diff --git a/src/mixer2/cairoblend/cairoblend.c b/src/mixer2/cairoblend/cairoblend.c
index 51b0154..81eb385 100644
--- a/src/mixer2/cairoblend/cairoblend.c
+++ b/src/mixer2/cairoblend/cairoblend.c
@@ -185,8 +185,8 @@ void f0r_update2(f0r_instance_t instance, double time, const uint32_t* inframe1,
unsigned char* out = (unsigned char*)outframe;
int pixels = inst->width * inst->height;
- frei0r_cairo_premultiply_rgba (src, pixels);
- frei0r_cairo_premultiply_rgba (dst, pixels);
+ frei0r_cairo_premultiply_rgba (src, pixels, 0xff);
+ frei0r_cairo_premultiply_rgba (dst, pixels, -1);
draw_composite (inst, out, src, dst, time);
frei0r_cairo_unpremultiply_rgba (out, pixels);
}