Explicitly forbid using a non-RGB colorspace with RGB pixel format or vice versa. This mirrors identical logic from vf_scale.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -697,6 +697,13 @@ static int output_frame_mix(AVFilterContext *ctx, · 696 unmodified lines | ||
| 697 | 697 | if (s->color_primaries >= 0) |
| 698 | 698 | out->color_primaries = s->color_primaries; |
| 699 | 699 | |
| 700 | + /* Sanity colorspace overrides */ | |
| 701 | + if (outdesc->flags & AV_PIX_FMT_FLAG_RGB) { | |
| 702 | + out->colorspace = AVCOL_SPC_RGB; | |
| 703 | + } else if (out->colorspace == AVCOL_SPC_RGB) { | |
| 704 | + out->colorspace = AVCOL_SPC_UNSPECIFIED; | |
| 705 | + } | |
| 706 | + | |
| 700 | 707 | changed_csp = ref->colorspace != out->colorspace || |
| 701 | 708 | ref->color_range != out->color_range || |
| 702 | 709 | ref->color_trc != out->color_trc || |