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 796846 - compositor: Use 255 as maximum alpha instead of 256
compositor: Use 255 as maximum alpha instead of 256
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
unspecified
Other All
: Normal normal
: 1.14.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-07-20 13:27 UTC by Sebastian Dröge (slomo)
Modified: 2018-07-25 13:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
compositor: Use 255 as maximum alpha instead of 256 (3.15 KB, patch)
2018-07-20 13:27 UTC, Sebastian Dröge (slomo)
none Details | Review
compositor: Use 255 as maximum alpha instead of 256 (3.08 KB, patch)
2018-07-23 08:25 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Sebastian Dröge (slomo) 2018-07-20 13:27:13 UTC
See commit message
Comment 1 Sebastian Dröge (slomo) 2018-07-20 13:27:17 UTC
Created attachment 373108 [details] [review]
compositor: Use 255 as maximum alpha instead of 256

255 will easily become 0 in the blending function as they expect
the maximum value to be 255.

Can be reproduce with

gst-launch-1.0 videotestsrc pattern=ball ! c.sink_0 \
               videotestsrc pattern=snow ! c.sink_1 \
               compositor name=c \
                 sink_0::zorder=0 sink_1::zorder=1 sink_0::crossfade-ratio=0.5 \
                 background=black ! \
               videoconvert ! xvimagesink

crossfade-ratio +/- 0.001 makes it work correctly and the same happens
at e.g. 0.25, 0.75, N*0.0625
Comment 2 Thibault Saunier 2018-07-21 20:09:01 UTC
Review of attachment 373108 [details] [review]:

That makes sense, but then, this bug should be trigerable without using crossfade-ratio too right?
Comment 3 Jan Schmidt 2018-07-22 11:35:09 UTC
Review of attachment 373108 [details] [review]:

Looks good to me, except:

::: gst/compositor/blend.c
@@ +34,3 @@
 #include <gst/video/video.h>
 
+#define BLEND(D,S,alpha) (((D) * (255 - (alpha)) + (S) * (alpha)) >> 8)

If your multiplier here is 255, you should divide by 255, not 256.

On 2nd look though, this macro isn't used anywhere and can just be deleted.
Comment 4 Sebastian Dröge (slomo) 2018-07-23 08:25:28 UTC
Created attachment 373120 [details] [review]
compositor: Use 255 as maximum alpha instead of 256

255 will easily become 0 in the blending function as they expect
the maximum value to be 255.

Can be reproduce with

gst-launch-1.0 videotestsrc pattern=ball ! c.sink_0 \
               videotestsrc pattern=snow ! c.sink_1 \
               compositor name=c \
                 sink_0::zorder=0 sink_1::zorder=1 sink_0::crossfade-ratio=0.5 \
                 background=black ! \
               videoconvert ! xvimagesink

crossfade-ratio +/- 0.001 makes it work correctly and the same happens
at e.g. 0.25, 0.75, N*0.0625
Comment 5 Sebastian Dröge (slomo) 2018-07-23 08:26:46 UTC
(In reply to Jan Schmidt from comment #3)
> 
> On 2nd look though, this macro isn't used anywhere and can just be deleted.

Done, removed :)

(In reply to Thibault Saunier from comment #2)
> Review of attachment 373108 [details] [review] [review]:
> 
> That makes sense, but then, this bug should be trigerable without using
> crossfade-ratio too right?

Probably, I didn't try very hard though. You basically would need to get alpha of 256 in the C code before passing it to orc, which happens more easily with crossfading because there you have two alphas that are individually controllable
Comment 6 Sebastian Dröge (slomo) 2018-07-23 08:32:59 UTC
https://bugzilla.gnome.org/show_bug.cgi?id=746247 is related to this
Comment 7 Sebastian Dröge (slomo) 2018-07-24 07:27:09 UTC
Attachment 373120 [details] pushed as b0ae6a5 - compositor: Use 255 as maximum alpha instead of 256