From 945757c6943f770e6086f180970bd8d31d5ec8a2 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/filters/transform/vsfilter/csriapi.cpp b/src/filters/transform/vsfilter/csriapi.cpp index f4536459..0436a28c 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]; @@ -146,7 +150,7 @@ CSRIAPI void csri_render(csri_inst *inst, struct csri_frame *frame, double time) default: ASSERT(0); CString msg; - msg.Format(_T("Anything other then RGB32 is NOT supported!")); + msg.Format(_T("Anything other than BGR(A)32 is NOT supported!")); MessageBox(NULL, msg, _T("Warning"), MB_OKCANCEL|MB_ICONWARNING); return; }