Frank Barchard 38ca05f1eb [libyuv] Fix color matrix, blend, NV layout and null pointer bugs
Correctness fixes:

- U010ToAB30 and U210ToAB30 swap U and V but passed
  kYuv2020Constants; use kYvu2020Constants as I010ToAB30 does.
- H420ToAR30 passed kYvuH709Constants without swapping U and V,
  so red and blue were swapped; use kYuvH709Constants.
- I420Blend with negative height flipped Y but not U and V.
- BlendPlaneRow_WASMSIMD processes 16 pixels per loop but was
  dispatched for widths that are a multiple of 8.
- I420Blend used ScaleRowDown2Box_RVV for odd widths, reading 1
  byte past the row. Add ScaleRowDown2Box_Odd_RVV.
- ConvertFromI420 to NV12/NV21/NV16 with odd width used a UV
  stride of width, overlapping UV rows and writing 1 byte past
  the plane. Use ((width + 1) / 2) * 2.
- ConvertToI420 (NV16/NV24) and ConvertToARGB (NV12/NV21/NV16/
  NV24) computed the Y plane size with the aligned width; the Y
  stride is src_width. NV24 UV stride is src_width * 2.
- I420Rect and I420Interpolate skipped a UV row for negative odd
  heights.
- DetilePlane and DetilePlane_16 accepted tile_height 0, reading
  past the source.
- Add null checks to NV12ToNV21, IxxxToPxxx, I422ToI210,
  I422ToNV21, YUY2ToI420, UYVYToI420, AYUVToNV12, AYUVToNV21,
  DetileSplitUVPlane and DetileToYUY2, and avoid pointer
  arithmetic on optional NULL src_y/dst_y with negative height.
  MT2TToP010 now returns -1 for NULL src_y with non-NULL dst_y.
- Replace unaligned uint32_t stores in row_common.cc with memcpy.
- Add LIBYUV_TARGET_AVX512VNNI to HammingDistance_AVX512VNNI so
  GCC accepts the k1 clobber on non-AVX512 builds.
- Check kCpuHasWASMSIMD instead of kCpuHasWASM in scale.cc and
  scale_uv.cc.
- Avoid the 16.16 fixed point NEON/LSX/RVV column scalers for
  src_width >= 32768, matching the existing AVX2 guard.

Performance:

- NV24ToI420 uses InterpolateRow, ScaleUVRowDown2Linear and
  SplitUVRow instead of a scalar loop (bit exact).
- Add HalfMergeUVRow_Any_NEON and MirrorSplitUVRow_Any_{NEON,
  LSX,LASX,WASMSIMD} so non-multiple-of-16 widths use SIMD.
- Enable BlendPlaneRow_SSSE3/AVX2 for row_win builds.
- Add missing LSX/LASX/RVV/SME dispatch for YUY2ToY,
  I422ToYUY2/UYVY, ARGBToY/UVMatrix, RAWToNVMatrix, AR64Shuffle,
  ARGBSobelize and Convert16To8Row in I010ToNV12, and coalesce
  rows in ARGBToI400Matrix.

Cleanup:

- UYVYToYRow_Any_AVX2 uses the same UVSHIFT/SBPP as YUY2.
- Add #ifdef HAS_* guards in compare_gcc.cc and row_gcc.cc.
- Remove unused clobbers and dead cnth/cmp/subs instructions in
  row_neon.cc, row_neon64.cc, row_sve.h, row_sve.cc and
  row_sme.cc, and order clobbers "memory", "cc" first.
- Re-enable the I420Blend_Any unit test.

