Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594
This commit is contained in:
@@ -14,13 +14,12 @@
|
||||
|
||||
#include "testyuv_cvt.h"
|
||||
|
||||
|
||||
static float clip3(float x, float y, float z)
|
||||
{
|
||||
return (z < x) ? x : ((z > y) ? y : z);
|
||||
}
|
||||
|
||||
static void RGBtoYUV(Uint8 * rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)
|
||||
static void RGBtoYUV(Uint8 *rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)
|
||||
{
|
||||
if (mode == SDL_YUV_CONVERSION_JPEG) {
|
||||
/* Full range YUV */
|
||||
@@ -52,9 +51,9 @@ static void RGBtoYUV(Uint8 * rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int mo
|
||||
G = rgb[1];
|
||||
B = rgb[2];
|
||||
L = Kr * R + Kb * B + (1 - Kr - Kb) * G;
|
||||
Y = (Uint8)SDL_floorf((219*(L-Z)/S + 16) + 0.5f);
|
||||
U = (Uint8)clip3(0, 255, SDL_floorf((112.0f*(B-L) / ((1.0f-Kb)*S) + 128) + 0.5f));
|
||||
V = (Uint8)clip3(0, 255, SDL_floorf((112.0f*(R-L) / ((1.0f-Kr)*S) + 128) + 0.5f));
|
||||
Y = (Uint8)SDL_floorf((219 * (L - Z) / S + 16) + 0.5f);
|
||||
U = (Uint8)clip3(0, 255, SDL_floorf((112.0f * (B - L) / ((1.0f - Kb) * S) + 128) + 0.5f));
|
||||
V = (Uint8)clip3(0, 255, SDL_floorf((112.0f * (R - L) / ((1.0f - Kr) * S) + 128) + 0.5f));
|
||||
|
||||
yuv[0] = (Uint8)Y;
|
||||
yuv[1] = (Uint8)U;
|
||||
@@ -80,7 +79,7 @@ static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *o
|
||||
int yuv[4][3];
|
||||
Uint8 *Y1, *Y2, *U, *V;
|
||||
Uint8 *rgb1, *rgb2;
|
||||
int rgb_row_advance = (pitch - w*3) + pitch;
|
||||
int rgb_row_advance = (pitch - w * 3) + pitch;
|
||||
int UV_advance;
|
||||
|
||||
rgb1 = src;
|
||||
@@ -91,12 +90,12 @@ static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *o
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
V = (Y1 + h * w);
|
||||
U = V + ((h + 1)/2)*((w + 1)/2);
|
||||
U = V + ((h + 1) / 2) * ((w + 1) / 2);
|
||||
UV_advance = 1;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
U = (Y1 + h * w);
|
||||
V = U + ((h + 1)/2)*((w + 1)/2);
|
||||
V = U + ((h + 1) / 2) * ((w + 1) / 2);
|
||||
UV_advance = 1;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
@@ -132,10 +131,10 @@ static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *o
|
||||
rgb2 += 3;
|
||||
*Y2++ = (Uint8)yuv[3][0];
|
||||
|
||||
*U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1] + yuv[2][1] + yuv[3][1])/4.0f + 0.5f);
|
||||
*U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1] + yuv[2][1] + yuv[3][1]) / 4.0f + 0.5f);
|
||||
U += UV_advance;
|
||||
|
||||
*V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2] + yuv[2][2] + yuv[3][2])/4.0f + 0.5f);
|
||||
*V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2] + yuv[2][2] + yuv[3][2]) / 4.0f + 0.5f);
|
||||
V += UV_advance;
|
||||
}
|
||||
/* Last column */
|
||||
@@ -148,10 +147,10 @@ static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *o
|
||||
rgb2 += 3;
|
||||
*Y2++ = (Uint8)yuv[2][0];
|
||||
|
||||
*U = (Uint8)SDL_floorf((yuv[0][1] + yuv[2][1])/2.0f + 0.5f);
|
||||
*U = (Uint8)SDL_floorf((yuv[0][1] + yuv[2][1]) / 2.0f + 0.5f);
|
||||
U += UV_advance;
|
||||
|
||||
*V = (Uint8)SDL_floorf((yuv[0][2] + yuv[2][2])/2.0f + 0.5f);
|
||||
*V = (Uint8)SDL_floorf((yuv[0][2] + yuv[2][2]) / 2.0f + 0.5f);
|
||||
V += UV_advance;
|
||||
}
|
||||
Y1 += w;
|
||||
@@ -170,10 +169,10 @@ static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *o
|
||||
rgb1 += 3;
|
||||
*Y1++ = (Uint8)yuv[1][0];
|
||||
|
||||
*U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1])/2.0f + 0.5f);
|
||||
*U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1]) / 2.0f + 0.5f);
|
||||
U += UV_advance;
|
||||
|
||||
*V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2])/2.0f + 0.5f);
|
||||
*V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2]) / 2.0f + 0.5f);
|
||||
V += UV_advance;
|
||||
}
|
||||
/* Last column */
|
||||
@@ -196,28 +195,28 @@ static void ConvertRGBtoPacked4(Uint32 format, Uint8 *src, int pitch, Uint8 *out
|
||||
int yuv[2][3];
|
||||
Uint8 *Y1, *Y2, *U, *V;
|
||||
Uint8 *rgb;
|
||||
int rgb_row_advance = (pitch - w*3);
|
||||
int rgb_row_advance = (pitch - w * 3);
|
||||
|
||||
rgb = src;
|
||||
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_YUY2:
|
||||
Y1 = out;
|
||||
U = out+1;
|
||||
Y2 = out+2;
|
||||
V = out+3;
|
||||
U = out + 1;
|
||||
Y2 = out + 2;
|
||||
V = out + 3;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_UYVY:
|
||||
U = out;
|
||||
Y1 = out+1;
|
||||
V = out+2;
|
||||
Y2 = out+3;
|
||||
Y1 = out + 1;
|
||||
V = out + 2;
|
||||
Y2 = out + 3;
|
||||
break;
|
||||
case SDL_PIXELFORMAT_YVYU:
|
||||
Y1 = out;
|
||||
V = out+1;
|
||||
Y2 = out+2;
|
||||
U = out+3;
|
||||
V = out + 1;
|
||||
Y2 = out + 2;
|
||||
U = out + 3;
|
||||
break;
|
||||
default:
|
||||
SDL_assert(!"Unsupported packed YUV format");
|
||||
@@ -236,10 +235,10 @@ static void ConvertRGBtoPacked4(Uint32 format, Uint8 *src, int pitch, Uint8 *out
|
||||
*Y2 = (Uint8)yuv[1][0];
|
||||
Y2 += 4;
|
||||
|
||||
*U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1])/2.0f + 0.5f);
|
||||
*U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1]) / 2.0f + 0.5f);
|
||||
U += 4;
|
||||
|
||||
*V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2])/2.0f + 0.5f);
|
||||
*V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2]) / 2.0f + 0.5f);
|
||||
V += 4;
|
||||
}
|
||||
/* Last column */
|
||||
@@ -262,8 +261,7 @@ static void ConvertRGBtoPacked4(Uint32 format, Uint8 *src, int pitch, Uint8 *out
|
||||
|
||||
SDL_bool ConvertRGBtoYUV(Uint32 format, Uint8 *src, int pitch, Uint8 *out, int w, int h, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
@@ -282,8 +280,7 @@ SDL_bool ConvertRGBtoYUV(Uint32 format, Uint8 *src, int pitch, Uint8 *out, int w
|
||||
|
||||
int CalculateYUVPitch(Uint32 format, int width)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
|
||||
Reference in New Issue
Block a user