Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 54 additions & 39 deletions src/modules/core/transition_luma.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ static void luma_composite_yuv422(mlt_frame a_frame,
int *width,
int *height,
int invert,
int fix_background_alpha)
int fix_background_alpha,
int alpha_over)
{
int width_src = *width, height_src = *height;
int width_dest = *width, height_dest = *height;
Expand Down Expand Up @@ -417,18 +418,21 @@ static void luma_composite_yuv422(mlt_frame a_frame,
while (j--) {
float weight = l[x_offset >> 16] / 65535.f;
float value = smoothstep_float(weight, softness + weight, field_pos[field]);
mix_a = calculate_mix(1.0f - value, alpha_dest ? *alpha_dest : 255);
mix_b = calculate_mix(value, alpha_src ? *alpha_src : 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;
if (alpha_over) {
// Alpha over-blending, source alpha will be passed to dest
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;
}
Comment thread
j-b-m marked this conversation as resolved.
Outdated
}
*q = sample_mix(*q, *p++, mix_b);
q++;
Expand Down Expand Up @@ -474,7 +478,8 @@ static int luma_composite_rgba32(mlt_frame a_frame,
int field_order,
int width,
int height,
int invert)
int invert,
int alpha_over)
{
if (mlt_properties_get(&a_frame->parent, "distort"))
mlt_properties_set(&b_frame->parent,
Expand Down Expand Up @@ -535,18 +540,21 @@ static int luma_composite_rgba32(mlt_frame a_frame,
while (j--) {
float weight = l[x_offset >> 16] / 65535.f;
float value = smoothstep_float(weight, softness + weight, field_pos[field]);
mix_a = calculate_mix(1.0f - value, q[3]);
mix_b = calculate_mix(value, p[3]);
if (invert) {
float mix2 = mix_b + mix_a;
q[3] = 255 * mix2;
if (mix2 != 0.f)
mix_b /= mix2;
} else {
float mix2 = mix_b + mix_a;
q[3] = 255 * mix2;
if (mix2 != 0.f)
mix_b /= mix2;
if (alpha_over) {
// Alpha over-blending, source alpha will be passed to dest
mix_a = calculate_mix(1.0f - value, q[3]);
if (invert) {
float mix2 = mix_b + mix_a;
q[3] = 255 * mix2;
if (mix2 != 0.f)
mix_b /= mix2;
} else {
float mix2 = mix_b + mix_a;
q[3] = 255 * mix2;
if (mix2 != 0.f)
mix_b /= mix2;
}
}
q[0] = sample_mix(q[0], p[0], mix_b);
q[1] = sample_mix(q[1], p[1], mix_b);
Expand Down Expand Up @@ -591,7 +599,8 @@ static int luma_composite_rgba64(mlt_frame a_frame,
int field_order,
int width,
int height,
int invert)
int invert,
int alpha_over)
{
if (mlt_properties_get(&a_frame->parent, "distort"))
mlt_properties_set(&b_frame->parent,
Expand Down Expand Up @@ -652,18 +661,21 @@ static int luma_composite_rgba64(mlt_frame a_frame,
while (j--) {
float weight = l[x_offset >> 16] / 65535.f;
float value = smoothstep_float(weight, softness + weight, field_pos[field]);
mix_a = calculate_mix_16(1.0f - value, q[3]);
mix_b = calculate_mix_16(value, p[3]);
if (invert) {
float mix2 = mix_b + mix_a;
q[3] = 65535 * mix2;
if (mix2 != 0.f)
mix_b /= mix2;
} else {
float mix2 = mix_b + mix_a;
q[3] = 65535 * mix2;
if (mix2 != 0.f)
mix_b /= mix2;
if (alpha_over) {
// Alpha over-blending, source alpha will be passed to dest
mix_a = calculate_mix_16(1.0f - value, q[3]);
if (invert) {
float mix2 = mix_b + mix_a;
q[3] = 65535 * mix2;
if (mix2 != 0.f)
mix_b /= mix2;
} else {
float mix2 = mix_b + mix_a;
q[3] = 65535 * mix2;
if (mix2 != 0.f)
mix_b /= mix2;
}
}
q[0] = sample_mix_16(q[0], p[0], mix_b);
q[1] = sample_mix_16(q[1], p[1], mix_b);
Expand Down Expand Up @@ -958,7 +970,8 @@ static int transition_get_image(mlt_frame a_frame,
progressive ? -1 : top_field_first,
*width,
*height,
invert);
invert,
alpha_over);
} else if (*format == mlt_image_rgba64) {
ret = luma_composite_rgba64(!invert ? a_frame : b_frame,
!invert ? b_frame : a_frame,
Expand All @@ -971,7 +984,8 @@ static int transition_get_image(mlt_frame a_frame,
progressive ? -1 : top_field_first,
*width,
*height,
invert);
invert,
alpha_over);
} else {
*format = mlt_image_yuv422;
luma_composite_yuv422(!invert ? a_frame : b_frame,
Expand All @@ -986,7 +1000,8 @@ static int transition_get_image(mlt_frame a_frame,
width,
height,
invert,
fix_background_alpha);
fix_background_alpha,
alpha_over);
}
} else {
if (mlt_properties_get(&a_frame->parent, "distort"))
Expand Down
Loading