From 41a954d9872c13b8d499429480f78c1aadd11294 Mon Sep 17 00:00:00 2001
From: Wan-Teh Chang <[EMAIL REDACTED]>
Date: Fri, 2 Aug 2024 07:47:12 -0700
Subject: [PATCH] Fix -Wundef warnings in libyuv's row_common.cc
See https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5758156.
Bug: aomedia:356830476
Change-Id: I402bce296930bdb7fb6994cdf4270353e7aeb301
---
third_party/libyuv/README.libaom | 85 +++++++++++++++++++++++++
third_party/libyuv/source/row_common.cc | 18 +++---
2 files changed, 94 insertions(+), 9 deletions(-)
diff --git a/third_party/libyuv/README.libaom b/third_party/libyuv/README.libaom
index 6e66f858e2..fcdf921c57 100644
--- a/third_party/libyuv/README.libaom
+++ b/third_party/libyuv/README.libaom
@@ -35,3 +35,88 @@ index fe89452b7..72a7fb82f 100644
+#if defined(_M_IX86) && defined(_MSC_VER) && (_MSC_VER < 1900)
#pragma optimize("g", on)
#endif
+diff --git a/third_party/libyuv/source/row_common.cc b/third_party/libyuv/source/row_common.cc
+index 79aed5c787..b0add63a6e 100644
+--- a/third_party/libyuv/source/row_common.cc
++++ b/third_party/libyuv/source/row_common.cc
+@@ -37,7 +37,7 @@ extern "C" {
+ // llvm x86 is poor at ternary operator, so use branchless min/max.
+
+ #define USE_BRANCHLESS 1
+-#if USE_BRANCHLESS
++#if defined(USE_BRANCHLESS)
+ static __inline int32_t clamp0(int32_t v) {
+ return -(v >= 0) & v;
+ }
+@@ -460,7 +460,7 @@ static __inline int RGB2xToV(uint16_t r, uint16_t g, uint16_t b) {
+
+ // ARGBToY_C and ARGBToUV_C
+ // Intel version mimic SSE/AVX which does 2 pavgb
+-#if LIBYUV_ARGBTOUV_PAVGB
++#if defined(LIBYUV_ARGBTOUV_PAVGB)
+
+ #define MAKEROWY(NAME, R, G, B, BPP) \
+ void NAME##ToYRow_C(const uint8_t* src_argb0, uint8_t* dst_y, int width) { \
+@@ -602,7 +602,7 @@ static __inline int RGB2xToVJ(uint16_t r, uint16_t g, uint16_t b) {
+
+ // ARGBToYJ_C and ARGBToUVJ_C
+ // Intel version mimic SSE/AVX which does 2 pavgb
+-#if LIBYUV_ARGBTOUV_PAVGB
++#if defined(LIBYUV_ARGBTOUV_PAVGB)
+ #define MAKEROWYJ(NAME, R, G, B, BPP) \
+ void NAME##ToYJRow_C(const uint8_t* src_argb0, uint8_t* dst_y, int width) { \
+ int x; \
+@@ -766,7 +766,7 @@ void RGB565ToUVRow_C(const uint8_t* src_rgb565,
+ g3 = (g3 << 2) | (g3 >> 4);
+ r3 = (r3 << 3) | (r3 >> 2);
+
+-#if LIBYUV_ARGBTOUV_PAVGB
++#if defined(LIBYUV_ARGBTOUV_PAVGB)
+ uint8_t ab = AVGB(AVGB(b0, b2), AVGB(b1, b3));
+ uint8_t ag = AVGB(AVGB(g0, g2), AVGB(g1, g3));
+ uint8_t ar = AVGB(AVGB(r0, r2), AVGB(r1, r3));
+@@ -800,7 +800,7 @@ void RGB565ToUVRow_C(const uint8_t* src_rgb565,
+ g2 = (g2 << 2) | (g2 >> 4);
+ r2 = (r2 << 3) | (r2 >> 2);
+
+-#if LIBYUV_ARGBTOUV_PAVGB
++#if defined(LIBYUV_ARGBTOUV_PAVGB)
+ uint8_t ab = AVGB(b0, b2);
+ uint8_t ag = AVGB(g0, g2);
+ uint8_t ar = AVGB(r0, r2);
+@@ -850,7 +850,7 @@ void ARGB1555ToUVRow_C(const uint8_t* src_argb1555,
+ g3 = (g3 << 3) | (g3 >> 2);
+ r3 = (r3 << 3) | (r3 >> 2);
+
+-#if LIBYUV_ARGBTOUV_PAVGB
++#if defined(LIBYUV_ARGBTOUV_PAVGB)
+ uint8_t ab = AVGB(AVGB(b0, b2), AVGB(b1, b3));
+ uint8_t ag = AVGB(AVGB(g0, g2), AVGB(g1, g3));
+ uint8_t ar = AVGB(AVGB(r0, r2), AVGB(r1, r3));
+@@ -884,7 +884,7 @@ void ARGB1555ToUVRow_C(const uint8_t* src_argb1555,
+ g2 = (g2 << 3) | (g2 >> 2);
+ r2 = (r2 << 3) | (r2 >> 2);
+
+-#if LIBYUV_ARGBTOUV_PAVGB
++#if defined(LIBYUV_ARGBTOUV_PAVGB)
+ uint8_t ab = AVGB(b0, b2);
+ uint8_t ag = AVGB(g0, g2);
+ uint8_t ar = AVGB(r0, r2);
+@@ -934,7 +934,7 @@ void ARGB4444ToUVRow_C(const uint8_t* src_argb4444,
+ g3 = (g3 << 4) | g3;
+ r3 = (r3 << 4) | r3;
+
+-#if LIBYUV_ARGBTOUV_PAVGB
++#if defined(LIBYUV_ARGBTOUV_PAVGB)
+ uint8_t ab = AVGB(AVGB(b0, b2), AVGB(b1, b3));
+ uint8_t ag = AVGB(AVGB(g0, g2), AVGB(g1, g3));
+ uint8_t ar = AVGB(AVGB(r0, r2), AVGB(r1, r3));
+@@ -968,7 +968,7 @@ void ARGB4444ToUVRow_C(const uint8_t* src_argb4444,
+ g2 = (g2 << 4) | g2;
+ r2 = (r2 << 4) | r2;
+
+-#if LIBYUV_ARGBTOUV_PAVGB
++#if defined(LIBYUV_ARGBTOUV_PAVGB)
+ uint8_t ab = AVGB(b0, b2);
+ uint8_t ag = AVGB(g0, g2);
+ uint8_t ar = AVGB(r0, r2);
diff --git a/third_party/libyuv/source/row_common.cc b/third_party/libyuv/source/row_common.cc
index 79aed5c787..b0add63a6e 100644
--- a/third_party/libyuv/source/row_common.cc
+++ b/third_party/libyuv/source/row_common.cc
@@ -37,7 +37,7 @@ extern "C" {
// llvm x86 is poor at ternary operator, so use branchless min/max.
#define USE_BRANCHLESS 1
-#if USE_BRANCHLESS
+#if defined(USE_BRANCHLESS)
static __inline int32_t clamp0(int32_t v) {
return -(v >= 0) & v;
}
@@ -460,7 +460,7 @@ static __inline int RGB2xToV(uint16_t r, uint16_t g, uint16_t b) {
// ARGBToY_C and ARGBToUV_C
// Intel version mimic SSE/AVX which does 2 pavgb
-#if LIBYUV_ARGBTOUV_PAVGB
+#if defined(LIBYUV_ARGBTOUV_PAVGB)
#define MAKEROWY(NAME, R, G, B, BPP) \
void NAME##ToYRow_C(const uint8_t* src_argb0, uint8_t* dst_y, int width) { \
@@ -602,7 +602,7 @@ static __inline int RGB2xToVJ(uint16_t r, uint16_t g, uint16_t b) {
// ARGBToYJ_C and ARGBToUVJ_C
// Intel version mimic SSE/AVX which does 2 pavgb
-#if LIBYUV_ARGBTOUV_PAVGB
+#if defined(LIBYUV_ARGBTOUV_PAVGB)
#define MAKEROWYJ(NAME, R, G, B, BPP) \
void NAME##ToYJRow_C(const uint8_t* src_argb0, uint8_t* dst_y, int width) { \
int x; \
@@ -766,7 +766,7 @@ void RGB565ToUVRow_C(const uint8_t* src_rgb565,
g3 = (g3 << 2) | (g3 >> 4);
r3 = (r3 << 3) | (r3 >> 2);
-#if LIBYUV_ARGBTOUV_PAVGB
+#if defined(LIBYUV_ARGBTOUV_PAVGB)
uint8_t ab = AVGB(AVGB(b0, b2), AVGB(b1, b3));
uint8_t ag = AVGB(AVGB(g0, g2), AVGB(g1, g3));
uint8_t ar = AVGB(AVGB(r0, r2), AVGB(r1, r3));
@@ -800,7 +800,7 @@ void RGB565ToUVRow_C(const uint8_t* src_rgb565,
g2 = (g2 << 2) | (g2 >> 4);
r2 = (r2 << 3) | (r2 >> 2);
-#if LIBYUV_ARGBTOUV_PAVGB
+#if defined(LIBYUV_ARGBTOUV_PAVGB)
uint8_t ab = AVGB(b0, b2);
uint8_t ag = AVGB(g0, g2);
uint8_t ar = AVGB(r0, r2);
@@ -850,7 +850,7 @@ void ARGB1555ToUVRow_C(const uint8_t* src_argb1555,
g3 = (g3 << 3) | (g3 >> 2);
r3 = (r3 << 3) | (r3 >> 2);
-#if LIBYUV_ARGBTOUV_PAVGB
+#if defined(LIBYUV_ARGBTOUV_PAVGB)
uint8_t ab = AVGB(AVGB(b0, b2), AVGB(b1, b3));
uint8_t ag = AVGB(AVGB(g0, g2), AVGB(g1, g3));
uint8_t ar = AVGB(AVGB(r0, r2), AVGB(r1, r3));
@@ -884,7 +884,7 @@ void ARGB1555ToUVRow_C(const uint8_t* src_argb1555,
g2 = (g2 << 3) | (g2 >> 2);
r2 = (r2 << 3) | (r2 >> 2);
-#if LIBYUV_ARGBTOUV_PAVGB
+#if defined(LIBYUV_ARGBTOUV_PAVGB)
uint8_t ab = AVGB(b0, b2);
uint8_t ag = AVGB(g0, g2);
uint8_t ar = AVGB(r0, r2);
@@ -934,7 +934,7 @@ void ARGB4444ToUVRow_C(const uint8_t* src_argb4444,
g3 = (g3 << 4) | g3;
r3 = (r3 << 4) | r3;
-#if LIBYUV_ARGBTOUV_PAVGB
+#if defined(LIBYUV_ARGBTOUV_PAVGB)
uint8_t ab = AVGB(AVGB(b0, b2), AVGB(b1, b3));
uint8_t ag = AVGB(AVGB(g0, g2), AVGB(g1, g3));
uint8_t ar = AVGB(AVGB(r0, r2), AVGB(r1, r3));
@@ -968,7 +968,7 @@ void ARGB4444ToUVRow_C(const uint8_t* src_argb4444,
g2 = (g2 << 4) | g2;
r2 = (r2 << 4) | r2;
-#if LIBYUV_ARGBTOUV_PAVGB
+#if defined(LIBYUV_ARGBTOUV_PAVGB)
uint8_t ab = AVGB(b0, b2);
uint8_t ag = AVGB(g0, g2);
uint8_t ar = AVGB(r0, r2);