Skip to content

Commit db82ad8

Browse files
committed
[primitives,yuv] fix compiler warnings
1 parent 8f5f65a commit db82ad8

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

libfreerdp/primitives/prim_YUV.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,11 @@ general_YUV444ToRGB_DOUBLE_ROW(BYTE* WINPR_RESTRICT pRGB[2], UINT32 DstFormat,
357357
{
358358
const INT32 subU = (INT32)pU[0][x + 1] + pU[1][x] + pU[1][x + 1];
359359
const INT32 avgU = ((4 * u) - subU);
360-
u = CONDITIONAL_CLIP(avgU, u);
360+
u = CONDITIONAL_CLIP(avgU, WINPR_ASSERTING_INT_CAST(BYTE, u));
361361

362362
const INT32 subV = (INT32)pV[0][x + 1] + pV[1][x] + pV[1][x + 1];
363363
const INT32 avgV = ((4 * v) - subV);
364-
v = CONDITIONAL_CLIP(avgV, v);
364+
v = CONDITIONAL_CLIP(avgV, WINPR_ASSERTING_INT_CAST(BYTE, v));
365365
}
366366
const BYTE r = YUV2R(y, u, v);
367367
const BYTE g = YUV2G(y, u, v);
@@ -1063,7 +1063,7 @@ void general_RGBToAVC444YUV_BGRX_DOUBLE_ROW(size_t offset, const BYTE* WINPR_RES
10631063
BYTE* WINPR_RESTRICT b6, BYTE* WINPR_RESTRICT b7,
10641064
UINT32 width)
10651065
{
1066-
for (UINT32 x = offset; x < width; x += 2)
1066+
for (size_t x = offset; x < width; x += 2)
10671067
{
10681068
const BYTE* srcEven = &pSrcEven[4ULL * x];
10691069
const BYTE* srcOdd = &pSrcOdd[4ULL * x];
@@ -1813,7 +1813,7 @@ static INLINE pstatus_t general_RGBToAVC444YUVv2_ANY(
18131813
return PRIMITIVES_SUCCESS;
18141814
}
18151815

1816-
inline void general_RGBToAVC444YUVv2_BGRX_DOUBLE_ROW(
1816+
void general_RGBToAVC444YUVv2_BGRX_DOUBLE_ROW(
18171817
size_t offset, const BYTE* WINPR_RESTRICT pSrcEven, const BYTE* WINPR_RESTRICT pSrcOdd,
18181818
BYTE* WINPR_RESTRICT yLumaDstEven, BYTE* WINPR_RESTRICT yLumaDstOdd,
18191819
BYTE* WINPR_RESTRICT uLumaDst, BYTE* WINPR_RESTRICT vLumaDst,
@@ -1822,7 +1822,7 @@ inline void general_RGBToAVC444YUVv2_BGRX_DOUBLE_ROW(
18221822
BYTE* WINPR_RESTRICT uChromaDst1, BYTE* WINPR_RESTRICT uChromaDst2,
18231823
BYTE* WINPR_RESTRICT vChromaDst1, BYTE* WINPR_RESTRICT vChromaDst2, UINT32 width)
18241824
{
1825-
for (UINT32 x = offset; x < width; x += 2)
1825+
for (size_t x = offset; x < width; x += 2)
18261826
{
18271827
const BYTE* srcEven = &pSrcEven[4ULL * x];
18281828
const BYTE* srcOdd = &pSrcOdd[4ULL * x];

libfreerdp/primitives/primitives.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,5 +421,7 @@ const char* primitives_avc444_frame_type_str(avc444_frame_type type)
421421
return "AVC444_CHROMAv1";
422422
case AVC444_CHROMAv2:
423423
return "AVC444_CHROMAv2";
424+
default:
425+
return "INVALID_FRAME_TYPE";
424426
}
425427
}

libfreerdp/primitives/test/TestPrimitivesYUV.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include "prim_test.h"
88

9+
#include <winpr/print.h>
10+
911
#include <winpr/wlog.h>
1012
#include <winpr/crypto.h>
1113
#include <freerdp/primitives.h>
@@ -1002,7 +1004,6 @@ static BOOL yuv444_to_rgb(BYTE* rgb, size_t stride, const BYTE* yuv[3], const UI
10021004
/* Check the result of generic matches the optimized routine.
10031005
*
10041006
*/
1005-
#include <winpr/print.h>
10061007
static BOOL compare_yuv444_to_rgb(prim_size_t roi, DWORD type)
10071008
{
10081009
BOOL rc = FALSE;
@@ -1051,10 +1052,14 @@ static BOOL compare_yuv444_to_rgb(prim_size_t roi, DWORD type)
10511052
const UINT32 color1 = FreeRDPReadColor(&line1[x * 4], format);
10521053
const UINT32 color2 = FreeRDPReadColor(&line2[x * 4], format);
10531054

1054-
BYTE r1, g1, b1;
1055+
BYTE r1 = 0;
1056+
BYTE g1 = 0;
1057+
BYTE b1 = 0;
10551058
FreeRDPSplitColor(color1, format, &r1, &g1, &b1, NULL, NULL);
10561059

1057-
BYTE r2, g2, b2;
1060+
BYTE r2 = 0;
1061+
BYTE g2 = 0;
1062+
BYTE b2 = 0;
10581063
FreeRDPSplitColor(color2, format, &r2, &g2, &b2, NULL, NULL);
10591064

10601065
const int dr12 = abs(r1 - r2);
@@ -1071,12 +1076,12 @@ static BOOL compare_yuv444_to_rgb(prim_size_t roi, DWORD type)
10711076

10721077
if ((dr12 > 0) || (dg12 > 0) || (db12 > 0))
10731078
{
1074-
fprintf(stderr,
1075-
"[%" PRIuz "x%" PRIuz "] generic and optimized data mismatch: r[0x%" PRIx8
1076-
"|0x%" PRIx8 "] g[0x%" PRIx8 "|0x%" PRIx8 "] b[0x%" PRIx8 "|0x%" PRIx8
1077-
"]\n",
1078-
x, y, r1, r2, g1, g2, b1, b2);
1079-
fprintf(stderr, "roi: %dx%d\n", roi.width, roi.height);
1079+
(void)fprintf(stderr,
1080+
"[%" PRIuz "x%" PRIuz
1081+
"] generic and optimized data mismatch: r[0x%" PRIx8 "|0x%" PRIx8
1082+
"] g[0x%" PRIx8 "|0x%" PRIx8 "] b[0x%" PRIx8 "|0x%" PRIx8 "]\n",
1083+
x, y, r1, r2, g1, g2, b1, b2);
1084+
(void)fprintf(stderr, "roi: %dx%d\n", roi.width, roi.height);
10801085
winpr_HexDump("y0", WLOG_INFO, &yline[0][x], 16);
10811086
winpr_HexDump("y1", WLOG_INFO, &yline[0][x + roi.width], 16);
10821087
winpr_HexDump("u0", WLOG_INFO, &yline[1][x], 16);
@@ -1151,7 +1156,7 @@ static BOOL compare_rgb_to_yuv444(prim_size_t roi, DWORD type)
11511156
{
11521157
if (memcmp(yline1[x], yline2[x], yuvStep[x]) != 0)
11531158
{
1154-
fprintf(stderr, "[%s] compare failed in line %" PRIuz, __func__, x);
1159+
(void)fprintf(stderr, "[%s] compare failed in line %" PRIuz, __func__, x);
11551160
goto fail;
11561161
}
11571162
}
@@ -1218,10 +1223,14 @@ static BOOL compare_yuv420_to_rgb(prim_size_t roi, DWORD type)
12181223
const UINT32 color1 = FreeRDPReadColor(&line1[x * 4], format);
12191224
const UINT32 color2 = FreeRDPReadColor(&line2[x * 4], format);
12201225

1221-
BYTE r1, g1, b1;
1226+
BYTE r1 = 0;
1227+
BYTE g1 = 0;
1228+
BYTE b1 = 0;
12221229
FreeRDPSplitColor(color1, format, &r1, &g1, &b1, NULL, NULL);
12231230

1224-
BYTE r2, g2, b2;
1231+
BYTE r2 = 0;
1232+
BYTE g2 = 0;
1233+
BYTE b2 = 0;
12251234
FreeRDPSplitColor(color2, format, &r2, &g2, &b2, NULL, NULL);
12261235

12271236
const int dr12 = abs(r1 - r2);
@@ -1348,10 +1357,11 @@ static BOOL compare_rgb_to_yuv420(prim_size_t roi, DWORD type)
13481357
{
13491358
if (similarY(yline1[x], yline2[x], yuvStep[x], x) != 0)
13501359
{
1351-
fprintf(stderr, "[%s] compare failed in component %" PRIuz ", line %" PRIuz "\n",
1352-
__func__, x, y);
1353-
fprintf(stderr, "[%s] roi %" PRIu32 "x%" PRIu32 "\n", __func__, roi.width,
1354-
roi.height);
1360+
(void)fprintf(stderr,
1361+
"[%s] compare failed in component %" PRIuz ", line %" PRIuz "\n",
1362+
__func__, x, y);
1363+
(void)fprintf(stderr, "[%s] roi %" PRIu32 "x%" PRIu32 "\n", __func__, roi.width,
1364+
roi.height);
13551365
winpr_HexDump(TAG, WLOG_WARN, yline1[x], yuvStep[x]);
13561366
winpr_HexDump(TAG, WLOG_WARN, yline2[x], yuvStep[x]);
13571367
winpr_HexDump(TAG, WLOG_WARN, &rgb[y * stride], stride);

0 commit comments

Comments
 (0)