Skip to content

Commit

Permalink
Fix cairo mixers second image bleeding.
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
ddennedy committed Nov 18, 2015
1 parent 129eeac commit 6380841
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion include/frei0r_cairo.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,18 @@ 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 ) {
register unsigned char a = rgba[3];
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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/mixer2/cairoaffineblend/cairoaffineblend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions src/mixer2/cairoblend/cairoblend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 6380841

Please sign in to comment.