mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-11-09 14:49:57 +08:00
Expand WebAssembly SIMD128 (_WASMSIMD) and WebAssembly Relaxed SIMD (_RELAXEDSIMD) optimizations across compare, rotate, convert, and scale row functions. Add a distinct kCpuHasRELAXEDSIMD (0x200) capability flag and runtime WasmCpuCaps() detection modeled after XNNPACK, probing whether wasm_i8x16_relaxed_swizzle or wasm_f32x4_relaxed_madd exhibit hardware-specific Relaxed SIMD behavior at runtime. Support disabling Relaxed SIMD alone (LIBYUV_DISABLE_RELAXEDSIMD), Wasm SIMD128 alone (LIBYUV_DISABLE_WASMSIMD), or all Wasm SIMD (LIBYUV_DISABLE_WASM) via compile-time macros or runtime environment variables. Compare (6 functions): C Function x86 Arm Wasm ----------------- ---------- ------------ ----------- HammingDistance_C AVX512VNNI NEON_DOTPROD RELAXEDSIMD SumSquareError_C AVX512VNNI NEON_DOTPROD WASMSIMD HashDjb2_C AVX512BW NEON WASMSIMD Ssim4x4Row_C AVX512BW SME WASMSIMD SsimWindowRow_C AVX512BW SME WASMSIMD ARGBDetectRow_C AVX2 NEON WASMSIMD ----------------- ---------- ------------ ----------- Count (6) 6/6 6/6 6/6 Percentage 100.0% 100.0% 100.0% Rotate (7 functions): C Function x86 Arm Wasm ----------------- -------- ------ -------- TransposeWx8_C AVX2 NEON WASMSIMD TransposeWx16_C AVX512BW NEON WASMSIMD TransposeUVWx8_C AVX2 NEON WASMSIMD TransposeUVWx16_C AVX512BW - WASMSIMD TransposeWx8_16_C AVX2 SVE2 WASMSIMD TransposeWxH_32_C AVX2 SME - TransposeWx4_32_C AVX2 SVE2 WASMSIMD ----------------- -------- ------ -------- Count (7) 7/7 6/7 6/7 Percentage 100.0% 85.7% 85.7% Convert (171 functions): C Function x86 Arm Wasm --------------------------- ---------- ------------ ----------- ARGBToYMatrixRow_C AVX512VNNI SME WASMSIMD ARGBToUVMatrixRow_C AVX512VNNI SME RELAXEDSIMD RGBToYMatrixRow_C AVX512BW NEON_DOTPROD RELAXEDSIMD RGBToUVMatrixRow_C AVX512BW NEON RELAXEDSIMD RGBToUV444MatrixRow_C AVX512BW NEON RELAXEDSIMD RGB565ToYMatrixRow_C AVX2 NEON WASMSIMD ARGB1555ToYMatrixRow_C AVX2 NEON WASMSIMD ARGB1555ToUVMatrixRow_C AVX2 NEON WASMSIMD ARGB4444ToYMatrixRow_C AVX2 NEON WASMSIMD ARGB4444ToUVMatrixRow_C AVX2 NEON WASMSIMD RGB565ToUVMatrixRow_C AVX2 NEON WASMSIMD ARGBToUV444MatrixRow_C AVX512VNNI NEON_I8MM RELAXEDSIMD RGB565ToYRow_C AVX2 NEON - ARGB1555ToYRow_C AVX2 NEON - ARGB4444ToYRow_C AVX2 NEON - RGB565ToUVRow_C AVX2 NEON - ARGB1555ToUVRow_C AVX2 NEON - ARGB4444ToUVRow_C AVX2 NEON - MirrorRow_C AVX512BW NEON RELAXEDSIMD MirrorUVRow_C AVX512BW NEON RELAXEDSIMD MirrorSplitUVRow_C AVX512BW NEON RELAXEDSIMD MirrorRow_16_C AVX512BW NEON - ARGBMirrorRow_C AVX512BW NEON WASMSIMD RGB24MirrorRow_C AVX512VBMI NEON RELAXEDSIMD SplitUVRow_C AVX512BW SME WASMSIMD DetileRow_C AVX2 NEON WASMSIMD DetileRow_16_C AVX2 NEON WASMSIMD DetileSplitUVRow_C AVX2 NEON WASMSIMD DetileToYUY2_C AVX2 NEON WASMSIMD UnpackMT2T_C AVX2 NEON - MergeUVRow_C AVX512BW SME WASMSIMD HalfMergeUVRow_C AVX512BW SME WASMSIMD SplitRGBRow_C AVX2 NEON RELAXEDSIMD MergeRGBRow_C AVX512VBMI NEON RELAXEDSIMD MergeARGBRow_C AVX2 NEON WASMSIMD SplitARGBRow_C AVX2 NEON WASMSIMD MergeXRGBRow_C AVX2 NEON WASMSIMD SplitXRGBRow_C AVX2 NEON WASMSIMD MergeXR30Row_C AVX2 NEON - MergeAR64Row_C AVX2 NEON - MergeARGB16To8Row_C AVX2 NEON - MergeXR64Row_C AVX2 NEON - MergeXRGB16To8Row_C AVX2 NEON - MergeUVRow_16_C AVX512BW SME WASMSIMD SplitUVRow_16_C AVX2 NEON WASMSIMD MultiplyRow_16_C AVX512BW SME WASMSIMD DivideRow_16_C AVX512BW SME WASMSIMD Convert8To16Row_C AVX512BW SME WASMSIMD Convert16To8Row_C AVX512BW SME WASMSIMD HalfRow_C AVX2 SME WASMSIMD HalfRow_16_C AVX2 SME WASMSIMD HalfRow_16To8_C AVX512BW SME WASMSIMD HalfWidthRow_16To8_C AVX512BW SME WASMSIMD HalfWidthRow_16To8_Odd_C AVX2 NEON - Convert8To8Row_C AVX512BW SME WASMSIMD CopyRow_C AVX512BW SME WASMSIMD CopyRow_16_C AVX2 NEON WASMSIMD ARGBCopyAlphaRow_C AVX2 NEON WASMSIMD ARGBExtractAlphaRow_C AVX512BW NEON WASMSIMD ARGBCopyYToAlphaRow_C AVX512BW NEON RELAXEDSIMD SetRow_C AVX2 NEON WASMSIMD ARGBSetRow_C AVX2 NEON WASMSIMD ARGBShuffleRow_C AVX512BW NEON RELAXEDSIMD RGB24ToARGBRow_C AVX512BW SME RELAXEDSIMD RAWToARGBRow_C AVX512BW SME RELAXEDSIMD RAWToRGBARow_C AVX512VBMI SME RELAXEDSIMD RAWToRGB24Row_C AVX512VBMI SME RELAXEDSIMD RGB565ToARGBRow_C AVX2 NEON WASMSIMD ARGB1555ToARGBRow_C AVX512BW SME WASMSIMD ARGB4444ToARGBRow_C AVX2 NEON WASMSIMD AR30ToARGBRow_C AVX512BW NEON WASMSIMD AR30ToABGRRow_C AVX512BW NEON WASMSIMD ARGBToAR30Row_C AVX512BW NEON WASMSIMD AR30ToAB30Row_C AVX512BW NEON WASMSIMD ARGBToRGB565DitherRow_C AVX512BW SME WASMSIMD ARGBToABGRRow_C - - - ARGBToBGRARow_C - - - ARGBToRGBARow_C - - - ARGBToRGB24Row_C AVX512BW SME RELAXEDSIMD ARGBToRAWRow_C AVX512BW SME RELAXEDSIMD ARGBToRGB565Row_C AVX512BW SME WASMSIMD ARGBToARGB1555Row_C AVX2 NEON WASMSIMD ARGBToARGB4444Row_C AVX2 NEON WASMSIMD ABGRToAR30Row_C AVX512BW NEON WASMSIMD ARGBToAR64Row_C AVX2 NEON WASMSIMD ARGBToAB64Row_C AVX2 NEON WASMSIMD AR64ToARGBRow_C AVX2 NEON WASMSIMD AB64ToARGBRow_C AVX2 NEON WASMSIMD AR64ToAB64Row_C - - - RGBAToARGBRow_C - - - AR64ShuffleRow_C - - - J400ToARGBRow_C AVX512BW NEON RELAXEDSIMD I444ToARGBRow_C AVX512BW SME WASMSIMD I444ToRGB24Row_C AVX512VBMI SME RELAXEDSIMD I422ToARGBRow_C AVX512BW SME WASMSIMD I422ToAR30Row_C AVX512BW SME WASMSIMD I210ToAR30Row_C AVX512BW SME WASMSIMD I210ToARGBRow_C AVX512BW SME WASMSIMD I212ToAR30Row_C AVX512BW SME - I212ToARGBRow_C AVX512BW SME - I410ToAR30Row_C AVX512BW SME WASMSIMD I410ToARGBRow_C AVX512BW SME WASMSIMD I210AlphaToARGBRow_C AVX512BW SME WASMSIMD I410AlphaToARGBRow_C AVX512BW SME WASMSIMD I444AlphaToARGBRow_C AVX512BW SME WASMSIMD I422AlphaToARGBRow_C AVX512BW SME WASMSIMD NV12ToARGBRow_C AVX512BW SME WASMSIMD NV12ToRGB565Row_C AVX2 NEON WASMSIMD NV21ToARGBRow_C AVX512BW SME WASMSIMD NV12ToRGB24Row_C AVX512VBMI SME RELAXEDSIMD NV21ToRGB24Row_C AVX512VBMI SME RELAXEDSIMD NV21ToYUV24Row_C AVX512VBMI NEON - YUY2ToARGBRow_C AVX512BW SME WASMSIMD UYVYToARGBRow_C AVX512BW SME WASMSIMD P210ToARGBRow_C AVX512BW SME - P410ToARGBRow_C AVX512BW SME - P210ToAR30Row_C AVX512BW SME - P410ToAR30Row_C AVX512BW SME - I422ToRGBARow_C AVX512BW SME WASMSIMD I422ToRGB24Row_C AVX512VBMI SME RELAXEDSIMD I422ToARGB4444Row_C AVX512BW SME WASMSIMD I422ToARGB1555Row_C AVX512BW SME WASMSIMD I422ToRGB565Row_C AVX512BW SME WASMSIMD I400ToARGBRow_C AVX512BW SME RELAXEDSIMD ARGBBlendRow_C AVX512BW NEON RELAXEDSIMD BlendPlaneRow_C AVX512BW NEON WASMSIMD ARGBMultiplyRow_C AVX512BW SME WASMSIMD ARGBAddRow_C AVX2 NEON WASMSIMD ARGBSubtractRow_C AVX2 NEON WASMSIMD ARGBOrRow_C AVX512BW SME WASMSIMD ARGBAlphaBlendRow_C AVX512BW SME WASMSIMD YUY2ToYRow_C AVX512BW SME WASMSIMD YUY2ToUVRow_C AVX512BW SME WASMSIMD YUY2ToNVUVRow_C AVX2 NEON WASMSIMD YUY2ToUV422Row_C AVX512BW NEON WASMSIMD UYVYToYRow_C AVX512BW SME WASMSIMD UYVYToUVRow_C AVX512BW SME WASMSIMD UYVYToUV422Row_C AVX512BW NEON WASMSIMD SwapUVRow_C AVX512BW NEON WASMSIMD AYUVToYRow_C AVX512VBMI NEON WASMSIMD AYUVToUVRow_C AVX512VBMI SME RELAXEDSIMD AYUVToVURow_C AVX512VBMI SME RELAXEDSIMD I422ToYUY2Row_C AVX2 NEON WASMSIMD I422ToUYVYRow_C AVX2 NEON WASMSIMD ARGBAttenuateRow_C AVX512BW NEON RELAXEDSIMD ARGBUnattenuateRow_C AVX2 NEON - ARGBGrayRow_C AVX512VNNI NEON_DOTPROD RELAXEDSIMD ARGBSepiaRow_C AVX512VNNI NEON_DOTPROD RELAXEDSIMD ARGBColorMatrixRow_C AVX512VNNI NEON_I8MM WASMSIMD ARGBColorTableRow_C AVX2 NEON - RGBColorTableRow_C AVX2 NEON - ARGBQuantizeRow_C AVX2 NEON WASMSIMD ARGBShadeRow_C AVX2 NEON WASMSIMD CumulativeSumToAverageRow_C AVX2 NEON - ComputeCumulativeSumRow_C AVX2 NEON - ARGBAffineRow_C AVX2 NEON - InterpolateRow_C AVX512BW SME WASMSIMD InterpolateRow_16_C AVX512BW SME WASMSIMD SobelXRow_C AVX2 NEON WASMSIMD SobelYRow_C AVX2 NEON WASMSIMD SobelRow_C AVX2 NEON RELAXEDSIMD SobelToPlaneRow_C AVX2 NEON WASMSIMD SobelXYRow_C AVX2 NEON WASMSIMD ARGBPolynomialRow_C AVX2 NEON WASMSIMD HalfFloatRow_C AVX512BW SME WASMSIMD ByteToFloatRow_C AVX2 NEON WASMSIMD ARGBLumaColorTableRow_C AVX2 NEON WASMSIMD GaussRow_F32_C AVX2 NEON - GaussCol_F32_C AVX2 NEON - GaussRow_C AVX2 NEON - GaussCol_C AVX2 NEON - --------------------------- ---------- ------------ ----------- Count (171) 165/171 165/171 134/171 Percentage 96.5% 96.5% 78.4% Scale (86 functions): C Function x86 Arm Wasm ------------------------------- ---------- ------ ----------- FixedDiv_C - - - FixedDiv1_C - - - ScaleRowDown2_C AVX512BW SME WASMSIMD ScaleRowDown2_16_C AVX2 SME - ScaleRowDown2Linear_C AVX512BW SME WASMSIMD ScaleRowDown2Linear_16_C AVX2 SME - ScaleRowDown2Box_C AVX512BW SME WASMSIMD ScaleRowDown2Box_Odd_C AVX512BW NEON WASMSIMD ScaleRowDown2Box_16_C AVX2 SME - ScaleRowDown4_C AVX2 NEON WASMSIMD ScaleRowDown4_16_C - - - ScaleRowDown4Box_C AVX2 NEON WASMSIMD ScaleRowDown4Box_16_C - - - ScaleRowDown34_C AVX2 NEON RELAXEDSIMD ScaleRowDown34_16_C - - - ScaleRowDown34_0_Box_C AVX2 NEON RELAXEDSIMD ScaleRowDown34_0_Box_16_C - - - ScaleRowDown34_1_Box_C AVX2 NEON RELAXEDSIMD ScaleRowDown34_1_Box_16_C - - - ScaleRowUp2_Linear_C AVX2 NEON RELAXEDSIMD ScaleRowUp2_Bilinear_C AVX2 NEON RELAXEDSIMD ScaleRowUp2_Linear_16_C AVX2 NEON - ScaleRowUp2_Bilinear_16_C AVX2 NEON - ScaleRowUp2_Linear_Any_C AVX2 NEON RELAXEDSIMD ScaleRowUp2_Bilinear_Any_C AVX2 NEON RELAXEDSIMD ScaleRowUp2_Linear_16_Any_C AVX2 NEON - ScaleRowUp2_Bilinear_16_Any_C AVX2 NEON - ScaleCols_C - - - ScaleCols_16_C - - - ScaleColsUp2_C AVX2 - - ScaleColsUp2_16_C - - - ScaleFilterCols_C AVX2 NEON WASMSIMD ScaleFilterCols_16_C - - - ScaleFilterCols64_C - - - ScaleFilterCols64_16_C - - - ScaleRowDown38_C AVX2 NEON RELAXEDSIMD ScaleRowDown38_16_C - - - ScaleRowDown38_3_Box_C AVX2 NEON RELAXEDSIMD ScaleRowDown38_3_Box_16_C - - - ScaleRowDown38_2_Box_C AVX2 NEON RELAXEDSIMD ScaleRowDown38_2_Box_16_C - - - ScaleAddRow_C AVX512BW NEON WASMSIMD ScaleAddRow_16_C - - - ScaleARGBRowDown2_C AVX2 SME WASMSIMD ScaleARGBRowDown2Linear_C AVX2 SME WASMSIMD ScaleARGBRowDown2Box_C AVX2 SME WASMSIMD ScaleARGBRowDownEven_C AVX2 NEON WASMSIMD ScaleARGBRowDownEvenBox_C AVX2 NEON WASMSIMD ScaleARGBCols_C AVX2 NEON WASMSIMD ScaleARGBCols64_C - - - ScaleARGBColsUp2_C AVX2 - WASMSIMD ScaleARGBFilterCols_C AVX2 NEON WASMSIMD ScaleARGBFilterCols64_C - - - ScaleUVRowDown2_C AVX2 SME WASMSIMD ScaleUVRowDown2_16_C - - - ScaleUVRowDown2Linear_C AVX2 SME WASMSIMD ScaleUVRowDown2Linear_16_C - - - ScaleUVRowDown2Box_C AVX2 SME WASMSIMD ScaleUVRowDown2Box_16_C - - - ScaleUVRowDownEven_C AVX2 NEON WASMSIMD ScaleUVRowDownEven_16_C - - - ScaleUVRowDownEvenBox_C - - - ScaleUVRowDownEvenBox_16_C - - - ScaleUVRowUp2_Linear_C AVX2 NEON RELAXEDSIMD ScaleUVRowUp2_Bilinear_C AVX2 NEON RELAXEDSIMD ScaleUVRowUp2_Linear_Any_C AVX2 NEON RELAXEDSIMD ScaleUVRowUp2_Bilinear_Any_C AVX2 NEON RELAXEDSIMD ScaleUVRowUp2_Linear_16_C AVX2 NEON - ScaleUVRowUp2_Bilinear_16_C AVX2 NEON - ScaleUVRowUp2_Linear_16_Any_C AVX2 NEON - ScaleUVRowUp2_Bilinear_16_Any_C AVX2 NEON - ScaleUVCols_C - - - ScaleUVCols_16_C - - - ScaleUVCols64_C - - - ScaleUVCols64_16_C - - - ScaleUVColsUp2_C - - - ScaleUVColsUp2_16_C - - - ScaleUVFilterCols_C - - - ScaleUVFilterCols_16_C - - - ScaleUVFilterCols64_C - - - ScaleUVFilterCols64_16_C - - - ScaleUVAddCols3_C AVX512VBMI SME WASMSIMD ScaleUVAddCols3_16_C - - - ScaleMaxSamples_C AVX2 NEON WASMSIMD ScaleSumSamples_C AVX2 NEON WASMSIMD ScaleSamples_C AVX2 NEON WASMSIMD ------------------------------- ---------- ------ ----------- Count (86) 50/86 48/86 38/86 Percentage 58.1% 55.8% 44.2% Bug: 42280942 Change-Id: I4420a570327a95cc998c6aa023286a0b3552f742 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8724066 Reviewed-by: richard winterton <rrwinterton@gmail.com> Commit-Queue: Frank Barchard <fbarchard@google.com> |
||
|---|---|---|
| build_overrides | ||
| docs | ||
| include | ||
| infra/config | ||
| riscv_script | ||
| source | ||
| tools_libyuv | ||
| unit_test | ||
| util | ||
| .clang-format | ||
| .gitignore | ||
| .gn | ||
| Android.bp | ||
| Android.mk | ||
| AUTHORS | ||
| BUILD.bazel | ||
| BUILD.gn | ||
| CM_linux_packages.cmake | ||
| CMakeLists.txt | ||
| codereview.settings | ||
| DEPS | ||
| DIR_METADATA | ||
| download_vs_toolchain.py | ||
| GEMINI.md | ||
| libyuv.bzl | ||
| libyuv.gni | ||
| libyuv.gyp | ||
| libyuv.gypi | ||
| LICENSE | ||
| linux.mk | ||
| OWNERS | ||
| PATENTS | ||
| PRESUBMIT.py | ||
| public.mk | ||
| pylintrc | ||
| README.chromium | ||
| README.md | ||
| vpython.toml | ||
| vpython.toml.uv.lock | ||
| winarm.mk | ||
| WORKSPACE.bazel | ||
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.