From 6ee2bd31724891dc3786526f08501779b553f8c7 Mon Sep 17 00:00:00 2001 From: Oneric Date: Fri, 18 Nov 2022 23:57:16 +0100 Subject: [PATCH] [UNTESTED] csri: add support for BGRA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xy-VSFilter already works with an alpha channel for BGR_ since 6a6f7cb39a446aa761abe40ffc94d659fe4a4c3f, so we just need to accept an additional format. Treating the padding byte of BGR_ as alpha may of course create its own problem. But given - the change to RGBA supposedly fixed some SSF bug - this behaviour existed since 2014 - I don’t know who besides Aegisub uses the csri interface I’m wary of changing this now. Regarding the naming mismatch BGR* and RGB*: csri has two distinct types for RGB* and BGR* with the name signifying the order of colour channels. Of those, guliverkli2 and xy-VSFilter always only supported the BGR* variants and mapped them to their internal RGB* types. This is most likely just a naming mismatch and *VSFilter’s RGB* types actually use BGR order. A look at the YUV to "RGB" conversion from the Aegisub commit mentioned in the previous commit corrobarates this. Even if not, this already dating back to guliverkli2 probably means every modern csri application already expects and relies on this. --- src/filters/transform/vsfilter/csriapi.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/filters/transform/vsfilter/csriapi.cpp b/src/filters/transform/vsfilter/csriapi.cpp index e7b5a086..c99d2811 100644 --- a/src/filters/transform/vsfilter/csriapi.cpp +++ b/src/filters/transform/vsfilter/csriapi.cpp @@ -114,6 +114,7 @@ CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt) // Check if pixel format is supported switch (fmt->pixfmt) { case CSRI_F_BGR_: + case CSRI_F_BGRA: inst->pixfmt = fmt->pixfmt; break; @@ -136,7 +137,10 @@ CSRIAPI void csri_render(csri_inst *inst, struct csri_frame *frame, double time) spd.w = inst->screen_res.cx; spd.h = inst->screen_res.cy; switch (inst->pixfmt) { + // xy-VSFilter treats BGR_ as having an alpha channel since 2014, + // specifically commit 6a6f7cb39a446aa761abe40ffc94d659fe4a4c3f case CSRI_F_BGR_: + case CSRI_F_BGRA: spd.type = MSP_RGBA; spd.bpp = 32; spd.bits = frame->planes[0];