After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 681447 - video overlay composition: fix video blending over transparent frame
video overlay composition: fix video blending over transparent frame
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: 1.7.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 708882 739695 (view as bug list)
Depends on:
Blocks: 708411 709140
 
 
Reported: 2012-08-08 12:55 UTC by Arnaud Vrac
Modified: 2015-11-04 21:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
blending fix patch (5.13 KB, patch)
2012-08-08 12:55 UTC, Arnaud Vrac
needs-work Details | Review
video: blend using OVER operation (7.55 KB, patch)
2013-11-30 01:31 UTC, Arnaud Vrac
none Details | Review
unit test for video blending over transparent frame (3.24 KB, patch)
2014-11-10 10:18 UTC, Andreas Frisch
none Details | Review
https://bug708882.bugzilla-attachments.gnome.org/attachment.cgi?id=255889 (632 bytes, patch)
2015-07-27 13:38 UTC, Alex Băluț
rejected Details | Review
video: blend using OVER operation (7.55 KB, patch)
2015-10-22 10:00 UTC, Thibault Saunier
committed Details | Review
unit test for video blending over transparent frame, refs https://bugzilla.gnome.org/show_bug.cgi?id=681447 (2.72 KB, patch)
2015-10-22 10:01 UTC, Thibault Saunier
committed Details | Review

Description Arnaud Vrac 2012-08-08 12:55:12 UTC
Created attachment 220668 [details] [review]
blending fix patch

The gst_video_blend function does not work as expected when blending over transparent pixels, the destination alpha is not changed currently.

The attached patch implements standard OVER blending operation, and adds support for missing premultiplied/non-premultiplied combinations for source/destination frames.
Comment 1 Tim-Philipp Müller 2012-08-08 13:13:57 UTC
Any chance you could add unit test bits for this as well?
Comment 2 Tim-Philipp Müller 2012-11-14 23:43:11 UTC
Comment on attachment 220668 [details] [review]
blending fix patch

According to comments on IRC this patch is not quite right yet.
Comment 3 Thibault Saunier 2013-10-30 15:47:07 UTC
*** Bug 708882 has been marked as a duplicate of this bug. ***
Comment 4 Thibault Saunier 2013-10-30 15:49:33 UTC
It would be very interesting to know what has been said on IRC about why this patch is not right yet :)
Comment 5 Tim-Philipp Müller 2013-10-30 16:05:03 UTC
No details just

  rawoul: __tim: https://bugzilla.gnome.org/show_bug.cgi?id=681447, the patch is actually wrong...
  rawoul: sorry I haven't tested properly...

Arnaud - do you remember?
Comment 6 Arnaud Vrac 2013-11-30 01:31:47 UTC
Created attachment 263194 [details] [review]
video: blend using OVER operation

This version should work in all cases. Hopefully the compiler can optimize some cases, for example when the global alpha is 255, it should remove all the * 255 / 255 in the code...

I'm not sure how orc could be used properly here, maybe it would be easier to apply the global alpha first on the source line if needed, and then do the blending. The non-premultiplied to non-premultiplied orc blending function can be copied from videomixer, and the other versions can be adapted from there.
Comment 7 Nicolas Dufresne (ndufresne) 2013-11-30 02:19:21 UTC
I pretty sure the compiler won't be able to do that. Performance whise, this code is pretty terrible, but as it did not work in most cases before, I'll all for it. Unit tests would be nice.
Comment 8 Arnaud Vrac 2013-11-30 02:37:19 UTC
Yes, the code is probably not very fast :) However, in the new code, no operation is done when the source pixel has zero alpha, so it's probably faster than the previous code since most overlays have a lot of transparent pixels.
Comment 9 Sebastian Dröge (slomo) 2014-04-02 21:37:17 UTC
Comment on attachment 263194 [details] [review]
video: blend using OVER operation

Looks good except for the performance... maybe think about optimising it a bit ;)

But apart from that I think it's good to be merged once you provide a unit test.
Comment 10 Thibault Saunier 2014-09-27 22:16:18 UTC
Ping? :)
Comment 11 Tim-Philipp Müller 2014-11-09 14:13:00 UTC
*** Bug 739695 has been marked as a duplicate of this bug. ***
Comment 12 Andreas Frisch 2014-11-10 10:18:29 UTC
Created attachment 290325 [details] [review]
unit test for video blending over transparent frame

basically blending a 100x50 white (0xFF) box in the right half of a 200x50 transparent (0x00) frame and checking to see whether the alpha byte is set to 0xFF.
without this patch, the alpha byte stays 0x00 and thus the test will fail.
Comment 13 Sebastian Dröge (slomo) 2014-11-10 10:19:53 UTC
Note that this basically converts ARGB to xRGB and makes all frames opaque. Not sure if that is generally the expected behaviour.
Comment 14 Andreas Frisch 2014-11-10 10:25:26 UTC
this is just how assrender does it, too.
Comment 15 Thibault Saunier 2014-11-27 15:28:19 UTC
(In reply to comment #13)
> Note that this basically converts ARGB to xRGB and makes all frames opaque. Not
> sure if that is generally the expected behaviour.

This is clearly not what we expect. In GES we have:

   videotestsrc ! video/x-raw,format=ARGB ! textoverlay ! ....

to create title clips and we definitely want the output of textoverlay to also be ARGB in that case so that it is transparent when mixed with the compositor downstream.
Comment 16 Alex Băluț 2015-07-27 01:43:59 UTC
Is the patch in bug 708882 is correct? https://bugzilla.gnome.org/attachment.cgi?id=255889&action=diff
Comment 17 Nicolas Dufresne (ndufresne) 2015-07-27 12:47:19 UTC
(In reply to Alex Băluț from comment #16)
> Is the patch in bug 708882 is correct?
> https://bugzilla.gnome.org/attachment.cgi?id=255889&action=diff

Patch does not have enough context line for me to confirm now. I'll have to look at where is "alpha" computed. Just bring that patch over here, and we'll try and sort out. To all, remember that colors are premultiplied by their alpha.
Comment 18 Alex Băluț 2015-07-27 13:38:41 UTC
Created attachment 308218 [details] [review]
https://bug708882.bugzilla-attachments.gnome.org/attachment.cgi?id=255889

This is Mathieu's patch to be discussed whether it makes sense.
Comment 19 Thibault Saunier 2015-10-22 10:00:57 UTC
Created attachment 313852 [details] [review]
video: blend using OVER operation

Also support all premultiplied/non-premultiplied source/destination
configurations
Comment 20 Thibault Saunier 2015-10-22 10:01:04 UTC
Created attachment 313853 [details] [review]
unit test for video blending over transparent frame, refs https://bugzilla.gnome.org/show_bug.cgi?id=681447
Comment 21 Thibault Saunier 2015-10-22 10:01:59 UTC
Just rebased arnaud's patches.

We really need that bug to be fixed in Pitivi, it looks like those patches are correct even though they deserve some optimization.
Comment 22 Alex Băluț 2015-11-04 20:37:18 UTC
Review of attachment 308218 [details] [review]:

See https://bugzilla.gnome.org/show_bug.cgi?id=708882#c3 why it's not good.
Comment 23 Thibault Saunier 2015-11-04 21:22:12 UTC
Attachment 313852 [details] pushed as dfe250d - video: blend using OVER operation