This was accidentally comparing s->colorspace against out->colorspace, which is wrong - the intent was to compare in->colorspace against out->colorspace. We also forgot to strip mastering metadata. Finally, the order is sort of wrong - we should strip this side data *before* process_frames, because otherwise it may end up being seen and used by libplacebo.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -390,7 +390,7 @@ fail: · 389 unmodified lines | |||
| 390 | 390 | ||
| 391 | static int filter_frame(AVFilterLink *link, AVFrame *in) | 391 | static int filter_frame(AVFilterLink *link, AVFrame *in) |
| 392 | { | 392 | { |
| 393 | int err, changed; | 393 | int err, changed_csp; |
| 394 | AVFilterContext *ctx = link->dst; | 394 | AVFilterContext *ctx = link->dst; |
| 395 | LibplaceboContext *s = ctx->priv; | 395 | LibplaceboContext *s = ctx->priv; |
| 396 | AVFilterLink *outlink = ctx->outputs[0]; | 396 | AVFilterLink *outlink = ctx->outputs[0]; |
| @@ -426,22 +426,25 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) · 29 unmodified lines | |||
| 426 | if (s->color_primaries >= 0) | 426 | if (s->color_primaries >= 0) |
| 427 | out->color_primaries = s->color_primaries; | 427 | out->color_primaries = s->color_primaries; |
| 428 | 428 | ||
| 429 | RET(process_frames(ctx, out, in)); | 429 | changed_csp = in->colorspace != out->colorspace || |
| 430 | 430 | in->color_range != out->color_range || | |
| 431 | int changed_csp = s->colorspace != out->colorspace || | 431 | in->color_trc != out->color_trc || |
| 432 | s->color_range != out->color_range || | 432 | in->color_primaries != out->color_primaries; |
| 433 | s->color_trc != out->color_trc || | ||
| 434 | s->color_primaries != out->color_primaries; | ||
| 435 | 433 | ||
| 434 | /* Strip side data if no longer relevant */ | ||
| 435 | if (changed_csp) { | ||
| 436 | av_frame_remove_side_data(out, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); | ||
| 437 | av_frame_remove_side_data(out, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); | ||
| 438 | } | ||
| 436 | if (s->apply_dovi || changed_csp) { | 439 | if (s->apply_dovi || changed_csp) { |
| 437 | /* Strip side data if no longer relevant */ | ||
| 438 | av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_RPU_BUFFER); | 440 | av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_RPU_BUFFER); |
| 439 | av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_METADATA); | 441 | av_frame_remove_side_data(out, AV_FRAME_DATA_DOVI_METADATA); |
| 440 | } | 442 | } |
| 441 | |||
| 442 | if (s->apply_filmgrain) | 443 | if (s->apply_filmgrain) |
| 443 | av_frame_remove_side_data(out, AV_FRAME_DATA_FILM_GRAIN_PARAMS); | 444 | av_frame_remove_side_data(out, AV_FRAME_DATA_FILM_GRAIN_PARAMS); |
| 444 | 445 | ||
| 446 | RET(process_frames(ctx, out, in)); | ||
| 447 | |||
| 445 | av_frame_free(&in); | 448 | av_frame_free(&in); |
| 446 | 449 | ||
| 447 | return ff_filter_frame(outlink, out); | 450 | return ff_filter_frame(outlink, out); |