I am getting wrong YUV colors when rendering a YUV texture to the screen after the latest commit that updated YUV conversion. It is a program that works with SDL 2.0.0+, and colors have been fine until now. No changes to the source code were made apart from re-compiling and re-linking to latest SDL dev version.
Blue is pink and everything else also seems to have wrong colors. It seems there’s also less color overall in the resulting image, everything is pink and brown.
The texture is created using
SDL_Texture _videoTexture = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_UYVY, SDL_TEXTUREACCESS_STREAMING, w, h);
SDL_UpdateTexture(_videoTexture, NULL, _videoBuffer, _videoW * sizeof(uint16_t));
and then rendered using
SDL_RenderCopy(renderer, _videoTexture, &src, &dst);
Since nothing in the code has changed, I conclude it is a bug with the new YUV RGB conversion routines. In the SDL_UpdateTexture function, eventually, the new function SDL_ConvertPixels_YUV_to_RGB is called. I think that is where the problem lies. However, I do not understand the contents of that function. It seems very hard to debug.
The renderer format is SDL_PIXELFORMAT_ABGR8888. So the problem appears when converting SDL_PIXELFORMAT_UYVY to SDL_PIXELFORMAT_ABGR8888. This is done (no_SSE) in yuv422_bgra_std in SDL_yuv.c.
A display of a different texture with SDL_PIXELFORMAT_RGB888 to the renderer format SDL_PIXELFORMAT_ABGR8888 works just fine. But maybe that is expected since that conversion is not using any of the new YUV code.
Please note that when compiling, I also get a whole bunch of warnings related to the new functions:
The structures and shapes in the picture are all correct, just the colors are wrong.