]> git.sesse.net Git - ffmpeg/commitdiff
librsvgdec: Fix frame clearing code
authorCalvin Walton <calvin.walton@kepstin.ca>
Thu, 1 Feb 2018 18:28:25 +0000 (13:28 -0500)
committerRostislav Pehlivanov <atomnuker@gmail.com>
Fri, 2 Feb 2018 15:36:21 +0000 (15:36 +0000)
The existing code attempts to clear the frame by painting in OVER
mode with transparent black - which is a no-op. As a result if you
have many input frames (e.g. you're using a sequence of svg files),
you'll start to see new frames drawn over old frames as memory gets
re-used.

Switch the code to paint using the CLEAR compositing operator,
which fills every channel with 0 values (setting a source colour
is not required).

libavcodec/librsvgdec.c

index e57070f8e44ec36b9c6c175eb1075337b2d712ef..66977850261f98d7f9f779f3774601b00b3d9866 100644 (file)
@@ -82,8 +82,10 @@ static int librsvg_decode_frame(AVCodecContext *avctx, void *data, int *got_fram
 
     crender = cairo_create(image);
 
-    cairo_set_source_rgba(crender, 0.0, 0.0, 0.0, 1.0f);
-    cairo_paint_with_alpha(crender, 0.0f);
+    cairo_save(crender);
+    cairo_set_operator(crender, CAIRO_OPERATOR_CLEAR);
+    cairo_paint(crender);
+    cairo_restore(crender);
 
     cairo_scale(crender, dimensions.width / (double)unscaled_dimensions.width,
                 dimensions.height / (double)unscaled_dimensions.height);