Draft: Fix handling of alpha when using luma file - #1276
Open
j-b-m wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
Hmm don't know how but it's only now that I realize that there is an issue with my change, bottom left part of the blue triangle is missing.. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the core luma transition implementation to make alpha handling consistent when a luma file is used, by ensuring the luma-based compositing path respects the alpha_over setting instead of implicitly behaving as if alpha_over were enabled.
Changes:
- Add an
alpha_overparameter to the luma compositing functions (YUV422/RGBA32/RGBA64) and thread it throughtransition_get_image. - Gate the “alpha-over” normalization/alpha-channel updates in the luma compositing loops behind
alpha_over.
Comments suppressed due to low confidence (1)
src/modules/core/transition_luma.c:438
- In the translucent+YUV422 luma path, the alpha pointers are advanced linearly across pixels (immediately after this block) but are not re-based per row/field or adjusted for differing src/dst row strides. If frames are interlaced (
field_count=2) or src/dst dimensions differ, alpha reads/writes can become misaligned and produce incorrect alpha output.
}
*q = sample_mix(*q, *p++, mix_b);
q++;
Comment on lines
+424
to
+435
| mix_a = calculate_mix(1.0f - value, alpha_dest ? *alpha_dest : 255); | ||
| if (invert && alpha_src) { | ||
| float mix2 = mix_b + mix_a; | ||
| *alpha_src = 255 * mix2; | ||
| if (mix2 != 0.f) | ||
| mix_b /= mix2; | ||
| } else if (!invert && alpha_dest) { | ||
| float mix2 = mix_b + mix_a; | ||
| *alpha_dest = 255 * mix2; | ||
| if (mix2 != 0.f) | ||
| mix_b /= mix2; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the luma transition behaves differently when using a luma file or not on images with an alpha channel. When a luma file is used, it always behaves as if alpha_over was enabled. Here are some screenshot comparing a transition between 2 images of triangles with a transparent background. Each image below contains 4 different cases:
Frame 0: only first image is visible (red triangle in top right corner):
Last frame of the transition, you can see the behavior difference when a luma is used or not (bottom left should be similar to top left):
With the changes in this merge request, the result is now as expected:
The only question is do we want to maintain backwards compatibility, and how ?
Feedback is welcome.