Skip to content

Commit

Permalink
[UNTESTED] csri: add support for BGRA
Browse files Browse the repository at this point in the history
xy-VSFilter already works with an alpha channel for BGR_
since 6a6f7cb, 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.
  • Loading branch information
TheOneric committed Jan 22, 2023
1 parent 27de7ba commit 945757c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/filters/transform/vsfilter/csriapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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];
Expand All @@ -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;
}
Expand Down

0 comments on commit 945757c

Please sign in to comment.