Instead of undconditionally using the first input. This covers the case of one layer fully obscuring another layer, in which case that should become the new "base" layer.
Unified · Split
| @@ -940,7 +940,11 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) · 939 unmodified lines | |||
| 940 | if (!cropped && cur->repr.alpha == PL_ALPHA_NONE) { | 940 | if (!cropped && cur->repr.alpha == PL_ALPHA_NONE) { |
| 941 | idx_start = i; | 941 | idx_start = i; |
| 942 | nb_visible = 0; | 942 | nb_visible = 0; |
| 943 | ref = NULL; | ||
| 943 | } | 944 | } |
| 945 | /* Use first visible input as overall reference */ | ||
| 946 | if (!ref) | ||
| 947 | ref = ref_frame(&in->mix); | ||
| 944 | nb_visible++; | 948 | nb_visible++; |
| 945 | } | 949 | } |
| 946 | 950 | ||
| @@ -948,15 +952,6 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) · 1 unmodified line | |||
| 948 | * valid nonempty frame mix */ | 952 | * valid nonempty frame mix */ |
| 949 | av_assert1(nb_visible > 0); | 953 | av_assert1(nb_visible > 0); |
| 950 | 954 | ||
| 951 | /* Use the first active input as metadata reference */ | ||
| 952 | for (int i = 0; i < s->nb_inputs; i++) { | ||
| 953 | const LibplaceboInput *in = &s->inputs[i]; | ||
| 954 | if (in->qstatus == PL_QUEUE_OK && (ref = ref_frame(&in->mix))) | ||
| 955 | break; | ||
| 956 | } | ||
| 957 | if (!ref) | ||
| 958 | return 0; | ||
| 959 | |||
| 960 | out = ff_get_video_buffer(outlink, outlink->w, outlink->h); | 955 | out = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
| 961 | if (!out) | 956 | if (!out) |
| 962 | return AVERROR(ENOMEM); | 957 | return AVERROR(ENOMEM); |