Fix unified sources build for LoongArch LASX

Several consumers of libyuv do unified sources build where many source
files are #include'd together to make compilation units larger and allow
for more optimization chances. But for LoongArch there is a wrinkle:
LASX and LSX code paths are implemented in separate files, unlike the
other currently supported architectures, and some definitions are
duplicated e.g. struct RgbConstants.

Since the duplicated content is identical across the two files, short of
some bigger refactoring, we can simply place #ifdef guards around the
definitions to fix unified sources build for LoongArch.

Change-Id: I952e8e0210221ec8bcc113f75fa1b9ba515ec323
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/6272801
Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Commit-Queue: Mirko Bonadei <mbonadei@chromium.org>
This commit is contained in:
WANG Xuerui 2025-02-15 10:02:45 +08:00 committed by libyuv LUCI CQ
parent 23d416d6f3
commit 55a708e226
2 changed files with 28 additions and 0 deletions

View File

@ -2002,11 +2002,13 @@ void NV21ToARGBRow_LASX(const uint8_t* src_y,
} }
} }
#ifndef RgbConstants
struct RgbConstants { struct RgbConstants {
uint8_t kRGBToY[4]; uint8_t kRGBToY[4];
uint16_t kAddY; uint16_t kAddY;
uint16_t pad; uint16_t pad;
}; };
#define RgbConstants RgbConstants
// RGB to JPeg coefficients // RGB to JPeg coefficients
// B * 0.1140 coefficient = 29 // B * 0.1140 coefficient = 29
@ -2032,6 +2034,7 @@ static const struct RgbConstants kRgb24I601Constants = {{25, 129, 66, 0},
static const struct RgbConstants kRawI601Constants = {{66, 129, 25, 0}, static const struct RgbConstants kRawI601Constants = {{66, 129, 25, 0},
0x1080, 0x1080,
0}; 0};
#endif // RgbConstants
// ARGB expects first 3 values to contain RGB and 4th value is ignored. // ARGB expects first 3 values to contain RGB and 4th value is ignored.
static void ARGBToYMatrixRow_LASX(const uint8_t* src_argb, static void ARGBToYMatrixRow_LASX(const uint8_t* src_argb,
@ -2298,6 +2301,17 @@ void ARGBToUVJRow_LASX(const uint8_t* src_argb,
} }
} }
// undef for unified sources build
#undef ALPHA_VAL
#undef YUVTORGB_SETUP
#undef READYUV422_D
#undef READYUV422
#undef YUVTORGB_D
#undef YUVTORGB
#undef STOREARGB_D
#undef STOREARGB
#undef RGBTOUV
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
} // namespace libyuv } // namespace libyuv

View File

@ -2771,11 +2771,13 @@ void HalfFloatRow_LSX(const uint16_t* src,
} }
} }
#ifndef RgbConstants
struct RgbConstants { struct RgbConstants {
uint8_t kRGBToY[4]; uint8_t kRGBToY[4];
uint16_t kAddY; uint16_t kAddY;
uint16_t pad; uint16_t pad;
}; };
#define RgbConstants RgbConstants
// RGB to JPeg coefficients // RGB to JPeg coefficients
// B * 0.1140 coefficient = 29 // B * 0.1140 coefficient = 29
@ -2801,6 +2803,7 @@ static const struct RgbConstants kRgb24I601Constants = {{25, 129, 66, 0},
static const struct RgbConstants kRawI601Constants = {{66, 129, 25, 0}, static const struct RgbConstants kRawI601Constants = {{66, 129, 25, 0},
0x1080, 0x1080,
0}; 0};
#endif // RgbConstants
// ARGB expects first 3 values to contain RGB and 4th value is ignored. // ARGB expects first 3 values to contain RGB and 4th value is ignored.
static void ARGBToYMatrixRow_LSX(const uint8_t* src_argb, static void ARGBToYMatrixRow_LSX(const uint8_t* src_argb,
@ -2981,6 +2984,17 @@ void RAWToYRow_LSX(const uint8_t* src_raw, uint8_t* dst_y, int width) {
RGBToYMatrixRow_LSX(src_raw, dst_y, width, &kRawI601Constants); RGBToYMatrixRow_LSX(src_raw, dst_y, width, &kRawI601Constants);
} }
// undef for unified sources build
#undef YUVTORGB_SETUP
#undef READYUV422_D
#undef READYUV422
#undef YUVTORGB_D
#undef YUVTORGB
#undef I444TORGB
#undef STOREARGB_D
#undef STOREARGB
#undef RGBTOUV
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
} // namespace libyuv } // namespace libyuv