Test: libyuv_unittest (x86-64 Release, rowwin, ASan, UBSan, MSan;
Arm64 SME, SVE2 and NEON on Samsung S26)
Bug: 579659306
Change-Id: Ic1afddbf961f7ef7deeba124a55907a31e09822d
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8702355
Reviewed-by: richard winterton <rrwinterton@gmail.com>
2026-11-02 10:06:18 -08:00
build_overrides [vpython] Migrate .vpython3 to vpython.toml 2026-09-18 00:28:26 -07:00
docs [libyuv] Upgrade x86 SIMD to AVX2/AVX-512 with 32-bit & row_win parity 2026-10-29 12:46:05 -07:00
include [libyuv] Fix color matrix, blend, NV layout and null pointer bugs 2026-11-02 10:06:18 -08:00
infra/config Use default xcode version in libyuv 2025-11-24 07:54:14 -08:00
riscv_script [libyuv] Fix RISC-V CMake/GN/Bazel builds and C compiler driver linking 2026-09-28 10:59:30 -07:00
source [libyuv] Fix color matrix, blend, NV layout and null pointer bugs 2026-11-02 10:06:18 -08:00
tools_libyuv Remove libyuv dependency on base/ 2025-01-08 09:04:21 -08:00
unit_test [libyuv] Fix color matrix, blend, NV layout and null pointer bugs 2026-11-02 10:06:18 -08:00
util [libyuv] Fix x86 SIMD OOB, math, alignment, MSan & GCC bugs 2026-10-30 14:51:16 -07:00
.clang-format clang-format libyuv 2016-11-07 17:37:23 -08:00
.gitignore DetilePlane and unittest for NEON 2022-01-31 20:05:55 +00:00
.gn [libyuv] Fix x86 SIMD OOB, math, alignment, MSan & GCC bugs 2026-10-30 14:51:16 -07:00
Android.bp [libyuv] Add Qualcomm Hexagon HVX SIMD support 2026-10-19 14:16:18 -07:00
Android.mk [libyuv] Add Qualcomm Hexagon HVX SIMD support 2026-10-19 14:16:18 -07:00
AUTHORS Fix same-width vertical point upsampling 2026-08-24 19:28:50 -07:00
BUILD.bazel [libyuv] Add WASM SIMD128 and Relaxed SIMD for RAWToRGB24Row 2026-10-05 17:45:41 -07:00
BUILD.gn [libyuv] Fix MSan AVX-512 intrinsics and standalone dynamic linker 2026-10-30 14:31:28 -07:00
CM_linux_packages.cmake Use grep extended regex for version 2024-11-13 02:11:17 +00:00
CMakeLists.txt [libyuv] Add Qualcomm Hexagon HVX SIMD support 2026-10-19 14:16:18 -07:00
codereview.settings [infra] remove no longer supported git cl upload setting. 2021-04-28 12:47:52 +00:00
DEPS [build] Use hermetic python3 for script_executable in .gn 2026-09-28 06:02:39 -07:00
DIR_METADATA Move metadata in OWNERS files to DIR_METADATA files 2021-02-09 19:34:43 +00:00
download_vs_toolchain.py Update pylintrc to a pep-8 like style 2024-12-18 05:38:56 -08:00
GEMINI.md [libyuv] Fix MSan AVX-512 intrinsics and standalone dynamic linker 2026-10-30 14:31:28 -07:00
libyuv.bzl [libyuv] Simplify RVV configuration in BUILD.bazel and libyuv.bzl 2026-09-08 17:50:17 -07:00
libyuv.gni [libyuv] Fix RISC-V CMake/GN/Bazel builds and C compiler driver linking 2026-09-28 10:59:30 -07:00
libyuv.gyp Stop setting --dynamic-linker for target_os="android" 2026-05-27 04:34:07 -07:00
libyuv.gypi [libyuv] Add Qualcomm Hexagon HVX SIMD support 2026-10-19 14:16:18 -07:00
LICENSE Update Copyright notice to follow new chromium conventions. 2012-08-08 19:04:24 +00:00
linux.mk [libyuv] Optimize SsimWindowRow with SIMD and use compare_win on x86 2026-10-20 15:00:52 -07:00
OWNERS Remove magjed from OWNERS 2026-08-24 10:43:21 -07:00
PATENTS LibYuv: Adding PATENT and LICENSE files 2011-10-25 16:15:49 +00:00
PRESUBMIT.py Update pylintrc to a pep-8 like style 2024-12-18 05:38:56 -08:00
public.mk use unix line endings 2018-06-20 23:19:59 +00:00
pylintrc Update pylintrc to a pep-8 like style 2024-12-18 05:38:56 -08:00
README.chromium [libyuv] Upgrade x86 SIMD to AVX2/AVX-512 with 32-bit & row_win parity 2026-10-29 12:46:05 -07:00
README.md Update README.md and environment_variables.md for Arm 2024-09-20 00:29:33 +00:00
vpython.toml [vpython] Migrate .vpython3 to vpython.toml 2026-09-18 00:28:26 -07:00
vpython.toml.uv.lock [vpython] Migrate .vpython3 to vpython.toml 2026-09-18 00:28:26 -07:00
winarm.mk NV12 Copy, include scale_uv.h 2020-12-08 18:54:16 +00:00
WORKSPACE.bazel Add Bazel build support 2026-04-15 18:20:26 -07:00

libyuv is an open source project that includes YUV scaling and conversion functionality.

  • Scale YUV to prepare content for compression, with point, bilinear or box filter.
  • Convert to YUV from webcam formats for compression.
  • Convert to RGB formats for rendering/effects.
  • Rotate by 90/180/270 degrees to adjust for mobile devices in portrait mode.
  • Optimized for SSSE3/AVX2 on x86/x64.
  • Optimized for Neon/SVE2/SME on Arm.
  • Optimized for MSA on Mips.
  • Optimized for RVV on RISC-V.

Development

See Getting started for instructions on how to get started developing.

You can also browse the docs directory for more documentation.