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 666090 - videoconvert: Add support for GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA
videoconvert: Add support for GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-12-13 14:52 UTC by Sebastian Dröge (slomo)
Modified: 2018-11-03 11:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Sebastian Dröge (slomo) 2011-12-13 14:52:08 UTC
Currently only non-premultiplied alpha is supported. I'd add it by adding new variants of all the video formats with alpha and adding a new flag to GstVideoFormatFlags.

Adding it to GstVideoColorimetry is probably not enough because that is not negotiable currently
Comment 1 Sebastian Dröge (slomo) 2013-07-17 13:08:58 UTC
There's GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA now
Comment 2 Tim-Philipp Müller 2013-07-17 13:23:59 UTC
> There's GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA now

Is that enough? It's not even used anywhere apart from the video overlay code - at least videoconvert etc. would need to be able to handle it (or the packing/unpacking funcs in libgstvideo).
Comment 3 Wim Taymans 2015-03-20 09:00:23 UTC
video-convert should use premultiplied alpha when doing scaling or else you can get wrong colors from neighbouring pixels with 0 alpha.

video-convert should therefore look at the input video-info flags and premultiply before scaling if needed, then look at the output flags and unpremultiply if needed.

We don't have anything in the caps to mark premultiplied alpha.
Comment 4 Sebastian Dröge (slomo) 2015-03-20 09:14:39 UTC
Premultiplying and then unpremultiplying will reduce the precision of the color components though, in the worst case leaving everything black. Or for AYUV, green :)
Comment 5 Sebastian Dröge (slomo) 2015-03-20 09:15:12 UTC
And first premultiplying and then unpremultiplying whenever we scale seems quite expensive.
Comment 6 Wim Taymans 2015-03-20 09:23:47 UTC
at a bare minimum we should zero out all color with 0 alpha to make sure whatever random color is in there doesn't get used when interpolating.
Comment 7 Sebastian Dröge (slomo) 2015-03-20 09:40:11 UTC
Yeah, I see what you mean :) It would give better results if the alpha is preserved, but if something is modifying only the alpha later (videoconvert to a non-alpha format!) you would lose colors. And it also seems to require more CPU to modify the colors.

All options seem not great :)
Comment 8 Nicolas Dufresne (ndufresne) 2015-03-20 12:48:28 UTC
A compromise could be to allocate an extra buffer, in which we store the pre-multiplied colors. This way we can reference the original and the premultiplied colors as needed to maintain precision. And we don't need to "unmultiply" at the end.
Comment 9 GStreamer system administrator 2018-11-03 11:20:02 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/56.