Updated SDL's YUV support, many thanks to Adrien Descamps
New functions get and set the YUV colorspace conversion mode: SDL_SetYUVConversionMode() SDL_GetYUVConversionMode() SDL_GetYUVConversionModeForResolution() SDL_ConvertPixels() converts between all supported RGB and YUV formats, with SSE acceleration for converting from planar YUV formats (YV12, NV12, etc) to common RGB/RGBA formats. Added a new test program, testyuv, to verify correctness and speed of YUV conversion functionality.
This commit is contained in:
parent
e7cc03e0bd
commit
145d2469ae
60 changed files with 8368 additions and 4310 deletions
|
@ -1349,13 +1349,37 @@ GL_SetupCopy(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
|
||||
GL_SetBlendMode(data, texture->blendMode);
|
||||
|
||||
if (texturedata->yuv) {
|
||||
GL_SetShader(data, SHADER_YUV);
|
||||
} else if (texturedata->nv12) {
|
||||
if (texture->format == SDL_PIXELFORMAT_NV12) {
|
||||
GL_SetShader(data, SHADER_NV12);
|
||||
} else {
|
||||
GL_SetShader(data, SHADER_NV21);
|
||||
if (texturedata->yuv || texturedata->nv12) {
|
||||
switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) {
|
||||
case SDL_YUV_CONVERSION_JPEG:
|
||||
if (texturedata->yuv) {
|
||||
GL_SetShader(data, SHADER_YUV_JPEG);
|
||||
} else if (texture->format == SDL_PIXELFORMAT_NV12) {
|
||||
GL_SetShader(data, SHADER_NV12_JPEG);
|
||||
} else {
|
||||
GL_SetShader(data, SHADER_NV21_JPEG);
|
||||
}
|
||||
break;
|
||||
case SDL_YUV_CONVERSION_BT601:
|
||||
if (texturedata->yuv) {
|
||||
GL_SetShader(data, SHADER_YUV_BT601);
|
||||
} else if (texture->format == SDL_PIXELFORMAT_NV12) {
|
||||
GL_SetShader(data, SHADER_NV12_BT601);
|
||||
} else {
|
||||
GL_SetShader(data, SHADER_NV21_BT601);
|
||||
}
|
||||
break;
|
||||
case SDL_YUV_CONVERSION_BT709:
|
||||
if (texturedata->yuv) {
|
||||
GL_SetShader(data, SHADER_YUV_BT709);
|
||||
} else if (texture->format == SDL_PIXELFORMAT_NV12) {
|
||||
GL_SetShader(data, SHADER_NV12_BT709);
|
||||
} else {
|
||||
GL_SetShader(data, SHADER_NV21_BT709);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return SDL_SetError("Unsupported YUV conversion mode");
|
||||
}
|
||||
} else {
|
||||
GL_SetShader(data, SHADER_RGB);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue