8 Commits

Author SHA1 Message Date
Frank Barchard
39445fa162 [libyuv] Fix RISC-V CMake/GN/Bazel builds and C compiler driver linking
- Use -fno-tree-vectorize and -fno-tree-slp-vectorize instead of
  Clang-only -fno-vectorize and -fno-slp-vectorize in CMakeLists.txt,
  riscv-clang.cmake, BUILD.gn, and BUILD.bazel for GCC and Clang
  compatibility.
- Split row_rvv.cc and scale_rvv.cc into a dedicated libyuv_rvv target
  in BUILD.gn and define LIBYUV_RVV so callers in row.h and scale_row.h
  can dispatch to RVV kernels when built without global -march=rv64gcv.
- Guard the x86 AVX512-BF16 vdpphps inline assembly probe in
  util/cpuid.c with __i386__ / __x86_64__.
- Replace new/delete and new[]/delete[] with calloc/malloc/free in
  source/mjpeg_decoder.cc and util/yuvconvert.cc to avoid C++ standard
  library dependencies, and link libm for yuvconstants and
  libyuv_unittest in CMakeLists.txt.

Test: cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
Bug: None
Change-Id: I701c0625f2730e864806556213a5e013c931e2d6
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8464751
Reviewed-by: richard winterton <rrwinterton@gmail.com>
Commit-Queue: Frank Barchard <fbarchard@google.com>
2026-09-28 10:59:30 -07:00
Frank Barchard
fab11704cd [libyuv] Use Armv8.5-A architecture flags for SME and SVE2 build targets
Update BUILD.gn, CMakeLists.txt, and BUILD.bazel to specify Armv8.5-A
baseline architecture flags rather than Armv9:
- BUILD.gn: update :libyuv_sve to -march=armv8.5-a+i8mm+sve2 and
  :libyuv_sme to -march=armv8.5-a+i8mm+sme.
- CMakeLists.txt: update SME check and compile options to
  -march=armv8.5-a+i8mm+sme (SVE target already uses armv8.5-a).
- BUILD.bazel: update ENABLE_SVE_COPTS to -march=armv8.5-a+i8mm+sve2.

Using -march=armv9-a enabled baseline SVE in the compiler, causing
Clang to emit non-streaming SVE instructions (such as cntd in function
prologues prior to smstart) in SME translation units. On processors
such as Apple M4/M5 that support SME but not SVE, executing these
prologue instructions resulted in SIGILL crashes.

Test: ninja -C out/arm64.release libyuv libyuv_unittest
Bug: 558654023
Change-Id: Ic7f62842bc9bd71608cc78ad11fd5e2214ef5e8e
TAG=agy
CONV=a70f0e53-caf2-4fbe-a024-1616ed25ba9a
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8376021
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Reviewed-by: Wan-Teh Chang <wtc@google.com>
2026-09-09 09:17:24 -07:00
Frank Barchard
137e29972e [libyuv] Simplify RVV configuration in BUILD.bazel and libyuv.bzl
Restructure RISC-V Vector (RVV) configuration to follow the pattern
used by NEON and SVE:
- Move RVV_COPTS immediately after SVE_COPTS.
- Define ENABLE_RVV_COPTS (-march=rv32gcv) and ENABLE_RVV64_COPTS
  (-march=rv64gcv) with SUPPORTS_RVV_COPTS (-DLIBYUV_RVV).
- Revert ALL_COPTS to PLATFORM_COPTS so RVV vector flags are not
  applied to generic sources.
- Add ALL_RVV_COPTS, RVV_DEPS, and libyuv_rvv_impl target.
- Update libyuv.bzl to add libyuv_rvv_srcs and exclude source/*rvv*.cc
  from libyuv_srcs.

R=wtc@google.com

Test: cmake -B out/Release -DUNIT_TEST=ON && cmake --build out/Release
Bug: none
Change-Id: Ia60a8bc1da9db46f0c5295064d7b9d3d5609a38f
TAG=agy
CONV=06856819-10a7-4815-93d3-cdcd32da7495
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8357976
Reviewed-by: richard winterton <rrwinterton@gmail.com>
2026-09-08 17:50:17 -07:00
Frank Barchard
af1aaca840 Enable RVV support in CMake and Bazel for RISC-V targets
Enable RISC-V Vector (RVV) by default when building natively on RISC-V
platforms (such as SpacemiT K1/K3) using CMake and Bazel:
- CMakeLists.txt: Detect riscv64 and riscv32, probe compiler support
  for -march=rv64gcv / -march=rv32gcv, and append architecture flags
  with auto-vectorization disabled (-fno-vectorize -fno-slp-vectorize).
  Support custom architecture flags via -DRISCV_COMPILER_FLAGS and
  provide -DUSE_RVV=OFF to disable.
- BUILD.bazel: Add RVV_COPTS for @platforms//cpu:riscv64 and
  @platforms//cpu:riscv32 with -fno-vectorize.
- docs/getting_started.md: Document native SBC builds, custom targets
  (SiFive X280, Coral 32-bit Zve32x), Bazel, and Blaze commands.

Test: cmake build on host and simulated riscv64; clang cross-compile tests
Bug: none
Change-Id: Iecb20b73b2934b6477e7e0c71b3539a8251e4e8b
TAG=agy
CONV=2f28dd8a-c892-4c29-8aed-606afd090398
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8349493
Reviewed-by: richard winterton <rrwinterton@gmail.com>
Commit-Queue: Frank Barchard <fbarchard@google.com>
2026-09-04 13:20:27 -07:00
Wan-Teh Chang
7ad044836d Do not use glob in the hdrs list of libyuv library
Some headers in the include/libyuv directory are private headers and
should not be visible to the clients of the libyuv library target. List
the public headers explicitly in the hdrs list of the libyuv library
target.

Ideally those private headers should be moved to some other directory
such as the source/ directory.

Change-Id: I04b1e209f6891f06c688fcf0bf5d167e82a27818
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8308801
Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Reviewed-by: Frank Barchard <fbarchard@google.com>
2026-08-28 15:17:28 -07:00
Frank Barchard
cb6c9d6fd9 Remove LIBYUV_UNBIASED_DATA and make unbiased AR30 rounding default
Remove the LIBYUV_UNBIASED_DATA macro and make the unbiased AR30
rounding bias adjustment (+24 / -24) default across all x86, ARM, and C
implementations.

Bug: 551985141
Test: libyuv_unittest --gtest_filter=*AR30*:*AB30*
Change-Id: I4a9b964ceef1d08580789cbba8c94846053c9d68
TAG=agy
CONV=15289919-ad91-40b2-9ed5-30c3117a5ba4
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8305516
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Reviewed-by: Wan-Teh Chang <wtc@google.com>
2026-08-27 17:42:40 -07:00
Wan-Teh Chang
086698434d Enable LIBYUV_UNBIASED_DATA
LIBYUV_UNBIASED_DATA is a new configuration macro introduced in
commit ba68378. It fixes the AR30 rounding bias offset (+24 / -24) for
10-bit YUV to RGB conversions.

Bug: 551985141
Change-Id: Id724d8cabaee441147d998f77034bc3e31c25a9d
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8298160
Reviewed-by: Frank Barchard <fbarchard@google.com>
2026-08-26 11:19:33 -07:00
Frank Barchard
0d8494abc0 Add Bazel build support
Change-Id: Idf205997010a95f975dbd347e268e36c2072f797
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/7745020
Reviewed-by: Wan-Teh Chang <wtc@google.com>
Reviewed-by: richard winterton <rrwinterton@gmail.com>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
2026-04-15 18:20:26 -07:00