Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] YUV to RGB in video/SDL_yuv.c is broken for any output format of type ABGR8888 or BGR888 #2724

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

SDLBugzilla commented Feb 11, 2021

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: All, All

Comments on the original bug report:

On 2017-11-17 06:05:25 +0000, wrote:

Here is the bug in latest SDL 2.0.8 development repo. It is obvious and simple to fix by correcting typos on six lines of code.

In “src/video/SDL_yuv.c,” on lines 217, 249, 280, 321, 353, and 384 the wrong conversion functions are called for SDL_PIXELFORMAT_ABGR8888 and SDL_PIXELFORMAT_BGR888. Instead of ABGR functions, BGRA functions are called. These are typos.

One example in context:
(…)
line 312:
case SDL_PIXELFORMAT_BGRX8888:
case SDL_PIXELFORMAT_BGRA8888:
yuv420_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
return SDL_TRUE;
case SDL_PIXELFORMAT_RGB888:
case SDL_PIXELFORMAT_ARGB8888:
yuv420_argb_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
return SDL_TRUE;
case SDL_PIXELFORMAT_BGR888:
case SDL_PIXELFORMAT_ABGR8888:
yuv420_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
return SDL_TRUE;

Notice the second to last line, line 321 has a typo. it should read
line321:
yuv420_abgr_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);

Similarly for line 353, it should read
line353:
yuv422_abgr_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);

Similarly for line 383, it should read
line383:
yuvnv12_abgr_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);

And the same typo is also present in the SSE function calls:
line217 should read:
yuv420_abgr_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
line249 should read:
yuv422_abgr_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
line 280 should read:
yuvnv12_abgr_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);

In summary, in six places in src/video/SDL_yuv.c, “bgra” should be switched to “abgr”.

It is clear from the context that it is a bug: Why would BGRA and ABGR pixel formats use the same conversion function?

But of course I also double-checked it using a program that displayed the wrong colors when linked to latest 2.0.8 HG but worked fine in previous versions. And indeed, these changes fixed the output. SDL was simply calling the wrong conversion function due to these typos.

On 2017-11-17 18:45:25 +0000, wrote:

Created attachment 3088
proposed patch to fix bug 3964 by fixing the typos in src/video/SDL_yuv.c

On 2017-11-17 19:03:02 +0000, Sam Lantinga wrote:

Good catch, thanks!
https://hg.libsdl.org/SDL/rev/88462f00ffac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant