video: overlay-composition: fix rectangle caching after alpha (un)premultiplying
authorHolger Kaelberer <hk@getslash.de>
Wed, 14 Mar 2012 17:28:57 +0000 (17:28 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Wed, 14 Mar 2012 18:04:38 +0000 (18:04 +0000)
If we are asked to (un)premultiply,we need to create the new rectangle
with the right flags, so we can find it properly on subsequent cache
lookups (also because it's wrong otherwise).

https://bugzilla.gnome.org/show_bug.cgi?id=668483

gst-libs/gst/video/video-overlay-composition.c

index 8c6ebb2..73641ea 100644 (file)
@@ -908,6 +908,7 @@ gst_video_overlay_rectangle_get_pixels_argb_internal (GstVideoOverlayRectangle *
     rectangle, guint * stride, GstVideoOverlayFormatFlags flags,
     gboolean unscaled)
 {
+  GstVideoOverlayFormatFlags new_flags;
   GstVideoOverlayRectangle *scaled_rect = NULL;
   GstBlendVideoFormatInfo info;
   GstBuffer *buf;
@@ -960,11 +961,14 @@ gst_video_overlay_rectangle_get_pixels_argb_internal (GstVideoOverlayRectangle *
     info.pixels = g_memdup (info.pixels, info.size);
   }
 
+  new_flags = rectangle->flags;
   if (!gst_video_overlay_rectangle_is_same_alpha_type (rectangle->flags, flags)) {
     if (rectangle->flags & GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA) {
       gst_video_overlay_rectangle_unpremultiply (&info);
+      new_flags &= ~GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA;
     } else {
       gst_video_overlay_rectangle_premultiply (&info);
+      new_flags |= GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA;
     }
   }
 
@@ -975,7 +979,7 @@ gst_video_overlay_rectangle_get_pixels_argb_internal (GstVideoOverlayRectangle *
 
   scaled_rect = gst_video_overlay_rectangle_new_argb (buf,
       wanted_width, wanted_height, info.stride[0],
-      0, 0, wanted_width, wanted_height, rectangle->flags);
+      0, 0, wanted_width, wanted_height, new_flags);
 
   gst_buffer_unref (buf);