libyuv/Android.bp
Frank Barchard eeb06a6451 [libyuv] Optimize ARGBRotate for Intel SSE2, AVX2, and AVX-512
Optimize 32-bit ARGBRotate (0, 90, 180, 270) across Intel x86/x64
architectures (SSE2, AVX2, AVX512BW), with matching kernels for ARM
(NEON, SVE2, SME), WASM, LoongArch (LSX, LASX), and RISC-V (RVV):

- Replace column-by-column ScaleARGBRowDownEven gather loops in
  ARGBTranspose (90/270) with full-plane horizontal tile transposes:
  - AVX512BW (TransposeWxH_32_AVX512BW / TransposeNx4_32_AVX512BW):
    Transpose 16x16 blocks across zmm0..zmm31 using 4-stage
    vpunpckldq/hdq, vpunpcklqdq/hqdq, and vshufi32x4 butterflies with
    k-masked right and bottom tails, eliminating Any wrappers and scalar
    C edge fallbacks.
  - AVX2 (TransposeWxH_32_AVX2 / TransposeNx4_32_AVX2):
    Transpose 8x8 blocks across ymm0..ymm15 using vpunpck* and
    vperm2i128 with vpmaskmovd masked tails.
  - SSE2 (Transpose4x4_32_SSE2 / Transpose4x4_32_Any_SSE2):
    Transpose 4x4 blocks in xmm registers.
- Implement ARGBRotate180 directly via ARGBMirror with negative height,
  avoiding intermediate row buffer allocations and extra copies.
- Implement ARGBRotate0 via ARGBCopy.

Speedup vs Before (1275x1650, US Letter 150 DPI, 1000 iterations):
CPU                  | 0 deg   | 90 deg  | 180 deg | 270 deg
---------------------|---------|---------|---------|--------
Intel Ice Lake       | 1.02x   | 1.34x   | 1.18x   | 1.33x
Intel Skylake-X      | 1.02x   | 1.20x   | 1.07x   | 1.13x
Intel Emerald Rapids | 1.01x   | 1.07x   | 1.00x   | 1.07x
Intel AVX-512 vs C   | 1.00x   | 2.67x   | 2.41x   | 2.63x

R=rrwinterton@gmail.com

Bug: b/42280915
Test: LIBYUV_WIDTH=1275 LIBYUV_HEIGHT=1650 LIBYUV_REPEAT=1000 ./out/Release/libyuv_unittest --gtest_filter=*ARGBRotate*
Change-Id: Ib308a225c17e46eab083a9da4033598fcf0c303c
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8538986
Reviewed-by: richard winterton <rrwinterton@gmail.com>
2026-10-08 16:20:46 -07:00

205 lines
4.6 KiB
Plaintext

package {
default_applicable_licenses: ["external_libyuv_license"],
}
// Added automatically by a large-scale-change
//
// large-scale-change included anything that looked like it might be a license
// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
//
// Please consider removing redundant or irrelevant files from 'license_text:'.
// See: http://go/android-license-faq
license {
name: "external_libyuv_license",
visibility: [":__subpackages__"],
license_kinds: [
"SPDX-license-identifier-BSD",
],
license_text: [
"LICENSE",
"PATENTS",
],
}
cc_library {
name: "libyuv",
vendor_available: true,
product_available: true,
host_supported: true,
vndk: {
enabled: true,
},
srcs: [
"source/compare.cc",
"source/compare_common.cc",
"source/compare_gcc.cc",
"source/compare_neon.cc",
"source/compare_neon64.cc",
"source/convert.cc",
"source/convert_argb.cc",
"source/convert_from.cc",
"source/convert_from_argb.cc",
"source/convert_jpeg.cc",
"source/convert_to_argb.cc",
"source/convert_to_i420.cc",
"source/cpu_id.cc",
"source/mjpeg_decoder.cc",
"source/mjpeg_validate.cc",
"source/planar_functions.cc",
"source/rotate.cc",
"source/rotate_any.cc",
"source/rotate_argb.cc",
"source/rotate_common.cc",
"source/rotate_gcc.cc",
"source/rotate_neon.cc",
"source/rotate_neon64.cc",
"source/rotate_rvv.cc",
"source/row_any.cc",
"source/row_common.cc",
"source/row_gcc.cc",
"source/row_neon.cc",
"source/row_neon64.cc",
"source/row_rvv.cc",
"source/scale.cc",
"source/scale_any.cc",
"source/scale_argb.cc",
"source/scale_common.cc",
"source/scale_gcc.cc",
"source/scale_neon.cc",
"source/scale_neon64.cc",
"source/scale_rgb.cc",
"source/scale_rvv.cc",
"source/scale_uv.cc",
"source/video_common.cc",
],
cflags: [
"-Wall",
"-Werror",
"-Wno-unused-parameter",
"-fexceptions",
"-DHAVE_JPEG",
"-DLIBYUV_UNLIMITED_DATA",
],
arch: {
arm: {
cflags: ["-mfpu=neon"],
},
},
shared_libs: ["libjpeg"],
export_include_dirs: ["include"],
apex_available: [
"//apex_available:platform",
"com.android.media.swcodec",
],
min_sdk_version: "29",
sanitize: {
cfi: true,
config: {
cfi_assembly_support: true,
},
},
}
// compatibilty static library until all uses of libyuv_static are replaced
// with libyuv (b/37646797)
cc_library_static {
name: "libyuv_static",
vendor_available: true,
whole_static_libs: ["libyuv"],
apex_available: [
"//apex_available:platform",
"com.android.media.swcodec",
],
min_sdk_version: "29",
}
cc_test {
name: "libyuv_unittest",
static_libs: ["libyuv"],
shared_libs: ["libjpeg"],
cflags: ["-Wall", "-Werror"],
srcs: [
"unit_test/basictypes_test.cc",
"unit_test/color_test.cc",
"unit_test/compare_test.cc",
"unit_test/convert_argb_test.cc",
"unit_test/convert_test.cc",
"unit_test/cpu_test.cc",
"unit_test/cpu_thread_test.cc",
"unit_test/math_test.cc",
"unit_test/planar_test.cc",
"unit_test/rotate_argb_test.cc",
"unit_test/rotate_test.cc",
"unit_test/scale_argb_test.cc",
"unit_test/scale_plane_test.cc",
"unit_test/scale_rgb_test.cc",
"unit_test/scale_test.cc",
"unit_test/scale_uv_test.cc",
"unit_test/unit_test.cc",
"unit_test/video_common_test.cc",
],
}
cc_test {
name: "compare",
gtest: false,
srcs: [
"util/compare.cc",
],
static_libs: ["libyuv"],
}
cc_test {
name: "cpuid",
gtest: false,
srcs: [
"util/cpuid.c",
],
static_libs: ["libyuv"],
}
cc_test {
name: "i444tonv12_eg",
gtest: false,
srcs: [
"util/i444tonv12_eg.cc",
],
static_libs: ["libyuv"],
}
cc_test {
name: "psnr",
gtest: false,
srcs: [
"util/psnr_main.cc",
"util/psnr.cc",
"util/ssim.cc",
],
static_libs: ["libyuv"],
}
cc_test {
name: "yuvconstants",
gtest: false,
srcs: [
"util/yuvconstants.c",
],
static_libs: ["libyuv"],
}
cc_test {
name: "yuvconvert",
gtest: false,
srcs: [
"util/yuvconvert.cc",
],
static_libs: ["libyuv"],
shared_libs: ["libjpeg"],
}