mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-17 23:08:35 +00:00
[libyuv] Update to hash 79ca9187e540faaaca47b34622e110d07f335d05 from https://chromium.googlesource.com/libyuv/libyuv/ (#3288)
* [libyuv] Update to hash 79ca9187e540faaaca47b34622e110d07f335d05 from https://chromium.googlesource.com/libyuv/libyuv/ * [libyuv] Build AArch64 dotprod/i8mm/SVE/SME kernels with per-file -march to fix arm64/macOS build * [libyuv] Fix build with GCC HammingDistance_AVX512VNNI clobbers k1 but lacks the LIBYUV_TARGET_AVX512VNNI attribute that its siblings use, so GCC on x86_64 fails with "the register 'k1' cannot be clobbered in 'asm' for the current target". ARGBAlphaBlendRow_SVE_SC uses "mov z25.s, #0x01010101", which the GNU assembler rejects as an invalid replicated MOV immediate. Use the equivalent "mov z25.b, #1", which sets the same value and is accepted by both GNU as and LLVM. * [libyuv] Fix function declaration without a prototype * [libyuv] Disable scan-build warnings.
This commit is contained in:
211 files changed
+149576
-52652
No files matched your search
+58
-12
@@ -179,10 +179,9 @@ libfreeswitch_libyuv_la_SOURCES = \
|
||||
libs/libyuv/source/compare.cc \
|
||||
libs/libyuv/source/compare_common.cc \
|
||||
libs/libyuv/source/compare_gcc.cc \
|
||||
libs/libyuv/source/compare_mmi.cc \
|
||||
libs/libyuv/source/compare_msa.cc \
|
||||
libs/libyuv/source/compare_neon64.cc \
|
||||
libs/libyuv/source/compare_hvx.cc \
|
||||
libs/libyuv/source/compare_neon.cc \
|
||||
libs/libyuv/source/compare_wasm.cc \
|
||||
libs/libyuv/source/compare_win.cc \
|
||||
libs/libyuv/source/convert_argb.cc \
|
||||
libs/libyuv/source/convert.cc \
|
||||
@@ -200,33 +199,80 @@ libs/libyuv/source/rotate_argb.cc \
|
||||
libs/libyuv/source/rotate.cc \
|
||||
libs/libyuv/source/rotate_common.cc \
|
||||
libs/libyuv/source/rotate_gcc.cc \
|
||||
libs/libyuv/source/rotate_mmi.cc \
|
||||
libs/libyuv/source/rotate_msa.cc \
|
||||
libs/libyuv/source/rotate_neon64.cc \
|
||||
libs/libyuv/source/rotate_hvx.cc \
|
||||
libs/libyuv/source/rotate_lasx.cc \
|
||||
libs/libyuv/source/rotate_lsx.cc \
|
||||
libs/libyuv/source/rotate_neon.cc \
|
||||
libs/libyuv/source/rotate_rvv.cc \
|
||||
libs/libyuv/source/rotate_wasm.cc \
|
||||
libs/libyuv/source/rotate_win.cc \
|
||||
libs/libyuv/source/row_any.cc \
|
||||
libs/libyuv/source/row_common.cc \
|
||||
libs/libyuv/source/row_gcc.cc \
|
||||
libs/libyuv/source/row_mmi.cc \
|
||||
libs/libyuv/source/row_msa.cc \
|
||||
libs/libyuv/source/row_neon64.cc \
|
||||
libs/libyuv/source/row_hvx.cc \
|
||||
libs/libyuv/source/row_lasx.cc \
|
||||
libs/libyuv/source/row_lsx.cc \
|
||||
libs/libyuv/source/row_neon.cc \
|
||||
libs/libyuv/source/row_rvv.cc \
|
||||
libs/libyuv/source/row_wasm.cc \
|
||||
libs/libyuv/source/row_win.cc \
|
||||
libs/libyuv/source/scale_any.cc \
|
||||
libs/libyuv/source/scale_argb.cc \
|
||||
libs/libyuv/source/scale.cc \
|
||||
libs/libyuv/source/scale_common.cc \
|
||||
libs/libyuv/source/scale_gcc.cc \
|
||||
libs/libyuv/source/scale_mmi.cc \
|
||||
libs/libyuv/source/scale_msa.cc \
|
||||
libs/libyuv/source/scale_neon64.cc \
|
||||
libs/libyuv/source/scale_hvx.cc \
|
||||
libs/libyuv/source/scale_lsx.cc \
|
||||
libs/libyuv/source/scale_neon.cc \
|
||||
libs/libyuv/source/scale_rgb.cc \
|
||||
libs/libyuv/source/scale_rvv.cc \
|
||||
libs/libyuv/source/scale_uv.cc \
|
||||
libs/libyuv/source/scale_wasm.cc \
|
||||
libs/libyuv/source/scale_win.cc \
|
||||
libs/libyuv/source/video_common.cc
|
||||
|
||||
|
||||
libfreeswitch_libyuv_la_CPPFLAGS = -O2 -fomit-frame-pointer -Ilibs/libyuv/include
|
||||
libfreeswitch_libyuv_la_LIBADD =
|
||||
|
||||
# libyuv's AArch64 dot-product (udot), i8mm (usdot), SVE and SME kernels emit
|
||||
# instructions outside the baseline armv8-a target and are selected at runtime
|
||||
# by libyuv's own CPU detection. Build them as separate objects with the
|
||||
# required -march flags so the rest of the library stays portable to any
|
||||
# armv8-a CPU. This mirrors libs/libyuv/CMakeLists.txt.
|
||||
if LIBYUV_AARCH64
|
||||
noinst_LTLIBRARIES += libfreeswitch_libyuv_neon64.la
|
||||
libfreeswitch_libyuv_neon64_la_SOURCES = \
|
||||
libs/libyuv/source/compare_neon64.cc \
|
||||
libs/libyuv/source/rotate_neon64.cc \
|
||||
libs/libyuv/source/row_neon64.cc \
|
||||
libs/libyuv/source/scale_neon64.cc
|
||||
libfreeswitch_libyuv_neon64_la_CPPFLAGS = $(libfreeswitch_libyuv_la_CPPFLAGS)
|
||||
libfreeswitch_libyuv_neon64_la_CXXFLAGS = -march=armv8.2-a+dotprod+i8mm
|
||||
libfreeswitch_libyuv_la_LIBADD += libfreeswitch_libyuv_neon64.la
|
||||
|
||||
noinst_LTLIBRARIES += libfreeswitch_libyuv_sve.la
|
||||
libfreeswitch_libyuv_sve_la_SOURCES = \
|
||||
libs/libyuv/source/rotate_sve.cc \
|
||||
libs/libyuv/source/row_sve.cc
|
||||
libfreeswitch_libyuv_sve_la_CPPFLAGS = $(libfreeswitch_libyuv_la_CPPFLAGS)
|
||||
libfreeswitch_libyuv_sve_la_CXXFLAGS = -march=armv8.5-a+i8mm+sve2
|
||||
libfreeswitch_libyuv_la_LIBADD += libfreeswitch_libyuv_sve.la
|
||||
|
||||
if LIBYUV_AARCH64_SME
|
||||
noinst_LTLIBRARIES += libfreeswitch_libyuv_sme.la
|
||||
libfreeswitch_libyuv_sme_la_SOURCES = \
|
||||
libs/libyuv/source/rotate_sme.cc \
|
||||
libs/libyuv/source/row_sme.cc \
|
||||
libs/libyuv/source/scale_sme.cc
|
||||
libfreeswitch_libyuv_sme_la_CPPFLAGS = $(libfreeswitch_libyuv_la_CPPFLAGS)
|
||||
libfreeswitch_libyuv_sme_la_CXXFLAGS = -march=armv8.5-a+i8mm+sme
|
||||
libfreeswitch_libyuv_la_LIBADD += libfreeswitch_libyuv_sme.la
|
||||
else
|
||||
libfreeswitch_libyuv_la_CPPFLAGS += -DLIBYUV_DISABLE_SME
|
||||
endif
|
||||
endif
|
||||
|
||||
CORE_LIBS+=libfreeswitch_libyuv.la
|
||||
endif
|
||||
|
||||
|
||||
@@ -549,6 +549,28 @@ AC_ARG_ENABLE(libyuv,
|
||||
|
||||
AM_CONDITIONAL([ENABLE_LIBYUV],[test "${enable_libyuv}" = "yes"])
|
||||
|
||||
# libyuv's AArch64 SIMD kernels (dot-product, i8mm, SVE, SME) use instructions
|
||||
# outside the baseline armv8-a target, so they must be compiled with per-file
|
||||
# -march flags (see Makefile.am). These conditionals mirror the logic in
|
||||
# libs/libyuv/CMakeLists.txt.
|
||||
AM_CONDITIONAL([LIBYUV_AARCH64],
|
||||
[test "x$host_cpu" = "xaarch64" || test "x$host_cpu" = "xarm64"])
|
||||
|
||||
libyuv_have_sme=no
|
||||
AS_IF([test "x$host_cpu" = "xaarch64" || test "x$host_cpu" = "xarm64"], [
|
||||
AC_LANG_PUSH([C])
|
||||
libyuv_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -march=armv8.5-a+i8mm+sme"
|
||||
AC_MSG_CHECKING([whether $CC supports AArch64 SME kernels])
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[__arm_locally_streaming void func(void) { }
|
||||
int main(void) { return 0; }]])],
|
||||
[libyuv_have_sme=yes])
|
||||
AC_MSG_RESULT([$libyuv_have_sme])
|
||||
CFLAGS="$libyuv_save_CFLAGS"
|
||||
AC_LANG_POP([C])
|
||||
])
|
||||
AM_CONDITIONAL([LIBYUV_AARCH64_SME], [test "x$libyuv_have_sme" = "xyes"])
|
||||
|
||||
AC_ARG_ENABLE(libvpx,
|
||||
[AC_HELP_STRING([--disable-libvpx],[build without libvpx])],[enable_libvpx="$enableval"],[enable_libvpx="yes"])
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Defines the Chromium style for automatic reformatting.
|
||||
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||
BasedOnStyle: Chromium
|
||||
---
|
||||
Language: Java
|
||||
BasedOnStyle: Google
|
||||
@@ -0,0 +1,37 @@
|
||||
*.pyc
|
||||
.landmines
|
||||
pin-log.txt
|
||||
/base
|
||||
/build
|
||||
/buildtools
|
||||
/google_apis
|
||||
/links
|
||||
/links.db
|
||||
/ios
|
||||
/mojo
|
||||
/native_client
|
||||
/net
|
||||
/out
|
||||
/unit_test/out
|
||||
/source/out
|
||||
/sde-avx-sse-transition-out.txt
|
||||
/testing
|
||||
/third_party
|
||||
/tools
|
||||
|
||||
# Files generated by CMake build
|
||||
cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
yuvconvert
|
||||
libgtest.a
|
||||
libyuv.a
|
||||
libyuv_unittest
|
||||
|
||||
# Files generated by winarm.mk build
|
||||
libyuv_arm.lib
|
||||
source/*.o
|
||||
|
||||
# Files generated by perf
|
||||
perf.data
|
||||
perf.data.old
|
||||
@@ -0,0 +1,41 @@
|
||||
# Copyright 2015 The LibYuv Project Authors. All rights reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
import("//build/dotfile_settings.gni")
|
||||
|
||||
# The location of the build configuration file.
|
||||
buildconfig = "//build/config/BUILDCONFIG.gn"
|
||||
|
||||
# The hermetic Python interpreter to use by default.
|
||||
script_executable = "//third_party/cpython3/host/bin/python3"
|
||||
|
||||
# The secondary source root is a parallel directory tree where
|
||||
# GN build files are placed when they can not be placed directly
|
||||
# in the source tree, e.g. for third party source trees.
|
||||
secondary_source = "//build/secondary/"
|
||||
|
||||
# These are the targets to check headers for by default. The files in targets
|
||||
# matching these patterns (see "gn help label_pattern" for format) will have
|
||||
# their includes checked for proper dependencies when you run either
|
||||
# "gn check" or "gn gen --check".
|
||||
check_targets = [ "//libyuv/*" ]
|
||||
|
||||
# These are the list of GN files that run exec_script. This allowlist exists
|
||||
# to force additional review for new uses of exec_script, which is strongly
|
||||
# discouraged except for gypi_to_gn calls.
|
||||
exec_script_allowlist = build_dotfile_settings.exec_script_allowlist +
|
||||
[ "//build_overrides/build.gni" ]
|
||||
|
||||
default_args = {
|
||||
android_static_analysis = "off"
|
||||
mac_sdk_min = "10.12"
|
||||
ios_deployment_target = "12.0"
|
||||
|
||||
# Use Siso instead of Ninja.
|
||||
use_siso = true
|
||||
}
|
||||
@@ -2,3 +2,7 @@
|
||||
# Name or Organization <email address>
|
||||
|
||||
Google Inc.
|
||||
|
||||
Ho Cheung <uioptt24@gmail.com>
|
||||
Ivan Pavlotskiy <ivan.pavlotskiy@lgepartner.com>
|
||||
Sida Zhu <zhusida@bytedance.com>
|
||||
+84
-12
@@ -1,6 +1,31 @@
|
||||
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,
|
||||
},
|
||||
@@ -9,47 +34,48 @@ cc_library {
|
||||
"source/compare.cc",
|
||||
"source/compare_common.cc",
|
||||
"source/compare_gcc.cc",
|
||||
"source/compare_hvx.cc",
|
||||
"source/compare_neon.cc",
|
||||
"source/compare_neon64.cc",
|
||||
"source/compare_mmi.cc",
|
||||
"source/compare_msa.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_mmi.cc",
|
||||
"source/rotate_msa.cc",
|
||||
"source/rotate_hvx.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_mmi.cc",
|
||||
"source/row_msa.cc",
|
||||
"source/row_hvx.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_mmi.cc",
|
||||
"source/scale_msa.cc",
|
||||
"source/scale_hvx.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",
|
||||
"source/convert_jpeg.cc",
|
||||
"source/mjpeg_decoder.cc",
|
||||
"source/mjpeg_validate.cc",
|
||||
],
|
||||
|
||||
cflags: [
|
||||
@@ -58,11 +84,30 @@ cc_library {
|
||||
"-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
|
||||
@@ -71,6 +116,11 @@ 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 {
|
||||
@@ -79,10 +129,10 @@ cc_test {
|
||||
shared_libs: ["libjpeg"],
|
||||
cflags: ["-Wall", "-Werror"],
|
||||
srcs: [
|
||||
"unit_test/unit_test.cc",
|
||||
"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",
|
||||
@@ -91,7 +141,11 @@ cc_test {
|
||||
"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",
|
||||
],
|
||||
}
|
||||
@@ -114,6 +168,15 @@ cc_test {
|
||||
static_libs: ["libyuv"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "i444tonv12_eg",
|
||||
gtest: false,
|
||||
srcs: [
|
||||
"util/i444tonv12_eg.cc",
|
||||
],
|
||||
static_libs: ["libyuv"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "psnr",
|
||||
gtest: false,
|
||||
@@ -125,6 +188,15 @@ cc_test {
|
||||
static_libs: ["libyuv"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "yuvconstants",
|
||||
gtest: false,
|
||||
srcs: [
|
||||
"util/yuvconstants.c",
|
||||
],
|
||||
static_libs: ["libyuv"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "yuvconvert",
|
||||
gtest: false,
|
||||
|
||||
+34
-21
@@ -1,4 +1,7 @@
|
||||
# This is the Android makefile for libyuv for NDK.
|
||||
|
||||
# Ignore this file during non-NDK builds.
|
||||
ifdef NDK_ROOT
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
@@ -9,10 +12,10 @@ LOCAL_SRC_FILES := \
|
||||
source/compare.cc \
|
||||
source/compare_common.cc \
|
||||
source/compare_gcc.cc \
|
||||
source/compare_mmi.cc \
|
||||
source/compare_msa.cc \
|
||||
source/compare_hvx.cc \
|
||||
source/compare_neon.cc \
|
||||
source/compare_neon64.cc \
|
||||
source/compare_win.cc \
|
||||
source/convert.cc \
|
||||
source/convert_argb.cc \
|
||||
source/convert_from.cc \
|
||||
@@ -26,26 +29,31 @@ LOCAL_SRC_FILES := \
|
||||
source/rotate_argb.cc \
|
||||
source/rotate_common.cc \
|
||||
source/rotate_gcc.cc \
|
||||
source/rotate_mmi.cc \
|
||||
source/rotate_msa.cc \
|
||||
source/rotate_hvx.cc \
|
||||
source/rotate_neon.cc \
|
||||
source/rotate_neon64.cc \
|
||||
source/rotate_rvv.cc \
|
||||
source/rotate_win.cc \
|
||||
source/row_any.cc \
|
||||
source/row_common.cc \
|
||||
source/row_gcc.cc \
|
||||
source/row_mmi.cc \
|
||||
source/row_msa.cc \
|
||||
source/row_hvx.cc \
|
||||
source/row_neon.cc \
|
||||
source/row_neon64.cc \
|
||||
source/row_rvv.cc \
|
||||
source/row_win.cc \
|
||||
source/scale.cc \
|
||||
source/scale_any.cc \
|
||||
source/scale_argb.cc \
|
||||
source/scale_common.cc \
|
||||
source/scale_gcc.cc \
|
||||
source/scale_mmi.cc \
|
||||
source/scale_msa.cc \
|
||||
source/scale_hvx.cc \
|
||||
source/scale_neon.cc \
|
||||
source/scale_neon64.cc \
|
||||
source/scale_rgb.cc \
|
||||
source/scale_rvv.cc \
|
||||
source/scale_uv.cc \
|
||||
source/scale_win.cc \
|
||||
source/video_common.cc
|
||||
|
||||
common_CFLAGS := -Wall -fexceptions
|
||||
@@ -85,20 +93,25 @@ LOCAL_MODULE_TAGS := tests
|
||||
LOCAL_CPP_EXTENSION := .cc
|
||||
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
|
||||
LOCAL_SRC_FILES := \
|
||||
unit_test/unit_test.cc \
|
||||
unit_test/basictypes_test.cc \
|
||||
unit_test/color_test.cc \
|
||||
unit_test/compare_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_test.cc \
|
||||
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
|
||||
|
||||
LOCAL_MODULE := libyuv_unittest
|
||||
include $(BUILD_NATIVE_TEST)
|
||||
endif # NDK_ROOT
|
||||
@@ -0,0 +1,287 @@
|
||||
# Copyright 2026 The LibYuv Project Authors. All rights reserved.
|
||||
#
|
||||
# Description:
|
||||
# The libyuv package provides implementation yuv image conversion, rotation
|
||||
# and scaling.
|
||||
|
||||
load("@bazel_skylib//lib:selects.bzl", "selects")
|
||||
load(":libyuv.bzl", "libyuv_hdrs", "libyuv_neon_srcs", "libyuv_rvv_srcs", "libyuv_srcs", "libyuv_sve_srcs", "libyuv_test_srcs")
|
||||
|
||||
# Detect if we are in Google's internal repository (where source files are
|
||||
# under files/) or open source (where source files are at the root).
|
||||
PREFIX = "files/" if len(native.glob(["files/source/*.cc"])) > 0 else ""
|
||||
|
||||
# We support NEON for all arm processors, as we only support ARMv7a+.
|
||||
SUPPORTS_NEON_COPTS = [
|
||||
"-DLIBYUV_NEON",
|
||||
]
|
||||
|
||||
# ARMv7a requires that we explicitly enable NEON. arm64 enables it implicitly.
|
||||
ENABLE_NEON_COPTS = [
|
||||
"-mfpu=neon",
|
||||
]
|
||||
|
||||
ENABLE_NEON64_COPTS = [
|
||||
"-march=armv8-a+dotprod+i8mm",
|
||||
]
|
||||
|
||||
NEON_COPTS = select({
|
||||
"@platforms//cpu:armv7": ENABLE_NEON_COPTS + SUPPORTS_NEON_COPTS,
|
||||
"@platforms//cpu:aarch64": ENABLE_NEON64_COPTS + SUPPORTS_NEON_COPTS,
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
SUPPORTS_SVE_COPTS = [
|
||||
"-DLIBYUV_SVE",
|
||||
]
|
||||
|
||||
ENABLE_SVE_COPTS = [
|
||||
"-march=armv8.5-a+i8mm+sve2",
|
||||
]
|
||||
|
||||
SVE_COPTS = select({
|
||||
"@platforms//cpu:aarch64": ENABLE_SVE_COPTS + SUPPORTS_SVE_COPTS,
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
SUPPORTS_RVV_COPTS = [
|
||||
"-DLIBYUV_RVV",
|
||||
"-fno-tree-vectorize",
|
||||
"-fno-tree-slp-vectorize",
|
||||
]
|
||||
|
||||
ENABLE_RVV_COPTS = [
|
||||
"-march=rv32gcv",
|
||||
]
|
||||
|
||||
ENABLE_RVV64_COPTS = [
|
||||
"-march=rv64gcv",
|
||||
]
|
||||
|
||||
RVV_COPTS = select({
|
||||
"@platforms//cpu:riscv32": ENABLE_RVV_COPTS + SUPPORTS_RVV_COPTS,
|
||||
"@platforms//cpu:riscv64": ENABLE_RVV64_COPTS + SUPPORTS_RVV_COPTS,
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
ARCH_SUPPORT_COPTS = select({
|
||||
"@platforms//cpu:armv7": SUPPORTS_NEON_COPTS,
|
||||
"@platforms//cpu:aarch64": SUPPORTS_NEON_COPTS + SUPPORTS_SVE_COPTS,
|
||||
"@platforms//cpu:riscv32": SUPPORTS_RVV_COPTS,
|
||||
"@platforms//cpu:riscv64": SUPPORTS_RVV_COPTS,
|
||||
"@platforms//cpu:wasm32": ["-msimd128"],
|
||||
"@platforms//cpu:wasm64": ["-msimd128"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
PLATFORM_COPTS = select({
|
||||
"@platforms//os:android": ["-DHAVE_JPEG"],
|
||||
"@platforms//os:linux": ["-DHAVE_JPEG"],
|
||||
"@platforms//os:windows": ["-DHAVE_JPEG"],
|
||||
"@platforms//os:macos": ["-DHAVE_JPEG"],
|
||||
"//conditions:default": [],
|
||||
}) + [
|
||||
"-DLIBYUV_DISABLE_SME",
|
||||
"-DLIBYUV_USE_ABSL_FLAGS",
|
||||
"-DGOOGLE_COMMANDLINEFLAGS_FULL_API",
|
||||
]
|
||||
|
||||
ALL_COPTS = PLATFORM_COPTS + ARCH_SUPPORT_COPTS
|
||||
|
||||
ALL_NEON_COPTS = NEON_COPTS + PLATFORM_COPTS
|
||||
|
||||
ALL_SVE_COPTS = SVE_COPTS + PLATFORM_COPTS
|
||||
|
||||
ALL_RVV_COPTS = RVV_COPTS + PLATFORM_COPTS
|
||||
|
||||
NEON_DEPS = select({
|
||||
"@platforms//cpu:armv7": [":libyuv_neon_impl"],
|
||||
"@platforms//cpu:aarch64": [":libyuv_neon_impl"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
SVE_DEPS = select({
|
||||
"@platforms//cpu:aarch64": [":libyuv_sve_impl"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
RVV_DEPS = select({
|
||||
"@platforms//cpu:riscv32": [":libyuv_rvv_impl"],
|
||||
"@platforms//cpu:riscv64": [":libyuv_rvv_impl"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
PLATFORM_DEPS = select({
|
||||
"@platforms//os:android": ["@libjpeg_turbo//:jpeg"],
|
||||
"@platforms//os:linux": ["@libjpeg_turbo//:jpeg"],
|
||||
"@platforms//os:windows": ["@libjpeg_turbo//:jpeg"],
|
||||
"@platforms//os:macos": ["@libjpeg_turbo//:jpeg"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
ALL_DEPS = NEON_DEPS + SVE_DEPS + RVV_DEPS + PLATFORM_DEPS
|
||||
|
||||
cc_library(
|
||||
name = "libyuv",
|
||||
hdrs = [
|
||||
PREFIX + "include/libyuv.h",
|
||||
# Headers included by libyuv.h.
|
||||
PREFIX + "include/libyuv/basic_types.h",
|
||||
PREFIX + "include/libyuv/compare.h",
|
||||
PREFIX + "include/libyuv/convert.h",
|
||||
PREFIX + "include/libyuv/convert_argb.h",
|
||||
PREFIX + "include/libyuv/convert_from.h",
|
||||
PREFIX + "include/libyuv/convert_from_argb.h",
|
||||
PREFIX + "include/libyuv/cpu_id.h",
|
||||
PREFIX + "include/libyuv/mjpeg_decoder.h",
|
||||
PREFIX + "include/libyuv/planar_functions.h",
|
||||
PREFIX + "include/libyuv/rotate.h",
|
||||
PREFIX + "include/libyuv/rotate_argb.h",
|
||||
PREFIX + "include/libyuv/row.h", # Bug 553148013: Should be private.
|
||||
PREFIX + "include/libyuv/scale.h",
|
||||
PREFIX + "include/libyuv/scale_argb.h",
|
||||
PREFIX + "include/libyuv/scale_rgb.h",
|
||||
PREFIX + "include/libyuv/scale_uv.h",
|
||||
PREFIX + "include/libyuv/version.h",
|
||||
PREFIX + "include/libyuv/video_common.h",
|
||||
# Headers included by libyuv/row.h.
|
||||
PREFIX + "include/libyuv/cpu_support.h", # Bug 553148013: Should be private.
|
||||
],
|
||||
strip_include_prefix = PREFIX + "include",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [":libyuv_impl"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "libyuv_impl",
|
||||
srcs = libyuv_srcs(PREFIX),
|
||||
hdrs = libyuv_hdrs(PREFIX),
|
||||
copts = ALL_COPTS + selects.with_or({
|
||||
(
|
||||
"@platforms//os:android",
|
||||
"@platforms//os:ios",
|
||||
"@platforms//os:tvos",
|
||||
"@platforms//os:windows",
|
||||
"@platforms//os:macos",
|
||||
): [],
|
||||
"//conditions:default": [
|
||||
"-fomit-frame-pointer",
|
||||
],
|
||||
}) + selects.with_or({
|
||||
(
|
||||
"@platforms//os:android",
|
||||
"@platforms//os:ios",
|
||||
"@platforms//os:tvos",
|
||||
): ["-O2"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
includes = [PREFIX + "include"],
|
||||
deps = ALL_DEPS,
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "libyuv_neon_impl",
|
||||
srcs = libyuv_neon_srcs(PREFIX),
|
||||
copts = ALL_NEON_COPTS,
|
||||
includes = [PREFIX + "include"],
|
||||
visibility = ["//visibility:private"],
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "libyuv_sve_impl",
|
||||
srcs = libyuv_sve_srcs(PREFIX),
|
||||
copts = ALL_SVE_COPTS,
|
||||
includes = [PREFIX + "include"],
|
||||
visibility = ["//visibility:private"],
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "libyuv_rvv_impl",
|
||||
srcs = libyuv_rvv_srcs(PREFIX),
|
||||
copts = ALL_RVV_COPTS,
|
||||
includes = [PREFIX + "include"],
|
||||
visibility = ["//visibility:private"],
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "libyuv_test",
|
||||
srcs = libyuv_test_srcs(PREFIX),
|
||||
copts = ALL_COPTS + [
|
||||
"-Wno-unused-variable",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":libyuv",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
"@com_google_absl//absl/flags:flag",
|
||||
"@com_google_absl//absl/flags:parse",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "psnr_lib",
|
||||
srcs = [PREFIX + "util/psnr.cc"],
|
||||
hdrs = [PREFIX + "util/psnr.h"],
|
||||
copts = PLATFORM_COPTS,
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "ssim_lib",
|
||||
srcs = [PREFIX + "util/ssim.cc"],
|
||||
hdrs = [PREFIX + "util/ssim.h"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "psnr",
|
||||
srcs = [PREFIX + "util/psnr_main.cc"],
|
||||
copts = PLATFORM_COPTS + [
|
||||
"-Wframe-larger-than=64000",
|
||||
],
|
||||
deps = [
|
||||
":libyuv",
|
||||
":psnr_lib",
|
||||
":ssim_lib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "i444tonv12_eg",
|
||||
srcs = [PREFIX + "util/i444tonv12_eg.cc"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":libyuv",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "cpuid",
|
||||
srcs = [PREFIX + "util/cpuid.c"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":libyuv",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "yuvconstants",
|
||||
srcs = [PREFIX + "util/yuvconstants.c"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":libyuv",
|
||||
],
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "yuvconvert",
|
||||
srcs = [PREFIX + "util/yuvconvert.cc"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
":libyuv",
|
||||
],
|
||||
)
|
||||
+273
-88
@@ -6,12 +6,14 @@
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
import("libyuv.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/config/sanitizers/sanitizers.gni")
|
||||
import("//testing/test.gni")
|
||||
import("libyuv.gni")
|
||||
|
||||
declare_args() {
|
||||
# Set to false to disable building with gflags.
|
||||
libyuv_use_gflags = true
|
||||
# Set to false to disable building with absl flags.
|
||||
libyuv_use_absl_flags = true
|
||||
|
||||
# When building a shared library using a target in WebRTC or
|
||||
# Chromium projects that depends on libyuv, setting this flag
|
||||
@@ -21,26 +23,49 @@ declare_args() {
|
||||
|
||||
config("libyuv_config") {
|
||||
include_dirs = [ "include" ]
|
||||
if (is_android && current_cpu == "arm64") {
|
||||
ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64" ]
|
||||
|
||||
# Define CHROMIUM to tell cpu_id to avoid sandbox unsafe system calls.
|
||||
defines = [ "CHROMIUM" ]
|
||||
if (libyuv_enable_rowwin) {
|
||||
defines += [ "LIBYUV_ENABLE_ROWWIN=1" ]
|
||||
}
|
||||
if (is_android && current_cpu != "arm64") {
|
||||
ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker" ]
|
||||
if (!libyuv_use_neon) {
|
||||
defines += [ "LIBYUV_DISABLE_NEON" ]
|
||||
}
|
||||
if (!libyuv_use_sve) {
|
||||
defines += [ "LIBYUV_DISABLE_SVE" ]
|
||||
}
|
||||
if (!libyuv_use_sme) {
|
||||
defines += [ "LIBYUV_DISABLE_SME" ]
|
||||
}
|
||||
if (libyuv_disable_rvv) {
|
||||
defines += [ "LIBYUV_DISABLE_RVV" ]
|
||||
} else if (libyuv_use_rvv) {
|
||||
defines += [ "LIBYUV_RVV" ]
|
||||
}
|
||||
if (!libyuv_use_lsx) {
|
||||
defines += [ "LIBYUV_DISABLE_LSX" ]
|
||||
}
|
||||
if (!libyuv_use_lasx) {
|
||||
defines += [ "LIBYUV_DISABLE_LASX" ]
|
||||
}
|
||||
if (current_cpu == "wasm") {
|
||||
cflags_cc = [ "-msimd128" ]
|
||||
}
|
||||
}
|
||||
|
||||
# This target is built when no specific target is specified on the command line.
|
||||
group("default") {
|
||||
testonly = true
|
||||
deps = [
|
||||
":libyuv",
|
||||
]
|
||||
deps = [ ":libyuv" ]
|
||||
if (libyuv_include_tests) {
|
||||
deps += [
|
||||
":compare",
|
||||
":cpuid",
|
||||
":i444tonv12_eg",
|
||||
":libyuv_unittest",
|
||||
":psnr",
|
||||
":yuvconstants",
|
||||
":yuvconvert",
|
||||
]
|
||||
}
|
||||
@@ -50,30 +75,38 @@ group("libyuv") {
|
||||
all_dependent_configs = [ ":libyuv_config" ]
|
||||
deps = []
|
||||
|
||||
if (is_win && target_cpu == "x64") {
|
||||
if (is_win && target_cpu == "x64" && current_toolchain == default_toolchain) {
|
||||
# Compile with clang in order to get inline assembly
|
||||
public_deps = [
|
||||
":libyuv_internal(//build/toolchain/win:win_clang_x64)",
|
||||
]
|
||||
public_deps = [ ":libyuv_internal(//build/toolchain/win:win_clang_x64)" ]
|
||||
} else {
|
||||
public_deps = [
|
||||
":libyuv_internal",
|
||||
]
|
||||
public_deps = [ ":libyuv_internal" ]
|
||||
}
|
||||
|
||||
if (libyuv_use_neon) {
|
||||
deps += [ ":libyuv_neon" ]
|
||||
}
|
||||
|
||||
if (libyuv_use_msa) {
|
||||
deps += [ ":libyuv_msa" ]
|
||||
if (libyuv_use_sve) {
|
||||
deps += [ ":libyuv_sve" ]
|
||||
}
|
||||
|
||||
if (libyuv_use_mmi) {
|
||||
deps += [ ":libyuv_mmi" ]
|
||||
if (libyuv_use_sme) {
|
||||
deps += [ ":libyuv_sme" ]
|
||||
}
|
||||
|
||||
if (!is_ios) {
|
||||
if (libyuv_use_rvv && !libyuv_disable_rvv) {
|
||||
deps += [ ":libyuv_rvv" ]
|
||||
}
|
||||
|
||||
if (libyuv_use_lsx) {
|
||||
deps += [ ":libyuv_lsx" ]
|
||||
}
|
||||
|
||||
if (libyuv_use_lasx) {
|
||||
deps += [ ":libyuv_lasx" ]
|
||||
}
|
||||
|
||||
if (!is_ios && !libyuv_disable_jpeg) {
|
||||
# Make sure that clients of libyuv link with libjpeg. This can't go in
|
||||
# libyuv_internal because in Windows x64 builds that will generate a clang
|
||||
# build of libjpeg, and we don't want two copies.
|
||||
@@ -89,20 +122,26 @@ static_library("libyuv_internal") {
|
||||
"include/libyuv.h",
|
||||
"include/libyuv/basic_types.h",
|
||||
"include/libyuv/compare.h",
|
||||
"include/libyuv/compare_row.h",
|
||||
"include/libyuv/convert.h",
|
||||
"include/libyuv/convert_argb.h",
|
||||
"include/libyuv/convert_from.h",
|
||||
"include/libyuv/convert_from_argb.h",
|
||||
"include/libyuv/cpu_id.h",
|
||||
"include/libyuv/cpu_support.h",
|
||||
"include/libyuv/loongson_intrinsics.h",
|
||||
"include/libyuv/mjpeg_decoder.h",
|
||||
"include/libyuv/planar_functions.h",
|
||||
"include/libyuv/rotate.h",
|
||||
"include/libyuv/rotate_argb.h",
|
||||
"include/libyuv/rotate_row.h",
|
||||
"include/libyuv/row.h",
|
||||
"include/libyuv/row_sve.h",
|
||||
"include/libyuv/scale.h",
|
||||
"include/libyuv/scale_argb.h",
|
||||
"include/libyuv/scale_rgb.h",
|
||||
"include/libyuv/scale_row.h",
|
||||
"include/libyuv/scale_uv.h",
|
||||
"include/libyuv/version.h",
|
||||
"include/libyuv/video_common.h",
|
||||
|
||||
@@ -110,6 +149,8 @@ static_library("libyuv_internal") {
|
||||
"source/compare.cc",
|
||||
"source/compare_common.cc",
|
||||
"source/compare_gcc.cc",
|
||||
"source/compare_hvx.cc",
|
||||
"source/compare_wasm.cc",
|
||||
"source/compare_win.cc",
|
||||
"source/convert.cc",
|
||||
"source/convert_argb.cc",
|
||||
@@ -127,16 +168,24 @@ static_library("libyuv_internal") {
|
||||
"source/rotate_argb.cc",
|
||||
"source/rotate_common.cc",
|
||||
"source/rotate_gcc.cc",
|
||||
"source/rotate_hvx.cc",
|
||||
"source/rotate_wasm.cc",
|
||||
"source/rotate_win.cc",
|
||||
"source/row_any.cc",
|
||||
"source/row_common.cc",
|
||||
"source/row_gcc.cc",
|
||||
"source/row_hvx.cc",
|
||||
"source/row_wasm.cc",
|
||||
"source/row_win.cc",
|
||||
"source/scale.cc",
|
||||
"source/scale_any.cc",
|
||||
"source/scale_argb.cc",
|
||||
"source/scale_common.cc",
|
||||
"source/scale_gcc.cc",
|
||||
"source/scale_hvx.cc",
|
||||
"source/scale_rgb.cc",
|
||||
"source/scale_uv.cc",
|
||||
"source/scale_wasm.cc",
|
||||
"source/scale_win.cc",
|
||||
"source/video_common.cc",
|
||||
]
|
||||
@@ -150,7 +199,7 @@ static_library("libyuv_internal") {
|
||||
configs += [ "//build/config/gcc:symbol_visibility_default" ]
|
||||
}
|
||||
|
||||
if (!is_ios) {
|
||||
if ((!is_ios || use_blink) && !libyuv_disable_jpeg) {
|
||||
defines += [ "HAVE_JPEG" ]
|
||||
|
||||
# Needed to pull in libjpeg headers. Can't add //third_party:jpeg to deps
|
||||
@@ -158,9 +207,7 @@ static_library("libyuv_internal") {
|
||||
deps += [ "//third_party:jpeg_includes" ]
|
||||
}
|
||||
|
||||
# Always enable optimization for Release and NaCl builds (to workaround
|
||||
# crbug.com/538243).
|
||||
if (!is_debug || is_nacl) {
|
||||
if (!is_debug) {
|
||||
configs -= [ "//build/config/compiler:default_optimization" ]
|
||||
|
||||
# Enable optimize for speed (-O2) over size (-Os).
|
||||
@@ -192,61 +239,126 @@ if (libyuv_use_neon) {
|
||||
"source/scale_neon64.cc",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":libyuv_internal",
|
||||
]
|
||||
deps = [ ":libyuv_internal" ]
|
||||
|
||||
public_configs = [ ":libyuv_config" ]
|
||||
|
||||
# Always enable optimization for Release and NaCl builds (to workaround
|
||||
# crbug.com/538243).
|
||||
if (!is_debug) {
|
||||
configs -= [ "//build/config/compiler:default_optimization" ]
|
||||
if (current_cpu == "arm64") {
|
||||
# The -march arguments below are incompatible with libc++ modules.
|
||||
use_libcxx_modules = false
|
||||
|
||||
# Enable optimize for speed (-O2) over size (-Os).
|
||||
# TODO(fbarchard): Consider optimize_speed which is O3.
|
||||
configs += [ "//build/config/compiler:optimize_max" ]
|
||||
}
|
||||
|
||||
if (current_cpu != "arm64") {
|
||||
configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
|
||||
cflags = [ "-mfpu=neon" ]
|
||||
# TODO(thakis): Do we get this from global flags already? Is this needed?
|
||||
cflags = [ "-march=armv8-a+dotprod+i8mm" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (libyuv_use_msa) {
|
||||
static_library("libyuv_msa") {
|
||||
if (libyuv_use_sve) {
|
||||
static_library("libyuv_sve") {
|
||||
sources = [
|
||||
# MSA Source Files
|
||||
"source/compare_msa.cc",
|
||||
"source/rotate_msa.cc",
|
||||
"source/row_msa.cc",
|
||||
"source/scale_msa.cc",
|
||||
"source/rotate_sve.cc",
|
||||
"source/row_sve.cc",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":libyuv_internal",
|
||||
deps = [ ":libyuv_internal" ]
|
||||
|
||||
public_configs = [ ":libyuv_config" ]
|
||||
|
||||
# The -march arguments below are incompatible with libc++ modules.
|
||||
use_libcxx_modules = false
|
||||
|
||||
# SVE2 is an Armv9-A feature, but use Armv8.5-A for compatibility.
|
||||
cflags = [ "-march=armv8.5-a+i8mm+sve2" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (libyuv_use_sme) {
|
||||
static_library("libyuv_sme") {
|
||||
sources = [
|
||||
"source/rotate_sme.cc",
|
||||
"source/row_sme.cc",
|
||||
"source/scale_sme.cc",
|
||||
]
|
||||
|
||||
deps = [ ":libyuv_internal" ]
|
||||
|
||||
public_configs = [ ":libyuv_config" ]
|
||||
|
||||
# The -march arguments below are incompatible with libc++ modules.
|
||||
use_libcxx_modules = false
|
||||
|
||||
# SME is an Armv9-A feature, but use Armv8.5-A for compatibility with
|
||||
# processors like Apple M4/M5 that support SME without SVE.
|
||||
cflags = [ "-march=armv8.5-a+i8mm+sme" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (libyuv_use_rvv && !libyuv_disable_rvv) {
|
||||
static_library("libyuv_rvv") {
|
||||
sources = [
|
||||
"source/rotate_rvv.cc",
|
||||
"source/row_rvv.cc",
|
||||
"source/scale_rvv.cc",
|
||||
]
|
||||
|
||||
deps = [ ":libyuv_internal" ]
|
||||
|
||||
public_configs = [ ":libyuv_config" ]
|
||||
|
||||
# The -march arguments below are incompatible with libc++ modules.
|
||||
use_libcxx_modules = false
|
||||
|
||||
if (current_cpu == "riscv64") {
|
||||
cflags = [
|
||||
"-march=rv64gcv",
|
||||
"-fno-tree-vectorize",
|
||||
"-fno-tree-slp-vectorize",
|
||||
]
|
||||
} else {
|
||||
cflags = [
|
||||
"-march=rv32gcv",
|
||||
"-fno-tree-vectorize",
|
||||
"-fno-tree-slp-vectorize",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (libyuv_use_lsx) {
|
||||
static_library("libyuv_lsx") {
|
||||
sources = [
|
||||
# LSX Source Files
|
||||
"source/rotate_lsx.cc",
|
||||
"source/row_lsx.cc",
|
||||
"source/scale_lsx.cc",
|
||||
]
|
||||
|
||||
cflags_cc = [
|
||||
"-mlsx",
|
||||
"-Wno-c++11-narrowing",
|
||||
]
|
||||
|
||||
deps = [ ":libyuv_internal" ]
|
||||
|
||||
public_configs = [ ":libyuv_config" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (libyuv_use_mmi) {
|
||||
static_library("libyuv_mmi") {
|
||||
if (libyuv_use_lasx) {
|
||||
static_library("libyuv_lasx") {
|
||||
sources = [
|
||||
# MMI Source Files
|
||||
"source/compare_mmi.cc",
|
||||
"source/rotate_mmi.cc",
|
||||
"source/row_mmi.cc",
|
||||
"source/scale_mmi.cc",
|
||||
# LASX Source Files
|
||||
"source/rotate_lasx.cc",
|
||||
"source/row_lasx.cc",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":libyuv_internal",
|
||||
cflags_cc = [
|
||||
"-mlasx",
|
||||
"-Wno-c++11-narrowing",
|
||||
]
|
||||
|
||||
deps = [ ":libyuv_internal" ]
|
||||
|
||||
public_configs = [ ":libyuv_config" ]
|
||||
}
|
||||
}
|
||||
@@ -267,19 +379,36 @@ if (libyuv_include_tests) {
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
config("libyuv_unittest_config") {
|
||||
defines = [ "GTEST_RELATIVE_PATH" ]
|
||||
}
|
||||
|
||||
if (!build_with_chromium && prebuilt_instrumented_libraries_available &&
|
||||
is_msan) {
|
||||
# Override the relative PT_INTERP from //third_party/instrumented_libs so
|
||||
# standalone test binaries can be launched from any working directory
|
||||
# (such as the builder root on LUCI Linux MSan).
|
||||
config("libyuv_msan_ldflags") {
|
||||
if (msan_track_origins == 0) {
|
||||
_msan_archive = "msan-no-origins-noble-lib"
|
||||
} else {
|
||||
_msan_archive = "msan-chained-origins-noble-lib"
|
||||
}
|
||||
_ld_linux = rebase_path(
|
||||
"//third_party/instrumented_libs/binaries/$_msan_archive/lib/ld-linux-x86-64.so.2")
|
||||
ldflags = [ "-Wl,--dynamic-linker=$_ld_linux" ]
|
||||
}
|
||||
}
|
||||
|
||||
test("libyuv_unittest") {
|
||||
testonly = true
|
||||
|
||||
sources = [
|
||||
# sources
|
||||
# headers
|
||||
"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",
|
||||
@@ -288,7 +417,10 @@ if (libyuv_include_tests) {
|
||||
"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/unit_test.h",
|
||||
"unit_test/video_common_test.cc",
|
||||
@@ -300,20 +432,28 @@ if (libyuv_include_tests) {
|
||||
]
|
||||
|
||||
defines = []
|
||||
if (libyuv_use_gflags) {
|
||||
defines += [ "LIBYUV_USE_GFLAGS" ]
|
||||
deps += [ "//third_party/gflags" ]
|
||||
if (libyuv_use_absl_flags) {
|
||||
defines += [ "LIBYUV_USE_ABSL_FLAGS" ]
|
||||
deps += [
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
]
|
||||
}
|
||||
|
||||
configs += [ ":libyuv_unittest_warnings_config" ]
|
||||
if (!build_with_chromium && prebuilt_instrumented_libraries_available &&
|
||||
is_msan) {
|
||||
configs += [ ":libyuv_msan_ldflags" ]
|
||||
}
|
||||
|
||||
public_deps = [
|
||||
"//testing/gtest",
|
||||
]
|
||||
public_deps = [ "//testing/gtest" ]
|
||||
public_configs = [ ":libyuv_unittest_config" ]
|
||||
|
||||
if (is_linux) {
|
||||
if (is_linux || is_chromeos) {
|
||||
cflags = [ "-fexceptions" ]
|
||||
|
||||
# For enabling ASLR.
|
||||
ldflags = [ "-pie" ]
|
||||
}
|
||||
if (is_ios) {
|
||||
configs -= [ "//build/config/compiler:default_symbols" ]
|
||||
@@ -323,15 +463,10 @@ if (libyuv_include_tests) {
|
||||
if (!is_ios && !libyuv_disable_jpeg) {
|
||||
defines += [ "HAVE_JPEG" ]
|
||||
}
|
||||
if (is_android) {
|
||||
deps += [ "//testing/android/native_test:native_test_native_code" ]
|
||||
}
|
||||
|
||||
# TODO(YangZhang): These lines can be removed when high accuracy
|
||||
# YUV to RGB to Neon is ported.
|
||||
if ((target_cpu == "armv7" || target_cpu == "armv7s" ||
|
||||
(target_cpu == "arm" && arm_version >= 7) || target_cpu == "arm64") &&
|
||||
(arm_use_neon || arm_optionally_use_neon)) {
|
||||
if (target_cpu == "arm" || target_cpu == "arm64") {
|
||||
defines += [ "LIBYUV_NEON" ]
|
||||
}
|
||||
|
||||
@@ -349,12 +484,14 @@ if (libyuv_include_tests) {
|
||||
# sources
|
||||
"util/compare.cc",
|
||||
]
|
||||
deps = [
|
||||
":libyuv",
|
||||
]
|
||||
if (is_linux) {
|
||||
deps = [ ":libyuv" ]
|
||||
if (is_linux || is_chromeos) {
|
||||
cflags = [ "-fexceptions" ]
|
||||
}
|
||||
if (!build_with_chromium && prebuilt_instrumented_libraries_available &&
|
||||
is_msan) {
|
||||
configs += [ ":libyuv_msan_ldflags" ]
|
||||
}
|
||||
}
|
||||
|
||||
executable("yuvconvert") {
|
||||
@@ -362,12 +499,29 @@ if (libyuv_include_tests) {
|
||||
# sources
|
||||
"util/yuvconvert.cc",
|
||||
]
|
||||
deps = [
|
||||
":libyuv",
|
||||
]
|
||||
if (is_linux) {
|
||||
deps = [ ":libyuv" ]
|
||||
if (is_linux || is_chromeos) {
|
||||
cflags = [ "-fexceptions" ]
|
||||
}
|
||||
if (!build_with_chromium && prebuilt_instrumented_libraries_available &&
|
||||
is_msan) {
|
||||
configs += [ ":libyuv_msan_ldflags" ]
|
||||
}
|
||||
}
|
||||
|
||||
executable("yuvconstants") {
|
||||
sources = [
|
||||
# sources
|
||||
"util/yuvconstants.c",
|
||||
]
|
||||
deps = [ ":libyuv" ]
|
||||
if (is_linux || is_chromeos) {
|
||||
cflags = [ "-fexceptions" ]
|
||||
}
|
||||
if (!build_with_chromium && prebuilt_instrumented_libraries_available &&
|
||||
is_msan) {
|
||||
configs += [ ":libyuv_msan_ldflags" ]
|
||||
}
|
||||
}
|
||||
|
||||
executable("psnr") {
|
||||
@@ -377,13 +531,27 @@ if (libyuv_include_tests) {
|
||||
"util/psnr_main.cc",
|
||||
"util/ssim.cc",
|
||||
]
|
||||
deps = [
|
||||
":libyuv",
|
||||
]
|
||||
deps = [ ":libyuv" ]
|
||||
|
||||
if (!is_ios && !libyuv_disable_jpeg) {
|
||||
defines = [ "HAVE_JPEG" ]
|
||||
}
|
||||
if (!build_with_chromium && prebuilt_instrumented_libraries_available &&
|
||||
is_msan) {
|
||||
configs += [ ":libyuv_msan_ldflags" ]
|
||||
}
|
||||
}
|
||||
|
||||
executable("i444tonv12_eg") {
|
||||
sources = [
|
||||
# sources
|
||||
"util/i444tonv12_eg.cc",
|
||||
]
|
||||
deps = [ ":libyuv" ]
|
||||
if (!build_with_chromium && prebuilt_instrumented_libraries_available &&
|
||||
is_msan) {
|
||||
configs += [ ":libyuv_msan_ldflags" ]
|
||||
}
|
||||
}
|
||||
|
||||
executable("cpuid") {
|
||||
@@ -391,8 +559,25 @@ if (libyuv_include_tests) {
|
||||
# sources
|
||||
"util/cpuid.c",
|
||||
]
|
||||
deps = [
|
||||
":libyuv",
|
||||
]
|
||||
deps = [ ":libyuv" ]
|
||||
if (!build_with_chromium && prebuilt_instrumented_libraries_available &&
|
||||
is_msan) {
|
||||
configs += [ ":libyuv_msan_ldflags" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!build_with_chromium) {
|
||||
# GN evaluates each .gn file once per toolchain, so restricting to default
|
||||
# toolchain will ensure write_file() is called only once.
|
||||
if (current_toolchain == default_toolchain) {
|
||||
# Write debug logs to gn_logs.txt.
|
||||
# This is also required for Siso builds.
|
||||
import("//build/gn_logs.gni")
|
||||
lines = [
|
||||
"Generated during 'gn gen' by //BUILD.gn.",
|
||||
"",
|
||||
] + build_gn_logs
|
||||
write_file("$root_build_dir/gn_logs.txt", lines)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
# determine the version number from the #define in libyuv/version.h
|
||||
EXECUTE_PROCESS (
|
||||
COMMAND grep --perl-regex --only-matching "(?<=LIBYUV_VERSION )[0-9]+" include/libyuv/version.h
|
||||
COMMAND grep -Eo "LIBYUV_VERSION\ [0-9]+" include/libyuv/version.h
|
||||
COMMAND grep -Eo "[0-9]+"
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE YUV_VERSION_NUMBER
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||
@@ -8,7 +9,7 @@ SET ( YUV_VER_MAJOR 0 )
|
||||
SET ( YUV_VER_MINOR 0 )
|
||||
SET ( YUV_VER_PATCH ${YUV_VERSION_NUMBER} )
|
||||
SET ( YUV_VERSION ${YUV_VER_MAJOR}.${YUV_VER_MINOR}.${YUV_VER_PATCH} )
|
||||
MESSAGE ( "Building ver.: ${YUV_VERSION}" )
|
||||
MESSAGE ( VERBOSE "Building ver.: ${YUV_VERSION}" )
|
||||
|
||||
# is this a 32-bit or 64-bit build?
|
||||
IF ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||
@@ -45,7 +46,7 @@ ELSE ()
|
||||
SET ( YUV_SYSTEM_NAME "amd-${YUV_BIT_SIZE}" )
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
MESSAGE ( "Packaging for: ${YUV_SYSTEM_NAME}" )
|
||||
MESSAGE ( VERBOSE "Packaging for: ${YUV_SYSTEM_NAME}" )
|
||||
|
||||
# define all the variables needed by CPack to create .deb and .rpm packages
|
||||
SET ( CPACK_PACKAGE_VENDOR "Frank Barchard" )
|
||||
|
||||
+269
-41
@@ -1,51 +1,276 @@
|
||||
# CMakeLists for libyuv
|
||||
# Originally created for "roxlu build system" to compile libyuv on windows
|
||||
# Run with -DTEST=ON to build unit tests
|
||||
# Run with -DUNIT_TEST=ON to build unit tests
|
||||
|
||||
PROJECT ( YUV C CXX ) # "C" is required even for C++ projects
|
||||
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 )
|
||||
OPTION( TEST "Built unit tests" OFF )
|
||||
cmake_minimum_required( VERSION 3.16 )
|
||||
project ( YUV C CXX ) # "C" is required even for C++ projects
|
||||
option( UNIT_TEST "Built unit tests" OFF )
|
||||
option( LIBYUV_DISABLE_JPEG "Disable JPEG support" OFF )
|
||||
|
||||
SET ( ly_base_dir ${PROJECT_SOURCE_DIR} )
|
||||
SET ( ly_src_dir ${ly_base_dir}/source )
|
||||
SET ( ly_inc_dir ${ly_base_dir}/include )
|
||||
SET ( ly_tst_dir ${ly_base_dir}/unit_test )
|
||||
SET ( ly_lib_name yuv )
|
||||
SET ( ly_lib_static ${ly_lib_name} )
|
||||
SET ( ly_lib_shared ${ly_lib_name}_shared )
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
FILE ( GLOB_RECURSE ly_source_files ${ly_src_dir}/*.cc )
|
||||
LIST ( SORT ly_source_files )
|
||||
set ( ly_base_dir ${PROJECT_SOURCE_DIR} )
|
||||
set ( ly_src_dir ${ly_base_dir}/source )
|
||||
set ( ly_inc_dir ${ly_base_dir}/include )
|
||||
set ( ly_tst_dir ${ly_base_dir}/unit_test )
|
||||
set ( ly_lib_name yuv )
|
||||
set ( ly_lib_static ${ly_lib_name} )
|
||||
set ( ly_lib_shared ${ly_lib_name}_shared )
|
||||
|
||||
FILE ( GLOB_RECURSE ly_unittest_sources ${ly_tst_dir}/*.cc )
|
||||
LIST ( SORT ly_unittest_sources )
|
||||
# We cannot use GLOB here since we want to be able to separate out files that
|
||||
# need particular flags to enable architecture extensions like AArch64's SVE.
|
||||
# TODO: More of these files could be separated out for different architectures.
|
||||
set ( ly_common_source_files
|
||||
${ly_src_dir}/compare.cc
|
||||
${ly_src_dir}/compare_common.cc
|
||||
${ly_src_dir}/compare_gcc.cc
|
||||
${ly_src_dir}/compare_hvx.cc
|
||||
${ly_src_dir}/compare_wasm.cc
|
||||
${ly_src_dir}/compare_win.cc
|
||||
${ly_src_dir}/convert.cc
|
||||
${ly_src_dir}/convert_argb.cc
|
||||
${ly_src_dir}/convert_from.cc
|
||||
${ly_src_dir}/convert_from_argb.cc
|
||||
${ly_src_dir}/convert_jpeg.cc
|
||||
${ly_src_dir}/convert_to_argb.cc
|
||||
${ly_src_dir}/convert_to_i420.cc
|
||||
${ly_src_dir}/cpu_id.cc
|
||||
${ly_src_dir}/mjpeg_decoder.cc
|
||||
${ly_src_dir}/mjpeg_validate.cc
|
||||
${ly_src_dir}/planar_functions.cc
|
||||
${ly_src_dir}/rotate.cc
|
||||
${ly_src_dir}/rotate_any.cc
|
||||
${ly_src_dir}/rotate_argb.cc
|
||||
${ly_src_dir}/rotate_common.cc
|
||||
${ly_src_dir}/rotate_gcc.cc
|
||||
${ly_src_dir}/rotate_hvx.cc
|
||||
${ly_src_dir}/rotate_rvv.cc
|
||||
${ly_src_dir}/rotate_wasm.cc
|
||||
${ly_src_dir}/rotate_win.cc
|
||||
${ly_src_dir}/row_any.cc
|
||||
${ly_src_dir}/row_common.cc
|
||||
${ly_src_dir}/row_gcc.cc
|
||||
${ly_src_dir}/row_hvx.cc
|
||||
${ly_src_dir}/row_rvv.cc
|
||||
${ly_src_dir}/row_wasm.cc
|
||||
${ly_src_dir}/row_win.cc
|
||||
${ly_src_dir}/scale.cc
|
||||
${ly_src_dir}/scale_any.cc
|
||||
${ly_src_dir}/scale_argb.cc
|
||||
${ly_src_dir}/scale_common.cc
|
||||
${ly_src_dir}/scale_gcc.cc
|
||||
${ly_src_dir}/scale_hvx.cc
|
||||
${ly_src_dir}/scale_rgb.cc
|
||||
${ly_src_dir}/scale_rvv.cc
|
||||
${ly_src_dir}/scale_uv.cc
|
||||
${ly_src_dir}/scale_wasm.cc
|
||||
${ly_src_dir}/scale_win.cc
|
||||
${ly_src_dir}/video_common.cc)
|
||||
|
||||
INCLUDE_DIRECTORIES( BEFORE ${ly_inc_dir} )
|
||||
file ( GLOB_RECURSE ly_unittest_sources ${ly_tst_dir}/*.cc )
|
||||
list ( SORT ly_unittest_sources )
|
||||
|
||||
# this creates the static library (.a)
|
||||
ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} )
|
||||
include_directories( BEFORE ${ly_inc_dir} )
|
||||
|
||||
# this creates the shared library (.so)
|
||||
ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} )
|
||||
SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
|
||||
SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" )
|
||||
|
||||
# this creates the conversion tool
|
||||
ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
|
||||
TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} )
|
||||
|
||||
|
||||
INCLUDE ( FindJPEG )
|
||||
if (JPEG_FOUND)
|
||||
include_directories( ${JPEG_INCLUDE_DIR} )
|
||||
target_link_libraries( yuvconvert ${JPEG_LIBRARY} )
|
||||
add_definitions( -DHAVE_JPEG )
|
||||
if(MSVC)
|
||||
add_definitions ( -D_CRT_SECURE_NO_WARNINGS )
|
||||
endif()
|
||||
|
||||
if(TEST)
|
||||
# Need to set PIC to allow creating shared libraries from object file libraries.
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# Build the set of objects that do not need to be compiled with flags to enable
|
||||
# particular architecture features.
|
||||
add_library( ${ly_lib_name}_common_objects OBJECT ${ly_common_source_files} )
|
||||
set(ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_common_objects>)
|
||||
|
||||
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSPROC)
|
||||
set(LOONGARCH64_ALIASES loongarch64)
|
||||
list(FIND LOONGARCH64_ALIASES "${SYSPROC}" LOONGARCH64MATCH)
|
||||
|
||||
if(LOONGARCH64MATCH GREATER "-1")
|
||||
set(LOONGARCH64 1)
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" arch_lowercase)
|
||||
|
||||
if(arch_lowercase MATCHES "^arm" AND NOT arch_lowercase STREQUAL "arm64")
|
||||
# Enable Arm Neon kernels.
|
||||
add_definitions(-DLIBYUV_NEON=1)
|
||||
add_library(${ly_lib_name}_neon OBJECT
|
||||
${ly_src_dir}/compare_neon.cc
|
||||
${ly_src_dir}/rotate_neon.cc
|
||||
${ly_src_dir}/row_neon.cc
|
||||
${ly_src_dir}/scale_neon.cc)
|
||||
target_compile_options(${ly_lib_name}_neon PRIVATE -mfpu=neon)
|
||||
list(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_neon>)
|
||||
endif()
|
||||
|
||||
if(arch_lowercase STREQUAL "aarch64" OR arch_lowercase STREQUAL "arm64")
|
||||
# Enable AArch64 Neon dot-product and i8mm kernels.
|
||||
add_library(${ly_lib_name}_neon64 OBJECT
|
||||
${ly_src_dir}/compare_neon64.cc
|
||||
${ly_src_dir}/rotate_neon64.cc
|
||||
${ly_src_dir}/row_neon64.cc
|
||||
${ly_src_dir}/scale_neon64.cc)
|
||||
target_compile_options(${ly_lib_name}_neon64 PRIVATE -march=armv8.2-a+dotprod+i8mm)
|
||||
list(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_neon64>)
|
||||
|
||||
# Enable AArch64 SVE kernels.
|
||||
add_library(${ly_lib_name}_sve OBJECT
|
||||
${ly_src_dir}/rotate_sve.cc
|
||||
${ly_src_dir}/row_sve.cc)
|
||||
target_compile_options(${ly_lib_name}_sve PRIVATE -march=armv8.5-a+i8mm+sve2)
|
||||
list(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_sve>)
|
||||
|
||||
# Check whether the compiler can compile SME functions; this fails
|
||||
# with Clang for Windows.
|
||||
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||
set(OLD_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=armv8.5-a+i8mm+sme")
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
check_c_source_compiles("
|
||||
__arm_locally_streaming void func(void) { }
|
||||
int main(void) { return 0; }
|
||||
" CAN_COMPILE_SME)
|
||||
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${OLD_CMAKE_TRY_COMPILE_TARGET_TYPE})
|
||||
|
||||
if (CAN_COMPILE_SME)
|
||||
# Enable AArch64 SME kernels.
|
||||
add_library(${ly_lib_name}_sme OBJECT
|
||||
${ly_src_dir}/rotate_sme.cc
|
||||
${ly_src_dir}/row_sme.cc
|
||||
${ly_src_dir}/scale_sme.cc)
|
||||
target_compile_options(${ly_lib_name}_sme PRIVATE -march=armv8.5-a+i8mm+sme)
|
||||
list(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_sme>)
|
||||
else()
|
||||
add_definitions(-DLIBYUV_DISABLE_SME)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(arch_lowercase MATCHES "^riscv")
|
||||
option(USE_RVV "Enable RISC-V Vector" ON)
|
||||
if(USE_RVV)
|
||||
if(NOT RISCV_COMPILER_FLAGS)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8 OR arch_lowercase STREQUAL "riscv64")
|
||||
set(RISCV_COMPILER_FLAGS "-march=rv64gcv")
|
||||
else()
|
||||
set(RISCV_COMPILER_FLAGS "-march=rv32gcv")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(CheckCSourceCompiles)
|
||||
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||
set(OLD_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${RISCV_COMPILER_FLAGS} -fno-tree-vectorize -fno-tree-slp-vectorize")
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
check_c_source_compiles("
|
||||
int main(void) { return 0; }
|
||||
" CAN_COMPILE_RVV)
|
||||
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${OLD_CMAKE_TRY_COMPILE_TARGET_TYPE})
|
||||
|
||||
if(CAN_COMPILE_RVV)
|
||||
if(NOT CMAKE_C_FLAGS MATCHES "-march=" AND NOT CMAKE_C_FLAGS MATCHES "-mcpu=")
|
||||
set(CMAKE_C_FLAGS "${RISCV_COMPILER_FLAGS} -fno-tree-vectorize -fno-tree-slp-vectorize ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${RISCV_COMPILER_FLAGS} -fno-tree-vectorize -fno-tree-slp-vectorize ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DLIBYUV_DISABLE_RVV)
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DLIBYUV_DISABLE_RVV)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(arch_lowercase MATCHES "^wasm" OR EMSCRIPTEN)
|
||||
set(CMAKE_C_FLAGS "-msimd128 ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "-msimd128 ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(LOONGARCH64)
|
||||
include(CheckCXXSourceCompiles)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-narrowing")
|
||||
check_cxx_source_compiles("
|
||||
int main(int argc, char **argv) {
|
||||
__asm__ volatile (
|
||||
\"vadd.w $vr0, $vr1, $vr1\"
|
||||
);
|
||||
return 0; }" SUPPORTS_LSX)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
int main(int argc, char **argv) {
|
||||
__asm__ volatile (
|
||||
\"xvadd.w $xr0, $xr1, $xr1\"
|
||||
);
|
||||
return 0; }" SUPPORTS_LASX)
|
||||
|
||||
if(SUPPORTS_LSX)
|
||||
# These kernels use only LSX (128-bit) instructions and must not be
|
||||
# compiled with -mlasx, which would let the compiler emit 256-bit LASX
|
||||
# code (e.g. for stack-array copies) and crash on LSX-only CPUs.
|
||||
add_library(${ly_lib_name}_lsx OBJECT
|
||||
${ly_src_dir}/rotate_lsx.cc
|
||||
${ly_src_dir}/row_lsx.cc
|
||||
${ly_src_dir}/scale_lsx.cc)
|
||||
target_compile_options(${ly_lib_name}_lsx PRIVATE -mlsx)
|
||||
list(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_lsx>)
|
||||
endif()
|
||||
if(SUPPORTS_LASX)
|
||||
add_library(${ly_lib_name}_lasx OBJECT
|
||||
${ly_src_dir}/rotate_lasx.cc
|
||||
${ly_src_dir}/row_lasx.cc)
|
||||
target_compile_options(${ly_lib_name}_lasx PRIVATE -mlasx)
|
||||
list(APPEND ly_lib_parts $<TARGET_OBJECTS:${ly_lib_name}_lasx>)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# this creates the static library (.a)
|
||||
add_library( ${ly_lib_static} STATIC ${ly_lib_parts})
|
||||
|
||||
# this creates the shared library (.so)
|
||||
add_library( ${ly_lib_shared} SHARED ${ly_lib_parts})
|
||||
set_target_properties( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" )
|
||||
set_target_properties( ${ly_lib_shared} PROPERTIES PREFIX "lib" )
|
||||
if(WIN32)
|
||||
set_target_properties( ${ly_lib_shared} PROPERTIES IMPORT_PREFIX "lib" )
|
||||
endif()
|
||||
|
||||
# this creates the cpuid tool
|
||||
add_executable ( cpuid ${ly_base_dir}/util/cpuid.c )
|
||||
target_link_libraries ( cpuid ${ly_lib_static} )
|
||||
|
||||
# this creates the conversion tool
|
||||
add_executable ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc )
|
||||
target_link_libraries ( yuvconvert ${ly_lib_static} )
|
||||
|
||||
# this creates the yuvconstants tool
|
||||
add_executable ( yuvconstants ${ly_base_dir}/util/yuvconstants.c )
|
||||
target_link_libraries ( yuvconstants ${ly_lib_static} )
|
||||
if(NOT MSVC)
|
||||
target_link_libraries ( yuvconstants m )
|
||||
endif()
|
||||
|
||||
if (NOT LIBYUV_DISABLE_JPEG)
|
||||
find_package ( JPEG )
|
||||
if (JPEG_FOUND)
|
||||
include_directories( ${JPEG_INCLUDE_DIR} )
|
||||
target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} )
|
||||
add_definitions( -DHAVE_JPEG )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(UNIT_TEST)
|
||||
find_library(GTEST_LIBRARY gtest)
|
||||
if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND")
|
||||
set(GTEST_SRC_DIR /usr/src/gtest CACHE STRING "Location of gtest sources")
|
||||
set(GTEST_SRC_DIR_DEFAULT /usr/src/gtest)
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
set(GTEST_SRC_DIR_DEFAULT ${CMAKE_SOURCE_DIR}/third_party/googletest/src/googletest)
|
||||
endif()
|
||||
set(GTEST_SRC_DIR ${GTEST_SRC_DIR_DEFAULT} CACHE STRING "Location of gtest sources")
|
||||
if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc)
|
||||
message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}")
|
||||
set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc)
|
||||
@@ -54,12 +279,15 @@ if(TEST)
|
||||
include_directories(${GTEST_SRC_DIR}/include)
|
||||
set(GTEST_LIBRARY gtest)
|
||||
else()
|
||||
message(FATAL_ERROR "TEST is set but unable to find gtest library")
|
||||
message(FATAL_ERROR "UNIT_TEST is set but unable to find gtest library")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(libyuv_unittest ${ly_unittest_sources})
|
||||
target_link_libraries(libyuv_unittest ${ly_lib_name} ${GTEST_LIBRARY})
|
||||
if(NOT MSVC)
|
||||
target_link_libraries(libyuv_unittest m)
|
||||
endif()
|
||||
find_library(PTHREAD_LIBRARY pthread)
|
||||
if(NOT PTHREAD_LIBRARY STREQUAL "PTHREAD_LIBRARY-NOTFOUND")
|
||||
target_link_libraries(libyuv_unittest pthread)
|
||||
@@ -81,11 +309,11 @@ endif()
|
||||
|
||||
|
||||
# install the conversion tool, .so, .a, and all the header files
|
||||
INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin )
|
||||
INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib )
|
||||
INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin )
|
||||
INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
|
||||
install ( TARGETS yuvconvert DESTINATION bin )
|
||||
install ( TARGETS ${ly_lib_static} DESTINATION lib )
|
||||
install ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib )
|
||||
install ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include )
|
||||
|
||||
# create the .deb and .rpm packages using cpack
|
||||
INCLUDE ( CM_linux_packages.cmake )
|
||||
include ( CM_linux_packages.cmake )
|
||||
|
||||
+521
-1164
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,3 @@
|
||||
monorail {
|
||||
component: "Internals>Images>Codecs"
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
# Gemini Project Context: libyuv Row Functions
|
||||
|
||||
This file provides context for the core row-processing architecture of
|
||||
libyuv. Use these guidelines when refactoring, reviewing, or generating
|
||||
code within the `row_*.cc` files.
|
||||
|
||||
## Architectural Overview
|
||||
|
||||
Libyuv uses a dispatch system where high-level conversion functions call
|
||||
optimized "Row" functions. These functions are categorized by SIMD architecture
|
||||
and compiler compatibility.
|
||||
|
||||
## Source File Map
|
||||
|
||||
### x86 Architectures (32-bit and 64-bit)
|
||||
|
||||
* **row_gcc.cc**: **Master copy.** Contains inline assembly in GCC syntax for
|
||||
GCC and Clang. Supports AVX, and AVX512. AVX512 implementations are strictly
|
||||
for 64-bit targets.
|
||||
* **row_win.cc**: Derivative of `row_gcc.cc`. Contains C++ intrinsics
|
||||
specifically for Visual C++ (MSVC). Can be tested with Clang using
|
||||
`-DLIBYUV_ENABLE_ROWWIN`.
|
||||
* **Note**: Use either `row_gcc` or `row_win`, never both.
|
||||
|
||||
### Arm Architecture (32-bit)
|
||||
|
||||
* **row_neon.cc**: 32-bit Arm. Written entirely in inline assembly for
|
||||
GCC/Clang.
|
||||
|
||||
### Arm Architecture (AArch64) (64-bit)
|
||||
|
||||
* **row_neon64.cc**: 64-bit Arm (AArch64) Neon. Written entirely in inline
|
||||
assembly for GCC/Clang.
|
||||
* **row_sve.cc**: Armv9 Scalable Vector Extension (SVE2).
|
||||
* **row_sme.cc**: Armv9 Scalable Matrix Extension (SME) and Streaming SVE
|
||||
(SSVE).
|
||||
* **row_sve.h**: Streaming-compatible implementations shared across
|
||||
**row_sve.cc** and **row_sme.cc**.
|
||||
|
||||
### Other Architectures
|
||||
|
||||
* **row_rvv.cc**: RISC-V Vector (RVV). Implemented using intrinsics. Optimized
|
||||
for SiFive X280.
|
||||
* **row_hvx.cc**: Qualcomm Hexagon Vector Extensions (HVX). Implemented using
|
||||
intrinsics.
|
||||
* **row_lsx.cc / row_lasx.cc**: Loongarch MIPS-like extensions.
|
||||
|
||||
### Utility and Fallbacks
|
||||
|
||||
* **row_common.cc**: Portable C/C++ versions and multi-step `ARGB` wrapper
|
||||
row functions. This is the reference implementation.
|
||||
* **row_any.cc**: Handles "remainder" pixels for widths not multiples of SIMD
|
||||
register size. Used for SSE/AVX2, Neon, and LoongArch (LSX/LASX). Not
|
||||
required for AVX-512, SVE2, SME, RVV, or HVX, which handle tail masking
|
||||
directly inside the Row function.
|
||||
|
||||
## Deprecated and Lower-Priority Formats
|
||||
|
||||
The following datatypes and functions are deprecated or lower priority and are
|
||||
not always fully hand-optimized across every SIMD extension:
|
||||
|
||||
* **16-bit RGB formats** (deprecated): `RGB565` (`FOURCC_RGBP`,
|
||||
`FOURCC_L565`), `ARGB1555` (`FOURCC_RGBO`, `FOURCC_L555`, `FOURCC_5551`),
|
||||
and `ARGB4444` (`FOURCC_R444`).
|
||||
* **Legacy fixed-matrix RGB-to-YUV row functions** (deprecated in favor of
|
||||
`*MatrixRow` variants): `RGB565ToYRow`, `RGB565ToUVRow`, `ARGB1555ToYRow`,
|
||||
`ARGB1555ToUVRow`, `ARGB4444ToYRow`, `ARGB4444ToUVRow`.
|
||||
* **Row-biplanar YUV** (deprecated): `M420` (`FOURCC_M420`).
|
||||
|
||||
When adding SIMD coverage for deprecated or less relevant formats, prefer
|
||||
two-step wrapper implementations in `source/row_common.cc` that convert to or
|
||||
from an intermediate stack-allocated `ARGB` row buffer (or delegate to existing
|
||||
`*MatrixRow` functions) rather than writing large bespoke assembly kernels.
|
||||
|
||||
## Coding Guidelines
|
||||
|
||||
1. **Feature Macros**: Use the `HAS_` macros in `include/libyuv/row.h` to
|
||||
enable or disable specific instruction set extensions.
|
||||
2. **Inline asm clobbers (all architectures)**: Every register written by an
|
||||
inline asm block must be listed in its clobber list: vector registers,
|
||||
general purpose registers, mask/predicate registers, `"cc"` when flags
|
||||
are set (`subs`, `cmp`, `whilelt`, ...) and `"memory"` when the block
|
||||
stores. Declare them even if the ABI treats them as caller-saved: with
|
||||
LTO/LTCG the compiler may keep values live in any register across the
|
||||
asm, and other OS ABIs (e.g. Windows) differ in which registers are
|
||||
callee-saved. Never remove a clobber because it "is not needed by the
|
||||
ABI". Use real register names, not numbers (`"v22"`, not `"22"`). Order
|
||||
the list `"memory"` first (when stores occur), then `"cc"` (on
|
||||
architectures with flags), then registers.
|
||||
|
||||
### x86 Architectures (32-bit and 64-bit)
|
||||
|
||||
1. **AVX512 Logic**: AVX512 row functions are strictly enabled for **64-bit x86
|
||||
only**. Do not create `_Any_` wrappers for AVX512 row functions; handle
|
||||
arbitrary tail widths directly inside the Row function using `k1`-`k7`
|
||||
opmask registers.
|
||||
2. **MSVC Intrinsics (`row_win.cc`)**: When converting `row_gcc.cc` to
|
||||
`row_win.cc`, use `_mm512_permutex2var_epi8`, not `_mm512_permi2var_epi8`
|
||||
intrinsic.
|
||||
3. **Clobber names**: Always declare vector clobbers as `"xmmN"`, never
|
||||
`"ymmN"` or `"zmmN"`, including for AVX2 and AVX512 code. Clang for
|
||||
Windows must preserve xmm6-xmm15 and does not save them when they are
|
||||
declared as ymm or zmm.
|
||||
4. **MSan Intrinsics (`*_win.cc`)**: Clang builds with MemorySanitizer
|
||||
(`-fsanitize=memory`) define `LIBYUV_ENABLE_ROWWIN` and compile `*_win.cc`
|
||||
(`row_win.cc`, `scale_win.cc`, `compare_win.cc`, `rotate_win.cc`) instead of
|
||||
inline assembly (`*_gcc.cc`). When porting `*_gcc.cc` to `*_win.cc`, never
|
||||
use AVX-512 intrinsics that LLVM's MSan pass does not model:
|
||||
* **Down-converting masked stores**: Never use
|
||||
`_mm512_mask_cvtepi32_storeu_epi8`, `_mm512_mask_cvtepi64_storeu_epi8`,
|
||||
`_mm512_mask_cvtepi16_storeu_epi8`, or
|
||||
`_mm512_mask_cvtepi32_storeu_epi16`. They lower to target-specific
|
||||
`@llvm.x86.avx512.mask.pmov.*.mem.*` intrinsics that LLVM MSan does not
|
||||
model, leaving the destination shadow memory poisoned (uninitialized).
|
||||
Instead, convert to a narrower vector first and use a standard masked
|
||||
store (e.g. `_mm_mask_storeu_epi8(dst, mask, _mm512_cvtepi32_epi8(v))`),
|
||||
which lowers to `@llvm.masked.store` for MSan and still compiles to a
|
||||
single `vpmovdb` instruction at `-O2`.
|
||||
* **Ternary logic (`_mm*_ternarylogic_epi32` / `epi64`)**: Never use
|
||||
`_mm512_ternarylogic_epi32`/`epi64` (or `_mm256_`/`_mm_` variants)
|
||||
anywhere in `*_win.cc` when porting `vpternlogd`/`vpternlogq` from
|
||||
`*_gcc.cc`. They lower to `@llvm.x86.avx512.pternlog.*`, which LLVM MSan
|
||||
does not model bitwise—`handleUnknownIntrinsic` traps immediately with
|
||||
`use-of-uninitialized-value` if *any* bit of any of the three inputs is
|
||||
uninitialized (such as the unused alpha byte of an `RGBX` buffer or tail
|
||||
padding), even if masked off by `imm8` or merely copied to memory.
|
||||
* For boolean blends and inversions (e.g. `ARGBGrayRow_AVX512VNNI`,
|
||||
`I422ToAR30Row_AVX512BW`, `ARGBToUV444MatrixRow_AVX512VNNIVBMI`),
|
||||
use standard bitwise intrinsics (`_mm512_and_si512`,
|
||||
`_mm512_andnot_si512`, `_mm512_or_si512`, `_mm512_xor_si512`), which
|
||||
LLVM MSan models bit-by-bit and Clang `-O2` folds back into
|
||||
`vpternlog` in non-MSan builds.
|
||||
* For write-only partial channel updates into `dst` (e.g. writing
|
||||
alpha in `ARGBCopyYToAlphaRow_AVX512BW`), use byte-masked stores
|
||||
(`_mm512_mask_storeu_epi8`) instead of reading `dst` and blending.
|
||||
* **Single-source variable permutes (`_mm512_permutexvar_epi*` /
|
||||
`_mm512_mask_permutexvar_epi*`)**: Never use
|
||||
`_mm512_permutexvar_epi{8,16,32,64}` or
|
||||
`_mm512_mask_permutexvar_epi{8,16,32,64}` directly. They lower to
|
||||
`@llvm.x86.avx512.permvar.*`, which LLVM MSan does not model
|
||||
lane-by-lane—instead it ORs the input shadows without permuting them,
|
||||
poisoning initialized output lanes whenever *any* lane of the input
|
||||
vector is uninitialized (e.g. `_mm512_castsi128_si512`,
|
||||
`_mm512_castsi256_si512`, unused `RGBX` alpha bytes, or uninitialized
|
||||
tail lanes). Use the `PermutexvarEpi*` and `MaskPermutexvarEpi*`
|
||||
helpers in `row_win.cc` / `scale_win.cc`, which use portable
|
||||
lane-by-lane C loops under `LIBYUV_MSAN` and the native intrinsics
|
||||
otherwise.
|
||||
* **512-bit float-to-int truncation (`_mm512_cvttps_epi32`)**: Never use
|
||||
`_mm512_cvttps_epi32` directly; it lowers to
|
||||
`@llvm.x86.avx512.mask.cvttps2dq.512`, which LLVM MSan does not model
|
||||
lane-by-lane. Use the `CvttpsEpi32` helper in `row_win.cc`, which uses
|
||||
a portable lane-by-lane C loop under `LIBYUV_MSAN` and
|
||||
`_mm512_cvttps_epi32` otherwise.
|
||||
|
||||
### AArch64
|
||||
|
||||
1. For SVE2/SME, aim to use full predicates (`ptrue`) and full vectors for the
|
||||
main loop body and use predication only to mask the tail loop as needed.
|
||||
Pointer updates should be done with `inc[bhwd]` or `add`, not by `incp`.
|
||||
|
||||
## Changelist (CL) Format Guidelines
|
||||
|
||||
When adding new code, remove trailing spaces.
|
||||
When generating descriptions, follow the Chromium standard format. Wrap
|
||||
commit message text at 72 characters
|
||||
|
||||
### Changelist (CL) Description Example
|
||||
|
||||
\[libyuv] Optimized ARGBToRGB24 for AVX2
|
||||
|
||||
Detailed technical explanation of the change. Describe the SIMD
|
||||
optimization logic and any platform-specific constraints. Mention
|
||||
if this impacts specific row files like row_gcc.cc.
|
||||
|
||||
Test: libyuv_unittest --gunit_filter=*ARGBToRGB24*
|
||||
Bug: libyuv:12345, b/67890
|
||||
+5
-3
@@ -1,8 +1,10 @@
|
||||
fbarchard@chromium.org
|
||||
magjed@chromium.org
|
||||
wtc@google.com
|
||||
mbonadei@chromium.org
|
||||
jansson@google.com
|
||||
|
||||
per-file *.gn=phoglund@chromium.org
|
||||
per-file *.gn=mbonadei@chromium.org,jansson@google.com
|
||||
per-file .gitignore=*
|
||||
per-file AUTHORS=*
|
||||
per-file DEPS=*
|
||||
per-file PRESUBMIT.py=phoglund@chromium.org
|
||||
per-file PRESUBMIT.py=mbonadei@chromium.org,jansson@google.com
|
||||
+48
-55
@@ -6,67 +6,60 @@
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def _RunPythonTests(input_api, output_api):
|
||||
def join(*args):
|
||||
return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
|
||||
|
||||
test_directories = [
|
||||
root for root, _, files in os.walk(join('tools_libyuv'))
|
||||
if any(f.endswith('_test.py') for f in files)
|
||||
]
|
||||
|
||||
tests = []
|
||||
for directory in test_directories:
|
||||
tests.extend(
|
||||
input_api.canned_checks.GetUnitTestsInDirectory(
|
||||
input_api,
|
||||
output_api,
|
||||
directory,
|
||||
whitelist=[r'.+_test\.py$']))
|
||||
return input_api.RunTests(tests, parallel=True)
|
||||
# Runs PRESUBMIT.py in py3 mode by git cl presubmit.
|
||||
USE_PYTHON3 = True
|
||||
|
||||
|
||||
def _CommonChecks(input_api, output_api):
|
||||
"""Checks common to both upload and commit."""
|
||||
results = []
|
||||
results.extend(input_api.canned_checks.RunPylint(input_api, output_api,
|
||||
black_list=(r'^base[\\\/].*\.py$',
|
||||
r'^build[\\\/].*\.py$',
|
||||
r'^buildtools[\\\/].*\.py$',
|
||||
r'^ios[\\\/].*\.py$',
|
||||
r'^out.*[\\\/].*\.py$',
|
||||
r'^testing[\\\/].*\.py$',
|
||||
r'^third_party[\\\/].*\.py$',
|
||||
r'^tools[\\\/].*\.py$',
|
||||
# TODO(kjellander): should arguably be checked.
|
||||
r'^tools_libyuv[\\\/]valgrind[\\\/].*\.py$',
|
||||
r'^xcodebuild.*[\\\/].*\.py$',),
|
||||
disabled_warnings=['F0401', # Failed to import x
|
||||
'E0611', # No package y in x
|
||||
'W0232', # Class has no __init__ method
|
||||
],
|
||||
pylintrc='pylintrc'))
|
||||
results.extend(_RunPythonTests(input_api, output_api))
|
||||
return results
|
||||
"""Checks common to both upload and commit."""
|
||||
results = []
|
||||
results.extend(
|
||||
input_api.canned_checks.RunPylint(
|
||||
input_api,
|
||||
output_api,
|
||||
files_to_skip=(
|
||||
r'^base[\\\/].*\.py$',
|
||||
r'^build[\\\/].*\.py$',
|
||||
r'^buildtools[\\\/].*\.py$',
|
||||
r'^ios[\\\/].*\.py$',
|
||||
r'^out.*[\\\/].*\.py$',
|
||||
r'^testing[\\\/].*\.py$',
|
||||
r'^third_party[\\\/].*\.py$',
|
||||
r'^tools[\\\/].*\.py$',
|
||||
# TODO(kjellander): should arguably be checked.
|
||||
r'^tools_libyuv[\\\/]valgrind[\\\/].*\.py$',
|
||||
r'^xcodebuild.*[\\\/].*\.py$',
|
||||
),
|
||||
disabled_warnings=[
|
||||
'F0401', # Failed to import x
|
||||
'E0611', # No package y in x
|
||||
'W0232', # Class has no __init__ method
|
||||
],
|
||||
pylintrc='pylintrc',
|
||||
version='2.7',
|
||||
)
|
||||
)
|
||||
return results
|
||||
|
||||
|
||||
def CheckChangeOnUpload(input_api, output_api):
|
||||
results = []
|
||||
results.extend(_CommonChecks(input_api, output_api))
|
||||
results.extend(
|
||||
input_api.canned_checks.CheckGNFormatted(input_api, output_api))
|
||||
return results
|
||||
results = []
|
||||
results.extend(_CommonChecks(input_api, output_api))
|
||||
results.extend(
|
||||
input_api.canned_checks.CheckGNFormatted(input_api, output_api)
|
||||
)
|
||||
return results
|
||||
|
||||
|
||||
def CheckChangeOnCommit(input_api, output_api):
|
||||
results = []
|
||||
results.extend(_CommonChecks(input_api, output_api))
|
||||
results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
|
||||
results.extend(input_api.canned_checks.CheckChangeWasUploaded(
|
||||
input_api, output_api))
|
||||
results.extend(input_api.canned_checks.CheckChangeHasDescription(
|
||||
input_api, output_api))
|
||||
return results
|
||||
results = []
|
||||
results.extend(_CommonChecks(input_api, output_api))
|
||||
results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
|
||||
results.extend(
|
||||
input_api.canned_checks.CheckChangeWasUploaded(input_api, output_api)
|
||||
)
|
||||
results.extend(
|
||||
input_api.canned_checks.CheckChangeHasDescription(input_api,
|
||||
output_api)
|
||||
)
|
||||
return results
|
||||
@@ -1,8 +1,13 @@
|
||||
Name: libyuv
|
||||
URL: http://code.google.com/p/libyuv/
|
||||
Version: 1735
|
||||
License: BSD
|
||||
URL: https://chromium.googlesource.com/libyuv/libyuv/
|
||||
Version: 1977
|
||||
Revision: DEPS
|
||||
License: BSD-3-Clause
|
||||
License File: LICENSE
|
||||
Shipped: yes
|
||||
Security Critical: yes
|
||||
Update Mechanism: Manual
|
||||
|
||||
Description:
|
||||
libyuv is an open source project that includes YUV conversion and scaling functionality.
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
* 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 on Arm.
|
||||
* Optimized for Neon/SVE2/SME on Arm.
|
||||
* Optimized for MSA on Mips.
|
||||
* Optimized for RVV on RISC-V.
|
||||
|
||||
### Development
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
workspace(name = "libyuv")
|
||||
|
||||
android_sdk_repository(
|
||||
name = "androidsdk",
|
||||
# Bazel will automatically use the ANDROID_HOME environment variable.
|
||||
)
|
||||
|
||||
android_ndk_repository(
|
||||
name = "androidndk",
|
||||
# Bazel will automatically use the ANDROID_NDK_HOME environment variable.
|
||||
)
|
||||
|
||||
# Optional: If you need to fetch specific dependencies (e.g., GoogleTest, libjpeg-turbo)
|
||||
# you can define them here using http_archive.
|
||||
@@ -6,9 +6,6 @@
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
# Some non-Chromium builds don't use Chromium's third_party/binutils.
|
||||
linux_use_bundled_binutils_override = true
|
||||
|
||||
# Variable that can be used to support multiple build scenarios, like having
|
||||
# Chromium specific targets in a client project's GN file etc.
|
||||
build_with_chromium = false
|
||||
@@ -16,6 +13,9 @@ build_with_chromium = false
|
||||
# Some non-Chromium builds don't support building java targets.
|
||||
enable_java_templates = true
|
||||
|
||||
# Enables assertions on safety checks in libc++.
|
||||
enable_safe_libcxx = true
|
||||
|
||||
# Allow using custom suppressions files (currently not used by libyuv).
|
||||
asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc"
|
||||
lsan_suppressions_file = "//build/sanitizers/lsan_suppressions.cc"
|
||||
@@ -35,12 +35,31 @@ ignore_elf32_limitations = true
|
||||
|
||||
# Use bundled hermetic Xcode installation maintained by Chromium,
|
||||
# except for local iOS builds where it is unsupported.
|
||||
if (host_os == "mac") {
|
||||
# Allow for mac cross compile on linux machines.
|
||||
if (host_os == "mac" || host_os == "linux") {
|
||||
_result = exec_script("//build/mac/should_use_hermetic_xcode.py",
|
||||
[ target_os ],
|
||||
"value")
|
||||
assert(_result != 2,
|
||||
"Do not allow building targets with the default" +
|
||||
"Do not allow building targets with the default " +
|
||||
"hermetic toolchain if the minimum OS version is not met.")
|
||||
use_system_xcode = _result == 0
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
# Limits the defined //third_party/android_deps targets to only "buildCompile"
|
||||
# and "buildCompileNoDeps" targets. This is useful for third-party
|
||||
# repositories which do not use JUnit tests. For instance,
|
||||
# limit_android_deps == true removes "gn gen" requirement for
|
||||
# //third_party/robolectric .
|
||||
limit_android_deps = false
|
||||
|
||||
# Allows googletest to pretty-print various absl types.
|
||||
# Defined here rather than in gtest.gni to match chromium.
|
||||
gtest_enable_absl_printers = true
|
||||
}
|
||||
|
||||
vpython_spec_files = [
|
||||
"//vpython.toml",
|
||||
"//vpython.toml.uv.lock",
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
# Copyright 2022 The LibYuv Project Authors. All rights reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
# Use default values for PartitionAlloc as standalone library from
|
||||
# base/allocator/partition_allocator/build_overrides/partition_alloc.gni
|
||||
use_partition_alloc_as_malloc_default = false
|
||||
use_allocator_shim_default = false
|
||||
enable_backup_ref_ptr_support_default = false
|
||||
enable_mte_checked_ptr_support_default = false
|
||||
put_ref_count_in_previous_slot_default = false
|
||||
enable_backup_ref_ptr_slow_checks_default = false
|
||||
enable_dangling_raw_ptr_checks_default = false
|
||||
@@ -1,107 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2017 The LibYuv Project Authors. All rights reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
# This is a copy of the file from WebRTC in:
|
||||
# https://chromium.googlesource.com/external/webrtc/+/master/cleanup_links.py
|
||||
|
||||
"""Script to cleanup symlinks created from setup_links.py.
|
||||
|
||||
Before 177567c518b121731e507e9b9c4049c4dc96e4c8 (#15754) we had a Chromium
|
||||
checkout which we created symlinks into. In order to do clean syncs after
|
||||
landing that change, this script cleans up any old symlinks, avoiding annoying
|
||||
manual cleanup needed in order to complete gclient sync.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import optparse
|
||||
import os
|
||||
import shelve
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
LINKS_DB = 'links'
|
||||
|
||||
# Version management to make future upgrades/downgrades easier to support.
|
||||
SCHEMA_VERSION = 1
|
||||
|
||||
class WebRTCLinkSetup(object):
|
||||
def __init__(self, links_db, dry_run=False):
|
||||
self._dry_run = dry_run
|
||||
self._links_db = links_db
|
||||
|
||||
def CleanupLinks(self):
|
||||
logging.debug('CleanupLinks')
|
||||
for source, link_path in self._links_db.iteritems():
|
||||
if source == 'SCHEMA_VERSION':
|
||||
continue
|
||||
if os.path.islink(link_path) or sys.platform.startswith('win'):
|
||||
# os.path.islink() always returns false on Windows
|
||||
# See http://bugs.python.org/issue13143.
|
||||
logging.debug('Removing link to %s at %s', source, link_path)
|
||||
if not self._dry_run:
|
||||
if os.path.exists(link_path):
|
||||
if sys.platform.startswith('win') and os.path.isdir(link_path):
|
||||
subprocess.check_call(['rmdir', '/q', '/s', link_path],
|
||||
shell=True)
|
||||
else:
|
||||
os.remove(link_path)
|
||||
del self._links_db[source]
|
||||
|
||||
|
||||
def _initialize_database(filename):
|
||||
links_database = shelve.open(filename)
|
||||
# Wipe the database if this version of the script ends up looking at a
|
||||
# newer (future) version of the links db, just to be sure.
|
||||
version = links_database.get('SCHEMA_VERSION')
|
||||
if version and version != SCHEMA_VERSION:
|
||||
logging.info('Found database with schema version %s while this script only '
|
||||
'supports %s. Wiping previous database contents.', version,
|
||||
SCHEMA_VERSION)
|
||||
links_database.clear()
|
||||
links_database['SCHEMA_VERSION'] = SCHEMA_VERSION
|
||||
return links_database
|
||||
|
||||
|
||||
def main():
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('-d', '--dry-run', action='store_true', default=False,
|
||||
help='Print what would be done, but don\'t perform any '
|
||||
'operations. This will automatically set logging to '
|
||||
'verbose.')
|
||||
parser.add_option('-v', '--verbose', action='store_const',
|
||||
const=logging.DEBUG, default=logging.INFO,
|
||||
help='Print verbose output for debugging.')
|
||||
options, _ = parser.parse_args()
|
||||
|
||||
if options.dry_run:
|
||||
options.verbose = logging.DEBUG
|
||||
logging.basicConfig(format='%(message)s', level=options.verbose)
|
||||
|
||||
# Work from the root directory of the checkout.
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
os.chdir(script_dir)
|
||||
|
||||
# The database file gets .db appended on some platforms.
|
||||
db_filenames = [LINKS_DB, LINKS_DB + '.db']
|
||||
if any(os.path.isfile(f) for f in db_filenames):
|
||||
links_database = _initialize_database(LINKS_DB)
|
||||
try:
|
||||
symlink_creator = WebRTCLinkSetup(links_database, options.dry_run)
|
||||
symlink_creator.CleanupLinks()
|
||||
finally:
|
||||
for f in db_filenames:
|
||||
if os.path.isfile(f):
|
||||
os.remove(f)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -1,6 +1,5 @@
|
||||
# This file is used by git cl to get repository specific information.
|
||||
# This file is used by `git cl` to get repository specific information.
|
||||
CODE_REVIEW_SERVER: codereview.chromium.org
|
||||
GERRIT_HOST: True
|
||||
PROJECT: libyuv
|
||||
TRY_ON_UPLOAD: False
|
||||
VIEW_VC: https://chromium.googlesource.com/libyuv/libyuv/+/
|
||||
@@ -11,23 +11,7 @@ Refer to chromium instructions for each platform for other prerequisites.
|
||||
|
||||
Create a working directory, enter it, and run:
|
||||
|
||||
gclient config https://chromium.googlesource.com/libyuv/libyuv
|
||||
gclient sync
|
||||
|
||||
|
||||
Then you'll get a .gclient file like:
|
||||
|
||||
solutions = [
|
||||
{ "name" : "libyuv",
|
||||
"url" : "https://chromium.googlesource.com/libyuv/libyuv",
|
||||
"deps_file" : "DEPS",
|
||||
"managed" : True,
|
||||
"custom_deps" : {
|
||||
},
|
||||
"safesync_url": "",
|
||||
},
|
||||
];
|
||||
|
||||
fetch libyuv
|
||||
|
||||
For iOS add `;target_os=['ios'];` to your OSX .gclient and run `GYP_DEFINES="OS=ios" gclient sync.`
|
||||
|
||||
@@ -157,19 +141,13 @@ ia32
|
||||
GYP_DEFINES="OS=android target_arch=ia32 android_full_debug=1" GYP_CROSSCOMPILE=1 ./gyp_libyuv
|
||||
ninja -j7 -C out/Debug yuv_unittest_apk
|
||||
|
||||
mipsel
|
||||
|
||||
GYP_DEFINES="OS=android target_arch=mipsel" GYP_CROSSCOMPILE=1 ./gyp_libyuv
|
||||
ninja -j7 -C out/Debug yuv_unittest_apk
|
||||
ninja -j7 -C out/Release yuv_unittest_apk
|
||||
|
||||
arm32 disassembly:
|
||||
|
||||
third_party/android_ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objdump -d out/Release/obj/source/libyuv.row_neon.o
|
||||
llvm-objdump -d out/Release/obj/source/libyuv.row_neon.o
|
||||
|
||||
arm64 disassembly:
|
||||
|
||||
third_party/android_ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -d out/Release/obj/source/libyuv.row_neon64.o
|
||||
llvm-objdump -d out/Release/obj/source/libyuv.row_neon64.o
|
||||
|
||||
Running tests:
|
||||
|
||||
@@ -195,16 +173,6 @@ Running test with C code:
|
||||
gn gen out/Official "--args=is_debug=false is_official_build=true is_chrome_branded=true"
|
||||
ninja -C out/Official
|
||||
|
||||
#### Building mips with GN
|
||||
|
||||
mipsel
|
||||
gn gen out/Default "--args=is_debug=false target_cpu=\"mipsel\" target_os = \"android\" mips_arch_variant = \"r6\" mips_use_msa = true is_component_build = true is_clang = false"
|
||||
ninja -C out/Default
|
||||
|
||||
mips64el
|
||||
gn gen out/Default "--args=is_debug=false target_cpu=\"mips64el\" target_os = \"android\" mips_arch_variant = \"r6\" mips_use_msa = true is_component_build = true is_clang = false"
|
||||
ninja -C out/Default
|
||||
|
||||
### Linux
|
||||
|
||||
GYP_DEFINES="target_arch=x64" ./gyp_libyuv
|
||||
@@ -239,6 +207,7 @@ If you get a compile error for atlthunk.lib on Windows, read http://www.chromium
|
||||
ninja -C out/Debug libyuv_unittest
|
||||
ninja -C out/Debug compare
|
||||
ninja -C out/Debug yuvconvert
|
||||
ninja -C out/Debug yuvconstants
|
||||
ninja -C out/Debug psnr
|
||||
ninja -C out/Debug cpuid
|
||||
|
||||
|
||||
@@ -7,9 +7,11 @@ For test purposes, environment variables can be set to control libyuv behavior.
|
||||
By default the cpu is detected and the most advanced form of SIMD is used. But you can disable instruction sets selectively, or completely, falling back on C code. Set the variable to 1 to disable the specified instruction set.
|
||||
|
||||
## All CPUs
|
||||
|
||||
LIBYUV_DISABLE_ASM
|
||||
|
||||
## Intel CPUs
|
||||
|
||||
LIBYUV_DISABLE_X86
|
||||
LIBYUV_DISABLE_SSE2
|
||||
LIBYUV_DISABLE_SSSE3
|
||||
@@ -22,19 +24,39 @@ By default the cpu is detected and the most advanced form of SIMD is used. But
|
||||
LIBYUV_DISABLE_F16C
|
||||
LIBYUV_DISABLE_AVX512BW
|
||||
LIBYUV_DISABLE_AVX512VL
|
||||
LIBYUV_DISABLE_AVX512VNNI
|
||||
LIBYUV_DISABLE_AVX512VBMI
|
||||
LIBYUV_DISABLE_AVX512VBMI2
|
||||
LIBYUV_DISABLE_AVX512VBITALG
|
||||
LIBYUV_DISABLE_AVX512VPOPCNTDQ
|
||||
LIBYUV_DISABLE_GFNI
|
||||
LIBYUV_DISABLE_AVX10
|
||||
LIBYUV_DISABLE_AVX10_2
|
||||
LIBYUV_DISABLE_AVXVNNI
|
||||
LIBYUV_DISABLE_AVXVNNIINT8
|
||||
LIBYUV_DISABLE_AMXINT8
|
||||
LIBYUV_DISABLE_AVX512BMM
|
||||
LIBYUV_DISABLE_AMXTF32
|
||||
|
||||
## ARM CPUs
|
||||
## Arm CPUs
|
||||
|
||||
LIBYUV_DISABLE_NEON
|
||||
LIBYUV_DISABLE_NEON_DOTPROD
|
||||
LIBYUV_DISABLE_NEON_I8MM
|
||||
LIBYUV_DISABLE_SVE
|
||||
LIBYUV_DISABLE_SVE2
|
||||
LIBYUV_DISABLE_SME
|
||||
|
||||
## MIPS CPUs
|
||||
LIBYUV_DISABLE_MSA
|
||||
LIBYUV_DISABLE_MMI
|
||||
## LOONGARCH CPUs
|
||||
|
||||
LIBYUV_DISABLE_LSX
|
||||
LIBYUV_DISABLE_LASX
|
||||
|
||||
## RISCV CPUs
|
||||
|
||||
LIBYUV_DISABLE_RVV
|
||||
|
||||
## Hexagon CPUs
|
||||
|
||||
LIBYUV_DISABLE_HVX
|
||||
|
||||
# Test Width/Height/Repeat
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
# Introduction
|
||||
|
||||
Several routines in libyuv have multiple implementations specialized for a
|
||||
variety of CPU architecture extensions. Libyuv will automatically detect and
|
||||
use the latest architecture extension present on a machine for which a kernel
|
||||
implementation is available.
|
||||
|
||||
# Feature detection on AArch64
|
||||
|
||||
## Architecture extensions of interest
|
||||
|
||||
The Arm 64-bit A-class architecture has a number of vector extensions which can
|
||||
be used to accelerate libyuv kernels.
|
||||
|
||||
### Neon extensions
|
||||
|
||||
Neon is available and mandatory in AArch64 from the base Armv8.0-A
|
||||
architecture. Neon can be used even if later extensions like the Scalable
|
||||
Vector Extension (SVE) are also present. The exception to this is if the CPU is
|
||||
currently operating in streaming mode as introduced by the Scalable Matrix
|
||||
Extension, described later.
|
||||
|
||||
There are also a couple of architecture extensions present for Neon that we can
|
||||
take advantage of in libyuv:
|
||||
|
||||
* The Neon DotProd extension is architecturally available from Armv8.1-A and
|
||||
becomes mandatory from Armv8.4-A. This extension provides instructions to
|
||||
perform a pairwise widening multiply of groups of four bytes from two source
|
||||
vectors, taking the sum of the four widened multiply results within each
|
||||
group to give a 32-bit result, accumulating into a destination vector.
|
||||
|
||||
* The Neon I8MM extension extends the DotProd extension with support for
|
||||
mixed-sign DotProds. The I8MM extension is architecturally available from
|
||||
Armv8.1-A and becomes mandatory from Armv8.6-A. It does not strictly depend
|
||||
on the DotProd extension being implemented, however at time of writing there
|
||||
is no known micro-architecture implementation where I8MM is implemented
|
||||
without the DotProd extension also being implemented.
|
||||
|
||||
### The Scalable Vector Extension (SVE)
|
||||
|
||||
The two Scalable Vector extensions (SVE and SVE2) provides equivalent
|
||||
functionality to most existing Neon instructions but with the ability to
|
||||
efficiently operate on vector registers with a run-time-determined vector
|
||||
length.
|
||||
|
||||
The original version of SVE is architecturally available from Armv8.2-A and is
|
||||
primarily targeted at HPC applications. This focus means it does not include
|
||||
most of the DSP-style operations that are necessary for most libyuv
|
||||
color-conversion kernels, though it can still be used for many scaling or
|
||||
rotation kernels.
|
||||
|
||||
SVE does not strictly depend on either of the Neon DotProd or I8MM extensions
|
||||
being implemented. The only micro-architecture at time of writing where SVE is
|
||||
implemented without these two extensions both also being implemented is the
|
||||
Fujitsu A64FX, which is not a CPU of interest for libyuv.
|
||||
|
||||
SVE2 extends the base SVE extension with the remaining instructions from Neon,
|
||||
porting these instructions to operate on scalable vectors. SVE2 is
|
||||
architecturally available from Armv9.0-A. If SVE2 is implemented then SVE must
|
||||
also be implemented. Since Armv9.0-A is based on Armv8.5-A this implies that
|
||||
the Neon DotProd extension is also implemented. Interestingly this means that
|
||||
the I8MM extension is not mandatory since it only becomes mandatory from
|
||||
Armv8.6-A or Armv9.1-A, however there is no micro-architecture at time of
|
||||
writing where SVE2 is implemented without all previously-mentioned features
|
||||
also being implemented.
|
||||
|
||||
### The Scalable Matrix Extension (SME)
|
||||
|
||||
The Scalable Matrix Extension (SME) is an optional feature introduced from
|
||||
Armv9.2-A. SME exists alongside SVE and introduces new execution modes for
|
||||
applications performing extended periods of data processing. In particular SME
|
||||
introduces a few new components of interest:
|
||||
|
||||
* Access to a scalable two-dimensional ZA tile register and new instructions to
|
||||
interact with rows and columns of the ZA tiles. This can be useful for data
|
||||
transformations like transposes.
|
||||
|
||||
* A streaming SVE (SSVE) mode, during which the SVE vector length matches the
|
||||
ZA tile register width. In typical systems where the ZA tile register width
|
||||
is longer than the core SVE vector length, SSVE processing allows for faster
|
||||
data processing, even if the ZA tile register is unused. While the CPU is
|
||||
executing in streaming mode, Neon instructions are unavailable.
|
||||
|
||||
* When both SSVE and the ZA tile registers are enabled there are additional
|
||||
outer-product instructions accumulating into a whole ZA tile, suitable for
|
||||
accelerating matrix arithmetic. This is likely less useful in libyuv.
|
||||
|
||||
## Linux and Android
|
||||
|
||||
On AArch64 running under Linux and Android, features are detected by inspecting
|
||||
the CPU auxiliary vector via `getauxval(AT_HWCAP)` and `getauxval(AT_HWCAP2)`,
|
||||
inspecting the returned bitmask.
|
||||
|
||||
## Windows
|
||||
|
||||
On Windows we detect features using the `IsProcessorFeaturePresent` interface
|
||||
and passing an enum parameter for the feature we want to check. More
|
||||
information on this can be found here:
|
||||
|
||||
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent#parameters
|
||||
|
||||
## Apple Silicon
|
||||
|
||||
On Apple Silicon we detect features using the `sysctlbyname` interface and
|
||||
passing a string representing the feature we want to detect. More information
|
||||
on this can be found here:
|
||||
|
||||
https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics
|
||||
+83
-17
@@ -4,7 +4,9 @@ Formats (FOURCC) supported by libyuv are detailed here.
|
||||
|
||||
# Core Formats
|
||||
|
||||
There are 2 core formats supported by libyuv - I420 and ARGB. All YUV formats can be converted to/from I420. All RGB formats can be converted to/from ARGB.
|
||||
There are 2 core formats supported by libyuv - I420 and ARGB.
|
||||
All YUV formats can be converted to/from I420.
|
||||
All RGB formats can be converted to/from ARGB.
|
||||
|
||||
Filtering functions such as scaling and planar functions work on I420 and/or ARGB.
|
||||
|
||||
@@ -36,26 +38,34 @@ This is how OSX formats map to libyuv
|
||||
|
||||
The following is extracted from video_common.h as a complete list of formats supported by libyuv.
|
||||
enum FourCC {
|
||||
// 9 Primary YUV formats: 5 planar, 2 biplanar, 2 packed.
|
||||
// 15 Primary YUV formats: 6 planar, 7 biplanar, 2 packed.
|
||||
FOURCC_I420 = FOURCC('I', '4', '2', '0'),
|
||||
FOURCC_I422 = FOURCC('I', '4', '2', '2'),
|
||||
FOURCC_I444 = FOURCC('I', '4', '4', '4'),
|
||||
FOURCC_I400 = FOURCC('I', '4', '0', '0'),
|
||||
FOURCC_NV21 = FOURCC('N', 'V', '2', '1'),
|
||||
FOURCC_NV12 = FOURCC('N', 'V', '1', '2'),
|
||||
FOURCC_NV16 = FOURCC('N', 'V', '1', '6'),
|
||||
FOURCC_NV24 = FOURCC('N', 'V', '2', '4'),
|
||||
FOURCC_P010 = FOURCC('P', '0', '1', '0'),
|
||||
FOURCC_P210 = FOURCC('P', '2', '1', '0'),
|
||||
FOURCC_P410 = FOURCC('P', '4', '1', '0'),
|
||||
FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'),
|
||||
FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'),
|
||||
FOURCC_H010 = FOURCC('H', '0', '1', '0'), // unofficial fourcc. 10 bit lsb
|
||||
FOURCC_I010 = FOURCC('I', '0', '1', '0'), // bt.601 10 bit 420
|
||||
FOURCC_I210 = FOURCC('I', '2', '1', '0'), // bt.601 10 bit 422
|
||||
|
||||
// 1 Secondary YUV format: row biplanar.
|
||||
FOURCC_M420 = FOURCC('M', '4', '2', '0'),
|
||||
FOURCC_M420 = FOURCC('M', '4', '2', '0'), // deprecated.
|
||||
|
||||
// 11 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp, 1 10 bpc
|
||||
// 13 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp, 1 10 bpc, 2 64 bpp
|
||||
FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'),
|
||||
FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'),
|
||||
FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'),
|
||||
FOURCC_AR30 = FOURCC('A', 'R', '3', '0'), // 10 bit per channel. 2101010.
|
||||
FOURCC_AB30 = FOURCC('A', 'B', '3', '0'), // ABGR version of 10 bit
|
||||
FOURCC_AR64 = FOURCC('A', 'R', '6', '4'), // 16 bit per channel.
|
||||
FOURCC_AB64 = FOURCC('A', 'B', '6', '4'), // ABGR version of 16 bit
|
||||
FOURCC_24BG = FOURCC('2', '4', 'B', 'G'),
|
||||
FOURCC_RAW = FOURCC('r', 'a', 'w', ' '),
|
||||
FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'),
|
||||
@@ -66,15 +76,34 @@ The following is extracted from video_common.h as a complete list of formats sup
|
||||
// 1 Primary Compressed YUV format.
|
||||
FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
|
||||
|
||||
// 8 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
|
||||
// 23 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
|
||||
FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
|
||||
FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
|
||||
FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
|
||||
FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'), // Linux version of I420.
|
||||
FOURCC_J420 = FOURCC('J', '4', '2', '0'),
|
||||
FOURCC_J400 = FOURCC('J', '4', '0', '0'), // unofficial fourcc
|
||||
FOURCC_H420 = FOURCC('H', '4', '2', '0'), // unofficial fourcc
|
||||
FOURCC_H422 = FOURCC('H', '4', '2', '2'), // unofficial fourcc
|
||||
FOURCC_J420 =
|
||||
FOURCC('J', '4', '2', '0'), // jpeg (bt.601 full), unofficial fourcc
|
||||
FOURCC_J422 =
|
||||
FOURCC('J', '4', '2', '2'), // jpeg (bt.601 full), unofficial fourcc
|
||||
FOURCC_J444 =
|
||||
FOURCC('J', '4', '4', '4'), // jpeg (bt.601 full), unofficial fourcc
|
||||
FOURCC_J400 =
|
||||
FOURCC('J', '4', '0', '0'), // jpeg (bt.601 full), unofficial fourcc
|
||||
FOURCC_F420 = FOURCC('F', '4', '2', '0'), // bt.709 full, unofficial fourcc
|
||||
FOURCC_F422 = FOURCC('F', '4', '2', '2'), // bt.709 full, unofficial fourcc
|
||||
FOURCC_F444 = FOURCC('F', '4', '4', '4'), // bt.709 full, unofficial fourcc
|
||||
FOURCC_H420 = FOURCC('H', '4', '2', '0'), // bt.709, unofficial fourcc
|
||||
FOURCC_H422 = FOURCC('H', '4', '2', '2'), // bt.709, unofficial fourcc
|
||||
FOURCC_H444 = FOURCC('H', '4', '4', '4'), // bt.709, unofficial fourcc
|
||||
FOURCC_U420 = FOURCC('U', '4', '2', '0'), // bt.2020, unofficial fourcc
|
||||
FOURCC_U422 = FOURCC('U', '4', '2', '2'), // bt.2020, unofficial fourcc
|
||||
FOURCC_U444 = FOURCC('U', '4', '4', '4'), // bt.2020, unofficial fourcc
|
||||
FOURCC_F010 = FOURCC('F', '0', '1', '0'), // bt.709 full range 10 bit 420
|
||||
FOURCC_H010 = FOURCC('H', '0', '1', '0'), // bt.709 10 bit 420
|
||||
FOURCC_U010 = FOURCC('U', '0', '1', '0'), // bt.2020 10 bit 420
|
||||
FOURCC_F210 = FOURCC('F', '2', '1', '0'), // bt.709 full range 10 bit 422
|
||||
FOURCC_H210 = FOURCC('H', '2', '1', '0'), // bt.709 10 bit 422
|
||||
FOURCC_U210 = FOURCC('U', '2', '1', '0'), // bt.2020 10 bit 422
|
||||
|
||||
// 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc.
|
||||
FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420.
|
||||
@@ -97,13 +126,35 @@ The following is extracted from video_common.h as a complete list of formats sup
|
||||
|
||||
# Planar YUV
|
||||
The following formats contains a full size Y plane followed by 1 or 2
|
||||
planes for UV: I420, I422, I444, I400, NV21, NV12, I400
|
||||
planes for UV: I420, I422, I444, I400, NV21, NV12, NV16, NV24,
|
||||
P010, P210, P410
|
||||
The size (subsampling) of the UV varies.
|
||||
I420, NV12 and NV21 are half width, half height
|
||||
I422, NV16 and NV61 are half width, full height
|
||||
I444, NV24 and NV42 are full width, full height
|
||||
I420, NV12, NV21 and P010 are half width, half height
|
||||
I422, NV16, NV61 and P210 are half width, full height
|
||||
I444, NV24, NV42 and P410 are full width, full height
|
||||
I400 and J400 have no chroma channel.
|
||||
|
||||
# Color space
|
||||
The YUV formats start with a letter to specify the color space. e.g. I420
|
||||
I = BT.601 limited range
|
||||
J = BT.601 full range (J = JPEG that uses this)
|
||||
H = BT.709 limited range (H for HD)
|
||||
F = BT.709 full range (F for Full range)
|
||||
U = BT.2020 limited range (U for UHD)
|
||||
V = BT.2020 full range
|
||||
For YUV to RGB conversions, a matrix can be passed. See also convert_argh.h
|
||||
|
||||
# HDR formats
|
||||
Planar formats with 10 or 12 bits use the following fourcc:
|
||||
I010, I012, P010, P012 are half width, half height
|
||||
I210, I212, P210, P212 are half width, full height
|
||||
I410, I412, P410, P412 are full width, full height
|
||||
where
|
||||
I is the color space (see above) and 3 planes: Y, U and V.
|
||||
P is a biplanar format, similar to NV12 but 16 bits, with the valid bits in the high bits. There is a Y plane and a UV plane.
|
||||
0, 2 or 4 is the last digit of subsampling: 4:2:0, 4:2:2, or 4:4:4
|
||||
10 or 12 is the bits per channel. The bits are in the low bits of a 16 bit channel.
|
||||
|
||||
# The ARGB FOURCC
|
||||
|
||||
There are 4 ARGB layouts - ARGB, BGRA, ABGR and RGBA. ARGB is most common by far, used for screen formats, and windows webcam drivers.
|
||||
@@ -114,13 +165,13 @@ A fourcc provided by capturer, can be thought of string, e.g. "ARGB".
|
||||
|
||||
On little endian machines, as an int, this would have 'A' in the lowest byte. The FOURCC macro reverses the order:
|
||||
|
||||
#define FOURCC(a, b, c, d) (((uint32)(a)) | ((uint32)(b) << 8) | ((uint32)(c) << 16) | ((uint32)(d) << 24))
|
||||
#define FOURCC(a, b, c, d) (((uint32_t)(a)) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
|
||||
|
||||
So the "ARGB" string, read as an uint32, is
|
||||
So the "ARGB" string, read as an uint32_t, is
|
||||
|
||||
FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B')
|
||||
|
||||
If you were to read ARGB pixels as uint32's, the alpha would be in the high byte, and the blue in the lowest byte. In memory, these are stored little endian, so 'B' is first, then 'G', 'R' and 'A' last.
|
||||
If you were to read ARGB pixels as uint32_t's, the alpha would be in the high byte, and the blue in the lowest byte. In memory, these are stored little endian, so 'B' is first, then 'G', 'R' and 'A' last.
|
||||
|
||||
When calling conversion functions, the names match the FOURCC, so in this case it would be I420ToARGB().
|
||||
|
||||
@@ -152,6 +203,13 @@ The 2 bit alpha has 4 values. Here are the comparable 8 bit alpha values.
|
||||
The 10 bit RGB values range from 0 to 1023.
|
||||
XR30 is the same as AR30 but with no alpha channel.
|
||||
|
||||
# AB64 and AR64
|
||||
|
||||
AB64 is similar to ABGR, with 16 bit (2 bytes) per channel. Each channel stores an unsigned short.
|
||||
In memory R is the lowest and A is the highest.
|
||||
Each channel has value ranges from 0 to 65535.
|
||||
AR64 is similar to ARGB.
|
||||
|
||||
# NV12 and NV21
|
||||
|
||||
NV12 is a biplanar format with a full sized Y plane followed by a single
|
||||
@@ -161,3 +219,11 @@ The 12 in NV12 refers to 12 bits per pixel. NV12 has a half width and half
|
||||
height chroma channel, and therefore is a 420 subsampling.
|
||||
NV16 is 16 bits per pixel, with half width and full height. aka 422.
|
||||
NV24 is 24 bits per pixel with full sized chroma channel. aka 444.
|
||||
Most NV12 functions allow the destination Y pointer to be NULL.
|
||||
|
||||
# YUY2 and UYVY
|
||||
|
||||
YUY2 is a packed YUV format with half width, full height.
|
||||
|
||||
YUY2 is YUYV in memory
|
||||
UYVY is UYVY in memory
|
||||
@@ -11,21 +11,7 @@ Refer to chromium instructions for each platform for other prerequisites.
|
||||
|
||||
Create a working directory, enter it, and run:
|
||||
|
||||
gclient config --name src https://chromium.googlesource.com/libyuv/libyuv
|
||||
gclient sync
|
||||
|
||||
Then you'll get a .gclient file like:
|
||||
|
||||
solutions = [
|
||||
{ "name" : "src",
|
||||
"url" : "https://chromium.googlesource.com/libyuv/libyuv",
|
||||
"deps_file" : "DEPS",
|
||||
"managed" : True,
|
||||
"custom_deps" : {
|
||||
},
|
||||
"safesync_url": "",
|
||||
},
|
||||
];
|
||||
fetch libyuv
|
||||
|
||||
For iOS add `;target_os=['ios'];` to your OSX .gclient and run `gclient sync.`
|
||||
|
||||
@@ -57,15 +43,47 @@ To get just the source (not buildable):
|
||||
|
||||
## Building the Library and Unittests
|
||||
|
||||
### Bazel
|
||||
|
||||
Libyuv can be built using [Bazel](https://bazel.build/).
|
||||
|
||||
#### Android Prerequisites
|
||||
To build for Android using Bazel, you must have the Android SDK and NDK installed. Bazel will look for the following environment variables to locate them:
|
||||
* `ANDROID_HOME`: Set this to the path of your Android SDK.
|
||||
* `ANDROID_NDK_HOME`: Set this to the path of your Android NDK.
|
||||
|
||||
Ensure these variables are set before running the Bazel Android build commands.
|
||||
|
||||
**Android arm64:**
|
||||
|
||||
bazel build -c opt --config=android_arm64 //:libyuv_test
|
||||
|
||||
# Or, specifying standard open-source flags (if NDK is set up in workspace):
|
||||
bazel build -c opt --cpu=arm64-v8a --crosstool_top=//external:android/crosstool //:libyuv_test
|
||||
|
||||
**Linux x86_64:**
|
||||
|
||||
bazel build -c opt //:libyuv_test
|
||||
|
||||
# Or, specifying a specific CPU architecture:
|
||||
bazel build -c opt --cpu=haswell //:libyuv_test
|
||||
|
||||
Additional commonly used compiler options can be passed to Bazel via `--copt`:
|
||||
|
||||
bazel build -c opt --config=android_arm64 \
|
||||
--copt=-DLIBYUV_UNLIMITED_DATA \
|
||||
--copt=-DENABLE_ROW_TESTS \
|
||||
//:libyuv_test
|
||||
|
||||
### Windows
|
||||
|
||||
call gn gen out\Release "--args=is_debug=false target_cpu=\"x64\""
|
||||
call gn gen out\Debug "--args=is_debug=true target_cpu=\"x64\""
|
||||
gn gen out\Release "--args=is_debug=false target_cpu=\"x64\""
|
||||
gn gen out\Debug "--args=is_debug=true target_cpu=\"x64\""
|
||||
ninja -v -C out\Release
|
||||
ninja -v -C out\Debug
|
||||
|
||||
call gn gen out\Release "--args=is_debug=false target_cpu=\"x86\""
|
||||
call gn gen out\Debug "--args=is_debug=true target_cpu=\"x86\""
|
||||
gn gen out\Release "--args=is_debug=false target_cpu=\"x86\""
|
||||
gn gen out\Debug "--args=is_debug=true target_cpu=\"x86\""
|
||||
ninja -v -C out\Release
|
||||
ninja -v -C out\Debug
|
||||
|
||||
@@ -130,20 +148,13 @@ ia32
|
||||
ninja -v -C out/Debug libyuv_unittest
|
||||
ninja -v -C out/Release libyuv_unittest
|
||||
|
||||
mips
|
||||
|
||||
gn gen out/Release "--args=is_debug=false target_os=\"android\" target_cpu=\"mips64el\" mips_arch_variant=\"r6\" mips_use_msa=true is_component_build=true"
|
||||
gn gen out/Debug "--args=is_debug=true target_os=\"android\" target_cpu=\"mips64el\" mips_arch_variant=\"r6\" mips_use_msa=true is_component_build=true"
|
||||
ninja -v -C out/Debug libyuv_unittest
|
||||
ninja -v -C out/Release libyuv_unittest
|
||||
|
||||
arm disassembly:
|
||||
|
||||
third_party/android_ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -d ./out/Release/obj/libyuv/row_common.o >row_common.txt
|
||||
llvm-objdump -d ./out/Release/obj/libyuv/row_common.o >row_common.txt
|
||||
|
||||
third_party/android_ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -d ./out/Release/obj/libyuv_neon/row_neon.o >row_neon.txt
|
||||
llvm-objdump -d ./out/Release/obj/libyuv_neon/row_neon.o >row_neon.txt
|
||||
|
||||
third_party/android_ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objdump -d ./out/Release/obj/libyuv_neon/row_neon64.o >row_neon64.txt
|
||||
llvm-objdump -d ./out/Release/obj/libyuv_neon/row_neon64.o >row_neon64.txt
|
||||
|
||||
Caveat: Disassembly may require optimize_max be disabled in BUILD.gn
|
||||
|
||||
@@ -165,6 +176,7 @@ Running test with C code:
|
||||
ninja -C out/Debug libyuv_unittest
|
||||
ninja -C out/Debug compare
|
||||
ninja -C out/Debug yuvconvert
|
||||
ninja -C out/Debug yuvconstants
|
||||
ninja -C out/Debug psnr
|
||||
ninja -C out/Debug cpuid
|
||||
|
||||
@@ -175,22 +187,13 @@ Running test with C code:
|
||||
ninja -v -C out/Debug libyuv_unittest
|
||||
ninja -v -C out/Release libyuv_unittest
|
||||
|
||||
### MIPS Linux
|
||||
|
||||
mips
|
||||
|
||||
gn gen out/Release "--args=is_debug=false target_os=\"linux\" target_cpu=\"mips64el\" mips_arch_variant=\"loongson3\" mips_use_mmi=true is_component_build=false use_sysroot=false use_gold=false"
|
||||
gn gen out/Debug "--args=is_debug=true target_os=\"linux\" target_cpu=\"mips64el\" mips_arch_variant=\"loongson3\" mips_use_mmi=true is_component_build=false use_sysroot=false use_gold=false"
|
||||
ninja -v -C out/Debug libyuv_unittest
|
||||
ninja -v -C out/Release libyuv_unittest
|
||||
|
||||
## Building the Library with make
|
||||
|
||||
### Linux
|
||||
|
||||
make V=1 -f linux.mk
|
||||
make V=1 -f linux.mk clean
|
||||
make V=1 -f linux.mk CXX=clang++
|
||||
make V=1 -f linux.mk CXX=clang++ CC=clang
|
||||
|
||||
## Building the library with cmake
|
||||
|
||||
@@ -219,6 +222,88 @@ Install cmake: http://www.cmake.org/
|
||||
make -j4
|
||||
make package
|
||||
|
||||
## Building RISC-V target with cmake
|
||||
|
||||
### Native build on RISC-V SBC (e.g. SpacemiT K1/K3)
|
||||
|
||||
On a 64-bit RISC-V system, CMake automatically detects `riscv64` and enables
|
||||
RVV with `-march=rv64gcv`:
|
||||
|
||||
cmake -B out/Release -DCMAKE_BUILD_TYPE=Release -DUNIT_TEST=ON
|
||||
cmake --build out/Release
|
||||
|
||||
To build for 32-bit RISC-V targets:
|
||||
|
||||
cmake -B out/Release -DCMAKE_BUILD_TYPE=Release -DRISCV_COMPILER_FLAGS="-march=rv32gcv"
|
||||
cmake --build out/Release
|
||||
|
||||
#### Customized Compiler Flags
|
||||
|
||||
Customized compiler flags can be passed with `-DRISCV_COMPILER_FLAGS="xxx"`.
|
||||
When assigned, the specified flags are used instead of the default `-march=rv64gcv`:
|
||||
|
||||
Targeting SiFive X280:
|
||||
|
||||
cmake -B out/Release -DUNIT_TEST=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DRISCV_COMPILER_FLAGS="-mcpu=sifive-x280"
|
||||
|
||||
Targeting Coral (32-bit without floating point, Zve32x):
|
||||
|
||||
cmake -B out/Release -DUNIT_TEST=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DRISCV_COMPILER_FLAGS="-march=rv32imac_zve32x"
|
||||
|
||||
To disable RVV:
|
||||
|
||||
cmake -B out/Release -DCMAKE_BUILD_TYPE=Release -DUSE_RVV=OFF
|
||||
|
||||
### Building RISC-V with Bazel and Blaze
|
||||
|
||||
To build with Bazel for 64-bit or 32-bit RISC-V targets:
|
||||
|
||||
bazel test --platforms=@platforms//cpu:riscv64 //...
|
||||
bazel test --platforms=@platforms//cpu:riscv32 //...
|
||||
|
||||
For custom targets such as SiFive X280 or Coral:
|
||||
|
||||
bazel test --platforms=@platforms//cpu:riscv64 --copt=-mcpu=sifive-x280 //...
|
||||
bazel test --platforms=@platforms//cpu:riscv32 --copt=-march=rv32imac_zve32x //...
|
||||
|
||||
In google3 using Blaze:
|
||||
|
||||
blaze test --config=mpu64 //third_party/libyuv:libyuv_test
|
||||
blaze run --config=mpu64 //third_party/libyuv:cpuid
|
||||
blaze run --config=mpu64 //third_party/libyuv:yuvconvert
|
||||
|
||||
### Cross-compile for RISC-V target using QEMU
|
||||
|
||||
#### Prerequisite: build risc-v clang toolchain and qemu
|
||||
|
||||
If you don't have prebuilt clang and riscv64 qemu, run the script to download source and build them.
|
||||
|
||||
./riscv_script/prepare_toolchain_qemu.sh
|
||||
|
||||
After running script, clang & qemu are built in `build-toolchain-qemu/riscv-clang/` & `build-toolchain-qemu/riscv-qemu/`.
|
||||
|
||||
#### Cross-compile for RISC-V target
|
||||
cmake -B out/Release/ -DUNIT_TEST=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_TOOLCHAIN_FILE="./riscv_script/riscv-clang.cmake" \
|
||||
-DTOOLCHAIN_PATH={TOOLCHAIN_PATH} \
|
||||
-DUSE_RVV=ON .
|
||||
cmake --build out/Release/
|
||||
|
||||
### Run on QEMU
|
||||
|
||||
#### Run libyuv_unittest on QEMU
|
||||
cd out/Release/
|
||||
USE_RVV=ON \
|
||||
TOOLCHAIN_PATH={TOOLCHAIN_PATH} \
|
||||
QEMU_PREFIX_PATH={QEMU_PREFIX_PATH} \
|
||||
../../riscv_script/run_qemu.sh libyuv_unittest
|
||||
|
||||
|
||||
## Setup for Arm Cross compile
|
||||
|
||||
See also https://www.ccoderun.ca/programming/2015-12-20_CrossCompiling/index.html
|
||||
@@ -239,6 +324,20 @@ See also https://www.ccoderun.ca/programming/2015-12-20_CrossCompiling/index.htm
|
||||
|
||||
## Running Unittests
|
||||
|
||||
### Bazel
|
||||
|
||||
You can run the tests using Bazel's `test` command. This will build and run the test in an isolated environment:
|
||||
|
||||
bazel test -c opt //:libyuv_test
|
||||
|
||||
To pass specific arguments to the test binary (like a gtest filter), use `--test_arg`:
|
||||
|
||||
bazel test -c opt //:libyuv_test --test_arg=--gtest_filter="*" --test_output=all
|
||||
|
||||
Alternatively, you can run the compiled binary directly from the `bazel-bin` directory:
|
||||
|
||||
./bazel-bin/libyuv_test --gtest_filter="*"
|
||||
|
||||
### Windows
|
||||
|
||||
out\Release\libyuv_unittest.exe --gtest_catch_exceptions=0 --gtest_filter="*"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
#!/usr/bin/env vpython3
|
||||
|
||||
# Copyright 2014 The LibYuv Project Authors. All rights reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
@@ -22,8 +22,8 @@ sys.path.insert(0, os.path.join(checkout_root, 'build'))
|
||||
sys.path.insert(0, os.path.join(checkout_root, 'tools', 'find_depot_tools'))
|
||||
|
||||
|
||||
import vs_toolchain
|
||||
import vs_toolchain # pylint: disable=wrong-import-position
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(vs_toolchain.main())
|
||||
sys.exit(vs_toolchain.main())
|
||||
@@ -25,7 +25,8 @@
|
||||
#include "libyuv/row.h"
|
||||
#include "libyuv/scale.h"
|
||||
#include "libyuv/scale_argb.h"
|
||||
#include "libyuv/scale_row.h"
|
||||
#include "libyuv/scale_rgb.h"
|
||||
#include "libyuv/scale_uv.h"
|
||||
#include "libyuv/version.h"
|
||||
#include "libyuv/video_common.h"
|
||||
|
||||
|
||||
@@ -11,37 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_
|
||||
#define INCLUDE_LIBYUV_BASIC_TYPES_H_
|
||||
|
||||
#include <stddef.h> // For size_t and NULL
|
||||
|
||||
#if !defined(INT_TYPES_DEFINED) && !defined(GG_LONGLONG)
|
||||
#define INT_TYPES_DEFINED
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
#include <sys/types.h> // for uintptr_t on x86
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed char int8_t;
|
||||
#else
|
||||
#include <stdint.h> // for uintptr_t and C99 types
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||
// Types are deprecated. Enable this macro for legacy types.
|
||||
#ifdef LIBYUV_LEGACY_TYPES
|
||||
typedef uint64_t uint64;
|
||||
typedef int64_t int64;
|
||||
typedef uint32_t uint32;
|
||||
typedef int32_t int32;
|
||||
typedef uint16_t uint16;
|
||||
typedef int16_t int16;
|
||||
typedef uint8_t uint8;
|
||||
typedef int8_t int8;
|
||||
#endif // LIBYUV_LEGACY_TYPES
|
||||
#endif // INT_TYPES_DEFINED
|
||||
|
||||
#if !defined(LIBYUV_API)
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#if defined(LIBYUV_BUILDING_SHARED_LIBRARY)
|
||||
@@ -60,9 +29,4 @@ typedef int8_t int8;
|
||||
#endif // __GNUC__
|
||||
#endif // LIBYUV_API
|
||||
|
||||
// TODO(fbarchard): Remove bool macros.
|
||||
#define LIBYUV_BOOL int
|
||||
#define LIBYUV_FALSE 0
|
||||
#define LIBYUV_TRUE 1
|
||||
|
||||
#endif // INCLUDE_LIBYUV_BASIC_TYPES_H_
|
||||
@@ -11,6 +11,9 @@
|
||||
#ifndef INCLUDE_LIBYUV_COMPARE_H_
|
||||
#define INCLUDE_LIBYUV_COMPARE_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -11,82 +11,164 @@
|
||||
#ifndef INCLUDE_LIBYUV_COMPARE_ROW_H_
|
||||
#define INCLUDE_LIBYUV_COMPARE_ROW_H_
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/cpu_support.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__pnacl__) || defined(__CLR_VER) || \
|
||||
(defined(__native_client__) && defined(__x86_64__)) || \
|
||||
(defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
|
||||
#define LIBYUV_DISABLE_X86
|
||||
#endif
|
||||
#if defined(__native_client__)
|
||||
#define LIBYUV_DISABLE_NEON
|
||||
#endif
|
||||
// MemorySanitizer does not support assembly code yet. http://crbug.com/344505
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
#define LIBYUV_DISABLE_X86
|
||||
#endif
|
||||
#endif
|
||||
// Visual C 2012 required for AVX2.
|
||||
#if defined(_M_IX86) && !defined(__clang__) && defined(_MSC_VER) && \
|
||||
_MSC_VER >= 1700
|
||||
#define VISUALC_HAS_AVX2 1
|
||||
#endif // VisualStudio >= 2012
|
||||
|
||||
// clang >= 3.4.0 required for AVX2.
|
||||
#if defined(__clang__) && (defined(__x86_64__) || defined(__i386__))
|
||||
#if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4))
|
||||
#define CLANG_HAS_AVX2 1
|
||||
#endif // clang >= 3.4
|
||||
#endif // __clang__
|
||||
|
||||
// The following are available for Visual C and GCC:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && \
|
||||
(defined(__x86_64__) || defined(__i386__) || defined(_M_IX86))
|
||||
#define HAS_HASHDJB2_SSE41
|
||||
// The following are available for Visual C 32/64 bit, and for clang with
|
||||
// LIBYUV_ENABLE_ROWWIN, which is also enabled for MemorySanitizer. These are
|
||||
// intrinsics in compare_win.cc.
|
||||
#if !defined(LIBYUV_DISABLE_X86) && \
|
||||
(defined(__x86_64__) || defined(__i386__) || defined(_M_X64) || \
|
||||
defined(_M_IX86)) && \
|
||||
((defined(_MSC_VER) && !defined(__clang__)) || \
|
||||
defined(LIBYUV_ENABLE_ROWWIN))
|
||||
#define HAS_HAMMINGDISTANCE_SSE42
|
||||
#define HAS_SUMSQUAREERROR_SSE2
|
||||
#define HAS_HASHDJB2_SSE41
|
||||
#define HAS_SSIM4X4ROW_SSE2
|
||||
#define HAS_SSIMWINDOWROW_SSE2
|
||||
#if defined(VISUALC_HAS_AVX2)
|
||||
#define HAS_HAMMINGDISTANCE_AVX2
|
||||
#define HAS_SUMSQUAREERROR_AVX2
|
||||
#define HAS_HASHDJB2_AVX2
|
||||
#define HAS_SSIM4X4ROW_AVX2
|
||||
#define HAS_SSIMWINDOWROW_AVX2
|
||||
#define HAS_ARGBDETECTROW_AVX2
|
||||
#endif
|
||||
#if defined(VISUALC_HAS_AVX512)
|
||||
#define HAS_HAMMINGDISTANCE_AVX512BW
|
||||
#define HAS_HAMMINGDISTANCE_AVX512VNNI
|
||||
#define HAS_SUMSQUAREERROR_AVX512BW
|
||||
#define HAS_SUMSQUAREERROR_AVX512VNNI
|
||||
#define HAS_HASHDJB2_AVX512BW
|
||||
#define HAS_SSIM4X4ROW_AVX512BW
|
||||
#define HAS_SSIMWINDOWROW_AVX512BW
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// The following are available for 32/64 bit GCC and clang, as inline assembly
|
||||
// in compare_gcc.cc:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && \
|
||||
(defined(__x86_64__) || defined(__i386__)) && \
|
||||
!defined(LIBYUV_ENABLE_ROWWIN) && \
|
||||
(!defined(_MSC_VER) || defined(__clang__))
|
||||
#if defined(__x86_64__)
|
||||
#define HAS_HAMMINGDISTANCE_SSE42
|
||||
#endif
|
||||
|
||||
// The following are available for Visual C and clangcl 32 bit:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER) && \
|
||||
(defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
|
||||
#define HAS_HASHDJB2_AVX2
|
||||
#define HAS_SUMSQUAREERROR_AVX2
|
||||
#endif
|
||||
|
||||
// The following are available for GCC and clangcl 64 bit:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && \
|
||||
(defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER)))
|
||||
#define HAS_HAMMINGDISTANCE_SSSE3
|
||||
#endif
|
||||
|
||||
// The following are available for GCC and clangcl 64 bit:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && defined(CLANG_HAS_AVX2) && \
|
||||
(defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER)))
|
||||
#define HAS_SUMSQUAREERROR_SSE2
|
||||
#define HAS_HASHDJB2_SSE41
|
||||
#define HAS_SSIM4X4ROW_SSE2
|
||||
#define HAS_SSIMWINDOWROW_SSE2
|
||||
#if defined(CLANG_HAS_AVX2) || defined(GCC_HAS_AVX2)
|
||||
#define HAS_HAMMINGDISTANCE_AVX2
|
||||
#define HAS_SUMSQUAREERROR_AVX2
|
||||
#define HAS_HASHDJB2_AVX2
|
||||
#define HAS_SSIM4X4ROW_AVX2
|
||||
#define HAS_SSIMWINDOWROW_AVX2
|
||||
#define HAS_ARGBDETECTROW_AVX2
|
||||
#endif
|
||||
#if defined(__x86_64__) && \
|
||||
(defined(CLANG_HAS_AVX512) || defined(GCC_HAS_AVX512))
|
||||
#define HAS_HAMMINGDISTANCE_AVX512BW
|
||||
#define HAS_HAMMINGDISTANCE_AVX512VNNI
|
||||
#define HAS_SUMSQUAREERROR_AVX512BW
|
||||
#define HAS_SUMSQUAREERROR_AVX512VNNI
|
||||
#define HAS_HASHDJB2_AVX512BW
|
||||
#define HAS_SSIM4X4ROW_AVX512BW
|
||||
#define HAS_SSIMWINDOWROW_AVX512BW
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// The following are available for Neon:
|
||||
#if !defined(LIBYUV_DISABLE_NEON) && \
|
||||
(defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__))
|
||||
#define HAS_SUMSQUAREERROR_NEON
|
||||
#define HAS_HAMMINGDISTANCE_NEON
|
||||
#define HAS_SUMSQUAREERROR_NEON
|
||||
#define HAS_HASHDJB2_NEON
|
||||
#define HAS_SSIM4X4ROW_NEON
|
||||
#define HAS_SSIMWINDOWROW_NEON
|
||||
#define HAS_ARGBDETECTROW_NEON
|
||||
#endif
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
|
||||
#define HAS_HAMMINGDISTANCE_MSA
|
||||
#define HAS_SUMSQUAREERROR_MSA
|
||||
// The following are available for AArch64 Neon:
|
||||
#if !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
|
||||
#define HAS_HAMMINGDISTANCE_NEON_DOTPROD
|
||||
#define HAS_SUMSQUAREERROR_NEON_DOTPROD
|
||||
#define HAS_SSIM4X4ROW_NEON_DOTPROD
|
||||
#endif
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A)
|
||||
#define HAS_HAMMINGDISTANCE_MMI
|
||||
#define HAS_SUMSQUAREERROR_MMI
|
||||
// The following are available for AArch64 SVE:
|
||||
#if !defined(LIBYUV_DISABLE_SVE) && defined(__aarch64__)
|
||||
#define HAS_SSIM4X4ROW_SVE2
|
||||
#define HAS_SSIMWINDOWROW_SVE2
|
||||
#endif
|
||||
|
||||
// The following are available for AArch64 SME:
|
||||
#if !defined(LIBYUV_DISABLE_SME) && defined(CLANG_HAS_SME) && \
|
||||
defined(__aarch64__)
|
||||
#define HAS_SSIM4X4ROW_SME
|
||||
#define HAS_SSIMWINDOWROW_SME
|
||||
#endif
|
||||
|
||||
// The following are available for RISC-V Vector (RVV):
|
||||
#if !defined(LIBYUV_DISABLE_RVV) && \
|
||||
(defined(__riscv_vector) || defined(LIBYUV_RVV))
|
||||
#define HAS_HAMMINGDISTANCE_RVV
|
||||
#define HAS_SUMSQUAREERROR_RVV
|
||||
#define HAS_HASHDJB2_RVV
|
||||
#define HAS_SSIM4X4ROW_RVV
|
||||
#if defined(__riscv_f) || defined(__riscv_zve32f)
|
||||
#define HAS_SSIMWINDOWROW_RVV
|
||||
#endif
|
||||
#define HAS_ARGBDETECTROW_RVV
|
||||
#endif
|
||||
|
||||
// The following are available for LoongArch LSX:
|
||||
#if !defined(LIBYUV_DISABLE_LSX) && defined(__loongarch_sx)
|
||||
#define HAS_HAMMINGDISTANCE_LSX
|
||||
#define HAS_SUMSQUAREERROR_LSX
|
||||
#define HAS_HASHDJB2_LSX
|
||||
#define HAS_SSIM4X4ROW_LSX
|
||||
#define HAS_SSIMWINDOWROW_LSX
|
||||
#define HAS_ARGBDETECTROW_LSX
|
||||
#endif
|
||||
|
||||
// The following are available for LoongArch LASX:
|
||||
#if !defined(LIBYUV_DISABLE_LASX) && defined(__loongarch_asx)
|
||||
#define HAS_HAMMINGDISTANCE_LASX
|
||||
#define HAS_SUMSQUAREERROR_LASX
|
||||
#define HAS_HASHDJB2_LASX
|
||||
#define HAS_SSIM4X4ROW_LASX
|
||||
#define HAS_SSIMWINDOWROW_LASX
|
||||
#define HAS_ARGBDETECTROW_LASX
|
||||
#endif
|
||||
|
||||
// The following are available for WebAssembly SIMD128:
|
||||
#if !defined(LIBYUV_DISABLE_WASM) && defined(__wasm_simd128__)
|
||||
#define HAS_HAMMINGDISTANCE_WASMSIMD
|
||||
#define HAS_SUMSQUAREERROR_WASMSIMD
|
||||
#define HAS_HASHDJB2_WASMSIMD
|
||||
#define HAS_SSIM4X4ROW_WASMSIMD
|
||||
#define HAS_SSIMWINDOWROW_WASMSIMD
|
||||
#define HAS_ARGBDETECTROW_WASMSIMD
|
||||
#endif
|
||||
|
||||
// The following are available for Hexagon HVX:
|
||||
#if !defined(LIBYUV_DISABLE_HVX) && defined(__HVX__)
|
||||
#define HAS_HAMMINGDISTANCE_HVX
|
||||
#define HAS_SUMSQUAREERROR_HVX
|
||||
#define HAS_HASHDJB2_HVX
|
||||
#define HAS_SSIM4X4ROW_HVX
|
||||
#define HAS_SSIMWINDOWROW_HVX
|
||||
#define HAS_ARGBDETECTROW_HVX
|
||||
#endif
|
||||
|
||||
uint32_t HammingDistance_C(const uint8_t* src_a,
|
||||
@@ -101,13 +183,31 @@ uint32_t HammingDistance_SSSE3(const uint8_t* src_a,
|
||||
uint32_t HammingDistance_AVX2(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t HammingDistance_AVX512BW(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t HammingDistance_AVX512VNNI(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t HammingDistance_NEON(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t HammingDistance_MSA(const uint8_t* src_a,
|
||||
uint32_t HammingDistance_NEON_DotProd(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t HammingDistance_RVV(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t HammingDistance_MMI(const uint8_t* src_a,
|
||||
uint32_t HammingDistance_LSX(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t HammingDistance_LASX(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t HammingDistance_WASMSIMD(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t HammingDistance_HVX(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t SumSquareError_C(const uint8_t* src_a,
|
||||
@@ -119,19 +219,168 @@ uint32_t SumSquareError_SSE2(const uint8_t* src_a,
|
||||
uint32_t SumSquareError_AVX2(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t SumSquareError_AVX512BW(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t SumSquareError_AVX512VNNI(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t SumSquareError_NEON(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t SumSquareError_MSA(const uint8_t* src_a,
|
||||
uint32_t SumSquareError_NEON_DotProd(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t SumSquareError_RVV(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t SumSquareError_MMI(const uint8_t* src_a,
|
||||
uint32_t SumSquareError_LSX(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t SumSquareError_LASX(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t SumSquareError_WASMSIMD(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
uint32_t SumSquareError_HVX(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count);
|
||||
|
||||
uint32_t HashDjb2_C(const uint8_t* src, int count, uint32_t seed);
|
||||
uint32_t HashDjb2_SSE41(const uint8_t* src, int count, uint32_t seed);
|
||||
uint32_t HashDjb2_AVX2(const uint8_t* src, int count, uint32_t seed);
|
||||
uint32_t HashDjb2_AVX512BW(const uint8_t* src, int count, uint32_t seed);
|
||||
uint32_t HashDjb2_NEON(const uint8_t* src, int count, uint32_t seed);
|
||||
uint32_t HashDjb2_RVV(const uint8_t* src, int count, uint32_t seed);
|
||||
uint32_t HashDjb2_LSX(const uint8_t* src, int count, uint32_t seed);
|
||||
uint32_t HashDjb2_LASX(const uint8_t* src, int count, uint32_t seed);
|
||||
uint32_t HashDjb2_WASMSIMD(const uint8_t* src, int count, uint32_t seed);
|
||||
uint32_t HashDjb2_HVX(const uint8_t* src, int count, uint32_t seed);
|
||||
|
||||
void Ssim4x4Row_C(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_SSE2(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_AVX2(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_AVX512BW(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_NEON(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_NEON_DotProd(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_SVE2(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_SME(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_RVV(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_LSX(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_LASX(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_WASMSIMD(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
void Ssim4x4Row_HVX(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width);
|
||||
float SsimWindowRow_C(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_SSE2(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_AVX2(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_AVX512BW(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_NEON(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_SVE2(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_SME(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_RVV(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_LSX(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_LASX(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_WASMSIMD(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
float SsimWindowRow_HVX(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows);
|
||||
|
||||
uint32_t ARGBDetectRow_C(const uint8_t* argb, int width);
|
||||
uint32_t ARGBDetectRow_AVX2(const uint8_t* argb, int width);
|
||||
uint32_t ARGBDetectRow_NEON(const uint8_t* argb, int width);
|
||||
uint32_t ARGBDetectRow_RVV(const uint8_t* argb, int width);
|
||||
uint32_t ARGBDetectRow_LSX(const uint8_t* argb, int width);
|
||||
uint32_t ARGBDetectRow_LASX(const uint8_t* argb, int width);
|
||||
uint32_t ARGBDetectRow_WASMSIMD(const uint8_t* argb, int width);
|
||||
uint32_t ARGBDetectRow_HVX(const uint8_t* argb, int width);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#ifndef INCLUDE_LIBYUV_CONVERT_H_
|
||||
#define INCLUDE_LIBYUV_CONVERT_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#include "libyuv/rotate.h" // For enum RotationMode.
|
||||
@@ -25,6 +28,8 @@ namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ArgbConstants;
|
||||
|
||||
// Convert I444 to I420.
|
||||
LIBYUV_API
|
||||
int I444ToI420(const uint8_t* src_y,
|
||||
@@ -42,6 +47,21 @@ int I444ToI420(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I444 to NV12.
|
||||
LIBYUV_API
|
||||
int I444ToNV12(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I444 to NV21.
|
||||
LIBYUV_API
|
||||
int I444ToNV21(const uint8_t* src_y,
|
||||
@@ -74,6 +94,95 @@ int I422ToI420(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I422 to I444.
|
||||
LIBYUV_API
|
||||
int I422ToI444(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I422 to I210.
|
||||
LIBYUV_API
|
||||
int I422ToI210(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert MM21 to NV12.
|
||||
LIBYUV_API
|
||||
int MM21ToNV12(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert MM21 to I420.
|
||||
LIBYUV_API
|
||||
int MM21ToI420(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert MM21 to YUY2
|
||||
LIBYUV_API
|
||||
int MM21ToYUY2(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_yuy2,
|
||||
int dst_stride_yuy2,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert MT2T to P010
|
||||
// Note that src_y and src_uv point to packed 10-bit values, so the Y plane will
|
||||
// be 10 / 8 times the dimensions of the image. Also for this reason,
|
||||
// src_stride_y and src_stride_uv are given in bytes.
|
||||
LIBYUV_API
|
||||
int MT2TToP010(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I422 to NV21.
|
||||
LIBYUV_API
|
||||
int I422ToNV21(const uint8_t* src_y,
|
||||
@@ -107,6 +216,23 @@ int I420Copy(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I420 to I444.
|
||||
LIBYUV_API
|
||||
int I420ToI444(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Copy I010 to I010
|
||||
#define I010ToI010 I010Copy
|
||||
#define H010ToH010 I010Copy
|
||||
@@ -144,6 +270,356 @@ int I010ToI420(const uint16_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define H210ToH420 I210ToI420
|
||||
LIBYUV_API
|
||||
int I210ToI420(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define H210ToH422 I210ToI422
|
||||
LIBYUV_API
|
||||
int I210ToI422(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define H410ToH420 I410ToI420
|
||||
LIBYUV_API
|
||||
int I410ToI420(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define H410ToH444 I410ToI444
|
||||
LIBYUV_API
|
||||
int I410ToI444(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define H012ToH420 I012ToI420
|
||||
LIBYUV_API
|
||||
int I012ToI420(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define H212ToH422 I212ToI422
|
||||
LIBYUV_API
|
||||
int I212ToI422(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define H212ToH420 I212ToI420
|
||||
LIBYUV_API
|
||||
int I212ToI420(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define H412ToH444 I412ToI444
|
||||
LIBYUV_API
|
||||
int I412ToI444(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define H412ToH420 I412ToI420
|
||||
LIBYUV_API
|
||||
int I412ToI420(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert 10 bit P010 to 8 bit NV12.
|
||||
// dst_y can be NULL
|
||||
LIBYUV_API
|
||||
int P010ToNV12(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define I412ToI012 I410ToI010
|
||||
#define H410ToH010 I410ToI010
|
||||
#define H412ToH012 I410ToI010
|
||||
LIBYUV_API
|
||||
int I410ToI010(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#define I212ToI012 I210ToI010
|
||||
#define H210ToH010 I210ToI010
|
||||
#define H212ToH012 I210ToI010
|
||||
LIBYUV_API
|
||||
int I210ToI010(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I010 to I410
|
||||
LIBYUV_API
|
||||
int I010ToI410(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I012 to I412
|
||||
#define I012ToI412 I010ToI410
|
||||
|
||||
// Convert I210 to I410
|
||||
LIBYUV_API
|
||||
int I210ToI410(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I212 to I412
|
||||
#define I212ToI412 I210ToI410
|
||||
|
||||
// Convert I010 to P010
|
||||
LIBYUV_API
|
||||
int I010ToP010(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert 10 bit YUV I010 to NV12
|
||||
LIBYUV_API
|
||||
int I010ToNV12(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I210 to P210
|
||||
LIBYUV_API
|
||||
int I210ToP210(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I410 to P410
|
||||
LIBYUV_API
|
||||
int I410ToP410(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I012 to P012
|
||||
LIBYUV_API
|
||||
int I012ToP012(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I212 to P212
|
||||
LIBYUV_API
|
||||
int I212ToP212(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I412 to P412
|
||||
LIBYUV_API
|
||||
int I412ToP412(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I400 (grey) to I420.
|
||||
LIBYUV_API
|
||||
int I400ToI420(const uint8_t* src_y,
|
||||
@@ -157,6 +633,23 @@ int I400ToI420(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert J420 to I420.
|
||||
LIBYUV_API
|
||||
int J420ToI420(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I400 (grey) to NV21.
|
||||
LIBYUV_API
|
||||
int I400ToNV21(const uint8_t* src_y,
|
||||
@@ -200,6 +693,175 @@ int NV21ToI420(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert NV12 to NV24.
|
||||
LIBYUV_API
|
||||
int NV12ToNV24(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert NV16 to NV24.
|
||||
LIBYUV_API
|
||||
int NV16ToNV24(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert P010 to I010.
|
||||
LIBYUV_API
|
||||
int P010ToI010(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert P210 to I210.
|
||||
LIBYUV_API
|
||||
int P210ToI210(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert P410 to I410.
|
||||
LIBYUV_API
|
||||
int P410ToI410(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert P010 to I420.
|
||||
LIBYUV_API
|
||||
int P010ToI420(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert P210 to I420.
|
||||
LIBYUV_API
|
||||
int P210ToI420(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert P410 to I420.
|
||||
LIBYUV_API
|
||||
int P410ToI420(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert P012 to I012.
|
||||
LIBYUV_API
|
||||
int P012ToI012(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert P010 to P410.
|
||||
LIBYUV_API
|
||||
int P010ToP410(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert P012 to P412.
|
||||
#define P012ToP412 P010ToP410
|
||||
|
||||
// Convert P016 to P416.
|
||||
#define P016ToP416 P010ToP410
|
||||
|
||||
// Convert P210 to P410.
|
||||
LIBYUV_API
|
||||
int P210ToP410(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert P212 to P412.
|
||||
#define P212ToP412 P210ToP410
|
||||
|
||||
// Convert P216 to P416.
|
||||
#define P216ToP416 P210ToP410
|
||||
|
||||
// Convert YUY2 to I420.
|
||||
LIBYUV_API
|
||||
int YUY2ToI420(const uint8_t* src_yuy2,
|
||||
@@ -248,19 +910,6 @@ int AYUVToNV21(const uint8_t* src_ayuv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert M420 to I420.
|
||||
LIBYUV_API
|
||||
int M420ToI420(const uint8_t* src_m420,
|
||||
int src_stride_m420,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert Android420 to I420.
|
||||
LIBYUV_API
|
||||
int Android420ToI420(const uint8_t* src_y,
|
||||
@@ -292,6 +941,35 @@ int ARGBToI420(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RGB to I420 with matrix. See ArgbConstants in convert_from_argb.h for usage.
|
||||
LIBYUV_API
|
||||
int ARGBToI420Matrix(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
const struct ArgbConstants* argbconstants,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB to I420 with Alpha
|
||||
LIBYUV_API
|
||||
int ARGBToI420Alpha(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// BGRA little endian (argb in memory) to I420.
|
||||
LIBYUV_API
|
||||
int BGRAToI420(const uint8_t* src_bgra,
|
||||
@@ -318,6 +996,71 @@ int ABGRToI420(const uint8_t* src_abgr,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert AR30 to I420.
|
||||
LIBYUV_API
|
||||
int AR30ToI420(const uint8_t* src_ar30,
|
||||
int src_stride_ar30,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert AB30 to I420.
|
||||
LIBYUV_API
|
||||
int AB30ToI420(const uint8_t* src_ab30,
|
||||
int src_stride_ab30,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// BGRA little endian (argb in memory) to I422.
|
||||
LIBYUV_API
|
||||
int BGRAToI422(const uint8_t* src_bgra,
|
||||
int src_stride_bgra,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// ABGR little endian (rgba in memory) to I422.
|
||||
LIBYUV_API
|
||||
int ABGRToI422(const uint8_t* src_abgr,
|
||||
int src_stride_abgr,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RGBA little endian (abgr in memory) to I422.
|
||||
LIBYUV_API
|
||||
int RGBAToI422(const uint8_t* src_rgba,
|
||||
int src_stride_rgba,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RGBA little endian (abgr in memory) to I420.
|
||||
LIBYUV_API
|
||||
int RGBAToI420(const uint8_t* src_rgba,
|
||||
@@ -370,7 +1113,46 @@ int RAWToI420(const uint8_t* src_raw,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RGB16 (RGBP fourcc) little endian to I420.
|
||||
// RGB big endian (rgb in memory) to I444.
|
||||
LIBYUV_API
|
||||
int RAWToI444(const uint8_t* src_raw,
|
||||
int src_stride_raw,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RGB big endian (rgb in memory) to J420.
|
||||
LIBYUV_API
|
||||
int RAWToJ420(const uint8_t* src_raw,
|
||||
int src_stride_raw,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RGB big endian (rgb in memory) to J444.
|
||||
LIBYUV_API
|
||||
int RAWToJ444(const uint8_t* src_raw,
|
||||
int src_stride_raw,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RGB16 (RGBP fourcc) little endian to I420. Deprecated.
|
||||
LIBYUV_API
|
||||
int RGB565ToI420(const uint8_t* src_rgb565,
|
||||
int src_stride_rgb565,
|
||||
@@ -383,7 +1165,7 @@ int RGB565ToI420(const uint8_t* src_rgb565,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RGB15 (RGBO fourcc) little endian to I420.
|
||||
// RGB15 (RGBO fourcc) little endian to I420. Deprecated.
|
||||
LIBYUV_API
|
||||
int ARGB1555ToI420(const uint8_t* src_argb1555,
|
||||
int src_stride_argb1555,
|
||||
@@ -396,7 +1178,7 @@ int ARGB1555ToI420(const uint8_t* src_argb1555,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RGB12 (R444 fourcc) little endian to I420.
|
||||
// RGB12 (R444 fourcc) little endian to I420. Deprecated.
|
||||
LIBYUV_API
|
||||
int ARGB4444ToI420(const uint8_t* src_argb4444,
|
||||
int src_stride_argb4444,
|
||||
@@ -418,7 +1200,15 @@ int RGB24ToJ400(const uint8_t* src_rgb24,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
// RGB big endian (rgb in memory) to J400.
|
||||
LIBYUV_API
|
||||
int RAWToJ400(const uint8_t* src_raw,
|
||||
int src_stride_raw,
|
||||
uint8_t* dst_yj,
|
||||
int dst_stride_yj,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// src_width/height provided by capture.
|
||||
// dst_width/height for clipping determine final size.
|
||||
LIBYUV_API
|
||||
@@ -448,13 +1238,25 @@ int MJPGToNV21(const uint8_t* sample,
|
||||
int dst_width,
|
||||
int dst_height);
|
||||
|
||||
// JPEG to NV12
|
||||
LIBYUV_API
|
||||
int MJPGToNV12(const uint8_t* sample,
|
||||
size_t sample_size,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int src_width,
|
||||
int src_height,
|
||||
int dst_width,
|
||||
int dst_height);
|
||||
|
||||
// Query size of MJPG in pixels.
|
||||
LIBYUV_API
|
||||
int MJPGSize(const uint8_t* sample,
|
||||
size_t sample_size,
|
||||
int* width,
|
||||
int* height);
|
||||
#endif
|
||||
|
||||
// Convert camera sample to I420 with cropping, rotation and vertical flip.
|
||||
// "src_size" is needed to parse MJPG.
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -11,6 +11,8 @@
|
||||
#ifndef INCLUDE_LIBYUV_CONVERT_FROM_H_
|
||||
#define INCLUDE_LIBYUV_CONVERT_FROM_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
#include "libyuv/rotate.h"
|
||||
|
||||
@@ -23,6 +25,7 @@ extern "C" {
|
||||
|
||||
// Convert 8 bit YUV to 10 bit.
|
||||
#define H420ToH010 I420ToI010
|
||||
LIBYUV_API
|
||||
int I420ToI010(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
@@ -38,6 +41,24 @@ int I420ToI010(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert 8 bit YUV to 12 bit.
|
||||
#define H420ToH012 I420ToI012
|
||||
LIBYUV_API
|
||||
int I420ToI012(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int I420ToI422(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
@@ -107,6 +128,81 @@ int I420ToNV21(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I420 to P010.
|
||||
LIBYUV_API
|
||||
int I420ToP010(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I422 to P210.
|
||||
LIBYUV_API
|
||||
int I422ToP210(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I444 to P410.
|
||||
LIBYUV_API
|
||||
int I444ToP410(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I420 to P210.
|
||||
LIBYUV_API
|
||||
int I420ToP210(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I420 to P410.
|
||||
LIBYUV_API
|
||||
int I420ToP410(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int I420ToYUY2(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
@@ -131,6 +227,10 @@ int I420ToUYVY(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// The following are from convert_argb.h
|
||||
// DEPRECATED: The prototypes will be removed in future. Use convert_argb.h
|
||||
|
||||
// Convert I420 to ARGB.
|
||||
LIBYUV_API
|
||||
int I420ToARGB(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
@@ -143,18 +243,7 @@ int I420ToARGB(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int I420ToBGRA(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_bgra,
|
||||
int dst_stride_bgra,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I420 to ABGR.
|
||||
LIBYUV_API
|
||||
int I420ToABGR(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
@@ -167,181 +256,6 @@ int I420ToABGR(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int I420ToRGBA(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_rgba,
|
||||
int dst_stride_rgba,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int I420ToRGB24(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_rgb24,
|
||||
int dst_stride_rgb24,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int I420ToRAW(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_raw,
|
||||
int dst_stride_raw,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int H420ToRGB24(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_rgb24,
|
||||
int dst_stride_rgb24,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int H420ToRAW(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_raw,
|
||||
int dst_stride_raw,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int I420ToRGB565(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_rgb565,
|
||||
int dst_stride_rgb565,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int J420ToRGB565(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_rgb565,
|
||||
int dst_stride_rgb565,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int H420ToRGB565(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_rgb565,
|
||||
int dst_stride_rgb565,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int I422ToRGB565(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_rgb565,
|
||||
int dst_stride_rgb565,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I420 To RGB565 with 4x4 dither matrix (16 bytes).
|
||||
// Values in dither matrix from 0 to 7 recommended.
|
||||
// The order of the dither matrix is first byte is upper left.
|
||||
|
||||
LIBYUV_API
|
||||
int I420ToRGB565Dither(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_rgb565,
|
||||
int dst_stride_rgb565,
|
||||
const uint8_t* dither4x4,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int I420ToARGB1555(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_argb1555,
|
||||
int dst_stride_argb1555,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int I420ToARGB4444(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_argb4444,
|
||||
int dst_stride_argb4444,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I420 to AR30.
|
||||
LIBYUV_API
|
||||
int I420ToAR30(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_ar30,
|
||||
int dst_stride_ar30,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert H420 to AR30.
|
||||
LIBYUV_API
|
||||
int H420ToAR30(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_ar30,
|
||||
int dst_stride_ar30,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I420 to specified format.
|
||||
// "dst_sample_stride" is bytes in a row for the destination. Pass 0 if the
|
||||
// buffer has contiguous rows. Can be negative. A multiple of 16 is optimal.
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#ifndef INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_
|
||||
#define INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -18,6 +20,47 @@ namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// The ArgbConstants below can be used with the ARGBTo*Matrix() functions to
|
||||
// process different RGB formats. E.g., if your input is ARGB little endian
|
||||
// (bgra in memory) you'll want to use the kArgb* constants. Alternatively, if
|
||||
// your input is ABGR little endian (rgba in memory) you'd use the kAbgr* ones.
|
||||
//
|
||||
// Conversion matrix for xRGB to YUV.
|
||||
LIBYUV_API extern const struct ArgbConstants kArgbI601Constants; // BT.601
|
||||
LIBYUV_API extern const struct ArgbConstants kArgbJPEGConstants; // BT.601 full
|
||||
LIBYUV_API extern const struct ArgbConstants kArgbH709Constants; // BT.709
|
||||
LIBYUV_API extern const struct ArgbConstants kArgbF709Constants; // BT.709 full
|
||||
LIBYUV_API extern const struct ArgbConstants kArgbU2020Constants; // BT.2020
|
||||
LIBYUV_API extern const struct ArgbConstants
|
||||
kArgbV2020Constants; // BT.2020 full
|
||||
|
||||
// Conversion matrix for xBGR to YUV.
|
||||
LIBYUV_API extern const struct ArgbConstants kAbgrI601Constants; // BT.601
|
||||
LIBYUV_API extern const struct ArgbConstants kAbgrJPEGConstants; // BT.601 full
|
||||
LIBYUV_API extern const struct ArgbConstants kAbgrH709Constants; // BT.709
|
||||
LIBYUV_API extern const struct ArgbConstants kAbgrF709Constants; // BT.709 full
|
||||
LIBYUV_API extern const struct ArgbConstants kAbgrU2020Constants; // BT.2020
|
||||
LIBYUV_API extern const struct ArgbConstants
|
||||
kAbgrV2020Constants; // BT.2020 full
|
||||
|
||||
// Conversion matrix for RGBx to YUV.
|
||||
LIBYUV_API extern const struct ArgbConstants kRgbaI601Constants; // BT.601
|
||||
LIBYUV_API extern const struct ArgbConstants kRgbaJPEGConstants; // BT.601 full
|
||||
LIBYUV_API extern const struct ArgbConstants kRgbaH709Constants; // BT.709
|
||||
LIBYUV_API extern const struct ArgbConstants kRgbaF709Constants; // BT.709 full
|
||||
LIBYUV_API extern const struct ArgbConstants kRgbaU2020Constants; // BT.2020
|
||||
LIBYUV_API extern const struct ArgbConstants
|
||||
kRgbaV2020Constants; // BT.2020 full
|
||||
|
||||
// Conversion matrix from BGRx to YUV.
|
||||
LIBYUV_API extern const struct ArgbConstants kBgraI601Constants; // BT.601
|
||||
LIBYUV_API extern const struct ArgbConstants kBgraJPEGConstants; // BT.601 full
|
||||
LIBYUV_API extern const struct ArgbConstants kBgraH709Constants; // BT.709
|
||||
LIBYUV_API extern const struct ArgbConstants kBgraF709Constants; // BT.709 full
|
||||
LIBYUV_API extern const struct ArgbConstants kBgraU2020Constants; // BT.2020
|
||||
LIBYUV_API extern const struct ArgbConstants
|
||||
kBgraV2020Constants; // BT.2020 full
|
||||
|
||||
// Copy ARGB to ARGB.
|
||||
#define ARGBToARGB ARGBCopy
|
||||
LIBYUV_API
|
||||
@@ -77,6 +120,10 @@ int ARGBToAR30(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Aliases
|
||||
#define ABGRToRGB24 ARGBToRAW
|
||||
#define ABGRToRAW ARGBToRGB24
|
||||
|
||||
// Convert ARGB To RGB24.
|
||||
LIBYUV_API
|
||||
int ARGBToRGB24(const uint8_t* src_argb,
|
||||
@@ -95,7 +142,7 @@ int ARGBToRAW(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To RGB565.
|
||||
// Convert ARGB To RGB565. Deprecated.
|
||||
LIBYUV_API
|
||||
int ARGBToRGB565(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
@@ -104,7 +151,7 @@ int ARGBToRGB565(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To RGB565 with 4x4 dither matrix (16 bytes).
|
||||
// Convert ARGB To RGB565 with 4x4 dither matrix (16 bytes). Deprecated.
|
||||
// Values in dither matrix from 0 to 7 recommended.
|
||||
// The order of the dither matrix is first byte is upper left.
|
||||
// TODO(fbarchard): Consider pointer to 2d array for dither4x4.
|
||||
@@ -118,7 +165,7 @@ int ARGBToRGB565Dither(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To ARGB1555.
|
||||
// Convert ARGB To ARGB1555. Deprecated.
|
||||
LIBYUV_API
|
||||
int ARGBToARGB1555(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
@@ -127,7 +174,7 @@ int ARGBToARGB1555(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To ARGB4444.
|
||||
// Convert ARGB To ARGB4444. Deprecated.
|
||||
LIBYUV_API
|
||||
int ARGBToARGB4444(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
@@ -149,6 +196,45 @@ int ARGBToI444(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// ARGB to I444 with matrix. See ArgbConstants at the top of this file for
|
||||
// usage.
|
||||
LIBYUV_API
|
||||
int ARGBToI444Matrix(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
const struct ArgbConstants* argbconstants,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB to AR64.
|
||||
LIBYUV_API
|
||||
int ARGBToAR64(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint16_t* dst_ar64,
|
||||
int dst_stride_ar64,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ABGR to AB64.
|
||||
#define ABGRToAB64 ARGBToAR64
|
||||
|
||||
// Convert ARGB to AB64.
|
||||
LIBYUV_API
|
||||
int ARGBToAB64(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint16_t* dst_ab64,
|
||||
int dst_stride_ab64,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ABGR to AR64.
|
||||
#define ABGRToAR64 ARGBToAB64
|
||||
|
||||
// Convert ARGB To I422.
|
||||
LIBYUV_API
|
||||
int ARGBToI422(const uint8_t* src_argb,
|
||||
@@ -162,6 +248,34 @@ int ARGBToI422(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ABGR To I422.
|
||||
LIBYUV_API
|
||||
int ABGRToI422(const uint8_t* src_abgr,
|
||||
int src_stride_abgr,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// ARGB to I422 with matrix. See ArgbConstants at the top of this file for
|
||||
// usage.
|
||||
LIBYUV_API
|
||||
int ARGBToI422Matrix(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
const struct ArgbConstants* argbconstants,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To I420. (also in convert.h)
|
||||
LIBYUV_API
|
||||
int ARGBToI420(const uint8_t* src_argb,
|
||||
@@ -181,10 +295,10 @@ int ARGBToJ420(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_yj,
|
||||
int dst_stride_yj,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
uint8_t* dst_uj,
|
||||
int dst_stride_uj,
|
||||
uint8_t* dst_vj,
|
||||
int dst_stride_vj,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
@@ -194,10 +308,23 @@ int ARGBToJ422(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_yj,
|
||||
int dst_stride_yj,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
uint8_t* dst_uj,
|
||||
int dst_stride_uj,
|
||||
uint8_t* dst_vj,
|
||||
int dst_stride_vj,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB to J444.
|
||||
LIBYUV_API
|
||||
int ARGBToJ444(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_yj,
|
||||
int dst_stride_yj,
|
||||
uint8_t* dst_uj,
|
||||
int dst_stride_uj,
|
||||
uint8_t* dst_vj,
|
||||
int dst_stride_vj,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
@@ -210,6 +337,50 @@ int ARGBToJ400(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ABGR to J420. (JPeg full range I420).
|
||||
LIBYUV_API
|
||||
int ABGRToJ420(const uint8_t* src_abgr,
|
||||
int src_stride_abgr,
|
||||
uint8_t* dst_yj,
|
||||
int dst_stride_yj,
|
||||
uint8_t* dst_uj,
|
||||
int dst_stride_uj,
|
||||
uint8_t* dst_vj,
|
||||
int dst_stride_vj,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ABGR to J422.
|
||||
LIBYUV_API
|
||||
int ABGRToJ422(const uint8_t* src_abgr,
|
||||
int src_stride_abgr,
|
||||
uint8_t* dst_yj,
|
||||
int dst_stride_yj,
|
||||
uint8_t* dst_uj,
|
||||
int dst_stride_uj,
|
||||
uint8_t* dst_vj,
|
||||
int dst_stride_vj,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ABGR to J400. (JPeg full range).
|
||||
LIBYUV_API
|
||||
int ABGRToJ400(const uint8_t* src_abgr,
|
||||
int src_stride_abgr,
|
||||
uint8_t* dst_yj,
|
||||
int dst_stride_yj,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert RGBA to J400. (JPeg full range).
|
||||
LIBYUV_API
|
||||
int RGBAToJ400(const uint8_t* src_rgba,
|
||||
int src_stride_rgba,
|
||||
uint8_t* dst_yj,
|
||||
int dst_stride_yj,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB to I400.
|
||||
LIBYUV_API
|
||||
int ARGBToI400(const uint8_t* src_argb,
|
||||
@@ -219,15 +390,6 @@ int ARGBToI400(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB to G. (Reverse of J400toARGB, which replicates G back to ARGB)
|
||||
LIBYUV_API
|
||||
int ARGBToG(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_g,
|
||||
int dst_stride_g,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To NV12.
|
||||
LIBYUV_API
|
||||
int ARGBToNV12(const uint8_t* src_argb,
|
||||
@@ -239,6 +401,80 @@ int ARGBToNV12(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// ARGB to NV12 with matrix. See ArgbConstants at the top of this file for
|
||||
// usage.
|
||||
LIBYUV_API
|
||||
int ARGBToNV12Matrix(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
const struct ArgbConstants* argbconstants,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To NV16.
|
||||
LIBYUV_API
|
||||
int ARGBToNV16(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// ARGB to NV16 with matrix. See ArgbConstants at the top of this file for
|
||||
// usage.
|
||||
LIBYUV_API
|
||||
int ARGBToNV16Matrix(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
const struct ArgbConstants* argbconstants,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To NV24.
|
||||
LIBYUV_API
|
||||
int ARGBToNV24(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// ARGB to NV24 with matrix. See ArgbConstants at the top of this file for
|
||||
// usage.
|
||||
LIBYUV_API
|
||||
int ARGBToNV24Matrix(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
const struct ArgbConstants* argbconstants,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// ARGB to NV21 with matrix. See ArgbConstants at the top of this file for
|
||||
// usage.
|
||||
LIBYUV_API
|
||||
int ARGBToNV21Matrix(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_vu,
|
||||
int dst_stride_vu,
|
||||
const struct ArgbConstants* argbconstants,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To NV21.
|
||||
LIBYUV_API
|
||||
int ARGBToNV21(const uint8_t* src_argb,
|
||||
@@ -250,6 +486,78 @@ int ARGBToNV21(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To P010.
|
||||
LIBYUV_API
|
||||
int ARGBToP010(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// ARGB to P010 with matrix. See ArgbConstants at the top of this file for
|
||||
// usage.
|
||||
LIBYUV_API
|
||||
int ARGBToP010Matrix(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
const struct ArgbConstants* argbconstants,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To P210.
|
||||
LIBYUV_API
|
||||
int ARGBToP210(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// ARGB to P210 with matrix. See ArgbConstants at the top of this file for
|
||||
// usage.
|
||||
LIBYUV_API
|
||||
int ARGBToP210Matrix(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
const struct ArgbConstants* argbconstants,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To P410.
|
||||
LIBYUV_API
|
||||
int ARGBToP410(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// ARGB to P410 with matrix. See ArgbConstants at the top of this file for
|
||||
// usage.
|
||||
LIBYUV_API
|
||||
int ARGBToP410Matrix(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
const struct ArgbConstants* argbconstants,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ABGR To NV12.
|
||||
LIBYUV_API
|
||||
int ABGRToNV12(const uint8_t* src_abgr,
|
||||
@@ -272,17 +580,6 @@ int ABGRToNV21(const uint8_t* src_abgr,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To NV21.
|
||||
LIBYUV_API
|
||||
int ARGBToNV21(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_vu,
|
||||
int dst_stride_vu,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert ARGB To YUY2.
|
||||
LIBYUV_API
|
||||
int ARGBToYUY2(const uint8_t* src_argb,
|
||||
@@ -301,6 +598,39 @@ int ARGBToUYVY(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RAW to NV21
|
||||
LIBYUV_API
|
||||
int RAWToNV21(const uint8_t* src_raw,
|
||||
int src_stride_raw,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_vu,
|
||||
int dst_stride_vu,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RGB24 to NV12
|
||||
LIBYUV_API
|
||||
int RGB24ToNV12(const uint8_t* src_rgb24,
|
||||
int src_stride_rgb24,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// RAW to JNV21 full range NV21
|
||||
LIBYUV_API
|
||||
int RAWToJNV21(const uint8_t* src_raw,
|
||||
int src_stride_raw,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_vu,
|
||||
int dst_stride_vu,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#ifndef INCLUDE_LIBYUV_CPU_ID_H_
|
||||
#define INCLUDE_LIBYUV_CPU_ID_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -21,34 +23,60 @@ extern "C" {
|
||||
// Internal flag to indicate cpuid requires initialization.
|
||||
static const int kCpuInitialized = 0x1;
|
||||
|
||||
// These flags are only valid on ARM processors.
|
||||
// These flags are only valid on Arm processors.
|
||||
static const int kCpuHasARM = 0x2;
|
||||
static const int kCpuHasNEON = 0x4;
|
||||
// 0x8 reserved for future ARM flag.
|
||||
static const int kCpuHasNEON = 0x100;
|
||||
static const int kCpuHasNeonDotProd = 0x200;
|
||||
static const int kCpuHasNeonI8MM = 0x400;
|
||||
static const int kCpuHasSVE = 0x800;
|
||||
static const int kCpuHasSVE2 = 0x1000;
|
||||
static const int kCpuHasSME = 0x2000;
|
||||
static const int kCpuHasSME2 = 0x4000;
|
||||
static const int kCpuHasSVEF32MM = 0x8000;
|
||||
|
||||
// These flags are only valid on RISCV processors.
|
||||
static const int kCpuHasRISCV = 0x4;
|
||||
static const int kCpuHasRVV = 0x100;
|
||||
static const int kCpuHasRVVZVFH = 0x200;
|
||||
|
||||
// These flags are only valid on x86 processors.
|
||||
static const int kCpuHasX86 = 0x10;
|
||||
static const int kCpuHasSSE2 = 0x20;
|
||||
static const int kCpuHasSSSE3 = 0x40;
|
||||
static const int kCpuHasSSE41 = 0x80;
|
||||
static const int kCpuHasSSE42 = 0x100; // unused at this time.
|
||||
static const int kCpuHasAVX = 0x200;
|
||||
static const int kCpuHasAVX2 = 0x400;
|
||||
static const int kCpuHasERMS = 0x800;
|
||||
static const int kCpuHasFMA3 = 0x1000;
|
||||
static const int kCpuHasF16C = 0x2000;
|
||||
static const int kCpuHasGFNI = 0x4000;
|
||||
static const int kCpuHasAVX512BW = 0x8000;
|
||||
static const int kCpuHasAVX512VL = 0x10000;
|
||||
static const int kCpuHasAVX512VBMI = 0x20000;
|
||||
static const int kCpuHasAVX512VBMI2 = 0x40000;
|
||||
static const int kCpuHasAVX512VBITALG = 0x80000;
|
||||
static const int kCpuHasAVX512VPOPCNTDQ = 0x100000;
|
||||
static const int kCpuHasX86 = 0x8;
|
||||
static const int kCpuHasSSE2 = 0x100;
|
||||
static const int kCpuHasSSSE3 = 0x200;
|
||||
static const int kCpuHasSSE41 = 0x400;
|
||||
static const int kCpuHasSSE42 = 0x800;
|
||||
static const int kCpuHasAVX = 0x1000;
|
||||
static const int kCpuHasAVX2 = 0x2000;
|
||||
static const int kCpuHasERMS = 0x4000;
|
||||
static const int kCpuHasFSMR = 0x8000;
|
||||
static const int kCpuHasFMA3 = 0x10000;
|
||||
static const int kCpuHasF16C = 0x20000;
|
||||
static const int kCpuHasAVX512BW = 0x40000;
|
||||
static const int kCpuHasAVX512VL = 0x80000;
|
||||
static const int kCpuHasAVX512VNNI = 0x100000;
|
||||
static const int kCpuHasAVX512VBMI = 0x200000;
|
||||
static const int kCpuHasAVX512VBMI2 = 0x400000;
|
||||
static const int kCpuHasAVX512VBITALG = 0x800000;
|
||||
static const int kCpuHasAVX10 = 0x1000000;
|
||||
static const int kCpuHasAVX10_2 = 0x2000000;
|
||||
static const int kCpuHasAVXVNNI = 0x4000000;
|
||||
static const int kCpuHasAVXVNNIINT8 = 0x8000000;
|
||||
static const int kCpuHasAMXINT8 = 0x10000000;
|
||||
static const int kCpuHasAVX512BMM = 0x20000000;
|
||||
static const int kCpuHasAMXTF32 = 0x40000000;
|
||||
|
||||
// These flags are only valid on MIPS processors.
|
||||
static const int kCpuHasMIPS = 0x200000;
|
||||
static const int kCpuHasMSA = 0x400000;
|
||||
static const int kCpuHasMMI = 0x800000;
|
||||
// These flags are only valid on LOONGARCH processors.
|
||||
static const int kCpuHasLOONGARCH = 0x20;
|
||||
static const int kCpuHasLSX = 0x100;
|
||||
static const int kCpuHasLASX = 0x200;
|
||||
|
||||
// These flags are only valid on WASM processors.
|
||||
static const int kCpuHasWASM = 0x40;
|
||||
static const int kCpuHasWASMSIMD = 0x100;
|
||||
|
||||
// These flags are only valid on Hexagon processors.
|
||||
static const int kCpuHasHexagon = 0x80;
|
||||
static const int kCpuHasHVX = 0x100;
|
||||
|
||||
// Optional init function. TestCpuFlag does an auto-init.
|
||||
// Returns cpu_info flags.
|
||||
@@ -71,6 +99,17 @@ static __inline int TestCpuFlag(int test_flag) {
|
||||
// Internal function for parsing /proc/cpuinfo.
|
||||
LIBYUV_API
|
||||
int ArmCpuCaps(const char* cpuinfo_name);
|
||||
LIBYUV_API
|
||||
int RiscvCpuCaps(const char* cpuinfo_name);
|
||||
|
||||
#ifdef __linux__
|
||||
// On Linux, parse AArch64 features from getauxval(AT_HWCAP{,2}).
|
||||
LIBYUV_API
|
||||
int AArch64CpuCaps(unsigned long hwcap, unsigned long hwcap2);
|
||||
#else
|
||||
LIBYUV_API
|
||||
int AArch64CpuCaps(void);
|
||||
#endif
|
||||
|
||||
// For testing, allow CPU flags to be disabled.
|
||||
// ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3.
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright 2024 The LibYuv Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_LIBYUV_CPU_SUPPORT_H_
|
||||
#define INCLUDE_LIBYUV_CPU_SUPPORT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__pnacl__) || defined(__CLR_VER) || \
|
||||
(defined(__native_client__) && defined(__x86_64__)) || \
|
||||
(defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
|
||||
#define LIBYUV_DISABLE_X86
|
||||
#endif
|
||||
|
||||
#if defined(__native_client__)
|
||||
#define LIBYUV_DISABLE_NEON
|
||||
#endif
|
||||
|
||||
// MemorySanitizer does not support assembly code yet. http://crbug.com/344505
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
#if !defined(LIBYUV_MSAN)
|
||||
#define LIBYUV_MSAN 1
|
||||
#endif
|
||||
#if !defined(LIBYUV_DISABLE_NEON)
|
||||
#define LIBYUV_DISABLE_NEON
|
||||
#endif
|
||||
#if !defined(LIBYUV_DISABLE_SME)
|
||||
#define LIBYUV_DISABLE_SME
|
||||
#endif
|
||||
#if !defined(LIBYUV_DISABLE_SVE)
|
||||
#define LIBYUV_DISABLE_SVE
|
||||
#endif
|
||||
#if !defined(LIBYUV_ENABLE_ROWWIN)
|
||||
#define LIBYUV_ENABLE_ROWWIN
|
||||
#endif
|
||||
#endif // __has_feature(memory_sanitizer)
|
||||
#endif // defined(__has_feature)
|
||||
|
||||
// clang >= 3.5.0 required for Arm64.
|
||||
#if defined(__clang__) && defined(__aarch64__) && !defined(LIBYUV_DISABLE_NEON)
|
||||
#if (__clang_major__ < 3) || (__clang_major__ == 3 && (__clang_minor__ < 5))
|
||||
#define LIBYUV_DISABLE_NEON
|
||||
#endif // clang >= 3.5
|
||||
#endif // __clang__
|
||||
|
||||
// GCC >= 4.7.0 required for AVX2.
|
||||
#if defined(__GNUC__) && !defined(__clang__) && \
|
||||
!defined(LIBYUV_ENABLE_ROWWIN) && \
|
||||
(defined(__x86_64__) || defined(__i386__))
|
||||
#if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 7))
|
||||
#define GCC_HAS_AVX2 1
|
||||
#endif // GNUC >= 4.7
|
||||
#endif // __GNUC__
|
||||
|
||||
// GCC >= 9.0.0 required for AVX512 (including VNNI and VBMI).
|
||||
#if defined(__GNUC__) && !defined(__clang__) && \
|
||||
!defined(LIBYUV_ENABLE_ROWWIN) && defined(__x86_64__)
|
||||
#if (__GNUC__ >= 9)
|
||||
#define GCC_HAS_AVX512 1
|
||||
#endif // GNUC >= 9
|
||||
#endif // __GNUC__
|
||||
|
||||
// Function target attributes so GCC enables zmm16..zmm31 and k1..k7 clobbers
|
||||
// inside AVX512 functions without emitting AVX512 in non-AVX512 functions.
|
||||
#if defined(GCC_HAS_AVX512)
|
||||
#define LIBYUV_TARGET_AVX512BW \
|
||||
__attribute__((target("avx512bw,avx512vl,avx512f,bmi2")))
|
||||
#define LIBYUV_TARGET_AVX512VBMI \
|
||||
__attribute__((target("avx512vbmi,avx512bw,avx512vl,avx512f,bmi2")))
|
||||
#define LIBYUV_TARGET_AVX512VNNI \
|
||||
__attribute__((target("avx512vnni,avx512bw,avx512vl,avx512f,bmi2")))
|
||||
#define LIBYUV_TARGET_AVX512VNNIVBMI \
|
||||
__attribute__(( \
|
||||
target("avx512vnni,avx512vbmi,avx512bw,avx512vl,avx512f,bmi2")))
|
||||
#elif !defined(LIBYUV_ENABLE_ROWWIN) && \
|
||||
!(defined(_MSC_VER) && !defined(__clang__))
|
||||
#define LIBYUV_TARGET_AVX512BW
|
||||
#define LIBYUV_TARGET_AVX512VBMI
|
||||
#define LIBYUV_TARGET_AVX512VNNI
|
||||
#define LIBYUV_TARGET_AVX512VNNIVBMI
|
||||
#endif
|
||||
|
||||
// clang >= 3.4.0 required for AVX2.
|
||||
#if defined(__clang__) && !defined(LIBYUV_ENABLE_ROWWIN) && \
|
||||
(defined(__x86_64__) || defined(__i386__))
|
||||
#if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4))
|
||||
#define CLANG_HAS_AVX2 1
|
||||
#endif // clang >= 3.4
|
||||
#endif // __clang__
|
||||
|
||||
// clang >= 7.0.0 required for AVX512.
|
||||
#if defined(__clang__) && !defined(LIBYUV_ENABLE_ROWWIN) && \
|
||||
(defined(__x86_64__) || defined(__i386__))
|
||||
// clang in xcode follows a different versioning scheme.
|
||||
// TODO(fbarchard): fix xcode 9 ios b/789.
|
||||
#if (__clang_major__ >= 7) && !defined(__APPLE__)
|
||||
#define CLANG_HAS_AVX512 1
|
||||
#endif // clang >= 7
|
||||
#endif // __clang__
|
||||
|
||||
// Visual C 2012 (or clang >= 3.4 with LIBYUV_ENABLE_ROWWIN) required for AVX2.
|
||||
#if ((defined(_M_IX86) || defined(_M_X64)) && !defined(__clang__) && \
|
||||
defined(_MSC_VER) && _MSC_VER >= 1700) || \
|
||||
(defined(LIBYUV_ENABLE_ROWWIN) && defined(__clang__) && \
|
||||
(defined(__x86_64__) || defined(__i386__) || defined(_M_X64) || \
|
||||
defined(_M_IX86)) && \
|
||||
((__clang_major__ > 3) || \
|
||||
(__clang_major__ == 3 && (__clang_minor__ >= 4))))
|
||||
#define VISUALC_HAS_AVX2 1
|
||||
#endif // VisualStudio >= 2012
|
||||
|
||||
// Visual C 2019 (or clang >= 7 with LIBYUV_ENABLE_ROWWIN) required for AVX512.
|
||||
#if (defined(_M_X64) || defined(__x86_64__)) && \
|
||||
((!defined(__clang__) && defined(_MSC_VER) && _MSC_VER >= 1920) || \
|
||||
(defined(LIBYUV_ENABLE_ROWWIN) && defined(__clang__) && \
|
||||
(__clang_major__ >= 7) && !defined(__APPLE__)))
|
||||
#define VISUALC_HAS_AVX512 1
|
||||
#endif // VisualStudio >= 2019
|
||||
|
||||
#if defined(LIBYUV_ENABLE_SME)
|
||||
#undef LIBYUV_DISABLE_SME
|
||||
#endif
|
||||
|
||||
// Clang 18+ required for SME due to needing __arm_tpidr2_save from compiler-rt,
|
||||
// only enabled on Linux and Android (both define __linux__) for now.
|
||||
#if !defined(LIBYUV_DISABLE_SME) && defined(__aarch64__) && \
|
||||
defined(__linux__) && defined(__clang__) && (__clang_major__ >= 18)
|
||||
#define CLANG_HAS_SME 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // INCLUDE_LIBYUV_CPU_SUPPORT_H_
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2022 The LibYuv Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_LIBYUV_LOONGSON_INTRINSICS_H_
|
||||
#define INCLUDE_LIBYUV_LOONGSON_INTRINSICS_H_
|
||||
|
||||
#endif // INCLUDE_LIBYUV_LOONGSON_INTRINSICS_H_
|
||||
@@ -1,233 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 The LibYuv Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_LIBYUV_MACROS_MSA_H_
|
||||
#define INCLUDE_LIBYUV_MACROS_MSA_H_
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
|
||||
#include <msa.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if (__mips_isa_rev >= 6)
|
||||
#define LW(psrc) \
|
||||
({ \
|
||||
const uint8_t* psrc_lw_m = (const uint8_t*)(psrc); \
|
||||
uint32_t val_m; \
|
||||
asm volatile("lw %[val_m], %[psrc_lw_m] \n" \
|
||||
: [val_m] "=r"(val_m) \
|
||||
: [psrc_lw_m] "m"(*psrc_lw_m)); \
|
||||
val_m; \
|
||||
})
|
||||
|
||||
#if (__mips == 64)
|
||||
#define LD(psrc) \
|
||||
({ \
|
||||
const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \
|
||||
uint64_t val_m = 0; \
|
||||
asm volatile("ld %[val_m], %[psrc_ld_m] \n" \
|
||||
: [val_m] "=r"(val_m) \
|
||||
: [psrc_ld_m] "m"(*psrc_ld_m)); \
|
||||
val_m; \
|
||||
})
|
||||
#else // !(__mips == 64)
|
||||
#define LD(psrc) \
|
||||
({ \
|
||||
const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \
|
||||
uint32_t val0_m, val1_m; \
|
||||
uint64_t val_m = 0; \
|
||||
val0_m = LW(psrc_ld_m); \
|
||||
val1_m = LW(psrc_ld_m + 4); \
|
||||
val_m = (uint64_t)(val1_m); /* NOLINT */ \
|
||||
val_m = (uint64_t)((val_m << 32) & 0xFFFFFFFF00000000); /* NOLINT */ \
|
||||
val_m = (uint64_t)(val_m | (uint64_t)val0_m); /* NOLINT */ \
|
||||
val_m; \
|
||||
})
|
||||
#endif // (__mips == 64)
|
||||
|
||||
#define SW(val, pdst) \
|
||||
({ \
|
||||
uint8_t* pdst_sw_m = (uint8_t*)(pdst); /* NOLINT */ \
|
||||
uint32_t val_m = (val); \
|
||||
asm volatile("sw %[val_m], %[pdst_sw_m] \n" \
|
||||
: [pdst_sw_m] "=m"(*pdst_sw_m) \
|
||||
: [val_m] "r"(val_m)); \
|
||||
})
|
||||
|
||||
#if (__mips == 64)
|
||||
#define SD(val, pdst) \
|
||||
({ \
|
||||
uint8_t* pdst_sd_m = (uint8_t*)(pdst); /* NOLINT */ \
|
||||
uint64_t val_m = (val); \
|
||||
asm volatile("sd %[val_m], %[pdst_sd_m] \n" \
|
||||
: [pdst_sd_m] "=m"(*pdst_sd_m) \
|
||||
: [val_m] "r"(val_m)); \
|
||||
})
|
||||
#else // !(__mips == 64)
|
||||
#define SD(val, pdst) \
|
||||
({ \
|
||||
uint8_t* pdst_sd_m = (uint8_t*)(pdst); /* NOLINT */ \
|
||||
uint32_t val0_m, val1_m; \
|
||||
val0_m = (uint32_t)((val)&0x00000000FFFFFFFF); \
|
||||
val1_m = (uint32_t)(((val) >> 32) & 0x00000000FFFFFFFF); \
|
||||
SW(val0_m, pdst_sd_m); \
|
||||
SW(val1_m, pdst_sd_m + 4); \
|
||||
})
|
||||
#endif // !(__mips == 64)
|
||||
#else // !(__mips_isa_rev >= 6)
|
||||
#define LW(psrc) \
|
||||
({ \
|
||||
const uint8_t* psrc_lw_m = (const uint8_t*)(psrc); \
|
||||
uint32_t val_m; \
|
||||
asm volatile("ulw %[val_m], %[psrc_lw_m] \n" \
|
||||
: [val_m] "=r"(val_m) \
|
||||
: [psrc_lw_m] "m"(*psrc_lw_m)); \
|
||||
val_m; \
|
||||
})
|
||||
|
||||
#if (__mips == 64)
|
||||
#define LD(psrc) \
|
||||
({ \
|
||||
const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \
|
||||
uint64_t val_m = 0; \
|
||||
asm volatile("uld %[val_m], %[psrc_ld_m] \n" \
|
||||
: [val_m] "=r"(val_m) \
|
||||
: [psrc_ld_m] "m"(*psrc_ld_m)); \
|
||||
val_m; \
|
||||
})
|
||||
#else // !(__mips == 64)
|
||||
#define LD(psrc) \
|
||||
({ \
|
||||
const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \
|
||||
uint32_t val0_m, val1_m; \
|
||||
uint64_t val_m = 0; \
|
||||
val0_m = LW(psrc_ld_m); \
|
||||
val1_m = LW(psrc_ld_m + 4); \
|
||||
val_m = (uint64_t)(val1_m); /* NOLINT */ \
|
||||
val_m = (uint64_t)((val_m << 32) & 0xFFFFFFFF00000000); /* NOLINT */ \
|
||||
val_m = (uint64_t)(val_m | (uint64_t)val0_m); /* NOLINT */ \
|
||||
val_m; \
|
||||
})
|
||||
#endif // (__mips == 64)
|
||||
|
||||
#define SW(val, pdst) \
|
||||
({ \
|
||||
uint8_t* pdst_sw_m = (uint8_t*)(pdst); /* NOLINT */ \
|
||||
uint32_t val_m = (val); \
|
||||
asm volatile("usw %[val_m], %[pdst_sw_m] \n" \
|
||||
: [pdst_sw_m] "=m"(*pdst_sw_m) \
|
||||
: [val_m] "r"(val_m)); \
|
||||
})
|
||||
|
||||
#define SD(val, pdst) \
|
||||
({ \
|
||||
uint8_t* pdst_sd_m = (uint8_t*)(pdst); /* NOLINT */ \
|
||||
uint32_t val0_m, val1_m; \
|
||||
val0_m = (uint32_t)((val)&0x00000000FFFFFFFF); \
|
||||
val1_m = (uint32_t)(((val) >> 32) & 0x00000000FFFFFFFF); \
|
||||
SW(val0_m, pdst_sd_m); \
|
||||
SW(val1_m, pdst_sd_m + 4); \
|
||||
})
|
||||
#endif // (__mips_isa_rev >= 6)
|
||||
|
||||
// TODO(fbarchard): Consider removing __VAR_ARGS versions.
|
||||
#define LD_B(RTYPE, psrc) *((RTYPE*)(psrc)) /* NOLINT */
|
||||
#define LD_UB(...) LD_B(const v16u8, __VA_ARGS__)
|
||||
|
||||
#define ST_B(RTYPE, in, pdst) *((RTYPE*)(pdst)) = (in) /* NOLINT */
|
||||
#define ST_UB(...) ST_B(v16u8, __VA_ARGS__)
|
||||
|
||||
#define ST_H(RTYPE, in, pdst) *((RTYPE*)(pdst)) = (in) /* NOLINT */
|
||||
#define ST_UH(...) ST_H(v8u16, __VA_ARGS__)
|
||||
|
||||
/* Description : Load two vectors with 16 'byte' sized elements
|
||||
Arguments : Inputs - psrc, stride
|
||||
Outputs - out0, out1
|
||||
Return Type - as per RTYPE
|
||||
Details : Load 16 byte elements in 'out0' from (psrc)
|
||||
Load 16 byte elements in 'out1' from (psrc + stride)
|
||||
*/
|
||||
#define LD_B2(RTYPE, psrc, stride, out0, out1) \
|
||||
{ \
|
||||
out0 = LD_B(RTYPE, (psrc)); \
|
||||
out1 = LD_B(RTYPE, (psrc) + stride); \
|
||||
}
|
||||
#define LD_UB2(...) LD_B2(const v16u8, __VA_ARGS__)
|
||||
|
||||
#define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) \
|
||||
{ \
|
||||
LD_B2(RTYPE, (psrc), stride, out0, out1); \
|
||||
LD_B2(RTYPE, (psrc) + 2 * stride, stride, out2, out3); \
|
||||
}
|
||||
#define LD_UB4(...) LD_B4(const v16u8, __VA_ARGS__)
|
||||
|
||||
/* Description : Store two vectors with stride each having 16 'byte' sized
|
||||
elements
|
||||
Arguments : Inputs - in0, in1, pdst, stride
|
||||
Details : Store 16 byte elements from 'in0' to (pdst)
|
||||
Store 16 byte elements from 'in1' to (pdst + stride)
|
||||
*/
|
||||
#define ST_B2(RTYPE, in0, in1, pdst, stride) \
|
||||
{ \
|
||||
ST_B(RTYPE, in0, (pdst)); \
|
||||
ST_B(RTYPE, in1, (pdst) + stride); \
|
||||
}
|
||||
#define ST_UB2(...) ST_B2(v16u8, __VA_ARGS__)
|
||||
|
||||
#define ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride) \
|
||||
{ \
|
||||
ST_B2(RTYPE, in0, in1, (pdst), stride); \
|
||||
ST_B2(RTYPE, in2, in3, (pdst) + 2 * stride, stride); \
|
||||
}
|
||||
#define ST_UB4(...) ST_B4(v16u8, __VA_ARGS__)
|
||||
|
||||
/* Description : Store vectors of 8 halfword elements with stride
|
||||
Arguments : Inputs - in0, in1, pdst, stride
|
||||
Details : Store 8 halfword elements from 'in0' to (pdst)
|
||||
Store 8 halfword elements from 'in1' to (pdst + stride)
|
||||
*/
|
||||
#define ST_H2(RTYPE, in0, in1, pdst, stride) \
|
||||
{ \
|
||||
ST_H(RTYPE, in0, (pdst)); \
|
||||
ST_H(RTYPE, in1, (pdst) + stride); \
|
||||
}
|
||||
#define ST_UH2(...) ST_H2(v8u16, __VA_ARGS__)
|
||||
|
||||
// TODO(fbarchard): Consider using __msa_vshf_b and __msa_ilvr_b directly.
|
||||
/* Description : Shuffle byte vector elements as per mask vector
|
||||
Arguments : Inputs - in0, in1, in2, in3, mask0, mask1
|
||||
Outputs - out0, out1
|
||||
Return Type - as per RTYPE
|
||||
Details : Byte elements from 'in0' & 'in1' are copied selectively to
|
||||
'out0' as per control vector 'mask0'
|
||||
*/
|
||||
#define VSHF_B2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) \
|
||||
{ \
|
||||
out0 = (RTYPE)__msa_vshf_b((v16i8)mask0, (v16i8)in1, (v16i8)in0); \
|
||||
out1 = (RTYPE)__msa_vshf_b((v16i8)mask1, (v16i8)in3, (v16i8)in2); \
|
||||
}
|
||||
#define VSHF_B2_UB(...) VSHF_B2(v16u8, __VA_ARGS__)
|
||||
|
||||
/* Description : Interleave both left and right half of input vectors
|
||||
Arguments : Inputs - in0, in1
|
||||
Outputs - out0, out1
|
||||
Return Type - as per RTYPE
|
||||
Details : Right half of byte elements from 'in0' and 'in1' are
|
||||
interleaved and written to 'out0'
|
||||
*/
|
||||
#define ILVRL_B2(RTYPE, in0, in1, out0, out1) \
|
||||
{ \
|
||||
out0 = (RTYPE)__msa_ilvr_b((v16i8)in0, (v16i8)in1); \
|
||||
out1 = (RTYPE)__msa_ilvl_b((v16i8)in0, (v16i8)in1); \
|
||||
}
|
||||
#define ILVRL_B2_UB(...) ILVRL_B2(v16u8, __VA_ARGS__)
|
||||
|
||||
#endif /* !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) */
|
||||
|
||||
#endif // INCLUDE_LIBYUV_MACROS_MSA_H_
|
||||
@@ -11,6 +11,9 @@
|
||||
#ifndef INCLUDE_LIBYUV_MJPEG_DECODER_H_
|
||||
#define INCLUDE_LIBYUV_MJPEG_DECODER_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -26,7 +29,7 @@ namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
LIBYUV_BOOL ValidateJpeg(const uint8_t* sample, size_t sample_size);
|
||||
int ValidateJpeg(const uint8_t* sample, size_t sample_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
@@ -81,11 +84,11 @@ class LIBYUV_API MJpegDecoder {
|
||||
|
||||
// Loads a new frame, reads its headers, and determines the uncompressed
|
||||
// image format.
|
||||
// Returns LIBYUV_TRUE if image looks valid and format is supported.
|
||||
// If return value is LIBYUV_TRUE, then the values for all the following
|
||||
// Returns true if image looks valid and format is supported.
|
||||
// If return value is true, then the values for all the following
|
||||
// getters are populated.
|
||||
// src_len is the size of the compressed mjpeg frame in bytes.
|
||||
LIBYUV_BOOL LoadFrame(const uint8_t* src, size_t src_len);
|
||||
bool LoadFrame(const uint8_t* src, size_t src_len);
|
||||
|
||||
// Returns width of the last loaded frame in pixels.
|
||||
int GetWidth();
|
||||
@@ -129,7 +132,7 @@ class LIBYUV_API MJpegDecoder {
|
||||
|
||||
// Call this after LoadFrame() if you decide you don't want to decode it
|
||||
// after all.
|
||||
LIBYUV_BOOL UnloadFrame();
|
||||
bool UnloadFrame();
|
||||
|
||||
// Decodes the entire image into a one-buffer-per-color-component format.
|
||||
// dst_width must match exactly. dst_height must be <= to image height; if
|
||||
@@ -138,16 +141,16 @@ class LIBYUV_API MJpegDecoder {
|
||||
// at least GetComponentSize(i). The pointers in planes are incremented
|
||||
// to point to after the end of the written data.
|
||||
// TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded.
|
||||
LIBYUV_BOOL DecodeToBuffers(uint8_t** planes, int dst_width, int dst_height);
|
||||
bool DecodeToBuffers(uint8_t** planes, int dst_width, int dst_height);
|
||||
|
||||
// Decodes the entire image and passes the data via repeated calls to a
|
||||
// callback function. Each call will get the data for a whole number of
|
||||
// image scanlines.
|
||||
// TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded.
|
||||
LIBYUV_BOOL DecodeToCallback(CallbackFunction fn,
|
||||
void* opaque,
|
||||
int dst_width,
|
||||
int dst_height);
|
||||
bool DecodeToCallback(CallbackFunction fn,
|
||||
void* opaque,
|
||||
int dst_width,
|
||||
int dst_height);
|
||||
|
||||
// The helper function which recognizes the jpeg sub-sampling type.
|
||||
static JpegSubsamplingType JpegSubsamplingTypeHelper(
|
||||
@@ -159,13 +162,11 @@ class LIBYUV_API MJpegDecoder {
|
||||
void AllocOutputBuffers(int num_outbufs);
|
||||
void DestroyOutputBuffers();
|
||||
|
||||
LIBYUV_BOOL StartDecode();
|
||||
LIBYUV_BOOL FinishDecode();
|
||||
bool StartDecode();
|
||||
bool FinishDecode();
|
||||
|
||||
void SetScanlinePointers(uint8_t** data);
|
||||
LIBYUV_BOOL DecodeImcuRow();
|
||||
|
||||
int GetComponentScanlinePadding(int component);
|
||||
bool DecodeImcuRow();
|
||||
|
||||
// A buffer holding the input data for a frame.
|
||||
Buffer buf_;
|
||||
@@ -175,9 +176,9 @@ class LIBYUV_API MJpegDecoder {
|
||||
jpeg_source_mgr* source_mgr_;
|
||||
SetJmpErrorMgr* error_mgr_;
|
||||
|
||||
// LIBYUV_TRUE iff at least one component has scanline padding. (i.e.,
|
||||
// true iff at least one component has scanline padding. (i.e.,
|
||||
// GetComponentScanlinePadding() != 0.)
|
||||
LIBYUV_BOOL has_scanline_padding_;
|
||||
bool has_scanline_padding_;
|
||||
|
||||
// Temporaries used to point to scanline outputs.
|
||||
int num_outbufs_; // Outermost size of all arrays below.
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#ifndef INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_
|
||||
#define INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
// TODO(fbarchard): Remove the following headers includes.
|
||||
@@ -22,24 +25,6 @@ namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// TODO(fbarchard): Move cpu macros to row.h
|
||||
#if defined(__pnacl__) || defined(__CLR_VER) || \
|
||||
(defined(__native_client__) && defined(__x86_64__)) || \
|
||||
(defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
|
||||
#define LIBYUV_DISABLE_X86
|
||||
#endif
|
||||
// MemorySanitizer does not support assembly code yet. http://crbug.com/344505
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
#define LIBYUV_DISABLE_X86
|
||||
#endif
|
||||
#endif
|
||||
// The following are available on all x86 platforms:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && \
|
||||
(defined(_M_IX86) || defined(__x86_64__) || defined(__i386__))
|
||||
#define HAS_ARGBAFFINEROW_SSE2
|
||||
#endif
|
||||
|
||||
// Copy a plane of data.
|
||||
LIBYUV_API
|
||||
void CopyPlane(const uint8_t* src_y,
|
||||
@@ -66,14 +51,28 @@ void Convert16To8Plane(const uint16_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert 8 bit Y to 10/12/16 bit.
|
||||
// "bits" accepts bit depths (10, 12, 16) or legacy scale values (1024, 4096,
|
||||
// 65536).
|
||||
LIBYUV_API
|
||||
void Convert8To16Plane(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
int scale, // 1024 for 10 bits
|
||||
int width,
|
||||
int height);
|
||||
void Convert8To16Plane(
|
||||
const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
int bits, // 10, 12, 16 bits (or 1024, 4096, 65536 scale)
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
void Convert8To8Plane(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
int scale, // 220 for Y, 225 for U,V
|
||||
int bias, // 16
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Set a plane of data to a 32 bit value.
|
||||
LIBYUV_API
|
||||
@@ -83,6 +82,50 @@ void SetPlane(uint8_t* dst_y,
|
||||
int height,
|
||||
uint32_t value);
|
||||
|
||||
// Convert a plane of tiles of 16 x H to linear.
|
||||
LIBYUV_API
|
||||
int DetilePlane(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
int width,
|
||||
int height,
|
||||
int tile_height);
|
||||
|
||||
// Convert a plane of 16 bit tiles of 16 x H to linear.
|
||||
LIBYUV_API
|
||||
int DetilePlane_16(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
int width,
|
||||
int height,
|
||||
int tile_height);
|
||||
|
||||
// Convert a UV plane of tiles of 16 x H into linear U and V planes.
|
||||
LIBYUV_API
|
||||
void DetileSplitUVPlane(const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
int tile_height);
|
||||
|
||||
// Convert a Y and UV plane of tiles into interlaced YUY2.
|
||||
LIBYUV_API
|
||||
void DetileToYUY2(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_yuy2,
|
||||
int dst_stride_yuy2,
|
||||
int width,
|
||||
int height,
|
||||
int tile_height);
|
||||
|
||||
// Split interleaved UV plane into separate U and V planes.
|
||||
LIBYUV_API
|
||||
void SplitUVPlane(const uint8_t* src_uv,
|
||||
@@ -105,6 +148,63 @@ void MergeUVPlane(const uint8_t* src_u,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Split interleaved msb UV plane into separate lsb U and V planes.
|
||||
LIBYUV_API
|
||||
void SplitUVPlane_16(const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
int depth);
|
||||
|
||||
// Merge separate lsb U and V planes into one interleaved msb UV plane.
|
||||
LIBYUV_API
|
||||
void MergeUVPlane_16(const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height,
|
||||
int depth);
|
||||
|
||||
// Convert lsb plane to msb plane
|
||||
LIBYUV_API
|
||||
void ConvertToMSBPlane_16(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
int width,
|
||||
int height,
|
||||
int depth);
|
||||
|
||||
// Convert msb plane to lsb plane
|
||||
LIBYUV_API
|
||||
void ConvertToLSBPlane_16(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
int width,
|
||||
int height,
|
||||
int depth);
|
||||
|
||||
// Scale U and V to half width and height and merge into interleaved UV plane.
|
||||
// width and height are source size, allowing odd sizes.
|
||||
// Use for converting I444 or I422 to NV12.
|
||||
LIBYUV_API
|
||||
void HalfMergeUVPlane(const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Swap U and V channels in interleaved UV plane.
|
||||
LIBYUV_API
|
||||
void SwapUVPlane(const uint8_t* src_uv,
|
||||
@@ -140,6 +240,92 @@ void MergeRGBPlane(const uint8_t* src_r,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Split interleaved ARGB plane into separate R, G, B and A planes.
|
||||
// dst_a can be NULL to discard alpha plane.
|
||||
LIBYUV_API
|
||||
void SplitARGBPlane(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_r,
|
||||
int dst_stride_r,
|
||||
uint8_t* dst_g,
|
||||
int dst_stride_g,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Merge separate R, G, B and A planes into one interleaved ARGB plane.
|
||||
// src_a can be NULL to fill opaque value to alpha.
|
||||
LIBYUV_API
|
||||
void MergeARGBPlane(const uint8_t* src_r,
|
||||
int src_stride_r,
|
||||
const uint8_t* src_g,
|
||||
int src_stride_g,
|
||||
const uint8_t* src_b,
|
||||
int src_stride_b,
|
||||
const uint8_t* src_a,
|
||||
int src_stride_a,
|
||||
uint8_t* dst_argb,
|
||||
int dst_stride_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Merge separate 'depth' bit R, G and B planes stored in lsb
|
||||
// into one interleaved XR30 plane.
|
||||
// depth should in range [10, 16]
|
||||
LIBYUV_API
|
||||
void MergeXR30Plane(const uint16_t* src_r,
|
||||
int src_stride_r,
|
||||
const uint16_t* src_g,
|
||||
int src_stride_g,
|
||||
const uint16_t* src_b,
|
||||
int src_stride_b,
|
||||
uint8_t* dst_ar30,
|
||||
int dst_stride_ar30,
|
||||
int width,
|
||||
int height,
|
||||
int depth);
|
||||
|
||||
// Merge separate 'depth' bit R, G, B and A planes stored in lsb
|
||||
// into one interleaved AR64 plane.
|
||||
// src_a can be NULL to fill opaque value to alpha.
|
||||
// depth should in range [1, 16]
|
||||
LIBYUV_API
|
||||
void MergeAR64Plane(const uint16_t* src_r,
|
||||
int src_stride_r,
|
||||
const uint16_t* src_g,
|
||||
int src_stride_g,
|
||||
const uint16_t* src_b,
|
||||
int src_stride_b,
|
||||
const uint16_t* src_a,
|
||||
int src_stride_a,
|
||||
uint16_t* dst_ar64,
|
||||
int dst_stride_ar64,
|
||||
int width,
|
||||
int height,
|
||||
int depth);
|
||||
|
||||
// Merge separate 'depth' bit R, G, B and A planes stored in lsb
|
||||
// into one interleaved ARGB plane.
|
||||
// src_a can be NULL to fill opaque value to alpha.
|
||||
// depth should in range [8, 16]
|
||||
LIBYUV_API
|
||||
void MergeARGB16To8Plane(const uint16_t* src_r,
|
||||
int src_stride_r,
|
||||
const uint16_t* src_g,
|
||||
int src_stride_g,
|
||||
const uint16_t* src_b,
|
||||
int src_stride_b,
|
||||
const uint16_t* src_a,
|
||||
int src_stride_a,
|
||||
uint8_t* dst_argb,
|
||||
int dst_stride_argb,
|
||||
int width,
|
||||
int height,
|
||||
int depth);
|
||||
|
||||
// Copy I400. Supports inverting.
|
||||
LIBYUV_API
|
||||
int I400ToI400(const uint8_t* src_y,
|
||||
@@ -187,6 +373,68 @@ int I444Copy(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Copy I210 to I210.
|
||||
#define I210ToI210 I210Copy
|
||||
LIBYUV_API
|
||||
int I210Copy(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Copy I410 to I410.
|
||||
#define I410ToI410 I410Copy
|
||||
LIBYUV_API
|
||||
int I410Copy(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Copy NV12. Supports inverting.
|
||||
LIBYUV_API
|
||||
int NV12Copy(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Copy NV21. Supports inverting.
|
||||
LIBYUV_API
|
||||
int NV21Copy(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_vu,
|
||||
int src_stride_vu,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_vu,
|
||||
int dst_stride_vu,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert YUY2 to I422.
|
||||
LIBYUV_API
|
||||
int YUY2ToI422(const uint8_t* src_yuy2,
|
||||
@@ -233,19 +481,22 @@ int UYVYToNV12(const uint8_t* src_uyvy,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert NV21 to NV12.
|
||||
// Convert NV12 to NV21.
|
||||
LIBYUV_API
|
||||
int NV21ToNV12(const uint8_t* src_y,
|
||||
int NV12ToNV21(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_vu,
|
||||
int src_stride_vu,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
uint8_t* dst_vu,
|
||||
int dst_stride_vu,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Alias
|
||||
#define NV21ToNV12 NV12ToNV21
|
||||
|
||||
LIBYUV_API
|
||||
int YUY2ToY(const uint8_t* src_yuy2,
|
||||
int src_stride_yuy2,
|
||||
@@ -254,6 +505,14 @@ int YUY2ToY(const uint8_t* src_yuy2,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
int UYVYToY(const uint8_t* src_uyvy,
|
||||
int src_stride_uyvy,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I420 to I400. (calls CopyPlane ignoring u/v).
|
||||
LIBYUV_API
|
||||
int I420ToI400(const uint8_t* src_y,
|
||||
@@ -301,6 +560,22 @@ int I400Mirror(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Alias
|
||||
#define NV12ToNV12Mirror NV12Mirror
|
||||
|
||||
// NV12 mirror.
|
||||
LIBYUV_API
|
||||
int NV12Mirror(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Alias
|
||||
#define ARGBToARGBMirror ARGBMirror
|
||||
|
||||
@@ -313,56 +588,44 @@ int ARGBMirror(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert NV12 to RGB565.
|
||||
// Alias
|
||||
#define RGB24ToRGB24Mirror RGB24Mirror
|
||||
|
||||
// RGB24 mirror.
|
||||
LIBYUV_API
|
||||
int NV12ToRGB565(const uint8_t* src_y,
|
||||
int RGB24Mirror(const uint8_t* src_rgb24,
|
||||
int src_stride_rgb24,
|
||||
uint8_t* dst_rgb24,
|
||||
int dst_stride_rgb24,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Mirror a plane of data.
|
||||
LIBYUV_API
|
||||
void MirrorPlane(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_rgb565,
|
||||
int dst_stride_rgb565,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// I422ToARGB is in convert_argb.h
|
||||
// Convert I422 to BGRA.
|
||||
// Mirror a plane of 16-bit data.
|
||||
LIBYUV_API
|
||||
int I422ToBGRA(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_bgra,
|
||||
int dst_stride_bgra,
|
||||
int width,
|
||||
int height);
|
||||
void MirrorPlane_16(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I422 to ABGR.
|
||||
// Mirror a plane of UV data.
|
||||
LIBYUV_API
|
||||
int I422ToABGR(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_abgr,
|
||||
int dst_stride_abgr,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Convert I422 to RGBA.
|
||||
LIBYUV_API
|
||||
int I422ToRGBA(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_rgba,
|
||||
int dst_stride_rgba,
|
||||
int width,
|
||||
int height);
|
||||
void MirrorUVPlane(const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Alias
|
||||
#define RGB24ToRAW RAWToRGB24
|
||||
@@ -511,6 +774,10 @@ int ARGBPolynomial(const uint8_t* src_argb,
|
||||
|
||||
// Convert plane of 16 bit shorts to half floats.
|
||||
// Source values are multiplied by scale before storing as half float.
|
||||
//
|
||||
// Note: Unlike other libyuv functions that operate on uint16_t buffers, the
|
||||
// src_stride_y and dst_stride_y parameters of HalfFloatPlane() are in bytes,
|
||||
// not in units of uint16_t.
|
||||
LIBYUV_API
|
||||
int HalfFloatPlane(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
@@ -575,15 +842,6 @@ int ARGBCopyYToAlpha(const uint8_t* src_y,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
typedef void (*ARGBBlendRow)(const uint8_t* src_argb0,
|
||||
const uint8_t* src_argb1,
|
||||
uint8_t* dst_argb,
|
||||
int width);
|
||||
|
||||
// Get function to Alpha Blend ARGB pixels and store to destination.
|
||||
LIBYUV_API
|
||||
ARGBBlendRow GetARGBBlend(void);
|
||||
|
||||
// Alpha Blend ARGB images and store to destination.
|
||||
// Source is pre-multiplied by alpha using ARGBAttenuate.
|
||||
// Alpha of destination is set to 255.
|
||||
@@ -597,6 +855,18 @@ int ARGBBlend(const uint8_t* src_argb0,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Alpha Blend unattenuated ARGB images and store to destination.
|
||||
// Source and destination are not pre-multiplied by alpha.
|
||||
LIBYUV_API
|
||||
int ARGBAlphaBlend(const uint8_t* src_argb0,
|
||||
int src_stride_argb0,
|
||||
const uint8_t* src_argb1,
|
||||
int src_stride_argb1,
|
||||
uint8_t* dst_argb,
|
||||
int dst_stride_argb,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Alpha Blend plane and store to destination.
|
||||
// Source is not pre-multiplied by alpha.
|
||||
LIBYUV_API
|
||||
@@ -671,6 +941,17 @@ int ARGBSubtract(const uint8_t* src_argb0,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Bitwise OR ARGB image with a specified ARGB value (e.g. 0xff000000 to force
|
||||
// opaque alpha).
|
||||
LIBYUV_API
|
||||
int ARGBOr(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_argb,
|
||||
int dst_stride_argb,
|
||||
int width,
|
||||
int height,
|
||||
uint32_t value);
|
||||
|
||||
// Convert I422 to YUY2.
|
||||
LIBYUV_API
|
||||
int I422ToYUY2(const uint8_t* src_y,
|
||||
@@ -743,6 +1024,19 @@ int ARGBBlur(const uint8_t* src_argb,
|
||||
int height,
|
||||
int radius);
|
||||
|
||||
// Gaussian 5x5 blur a float plane.
|
||||
// Coefficients of 1, 4, 6, 4, 1.
|
||||
// Each destination pixel is a blur of the 5x5
|
||||
// pixels from the source.
|
||||
// Source edges are clamped.
|
||||
LIBYUV_API
|
||||
int GaussPlane_F32(const float* src,
|
||||
int src_stride,
|
||||
float* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Multiply ARGB image by ARGB value.
|
||||
LIBYUV_API
|
||||
int ARGBShade(const uint8_t* src_argb,
|
||||
@@ -768,6 +1062,21 @@ int InterpolatePlane(const uint8_t* src0,
|
||||
int height,
|
||||
int interpolation);
|
||||
|
||||
// Interpolate between two images using specified amount of interpolation
|
||||
// (0 to 255) and store to destination.
|
||||
// 'interpolation' is specified as 8 bit fraction where 0 means 100% src0
|
||||
// and 255 means 1% src0 and 99% src1.
|
||||
LIBYUV_API
|
||||
int InterpolatePlane_16(const uint16_t* src0,
|
||||
int src_stride0, // measured in 16 bit pixels
|
||||
const uint16_t* src1,
|
||||
int src_stride1,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height,
|
||||
int interpolation);
|
||||
|
||||
// Interpolate between two ARGB images using specified amount of interpolation
|
||||
// Internally calls InterpolatePlane with width * 4 (bpp).
|
||||
LIBYUV_API
|
||||
@@ -807,33 +1116,28 @@ int I420Interpolate(const uint8_t* src0_y,
|
||||
int height,
|
||||
int interpolation);
|
||||
|
||||
// Row function for copying pixels from a source with a slope to a row
|
||||
// of destination. Useful for scaling, rotation, mirror, texture mapping.
|
||||
LIBYUV_API
|
||||
void ARGBAffineRow_C(const uint8_t* src_argb,
|
||||
int src_argb_stride,
|
||||
uint8_t* dst_argb,
|
||||
const float* uv_dudv,
|
||||
int width);
|
||||
// TODO(fbarchard): Move ARGBAffineRow_SSE2 to row.h
|
||||
LIBYUV_API
|
||||
void ARGBAffineRow_SSE2(const uint8_t* src_argb,
|
||||
int src_argb_stride,
|
||||
uint8_t* dst_argb,
|
||||
const float* uv_dudv,
|
||||
int width);
|
||||
|
||||
// Shuffle ARGB channel order. e.g. BGRA to ARGB.
|
||||
// shuffler is 16 bytes and must be aligned.
|
||||
// shuffler is 16 bytes.
|
||||
LIBYUV_API
|
||||
int ARGBShuffle(const uint8_t* src_bgra,
|
||||
int src_stride_bgra,
|
||||
int ARGBShuffle(const uint8_t* src_argb,
|
||||
int src_stride_argb,
|
||||
uint8_t* dst_argb,
|
||||
int dst_stride_argb,
|
||||
const uint8_t* shuffler,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Shuffle AR64 channel order. e.g. AR64 to AB64.
|
||||
// shuffler is 16 bytes.
|
||||
LIBYUV_API
|
||||
int AR64Shuffle(const uint16_t* src_ar64,
|
||||
int src_stride_ar64,
|
||||
uint16_t* dst_ar64,
|
||||
int dst_stride_ar64,
|
||||
const uint8_t* shuffler,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Sobel ARGB effect with planar output.
|
||||
LIBYUV_API
|
||||
int ARGBSobelToPlane(const uint8_t* src_argb,
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#ifndef INCLUDE_LIBYUV_ROTATE_H_
|
||||
#define INCLUDE_LIBYUV_ROTATE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -49,6 +51,24 @@ int I420Rotate(const uint8_t* src_y,
|
||||
int height,
|
||||
enum RotationMode mode);
|
||||
|
||||
// Rotate I422 frame.
|
||||
LIBYUV_API
|
||||
int I422Rotate(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
enum RotationMode mode);
|
||||
|
||||
// Rotate I444 frame.
|
||||
LIBYUV_API
|
||||
int I444Rotate(const uint8_t* src_y,
|
||||
@@ -67,6 +87,60 @@ int I444Rotate(const uint8_t* src_y,
|
||||
int height,
|
||||
enum RotationMode mode);
|
||||
|
||||
// Rotate I010 frame.
|
||||
LIBYUV_API
|
||||
int I010Rotate(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
enum RotationMode mode);
|
||||
|
||||
// Rotate I210 frame.
|
||||
LIBYUV_API
|
||||
int I210Rotate(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
enum RotationMode mode);
|
||||
|
||||
// Rotate I410 frame.
|
||||
LIBYUV_API
|
||||
int I410Rotate(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
enum RotationMode mode);
|
||||
|
||||
// Rotate NV12 input and store in I420.
|
||||
LIBYUV_API
|
||||
int NV12ToI420Rotate(const uint8_t* src_y,
|
||||
@@ -83,6 +157,26 @@ int NV12ToI420Rotate(const uint8_t* src_y,
|
||||
int height,
|
||||
enum RotationMode mode);
|
||||
|
||||
// Convert Android420 to I420 with rotation.
|
||||
// "rotation" can be 0, 90, 180 or 270.
|
||||
LIBYUV_API
|
||||
int Android420ToI420Rotate(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
int src_pixel_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
enum RotationMode rotation);
|
||||
|
||||
// Rotate a plane by 0, 90, 180, or 270.
|
||||
LIBYUV_API
|
||||
int RotatePlane(const uint8_t* src,
|
||||
@@ -118,39 +212,61 @@ void RotatePlane270(const uint8_t* src,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// Rotate a plane by 0, 90, 180, or 270.
|
||||
LIBYUV_API
|
||||
void RotateUV90(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
int RotatePlane_16(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height,
|
||||
enum RotationMode mode);
|
||||
|
||||
// Rotations for when U and V are interleaved.
|
||||
// These functions take one input pointer and
|
||||
// These functions take one UV input pointer and
|
||||
// split the data into two buffers while
|
||||
// rotating them. Deprecated.
|
||||
// rotating them.
|
||||
// width and height expected to be half size for NV12.
|
||||
LIBYUV_API
|
||||
void RotateUV180(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
int SplitRotateUV(const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height,
|
||||
enum RotationMode mode);
|
||||
|
||||
LIBYUV_API
|
||||
void RotateUV270(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
void SplitRotateUV90(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
void SplitRotateUV180(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
void SplitRotateUV270(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
// The 90 and 270 functions are based on transposes.
|
||||
// Doing a transpose with reversing the read/write
|
||||
@@ -165,14 +281,14 @@ void TransposePlane(const uint8_t* src,
|
||||
int height);
|
||||
|
||||
LIBYUV_API
|
||||
void TransposeUV(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
void SplitTransposeUV(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#ifndef INCLUDE_LIBYUV_ROTATE_ARGB_H_
|
||||
#define INCLUDE_LIBYUV_ROTATE_ARGB_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
#include "libyuv/rotate.h" // For RotationMode.
|
||||
|
||||
|
||||
@@ -11,66 +11,133 @@
|
||||
#ifndef INCLUDE_LIBYUV_ROTATE_ROW_H_
|
||||
#define INCLUDE_LIBYUV_ROTATE_ROW_H_
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/cpu_support.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__pnacl__) || defined(__CLR_VER) || \
|
||||
(defined(__native_client__) && defined(__x86_64__)) || \
|
||||
(defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
|
||||
#define LIBYUV_DISABLE_X86
|
||||
// The following are available for Visual C 32/64 bit, and for clang with
|
||||
// LIBYUV_ENABLE_ROWWIN, which is also enabled for MemorySanitizer. These are
|
||||
// intrinsics in rotate_win.cc.
|
||||
#if !defined(LIBYUV_DISABLE_X86) && \
|
||||
(defined(__x86_64__) || defined(__i386__) || defined(_M_X64) || \
|
||||
defined(_M_IX86)) && \
|
||||
((defined(_MSC_VER) && !defined(__clang__)) || \
|
||||
defined(LIBYUV_ENABLE_ROWWIN))
|
||||
#if defined(VISUALC_HAS_AVX2)
|
||||
#define HAS_TRANSPOSEWX8_AVX2
|
||||
#define HAS_TRANSPOSEUVWX8_AVX2
|
||||
#define HAS_TRANSPOSEWX8_16_AVX2
|
||||
#define HAS_TRANSPOSEWX16_16_AVX2
|
||||
#define HAS_TRANSPOSEWX4_32_AVX2
|
||||
#define HAS_TRANSPOSEWX8_32_AVX2
|
||||
#define HAS_TRANSPOSEWXH_32_AVX2
|
||||
#define HAS_TRANSPOSEWX16_AVX2
|
||||
#define HAS_TRANSPOSEUVWX16_AVX2
|
||||
#endif
|
||||
#if defined(__native_client__)
|
||||
#define LIBYUV_DISABLE_NEON
|
||||
#if defined(VISUALC_HAS_AVX512)
|
||||
#define HAS_TRANSPOSEWX16_AVX512BW
|
||||
#define HAS_TRANSPOSEUVWX16_AVX512BW
|
||||
#define HAS_TRANSPOSEWX32_16_AVX512BW
|
||||
#define HAS_TRANSPOSEWX16_32_AVX512BW
|
||||
#endif
|
||||
// MemorySanitizer does not support assembly code yet. http://crbug.com/344505
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
#define LIBYUV_DISABLE_X86
|
||||
#endif
|
||||
#endif
|
||||
// The following are available for Visual C and clangcl 32 bit:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER)
|
||||
#define HAS_TRANSPOSEWX8_SSSE3
|
||||
#define HAS_TRANSPOSEUVWX8_SSE2
|
||||
#endif
|
||||
|
||||
// The following are available for GCC 32 or 64 bit:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && (defined(__i386__) || defined(__x86_64__))
|
||||
#define HAS_TRANSPOSEWX8_SSSE3
|
||||
// The following are available for 32/64 bit GCC and clang, as inline assembly
|
||||
// in rotate_gcc.cc:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && \
|
||||
(defined(__x86_64__) || defined(__i386__)) && \
|
||||
(defined(CLANG_HAS_AVX2) || defined(GCC_HAS_AVX2)) && \
|
||||
!defined(LIBYUV_ENABLE_ROWWIN) && \
|
||||
(!defined(_MSC_VER) || defined(__clang__))
|
||||
#define HAS_TRANSPOSEWX8_AVX2
|
||||
#define HAS_TRANSPOSEUVWX8_AVX2
|
||||
#define HAS_TRANSPOSEWX8_16_AVX2
|
||||
#define HAS_TRANSPOSEWX16_16_AVX2
|
||||
#define HAS_TRANSPOSEWX4_32_AVX2
|
||||
#define HAS_TRANSPOSEWX8_32_AVX2
|
||||
#define HAS_TRANSPOSEWXH_32_AVX2
|
||||
#define HAS_TRANSPOSEWX16_AVX2
|
||||
#define HAS_TRANSPOSEUVWX16_AVX2
|
||||
#endif
|
||||
|
||||
// The following are available for 64 bit GCC:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && defined(__x86_64__)
|
||||
#define HAS_TRANSPOSEWX8_FAST_SSSE3
|
||||
#define HAS_TRANSPOSEUVWX8_SSE2
|
||||
// The following are available for AVX512 GCC/clang x64 platforms:
|
||||
#if !defined(LIBYUV_DISABLE_X86) && defined(__x86_64__) && \
|
||||
(defined(CLANG_HAS_AVX512) || defined(GCC_HAS_AVX512)) && \
|
||||
!defined(LIBYUV_ENABLE_ROWWIN) && \
|
||||
(!defined(_MSC_VER) || defined(__clang__))
|
||||
#define HAS_TRANSPOSEWX16_AVX512BW
|
||||
#define HAS_TRANSPOSEUVWX16_AVX512BW
|
||||
#define HAS_TRANSPOSEWX32_16_AVX512BW
|
||||
#define HAS_TRANSPOSEWX16_32_AVX512BW
|
||||
#endif
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_NEON) && \
|
||||
(defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__))
|
||||
#if defined(__aarch64__)
|
||||
#define HAS_TRANSPOSEWX16_NEON
|
||||
#else
|
||||
#define HAS_TRANSPOSEWX8_NEON
|
||||
#endif
|
||||
#define HAS_TRANSPOSEUVWX8_NEON
|
||||
#define HAS_TRANSPOSEWX8_16_NEON
|
||||
#define HAS_TRANSPOSEWX4_32_NEON
|
||||
#define HAS_TRANSPOSEWXH_32_NEON
|
||||
#endif
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
|
||||
#define HAS_TRANSPOSEWX16_MSA
|
||||
#define HAS_TRANSPOSEUVWX16_MSA
|
||||
#if !defined(LIBYUV_DISABLE_SVE) && defined(__aarch64__)
|
||||
#define HAS_TRANSPOSEWX8_16_SVE2
|
||||
#define HAS_TRANSPOSEWX4_32_SVE2
|
||||
#endif
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A)
|
||||
#define HAS_TRANSPOSEWX8_MMI
|
||||
#define HAS_TRANSPOSEUVWX8_MMI
|
||||
#if !defined(LIBYUV_DISABLE_SME) && defined(CLANG_HAS_SME) && \
|
||||
defined(__aarch64__)
|
||||
#define HAS_TRANSPOSEWXH_SME
|
||||
#define HAS_TRANSPOSEUVWXH_SME
|
||||
#define HAS_TRANSPOSEWXH_16_SME
|
||||
#define HAS_TRANSPOSEWXH_32_SME
|
||||
#endif
|
||||
|
||||
void TransposeWxH_C(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
#if !defined(LIBYUV_DISABLE_LSX) && defined(__loongarch_sx)
|
||||
#define HAS_TRANSPOSEWX8_LSX
|
||||
#define HAS_TRANSPOSEUVWX8_LSX
|
||||
#define HAS_TRANSPOSEWX8_16_LSX
|
||||
#define HAS_TRANSPOSEWX4_32_LSX
|
||||
#endif
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_LASX) && defined(__loongarch_asx)
|
||||
#define HAS_TRANSPOSEWX16_LASX
|
||||
#define HAS_TRANSPOSEUVWX16_LASX
|
||||
#define HAS_TRANSPOSEWX16_16_LASX
|
||||
#define HAS_TRANSPOSEWX4_32_LASX
|
||||
#endif
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector)
|
||||
#define HAS_TRANSPOSEWXH_16_RVV
|
||||
#define HAS_TRANSPOSEWX4_32_RVV
|
||||
#define HAS_TRANSPOSEWXH_32_RVV
|
||||
#endif
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_WASM) && defined(__wasm_simd128__)
|
||||
#define HAS_TRANSPOSEWX8_WASMSIMD
|
||||
#define HAS_TRANSPOSEUVWX8_WASMSIMD
|
||||
#define HAS_TRANSPOSEWX16_WASMSIMD
|
||||
#define HAS_TRANSPOSEUVWX16_WASMSIMD
|
||||
#define HAS_TRANSPOSEWX8_16_WASMSIMD
|
||||
#define HAS_TRANSPOSEWX4_32_WASMSIMD
|
||||
#endif
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_HVX) && defined(__HVX__)
|
||||
#define HAS_TRANSPOSEWXH_HVX
|
||||
#define HAS_TRANSPOSEUVWXH_HVX
|
||||
#define HAS_TRANSPOSEWXH_16_HVX
|
||||
#define HAS_TRANSPOSEWXH_32_HVX
|
||||
#endif
|
||||
|
||||
void TransposeWx8_C(const uint8_t* src,
|
||||
int src_stride,
|
||||
@@ -87,61 +154,99 @@ void TransposeWx8_NEON(const uint8_t* src,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_SSSE3(const uint8_t* src,
|
||||
void TransposeWx16_NEON(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_MMI(const uint8_t* src,
|
||||
void TransposeWxH_SME(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_Fast_SSSE3(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_MSA(const uint8_t* src,
|
||||
int width,
|
||||
int height);
|
||||
void TransposeWxH_HVX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
void TransposeWx8_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_AVX512BW(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_LSX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_LASX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_WASMSIMD(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_WASMSIMD(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx8_Any_NEON(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_Any_SSSE3(const uint8_t* src,
|
||||
void TransposeWx16_Any_NEON(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_Any_MMI(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_Fast_Any_SSSE3(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_Any_MSA(const uint8_t* src,
|
||||
void TransposeWx8_Any_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeUVWxH_C(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
void TransposeWx16_Any_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_Any_LSX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_Any_LASX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_Any_WASMSIMD(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_Any_WASMSIMD(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeUVWx8_C(const uint8_t* src,
|
||||
int src_stride,
|
||||
@@ -157,13 +262,27 @@ void TransposeUVWx16_C(const uint8_t* src,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx8_SSE2(const uint8_t* src,
|
||||
void TransposeUVWx8_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx16_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx16_AVX512BW(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx8_NEON(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
@@ -171,22 +290,52 @@ void TransposeUVWx8_NEON(const uint8_t* src,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx8_MMI(const uint8_t* src,
|
||||
void TransposeUVWxH_SME(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
void TransposeUVWxH_HVX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width,
|
||||
int height);
|
||||
void TransposeUVWx8_LSX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx16_MSA(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx16_LASX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx8_WASMSIMD(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx16_WASMSIMD(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
|
||||
void TransposeUVWx8_Any_SSE2(const uint8_t* src,
|
||||
void TransposeUVWx8_Any_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
@@ -200,20 +349,266 @@ void TransposeUVWx8_Any_NEON(const uint8_t* src,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx8_Any_MMI(const uint8_t* src,
|
||||
void TransposeUVWx16_Any_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx8_Any_LSX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx16_Any_MSA(const uint8_t* src,
|
||||
void TransposeUVWx16_Any_LASX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx8_Any_WASMSIMD(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
void TransposeUVWx16_Any_WASMSIMD(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
int width);
|
||||
|
||||
void TransposeWx8_16_C(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_16_AVX2(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_16_AVX2(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx32_16_AVX512BW(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_16_NEON(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_16_SVE2(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWxH_16_SME(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
void TransposeWxH_16_RVV(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
void TransposeWxH_16_HVX(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
void TransposeWx8_16_LSX(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_16_LASX(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_16_WASMSIMD(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_16_Any_AVX2(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_16_Any_AVX2(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_16_Any_NEON(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_16_Any_LSX(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst_a,
|
||||
int dst_stride_a,
|
||||
uint8_t* dst_b,
|
||||
int dst_stride_b,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx16_16_Any_LASX(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
void TransposeWx8_16_Any_WASMSIMD(const uint16_t* src,
|
||||
int src_stride,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWxH_32_C(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
void TransposeWxH_32_SME(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
void TransposeWx4_32_NEON(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWxH_32_NEON(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
void TransposeWx4_32_SVE2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx4_32_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx8_32_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWxH_32_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
void TransposeWx16_32_AVX512BW(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx4_32_RVV(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWxH_32_RVV(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
void TransposeWxH_32_HVX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
void TransposeWx4_32_LSX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx4_32_LASX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx4_32_WASMSIMD(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx4_32_C(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx4_32_Any_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx8_32_Any_AVX2(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx4_32_Any_LSX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx4_32_Any_LASX(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
void TransposeWx4_32_Any_WASMSIMD(const uint8_t* src,
|
||||
int src_stride,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int width);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
+6041
-1529
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -11,6 +11,8 @@
|
||||
#ifndef INCLUDE_LIBYUV_SCALE_H_
|
||||
#define INCLUDE_LIBYUV_SCALE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -27,27 +29,40 @@ typedef enum FilterMode {
|
||||
} FilterModeEnum;
|
||||
|
||||
// Scale a YUV plane.
|
||||
// Returns 0 if successful.
|
||||
LIBYUV_API
|
||||
void ScalePlane(const uint8_t* src,
|
||||
int src_stride,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
int ScalePlane(const uint8_t* src,
|
||||
int src_stride,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint8_t* dst,
|
||||
int dst_stride,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
void ScalePlane_16(const uint16_t* src,
|
||||
int src_stride,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
int ScalePlane_16(const uint16_t* src,
|
||||
int src_stride,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
// Sample is expected to be in the low 12 bits.
|
||||
LIBYUV_API
|
||||
int ScalePlane_12(const uint16_t* src,
|
||||
int src_stride,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst,
|
||||
int dst_stride,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
// Scales a YUV 4:2:0 image from the src width and height to the
|
||||
// dst width and height.
|
||||
@@ -97,6 +112,25 @@ int I420Scale_16(const uint16_t* src_y,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
int I420Scale_12(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
// Scales a YUV 4:4:4 image from the src width and height to the
|
||||
// dst width and height.
|
||||
// If filtering is kFilterNone, a simple nearest-neighbor algorithm is
|
||||
@@ -145,6 +179,197 @@ int I444Scale_16(const uint16_t* src_y,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
int I444Scale_12(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
// Scales a YUV 4:2:2 image from the src width and height to the
|
||||
// dst width and height.
|
||||
// If filtering is kFilterNone, a simple nearest-neighbor algorithm is
|
||||
// used. This produces basic (blocky) quality at the fastest speed.
|
||||
// If filtering is kFilterBilinear, interpolation is used to produce a better
|
||||
// quality image, at the expense of speed.
|
||||
// If filtering is kFilterBox, averaging is used to produce ever better
|
||||
// quality image, at further expense of speed.
|
||||
// Returns 0 if successful.
|
||||
LIBYUV_API
|
||||
int I422Scale(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint8_t* src_v,
|
||||
int src_stride_v,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
int I422Scale_16(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
int I422Scale_12(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_u,
|
||||
int src_stride_u,
|
||||
const uint16_t* src_v,
|
||||
int src_stride_v,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint16_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
// Scales an NV12, NV16 or NV24 image from the src width and height to the
|
||||
// dst width and height.
|
||||
// If filtering is kFilterNone, a simple nearest-neighbor algorithm is
|
||||
// used. This produces basic (blocky) quality at the fastest speed.
|
||||
// If filtering is kFilterBilinear, interpolation is used to produce a better
|
||||
// quality image, at the expense of speed.
|
||||
// kFilterBox is not supported for the UV channel and will be treated as
|
||||
// bilinear.
|
||||
// Returns 0 if successful.
|
||||
|
||||
LIBYUV_API
|
||||
int NV12Scale(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
int NV16Scale(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
int NV24Scale(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
// Scales a P010, P210 or P410 image (10-bit, samples in the MSBs of uint16).
|
||||
// Strides are in uint16 elements. Y and UV are converted to 10-bit LSB,
|
||||
// scaled with ScalePlane_16 (kFilterBox included), then converted back to
|
||||
// 10-bit MSB.
|
||||
// Returns 0 if successful.
|
||||
|
||||
LIBYUV_API
|
||||
int P010Scale(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
int P210Scale(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
LIBYUV_API
|
||||
int P410Scale(const uint16_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
#ifdef __cplusplus
|
||||
// Legacy API. Deprecated.
|
||||
LIBYUV_API
|
||||
@@ -164,11 +389,7 @@ int Scale(const uint8_t* src_y,
|
||||
int dst_stride_v,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
LIBYUV_BOOL interpolate);
|
||||
|
||||
// For testing, allow disabling of specialized scalers.
|
||||
LIBYUV_API
|
||||
void SetUseReferenceImpl(LIBYUV_BOOL use);
|
||||
int interpolate);
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#ifndef INCLUDE_LIBYUV_SCALE_ARGB_H_
|
||||
#define INCLUDE_LIBYUV_SCALE_ARGB_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
#include "libyuv/scale.h" // For FilterMode
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2022 The LibYuv Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_LIBYUV_SCALE_RGB_H_
|
||||
#define INCLUDE_LIBYUV_SCALE_RGB_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
#include "libyuv/scale.h" // For FilterMode
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// RGB can be RAW, RGB24 or YUV24
|
||||
// RGB scales 24 bit images by converting a row at a time to ARGB
|
||||
// and using ARGB row functions to scale, then convert to RGB.
|
||||
// TODO(fbarchard): Allow input/output formats to be specified.
|
||||
LIBYUV_API
|
||||
int RGBScale(const uint8_t* src_rgb,
|
||||
int src_stride_rgb,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint8_t* dst_rgb,
|
||||
int dst_stride_rgb,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // INCLUDE_LIBYUV_SCALE_UV_H_
|
||||
+1272
-299
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2020 The LibYuv Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_LIBYUV_SCALE_UV_H_
|
||||
#define INCLUDE_LIBYUV_SCALE_UV_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
#include "libyuv/scale.h" // For FilterMode
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
LIBYUV_API
|
||||
int UVScale(const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
// Scale a 16 bit UV image.
|
||||
LIBYUV_API
|
||||
int UVScale_16(const uint16_t* src_uv,
|
||||
int src_stride_uv,
|
||||
int src_width,
|
||||
int src_height,
|
||||
uint16_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int dst_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // INCLUDE_LIBYUV_SCALE_UV_H_
|
||||
@@ -11,6 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 1735
|
||||
#define LIBYUV_VERSION 1977
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_
|
||||
@@ -13,6 +13,9 @@
|
||||
#ifndef INCLUDE_LIBYUV_VIDEO_COMMON_H_
|
||||
#define INCLUDE_LIBYUV_VIDEO_COMMON_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -50,45 +53,72 @@ extern "C" {
|
||||
// Secondary formats are converted in 2 steps.
|
||||
// Auxilliary formats call primary converters.
|
||||
enum FourCC {
|
||||
// 9 Primary YUV formats: 5 planar, 2 biplanar, 2 packed.
|
||||
// 15 Primary YUV formats: 6 planar, 7 biplanar, 2 packed.
|
||||
FOURCC_I420 = FOURCC('I', '4', '2', '0'),
|
||||
FOURCC_I422 = FOURCC('I', '4', '2', '2'),
|
||||
FOURCC_I444 = FOURCC('I', '4', '4', '4'),
|
||||
FOURCC_I400 = FOURCC('I', '4', '0', '0'),
|
||||
FOURCC_NV21 = FOURCC('N', 'V', '2', '1'),
|
||||
FOURCC_NV12 = FOURCC('N', 'V', '1', '2'),
|
||||
FOURCC_NV16 = FOURCC('N', 'V', '1', '6'),
|
||||
FOURCC_NV24 = FOURCC('N', 'V', '2', '4'),
|
||||
FOURCC_P010 = FOURCC('P', '0', '1', '0'),
|
||||
FOURCC_P210 = FOURCC('P', '2', '1', '0'),
|
||||
FOURCC_P410 = FOURCC('P', '4', '1', '0'),
|
||||
FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'),
|
||||
FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'),
|
||||
FOURCC_H010 = FOURCC('H', '0', '1', '0'), // unofficial fourcc. 10 bit lsb
|
||||
FOURCC_I010 = FOURCC('I', '0', '1', '0'), // bt.601 10 bit 420
|
||||
FOURCC_I210 = FOURCC('I', '2', '1', '0'), // bt.601 10 bit 422
|
||||
|
||||
// 1 Secondary YUV format: row biplanar.
|
||||
// 1 Secondary YUV format: row biplanar. deprecated.
|
||||
FOURCC_M420 = FOURCC('M', '4', '2', '0'),
|
||||
|
||||
// 11 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp, 1 10 bpc
|
||||
// 13 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp, 1 10 bpc 2 64 bpp
|
||||
FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'),
|
||||
FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'),
|
||||
FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'),
|
||||
FOURCC_AR30 = FOURCC('A', 'R', '3', '0'), // 10 bit per channel. 2101010.
|
||||
FOURCC_AB30 = FOURCC('A', 'B', '3', '0'), // ABGR version of 10 bit
|
||||
FOURCC_AR64 = FOURCC('A', 'R', '6', '4'), // 16 bit per channel.
|
||||
FOURCC_AB64 = FOURCC('A', 'B', '6', '4'), // ABGR version of 16 bit
|
||||
FOURCC_24BG = FOURCC('2', '4', 'B', 'G'),
|
||||
FOURCC_RAW = FOURCC('r', 'a', 'w', ' '),
|
||||
FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'),
|
||||
FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE.
|
||||
FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // argb1555 LE.
|
||||
FOURCC_R444 = FOURCC('R', '4', '4', '4'), // argb4444 LE.
|
||||
FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE. deprecated.
|
||||
FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // argb1555 LE. deprecated.
|
||||
FOURCC_R444 = FOURCC('R', '4', '4', '4'), // argb4444 LE. deprecated.
|
||||
|
||||
// 1 Primary Compressed YUV format.
|
||||
FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
|
||||
|
||||
// 8 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
|
||||
// 23 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
|
||||
FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
|
||||
FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
|
||||
FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
|
||||
FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'), // Linux version of I420.
|
||||
FOURCC_J420 = FOURCC('J', '4', '2', '0'),
|
||||
FOURCC_J400 = FOURCC('J', '4', '0', '0'), // unofficial fourcc
|
||||
FOURCC_H420 = FOURCC('H', '4', '2', '0'), // unofficial fourcc
|
||||
FOURCC_H422 = FOURCC('H', '4', '2', '2'), // unofficial fourcc
|
||||
FOURCC_J420 =
|
||||
FOURCC('J', '4', '2', '0'), // jpeg (bt.601 full), unofficial fourcc
|
||||
FOURCC_J422 =
|
||||
FOURCC('J', '4', '2', '2'), // jpeg (bt.601 full), unofficial fourcc
|
||||
FOURCC_J444 =
|
||||
FOURCC('J', '4', '4', '4'), // jpeg (bt.601 full), unofficial fourcc
|
||||
FOURCC_J400 =
|
||||
FOURCC('J', '4', '0', '0'), // jpeg (bt.601 full), unofficial fourcc
|
||||
FOURCC_F420 = FOURCC('F', '4', '2', '0'), // bt.709 full, unofficial fourcc
|
||||
FOURCC_F422 = FOURCC('F', '4', '2', '2'), // bt.709 full, unofficial fourcc
|
||||
FOURCC_F444 = FOURCC('F', '4', '4', '4'), // bt.709 full, unofficial fourcc
|
||||
FOURCC_H420 = FOURCC('H', '4', '2', '0'), // bt.709, unofficial fourcc
|
||||
FOURCC_H422 = FOURCC('H', '4', '2', '2'), // bt.709, unofficial fourcc
|
||||
FOURCC_H444 = FOURCC('H', '4', '4', '4'), // bt.709, unofficial fourcc
|
||||
FOURCC_U420 = FOURCC('U', '4', '2', '0'), // bt.2020, unofficial fourcc
|
||||
FOURCC_U422 = FOURCC('U', '4', '2', '2'), // bt.2020, unofficial fourcc
|
||||
FOURCC_U444 = FOURCC('U', '4', '4', '4'), // bt.2020, unofficial fourcc
|
||||
FOURCC_F010 = FOURCC('F', '0', '1', '0'), // bt.709 full range 10 bit 420
|
||||
FOURCC_H010 = FOURCC('H', '0', '1', '0'), // bt.709 10 bit 420
|
||||
FOURCC_U010 = FOURCC('U', '0', '1', '0'), // bt.2020 10 bit 420
|
||||
FOURCC_F210 = FOURCC('F', '2', '1', '0'), // bt.709 full range 10 bit 422
|
||||
FOURCC_H210 = FOURCC('H', '2', '1', '0'), // bt.709 10 bit 422
|
||||
FOURCC_U210 = FOURCC('U', '2', '1', '0'), // bt.2020 10 bit 422
|
||||
|
||||
// 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc.
|
||||
FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420.
|
||||
@@ -105,9 +135,9 @@ enum FourCC {
|
||||
FOURCC_BGR3 = FOURCC('B', 'G', 'R', '3'), // Alias for 24BG.
|
||||
FOURCC_CM32 = FOURCC(0, 0, 0, 32), // Alias for BGRA kCMPixelFormat_32ARGB
|
||||
FOURCC_CM24 = FOURCC(0, 0, 0, 24), // Alias for RAW kCMPixelFormat_24RGB
|
||||
FOURCC_L555 = FOURCC('L', '5', '5', '5'), // Alias for RGBO.
|
||||
FOURCC_L565 = FOURCC('L', '5', '6', '5'), // Alias for RGBP.
|
||||
FOURCC_5551 = FOURCC('5', '5', '5', '1'), // Alias for RGBO.
|
||||
FOURCC_L555 = FOURCC('L', '5', '5', '5'), // Alias for RGBO. deprecated.
|
||||
FOURCC_L565 = FOURCC('L', '5', '6', '5'), // Alias for RGBP. deprecated.
|
||||
FOURCC_5551 = FOURCC('5', '5', '5', '1'), // Alias for RGBO. deprecated.
|
||||
|
||||
// deprecated formats. Not supported, but defined for backward compatibility.
|
||||
FOURCC_I411 = FOURCC('I', '4', '1', '1'),
|
||||
@@ -131,9 +161,11 @@ enum FourCCBpp {
|
||||
FOURCC_BPP_I400 = 8,
|
||||
FOURCC_BPP_NV21 = 12,
|
||||
FOURCC_BPP_NV12 = 12,
|
||||
FOURCC_BPP_NV16 = 16,
|
||||
FOURCC_BPP_NV24 = 24,
|
||||
FOURCC_BPP_YUY2 = 16,
|
||||
FOURCC_BPP_UYVY = 16,
|
||||
FOURCC_BPP_M420 = 12,
|
||||
FOURCC_BPP_M420 = 12, // deprecated
|
||||
FOURCC_BPP_Q420 = 12,
|
||||
FOURCC_BPP_ARGB = 32,
|
||||
FOURCC_BPP_BGRA = 32,
|
||||
@@ -141,11 +173,13 @@ enum FourCCBpp {
|
||||
FOURCC_BPP_RGBA = 32,
|
||||
FOURCC_BPP_AR30 = 32,
|
||||
FOURCC_BPP_AB30 = 32,
|
||||
FOURCC_BPP_AR64 = 64,
|
||||
FOURCC_BPP_AB64 = 64,
|
||||
FOURCC_BPP_24BG = 24,
|
||||
FOURCC_BPP_RAW = 24,
|
||||
FOURCC_BPP_RGBP = 16,
|
||||
FOURCC_BPP_RGBO = 16,
|
||||
FOURCC_BPP_R444 = 16,
|
||||
FOURCC_BPP_RGBP = 16, // deprecated
|
||||
FOURCC_BPP_RGBO = 16, // deprecated
|
||||
FOURCC_BPP_R444 = 16, // deprecated
|
||||
FOURCC_BPP_RGGB = 8,
|
||||
FOURCC_BPP_BGGR = 8,
|
||||
FOURCC_BPP_GRBG = 8,
|
||||
@@ -158,7 +192,13 @@ enum FourCCBpp {
|
||||
FOURCC_BPP_J400 = 8,
|
||||
FOURCC_BPP_H420 = 12,
|
||||
FOURCC_BPP_H422 = 16,
|
||||
FOURCC_BPP_H010 = 24,
|
||||
FOURCC_BPP_I010 = 15,
|
||||
FOURCC_BPP_I210 = 20,
|
||||
FOURCC_BPP_H010 = 15,
|
||||
FOURCC_BPP_H210 = 20,
|
||||
FOURCC_BPP_P010 = 15,
|
||||
FOURCC_BPP_P210 = 20,
|
||||
FOURCC_BPP_P410 = 30,
|
||||
FOURCC_BPP_MJPG = 0, // 0 means unknown.
|
||||
FOURCC_BPP_H264 = 0,
|
||||
FOURCC_BPP_IYUV = 12,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fbarchard@chromium.org
|
||||
mbonadei@chromium.org
|
||||
jansson@google.com
|
||||
@@ -0,0 +1,17 @@
|
||||
# Copyright 2018 The PDFium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
USE_PYTHON3 = True
|
||||
|
||||
|
||||
def CheckChangeOnUpload(input_api, output_api):
|
||||
return input_api.canned_checks.CheckChangedLUCIConfigs(
|
||||
input_api, output_api
|
||||
)
|
||||
|
||||
|
||||
def CheckChangeOnCommit(input_api, output_api):
|
||||
return input_api.canned_checks.CheckChangedLUCIConfigs(
|
||||
input_api, output_api
|
||||
)
|
||||
@@ -0,0 +1,2 @@
|
||||
This folder contains libyuv project-wide configurations
|
||||
for chrome-infra services.
|
||||
@@ -0,0 +1,6 @@
|
||||
# This file is used by gcl and git-cl to get repository specific information.
|
||||
CODE_REVIEW_SERVER: codereview.chromium.org
|
||||
PROJECT: libyuv
|
||||
GERRIT_HOST: True
|
||||
VIEW_VC: https://chromium.googlesource.com/libyuv/libyuv/+/
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
# Auto-generated by lucicfg.
|
||||
# Do not modify manually.
|
||||
#
|
||||
# For the schema of this file, see Config message:
|
||||
# https://config.luci.app/schemas/projects:commit-queue.cfg
|
||||
|
||||
cq_status_host: "chromium-cq-status.appspot.com"
|
||||
submit_options {
|
||||
max_burst: 4
|
||||
burst_delay {
|
||||
seconds: 480
|
||||
}
|
||||
}
|
||||
config_groups {
|
||||
name: "config"
|
||||
gerrit {
|
||||
url: "https://chromium-review.googlesource.com"
|
||||
projects {
|
||||
name: "libyuv/libyuv"
|
||||
ref_regexp: "refs/heads/infra/config"
|
||||
}
|
||||
}
|
||||
verifiers {
|
||||
gerrit_cq_ability {
|
||||
committer_list: "project-libyuv-committers"
|
||||
dry_run_access_list: "project-libyuv-tryjob-access"
|
||||
}
|
||||
tryjob {
|
||||
builders {
|
||||
name: "libyuv/try/presubmit"
|
||||
}
|
||||
retry_config {
|
||||
single_quota: 1
|
||||
global_quota: 2
|
||||
failure_weight: 1
|
||||
transient_failure_weight: 1
|
||||
timeout_weight: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
config_groups {
|
||||
name: "master"
|
||||
gerrit {
|
||||
url: "https://chromium-review.googlesource.com"
|
||||
projects {
|
||||
name: "libyuv/libyuv"
|
||||
ref_regexp: "refs/heads/main"
|
||||
ref_regexp: "refs/heads/master"
|
||||
}
|
||||
}
|
||||
verifiers {
|
||||
gerrit_cq_ability {
|
||||
committer_list: "project-libyuv-committers"
|
||||
dry_run_access_list: "project-libyuv-tryjob-access"
|
||||
}
|
||||
tryjob {
|
||||
builders {
|
||||
name: "libyuv/try/android"
|
||||
experiment_percentage: 100
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/android_arm64"
|
||||
experiment_percentage: 100
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/android_rel"
|
||||
experiment_percentage: 100
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/android_x64"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/android_x86"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/ios_arm64"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/ios_arm64_rel"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/linux"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/linux_asan"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/linux_gcc"
|
||||
experiment_percentage: 100
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/linux_msan"
|
||||
experiment_percentage: 100
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/linux_rel"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/linux_tsan2"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/linux_ubsan"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/linux_ubsan_vptr"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/mac"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/mac_asan"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/mac_rel"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/win"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/win_clang"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/win_clang_rel"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/win_rel"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/win_x64_clang_rel"
|
||||
}
|
||||
builders {
|
||||
name: "libyuv/try/win_x64_rel"
|
||||
}
|
||||
retry_config {
|
||||
single_quota: 1
|
||||
global_quota: 2
|
||||
failure_weight: 1
|
||||
transient_failure_weight: 1
|
||||
timeout_weight: 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,9 @@
|
||||
# Auto-generated by lucicfg.
|
||||
# Do not modify manually.
|
||||
#
|
||||
# For the schema of this file, see ProjectConfig message:
|
||||
# https://config.luci.app/schemas/projects:luci-logdog.cfg
|
||||
|
||||
reader_auth_groups: "all"
|
||||
writer_auth_groups: "luci-logdog-chromium-writers"
|
||||
archive_gs_bucket: "chromium-luci-logdog"
|
||||
@@ -0,0 +1,246 @@
|
||||
# Auto-generated by lucicfg.
|
||||
# Do not modify manually.
|
||||
#
|
||||
# For the schema of this file, see Project message:
|
||||
# https://config.luci.app/schemas/projects:luci-milo.cfg
|
||||
|
||||
consoles {
|
||||
id: "main"
|
||||
name: "libyuv Main Console"
|
||||
repo_url: "https://chromium.googlesource.com/libyuv/libyuv"
|
||||
refs: "regexp:refs/heads/main"
|
||||
manifest_name: "REVISION"
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Android ARM64 Debug"
|
||||
category: "Android|Builder"
|
||||
short_name: "dbg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Android Debug"
|
||||
category: "Android|Builder"
|
||||
short_name: "dbg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Android Release"
|
||||
category: "Android|Builder"
|
||||
short_name: "rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Android32 x86 Debug"
|
||||
category: "Android|Builder|x86"
|
||||
short_name: "dbg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Android64 x64 Debug"
|
||||
category: "Android|Builder|x64"
|
||||
short_name: "dbg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Android Tester ARM32 Debug (Nexus 5X)"
|
||||
category: "Android|Tester|ARM 32"
|
||||
short_name: "dbg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Android Tester ARM32 Release (Nexus 5X)"
|
||||
category: "Android|Tester|ARM 32"
|
||||
short_name: "rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Android Tester ARM64 Debug (Nexus 5X)"
|
||||
category: "Android|Tester|ARM 64"
|
||||
short_name: "dbg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Linux Asan"
|
||||
category: "Linux"
|
||||
short_name: "asan"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Linux MSan"
|
||||
category: "Linux"
|
||||
short_name: "msan"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Linux Tsan v2"
|
||||
category: "Linux"
|
||||
short_name: "tsan"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Linux UBSan"
|
||||
category: "Linux|UBSan"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Linux UBSan vptr"
|
||||
category: "Linux|UBSan"
|
||||
short_name: "vptr"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Linux32 Debug"
|
||||
category: "Linux|32"
|
||||
short_name: "dbg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Linux32 Release"
|
||||
category: "Linux|32"
|
||||
short_name: "rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Linux64 Debug"
|
||||
category: "Linux|64"
|
||||
short_name: "dbg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Linux64 Release"
|
||||
category: "Linux|64"
|
||||
short_name: "rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Mac Asan"
|
||||
category: "Mac"
|
||||
short_name: "asan"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Mac64 Debug"
|
||||
category: "Mac"
|
||||
short_name: "dbg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Mac64 Release"
|
||||
category: "Mac"
|
||||
short_name: "rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Win32 Debug"
|
||||
category: "Win|32|Debug"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Win32 Debug (Clang)"
|
||||
category: "Win|32|Debug"
|
||||
short_name: "clg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Win32 Release"
|
||||
category: "Win|32|Release"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Win32 Release (Clang)"
|
||||
category: "Win|32|Release"
|
||||
short_name: "clg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Win64 Debug"
|
||||
category: "Win|64|Debug"
|
||||
short_name: "clg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Win64 Debug (Clang)"
|
||||
category: "Win|64|Debug"
|
||||
short_name: "clg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Win64 Release"
|
||||
category: "Win|64|Release"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/Win64 Release (Clang)"
|
||||
category: "Win|64|Release"
|
||||
short_name: "clg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/iOS ARM64 Debug"
|
||||
category: "iOS|ARM64"
|
||||
short_name: "dbg"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.ci/iOS ARM64 Release"
|
||||
category: "iOS|ARM64"
|
||||
short_name: "rel"
|
||||
}
|
||||
include_experimental_builds: true
|
||||
}
|
||||
consoles {
|
||||
id: "cron"
|
||||
name: "Cron"
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.cron/DEPS Autoroller"
|
||||
}
|
||||
builder_view_only: true
|
||||
}
|
||||
consoles {
|
||||
id: "try"
|
||||
name: "libyuv Try Builders"
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/android"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/android_arm64"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/android_rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/android_x64"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/android_x86"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/ios_arm64"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/ios_arm64_rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/linux"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/linux_asan"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/linux_gcc"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/linux_msan"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/linux_rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/linux_tsan2"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/linux_ubsan"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/linux_ubsan_vptr"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/mac"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/mac_asan"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/mac_rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/win"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/win_clang"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/win_clang_rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/win_rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/win_x64_clang_rel"
|
||||
}
|
||||
builders {
|
||||
name: "buildbucket/luci.libyuv.try/win_x64_rel"
|
||||
}
|
||||
builder_view_only: true
|
||||
}
|
||||
logo_url: "https://storage.googleapis.com/chrome-infra-public/logo/libyuv-logo.png"
|
||||
@@ -0,0 +1,385 @@
|
||||
# Auto-generated by lucicfg.
|
||||
# Do not modify manually.
|
||||
#
|
||||
# For the schema of this file, see ProjectConfig message:
|
||||
# https://config.luci.app/schemas/projects:luci-scheduler.cfg
|
||||
|
||||
job {
|
||||
id: "Android ARM64 Debug"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Android ARM64 Debug"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Android Debug"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Android Debug"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Android Release"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Android Release"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Android Tester ARM32 Debug (Nexus 5X)"
|
||||
realm: "ci"
|
||||
acls {
|
||||
role: TRIGGERER
|
||||
granted_to: "libyuv-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
|
||||
}
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Android Tester ARM32 Debug (Nexus 5X)"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Android Tester ARM32 Release (Nexus 5X)"
|
||||
realm: "ci"
|
||||
acls {
|
||||
role: TRIGGERER
|
||||
granted_to: "libyuv-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
|
||||
}
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Android Tester ARM32 Release (Nexus 5X)"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Android Tester ARM64 Debug (Nexus 5X)"
|
||||
realm: "ci"
|
||||
acls {
|
||||
role: TRIGGERER
|
||||
granted_to: "libyuv-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
|
||||
}
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Android Tester ARM64 Debug (Nexus 5X)"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Android32 x86 Debug"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Android32 x86 Debug"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Android64 x64 Debug"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Android64 x64 Debug"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "DEPS Autoroller"
|
||||
realm: "cron"
|
||||
schedule: "0 14 * * *"
|
||||
acl_sets: "cron"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "cron"
|
||||
builder: "DEPS Autoroller"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Linux Asan"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Linux Asan"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Linux MSan"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Linux MSan"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Linux Tsan v2"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Linux Tsan v2"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Linux UBSan"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Linux UBSan"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Linux UBSan vptr"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Linux UBSan vptr"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Linux32 Debug"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Linux32 Debug"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Linux32 Release"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Linux32 Release"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Linux64 Debug"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Linux64 Debug"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Linux64 Release"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Linux64 Release"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Mac Asan"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Mac Asan"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Mac64 Debug"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Mac64 Debug"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Mac64 Release"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Mac64 Release"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Win32 Debug"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Win32 Debug"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Win32 Debug (Clang)"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Win32 Debug (Clang)"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Win32 Release"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Win32 Release"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Win32 Release (Clang)"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Win32 Release (Clang)"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Win64 Debug"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Win64 Debug"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Win64 Debug (Clang)"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Win64 Debug (Clang)"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Win64 Release"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Win64 Release"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "Win64 Release (Clang)"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "Win64 Release (Clang)"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "iOS ARM64 Debug"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "iOS ARM64 Debug"
|
||||
}
|
||||
}
|
||||
job {
|
||||
id: "iOS ARM64 Release"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
buildbucket {
|
||||
server: "cr-buildbucket.appspot.com"
|
||||
bucket: "ci"
|
||||
builder: "iOS ARM64 Release"
|
||||
}
|
||||
}
|
||||
trigger {
|
||||
id: "master-gitiles-trigger"
|
||||
realm: "ci"
|
||||
acl_sets: "ci"
|
||||
triggers: "Android ARM64 Debug"
|
||||
triggers: "Android Debug"
|
||||
triggers: "Android Release"
|
||||
triggers: "Android32 x86 Debug"
|
||||
triggers: "Android64 x64 Debug"
|
||||
triggers: "Linux Asan"
|
||||
triggers: "Linux MSan"
|
||||
triggers: "Linux Tsan v2"
|
||||
triggers: "Linux UBSan"
|
||||
triggers: "Linux UBSan vptr"
|
||||
triggers: "Linux32 Debug"
|
||||
triggers: "Linux32 Release"
|
||||
triggers: "Linux64 Debug"
|
||||
triggers: "Linux64 Release"
|
||||
triggers: "Mac Asan"
|
||||
triggers: "Mac64 Debug"
|
||||
triggers: "Mac64 Release"
|
||||
triggers: "Win32 Debug"
|
||||
triggers: "Win32 Debug (Clang)"
|
||||
triggers: "Win32 Release"
|
||||
triggers: "Win32 Release (Clang)"
|
||||
triggers: "Win64 Debug"
|
||||
triggers: "Win64 Debug (Clang)"
|
||||
triggers: "Win64 Release"
|
||||
triggers: "Win64 Release (Clang)"
|
||||
triggers: "iOS ARM64 Debug"
|
||||
triggers: "iOS ARM64 Release"
|
||||
gitiles {
|
||||
repo: "https://chromium.googlesource.com/libyuv/libyuv"
|
||||
refs: "regexp:refs/heads/main"
|
||||
}
|
||||
}
|
||||
acl_sets {
|
||||
name: "ci"
|
||||
acls {
|
||||
role: OWNER
|
||||
granted_to: "group:project-libyuv-admins"
|
||||
}
|
||||
acls {
|
||||
granted_to: "group:all"
|
||||
}
|
||||
}
|
||||
acl_sets {
|
||||
name: "cron"
|
||||
acls {
|
||||
role: OWNER
|
||||
granted_to: "group:project-libyuv-admins"
|
||||
}
|
||||
acls {
|
||||
granted_to: "group:all"
|
||||
}
|
||||
}
|
||||
Executable
+399
@@ -0,0 +1,399 @@
|
||||
#!/usr/bin/env lucicfg
|
||||
# https://chromium.googlesource.com/infra/luci/luci-go/+/master/lucicfg/doc/
|
||||
|
||||
"""LUCI project configuration for libyuv CQ and CI."""
|
||||
|
||||
lucicfg.check_version("1.30.9")
|
||||
|
||||
LIBYUV_GIT = "https://chromium.googlesource.com/libyuv/libyuv"
|
||||
LIBYUV_GERRIT = "https://chromium-review.googlesource.com/libyuv/libyuv"
|
||||
|
||||
RBE_PROJECT = {
|
||||
"ci": "rbe-webrtc-trusted",
|
||||
"try": "rbe-webrtc-untrusted",
|
||||
}
|
||||
|
||||
# Use LUCI Scheduler BBv2 names and add Scheduler realms configs.
|
||||
lucicfg.enable_experiment("crbug.com/1182002")
|
||||
|
||||
lucicfg.config(
|
||||
lint_checks = ["default"],
|
||||
config_dir = ".",
|
||||
tracked_files = [
|
||||
"commit-queue.cfg",
|
||||
"cr-buildbucket.cfg",
|
||||
"luci-logdog.cfg",
|
||||
"luci-milo.cfg",
|
||||
"luci-scheduler.cfg",
|
||||
"project.cfg",
|
||||
"realms.cfg",
|
||||
],
|
||||
)
|
||||
|
||||
# Generates project.cfg
|
||||
|
||||
luci.project(
|
||||
name = "libyuv",
|
||||
buildbucket = "cr-buildbucket.appspot.com",
|
||||
logdog = "luci-logdog.appspot.com",
|
||||
milo = "luci-milo.appspot.com",
|
||||
notify = "luci-notify.appspot.com",
|
||||
scheduler = "luci-scheduler.appspot.com",
|
||||
swarming = "chromium-swarm.appspot.com",
|
||||
acls = [
|
||||
acl.entry(acl.PROJECT_CONFIGS_READER, groups = ["all"]),
|
||||
acl.entry(acl.LOGDOG_READER, groups = ["all"]),
|
||||
acl.entry(acl.LOGDOG_WRITER, groups = ["luci-logdog-chromium-writers"]),
|
||||
acl.entry(acl.SCHEDULER_READER, groups = ["all"]),
|
||||
acl.entry(acl.SCHEDULER_OWNER, groups = ["project-libyuv-admins"]),
|
||||
acl.entry(acl.BUILDBUCKET_READER, groups = ["all"]),
|
||||
acl.entry(acl.BUILDBUCKET_OWNER, groups = ["project-libyuv-admins"]),
|
||||
],
|
||||
bindings = [
|
||||
luci.binding(
|
||||
roles = "role/swarming.taskTriggerer", # for LED tasks.
|
||||
groups = "project-libyuv-admins",
|
||||
),
|
||||
luci.binding(
|
||||
roles = "role/configs.validator",
|
||||
users = "libyuv-try-builder@chops-service-accounts.iam.gserviceaccount.com",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
# Generates luci-logdog.cfg
|
||||
|
||||
luci.logdog(
|
||||
gs_bucket = "chromium-luci-logdog",
|
||||
)
|
||||
|
||||
# Generates luci-scheduler.cfg
|
||||
|
||||
luci.gitiles_poller(
|
||||
name = "master-gitiles-trigger",
|
||||
bucket = "ci",
|
||||
repo = LIBYUV_GIT,
|
||||
)
|
||||
|
||||
# Generates luci-milo.cfg
|
||||
|
||||
luci.milo(
|
||||
logo = "https://storage.googleapis.com/chrome-infra-public/logo/libyuv-logo.png",
|
||||
)
|
||||
|
||||
def libyuv_ci_view(name, category, short_name):
|
||||
return luci.console_view_entry(
|
||||
console_view = "main",
|
||||
builder = name,
|
||||
category = category,
|
||||
short_name = short_name,
|
||||
)
|
||||
|
||||
def libyuv_try_view(name):
|
||||
return luci.list_view_entry(
|
||||
list_view = "try",
|
||||
builder = name,
|
||||
)
|
||||
|
||||
luci.console_view(
|
||||
name = "main",
|
||||
title = "libyuv Main Console",
|
||||
include_experimental_builds = True,
|
||||
repo = LIBYUV_GIT,
|
||||
)
|
||||
|
||||
luci.list_view(
|
||||
name = "cron",
|
||||
title = "Cron",
|
||||
entries = ["DEPS Autoroller"],
|
||||
)
|
||||
|
||||
luci.list_view(
|
||||
name = "try",
|
||||
title = "libyuv Try Builders",
|
||||
)
|
||||
|
||||
# Generates commit-queue.cfg
|
||||
|
||||
def libyuv_try_job_verifier(name, cq_group, experiment_percentage):
|
||||
return luci.cq_tryjob_verifier(
|
||||
builder = name,
|
||||
cq_group = cq_group,
|
||||
experiment_percentage = experiment_percentage,
|
||||
)
|
||||
|
||||
luci.cq(
|
||||
status_host = "chromium-cq-status.appspot.com",
|
||||
submit_max_burst = 4,
|
||||
submit_burst_delay = 8 * time.minute,
|
||||
)
|
||||
|
||||
luci.cq_group(
|
||||
name = "master",
|
||||
watch = [
|
||||
cq.refset(
|
||||
repo = LIBYUV_GERRIT,
|
||||
refs = ["refs/heads/main", "refs/heads/master"],
|
||||
),
|
||||
],
|
||||
acls = [
|
||||
acl.entry(acl.CQ_COMMITTER, groups = ["project-libyuv-committers"]),
|
||||
acl.entry(acl.CQ_DRY_RUNNER, groups = ["project-libyuv-tryjob-access"]),
|
||||
],
|
||||
retry_config = cq.RETRY_ALL_FAILURES,
|
||||
cancel_stale_tryjobs = True,
|
||||
)
|
||||
|
||||
luci.cq_group(
|
||||
name = "config",
|
||||
watch = [
|
||||
cq.refset(
|
||||
repo = LIBYUV_GERRIT,
|
||||
refs = ["refs/heads/infra/config"],
|
||||
),
|
||||
],
|
||||
acls = [
|
||||
acl.entry(acl.CQ_COMMITTER, groups = ["project-libyuv-committers"]),
|
||||
acl.entry(acl.CQ_DRY_RUNNER, groups = ["project-libyuv-tryjob-access"]),
|
||||
],
|
||||
retry_config = cq.RETRY_ALL_FAILURES,
|
||||
cancel_stale_tryjobs = True,
|
||||
)
|
||||
|
||||
# Generates cr-buildbucket.cfg
|
||||
|
||||
luci.bucket(
|
||||
name = "ci",
|
||||
constraints = luci.bucket_constraints(
|
||||
pools = ["luci.flex.ci"],
|
||||
),
|
||||
)
|
||||
luci.bucket(
|
||||
name = "ci.shadow",
|
||||
shadows = "ci",
|
||||
constraints = luci.bucket_constraints(
|
||||
pools = ["luci.flex.ci"],
|
||||
service_accounts = [
|
||||
"libyuv-ci-builder@chops-service-accounts.iam.gserviceaccount.com",
|
||||
],
|
||||
),
|
||||
bindings = [
|
||||
# For led permissions.
|
||||
luci.binding(
|
||||
roles = "role/buildbucket.creator",
|
||||
groups = [
|
||||
"chromium-led-users",
|
||||
"mdb/chrome-build-access-sphinx",
|
||||
"mdb/chrome-troopers",
|
||||
"mdb/foundry-x-team",
|
||||
],
|
||||
),
|
||||
],
|
||||
dynamic = True,
|
||||
)
|
||||
luci.bucket(
|
||||
name = "try",
|
||||
acls = [
|
||||
acl.entry(acl.BUILDBUCKET_TRIGGERER, groups = [
|
||||
"project-libyuv-tryjob-access",
|
||||
"service-account-cq",
|
||||
]),
|
||||
],
|
||||
constraints = luci.bucket_constraints(
|
||||
pools = ["luci.flex.try"],
|
||||
service_accounts = [
|
||||
"libyuv-try-builder@chops-service-accounts.iam.gserviceaccount.com",
|
||||
],
|
||||
),
|
||||
)
|
||||
luci.bucket(
|
||||
name = "try.shadow",
|
||||
shadows = "try",
|
||||
constraints = luci.bucket_constraints(
|
||||
pools = ["luci.flex.try"],
|
||||
service_accounts = [
|
||||
"libyuv-try-builder@chops-service-accounts.iam.gserviceaccount.com",
|
||||
],
|
||||
),
|
||||
bindings = [
|
||||
# For led permissions.
|
||||
luci.binding(
|
||||
roles = "role/buildbucket.creator",
|
||||
groups = [
|
||||
"chromium-led-users",
|
||||
"mdb/chrome-build-access-sphinx",
|
||||
"mdb/chrome-troopers",
|
||||
"mdb/foundry-x-team",
|
||||
],
|
||||
),
|
||||
],
|
||||
dynamic = True,
|
||||
)
|
||||
luci.bucket(
|
||||
name = "cron",
|
||||
)
|
||||
|
||||
def get_os_dimensions(os):
|
||||
if os == "android":
|
||||
return {"device_type": "walleye"}
|
||||
if os == "ios" or os == "mac":
|
||||
return {"os": "Mac-15", "cpu": "arm64"}
|
||||
elif os == "win":
|
||||
return {"os": "Windows-10", "cores": "8", "cpu": "x86-64"}
|
||||
elif os == "linux":
|
||||
return {"os": "Ubuntu-24.04", "cores": "8", "cpu": "x86-64"}
|
||||
return {}
|
||||
|
||||
def libyuv_ci_builder(name, dimensions, properties, triggered_by):
|
||||
return luci.builder(
|
||||
name = name,
|
||||
dimensions = dimensions,
|
||||
properties = properties,
|
||||
bucket = "ci",
|
||||
service_account = "libyuv-ci-builder@chops-service-accounts.iam.gserviceaccount.com",
|
||||
triggered_by = triggered_by,
|
||||
swarming_tags = ["vpython:native-python-wrapper"],
|
||||
execution_timeout = 180 * time.minute,
|
||||
build_numbers = True,
|
||||
executable = luci.recipe(
|
||||
name = "libyuv/libyuv",
|
||||
cipd_package = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",
|
||||
),
|
||||
)
|
||||
|
||||
def libyuv_try_builder(name, dimensions, properties, recipe_name = "libyuv/libyuv"):
|
||||
return luci.builder(
|
||||
name = name,
|
||||
dimensions = dimensions,
|
||||
properties = properties,
|
||||
bucket = "try",
|
||||
service_account = "libyuv-try-builder@chops-service-accounts.iam.gserviceaccount.com",
|
||||
swarming_tags = ["vpython:native-python-wrapper"],
|
||||
execution_timeout = 180 * time.minute,
|
||||
build_numbers = True,
|
||||
executable = luci.recipe(
|
||||
name = recipe_name,
|
||||
cipd_package = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",
|
||||
),
|
||||
)
|
||||
|
||||
def get_build_properties(bucket):
|
||||
rbe_project = RBE_PROJECT.get(bucket)
|
||||
return {
|
||||
"$build/siso": {
|
||||
"project": rbe_project,
|
||||
"configs": ["builder"],
|
||||
"enable_cloud_profiler": True,
|
||||
"enable_cloud_trace": True,
|
||||
"enable_monitoring": True,
|
||||
},
|
||||
}
|
||||
|
||||
def ci_builder(name, os, category, short_name = None):
|
||||
dimensions = get_os_dimensions(os)
|
||||
properties = get_build_properties("ci")
|
||||
|
||||
dimensions["pool"] = "luci.flex.ci"
|
||||
properties["builder_group"] = "client.libyuv"
|
||||
|
||||
triggered_by = ["master-gitiles-trigger" if os != "android" else "Android Debug"]
|
||||
libyuv_ci_view(name, category, short_name)
|
||||
return libyuv_ci_builder(name, dimensions, properties, triggered_by)
|
||||
|
||||
def try_builder(name, os, experiment_percentage = None):
|
||||
dimensions = get_os_dimensions(os)
|
||||
properties = get_build_properties("try")
|
||||
|
||||
dimensions["pool"] = "luci.flex.try"
|
||||
properties["builder_group"] = "tryserver.libyuv"
|
||||
|
||||
if name == "presubmit":
|
||||
recipe_name = "run_presubmit"
|
||||
properties["repo_name"] = "libyuv"
|
||||
properties["runhooks"] = True
|
||||
libyuv_try_job_verifier(name, "config", experiment_percentage)
|
||||
return libyuv_try_builder(name, dimensions, properties, recipe_name)
|
||||
|
||||
libyuv_try_job_verifier(name, "master", experiment_percentage)
|
||||
libyuv_try_view(name)
|
||||
return libyuv_try_builder(name, dimensions, properties)
|
||||
|
||||
luci.builder(
|
||||
name = "DEPS Autoroller",
|
||||
bucket = "cron",
|
||||
service_account = "libyuv-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com",
|
||||
dimensions = {
|
||||
"pool": "luci.webrtc.cron",
|
||||
"os": "Linux",
|
||||
"cpu": "x86-64",
|
||||
},
|
||||
swarming_tags = ["vpython:native-python-wrapper"],
|
||||
execution_timeout = 120 * time.minute,
|
||||
build_numbers = True,
|
||||
schedule = "0 14 * * *", # Every 2 hours.
|
||||
executable = luci.recipe(
|
||||
name = "libyuv/roll_deps",
|
||||
cipd_package = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",
|
||||
),
|
||||
)
|
||||
|
||||
ci_builder("Android ARM64 Debug", "linux", "Android|Builder", "dbg")
|
||||
ci_builder("Android Debug", "linux", "Android|Builder", "dbg")
|
||||
ci_builder("Android Release", "linux", "Android|Builder", "rel")
|
||||
ci_builder("Android32 x86 Debug", "linux", "Android|Builder|x86", "dbg")
|
||||
ci_builder("Android64 x64 Debug", "linux", "Android|Builder|x64", "dbg")
|
||||
ci_builder("Android Tester ARM32 Debug (Nexus 5X)", "android", "Android|Tester|ARM 32", "dbg")
|
||||
ci_builder("Android Tester ARM32 Release (Nexus 5X)", "android", "Android|Tester|ARM 32", "rel")
|
||||
ci_builder("Android Tester ARM64 Debug (Nexus 5X)", "android", "Android|Tester|ARM 64", "dbg")
|
||||
ci_builder("Linux Asan", "linux", "Linux", "asan")
|
||||
ci_builder("Linux MSan", "linux", "Linux", "msan")
|
||||
ci_builder("Linux Tsan v2", "linux", "Linux", "tsan")
|
||||
ci_builder("Linux UBSan", "linux", "Linux|UBSan")
|
||||
ci_builder("Linux UBSan vptr", "linux", "Linux|UBSan", "vptr")
|
||||
ci_builder("Linux32 Debug", "linux", "Linux|32", "dbg")
|
||||
ci_builder("Linux32 Release", "linux", "Linux|32", "rel")
|
||||
ci_builder("Linux64 Debug", "linux", "Linux|64", "dbg")
|
||||
ci_builder("Linux64 Release", "linux", "Linux|64", "rel")
|
||||
ci_builder("Mac Asan", "mac", "Mac", "asan")
|
||||
ci_builder("Mac64 Debug", "mac", "Mac", "dbg")
|
||||
ci_builder("Mac64 Release", "mac", "Mac", "rel")
|
||||
ci_builder("Win32 Debug", "win", "Win|32|Debug")
|
||||
ci_builder("Win32 Debug (Clang)", "win", "Win|32|Debug", "clg")
|
||||
ci_builder("Win32 Release", "win", "Win|32|Release")
|
||||
ci_builder("Win32 Release (Clang)", "win", "Win|32|Release", "clg")
|
||||
ci_builder("Win64 Debug", "win", "Win|64|Debug", "clg")
|
||||
ci_builder("Win64 Debug (Clang)", "win", "Win|64|Debug", "clg")
|
||||
ci_builder("Win64 Release", "win", "Win|64|Release")
|
||||
ci_builder("Win64 Release (Clang)", "win", "Win|64|Release", "clg")
|
||||
ci_builder("iOS ARM64 Debug", "ios", "iOS|ARM64", "dbg")
|
||||
ci_builder("iOS ARM64 Release", "ios", "iOS|ARM64", "rel")
|
||||
|
||||
# TODO(crbug.com/1242847): make this not experimental.
|
||||
try_builder("android", "android", experiment_percentage = 100)
|
||||
try_builder("android_arm64", "android", experiment_percentage = 100)
|
||||
try_builder("android_rel", "android", experiment_percentage = 100)
|
||||
|
||||
try_builder("android_x64", "linux")
|
||||
try_builder("android_x86", "linux")
|
||||
try_builder("ios_arm64", "ios")
|
||||
try_builder("ios_arm64_rel", "ios")
|
||||
try_builder("linux", "linux")
|
||||
try_builder("linux_asan", "linux")
|
||||
try_builder("linux_gcc", "linux", experiment_percentage = 100)
|
||||
|
||||
# TODO(libyuv:388428508): Make linux_msan not experimental.
|
||||
try_builder("linux_msan", "linux", experiment_percentage = 100)
|
||||
try_builder("linux_rel", "linux")
|
||||
try_builder("linux_tsan2", "linux")
|
||||
try_builder("linux_ubsan", "linux")
|
||||
try_builder("linux_ubsan_vptr", "linux")
|
||||
try_builder("mac", "mac")
|
||||
try_builder("mac_asan", "mac")
|
||||
try_builder("mac_rel", "mac")
|
||||
try_builder("win", "win")
|
||||
try_builder("win_clang", "win")
|
||||
try_builder("win_clang_rel", "win")
|
||||
try_builder("win_rel", "win")
|
||||
try_builder("win_x64_clang_rel", "win")
|
||||
try_builder("win_x64_rel", "win")
|
||||
try_builder("presubmit", "linux")
|
||||
@@ -0,0 +1,15 @@
|
||||
# Auto-generated by lucicfg.
|
||||
# Do not modify manually.
|
||||
#
|
||||
# For the schema of this file, see ProjectCfg message:
|
||||
# https://config.luci.app/schemas/projects:project.cfg
|
||||
|
||||
name: "libyuv"
|
||||
access: "group:all"
|
||||
lucicfg {
|
||||
version: "1.46.1"
|
||||
package_dir: "."
|
||||
config_dir: "."
|
||||
entry_point: "main.star"
|
||||
experiments: "crbug.com/1182002"
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
# Auto-generated by lucicfg.
|
||||
# Do not modify manually.
|
||||
#
|
||||
# For the schema of this file, see RealmsCfg message:
|
||||
# https://config.luci.app/schemas/projects:realms.cfg
|
||||
|
||||
realms {
|
||||
name: "@root"
|
||||
bindings {
|
||||
role: "role/buildbucket.owner"
|
||||
principals: "group:project-libyuv-admins"
|
||||
}
|
||||
bindings {
|
||||
role: "role/buildbucket.reader"
|
||||
principals: "group:all"
|
||||
}
|
||||
bindings {
|
||||
role: "role/configs.reader"
|
||||
principals: "group:all"
|
||||
}
|
||||
bindings {
|
||||
role: "role/configs.validator"
|
||||
principals: "user:libyuv-try-builder@chops-service-accounts.iam.gserviceaccount.com"
|
||||
}
|
||||
bindings {
|
||||
role: "role/logdog.reader"
|
||||
principals: "group:all"
|
||||
}
|
||||
bindings {
|
||||
role: "role/logdog.writer"
|
||||
principals: "group:luci-logdog-chromium-writers"
|
||||
}
|
||||
bindings {
|
||||
role: "role/scheduler.owner"
|
||||
principals: "group:project-libyuv-admins"
|
||||
}
|
||||
bindings {
|
||||
role: "role/scheduler.reader"
|
||||
principals: "group:all"
|
||||
}
|
||||
bindings {
|
||||
role: "role/swarming.taskTriggerer"
|
||||
principals: "group:project-libyuv-admins"
|
||||
}
|
||||
}
|
||||
realms {
|
||||
name: "ci"
|
||||
bindings {
|
||||
role: "role/buildbucket.builderServiceAccount"
|
||||
principals: "user:libyuv-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
|
||||
}
|
||||
bindings {
|
||||
role: "role/scheduler.triggerer"
|
||||
principals: "user:libyuv-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
|
||||
conditions {
|
||||
restrict {
|
||||
attribute: "scheduler.job.name"
|
||||
values: "Android Tester ARM32 Debug (Nexus 5X)"
|
||||
values: "Android Tester ARM32 Release (Nexus 5X)"
|
||||
values: "Android Tester ARM64 Debug (Nexus 5X)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
realms {
|
||||
name: "ci.shadow"
|
||||
bindings {
|
||||
role: "role/buildbucket.builderServiceAccount"
|
||||
principals: "user:libyuv-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
|
||||
}
|
||||
bindings {
|
||||
role: "role/buildbucket.creator"
|
||||
principals: "group:chromium-led-users"
|
||||
principals: "group:mdb/chrome-build-access-sphinx"
|
||||
principals: "group:mdb/chrome-troopers"
|
||||
principals: "group:mdb/foundry-x-team"
|
||||
}
|
||||
}
|
||||
realms {
|
||||
name: "cron"
|
||||
bindings {
|
||||
role: "role/buildbucket.builderServiceAccount"
|
||||
principals: "user:libyuv-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com"
|
||||
}
|
||||
}
|
||||
realms {
|
||||
name: "try"
|
||||
bindings {
|
||||
role: "role/buildbucket.builderServiceAccount"
|
||||
principals: "user:libyuv-try-builder@chops-service-accounts.iam.gserviceaccount.com"
|
||||
}
|
||||
bindings {
|
||||
role: "role/buildbucket.triggerer"
|
||||
principals: "group:project-libyuv-tryjob-access"
|
||||
principals: "group:service-account-cq"
|
||||
}
|
||||
}
|
||||
realms {
|
||||
name: "try.shadow"
|
||||
bindings {
|
||||
role: "role/buildbucket.builderServiceAccount"
|
||||
principals: "user:libyuv-try-builder@chops-service-accounts.iam.gserviceaccount.com"
|
||||
}
|
||||
bindings {
|
||||
role: "role/buildbucket.creator"
|
||||
principals: "group:chromium-led-users"
|
||||
principals: "group:mdb/chrome-build-access-sphinx"
|
||||
principals: "group:mdb/chrome-troopers"
|
||||
principals: "group:mdb/foundry-x-team"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
# Copyright 2026 The LibYuv Project Authors. All rights reserved.
|
||||
#
|
||||
# Shared target definitions for Bazel and Blaze builds.
|
||||
|
||||
def libyuv_srcs(prefix = ""):
|
||||
return native.glob(
|
||||
[
|
||||
prefix + "source/*.cc",
|
||||
prefix + "include/libyuv/*.h",
|
||||
],
|
||||
exclude = [
|
||||
prefix + "source/*neon*.cc",
|
||||
prefix + "source/*rvv*.cc",
|
||||
prefix + "source/*sve*.cc",
|
||||
prefix + "source/*sme*.cc",
|
||||
],
|
||||
)
|
||||
|
||||
def libyuv_hdrs(prefix = ""):
|
||||
return [
|
||||
prefix + "include/libyuv/compare.h",
|
||||
prefix + "include/libyuv/convert.h",
|
||||
prefix + "include/libyuv/convert_from_argb.h",
|
||||
prefix + "include/libyuv/cpu_id.h",
|
||||
prefix + "include/libyuv/row.h", # Bug 553148013: Should be private.
|
||||
]
|
||||
|
||||
def libyuv_neon_srcs(prefix = ""):
|
||||
return native.glob([
|
||||
prefix + "source/*neon*.cc",
|
||||
prefix + "include/libyuv/*.h",
|
||||
])
|
||||
|
||||
def libyuv_rvv_srcs(prefix = ""):
|
||||
return native.glob([
|
||||
prefix + "source/*rvv*.cc",
|
||||
prefix + "include/libyuv/*.h",
|
||||
])
|
||||
|
||||
def libyuv_sve_srcs(prefix = ""):
|
||||
return native.glob([
|
||||
prefix + "source/*sve*.cc",
|
||||
prefix + "include/libyuv/*.h",
|
||||
])
|
||||
|
||||
def libyuv_test_srcs(prefix = ""):
|
||||
return native.glob([
|
||||
prefix + "unit_test/*.cc",
|
||||
prefix + "unit_test/*.h",
|
||||
])
|
||||
+15
-4
@@ -6,18 +6,29 @@
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
import("//build_overrides/build.gni")
|
||||
import("//build/config/arm.gni")
|
||||
import("//build/config/loongarch64.gni")
|
||||
import("//build/config/mips.gni")
|
||||
import("//build_overrides/build.gni")
|
||||
|
||||
declare_args() {
|
||||
libyuv_include_tests = !build_with_chromium
|
||||
libyuv_disable_jpeg = false
|
||||
libyuv_use_neon =
|
||||
current_cpu == "arm64" ||
|
||||
(current_cpu == "arm" && (arm_use_neon || arm_optionally_use_neon))
|
||||
libyuv_disable_rvv = false
|
||||
libyuv_enable_rowwin = false
|
||||
libyuv_use_neon = current_cpu == "arm64" || current_cpu == "arm"
|
||||
libyuv_use_sve = current_cpu == "arm64"
|
||||
|
||||
# Restrict to (is_linux || is_android) to work around undefined symbol linker
|
||||
# errors on Fuchsia, macOS, and compilation errors on Windows.
|
||||
# TODO: bug 359006069 - Remove the restriction after the linker and
|
||||
# compilation errors are fixed.
|
||||
libyuv_use_sme = current_cpu == "arm64" && (is_linux || is_android)
|
||||
libyuv_use_msa =
|
||||
(current_cpu == "mips64el" || current_cpu == "mipsel") && mips_use_msa
|
||||
libyuv_use_mmi =
|
||||
(current_cpu == "mips64el" || current_cpu == "mipsel") && mips_use_mmi
|
||||
libyuv_use_lsx = current_cpu == "loong64" && loongarch64_use_lsx
|
||||
libyuv_use_lasx = current_cpu == "loong64" && loongarch64_use_lasx
|
||||
libyuv_use_rvv = current_cpu == "riscv64" || current_cpu == "riscv32"
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
# Copyright 2011 The LibYuv Project Authors. All rights reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
{
|
||||
'includes': [
|
||||
'libyuv.gypi',
|
||||
],
|
||||
# Make sure that if we are being compiled to an xcodeproj, nothing tries to
|
||||
# include a .pch.
|
||||
'xcode_settings': {
|
||||
'GCC_PREFIX_HEADER': '',
|
||||
'GCC_PRECOMPILE_PREFIX_HEADER': 'NO',
|
||||
},
|
||||
'variables': {
|
||||
'use_system_libjpeg%': 0,
|
||||
# Can be enabled if your jpeg has GYP support.
|
||||
'libyuv_disable_jpeg%': 1,
|
||||
# 'chromium_code' treats libyuv as internal and increases warning level.
|
||||
'chromium_code': 1,
|
||||
# clang compiler default variable usable by other apps that include libyuv.
|
||||
'clang%': 0,
|
||||
# Link-Time Optimizations.
|
||||
'use_lto%': 0,
|
||||
'build_neon': 0,
|
||||
'conditions': [
|
||||
['(target_arch == "armv7" or target_arch == "armv7s" or \
|
||||
(target_arch == "arm" and arm_version >= 7) or target_arch == "arm64")\
|
||||
and (arm_neon == 1 or arm_neon_optional == 1)', {
|
||||
'build_neon': 1,
|
||||
}],
|
||||
],
|
||||
},
|
||||
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'libyuv',
|
||||
# Change type to 'shared_library' to build .so or .dll files.
|
||||
'type': 'static_library',
|
||||
'variables': {
|
||||
'optimize': 'max', # enable O2 and ltcg.
|
||||
},
|
||||
# Allows libyuv.a redistributable library without external dependencies.
|
||||
'standalone_static_library': 1,
|
||||
'conditions': [
|
||||
# Disable -Wunused-parameter
|
||||
['clang == 1', {
|
||||
'cflags': [
|
||||
'-Wno-unused-parameter',
|
||||
],
|
||||
}],
|
||||
['build_neon != 0', {
|
||||
'defines': [
|
||||
'LIBYUV_NEON',
|
||||
],
|
||||
'cflags!': [
|
||||
'-mfpu=vfp',
|
||||
'-mfpu=vfpv3',
|
||||
'-mfpu=vfpv3-d16',
|
||||
# '-mthumb', # arm32 not thumb
|
||||
],
|
||||
'conditions': [
|
||||
# Disable LTO in libyuv_neon target due to gcc 4.9 compiler bug.
|
||||
['clang == 0 and use_lto == 1', {
|
||||
'cflags!': [
|
||||
'-flto',
|
||||
'-ffat-lto-objects',
|
||||
],
|
||||
}],
|
||||
# arm64 does not need -mfpu=neon option as neon is not optional
|
||||
['target_arch != "arm64"', {
|
||||
'cflags': [
|
||||
'-mfpu=neon',
|
||||
# '-marm', # arm32 not thumb
|
||||
],
|
||||
}],
|
||||
],
|
||||
}],
|
||||
['OS != "ios" and libyuv_disable_jpeg != 1', {
|
||||
'defines': [
|
||||
'HAVE_JPEG'
|
||||
],
|
||||
'conditions': [
|
||||
# Caveat system jpeg support may not support motion jpeg
|
||||
[ 'use_system_libjpeg == 1', {
|
||||
'dependencies': [
|
||||
'<(DEPTH)/third_party/libjpeg/libjpeg.gyp:libjpeg',
|
||||
],
|
||||
}, {
|
||||
'dependencies': [
|
||||
'<(DEPTH)/third_party/libjpeg_turbo/libjpeg.gyp:libjpeg',
|
||||
],
|
||||
}],
|
||||
[ 'use_system_libjpeg == 1', {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'-ljpeg',
|
||||
],
|
||||
}
|
||||
}],
|
||||
],
|
||||
}],
|
||||
], #conditions
|
||||
'defines': [
|
||||
# Enable the following 3 macros to turn off assembly for specified CPU.
|
||||
# 'LIBYUV_DISABLE_X86',
|
||||
# 'LIBYUV_DISABLE_NEON',
|
||||
# Enable the following macro to build libyuv as a shared library (dll).
|
||||
# 'LIBYUV_USING_SHARED_LIBRARY',
|
||||
# TODO(fbarchard): Make these into gyp defines.
|
||||
],
|
||||
'include_dirs': [
|
||||
'include',
|
||||
'.',
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
'include',
|
||||
'.',
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'<@(libyuv_sources)',
|
||||
],
|
||||
},
|
||||
], # targets.
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# tab-width:2
|
||||
# indent-tabs-mode:nil
|
||||
# End:
|
||||
# vim: set expandtab tabstop=2 shiftwidth=2:
|
||||
@@ -0,0 +1,96 @@
|
||||
# Copyright 2014 The LibYuv Project Authors. All rights reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
{
|
||||
'variables': {
|
||||
'libyuv_sources': [
|
||||
# includes.
|
||||
'include/libyuv.h',
|
||||
'include/libyuv/basic_types.h',
|
||||
'include/libyuv/compare.h',
|
||||
'include/libyuv/compare_row.h',
|
||||
'include/libyuv/convert.h',
|
||||
'include/libyuv/convert_argb.h',
|
||||
'include/libyuv/convert_from.h',
|
||||
'include/libyuv/convert_from_argb.h',
|
||||
'include/libyuv/cpu_id.h',
|
||||
'include/libyuv/cpu_support.h',
|
||||
'include/libyuv/loongson_intrinsics.h',
|
||||
'include/libyuv/mjpeg_decoder.h',
|
||||
'include/libyuv/planar_functions.h',
|
||||
'include/libyuv/rotate.h',
|
||||
'include/libyuv/rotate_argb.h',
|
||||
'include/libyuv/rotate_row.h',
|
||||
'include/libyuv/row.h',
|
||||
'include/libyuv/row_sve.h',
|
||||
'include/libyuv/scale.h',
|
||||
'include/libyuv/scale_argb.h',
|
||||
'include/libyuv/scale_rgb.h',
|
||||
'include/libyuv/scale_row.h',
|
||||
'include/libyuv/scale_uv.h',
|
||||
'include/libyuv/version.h',
|
||||
'include/libyuv/video_common.h',
|
||||
|
||||
# sources.
|
||||
'source/compare.cc',
|
||||
'source/compare_common.cc',
|
||||
'source/compare_gcc.cc',
|
||||
'source/compare_hvx.cc',
|
||||
'source/compare_neon.cc',
|
||||
'source/compare_neon64.cc',
|
||||
'source/compare_win.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_hvx.cc',
|
||||
'source/rotate_lasx.cc',
|
||||
'source/rotate_lsx.cc',
|
||||
'source/rotate_neon.cc',
|
||||
'source/rotate_neon64.cc',
|
||||
'source/rotate_rvv.cc',
|
||||
'source/rotate_win.cc',
|
||||
'source/row_any.cc',
|
||||
'source/row_common.cc',
|
||||
'source/row_gcc.cc',
|
||||
'source/row_hvx.cc',
|
||||
'source/row_lasx.cc',
|
||||
'source/row_lsx.cc',
|
||||
'source/row_neon.cc',
|
||||
'source/row_neon64.cc',
|
||||
'source/row_rvv.cc',
|
||||
'source/row_win.cc',
|
||||
'source/scale.cc',
|
||||
'source/scale_any.cc',
|
||||
'source/scale_argb.cc',
|
||||
'source/scale_common.cc',
|
||||
'source/scale_gcc.cc',
|
||||
'source/scale_hvx.cc',
|
||||
'source/scale_lsx.cc',
|
||||
'source/scale_neon.cc',
|
||||
'source/scale_neon64.cc',
|
||||
'source/scale_rgb.cc',
|
||||
'source/scale_rvv.cc',
|
||||
'source/scale_uv.cc',
|
||||
'source/scale_win.cc',
|
||||
'source/video_common.cc',
|
||||
],
|
||||
}
|
||||
}
|
||||
+36
-18
@@ -13,15 +13,14 @@ LOCAL_OBJ_FILES := \
|
||||
source/compare.o \
|
||||
source/compare_common.o \
|
||||
source/compare_gcc.o \
|
||||
source/compare_mmi.o \
|
||||
source/compare_msa.o \
|
||||
source/compare_neon64.o \
|
||||
source/compare_hvx.o \
|
||||
source/compare_neon.o \
|
||||
source/compare_neon64.o \
|
||||
source/compare_win.o \
|
||||
source/convert_argb.o \
|
||||
source/convert.o \
|
||||
source/convert_from_argb.o \
|
||||
source/convert_argb.o \
|
||||
source/convert_from.o \
|
||||
source/convert_from_argb.o \
|
||||
source/convert_jpeg.o \
|
||||
source/convert_to_argb.o \
|
||||
source/convert_to_i420.o \
|
||||
@@ -29,33 +28,40 @@ LOCAL_OBJ_FILES := \
|
||||
source/mjpeg_decoder.o \
|
||||
source/mjpeg_validate.o \
|
||||
source/planar_functions.o \
|
||||
source/rotate.o \
|
||||
source/rotate_any.o \
|
||||
source/rotate_argb.o \
|
||||
source/rotate.o \
|
||||
source/rotate_common.o \
|
||||
source/rotate_gcc.o \
|
||||
source/rotate_mmi.o \
|
||||
source/rotate_msa.o \
|
||||
source/rotate_neon64.o \
|
||||
source/rotate_hvx.o \
|
||||
source/rotate_lasx.o \
|
||||
source/rotate_lsx.o \
|
||||
source/rotate_neon.o \
|
||||
source/rotate_neon64.o \
|
||||
source/rotate_rvv.o \
|
||||
source/rotate_win.o \
|
||||
source/row_any.o \
|
||||
source/row_common.o \
|
||||
source/row_gcc.o \
|
||||
source/row_mmi.o \
|
||||
source/row_msa.o \
|
||||
source/row_neon64.o \
|
||||
source/row_hvx.o \
|
||||
source/row_lasx.o \
|
||||
source/row_lsx.o \
|
||||
source/row_neon.o \
|
||||
source/row_neon64.o \
|
||||
source/row_rvv.o \
|
||||
source/row_win.o \
|
||||
source/scale.o \
|
||||
source/scale_any.o \
|
||||
source/scale_argb.o \
|
||||
source/scale.o \
|
||||
source/scale_common.o \
|
||||
source/scale_gcc.o \
|
||||
source/scale_mmi.o \
|
||||
source/scale_msa.o \
|
||||
source/scale_neon64.o \
|
||||
source/scale_hvx.o \
|
||||
source/scale_lsx.o \
|
||||
source/scale_neon.o \
|
||||
source/scale_neon64.o \
|
||||
source/scale_rgb.o \
|
||||
source/scale_rvv.o \
|
||||
source/scale_uv.o \
|
||||
source/scale_win.o \
|
||||
source/video_common.o
|
||||
|
||||
@@ -65,19 +71,31 @@ LOCAL_OBJ_FILES := \
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $*.c -o $*.o
|
||||
|
||||
all: libyuv.a yuvconvert cpuid psnr
|
||||
all: libyuv.a i444tonv12_eg yuvconvert yuvconstants cpuid psnr compare
|
||||
|
||||
libyuv.a: $(LOCAL_OBJ_FILES)
|
||||
$(AR) $(ARFLAGS) $@ $(LOCAL_OBJ_FILES)
|
||||
|
||||
# A C++ test utility that compares two YUV files.
|
||||
compare: util/compare.cc libyuv.a
|
||||
$(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/compare.cc libyuv.a
|
||||
|
||||
# A C++ test utility that uses libyuv conversion.
|
||||
yuvconvert: util/yuvconvert.cc libyuv.a
|
||||
$(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/yuvconvert.cc libyuv.a
|
||||
|
||||
# A C test utility that generates yuvconstants for yuv to rgb.
|
||||
yuvconstants: util/yuvconstants.c libyuv.a
|
||||
$(CXX) $(CXXFLAGS) -Iutil/ -lm -o $@ util/yuvconstants.c libyuv.a
|
||||
|
||||
# A standalone test utility
|
||||
psnr: util/psnr.cc
|
||||
$(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/psnr.cc util/psnr_main.cc util/ssim.cc
|
||||
|
||||
# A simple conversion example.
|
||||
i444tonv12_eg: util/i444tonv12_eg.cc libyuv.a
|
||||
$(CXX) $(CXXFLAGS) -o $@ util/i444tonv12_eg.cc libyuv.a
|
||||
|
||||
# A C test utility that uses libyuv conversion from C.
|
||||
# gcc 4.4 and older require -fno-exceptions to avoid link error on __gxx_personality_v0
|
||||
# CC=gcc-4.4 CXXFLAGS=-fno-exceptions CXX=g++-4.4 make -f linux.mk
|
||||
@@ -85,4 +103,4 @@ cpuid: util/cpuid.c libyuv.a
|
||||
$(CC) $(CFLAGS) -o $@ util/cpuid.c libyuv.a
|
||||
|
||||
clean:
|
||||
/bin/rm -f source/*.o *.ii *.s libyuv.a yuvconvert cpuid psnr
|
||||
/bin/rm -f source/*.o *.ii *.s libyuv.a i444tonv12_eg yuvconvert yuvconstants cpuid psnr compare
|
||||
+34
-2
@@ -13,5 +13,37 @@ reports=no
|
||||
|
||||
[FORMAT]
|
||||
|
||||
# We use two spaces for indents, instead of the usual four spaces or tab.
|
||||
indent-string=' '
|
||||
# Maximum number of characters on a single line.
|
||||
max-line-length=79
|
||||
|
||||
# We use four spaces for indents.
|
||||
indent-string=' '
|
||||
|
||||
[BASIC]
|
||||
|
||||
# List of builtins function names that should not be used, separated by a comma
|
||||
bad-functions=map,filter,apply,input
|
||||
|
||||
# Naming style matching correct module names.
|
||||
module-naming-style=snake_case
|
||||
|
||||
# Naming style matching correct constant names.
|
||||
const-naming-style=UPPER_CASE
|
||||
|
||||
# Naming style matching correct class names.
|
||||
class-naming-style=PascalCase
|
||||
|
||||
# Naming style matching correct function names.
|
||||
function-naming-style=snake_case
|
||||
|
||||
# Regular expression matching correct method names.
|
||||
method-rgx=([a-z_][a-z0-9_]{2,}|setUp|tearDown)$
|
||||
|
||||
# Naming style matching correct attribute names.
|
||||
attr-naming-style=snake_case
|
||||
|
||||
# Naming style matching correct argument names.
|
||||
argument-naming-style=snake_case
|
||||
|
||||
# Naming style matching correct variable names.
|
||||
variable-naming-style=snake_case
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
set -ev
|
||||
|
||||
# Download & build RISC-V Clang toolchain & QEMU emulator.
|
||||
# RISC-V Clang is for cross compile with the RISC-V Vector ISA.
|
||||
# RISC-V QEMU is used to run the test suite.
|
||||
#
|
||||
# Requirements: Linux host w/ working C++ compiler, git, cmake, ninja, wget, tar
|
||||
|
||||
# NOTE: this script must be run from the top-level directory of the LIBYUV_SRC_DIR.
|
||||
|
||||
RISCV_TRIPLE="riscv64-unknown-linux-gnu"
|
||||
RISCV_QEMU="qemu-riscv64"
|
||||
|
||||
LIBYUV_SRC_DIR=$(pwd)
|
||||
BUILD_DIR="$LIBYUV_SRC_DIR"/build-toolchain-qemu
|
||||
INSTALL_QEMU="$BUILD_DIR"/riscv-qemu
|
||||
INSTALL_CLANG="$BUILD_DIR"/riscv-clang
|
||||
|
||||
LLVM_VERSION="16.0.0"
|
||||
LLVM_NAME=llvm-project-"$LLVM_VERSION".src
|
||||
|
||||
RISCV_GNU_TOOLCHAIN="$BUILD_DIR"/riscv-gnu-toolchain
|
||||
RISCV_CLANG_TOOLCHAIN="$BUILD_DIR"/"$LLVM_NAME"
|
||||
|
||||
QEMU_NAME="qemu-7.0.0"
|
||||
|
||||
mkdir -p "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
# Download and install RISC-V GNU Toolchain (needed to build Clang)
|
||||
if [ ! -d "$RISCV_GNU_TOOLCHAIN" ]
|
||||
then
|
||||
git clone git@github.com:riscv/riscv-gnu-toolchain.git
|
||||
pushd "$RISCV_GNU_TOOLCHAIN"
|
||||
git submodule update --init --recursive
|
||||
./configure --with-cmodel=medany --prefix="$INSTALL_CLANG"
|
||||
ionice nice make linux -j `nproc` install
|
||||
popd
|
||||
fi
|
||||
|
||||
# Download Clang toolchain & build cross compiler
|
||||
if [ ! -d "$RISCV_CLANG_TOOLCHAIN" ]
|
||||
then
|
||||
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-"$LLVM_VERSION"/"$LLVM_NAME".tar.xz
|
||||
tar xvJf "$LLVM_NAME".tar.xz
|
||||
pushd "$RISCV_CLANG_TOOLCHAIN"
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$INSTALL_CLANG" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DLLVM_TARGETS_TO_BUILD="RISCV" \
|
||||
-DLLVM_ENABLE_PROJECTS="clang" \
|
||||
-DLLVM_DEFAULT_TARGET_TRIPLE="$RISCV_TRIPLE" \
|
||||
-DLLVM_INSTALL_TOOLCHAIN_ONLY=On \
|
||||
-DDEFAULT_SYSROOT=../sysroot \
|
||||
-G "Ninja" "$RISCV_CLANG_TOOLCHAIN"/llvm
|
||||
ionice nice ninja -j `nproc`
|
||||
ionice nice ninja -j `nproc` install
|
||||
popd
|
||||
pushd "$INSTALL_CLANG"/bin
|
||||
ln -sf clang "$RISCV_TRIPLE"-clang
|
||||
ln -sf clang++ "$RISCV_TRIPLE"-clang++
|
||||
popd
|
||||
fi
|
||||
|
||||
# Download QEMU and build the riscv64 Linux usermode emulator
|
||||
if [ ! -d "$QEMU_NAME" ]
|
||||
then
|
||||
wget https://download.qemu.org/"$QEMU_NAME".tar.xz
|
||||
tar xvJf "$QEMU_NAME".tar.xz
|
||||
pushd "$QEMU_NAME"
|
||||
./configure --target-list=riscv64-linux-user --prefix="$INSTALL_QEMU"
|
||||
ionice nice make -j `nproc` install
|
||||
popd
|
||||
fi
|
||||
@@ -0,0 +1,56 @@
|
||||
set(CMAKE_CROSSCOMPILING TRUE)
|
||||
set(CMAKE_SYSTEM_NAME "Linux")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "riscv64")
|
||||
|
||||
option(USE_RVV "Enable riscv vector or not." ON)
|
||||
option(USE_AUTO_VECTORIZER "Enable riscv auto vectorizer or not." OFF)
|
||||
|
||||
# Avoid to use system path for cross-compile
|
||||
set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE)
|
||||
|
||||
set(TOOLCHAIN_PATH "" CACHE STRING "The toolcahin path.")
|
||||
if(NOT TOOLCHAIN_PATH)
|
||||
set(TOOLCHAIN_PATH ${CMAKE_SOURCE_DIR}/build-toolchain-qemu/riscv-clang)
|
||||
endif()
|
||||
|
||||
set(TOOLCHAIN_PREFIX "riscv64-unknown-linux-gnu-" CACHE STRING "The toolcahin prefix.")
|
||||
|
||||
# toolchain setting
|
||||
set(CMAKE_C_COMPILER "${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}clang")
|
||||
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}clang++")
|
||||
|
||||
# CMake will just use the host-side tools for the following tools, so we setup them here.
|
||||
set(CMAKE_C_COMPILER_AR "${TOOLCHAIN_PATH}/bin/llvm-ar")
|
||||
set(CMAKE_CXX_COMPILER_AR "${TOOLCHAIN_PATH}/bin/llvm-ar")
|
||||
set(CMAKE_C_COMPILER_RANLIB "${TOOLCHAIN_PATH}/bin/llvm-ranlib")
|
||||
set(CMAKE_CXX_COMPILER_RANLIB "${TOOLCHAIN_PATH}/bin/llvm-ranlib")
|
||||
set(CMAKE_OBJDUMP "${TOOLCHAIN_PATH}/bin/llvm-objdump")
|
||||
set(CMAKE_OBJCOPY "${TOOLCHAIN_PATH}/bin/llvm-objcopy")
|
||||
|
||||
# compile options
|
||||
set(RISCV_COMPILER_FLAGS "" CACHE STRING "Compile flags")
|
||||
# if user provides RISCV_COMPILER_FLAGS, appeding compile flags is avoided.
|
||||
if(RISCV_COMPILER_FLAGS STREQUAL "")
|
||||
message(STATUS "USE_RVV: ${USE_RVV}")
|
||||
message(STATUS "USE_AUTO_VECTORIZER: ${USE_AUTO_VECTORIZER}")
|
||||
if(USE_RVV)
|
||||
list(APPEND RISCV_COMPILER_FLAGS "-march=rv64gcv")
|
||||
if(NOT USE_AUTO_VECTORIZER)
|
||||
# Disable auto-vectorizer
|
||||
add_compile_options(-fno-tree-vectorize -fno-tree-slp-vectorize)
|
||||
endif()
|
||||
else()
|
||||
list(APPEND RISCV_COMPILER_FLAGS "-march=rv64gc")
|
||||
endif()
|
||||
endif()
|
||||
add_compile_options("-Wuninitialized")
|
||||
message(STATUS "RISCV_COMPILER_FLAGS: ${RISCV_COMPILER_FLAGS}")
|
||||
|
||||
set(CMAKE_C_FLAGS "${RISCV_COMPILER_FLAGS} ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${RISCV_COMPILER_FLAGS} ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
set(RISCV_LINKER_FLAGS "-lstdc++ -lpthread -lm -ldl")
|
||||
set(RISCV_LINKER_FLAGS_EXE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${RISCV_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${RISCV_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${RISCV_LINKER_FLAGS} ${RISCV_LINKER_FLAGS_EXE} ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -x
|
||||
set -e
|
||||
|
||||
USE_RVV="${USE_RVV:-OFF}"
|
||||
TOOLCHAIN_PATH="${TOOLCHAIN_PATH:-../../build-toolchain-qemu/riscv-clang}"
|
||||
QEMU_PREFIX_PATH="${QEMU_PREFIX_PATH:-../../build-toolchain-qemu/riscv-qemu/}"
|
||||
|
||||
if [ "${USE_RVV}" = "ON" ];then
|
||||
QEMU_OPTION="-cpu rv64,zba=true,zbb=true,zbc=true,zbs=true,v=true,vlen=512,elen=64,vext_spec=v1.0 -L ${TOOLCHAIN_PATH}/sysroot"
|
||||
else
|
||||
QEMU_OPTION="-cpu rv64,zba=true,zbb=true,zbc=true,zbs=true -L ${TOOLCHAIN_PATH}/sysroot"
|
||||
fi
|
||||
|
||||
$QEMU_PREFIX_PATH/bin/qemu-riscv64 $QEMU_OPTION $@
|
||||
+527
-103
@@ -11,12 +11,13 @@
|
||||
#include "libyuv/compare.h"
|
||||
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
#include "libyuv/compare_row.h"
|
||||
#include "libyuv/cpu_id.h"
|
||||
#include "libyuv/row.h"
|
||||
@@ -31,6 +32,7 @@ extern "C" {
|
||||
LIBYUV_API
|
||||
uint32_t HashDjb2(const uint8_t* src, uint64_t count, uint32_t seed) {
|
||||
const int kBlockSize = 1 << 15; // 32768;
|
||||
int simd_size = 16; // SIMD for multiple of 16, and C for remainder.
|
||||
int remainder;
|
||||
uint32_t (*HashDjb2_SSE)(const uint8_t* src, int count, uint32_t seed) =
|
||||
HashDjb2_C;
|
||||
@@ -42,55 +44,78 @@ uint32_t HashDjb2(const uint8_t* src, uint64_t count, uint32_t seed) {
|
||||
#if defined(HAS_HASHDJB2_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
HashDjb2_SSE = HashDjb2_AVX2;
|
||||
simd_size = 32;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HASHDJB2_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
HashDjb2_SSE = HashDjb2_NEON;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HASHDJB2_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
HashDjb2_SSE = HashDjb2_AVX512BW;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HASHDJB2_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
HashDjb2_SSE = HashDjb2_RVV;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HASHDJB2_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
HashDjb2_SSE = HashDjb2_LSX;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HASHDJB2_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
HashDjb2_SSE = HashDjb2_LASX;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HASHDJB2_WASMSIMD)
|
||||
if (TestCpuFlag(kCpuHasWASMSIMD)) {
|
||||
HashDjb2_SSE = HashDjb2_WASMSIMD;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HASHDJB2_HVX)
|
||||
if (TestCpuFlag(kCpuHasHVX)) {
|
||||
HashDjb2_SSE = HashDjb2_HVX;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
|
||||
while (count >= (uint64_t)(kBlockSize)) {
|
||||
while (count >= (uint64_t)kBlockSize) {
|
||||
seed = HashDjb2_SSE(src, kBlockSize, seed);
|
||||
src += kBlockSize;
|
||||
count -= kBlockSize;
|
||||
}
|
||||
remainder = (int)count & ~15;
|
||||
remainder = (int)count & ~(simd_size - 1);
|
||||
if (remainder) {
|
||||
seed = HashDjb2_SSE(src, remainder, seed);
|
||||
src += remainder;
|
||||
count -= remainder;
|
||||
}
|
||||
remainder = (int)count & 15;
|
||||
remainder = (int)count & (simd_size - 1);
|
||||
if (remainder) {
|
||||
seed = HashDjb2_C(src, remainder, seed);
|
||||
if (HashDjb2_SSE == HashDjb2_C) {
|
||||
seed = HashDjb2_C(src, remainder, seed);
|
||||
} else {
|
||||
SIMD_ALIGNED(uint8_t buf[32]);
|
||||
uint32_t pow33 = 1;
|
||||
int i;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
for (i = 0; i < remainder; ++i) {
|
||||
pow33 *= 33;
|
||||
}
|
||||
memcpy(buf + simd_size - remainder, src, remainder);
|
||||
seed = seed * pow33 + HashDjb2_SSE(buf, simd_size, 0);
|
||||
}
|
||||
}
|
||||
return seed;
|
||||
}
|
||||
|
||||
static uint32_t ARGBDetectRow_C(const uint8_t* argb, int width) {
|
||||
int x;
|
||||
for (x = 0; x < width - 1; x += 2) {
|
||||
if (argb[0] != 255) { // First byte is not Alpha of 255, so not ARGB.
|
||||
return FOURCC_BGRA;
|
||||
}
|
||||
if (argb[3] != 255) { // Fourth byte is not Alpha of 255, so not BGRA.
|
||||
return FOURCC_ARGB;
|
||||
}
|
||||
if (argb[4] != 255) { // Second pixel first byte is not Alpha of 255.
|
||||
return FOURCC_BGRA;
|
||||
}
|
||||
if (argb[7] != 255) { // Second pixel fourth byte is not Alpha of 255.
|
||||
return FOURCC_ARGB;
|
||||
}
|
||||
argb += 8;
|
||||
}
|
||||
if (width & 1) {
|
||||
if (argb[0] != 255) { // First byte is not Alpha of 255, so not ARGB.
|
||||
return FOURCC_BGRA;
|
||||
}
|
||||
if (argb[3] != 255) { // 4th byte is not Alpha of 255, so not BGRA.
|
||||
return FOURCC_ARGB;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Scan an opaque argb image and return fourcc based on alpha offset.
|
||||
// Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown.
|
||||
LIBYUV_API
|
||||
@@ -98,17 +123,56 @@ uint32_t ARGBDetect(const uint8_t* argb,
|
||||
int stride_argb,
|
||||
int width,
|
||||
int height) {
|
||||
uint32_t (*ARGBDetectRow)(const uint8_t* argb, int width) = ARGBDetectRow_C;
|
||||
uint32_t fourcc = 0;
|
||||
int h;
|
||||
|
||||
if (!argb || width <= 0 || height <= 0) {
|
||||
return fourcc;
|
||||
}
|
||||
// Coalesce rows.
|
||||
if (stride_argb == width * 4) {
|
||||
if (stride_argb == width * 4 && (ptrdiff_t)width * height <= INT_MAX) {
|
||||
width *= height;
|
||||
height = 1;
|
||||
stride_argb = 0;
|
||||
}
|
||||
#if defined(HAS_ARGBDETECTROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
ARGBDetectRow = ARGBDetectRow_AVX2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBDETECTROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
ARGBDetectRow = ARGBDetectRow_NEON;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBDETECTROW_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
ARGBDetectRow = ARGBDetectRow_RVV;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBDETECTROW_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
ARGBDetectRow = ARGBDetectRow_LSX;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBDETECTROW_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
ARGBDetectRow = ARGBDetectRow_LASX;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBDETECTROW_WASMSIMD)
|
||||
if (TestCpuFlag(kCpuHasWASMSIMD)) {
|
||||
ARGBDetectRow = ARGBDetectRow_WASMSIMD;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBDETECTROW_HVX)
|
||||
if (TestCpuFlag(kCpuHasHVX)) {
|
||||
ARGBDetectRow = ARGBDetectRow_HVX;
|
||||
}
|
||||
#endif
|
||||
for (h = 0; h < height && fourcc == 0; ++h) {
|
||||
fourcc = ARGBDetectRow_C(argb, width);
|
||||
fourcc = ARGBDetectRow(argb, width);
|
||||
argb += stride_argb;
|
||||
}
|
||||
return fourcc;
|
||||
@@ -122,9 +186,8 @@ uint64_t ComputeHammingDistance(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
const int kBlockSize = 1 << 15; // 32768;
|
||||
const int kSimdSize = 64;
|
||||
// SIMD for multiple of 64, and C for remainder
|
||||
int remainder = count & (kBlockSize - 1) & ~(kSimdSize - 1);
|
||||
int simd_size = 64; // SIMD for multiple of 64, and C for remainder.
|
||||
int remainder;
|
||||
uint64_t diff = 0;
|
||||
int i;
|
||||
uint32_t (*HammingDistance)(const uint8_t* src_a, const uint8_t* src_b,
|
||||
@@ -134,6 +197,11 @@ uint64_t ComputeHammingDistance(const uint8_t* src_a,
|
||||
HammingDistance = HammingDistance_NEON;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HAMMINGDISTANCE_NEON_DOTPROD)
|
||||
if (TestCpuFlag(kCpuHasNeonDotProd)) {
|
||||
HammingDistance = HammingDistance_NEON_DotProd;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HAMMINGDISTANCE_SSSE3)
|
||||
if (TestCpuFlag(kCpuHasSSSE3)) {
|
||||
HammingDistance = HammingDistance_SSSE3;
|
||||
@@ -149,16 +217,46 @@ uint64_t ComputeHammingDistance(const uint8_t* src_a,
|
||||
HammingDistance = HammingDistance_AVX2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HAMMINGDISTANCE_MSA)
|
||||
if (TestCpuFlag(kCpuHasMSA)) {
|
||||
HammingDistance = HammingDistance_MSA;
|
||||
#if defined(HAS_HAMMINGDISTANCE_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
HammingDistance = HammingDistance_AVX512BW;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HAMMINGDISTANCE_MMI)
|
||||
if (TestCpuFlag(kCpuHasMMI)) {
|
||||
HammingDistance = HammingDistance_MMI;
|
||||
#if defined(HAS_HAMMINGDISTANCE_AVX512VNNI)
|
||||
if (TestCpuFlag(kCpuHasAVX512VNNI)) {
|
||||
HammingDistance = HammingDistance_AVX512VNNI;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HAMMINGDISTANCE_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
HammingDistance = HammingDistance_RVV;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HAMMINGDISTANCE_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
HammingDistance = HammingDistance_LSX;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HAMMINGDISTANCE_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
HammingDistance = HammingDistance_LASX;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HAMMINGDISTANCE_WASMSIMD)
|
||||
if (TestCpuFlag(kCpuHasWASMSIMD)) {
|
||||
HammingDistance = HammingDistance_WASMSIMD;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_HAMMINGDISTANCE_HVX)
|
||||
if (TestCpuFlag(kCpuHasHVX)) {
|
||||
HammingDistance = HammingDistance_HVX;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
remainder = count & (kBlockSize - 1) & ~(simd_size - 1);
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for reduction(+ : diff)
|
||||
@@ -173,9 +271,19 @@ uint64_t ComputeHammingDistance(const uint8_t* src_a,
|
||||
src_a += remainder;
|
||||
src_b += remainder;
|
||||
}
|
||||
remainder = count & (kSimdSize - 1);
|
||||
remainder = count & (simd_size - 1);
|
||||
if (remainder) {
|
||||
diff += HammingDistance_C(src_a, src_b, remainder);
|
||||
if (HammingDistance == HammingDistance_C) {
|
||||
diff += HammingDistance_C(src_a, src_b, remainder);
|
||||
} else {
|
||||
SIMD_ALIGNED(uint8_t buf_a[64]);
|
||||
SIMD_ALIGNED(uint8_t buf_b[64]);
|
||||
memset(buf_a, 0, sizeof(buf_a));
|
||||
memset(buf_b, 0, sizeof(buf_b));
|
||||
memcpy(buf_a, src_a, remainder);
|
||||
memcpy(buf_b, src_b, remainder);
|
||||
diff += HammingDistance(buf_a, buf_b, simd_size);
|
||||
}
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
@@ -189,7 +297,8 @@ uint64_t ComputeSumSquareError(const uint8_t* src_a,
|
||||
// Up to 65536 of those can be summed and remain within a uint32_t.
|
||||
// After each block of 65536 pixels, accumulate into a uint64_t.
|
||||
const int kBlockSize = 65536;
|
||||
int remainder = count & (kBlockSize - 1) & ~31;
|
||||
int simd_size = 32; // SIMD for multiple of 32, and C for remainder.
|
||||
int remainder;
|
||||
uint64_t sse = 0;
|
||||
int i;
|
||||
uint32_t (*SumSquareError)(const uint8_t* src_a, const uint8_t* src_b,
|
||||
@@ -199,6 +308,11 @@ uint64_t ComputeSumSquareError(const uint8_t* src_a,
|
||||
SumSquareError = SumSquareError_NEON;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SUMSQUAREERROR_NEON_DOTPROD)
|
||||
if (TestCpuFlag(kCpuHasNeonDotProd)) {
|
||||
SumSquareError = SumSquareError_NEON_DotProd;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SUMSQUAREERROR_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
// Note only used for multiples of 16 so count is not checked.
|
||||
@@ -211,16 +325,46 @@ uint64_t ComputeSumSquareError(const uint8_t* src_a,
|
||||
SumSquareError = SumSquareError_AVX2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SUMSQUAREERROR_MSA)
|
||||
if (TestCpuFlag(kCpuHasMSA)) {
|
||||
SumSquareError = SumSquareError_MSA;
|
||||
#if defined(HAS_SUMSQUAREERROR_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
SumSquareError = SumSquareError_AVX512BW;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SUMSQUAREERROR_MMI)
|
||||
if (TestCpuFlag(kCpuHasMMI)) {
|
||||
SumSquareError = SumSquareError_MMI;
|
||||
#if defined(HAS_SUMSQUAREERROR_AVX512VNNI)
|
||||
if (TestCpuFlag(kCpuHasAVX512VNNI)) {
|
||||
SumSquareError = SumSquareError_AVX512VNNI;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SUMSQUAREERROR_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
SumSquareError = SumSquareError_RVV;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SUMSQUAREERROR_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
SumSquareError = SumSquareError_LSX;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SUMSQUAREERROR_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
SumSquareError = SumSquareError_LASX;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SUMSQUAREERROR_WASMSIMD)
|
||||
if (TestCpuFlag(kCpuHasWASMSIMD)) {
|
||||
SumSquareError = SumSquareError_WASMSIMD;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SUMSQUAREERROR_HVX)
|
||||
if (TestCpuFlag(kCpuHasHVX)) {
|
||||
SumSquareError = SumSquareError_HVX;
|
||||
simd_size = 1; // Any count.
|
||||
}
|
||||
#endif
|
||||
remainder = count & (kBlockSize - 1) & ~(simd_size - 1);
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for reduction(+ : sse)
|
||||
#endif
|
||||
@@ -234,9 +378,19 @@ uint64_t ComputeSumSquareError(const uint8_t* src_a,
|
||||
src_a += remainder;
|
||||
src_b += remainder;
|
||||
}
|
||||
remainder = count & 31;
|
||||
remainder = count & (simd_size - 1);
|
||||
if (remainder) {
|
||||
sse += SumSquareError_C(src_a, src_b, remainder);
|
||||
if (SumSquareError == SumSquareError_C) {
|
||||
sse += SumSquareError_C(src_a, src_b, remainder);
|
||||
} else {
|
||||
SIMD_ALIGNED(uint8_t buf_a[32]);
|
||||
SIMD_ALIGNED(uint8_t buf_b[32]);
|
||||
memset(buf_a, 0, sizeof(buf_a));
|
||||
memset(buf_b, 0, sizeof(buf_b));
|
||||
memcpy(buf_a, src_a, remainder);
|
||||
memcpy(buf_b, src_b, remainder);
|
||||
sse += SumSquareError(buf_a, buf_b, simd_size);
|
||||
}
|
||||
}
|
||||
return sse;
|
||||
}
|
||||
@@ -250,8 +404,12 @@ uint64_t ComputeSumSquareErrorPlane(const uint8_t* src_a,
|
||||
int height) {
|
||||
uint64_t sse = 0;
|
||||
int h;
|
||||
if (!src_a || !src_b || width <= 0 || height <= 0) {
|
||||
return sse;
|
||||
}
|
||||
// Coalesce rows.
|
||||
if (stride_a == width && stride_b == width) {
|
||||
if (stride_a == width && stride_b == width &&
|
||||
(ptrdiff_t)width * height <= INT_MAX) {
|
||||
width *= height;
|
||||
height = 1;
|
||||
stride_a = stride_b = 0;
|
||||
@@ -323,18 +481,14 @@ double I420Psnr(const uint8_t* src_y_a,
|
||||
return SumSquareErrorToPsnr(sse, samples);
|
||||
}
|
||||
|
||||
static const int64_t cc1 = 26634; // (64^2*(.01*255)^2
|
||||
static const int64_t cc2 = 239708; // (64^2*(.03*255)^2
|
||||
|
||||
static double Ssim8x8_C(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b) {
|
||||
int64_t sum_a = 0;
|
||||
int64_t sum_b = 0;
|
||||
int64_t sum_sq_a = 0;
|
||||
int64_t sum_sq_b = 0;
|
||||
int64_t sum_axb = 0;
|
||||
static float Ssim8x8(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b) {
|
||||
int32_t sum_a = 0;
|
||||
int32_t sum_b = 0;
|
||||
int32_t sum_sq_ab = 0;
|
||||
int32_t sum_axb = 0;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 8; ++i) {
|
||||
@@ -342,8 +496,7 @@ static double Ssim8x8_C(const uint8_t* src_a,
|
||||
for (j = 0; j < 8; ++j) {
|
||||
sum_a += src_a[j];
|
||||
sum_b += src_b[j];
|
||||
sum_sq_a += src_a[j] * src_a[j];
|
||||
sum_sq_b += src_b[j] * src_b[j];
|
||||
sum_sq_ab += src_a[j] * src_a[j] + src_b[j] * src_b[j];
|
||||
sum_axb += src_a[j] * src_b[j];
|
||||
}
|
||||
|
||||
@@ -352,30 +505,90 @@ static double Ssim8x8_C(const uint8_t* src_a,
|
||||
}
|
||||
|
||||
{
|
||||
const int64_t count = 64;
|
||||
// scale the constants by number of pixels
|
||||
const int64_t c1 = (cc1 * count * count) >> 12;
|
||||
const int64_t c2 = (cc2 * count * count) >> 12;
|
||||
|
||||
const int64_t sum_a_x_sum_b = sum_a * sum_b;
|
||||
|
||||
const int64_t ssim_n = (2 * sum_a_x_sum_b + c1) *
|
||||
(2 * count * sum_axb - 2 * sum_a_x_sum_b + c2);
|
||||
|
||||
const int64_t sum_a_sq = sum_a * sum_a;
|
||||
const int64_t sum_b_sq = sum_b * sum_b;
|
||||
|
||||
const int64_t ssim_d =
|
||||
(sum_a_sq + sum_b_sq + c1) *
|
||||
(count * sum_sq_a - sum_a_sq + count * sum_sq_b - sum_b_sq + c2);
|
||||
|
||||
if (ssim_d == 0.0) {
|
||||
return DBL_MAX;
|
||||
}
|
||||
return ssim_n * 1.0 / ssim_d;
|
||||
const int32_t c1 = 26634; // (64^2*(.01*255)^2)
|
||||
const int32_t c2 = 239708; // (64^2*(.03*255)^2)
|
||||
const int32_t sum_a_x_sum_b_2 = 2 * sum_a * sum_b;
|
||||
const int32_t sum_a_sq_b_sq = sum_a * sum_a + sum_b * sum_b;
|
||||
const int32_t n1 = sum_a_x_sum_b_2 + c1;
|
||||
const int32_t n2 = (sum_axb << 7) - sum_a_x_sum_b_2 + c2;
|
||||
const int32_t d1 = sum_a_sq_b_sq + c1;
|
||||
const int32_t d2 = (sum_sq_ab << 6) - sum_a_sq_b_sq + c2;
|
||||
return ((float)n1 * (float)n2) / ((float)d1 * (float)d2);
|
||||
}
|
||||
}
|
||||
|
||||
static void Ssim4x4Row_Rem(void (*Ssim4x4Row)(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width),
|
||||
int simd_size,
|
||||
const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int rem_width) {
|
||||
if (Ssim4x4Row == Ssim4x4Row_C) {
|
||||
Ssim4x4Row_C(src_a, stride_a, src_b, stride_b, dst, rem_width);
|
||||
return;
|
||||
}
|
||||
SIMD_ALIGNED(uint8_t buf_a[32 * 4]);
|
||||
SIMD_ALIGNED(uint8_t buf_b[32 * 4]);
|
||||
SIMD_ALIGNED(uint32_t buf_dst[32]);
|
||||
memset(buf_a, 0, sizeof(buf_a));
|
||||
memset(buf_b, 0, sizeof(buf_b));
|
||||
int r;
|
||||
for (r = 0; r < 4; ++r) {
|
||||
memcpy(buf_a + r * 32, src_a + (ptrdiff_t)r * stride_a, rem_width);
|
||||
memcpy(buf_b + r * 32, src_b + (ptrdiff_t)r * stride_b, rem_width);
|
||||
}
|
||||
Ssim4x4Row(buf_a, 32, buf_b, 32, buf_dst, simd_size);
|
||||
memcpy(dst, buf_dst, (size_t)rem_width * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
static float SsimWindowRow_Rem(float (*SsimWindowRow)(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows),
|
||||
int win_simd_size,
|
||||
const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int rem_windows) {
|
||||
if (SsimWindowRow == SsimWindowRow_C) {
|
||||
return SsimWindowRow_C(row0, row1, rem_windows);
|
||||
}
|
||||
SIMD_ALIGNED(uint32_t win0[9 * 4]);
|
||||
SIMD_ALIGNED(uint32_t win1[9 * 4]);
|
||||
memset(win0, 0, sizeof(win0));
|
||||
memset(win1, 0, sizeof(win1));
|
||||
// Set odd tiles (1, 3, 5, 7) in win1 so each unused window k >= 1 has
|
||||
// sum_a = 4439, sum_b = -3, sum_sq = 307887, giving n1 = 2*4439*(-3) + c1 = 0
|
||||
// and SSIM = 0.0f (avoiding float precision loss from adding 1.0f per lane).
|
||||
int k;
|
||||
for (k = 1; k <= win_simd_size; k += 2) {
|
||||
win1[k * 4 + 0] = 4439u;
|
||||
win1[k * 4 + 1] = (uint32_t)-3;
|
||||
win1[k * 4 + 2] = 307887u;
|
||||
}
|
||||
float total = 0.0f;
|
||||
int w;
|
||||
for (w = 0; w < rem_windows; ++w) {
|
||||
const uint32_t* r0 = row0 + w * 4;
|
||||
const uint32_t* r1 = row1 + w * 4;
|
||||
win0[0] = r0[0] + r0[4];
|
||||
win0[1] = r0[1] + r0[5];
|
||||
win0[2] = r0[2] + r0[6];
|
||||
win0[3] = r0[3] + r0[7];
|
||||
win1[0] = r1[0] + r1[4] - 4439u;
|
||||
win1[1] = r1[1] + r1[5] - (uint32_t)-3;
|
||||
win1[2] = r1[2] + r1[6] - 307887u;
|
||||
win1[3] = r1[3] + r1[7];
|
||||
total += SsimWindowRow(win0, win1, win_simd_size);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
// We are using a 8x8 moving window with starting location of each 8x8 window
|
||||
// on the 4x4 pixel grid. Such arrangement allows the windows to overlap
|
||||
// block boundaries to penalize blocking artifacts.
|
||||
@@ -388,20 +601,231 @@ double CalcFrameSsim(const uint8_t* src_a,
|
||||
int height) {
|
||||
int samples = 0;
|
||||
double ssim_total = 0;
|
||||
double (*Ssim8x8)(const uint8_t* src_a, int stride_a, const uint8_t* src_b,
|
||||
int stride_b) = Ssim8x8_C;
|
||||
// Return 0 rather than 0.0 / 0 (NaN) when the plane is too small for any
|
||||
// sample windows, so I420Ssim on small images stays finite.
|
||||
if (width <= 8 || height <= 8) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// sample point start with each 4x4 location
|
||||
int i;
|
||||
for (i = 0; i < height - 8; i += 4) {
|
||||
int j;
|
||||
for (j = 0; j < width - 8; j += 4) {
|
||||
ssim_total += Ssim8x8(src_a + j, stride_a, src_b + j, stride_b);
|
||||
samples++;
|
||||
int simd_size = 4;
|
||||
void (*Ssim4x4Row)(const uint8_t* src_a, int stride_a, const uint8_t* src_b,
|
||||
int stride_b, uint32_t* dst, int width) = Ssim4x4Row_C;
|
||||
int win_simd_size = 1;
|
||||
float (*SsimWindowRow)(const uint32_t* row0, const uint32_t* row1,
|
||||
int num_windows) = SsimWindowRow_C;
|
||||
#if defined(HAS_SSIM4X4ROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
Ssim4x4Row = Ssim4x4Row_SSE2;
|
||||
simd_size = 16;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
Ssim4x4Row = Ssim4x4Row_AVX2;
|
||||
simd_size = 32;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
Ssim4x4Row = Ssim4x4Row_AVX512BW;
|
||||
simd_size = 4;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
SsimWindowRow = SsimWindowRow_SSE2;
|
||||
win_simd_size = 4;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
SsimWindowRow = SsimWindowRow_AVX2;
|
||||
win_simd_size = 8;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
SsimWindowRow = SsimWindowRow_AVX512BW;
|
||||
win_simd_size = 1;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
Ssim4x4Row = Ssim4x4Row_NEON;
|
||||
simd_size = 16;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_NEON_DOTPROD)
|
||||
if (TestCpuFlag(kCpuHasNeonDotProd)) {
|
||||
Ssim4x4Row = Ssim4x4Row_NEON_DotProd;
|
||||
simd_size = 16;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
SsimWindowRow = SsimWindowRow_NEON;
|
||||
win_simd_size = 4;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_SVE2)
|
||||
if (TestCpuFlag(kCpuHasSVE2)) {
|
||||
Ssim4x4Row = Ssim4x4Row_SVE2;
|
||||
simd_size = 4;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_SVE2)
|
||||
if (TestCpuFlag(kCpuHasSVE2)) {
|
||||
SsimWindowRow = SsimWindowRow_SVE2;
|
||||
win_simd_size = 1;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_SME)
|
||||
if (TestCpuFlag(kCpuHasSME)) {
|
||||
Ssim4x4Row = Ssim4x4Row_SME;
|
||||
simd_size = 4;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_SME)
|
||||
if (TestCpuFlag(kCpuHasSME)) {
|
||||
SsimWindowRow = SsimWindowRow_SME;
|
||||
win_simd_size = 1;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
Ssim4x4Row = Ssim4x4Row_RVV;
|
||||
simd_size = 4;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
SsimWindowRow = SsimWindowRow_RVV;
|
||||
win_simd_size = 1;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
Ssim4x4Row = Ssim4x4Row_LSX;
|
||||
simd_size = 16;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
SsimWindowRow = SsimWindowRow_LSX;
|
||||
win_simd_size = 1;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
Ssim4x4Row = Ssim4x4Row_LASX;
|
||||
simd_size = 32;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
SsimWindowRow = SsimWindowRow_LASX;
|
||||
win_simd_size = 1;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_WASMSIMD)
|
||||
if (TestCpuFlag(kCpuHasWASMSIMD)) {
|
||||
Ssim4x4Row = Ssim4x4Row_WASMSIMD;
|
||||
simd_size = 16;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_WASMSIMD)
|
||||
if (TestCpuFlag(kCpuHasWASMSIMD)) {
|
||||
SsimWindowRow = SsimWindowRow_WASMSIMD;
|
||||
win_simd_size = 4;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIM4X4ROW_HVX)
|
||||
if (TestCpuFlag(kCpuHasHVX)) {
|
||||
Ssim4x4Row = Ssim4x4Row_HVX;
|
||||
simd_size = 4;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SSIMWINDOWROW_HVX)
|
||||
if (TestCpuFlag(kCpuHasHVX)) {
|
||||
SsimWindowRow = SsimWindowRow_HVX;
|
||||
win_simd_size = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
const int num_windows = (width - 8 + 3) >> 2;
|
||||
const int num_tiles = num_windows + 1;
|
||||
const int tile_width = num_tiles * 4;
|
||||
const int main_width = tile_width & ~(simd_size - 1);
|
||||
const int rem_width = tile_width & (simd_size - 1);
|
||||
const int main_windows = num_windows & ~(win_simd_size - 1);
|
||||
const int rem_windows = num_windows & (win_simd_size - 1);
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel reduction(+ : ssim_total, samples)
|
||||
#endif
|
||||
{
|
||||
align_buffer_64(row_buf, (size_t)tile_width * 2 * sizeof(uint32_t));
|
||||
if (row_buf) {
|
||||
uint32_t* row0 = (uint32_t*)row_buf;
|
||||
uint32_t* row1 = row0 + tile_width;
|
||||
int prev_i = -8;
|
||||
int i;
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for schedule(static)
|
||||
#endif
|
||||
for (i = 0; i < height - 8; i += 4) {
|
||||
const uint8_t* a = src_a + (ptrdiff_t)i * stride_a;
|
||||
const uint8_t* b = src_b + (ptrdiff_t)i * stride_b;
|
||||
if (prev_i + 4 != i) {
|
||||
if (main_width > 0) {
|
||||
Ssim4x4Row(a, stride_a, b, stride_b, row0, main_width);
|
||||
}
|
||||
if (rem_width > 0) {
|
||||
Ssim4x4Row_Rem(Ssim4x4Row, simd_size, a + main_width, stride_a,
|
||||
b + main_width, stride_b, row0 + main_width,
|
||||
rem_width);
|
||||
}
|
||||
}
|
||||
a += (ptrdiff_t)stride_a * 4;
|
||||
b += (ptrdiff_t)stride_b * 4;
|
||||
if (main_width > 0) {
|
||||
Ssim4x4Row(a, stride_a, b, stride_b, row1, main_width);
|
||||
}
|
||||
if (rem_width > 0) {
|
||||
Ssim4x4Row_Rem(Ssim4x4Row, simd_size, a + main_width, stride_a,
|
||||
b + main_width, stride_b, row1 + main_width,
|
||||
rem_width);
|
||||
}
|
||||
if (main_windows > 0) {
|
||||
ssim_total += SsimWindowRow(row0, row1, main_windows);
|
||||
}
|
||||
if (rem_windows > 0) {
|
||||
ssim_total += SsimWindowRow_Rem(SsimWindowRow, win_simd_size,
|
||||
row0 + main_windows * 4,
|
||||
row1 + main_windows * 4, rem_windows);
|
||||
}
|
||||
samples += num_windows;
|
||||
uint32_t* tmp = row0;
|
||||
row0 = row1;
|
||||
row1 = tmp;
|
||||
prev_i = i;
|
||||
}
|
||||
free_aligned_buffer_64(row_buf);
|
||||
} else {
|
||||
int i;
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for schedule(static)
|
||||
#endif
|
||||
for (i = 0; i < height - 8; i += 4) {
|
||||
const uint8_t* a = src_a + (ptrdiff_t)i * stride_a;
|
||||
const uint8_t* b = src_b + (ptrdiff_t)i * stride_b;
|
||||
int j;
|
||||
for (j = 0; j < width - 8; j += 4) {
|
||||
ssim_total += Ssim8x8(a + j, stride_a, b + j, stride_b);
|
||||
samples++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
src_a += stride_a * 4;
|
||||
src_b += stride_b * 4;
|
||||
}
|
||||
|
||||
ssim_total /= samples;
|
||||
|
||||
@@ -8,45 +8,17 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#include "libyuv/compare_row.h"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "libyuv/video_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if ORIGINAL_OPT
|
||||
uint32_t HammingDistance_C1(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
uint32_t diff = 0u;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
int x = src_a[i] ^ src_b[i];
|
||||
if (x & 1)
|
||||
++diff;
|
||||
if (x & 2)
|
||||
++diff;
|
||||
if (x & 4)
|
||||
++diff;
|
||||
if (x & 8)
|
||||
++diff;
|
||||
if (x & 16)
|
||||
++diff;
|
||||
if (x & 32)
|
||||
++diff;
|
||||
if (x & 64)
|
||||
++diff;
|
||||
if (x & 128)
|
||||
++diff;
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Hakmem method for hamming distance.
|
||||
uint32_t HammingDistance_C(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
@@ -55,7 +27,11 @@ uint32_t HammingDistance_C(const uint8_t* src_a,
|
||||
|
||||
int i;
|
||||
for (i = 0; i < count - 3; i += 4) {
|
||||
uint32_t x = *((const uint32_t*)src_a) ^ *((const uint32_t*)src_b);
|
||||
uint32_t a = (uint32_t)src_a[0] | ((uint32_t)src_a[1] << 8) |
|
||||
((uint32_t)src_a[2] << 16) | ((uint32_t)src_a[3] << 24);
|
||||
uint32_t b = (uint32_t)src_b[0] | ((uint32_t)src_b[1] << 8) |
|
||||
((uint32_t)src_b[2] << 16) | ((uint32_t)src_b[3] << 24);
|
||||
uint32_t x = a ^ b;
|
||||
uint32_t u = x - ((x >> 1) & 0x55555555);
|
||||
u = ((u >> 2) & 0x33333333) + (u & 0x33333333);
|
||||
diff += ((((u + (u >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24);
|
||||
@@ -98,6 +74,131 @@ uint32_t HashDjb2_C(const uint8_t* src, int count, uint32_t seed) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Compute 4x4 tile statistics (sum_a, sum_b, sum_sq_a + sum_sq_b, sum_axb)
|
||||
// across 4 rows for width pixels (width is a multiple of 4).
|
||||
void Ssim4x4Row_C(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width) {
|
||||
const ptrdiff_t sa = stride_a;
|
||||
const ptrdiff_t sb = stride_b;
|
||||
const uint8_t* a0 = src_a;
|
||||
const uint8_t* a1 = a0 + sa;
|
||||
const uint8_t* a2 = a1 + sa;
|
||||
const uint8_t* a3 = a2 + sa;
|
||||
const uint8_t* b0 = src_b;
|
||||
const uint8_t* b1 = b0 + sb;
|
||||
const uint8_t* b2 = b1 + sb;
|
||||
const uint8_t* b3 = b2 + sb;
|
||||
int x;
|
||||
for (x = 0; x < width; x += 4) {
|
||||
uint32_t sum_a = a0[0] + a0[1] + a0[2] + a0[3] + a1[0] + a1[1] + a1[2] +
|
||||
a1[3] + a2[0] + a2[1] + a2[2] + a2[3] + a3[0] + a3[1] +
|
||||
a3[2] + a3[3];
|
||||
uint32_t sum_b = b0[0] + b0[1] + b0[2] + b0[3] + b1[0] + b1[1] + b1[2] +
|
||||
b1[3] + b2[0] + b2[1] + b2[2] + b2[3] + b3[0] + b3[1] +
|
||||
b3[2] + b3[3];
|
||||
uint32_t sum_sq_ab =
|
||||
a0[0] * a0[0] + a0[1] * a0[1] + a0[2] * a0[2] + a0[3] * a0[3] +
|
||||
a1[0] * a1[0] + a1[1] * a1[1] + a1[2] * a1[2] + a1[3] * a1[3] +
|
||||
a2[0] * a2[0] + a2[1] * a2[1] + a2[2] * a2[2] + a2[3] * a2[3] +
|
||||
a3[0] * a3[0] + a3[1] * a3[1] + a3[2] * a3[2] + a3[3] * a3[3] +
|
||||
b0[0] * b0[0] + b0[1] * b0[1] + b0[2] * b0[2] + b0[3] * b0[3] +
|
||||
b1[0] * b1[0] + b1[1] * b1[1] + b1[2] * b1[2] + b1[3] * b1[3] +
|
||||
b2[0] * b2[0] + b2[1] * b2[1] + b2[2] * b2[2] + b2[3] * b2[3] +
|
||||
b3[0] * b3[0] + b3[1] * b3[1] + b3[2] * b3[2] + b3[3] * b3[3];
|
||||
uint32_t sum_axb =
|
||||
a0[0] * b0[0] + a0[1] * b0[1] + a0[2] * b0[2] + a0[3] * b0[3] +
|
||||
a1[0] * b1[0] + a1[1] * b1[1] + a1[2] * b1[2] + a1[3] * b1[3] +
|
||||
a2[0] * b2[0] + a2[1] * b2[1] + a2[2] * b2[2] + a2[3] * b2[3] +
|
||||
a3[0] * b3[0] + a3[1] * b3[1] + a3[2] * b3[2] + a3[3] * b3[3];
|
||||
dst[0] = sum_a;
|
||||
dst[1] = sum_b;
|
||||
dst[2] = sum_sq_ab;
|
||||
dst[3] = sum_axb;
|
||||
a0 += 4;
|
||||
a1 += 4;
|
||||
a2 += 4;
|
||||
a3 += 4;
|
||||
b0 += 4;
|
||||
b1 += 4;
|
||||
b2 += 4;
|
||||
b3 += 4;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
// Combine two consecutive 4x4 tile rows (row0 and row1) into 8x8 windows
|
||||
// stepped on a 4-pixel horizontal grid and return the sum of SSIM values.
|
||||
float SsimWindowRow_C(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows) {
|
||||
const int32_t c1 = 26634; // (64^2*(.01*255)^2)
|
||||
const int32_t c2 = 239708; // (64^2*(.03*255)^2)
|
||||
|
||||
float ssim_total = 0.0f;
|
||||
int32_t prev_a = (int32_t)(row0[0] + row1[0]);
|
||||
int32_t prev_b = (int32_t)(row0[1] + row1[1]);
|
||||
int32_t prev_sq = (int32_t)(row0[2] + row1[2]);
|
||||
int32_t prev_axb = (int32_t)(row0[3] + row1[3]);
|
||||
int w;
|
||||
for (w = 0; w < num_windows; ++w) {
|
||||
row0 += 4;
|
||||
row1 += 4;
|
||||
const int32_t next_a = (int32_t)(row0[0] + row1[0]);
|
||||
const int32_t next_b = (int32_t)(row0[1] + row1[1]);
|
||||
const int32_t next_sq = (int32_t)(row0[2] + row1[2]);
|
||||
const int32_t next_axb = (int32_t)(row0[3] + row1[3]);
|
||||
const int32_t sum_a = prev_a + next_a;
|
||||
const int32_t sum_b = prev_b + next_b;
|
||||
const int32_t sum_sq_ab = prev_sq + next_sq;
|
||||
const int32_t sum_axb = prev_axb + next_axb;
|
||||
prev_a = next_a;
|
||||
prev_b = next_b;
|
||||
prev_sq = next_sq;
|
||||
prev_axb = next_axb;
|
||||
|
||||
const int32_t sum_a_x_sum_b_2 = 2 * sum_a * sum_b;
|
||||
const int32_t sum_a_sq_b_sq = sum_a * sum_a + sum_b * sum_b;
|
||||
const int32_t n1 = sum_a_x_sum_b_2 + c1;
|
||||
const int32_t n2 = (sum_axb << 7) - sum_a_x_sum_b_2 + c2;
|
||||
const int32_t d1 = sum_a_sq_b_sq + c1;
|
||||
const int32_t d2 = (sum_sq_ab << 6) - sum_a_sq_b_sq + c2;
|
||||
ssim_total += ((float)n1 * (float)n2) / ((float)d1 * (float)d2);
|
||||
}
|
||||
return ssim_total;
|
||||
}
|
||||
|
||||
uint32_t ARGBDetectRow_C(const uint8_t* argb, int width) {
|
||||
int x;
|
||||
for (x = 0; x < width - 1; x += 2) {
|
||||
if (argb[0] != 255) { // First byte is not Alpha of 255, so not ARGB.
|
||||
return FOURCC_BGRA;
|
||||
}
|
||||
if (argb[3] != 255) { // Fourth byte is not Alpha of 255, so not BGRA.
|
||||
return FOURCC_ARGB;
|
||||
}
|
||||
if (argb[4] != 255) { // Second pixel first byte is not Alpha of 255.
|
||||
return FOURCC_BGRA;
|
||||
}
|
||||
if (argb[7] != 255) { // Second pixel fourth byte is not Alpha of 255.
|
||||
return FOURCC_ARGB;
|
||||
}
|
||||
argb += 8;
|
||||
}
|
||||
if (width & 1) {
|
||||
if (argb[0] != 255) { // First byte is not Alpha of 255, so not ARGB.
|
||||
return FOURCC_BGRA;
|
||||
}
|
||||
if (argb[3] != 255) { // 4th byte is not Alpha of 255, so not BGRA.
|
||||
return FOURCC_ARGB;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
|
||||
+1436
-219
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,381 @@
|
||||
/*
|
||||
* Copyright 2026 The LibYuv Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "libyuv/compare_row.h"
|
||||
#include "libyuv/video_common.h"
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_HVX) && defined(__HVX__)
|
||||
|
||||
#include <hexagon_protos.h>
|
||||
#include <hexagon_types.h>
|
||||
#include <hvx_hexagon_protos.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline HVX_Vector vloada(const void* ptr) {
|
||||
HVX_Vector v;
|
||||
memcpy(&v, (const HVX_Vector*)ptr, sizeof(v));
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline HVX_UVector vloadu(const void* ptr) {
|
||||
HVX_UVector v;
|
||||
memcpy(&v, ptr, sizeof(v));
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline void vstoreu(void* ptr, HVX_UVector v) {
|
||||
memcpy(ptr, &v, sizeof(v));
|
||||
}
|
||||
|
||||
// Partial load of n bytes (1 <= n <= 128), zeroing lanes past n.
|
||||
static inline HVX_Vector vloadu_partial_zero(const void* ptr, int n) {
|
||||
if (n >= 128) {
|
||||
return vloadu(ptr);
|
||||
}
|
||||
const uintptr_t addr = (uintptr_t)ptr;
|
||||
const uintptr_t offset = addr & 127;
|
||||
HVX_Vector v0 = vloada(ptr);
|
||||
HVX_Vector v1 =
|
||||
(offset + (uintptr_t)n > 128) ? vloada((const uint8_t*)ptr + 128) : v0;
|
||||
HVX_Vector aligned = Q6_V_valign_VVR(v1, v0, addr);
|
||||
HVX_VectorPred mask = Q6_Q_vsetq_R(n);
|
||||
return Q6_V_vmux_QVV(mask, aligned, Q6_V_vzero());
|
||||
}
|
||||
|
||||
// Partial store of n bytes (1 <= n <= 128) without overwriting past n.
|
||||
static inline void vstoreu_partial(void* ptr, HVX_Vector v, int n) {
|
||||
if (n >= 128) {
|
||||
vstoreu(ptr, v);
|
||||
return;
|
||||
}
|
||||
const uintptr_t addr = (uintptr_t)ptr;
|
||||
const uintptr_t offset = addr & 127;
|
||||
HVX_Vector value = Q6_V_vlalign_VVR(v, v, addr);
|
||||
HVX_VectorPred ql_not = Q6_Q_vsetq_R(addr);
|
||||
HVX_VectorPred qr = Q6_Q_vsetq2_R(offset + (uintptr_t)n);
|
||||
if (offset + (uintptr_t)n > 128) {
|
||||
Q6_vmem_QRIV(qr, (uint8_t*)ptr + 128, value);
|
||||
qr = Q6_Q_vcmp_eq_VbVb(value, value);
|
||||
}
|
||||
ql_not = Q6_Q_or_QQn(ql_not, qr);
|
||||
Q6_vmem_QnRIV(ql_not, ptr, value);
|
||||
}
|
||||
|
||||
static inline uint32_t horizontal_sum_u32(HVX_Vector x) {
|
||||
x = Q6_Vw_vadd_VwVw(x, Q6_V_vror_VR(x, 64));
|
||||
x = Q6_Vw_vadd_VwVw(x, Q6_V_vror_VR(x, 32));
|
||||
x = Q6_Vw_vadd_VwVw(x, Q6_V_vror_VR(x, 16));
|
||||
x = Q6_Vw_vadd_VwVw(x, Q6_V_vror_VR(x, 8));
|
||||
x = Q6_Vw_vadd_VwVw(x, Q6_V_vror_VR(x, 4));
|
||||
uint32_t result;
|
||||
memcpy(&result, &x, sizeof(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined(HAS_HAMMINGDISTANCE_HVX)
|
||||
uint32_t HammingDistance_HVX(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
HVX_Vector sum = Q6_V_vzero();
|
||||
while (count >= 128) {
|
||||
HVX_Vector x = Q6_V_vxor_VV(vloadu(src_a), vloadu(src_b));
|
||||
HVX_Vector c = Q6_Vh_vpopcount_Vh(x);
|
||||
sum = Q6_Vuw_vrmpyacc_VuwVubRub(sum, c, 0x01010101);
|
||||
src_a += 128;
|
||||
src_b += 128;
|
||||
count -= 128;
|
||||
}
|
||||
if (count > 0) {
|
||||
HVX_Vector x = Q6_V_vxor_VV(vloadu_partial_zero(src_a, count),
|
||||
vloadu_partial_zero(src_b, count));
|
||||
HVX_Vector c = Q6_Vh_vpopcount_Vh(x);
|
||||
sum = Q6_Vuw_vrmpyacc_VuwVubRub(sum, c, 0x01010101);
|
||||
}
|
||||
return horizontal_sum_u32(sum);
|
||||
}
|
||||
#endif // defined(HAS_HAMMINGDISTANCE_HVX)
|
||||
|
||||
#if defined(HAS_SUMSQUAREERROR_HVX)
|
||||
uint32_t SumSquareError_HVX(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
HVX_Vector sum = Q6_V_vzero();
|
||||
while (count >= 128) {
|
||||
HVX_Vector d = Q6_Vub_vabsdiff_VubVub(vloadu(src_a), vloadu(src_b));
|
||||
sum = Q6_Vuw_vrmpyacc_VuwVubVub(sum, d, d);
|
||||
src_a += 128;
|
||||
src_b += 128;
|
||||
count -= 128;
|
||||
}
|
||||
if (count > 0) {
|
||||
HVX_Vector d = Q6_Vub_vabsdiff_VubVub(vloadu_partial_zero(src_a, count),
|
||||
vloadu_partial_zero(src_b, count));
|
||||
sum = Q6_Vuw_vrmpyacc_VuwVubVub(sum, d, d);
|
||||
}
|
||||
return horizontal_sum_u32(sum);
|
||||
}
|
||||
#endif // defined(HAS_SUMSQUAREERROR_HVX)
|
||||
|
||||
#if defined(HAS_HASHDJB2_HVX)
|
||||
static const uint32_t kHashMul32[32] __attribute__((aligned(128))) = {
|
||||
0x655ec7e1, 0xccc4cfc1, 0x99995ba1, 0xd61beb81, // 33 ^ 31 .. 28
|
||||
0x829bff61, 0x13791741, 0x2f22b321, 0xac185301, // 33 ^ 27 .. 24
|
||||
0xcee976e1, 0xc8359ec1, 0x72ac4aa1, 0x510cfa81, // 33 ^ 23 .. 20
|
||||
0xcc272e61, 0xb0da6641, 0xee162221, 0x92d9e201, // 33 ^ 19 .. 16
|
||||
0x0c3525e1, 0xa3476dc1, 0x3b4039a1, 0x4f5f0981, // 33 ^ 15 .. 12
|
||||
0x30f35d61, 0x855cb541, 0x040a9121, 0x747c7101, // 33 ^ 11 .. 8
|
||||
0xec41d4e1, 0x4cfa3cc1, 0x025528a1, 0x00121881, // 33 ^ 7 .. 4
|
||||
0x00008c61, 0x00000441, 0x00000021, 0x00000001, // 33 ^ 3 .. 0
|
||||
};
|
||||
|
||||
static inline HVX_Vector vmpy_u32(HVX_Vector a, HVX_Vector b) {
|
||||
HVX_Vector hi = Q6_Vw_vmpyieo_VhVh(a, b);
|
||||
return Q6_Vw_vmpyieacc_VwVwVuh(hi, a, b);
|
||||
}
|
||||
|
||||
static uint32_t Pow33(int n) {
|
||||
uint32_t r = 1u;
|
||||
uint32_t b = 33u;
|
||||
while (n) {
|
||||
if (n & 1) {
|
||||
r *= b;
|
||||
}
|
||||
b *= b;
|
||||
n >>= 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline uint32_t HashSum128_HVX(HVX_Vector s,
|
||||
HVX_Vector mul0,
|
||||
HVX_Vector mul1,
|
||||
HVX_Vector mul2,
|
||||
HVX_Vector mul3) {
|
||||
HVX_VectorPair h01 = Q6_Wuh_vunpack_Vub(s);
|
||||
HVX_VectorPair w01 = Q6_Wuw_vunpack_Vuh(Q6_V_lo_W(h01));
|
||||
HVX_VectorPair w23 = Q6_Wuw_vunpack_Vuh(Q6_V_hi_W(h01));
|
||||
HVX_Vector sum = Q6_Vw_vmpyie_VwVuh(mul0, Q6_V_lo_W(w01));
|
||||
sum = Q6_Vw_vmpyieacc_VwVwVuh(sum, mul1, Q6_V_hi_W(w01));
|
||||
sum = Q6_Vw_vmpyieacc_VwVwVuh(sum, mul2, Q6_V_lo_W(w23));
|
||||
sum = Q6_Vw_vmpyieacc_VwVwVuh(sum, mul3, Q6_V_hi_W(w23));
|
||||
return horizontal_sum_u32(sum);
|
||||
}
|
||||
|
||||
uint32_t HashDjb2_HVX(const uint8_t* src, int count, uint32_t seed) {
|
||||
const HVX_Vector c32 = Q6_V_vsplat_R(0x1137c401u); // 33 ^ 32
|
||||
const HVX_Vector mul3 = vloada(kHashMul32);
|
||||
const HVX_Vector mul2 = vmpy_u32(mul3, c32);
|
||||
const HVX_Vector mul1 = vmpy_u32(mul2, c32);
|
||||
const HVX_Vector mul0 = vmpy_u32(mul1, c32);
|
||||
while (count >= 128) {
|
||||
seed = seed * 0x193f1001u + // 33 ^ 128
|
||||
HashSum128_HVX(vloadu(src), mul0, mul1, mul2, mul3);
|
||||
src += 128;
|
||||
count -= 128;
|
||||
}
|
||||
if (count > 0) {
|
||||
HVX_Vector v = vloadu_partial_zero(src, count);
|
||||
HVX_Vector s = Q6_V_valign_VVR(v, Q6_V_vzero(), count);
|
||||
seed = seed * Pow33(count) + HashSum128_HVX(s, mul0, mul1, mul2, mul3);
|
||||
}
|
||||
return seed;
|
||||
}
|
||||
#endif // defined(HAS_HASHDJB2_HVX)
|
||||
|
||||
#if defined(HAS_SSIM4X4ROW_HVX)
|
||||
#define SSIM_4X4_HVX(va0, vb0, va1, vb1, va2, vb2, va3, vb3) \
|
||||
HVX_Vector sum_a = Q6_Vuw_vrmpy_VubRub(va0, 0x01010101); \
|
||||
sum_a = Q6_Vuw_vrmpyacc_VuwVubRub(sum_a, va1, 0x01010101); \
|
||||
sum_a = Q6_Vuw_vrmpyacc_VuwVubRub(sum_a, va2, 0x01010101); \
|
||||
sum_a = Q6_Vuw_vrmpyacc_VuwVubRub(sum_a, va3, 0x01010101); \
|
||||
HVX_Vector sum_b = Q6_Vuw_vrmpy_VubRub(vb0, 0x01010101); \
|
||||
sum_b = Q6_Vuw_vrmpyacc_VuwVubRub(sum_b, vb1, 0x01010101); \
|
||||
sum_b = Q6_Vuw_vrmpyacc_VuwVubRub(sum_b, vb2, 0x01010101); \
|
||||
sum_b = Q6_Vuw_vrmpyacc_VuwVubRub(sum_b, vb3, 0x01010101); \
|
||||
HVX_Vector sum_sq = Q6_Vuw_vrmpy_VubVub(va0, va0); \
|
||||
sum_sq = Q6_Vuw_vrmpyacc_VuwVubVub(sum_sq, vb0, vb0); \
|
||||
sum_sq = Q6_Vuw_vrmpyacc_VuwVubVub(sum_sq, va1, va1); \
|
||||
sum_sq = Q6_Vuw_vrmpyacc_VuwVubVub(sum_sq, vb1, vb1); \
|
||||
sum_sq = Q6_Vuw_vrmpyacc_VuwVubVub(sum_sq, va2, va2); \
|
||||
sum_sq = Q6_Vuw_vrmpyacc_VuwVubVub(sum_sq, vb2, vb2); \
|
||||
sum_sq = Q6_Vuw_vrmpyacc_VuwVubVub(sum_sq, va3, va3); \
|
||||
sum_sq = Q6_Vuw_vrmpyacc_VuwVubVub(sum_sq, vb3, vb3); \
|
||||
HVX_Vector sum_axb = Q6_Vuw_vrmpy_VubVub(va0, vb0); \
|
||||
sum_axb = Q6_Vuw_vrmpyacc_VuwVubVub(sum_axb, va1, vb1); \
|
||||
sum_axb = Q6_Vuw_vrmpyacc_VuwVubVub(sum_axb, va2, vb2); \
|
||||
sum_axb = Q6_Vuw_vrmpyacc_VuwVubVub(sum_axb, va3, vb3); \
|
||||
HVX_VectorPair ab = Q6_W_vshuff_VVR(sum_b, sum_a, -4); \
|
||||
HVX_VectorPair sqx = Q6_W_vshuff_VVR(sum_axb, sum_sq, -4); \
|
||||
HVX_VectorPair out01 = Q6_W_vshuff_VVR(Q6_V_lo_W(sqx), Q6_V_lo_W(ab), -8); \
|
||||
HVX_VectorPair out23 = Q6_W_vshuff_VVR(Q6_V_hi_W(sqx), Q6_V_hi_W(ab), -8)
|
||||
|
||||
// Width is a multiple of 4.
|
||||
void Ssim4x4Row_HVX(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width) {
|
||||
const ptrdiff_t sa = stride_a;
|
||||
const ptrdiff_t sb = stride_b;
|
||||
const uint8_t* a0 = src_a;
|
||||
const uint8_t* a1 = a0 + sa;
|
||||
const uint8_t* a2 = a1 + sa;
|
||||
const uint8_t* a3 = a2 + sa;
|
||||
const uint8_t* b0 = src_b;
|
||||
const uint8_t* b1 = b0 + sb;
|
||||
const uint8_t* b2 = b1 + sb;
|
||||
const uint8_t* b3 = b2 + sb;
|
||||
|
||||
while (width >= 128) {
|
||||
SSIM_4X4_HVX(vloadu(a0), vloadu(b0), vloadu(a1), vloadu(b1), vloadu(a2),
|
||||
vloadu(b2), vloadu(a3), vloadu(b3));
|
||||
vstoreu(dst + 0, Q6_V_lo_W(out01));
|
||||
vstoreu(dst + 32, Q6_V_hi_W(out01));
|
||||
vstoreu(dst + 64, Q6_V_lo_W(out23));
|
||||
vstoreu(dst + 96, Q6_V_hi_W(out23));
|
||||
a0 += 128;
|
||||
a1 += 128;
|
||||
a2 += 128;
|
||||
a3 += 128;
|
||||
b0 += 128;
|
||||
b1 += 128;
|
||||
b2 += 128;
|
||||
b3 += 128;
|
||||
dst += 128;
|
||||
width -= 128;
|
||||
}
|
||||
if (width > 0) {
|
||||
SSIM_4X4_HVX(vloadu_partial_zero(a0, width), vloadu_partial_zero(b0, width),
|
||||
vloadu_partial_zero(a1, width), vloadu_partial_zero(b1, width),
|
||||
vloadu_partial_zero(a2, width), vloadu_partial_zero(b2, width),
|
||||
vloadu_partial_zero(a3, width),
|
||||
vloadu_partial_zero(b3, width));
|
||||
int bytes = width * 4;
|
||||
if (bytes > 0) {
|
||||
vstoreu_partial(dst + 0, Q6_V_lo_W(out01), bytes < 128 ? bytes : 128);
|
||||
}
|
||||
if (bytes > 128) {
|
||||
vstoreu_partial(dst + 32, Q6_V_hi_W(out01),
|
||||
bytes - 128 < 128 ? bytes - 128 : 128);
|
||||
}
|
||||
if (bytes > 256) {
|
||||
vstoreu_partial(dst + 64, Q6_V_lo_W(out23),
|
||||
bytes - 256 < 128 ? bytes - 256 : 128);
|
||||
}
|
||||
if (bytes > 384) {
|
||||
vstoreu_partial(dst + 96, Q6_V_hi_W(out23), bytes - 384);
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef SSIM_4X4_HVX
|
||||
#endif // defined(HAS_SSIM4X4ROW_HVX)
|
||||
|
||||
#if defined(HAS_SSIMWINDOWROW_HVX)
|
||||
float SsimWindowRow_HVX(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows) {
|
||||
const HVX_Vector vc1 = Q6_V_vsplat_R(26634);
|
||||
const HVX_Vector vc2 = Q6_V_vsplat_R(239708);
|
||||
float total = 0.0f;
|
||||
while (num_windows > 0) {
|
||||
int count = num_windows < 8 ? num_windows : 8;
|
||||
HVX_Vector t0, t1;
|
||||
if (num_windows >= 8) {
|
||||
t0 = Q6_Vw_vadd_VwVw(vloadu(row0), vloadu(row1));
|
||||
t1 = Q6_Vw_vadd_VwVw(vloadu(row0 + 4), vloadu(row1 + 4));
|
||||
} else {
|
||||
int bytes0 = count * 16;
|
||||
int bytes1 = (count + 1) * 16;
|
||||
t0 = Q6_Vw_vadd_VwVw(vloadu_partial_zero(row0, bytes0),
|
||||
vloadu_partial_zero(row1, bytes0));
|
||||
t1 = Q6_Vw_vadd_VwVw(vloadu_partial_zero(row0 + 4, bytes1 - 16),
|
||||
vloadu_partial_zero(row1 + 4, bytes1 - 16));
|
||||
}
|
||||
HVX_Vector w = Q6_Vw_vadd_VwVw(t0, t1);
|
||||
HVX_Vector w_b = Q6_V_vror_VR(w, 4);
|
||||
HVX_Vector w_sq = Q6_V_vror_VR(w, 8);
|
||||
HVX_Vector w_axb = Q6_V_vror_VR(w, 12);
|
||||
HVX_Vector ab2 = Q6_Vw_vasl_VwR(Q6_Vw_vmpyie_VwVuh(w, w_b), 1);
|
||||
HVX_Vector a2b2 =
|
||||
Q6_Vw_vmpyieacc_VwVwVuh(Q6_Vw_vmpyie_VwVuh(w, w), w_b, w_b);
|
||||
HVX_Vector vn1 = Q6_Vw_vadd_VwVw(ab2, vc1);
|
||||
HVX_Vector vn2 =
|
||||
Q6_Vw_vadd_VwVw(Q6_Vw_vsub_VwVw(Q6_Vw_vasl_VwR(w_axb, 7), ab2), vc2);
|
||||
HVX_Vector vd1 = Q6_Vw_vadd_VwVw(a2b2, vc1);
|
||||
HVX_Vector vd2 =
|
||||
Q6_Vw_vadd_VwVw(Q6_Vw_vsub_VwVw(Q6_Vw_vasl_VwR(w_sq, 6), a2b2), vc2);
|
||||
int32_t n1[32] __attribute__((aligned(128)));
|
||||
int32_t n2[32] __attribute__((aligned(128)));
|
||||
int32_t d1[32] __attribute__((aligned(128)));
|
||||
int32_t d2[32] __attribute__((aligned(128)));
|
||||
vstoreu(n1, vn1);
|
||||
vstoreu(n2, vn2);
|
||||
vstoreu(d1, vd1);
|
||||
vstoreu(d2, vd2);
|
||||
int i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
float num = (float)n1[i * 4] * (float)n2[i * 4];
|
||||
float den = (float)d1[i * 4] * (float)d2[i * 4];
|
||||
total += num / den;
|
||||
}
|
||||
row0 += 32;
|
||||
row1 += 32;
|
||||
num_windows -= 8;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
#endif // defined(HAS_SSIMWINDOWROW_HVX)
|
||||
|
||||
#if defined(HAS_ARGBDETECTROW_HVX)
|
||||
uint32_t ARGBDetectRow_HVX(const uint8_t* argb, int width) {
|
||||
const HVX_Vector mask_rgb = Q6_V_vsplat_R(0x00ffff00);
|
||||
const HVX_Vector ones = Q6_Vb_vsplat_R(-1);
|
||||
const HVX_Vector zero = Q6_V_vzero();
|
||||
while (width > 0) {
|
||||
HVX_Vector v;
|
||||
if (width >= 32) {
|
||||
v = vloadu(argb);
|
||||
} else {
|
||||
int bytes = width * 4;
|
||||
v = Q6_V_vmux_QVV(Q6_Q_vsetq_R(bytes), vloadu_partial_zero(argb, bytes),
|
||||
ones);
|
||||
}
|
||||
v = Q6_V_vor_VV(v, mask_rgb);
|
||||
HVX_VectorPred eq = Q6_Q_vcmp_eq_VbVb(v, ones);
|
||||
HVX_Vector diff_v = Q6_V_vmux_QVV(eq, zero, ones);
|
||||
if (horizontal_sum_u32(Q6_Vuw_vrmpy_VubRub(diff_v, 0x01010101)) != 0) {
|
||||
uint32_t diff[32] __attribute__((aligned(128)));
|
||||
vstoreu(diff, diff_v);
|
||||
int i;
|
||||
for (i = 0; i < 32; ++i) {
|
||||
if (diff[i] != 0) {
|
||||
return (diff[i] & 0xffu) ? FOURCC_BGRA : FOURCC_ARGB;
|
||||
}
|
||||
}
|
||||
}
|
||||
argb += 128;
|
||||
width -= 32;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif // defined(HAS_ARGBDETECTROW_HVX)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // !defined(LIBYUV_DISABLE_HVX) && defined(__HVX__)
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 The LibYuv Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#include "libyuv/compare_row.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// This module is for Mips MMI.
|
||||
#if !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A)
|
||||
|
||||
// Hakmem method for hamming distance.
|
||||
uint32_t HammingDistance_MMI(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
uint32_t diff = 0u;
|
||||
|
||||
uint64_t temp = 0, temp1 = 0, ta = 0, tb = 0;
|
||||
uint64_t c1 = 0x5555555555555555;
|
||||
uint64_t c2 = 0x3333333333333333;
|
||||
uint64_t c3 = 0x0f0f0f0f0f0f0f0f;
|
||||
uint32_t c4 = 0x01010101;
|
||||
uint64_t s1 = 1, s2 = 2, s3 = 4;
|
||||
__asm__ volatile(
|
||||
"1: \n\t"
|
||||
"ldc1 %[ta], 0(%[src_a]) \n\t"
|
||||
"ldc1 %[tb], 0(%[src_b]) \n\t"
|
||||
"xor %[temp], %[ta], %[tb] \n\t"
|
||||
"psrlw %[temp1], %[temp], %[s1] \n\t" // temp1=x>>1
|
||||
"and %[temp1], %[temp1], %[c1] \n\t" // temp1&=c1
|
||||
"psubw %[temp1], %[temp], %[temp1] \n\t" // x-temp1
|
||||
"and %[temp], %[temp1], %[c2] \n\t" // t = (u&c2)
|
||||
"psrlw %[temp1], %[temp1], %[s2] \n\t" // u>>2
|
||||
"and %[temp1], %[temp1], %[c2] \n\t" // u>>2 & c2
|
||||
"paddw %[temp1], %[temp1], %[temp] \n\t" // t1 = t1+t
|
||||
"psrlw %[temp], %[temp1], %[s3] \n\t" // u>>4
|
||||
"paddw %[temp1], %[temp1], %[temp] \n\t" // u+(u>>4)
|
||||
"and %[temp1], %[temp1], %[c3] \n\t" //&c3
|
||||
"dmfc1 $t0, %[temp1] \n\t"
|
||||
"dsrl32 $t0, $t0, 0 \n\t "
|
||||
"mul $t0, $t0, %[c4] \n\t"
|
||||
"dsrl $t0, $t0, 24 \n\t"
|
||||
"dadd %[diff], %[diff], $t0 \n\t"
|
||||
"dmfc1 $t0, %[temp1] \n\t"
|
||||
"mul $t0, $t0, %[c4] \n\t"
|
||||
"dsrl $t0, $t0, 24 \n\t"
|
||||
"dadd %[diff], %[diff], $t0 \n\t"
|
||||
"daddiu %[src_a], %[src_a], 8 \n\t"
|
||||
"daddiu %[src_b], %[src_b], 8 \n\t"
|
||||
"addiu %[count], %[count], -8 \n\t"
|
||||
"bgtz %[count], 1b \n\t"
|
||||
"nop \n\t"
|
||||
: [diff] "+r"(diff), [src_a] "+r"(src_a), [src_b] "+r"(src_b),
|
||||
[count] "+r"(count), [ta] "+f"(ta), [tb] "+f"(tb), [temp] "+f"(temp),
|
||||
[temp1] "+f"(temp1)
|
||||
: [c1] "f"(c1), [c2] "f"(c2), [c3] "f"(c3), [c4] "r"(c4), [s1] "f"(s1),
|
||||
[s2] "f"(s2), [s3] "f"(s3)
|
||||
: "memory");
|
||||
return diff;
|
||||
}
|
||||
|
||||
uint32_t SumSquareError_MMI(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
uint32_t sse = 0u;
|
||||
uint32_t sse_hi = 0u, sse_lo = 0u;
|
||||
|
||||
uint64_t src1, src2;
|
||||
uint64_t diff, diff_hi, diff_lo;
|
||||
uint64_t sse_sum, sse_tmp;
|
||||
|
||||
const uint64_t mask = 0x0ULL;
|
||||
|
||||
__asm__ volatile(
|
||||
"xor %[sse_sum], %[sse_sum], %[sse_sum] \n\t"
|
||||
|
||||
"1: \n\t"
|
||||
"ldc1 %[src1], 0x00(%[src_a]) \n\t"
|
||||
"ldc1 %[src2], 0x00(%[src_b]) \n\t"
|
||||
"pasubub %[diff], %[src1], %[src2] \n\t"
|
||||
"punpcklbh %[diff_lo], %[diff], %[mask] \n\t"
|
||||
"punpckhbh %[diff_hi], %[diff], %[mask] \n\t"
|
||||
"pmaddhw %[sse_tmp], %[diff_lo], %[diff_lo] \n\t"
|
||||
"paddw %[sse_sum], %[sse_sum], %[sse_tmp] \n\t"
|
||||
"pmaddhw %[sse_tmp], %[diff_hi], %[diff_hi] \n\t"
|
||||
"paddw %[sse_sum], %[sse_sum], %[sse_tmp] \n\t"
|
||||
|
||||
"daddiu %[src_a], %[src_a], 0x08 \n\t"
|
||||
"daddiu %[src_b], %[src_b], 0x08 \n\t"
|
||||
"daddiu %[count], %[count], -0x08 \n\t"
|
||||
"bnez %[count], 1b \n\t"
|
||||
|
||||
"mfc1 %[sse_lo], %[sse_sum] \n\t"
|
||||
"mfhc1 %[sse_hi], %[sse_sum] \n\t"
|
||||
"daddu %[sse], %[sse_hi], %[sse_lo] \n\t"
|
||||
: [sse] "+&r"(sse), [diff] "=&f"(diff), [src1] "=&f"(src1),
|
||||
[src2] "=&f"(src2), [diff_lo] "=&f"(diff_lo), [diff_hi] "=&f"(diff_hi),
|
||||
[sse_sum] "=&f"(sse_sum), [sse_tmp] "=&f"(sse_tmp),
|
||||
[sse_hi] "+&r"(sse_hi), [sse_lo] "+&r"(sse_lo)
|
||||
: [src_a] "r"(src_a), [src_b] "r"(src_b), [count] "r"(count),
|
||||
[mask] "f"(mask)
|
||||
: "memory");
|
||||
|
||||
return sse;
|
||||
}
|
||||
|
||||
#endif // !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 The LibYuv Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#include "libyuv/compare_row.h"
|
||||
#include "libyuv/row.h"
|
||||
|
||||
// This module is for GCC MSA
|
||||
#if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
|
||||
#include "libyuv/macros_msa.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint32_t HammingDistance_MSA(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
uint32_t diff = 0u;
|
||||
int i;
|
||||
v16u8 src0, src1, src2, src3;
|
||||
v2i64 vec0 = {0}, vec1 = {0};
|
||||
|
||||
for (i = 0; i < count; i += 32) {
|
||||
src0 = (v16u8)__msa_ld_b((v16i8*)src_a, 0);
|
||||
src1 = (v16u8)__msa_ld_b((v16i8*)src_a, 16);
|
||||
src2 = (v16u8)__msa_ld_b((v16i8*)src_b, 0);
|
||||
src3 = (v16u8)__msa_ld_b((v16i8*)src_b, 16);
|
||||
src0 ^= src2;
|
||||
src1 ^= src3;
|
||||
vec0 += __msa_pcnt_d((v2i64)src0);
|
||||
vec1 += __msa_pcnt_d((v2i64)src1);
|
||||
src_a += 32;
|
||||
src_b += 32;
|
||||
}
|
||||
|
||||
vec0 += vec1;
|
||||
diff = (uint32_t)__msa_copy_u_w((v4i32)vec0, 0);
|
||||
diff += (uint32_t)__msa_copy_u_w((v4i32)vec0, 2);
|
||||
return diff;
|
||||
}
|
||||
|
||||
uint32_t SumSquareError_MSA(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
uint32_t sse = 0u;
|
||||
int i;
|
||||
v16u8 src0, src1, src2, src3;
|
||||
v8i16 vec0, vec1, vec2, vec3;
|
||||
v4i32 reg0 = {0}, reg1 = {0}, reg2 = {0}, reg3 = {0};
|
||||
v2i64 tmp0;
|
||||
|
||||
for (i = 0; i < count; i += 32) {
|
||||
src0 = (v16u8)__msa_ld_b((v16i8*)src_a, 0);
|
||||
src1 = (v16u8)__msa_ld_b((v16i8*)src_a, 16);
|
||||
src2 = (v16u8)__msa_ld_b((v16i8*)src_b, 0);
|
||||
src3 = (v16u8)__msa_ld_b((v16i8*)src_b, 16);
|
||||
vec0 = (v8i16)__msa_ilvr_b((v16i8)src2, (v16i8)src0);
|
||||
vec1 = (v8i16)__msa_ilvl_b((v16i8)src2, (v16i8)src0);
|
||||
vec2 = (v8i16)__msa_ilvr_b((v16i8)src3, (v16i8)src1);
|
||||
vec3 = (v8i16)__msa_ilvl_b((v16i8)src3, (v16i8)src1);
|
||||
vec0 = __msa_hsub_u_h((v16u8)vec0, (v16u8)vec0);
|
||||
vec1 = __msa_hsub_u_h((v16u8)vec1, (v16u8)vec1);
|
||||
vec2 = __msa_hsub_u_h((v16u8)vec2, (v16u8)vec2);
|
||||
vec3 = __msa_hsub_u_h((v16u8)vec3, (v16u8)vec3);
|
||||
reg0 = __msa_dpadd_s_w(reg0, vec0, vec0);
|
||||
reg1 = __msa_dpadd_s_w(reg1, vec1, vec1);
|
||||
reg2 = __msa_dpadd_s_w(reg2, vec2, vec2);
|
||||
reg3 = __msa_dpadd_s_w(reg3, vec3, vec3);
|
||||
src_a += 32;
|
||||
src_b += 32;
|
||||
}
|
||||
|
||||
reg0 += reg1;
|
||||
reg2 += reg3;
|
||||
reg0 += reg2;
|
||||
tmp0 = __msa_hadd_s_d(reg0, reg0);
|
||||
sse = (uint32_t)__msa_copy_u_w((v4i32)tmp0, 0);
|
||||
sse += (uint32_t)__msa_copy_u_w((v4i32)tmp0, 2);
|
||||
return sse;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
|
||||
@@ -8,16 +8,22 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#include "libyuv/compare_row.h"
|
||||
#include "libyuv/row.h"
|
||||
#include "libyuv/video_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Note: every register written by an inline asm block (vector, general
|
||||
// purpose, mask/predicate, "cc" for flags and "memory" for stores) must be
|
||||
// listed in its clobber list, even when the ABI treats it as caller-saved.
|
||||
// With LTO/LTCG the compiler may keep values live in any register across the
|
||||
// asm statement, and other OS ABIs (e.g. Windows) differ in which registers
|
||||
// are callee-saved. List "memory" first, then "cc", then registers.
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_NEON) && defined(__ARM_NEON__) && \
|
||||
!defined(__aarch64__)
|
||||
|
||||
@@ -29,24 +35,24 @@ uint32_t HammingDistance_NEON(const uint8_t* src_a,
|
||||
uint32_t diff;
|
||||
|
||||
asm volatile(
|
||||
"vmov.u16 q4, #0 \n" // accumulator
|
||||
"vmov.u16 q4, #0 \n" // accumulator
|
||||
|
||||
"1: \n"
|
||||
"vld1.8 {q0, q1}, [%0]! \n"
|
||||
"vld1.8 {q2, q3}, [%1]! \n"
|
||||
"veor.32 q0, q0, q2 \n"
|
||||
"veor.32 q1, q1, q3 \n"
|
||||
"vcnt.i8 q0, q0 \n"
|
||||
"vcnt.i8 q1, q1 \n"
|
||||
"subs %2, %2, #32 \n"
|
||||
"vadd.u8 q0, q0, q1 \n" // 16 byte counts
|
||||
"vpadal.u8 q4, q0 \n" // 8 shorts
|
||||
"bgt 1b \n"
|
||||
"1: \n"
|
||||
"vld1.8 {q0, q1}, [%0]! \n"
|
||||
"vld1.8 {q2, q3}, [%1]! \n"
|
||||
"veor.32 q0, q0, q2 \n"
|
||||
"veor.32 q1, q1, q3 \n"
|
||||
"vcnt.i8 q0, q0 \n"
|
||||
"vcnt.i8 q1, q1 \n"
|
||||
"subs %2, %2, #32 \n"
|
||||
"vadd.u8 q0, q0, q1 \n" // 16 byte counts
|
||||
"vpadal.u8 q4, q0 \n" // 8 shorts
|
||||
"bgt 1b \n"
|
||||
|
||||
"vpaddl.u16 q0, q4 \n" // 4 ints
|
||||
"vpadd.u32 d0, d0, d1 \n"
|
||||
"vpadd.u32 d0, d0, d0 \n"
|
||||
"vmov.32 %3, d0[0] \n"
|
||||
"vpaddl.u16 q0, q4 \n" // 4 ints
|
||||
"vpadd.u32 d0, d0, d1 \n"
|
||||
"vpadd.u32 d0, d0, d0 \n"
|
||||
"vmov.32 %3, d0[0] \n"
|
||||
|
||||
: "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(diff)
|
||||
:
|
||||
@@ -59,35 +65,267 @@ uint32_t SumSquareError_NEON(const uint8_t* src_a,
|
||||
int count) {
|
||||
uint32_t sse;
|
||||
asm volatile(
|
||||
"vmov.u8 q8, #0 \n"
|
||||
"vmov.u8 q10, #0 \n"
|
||||
"vmov.u8 q9, #0 \n"
|
||||
"vmov.u8 q11, #0 \n"
|
||||
"vmov.u8 q8, #0 \n"
|
||||
"vmov.u8 q10, #0 \n"
|
||||
"vmov.u8 q9, #0 \n"
|
||||
"vmov.u8 q11, #0 \n"
|
||||
|
||||
"1: \n"
|
||||
"vld1.8 {q0}, [%0]! \n"
|
||||
"vld1.8 {q1}, [%1]! \n"
|
||||
"subs %2, %2, #16 \n"
|
||||
"vsubl.u8 q2, d0, d2 \n"
|
||||
"vsubl.u8 q3, d1, d3 \n"
|
||||
"vmlal.s16 q8, d4, d4 \n"
|
||||
"vmlal.s16 q9, d6, d6 \n"
|
||||
"vmlal.s16 q10, d5, d5 \n"
|
||||
"vmlal.s16 q11, d7, d7 \n"
|
||||
"bgt 1b \n"
|
||||
"1: \n"
|
||||
"vld1.8 {q0}, [%0]! \n"
|
||||
"vld1.8 {q1}, [%1]! \n"
|
||||
"subs %2, %2, #16 \n"
|
||||
"vsubl.u8 q2, d0, d2 \n"
|
||||
"vsubl.u8 q3, d1, d3 \n"
|
||||
"vmlal.s16 q8, d4, d4 \n"
|
||||
"vmlal.s16 q9, d6, d6 \n"
|
||||
"vmlal.s16 q10, d5, d5 \n"
|
||||
"vmlal.s16 q11, d7, d7 \n"
|
||||
"bgt 1b \n"
|
||||
|
||||
"vadd.u32 q8, q8, q9 \n"
|
||||
"vadd.u32 q10, q10, q11 \n"
|
||||
"vadd.u32 q11, q8, q10 \n"
|
||||
"vpaddl.u32 q1, q11 \n"
|
||||
"vadd.u64 d0, d2, d3 \n"
|
||||
"vmov.32 %3, d0[0] \n"
|
||||
"vadd.u32 q8, q8, q9 \n"
|
||||
"vadd.u32 q10, q10, q11 \n"
|
||||
"vadd.u32 q11, q8, q10 \n"
|
||||
"vpaddl.u32 q1, q11 \n"
|
||||
"vadd.u64 d0, d2, d3 \n"
|
||||
"vmov.32 %3, d0[0] \n"
|
||||
: "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse)
|
||||
:
|
||||
: "memory", "cc", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11");
|
||||
return sse;
|
||||
}
|
||||
|
||||
#define SSIM_ROW_NEON32(LOAD_A, LOAD_B, PADD_U8, PADD_U16) \
|
||||
LOAD_A \
|
||||
LOAD_B \
|
||||
PADD_U8 " q8, q0 \n" PADD_U8 \
|
||||
" q9, q1 \n" \
|
||||
"vmull.u8 q2, d0, d0 \n" \
|
||||
"vmull.u8 q3, d1, d1 \n" PADD_U16 \
|
||||
" q10, q2 \n" PADD_U16 \
|
||||
" q11, q3 \n" \
|
||||
"vmull.u8 q2, d2, d2 \n" \
|
||||
"vmull.u8 q3, d3, d3 \n" \
|
||||
"vpadal.u16 q10, q2 \n" \
|
||||
"vpadal.u16 q11, q3 \n" \
|
||||
"vmull.u8 q2, d0, d2 \n" \
|
||||
"vmull.u8 q3, d1, d3 \n" PADD_U16 \
|
||||
" q12, q2 \n" PADD_U16 \
|
||||
" q13, q3 \n"
|
||||
|
||||
void Ssim4x4Row_NEON(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width) {
|
||||
asm volatile(
|
||||
"1: \n" //
|
||||
SSIM_ROW_NEON32("vld1.8 {d0, d1}, [%[src_a]], %[stride_a]\n",
|
||||
"vld1.8 {d2, d3}, [%[src_b]], %[stride_b]\n", "vpaddl.u8",
|
||||
"vpaddl.u16") //
|
||||
SSIM_ROW_NEON32("vld1.8 {d0, d1}, [%[src_a]], %[stride_a]\n",
|
||||
"vld1.8 {d2, d3}, [%[src_b]], %[stride_b]\n", "vpadal.u8",
|
||||
"vpadal.u16") //
|
||||
SSIM_ROW_NEON32("vld1.8 {d0, d1}, [%[src_a]], %[stride_a]\n",
|
||||
"vld1.8 {d2, d3}, [%[src_b]], %[stride_b]\n", "vpadal.u8",
|
||||
"vpadal.u16") //
|
||||
SSIM_ROW_NEON32("vld1.8 {d0, d1}, [%[src_a]]\n",
|
||||
"vld1.8 {d2, d3}, [%[src_b]]\n", "vpadal.u8",
|
||||
"vpadal.u16") //
|
||||
"sub %[src_a], %[src_a], %[stride_a], lsl #1 \n"
|
||||
"sub %[src_a], %[src_a], %[stride_a] \n"
|
||||
"add %[src_a], %[src_a], #16 \n"
|
||||
"sub %[src_b], %[src_b], %[stride_b], lsl #1 \n"
|
||||
"sub %[src_b], %[src_b], %[stride_b] \n"
|
||||
"add %[src_b], %[src_b], #16 \n"
|
||||
"vpaddl.u16 q8, q8 \n"
|
||||
"vpaddl.u16 q9, q9 \n"
|
||||
"vpadd.u32 d20, d20, d21 \n"
|
||||
"vpadd.u32 d21, d22, d23 \n"
|
||||
"vpadd.u32 d22, d24, d25 \n"
|
||||
"vpadd.u32 d23, d26, d27 \n"
|
||||
"subs %[width], %[width], #16 \n"
|
||||
"vst4.32 {d16, d18, d20, d22}, [%[dst]]! \n"
|
||||
"vst4.32 {d17, d19, d21, d23}, [%[dst]]! \n"
|
||||
"bgt 1b \n"
|
||||
: [src_a] "+r"(src_a), [src_b] "+r"(src_b), [dst] "+r"(dst),
|
||||
[width] "+r"(width)
|
||||
: [stride_a] "r"(stride_a), [stride_b] "r"(stride_b)
|
||||
: "memory", "cc", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12",
|
||||
"q13");
|
||||
}
|
||||
#undef SSIM_ROW_NEON32
|
||||
|
||||
static const uvec32 kDjb2Multiplicands[] = {
|
||||
{0x0c3525e1, // 33^15
|
||||
0xa3476dc1, // 33^14
|
||||
0x3b4039a1, // 33^13
|
||||
0x4f5f0981}, // 33^12
|
||||
{0x30f35d61, // 33^11
|
||||
0x855cb541, // 33^10
|
||||
0x040a9121, // 33^9
|
||||
0x747c7101}, // 33^8
|
||||
{0xec41d4e1, // 33^7
|
||||
0x4cfa3cc1, // 33^6
|
||||
0x025528a1, // 33^5
|
||||
0x00121881}, // 33^4
|
||||
{0x00008c61, // 33^3
|
||||
0x00000441, // 33^2
|
||||
0x00000021, // 33^1
|
||||
0x00000001}, // 33^0
|
||||
};
|
||||
|
||||
uint32_t HashDjb2_NEON(const uint8_t* src, int count, uint32_t seed) {
|
||||
uint32_t hash = seed;
|
||||
const uint32_t c16 = 0x92d9e201; // 33^16
|
||||
const void* muls0 = &kDjb2Multiplicands[0];
|
||||
const void* muls1 = &kDjb2Multiplicands[2];
|
||||
uint32_t tmp;
|
||||
asm volatile(
|
||||
"vld1.32 {d16, d17, d18, d19}, [%[muls0]] \n"
|
||||
"vld1.32 {d20, d21, d22, d23}, [%[muls1]] \n"
|
||||
"1: \n"
|
||||
"vld1.8 {d0, d1}, [%[src]]! \n"
|
||||
"subs %[count], %[count], #16 \n"
|
||||
"vmovl.u8 q1, d0 \n"
|
||||
"vmovl.u8 q2, d1 \n"
|
||||
"vmovl.u16 q0, d2 \n"
|
||||
"vmovl.u16 q1, d3 \n"
|
||||
"vmovl.u16 q3, d5 \n"
|
||||
"vmovl.u16 q2, d4 \n"
|
||||
"vmul.i32 q0, q0, q8 \n"
|
||||
"vmla.i32 q0, q1, q9 \n"
|
||||
"vmla.i32 q0, q2, q10 \n"
|
||||
"vmla.i32 q0, q3, q11 \n"
|
||||
"vpadd.i32 d0, d0, d1 \n"
|
||||
"vpadd.i32 d0, d0, d0 \n"
|
||||
"vmov.32 %[tmp], d0[0] \n"
|
||||
"mla %[hash], %[hash], %[c16], %[tmp] \n"
|
||||
"bgt 1b \n"
|
||||
:
|
||||
[src] "+r"(src), [hash] "+r"(hash), [count] "+r"(count), [tmp] "=&r"(tmp)
|
||||
: [muls0] "r"(muls0), [muls1] "r"(muls1), [c16] "r"(c16)
|
||||
: "memory", "cc", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11");
|
||||
return hash;
|
||||
}
|
||||
|
||||
float SsimWindowRow_NEON(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows) {
|
||||
const uint32_t* row0_next = row0 + 4;
|
||||
const uint32_t* row1_next = row1 + 4;
|
||||
float total;
|
||||
asm volatile(
|
||||
"vmov.i32 q12, #0 \n"
|
||||
"vdup.32 q13, %[c1] \n"
|
||||
"vdup.32 q14, %[c2] \n"
|
||||
"1: \n"
|
||||
"vld4.32 {d0, d2, d4, d6}, [%[row0]]! \n"
|
||||
"vld4.32 {d1, d3, d5, d7}, [%[row0]]! \n"
|
||||
"vld4.32 {d16, d18, d20, d22}, [%[row0_next]]! \n"
|
||||
"vld4.32 {d17, d19, d21, d23}, [%[row0_next]]! \n"
|
||||
"vadd.i32 q0, q0, q8 \n"
|
||||
"vadd.i32 q1, q1, q9 \n"
|
||||
"vadd.i32 q2, q2, q10 \n"
|
||||
"vadd.i32 q3, q3, q11 \n"
|
||||
"vld4.32 {d16, d18, d20, d22}, [%[row1]]! \n"
|
||||
"vld4.32 {d17, d19, d21, d23}, [%[row1]]! \n"
|
||||
"vadd.i32 q0, q0, q8 \n"
|
||||
"vadd.i32 q1, q1, q9 \n"
|
||||
"vadd.i32 q2, q2, q10 \n"
|
||||
"vadd.i32 q3, q3, q11 \n"
|
||||
"vld4.32 {d16, d18, d20, d22}, [%[row1_next]]! \n"
|
||||
"vld4.32 {d17, d19, d21, d23}, [%[row1_next]]! \n"
|
||||
"vadd.i32 q0, q0, q8 \n"
|
||||
"vadd.i32 q1, q1, q9 \n"
|
||||
"vadd.i32 q2, q2, q10 \n"
|
||||
"vadd.i32 q3, q3, q11 \n"
|
||||
"vmul.i32 q8, q0, q1 \n"
|
||||
"vshl.i32 q8, q8, #1 \n"
|
||||
"vmul.i32 q9, q0, q0 \n"
|
||||
"vmla.i32 q9, q1, q1 \n"
|
||||
"vshl.i32 q3, q3, #7 \n"
|
||||
"vsub.i32 q3, q3, q8 \n"
|
||||
"vadd.i32 q8, q8, q13 \n"
|
||||
"vadd.i32 q3, q3, q14 \n"
|
||||
"vshl.i32 q2, q2, #6 \n"
|
||||
"vsub.i32 q2, q2, q9 \n"
|
||||
"vadd.i32 q9, q9, q13 \n"
|
||||
"vadd.i32 q2, q2, q14 \n"
|
||||
"vcvt.f32.s32 q8, q8 \n"
|
||||
"vcvt.f32.s32 q3, q3 \n"
|
||||
"vcvt.f32.s32 q9, q9 \n"
|
||||
"vcvt.f32.s32 q2, q2 \n"
|
||||
"vmul.f32 q3, q8, q3 \n"
|
||||
"vmul.f32 q2, q9, q2 \n"
|
||||
"vdiv.f32 s12, s12, s8 \n"
|
||||
"vdiv.f32 s13, s13, s9 \n"
|
||||
"vdiv.f32 s14, s14, s10 \n"
|
||||
"vdiv.f32 s15, s15, s11 \n"
|
||||
"subs %[num_windows], %[num_windows], #4 \n"
|
||||
"vadd.f32 q12, q12, q3 \n"
|
||||
"bgt 1b \n"
|
||||
"vpadd.f32 d0, d24, d25 \n"
|
||||
"vpadd.f32 d0, d0, d0 \n"
|
||||
"vmov.f32 %[total], s0 \n"
|
||||
: [row0] "+r"(row0), [row0_next] "+r"(row0_next), [row1] "+r"(row1),
|
||||
[row1_next] "+r"(row1_next), [num_windows] "+r"(num_windows),
|
||||
[total] "=r"(total)
|
||||
: [c1] "r"(26634), [c2] "r"(239708)
|
||||
: "memory", "cc", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12",
|
||||
"q13", "q14");
|
||||
return total;
|
||||
}
|
||||
|
||||
uint32_t ARGBDetectRow_NEON(const uint8_t* argb, int width) {
|
||||
uint32_t diff_lo = 0;
|
||||
uint32_t diff_hi = 0;
|
||||
uint32_t tmp;
|
||||
asm volatile(
|
||||
"vmov.i32 q2, #0x00ff0000 \n"
|
||||
"vorr.i32 q2, #0x0000ff00 \n"
|
||||
"vmov.i8 q3, #0xff \n"
|
||||
"subs %[width], %[width], #4 \n"
|
||||
"blt 2f \n"
|
||||
"1: \n"
|
||||
"vld1.8 {q0}, [%[argb]]! \n"
|
||||
"vorr q0, q0, q2 \n"
|
||||
"vceq.i8 q0, q0, q3 \n"
|
||||
"vmvn q0, q0 \n"
|
||||
"vshrn.i16 d0, q0, #4 \n"
|
||||
"vmov %[diff_lo], %[diff_hi], d0 \n"
|
||||
"orrs %[tmp], %[diff_lo], %[diff_hi] \n"
|
||||
"bne 99f \n"
|
||||
"subs %[width], %[width], #4 \n"
|
||||
"bge 1b \n"
|
||||
"2: \n"
|
||||
"adds %[width], %[width], #4 \n"
|
||||
"ble 99f \n"
|
||||
"3: \n"
|
||||
"vld1.32 {d0[0]}, [%[argb]]! \n"
|
||||
"vorr d0, d0, d4 \n"
|
||||
"vceq.i8 d0, d0, d6 \n"
|
||||
"vmvn d0, d0 \n"
|
||||
"vshrn.i16 d0, q0, #4 \n"
|
||||
"vmov.u16 %[diff_lo], d0[0] \n"
|
||||
"cmp %[diff_lo], #0 \n"
|
||||
"bne 99f \n"
|
||||
"subs %[width], %[width], #1 \n"
|
||||
"bgt 3b \n"
|
||||
"99: \n"
|
||||
: [argb] "+r"(argb), [width] "+r"(width), [diff_lo] "+r"(diff_lo),
|
||||
[diff_hi] "+r"(diff_hi), [tmp] "=&r"(tmp)
|
||||
:
|
||||
: "memory", "cc", "q0", "q2", "q3");
|
||||
if (diff_lo) {
|
||||
return (__builtin_ctz(diff_lo) & 12) == 0 ? FOURCC_BGRA : FOURCC_ARGB;
|
||||
}
|
||||
if (diff_hi) {
|
||||
return (__builtin_ctz(diff_hi) & 12) == 0 ? FOURCC_BGRA : FOURCC_ARGB;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // defined(__ARM_NEON__) && !defined(__aarch64__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -8,16 +8,22 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#include "libyuv/compare_row.h"
|
||||
#include "libyuv/row.h"
|
||||
#include "libyuv/video_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Note: every register written by an inline asm block (vector, general
|
||||
// purpose, mask/predicate, "cc" for flags and "memory" for stores) must be
|
||||
// listed in its clobber list, even when the ABI treats it as caller-saved.
|
||||
// With LTO/LTCG the compiler may keep values live in any register across the
|
||||
// asm statement, and other OS ABIs (e.g. Windows) differ in which registers
|
||||
// are callee-saved. List "memory" first, then "cc", then registers.
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
|
||||
|
||||
// 256 bits at a time
|
||||
@@ -27,25 +33,27 @@ uint32_t HammingDistance_NEON(const uint8_t* src_a,
|
||||
int count) {
|
||||
uint32_t diff;
|
||||
asm volatile(
|
||||
"movi v4.8h, #0 \n"
|
||||
"movi v4.8h, #0 \n"
|
||||
|
||||
"1: \n"
|
||||
"ld1 {v0.16b, v1.16b}, [%0], #32 \n"
|
||||
"ld1 {v2.16b, v3.16b}, [%1], #32 \n"
|
||||
"eor v0.16b, v0.16b, v2.16b \n"
|
||||
"eor v1.16b, v1.16b, v3.16b \n"
|
||||
"cnt v0.16b, v0.16b \n"
|
||||
"cnt v1.16b, v1.16b \n"
|
||||
"subs %w2, %w2, #32 \n"
|
||||
"add v0.16b, v0.16b, v1.16b \n"
|
||||
"uadalp v4.8h, v0.16b \n"
|
||||
"b.gt 1b \n"
|
||||
"1: \n"
|
||||
"ld1 {v0.16b, v1.16b}, [%0], #32 \n"
|
||||
"ld1 {v2.16b, v3.16b}, [%1], #32 \n"
|
||||
"eor v0.16b, v0.16b, v2.16b \n"
|
||||
"prfm pldl1keep, [%0, 448] \n" // prefetch 7 lines ahead
|
||||
"eor v1.16b, v1.16b, v3.16b \n"
|
||||
"cnt v0.16b, v0.16b \n"
|
||||
"prfm pldl1keep, [%1, 448] \n"
|
||||
"cnt v1.16b, v1.16b \n"
|
||||
"subs %w2, %w2, #32 \n"
|
||||
"add v0.16b, v0.16b, v1.16b \n"
|
||||
"uadalp v4.8h, v0.16b \n"
|
||||
"b.gt 1b \n"
|
||||
|
||||
"uaddlv s4, v4.8h \n"
|
||||
"fmov %w3, s4 \n"
|
||||
"uaddlv s4, v4.8h \n"
|
||||
"fmov %w3, s4 \n"
|
||||
: "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(diff)
|
||||
:
|
||||
: "cc", "v0", "v1", "v2", "v3", "v4");
|
||||
: "memory", "cc", "v0", "v1", "v2", "v3", "v4");
|
||||
return diff;
|
||||
}
|
||||
|
||||
@@ -54,34 +62,395 @@ uint32_t SumSquareError_NEON(const uint8_t* src_a,
|
||||
int count) {
|
||||
uint32_t sse;
|
||||
asm volatile(
|
||||
"eor v16.16b, v16.16b, v16.16b \n"
|
||||
"eor v18.16b, v18.16b, v18.16b \n"
|
||||
"eor v17.16b, v17.16b, v17.16b \n"
|
||||
"eor v19.16b, v19.16b, v19.16b \n"
|
||||
"movi v16.16b, #0 \n"
|
||||
"movi v17.16b, #0 \n"
|
||||
"movi v18.16b, #0 \n"
|
||||
"movi v19.16b, #0 \n"
|
||||
|
||||
"1: \n"
|
||||
"ld1 {v0.16b}, [%0], #16 \n"
|
||||
"ld1 {v1.16b}, [%1], #16 \n"
|
||||
"subs %w2, %w2, #16 \n"
|
||||
"usubl v2.8h, v0.8b, v1.8b \n"
|
||||
"usubl2 v3.8h, v0.16b, v1.16b \n"
|
||||
"smlal v16.4s, v2.4h, v2.4h \n"
|
||||
"smlal v17.4s, v3.4h, v3.4h \n"
|
||||
"smlal2 v18.4s, v2.8h, v2.8h \n"
|
||||
"smlal2 v19.4s, v3.8h, v3.8h \n"
|
||||
"b.gt 1b \n"
|
||||
"1: \n"
|
||||
"ld1 {v0.16b}, [%0], #16 \n"
|
||||
"ld1 {v1.16b}, [%1], #16 \n"
|
||||
"subs %w2, %w2, #16 \n"
|
||||
"usubl v2.8h, v0.8b, v1.8b \n"
|
||||
"usubl2 v3.8h, v0.16b, v1.16b \n"
|
||||
"prfm pldl1keep, [%0, 448] \n" // prefetch 7 lines ahead
|
||||
"smlal v16.4s, v2.4h, v2.4h \n"
|
||||
"smlal v17.4s, v3.4h, v3.4h \n"
|
||||
"prfm pldl1keep, [%1, 448] \n"
|
||||
"smlal2 v18.4s, v2.8h, v2.8h \n"
|
||||
"smlal2 v19.4s, v3.8h, v3.8h \n"
|
||||
"b.gt 1b \n"
|
||||
|
||||
"add v16.4s, v16.4s, v17.4s \n"
|
||||
"add v18.4s, v18.4s, v19.4s \n"
|
||||
"add v19.4s, v16.4s, v18.4s \n"
|
||||
"addv s0, v19.4s \n"
|
||||
"fmov %w3, s0 \n"
|
||||
"add v16.4s, v16.4s, v17.4s \n"
|
||||
"add v18.4s, v18.4s, v19.4s \n"
|
||||
"add v19.4s, v16.4s, v18.4s \n"
|
||||
"addv s0, v19.4s \n"
|
||||
"fmov %w3, s0 \n"
|
||||
: "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse)
|
||||
:
|
||||
: "cc", "v0", "v1", "v2", "v3", "v16", "v17", "v18", "v19");
|
||||
: "memory", "cc", "v0", "v1", "v2", "v3", "v16", "v17", "v18", "v19");
|
||||
return sse;
|
||||
}
|
||||
|
||||
static const uvec32 kDjb2Multiplicands[] = {
|
||||
{0x0c3525e1, // 33^15
|
||||
0xa3476dc1, // 33^14
|
||||
0x3b4039a1, // 33^13
|
||||
0x4f5f0981}, // 33^12
|
||||
{0x30f35d61, // 33^11
|
||||
0x855cb541, // 33^10
|
||||
0x040a9121, // 33^9
|
||||
0x747c7101}, // 33^8
|
||||
{0xec41d4e1, // 33^7
|
||||
0x4cfa3cc1, // 33^6
|
||||
0x025528a1, // 33^5
|
||||
0x00121881}, // 33^4
|
||||
{0x00008c61, // 33^3
|
||||
0x00000441, // 33^2
|
||||
0x00000021, // 33^1
|
||||
0x00000001}, // 33^0
|
||||
};
|
||||
|
||||
static const uvec32 kDjb2WidenIndices[] = {
|
||||
{0xffffff00U, 0xffffff01U, 0xffffff02U, 0xffffff03U},
|
||||
{0xffffff04U, 0xffffff05U, 0xffffff06U, 0xffffff07U},
|
||||
{0xffffff08U, 0xffffff09U, 0xffffff0aU, 0xffffff0bU},
|
||||
{0xffffff0cU, 0xffffff0dU, 0xffffff0eU, 0xffffff0fU},
|
||||
};
|
||||
|
||||
uint32_t HashDjb2_NEON(const uint8_t* src, int count, uint32_t seed) {
|
||||
uint32_t hash = seed;
|
||||
const uint32_t c16 = 0x92d9e201; // 33^16
|
||||
uint32_t tmp, tmp2;
|
||||
asm("ld1 {v16.4s, v17.4s, v18.4s, v19.4s}, [%[kIdx]] \n"
|
||||
"ld1 {v4.4s, v5.4s, v6.4s, v7.4s}, [%[kMuls]] \n"
|
||||
|
||||
// count is always a multiple of 16.
|
||||
// maintain two accumulators, reduce and then final sum in scalar since
|
||||
// this has better performance on little cores.
|
||||
"1: \n"
|
||||
"ldr q0, [%[src]], #16 \n"
|
||||
"subs %w[count], %w[count], #16 \n"
|
||||
"tbl v3.16b, {v0.16b}, v19.16b \n"
|
||||
"tbl v2.16b, {v0.16b}, v18.16b \n"
|
||||
"tbl v1.16b, {v0.16b}, v17.16b \n"
|
||||
"tbl v0.16b, {v0.16b}, v16.16b \n"
|
||||
"mul v3.4s, v3.4s, v7.4s \n"
|
||||
"mul v2.4s, v2.4s, v6.4s \n"
|
||||
"mla v3.4s, v1.4s, v5.4s \n"
|
||||
"mla v2.4s, v0.4s, v4.4s \n"
|
||||
"addv s1, v3.4s \n"
|
||||
"addv s0, v2.4s \n"
|
||||
"fmov %w[tmp2], s1 \n"
|
||||
"fmov %w[tmp], s0 \n"
|
||||
"add %w[tmp], %w[tmp], %w[tmp2] \n"
|
||||
"madd %w[hash], %w[hash], %w[c16], %w[tmp] \n"
|
||||
"b.gt 1b \n"
|
||||
: [src] "+r"(src), // %[src]
|
||||
[hash] "+r"(hash), // %[hash]
|
||||
[count] "+r"(count), // %[count]
|
||||
[tmp] "=&r"(tmp), // %[tmp]
|
||||
[tmp2] "=&r"(tmp2) // %[tmp2]
|
||||
: [kMuls] "r"(kDjb2Multiplicands), // %[kMuls]
|
||||
[kIdx] "r"(kDjb2WidenIndices), // %[kIdx]
|
||||
[c16] "r"(c16) // %[c16]
|
||||
: "cc", "memory", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v16",
|
||||
"v17", "v18", "v19");
|
||||
return hash;
|
||||
}
|
||||
|
||||
uint32_t HammingDistance_NEON_DotProd(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
uint32_t diff;
|
||||
asm volatile(
|
||||
"movi v4.4s, #0 \n"
|
||||
"movi v5.4s, #0 \n"
|
||||
"movi v6.16b, #1 \n"
|
||||
|
||||
"1: \n"
|
||||
"ldp q0, q1, [%0], #32 \n"
|
||||
"ldp q2, q3, [%1], #32 \n"
|
||||
"eor v0.16b, v0.16b, v2.16b \n"
|
||||
"prfm pldl1keep, [%0, 448] \n" // prefetch 7 lines ahead
|
||||
"eor v1.16b, v1.16b, v3.16b \n"
|
||||
"cnt v0.16b, v0.16b \n"
|
||||
"prfm pldl1keep, [%1, 448] \n"
|
||||
"cnt v1.16b, v1.16b \n"
|
||||
"subs %w2, %w2, #32 \n"
|
||||
"udot v4.4s, v0.16b, v6.16b \n"
|
||||
"udot v5.4s, v1.16b, v6.16b \n"
|
||||
"b.gt 1b \n"
|
||||
|
||||
"add v0.4s, v4.4s, v5.4s \n"
|
||||
"addv s0, v0.4s \n"
|
||||
"fmov %w3, s0 \n"
|
||||
: "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(diff)
|
||||
:
|
||||
: "memory", "cc", "v0", "v1", "v2", "v3", "v4", "v5", "v6");
|
||||
return diff;
|
||||
}
|
||||
|
||||
uint32_t SumSquareError_NEON_DotProd(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
// count is guaranteed to be a multiple of 32.
|
||||
uint32_t sse;
|
||||
asm volatile(
|
||||
"movi v4.4s, #0 \n"
|
||||
"movi v5.4s, #0 \n"
|
||||
|
||||
"1: \n"
|
||||
"ldp q0, q2, [%0], #32 \n"
|
||||
"ldp q1, q3, [%1], #32 \n"
|
||||
"subs %w2, %w2, #32 \n"
|
||||
"uabd v0.16b, v0.16b, v1.16b \n"
|
||||
"uabd v1.16b, v2.16b, v3.16b \n"
|
||||
"prfm pldl1keep, [%0, 448] \n" // prefetch 7 lines ahead
|
||||
"udot v4.4s, v0.16b, v0.16b \n"
|
||||
"udot v5.4s, v1.16b, v1.16b \n"
|
||||
"prfm pldl1keep, [%1, 448] \n"
|
||||
"b.gt 1b \n"
|
||||
|
||||
"add v0.4s, v4.4s, v5.4s \n"
|
||||
"addv s0, v0.4s \n"
|
||||
"fmov %w3, s0 \n"
|
||||
: "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse)
|
||||
:
|
||||
: "memory", "cc", "v0", "v1", "v2", "v3", "v4", "v5");
|
||||
return sse;
|
||||
}
|
||||
|
||||
#define SSIM_ROW_NEON64(VA, VB, PADD_U8, PADD_U16) \
|
||||
PADD_U8 " v4.8h, " #VA ".16b \n" PADD_U8 \
|
||||
" v5.8h, " #VB \
|
||||
".16b \n" \
|
||||
"umull v6.8h, " #VA ".8b, " #VA \
|
||||
".8b \n" \
|
||||
"umull2 v7.8h, " #VA ".16b, " #VA ".16b \n" PADD_U16 \
|
||||
" v20.4s, v6.8h \n" PADD_U16 \
|
||||
" v21.4s, v7.8h \n" \
|
||||
"umull v6.8h, " #VB ".8b, " #VB \
|
||||
".8b \n" \
|
||||
"umull2 v7.8h, " #VB ".16b, " #VB \
|
||||
".16b \n" \
|
||||
"uadalp v20.4s, v6.8h \n" \
|
||||
"uadalp v21.4s, v7.8h \n" \
|
||||
"umull v6.8h, " #VA ".8b, " #VB \
|
||||
".8b \n" \
|
||||
"umull2 v7.8h, " #VA ".16b, " #VB ".16b \n" PADD_U16 \
|
||||
" v22.4s, v6.8h \n" PADD_U16 \
|
||||
" v23.4s, v7.8h \n"
|
||||
|
||||
void Ssim4x4Row_NEON(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width) {
|
||||
const ptrdiff_t sa = stride_a;
|
||||
const ptrdiff_t sb = stride_b;
|
||||
const uint8_t* a0 = src_a;
|
||||
const uint8_t* a1 = a0 + sa;
|
||||
const uint8_t* a2 = a1 + sa;
|
||||
const uint8_t* a3 = a2 + sa;
|
||||
const uint8_t* b0 = src_b;
|
||||
const uint8_t* b1 = b0 + sb;
|
||||
const uint8_t* b2 = b1 + sb;
|
||||
const uint8_t* b3 = b2 + sb;
|
||||
asm volatile(
|
||||
"1: \n"
|
||||
"ldr q0, [%[a0]], #16 \n"
|
||||
"ldr q1, [%[b0]], #16 \n"
|
||||
"ldr q2, [%[a1]], #16 \n"
|
||||
"ldr q3, [%[b1]], #16 \n" //
|
||||
SSIM_ROW_NEON64(v0, v1, "uaddlp", "uaddlp") //
|
||||
SSIM_ROW_NEON64(v2, v3, "uadalp", "uadalp") //
|
||||
"ldr q0, [%[a2]], #16 \n"
|
||||
"ldr q1, [%[b2]], #16 \n"
|
||||
"ldr q2, [%[a3]], #16 \n"
|
||||
"ldr q3, [%[b3]], #16 \n" //
|
||||
SSIM_ROW_NEON64(v0, v1, "uadalp", "uadalp") //
|
||||
SSIM_ROW_NEON64(v2, v3, "uadalp", "uadalp") //
|
||||
"uaddlp v16.4s, v4.8h \n"
|
||||
"uaddlp v17.4s, v5.8h \n"
|
||||
"addp v18.4s, v20.4s, v21.4s \n"
|
||||
"addp v19.4s, v22.4s, v23.4s \n"
|
||||
"subs %w[width], %w[width], #16 \n"
|
||||
"st4 {v16.4s, v17.4s, v18.4s, v19.4s}, [%[dst]], #64 \n"
|
||||
"b.gt 1b \n"
|
||||
: [a0] "+r"(a0), [a1] "+r"(a1), [a2] "+r"(a2), [a3] "+r"(a3),
|
||||
[b0] "+r"(b0), [b1] "+r"(b1), [b2] "+r"(b2), [b3] "+r"(b3),
|
||||
[dst] "+r"(dst), [width] "+r"(width)
|
||||
:
|
||||
: "memory", "cc", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v16",
|
||||
"v17", "v18", "v19", "v20", "v21", "v22", "v23");
|
||||
}
|
||||
#undef SSIM_ROW_NEON64
|
||||
|
||||
void Ssim4x4Row_NEON_DotProd(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width) {
|
||||
const ptrdiff_t sa = stride_a;
|
||||
const ptrdiff_t sb = stride_b;
|
||||
const uint8_t* a0 = src_a;
|
||||
const uint8_t* a1 = a0 + sa;
|
||||
const uint8_t* a2 = a1 + sa;
|
||||
const uint8_t* a3 = a2 + sa;
|
||||
const uint8_t* b0 = src_b;
|
||||
const uint8_t* b1 = b0 + sb;
|
||||
const uint8_t* b2 = b1 + sb;
|
||||
const uint8_t* b3 = b2 + sb;
|
||||
asm volatile(
|
||||
"movi v6.16b, #1 \n"
|
||||
"1: \n"
|
||||
"movi v16.4s, #0 \n"
|
||||
"movi v17.4s, #0 \n"
|
||||
"movi v18.4s, #0 \n"
|
||||
"movi v19.4s, #0 \n"
|
||||
"ldr q0, [%[a0]], #16 \n"
|
||||
"ldr q1, [%[b0]], #16 \n"
|
||||
"ldr q2, [%[a1]], #16 \n"
|
||||
"ldr q3, [%[b1]], #16 \n"
|
||||
"udot v16.4s, v0.16b, v6.16b \n"
|
||||
"udot v17.4s, v1.16b, v6.16b \n"
|
||||
"udot v18.4s, v0.16b, v0.16b \n"
|
||||
"udot v18.4s, v1.16b, v1.16b \n"
|
||||
"udot v19.4s, v0.16b, v1.16b \n"
|
||||
"udot v16.4s, v2.16b, v6.16b \n"
|
||||
"udot v17.4s, v3.16b, v6.16b \n"
|
||||
"udot v18.4s, v2.16b, v2.16b \n"
|
||||
"udot v18.4s, v3.16b, v3.16b \n"
|
||||
"udot v19.4s, v2.16b, v3.16b \n"
|
||||
"ldr q0, [%[a2]], #16 \n"
|
||||
"ldr q1, [%[b2]], #16 \n"
|
||||
"ldr q2, [%[a3]], #16 \n"
|
||||
"ldr q3, [%[b3]], #16 \n"
|
||||
"udot v16.4s, v0.16b, v6.16b \n"
|
||||
"udot v17.4s, v1.16b, v6.16b \n"
|
||||
"udot v18.4s, v0.16b, v0.16b \n"
|
||||
"udot v18.4s, v1.16b, v1.16b \n"
|
||||
"udot v19.4s, v0.16b, v1.16b \n"
|
||||
"udot v16.4s, v2.16b, v6.16b \n"
|
||||
"udot v17.4s, v3.16b, v6.16b \n"
|
||||
"udot v18.4s, v2.16b, v2.16b \n"
|
||||
"udot v18.4s, v3.16b, v3.16b \n"
|
||||
"udot v19.4s, v2.16b, v3.16b \n"
|
||||
"subs %w[width], %w[width], #16 \n"
|
||||
"st4 {v16.4s, v17.4s, v18.4s, v19.4s}, [%[dst]], #64 \n"
|
||||
"b.gt 1b \n"
|
||||
: [a0] "+r"(a0), [a1] "+r"(a1), [a2] "+r"(a2), [a3] "+r"(a3),
|
||||
[b0] "+r"(b0), [b1] "+r"(b1), [b2] "+r"(b2), [b3] "+r"(b3),
|
||||
[dst] "+r"(dst), [width] "+r"(width)
|
||||
:
|
||||
: "memory", "cc", "v0", "v1", "v2", "v3", "v6", "v16", "v17", "v18",
|
||||
"v19");
|
||||
}
|
||||
|
||||
float SsimWindowRow_NEON(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows) {
|
||||
const uint32_t* row0_next = row0 + 4;
|
||||
const uint32_t* row1_next = row1 + 4;
|
||||
float total;
|
||||
asm volatile(
|
||||
"movi v24.4s, #0 \n"
|
||||
"dup v25.4s, %w[c1] \n"
|
||||
"dup v26.4s, %w[c2] \n"
|
||||
"1: \n"
|
||||
"ld4 {v0.4s, v1.4s, v2.4s, v3.4s}, [%[row0]], #64 \n"
|
||||
"ld4 {v4.4s, v5.4s, v6.4s, v7.4s}, [%[row0_next]], #64 \n"
|
||||
"ld4 {v16.4s, v17.4s, v18.4s, v19.4s}, [%[row1]], #64 \n"
|
||||
"ld4 {v20.4s, v21.4s, v22.4s, v23.4s}, [%[row1_next]], #64 \n"
|
||||
"add v0.4s, v0.4s, v4.4s \n"
|
||||
"add v1.4s, v1.4s, v5.4s \n"
|
||||
"add v2.4s, v2.4s, v6.4s \n"
|
||||
"add v3.4s, v3.4s, v7.4s \n"
|
||||
"add v16.4s, v16.4s, v20.4s \n"
|
||||
"add v17.4s, v17.4s, v21.4s \n"
|
||||
"add v18.4s, v18.4s, v22.4s \n"
|
||||
"add v19.4s, v19.4s, v23.4s \n"
|
||||
"add v0.4s, v0.4s, v16.4s \n"
|
||||
"add v1.4s, v1.4s, v17.4s \n"
|
||||
"add v2.4s, v2.4s, v18.4s \n"
|
||||
"add v3.4s, v3.4s, v19.4s \n"
|
||||
"mul v4.4s, v0.4s, v1.4s \n"
|
||||
"shl v4.4s, v4.4s, #1 \n"
|
||||
"mul v5.4s, v0.4s, v0.4s \n"
|
||||
"mla v5.4s, v1.4s, v1.4s \n"
|
||||
"shl v3.4s, v3.4s, #7 \n"
|
||||
"sub v3.4s, v3.4s, v4.4s \n"
|
||||
"add v4.4s, v4.4s, v25.4s \n"
|
||||
"add v3.4s, v3.4s, v26.4s \n"
|
||||
"shl v2.4s, v2.4s, #6 \n"
|
||||
"sub v2.4s, v2.4s, v5.4s \n"
|
||||
"add v5.4s, v5.4s, v25.4s \n"
|
||||
"add v2.4s, v2.4s, v26.4s \n"
|
||||
"scvtf v4.4s, v4.4s \n"
|
||||
"scvtf v3.4s, v3.4s \n"
|
||||
"scvtf v5.4s, v5.4s \n"
|
||||
"scvtf v2.4s, v2.4s \n"
|
||||
"fmul v4.4s, v4.4s, v3.4s \n"
|
||||
"fmul v5.4s, v5.4s, v2.4s \n"
|
||||
"fdiv v4.4s, v4.4s, v5.4s \n"
|
||||
"subs %w[num_windows], %w[num_windows], #4 \n"
|
||||
"fadd v24.4s, v24.4s, v4.4s \n"
|
||||
"b.gt 1b \n"
|
||||
"faddp v24.4s, v24.4s, v24.4s \n"
|
||||
"faddp %s[total], v24.2s \n"
|
||||
: [row0] "+r"(row0), [row0_next] "+r"(row0_next), [row1] "+r"(row1),
|
||||
[row1_next] "+r"(row1_next), [num_windows] "+r"(num_windows),
|
||||
[total] "=w"(total)
|
||||
: [c1] "r"(26634), [c2] "r"(239708)
|
||||
: "memory", "cc", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v16",
|
||||
"v17", "v18", "v19", "v20", "v21", "v22", "v23", "v24", "v25", "v26");
|
||||
return total;
|
||||
}
|
||||
|
||||
uint32_t ARGBDetectRow_NEON(const uint8_t* argb, int width) {
|
||||
uint64_t diff = 0;
|
||||
asm volatile(
|
||||
"movi v2.2d, #0x00ffff0000ffff00 \n"
|
||||
"movi v3.16b, #0xff \n"
|
||||
"subs %w[width], %w[width], #4 \n"
|
||||
"b.lt 2f \n"
|
||||
"1: \n"
|
||||
"ldr q0, [%[argb]], #16 \n"
|
||||
"orr v0.16b, v0.16b, v2.16b \n"
|
||||
"cmeq v0.16b, v0.16b, v3.16b \n"
|
||||
"mvn v0.16b, v0.16b \n"
|
||||
"shrn v0.8b, v0.8h, #4 \n"
|
||||
"fmov %x[diff], d0 \n"
|
||||
"cbnz %x[diff], 99f \n"
|
||||
"subs %w[width], %w[width], #4 \n"
|
||||
"b.ge 1b \n"
|
||||
"2: \n"
|
||||
"adds %w[width], %w[width], #4 \n"
|
||||
"b.le 99f \n"
|
||||
"3: \n"
|
||||
"ldr s0, [%[argb]], #4 \n"
|
||||
"orr v0.8b, v0.8b, v2.8b \n"
|
||||
"cmeq v0.8b, v0.8b, v3.8b \n"
|
||||
"mvn v0.8b, v0.8b \n"
|
||||
"shrn v0.8b, v0.8h, #4 \n"
|
||||
"fmov %x[diff], d0 \n"
|
||||
"and %x[diff], %x[diff], #0xffff \n"
|
||||
"cbnz %x[diff], 99f \n"
|
||||
"subs %w[width], %w[width], #1 \n"
|
||||
"b.gt 3b \n"
|
||||
"99: \n"
|
||||
: [argb] "+r"(argb), [width] "+r"(width), [diff] "+r"(diff)
|
||||
:
|
||||
: "memory", "cc", "v0", "v2", "v3");
|
||||
if (diff) {
|
||||
return (__builtin_ctzll(diff) & 12) == 0 ? FOURCC_BGRA : FOURCC_ARGB;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -0,0 +1,345 @@
|
||||
/*
|
||||
* Copyright 2026 The LibYuv Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "libyuv/compare_row.h"
|
||||
#include "libyuv/row.h"
|
||||
#include "libyuv/video_common.h"
|
||||
|
||||
#if !defined(LIBYUV_DISABLE_WASM) && defined(__wasm_simd128__)
|
||||
#include <wasm_simd128.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Add the 4 32 bit lanes.
|
||||
static inline uint32_t SumLanes_WASMSIMD(v128_t sum) {
|
||||
sum = wasm_i32x4_add(sum, wasm_i64x2_shuffle(sum, sum, 1, 0));
|
||||
sum = wasm_i32x4_add(sum, wasm_i32x4_shuffle(sum, sum, 1, 0, 3, 2));
|
||||
return wasm_u32x4_extract_lane(sum, 0);
|
||||
}
|
||||
|
||||
#if defined(HAS_HAMMINGDISTANCE_WASMSIMD)
|
||||
// Bit counts of 64 bytes are added as bytes, then accumulated into 32 bit
|
||||
// lanes using relaxed i8x16 dot product when available or pairwise widening
|
||||
// adds. Count is a multiple of 64.
|
||||
uint32_t HammingDistance_WASMSIMD(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
v128_t sum = wasm_i32x4_splat(0);
|
||||
#ifdef __wasm_relaxed_simd__
|
||||
const v128_t ones = wasm_i8x16_splat(1);
|
||||
#endif
|
||||
while (count > 0) {
|
||||
v128_t c0 = wasm_i8x16_popcnt(
|
||||
wasm_v128_xor(wasm_v128_load(src_a), wasm_v128_load(src_b)));
|
||||
v128_t c1 = wasm_i8x16_popcnt(
|
||||
wasm_v128_xor(wasm_v128_load(src_a + 16), wasm_v128_load(src_b + 16)));
|
||||
v128_t c2 = wasm_i8x16_popcnt(
|
||||
wasm_v128_xor(wasm_v128_load(src_a + 32), wasm_v128_load(src_b + 32)));
|
||||
v128_t c3 = wasm_i8x16_popcnt(
|
||||
wasm_v128_xor(wasm_v128_load(src_a + 48), wasm_v128_load(src_b + 48)));
|
||||
v128_t c = wasm_i8x16_add(wasm_i8x16_add(c0, c1), wasm_i8x16_add(c2, c3));
|
||||
#ifdef __wasm_relaxed_simd__
|
||||
sum = wasm_i32x4_relaxed_dot_i8x16_i7x16_add(c, ones, sum);
|
||||
#else
|
||||
sum = wasm_i32x4_add(sum, wasm_u32x4_extadd_pairwise_u16x8(
|
||||
wasm_u16x8_extadd_pairwise_u8x16(c)));
|
||||
#endif
|
||||
src_a += 64;
|
||||
src_b += 64;
|
||||
count -= 64;
|
||||
}
|
||||
return SumLanes_WASMSIMD(sum);
|
||||
}
|
||||
#endif // HAS_HAMMINGDISTANCE_WASMSIMD
|
||||
|
||||
#if defined(HAS_SUMSQUAREERROR_WASMSIMD)
|
||||
// Differences are widened to signed 16 bits and squared with i32x4.dot.
|
||||
// Count is a multiple of 16.
|
||||
uint32_t SumSquareError_WASMSIMD(const uint8_t* src_a,
|
||||
const uint8_t* src_b,
|
||||
int count) {
|
||||
v128_t sum = wasm_i32x4_splat(0);
|
||||
while (count > 0) {
|
||||
v128_t a = wasm_v128_load(src_a);
|
||||
v128_t b = wasm_v128_load(src_b);
|
||||
v128_t lo = wasm_i16x8_sub(wasm_u16x8_extend_low_u8x16(a),
|
||||
wasm_u16x8_extend_low_u8x16(b));
|
||||
v128_t hi = wasm_i16x8_sub(wasm_u16x8_extend_high_u8x16(a),
|
||||
wasm_u16x8_extend_high_u8x16(b));
|
||||
sum = wasm_i32x4_add(sum, wasm_i32x4_add(wasm_i32x4_dot_i16x8(lo, lo),
|
||||
wasm_i32x4_dot_i16x8(hi, hi)));
|
||||
src_a += 16;
|
||||
src_b += 16;
|
||||
count -= 16;
|
||||
}
|
||||
return SumLanes_WASMSIMD(sum);
|
||||
}
|
||||
#endif // HAS_SUMSQUAREERROR_WASMSIMD
|
||||
|
||||
#if defined(HAS_HASHDJB2_WASMSIMD)
|
||||
static const uint32_t kHashMul_WASMSIMD[24] = {
|
||||
// 33 ^ (30 - 2 * i) for byte pair i of 32 bytes.
|
||||
0xccc4cfc1, 0xd61beb81, 0x13791741, 0xac185301, // 33 ^ 30 .. 24
|
||||
0xc8359ec1, 0x510cfa81, 0xb0da6641, 0x92d9e201, // 33 ^ 22 .. 16
|
||||
0xa3476dc1, 0x4f5f0981, 0x855cb541, 0x747c7101, // 33 ^ 14 .. 8
|
||||
0x4cfa3cc1, 0x00121881, 0x00000441, 0x00000001, // 33 ^ 6 .. 0
|
||||
0x1137c401, 0x1137c401, 0x1137c401, 0x1137c401, // 33 ^ 32
|
||||
0x00010021, 0x00010021, 0x00010021, 0x00010021, // 16 bit 33, 1
|
||||
};
|
||||
|
||||
// Sum of 16 bytes times 33 ^ n, as 4 lanes. Byte pairs are combined as
|
||||
// src[2 * i] * 33 + src[2 * i + 1] with i32x4.dot, then multiplied by
|
||||
// 33 ^ n for the pair.
|
||||
static inline v128_t HashMul16_WASMSIMD(const uint8_t* src,
|
||||
const v128_t* m,
|
||||
v128_t k33) {
|
||||
v128_t s = wasm_v128_load(src);
|
||||
v128_t lo = wasm_i32x4_dot_i16x8(wasm_u16x8_extend_low_u8x16(s), k33);
|
||||
v128_t hi = wasm_i32x4_dot_i16x8(wasm_u16x8_extend_high_u8x16(s), k33);
|
||||
return wasm_i32x4_add(wasm_i32x4_mul(lo, m[0]), wasm_i32x4_mul(hi, m[1]));
|
||||
}
|
||||
|
||||
// HashDjb2 of n bytes is hash * 33 ^ n + sum(src[i] * 33 ^ (n - 1 - i)).
|
||||
// Products are summed per lane, multiplying the sums by 33 ^ 32 for each 32
|
||||
// bytes, so one horizontal add is done at the end.
|
||||
// Count is a multiple of 16.
|
||||
uint32_t HashDjb2_WASMSIMD(const uint8_t* src, int count, uint32_t seed) {
|
||||
const v128_t* m = (const v128_t*)kHashMul_WASMSIMD;
|
||||
v128_t sum = wasm_i32x4_make(0, 0, 0, (int32_t)seed);
|
||||
// Load constants into Wasm locals outside the loop, instead of v128.const
|
||||
// in the loop.
|
||||
asm("" : "+r"(m));
|
||||
const v128_t k33_32 = m[4];
|
||||
const v128_t k33 = m[5];
|
||||
if (count & 16) {
|
||||
// Lane 3 of m[1] is 33 ^ 16, and lanes 0..2 of sum are 0.
|
||||
sum = wasm_i32x4_add(wasm_i32x4_mul(sum, m[1]),
|
||||
HashMul16_WASMSIMD(src, m + 2, k33));
|
||||
src += 16;
|
||||
count -= 16;
|
||||
}
|
||||
while (count > 0) {
|
||||
sum = wasm_i32x4_add(
|
||||
wasm_i32x4_mul(sum, k33_32),
|
||||
wasm_i32x4_add(HashMul16_WASMSIMD(src, m, k33),
|
||||
HashMul16_WASMSIMD(src + 16, m + 2, k33)));
|
||||
src += 32;
|
||||
count -= 32;
|
||||
}
|
||||
return SumLanes_WASMSIMD(sum);
|
||||
}
|
||||
#endif // HAS_HASHDJB2_WASMSIMD
|
||||
|
||||
#if defined(HAS_SSIM4X4ROW_WASMSIMD)
|
||||
void Ssim4x4Row_WASMSIMD(const uint8_t* src_a,
|
||||
int stride_a,
|
||||
const uint8_t* src_b,
|
||||
int stride_b,
|
||||
uint32_t* dst,
|
||||
int width) {
|
||||
const uint8_t* src_a1 = src_a + stride_a;
|
||||
const uint8_t* src_a2 = src_a1 + stride_a;
|
||||
const uint8_t* src_a3 = src_a2 + stride_a;
|
||||
const uint8_t* src_b1 = src_b + stride_b;
|
||||
const uint8_t* src_b2 = src_b1 + stride_b;
|
||||
const uint8_t* src_b3 = src_b2 + stride_b;
|
||||
const v128_t mask = wasm_i16x8_splat(0x00ff);
|
||||
for (; width > 0; width -= 16) {
|
||||
v128_t a0 = wasm_v128_load(src_a);
|
||||
v128_t a1 = wasm_v128_load(src_a1);
|
||||
v128_t a2 = wasm_v128_load(src_a2);
|
||||
v128_t a3 = wasm_v128_load(src_a3);
|
||||
v128_t b0 = wasm_v128_load(src_b);
|
||||
v128_t b1 = wasm_v128_load(src_b1);
|
||||
v128_t b2 = wasm_v128_load(src_b2);
|
||||
v128_t b3 = wasm_v128_load(src_b3);
|
||||
|
||||
v128_t a0_ev = wasm_v128_and(a0, mask);
|
||||
v128_t a0_od = wasm_u16x8_shr(a0, 8);
|
||||
v128_t a1_ev = wasm_v128_and(a1, mask);
|
||||
v128_t a1_od = wasm_u16x8_shr(a1, 8);
|
||||
v128_t a2_ev = wasm_v128_and(a2, mask);
|
||||
v128_t a2_od = wasm_u16x8_shr(a2, 8);
|
||||
v128_t a3_ev = wasm_v128_and(a3, mask);
|
||||
v128_t a3_od = wasm_u16x8_shr(a3, 8);
|
||||
|
||||
v128_t b0_ev = wasm_v128_and(b0, mask);
|
||||
v128_t b0_od = wasm_u16x8_shr(b0, 8);
|
||||
v128_t b1_ev = wasm_v128_and(b1, mask);
|
||||
v128_t b1_od = wasm_u16x8_shr(b1, 8);
|
||||
v128_t b2_ev = wasm_v128_and(b2, mask);
|
||||
v128_t b2_od = wasm_u16x8_shr(b2, 8);
|
||||
v128_t b3_ev = wasm_v128_and(b3, mask);
|
||||
v128_t b3_od = wasm_u16x8_shr(b3, 8);
|
||||
|
||||
v128_t sum_a_16 =
|
||||
wasm_i16x8_add(wasm_i16x8_add(wasm_i16x8_add(a0_ev, a0_od),
|
||||
wasm_i16x8_add(a1_ev, a1_od)),
|
||||
wasm_i16x8_add(wasm_i16x8_add(a2_ev, a2_od),
|
||||
wasm_i16x8_add(a3_ev, a3_od)));
|
||||
v128_t sum_b_16 =
|
||||
wasm_i16x8_add(wasm_i16x8_add(wasm_i16x8_add(b0_ev, b0_od),
|
||||
wasm_i16x8_add(b1_ev, b1_od)),
|
||||
wasm_i16x8_add(wasm_i16x8_add(b2_ev, b2_od),
|
||||
wasm_i16x8_add(b3_ev, b3_od)));
|
||||
|
||||
v128_t sum_a = wasm_u32x4_extadd_pairwise_u16x8(sum_a_16);
|
||||
v128_t sum_b = wasm_u32x4_extadd_pairwise_u16x8(sum_b_16);
|
||||
|
||||
v128_t sum_axb = wasm_i32x4_add(
|
||||
wasm_i32x4_add(wasm_i32x4_add(wasm_i32x4_dot_i16x8(a0_ev, b0_ev),
|
||||
wasm_i32x4_dot_i16x8(a0_od, b0_od)),
|
||||
wasm_i32x4_add(wasm_i32x4_dot_i16x8(a1_ev, b1_ev),
|
||||
wasm_i32x4_dot_i16x8(a1_od, b1_od))),
|
||||
wasm_i32x4_add(wasm_i32x4_add(wasm_i32x4_dot_i16x8(a2_ev, b2_ev),
|
||||
wasm_i32x4_dot_i16x8(a2_od, b2_od)),
|
||||
wasm_i32x4_add(wasm_i32x4_dot_i16x8(a3_ev, b3_ev),
|
||||
wasm_i32x4_dot_i16x8(a3_od, b3_od))));
|
||||
|
||||
v128_t sq0 =
|
||||
wasm_i32x4_add(wasm_i32x4_add(wasm_i32x4_dot_i16x8(a0_ev, a0_ev),
|
||||
wasm_i32x4_dot_i16x8(a0_od, a0_od)),
|
||||
wasm_i32x4_add(wasm_i32x4_dot_i16x8(b0_ev, b0_ev),
|
||||
wasm_i32x4_dot_i16x8(b0_od, b0_od)));
|
||||
v128_t sq1 =
|
||||
wasm_i32x4_add(wasm_i32x4_add(wasm_i32x4_dot_i16x8(a1_ev, a1_ev),
|
||||
wasm_i32x4_dot_i16x8(a1_od, a1_od)),
|
||||
wasm_i32x4_add(wasm_i32x4_dot_i16x8(b1_ev, b1_ev),
|
||||
wasm_i32x4_dot_i16x8(b1_od, b1_od)));
|
||||
v128_t sq2 =
|
||||
wasm_i32x4_add(wasm_i32x4_add(wasm_i32x4_dot_i16x8(a2_ev, a2_ev),
|
||||
wasm_i32x4_dot_i16x8(a2_od, a2_od)),
|
||||
wasm_i32x4_add(wasm_i32x4_dot_i16x8(b2_ev, b2_ev),
|
||||
wasm_i32x4_dot_i16x8(b2_od, b2_od)));
|
||||
v128_t sq3 =
|
||||
wasm_i32x4_add(wasm_i32x4_add(wasm_i32x4_dot_i16x8(a3_ev, a3_ev),
|
||||
wasm_i32x4_dot_i16x8(a3_od, a3_od)),
|
||||
wasm_i32x4_add(wasm_i32x4_dot_i16x8(b3_ev, b3_ev),
|
||||
wasm_i32x4_dot_i16x8(b3_od, b3_od)));
|
||||
v128_t sum_sq_ab =
|
||||
wasm_i32x4_add(wasm_i32x4_add(sq0, sq1), wasm_i32x4_add(sq2, sq3));
|
||||
|
||||
v128_t t0 = wasm_i32x4_shuffle(sum_a, sum_b, 0, 4, 1, 5);
|
||||
v128_t t1 = wasm_i32x4_shuffle(sum_a, sum_b, 2, 6, 3, 7);
|
||||
v128_t t2 = wasm_i32x4_shuffle(sum_sq_ab, sum_axb, 0, 4, 1, 5);
|
||||
v128_t t3 = wasm_i32x4_shuffle(sum_sq_ab, sum_axb, 2, 6, 3, 7);
|
||||
|
||||
wasm_v128_store(dst, wasm_i64x2_shuffle(t0, t2, 0, 2));
|
||||
wasm_v128_store(dst + 4, wasm_i64x2_shuffle(t0, t2, 1, 3));
|
||||
wasm_v128_store(dst + 8, wasm_i64x2_shuffle(t1, t3, 0, 2));
|
||||
wasm_v128_store(dst + 12, wasm_i64x2_shuffle(t1, t3, 1, 3));
|
||||
|
||||
src_a += 16;
|
||||
src_a1 += 16;
|
||||
src_a2 += 16;
|
||||
src_a3 += 16;
|
||||
src_b += 16;
|
||||
src_b1 += 16;
|
||||
src_b2 += 16;
|
||||
src_b3 += 16;
|
||||
dst += 16;
|
||||
}
|
||||
}
|
||||
#endif // HAS_SSIM4X4ROW_WASMSIMD
|
||||
|
||||
#if defined(HAS_SSIMWINDOWROW_WASMSIMD)
|
||||
float SsimWindowRow_WASMSIMD(const uint32_t* row0,
|
||||
const uint32_t* row1,
|
||||
int num_windows) {
|
||||
const v128_t vc1 = wasm_i32x4_splat(26634);
|
||||
const v128_t vc2 = wasm_i32x4_splat(239708);
|
||||
v128_t total = wasm_f32x4_splat(0.0f);
|
||||
v128_t t0 = wasm_i32x4_add(wasm_v128_load(row0), wasm_v128_load(row1));
|
||||
int w;
|
||||
for (w = 0; w < num_windows; w += 4) {
|
||||
v128_t t1 =
|
||||
wasm_i32x4_add(wasm_v128_load(row0 + 4), wasm_v128_load(row1 + 4));
|
||||
v128_t t2 =
|
||||
wasm_i32x4_add(wasm_v128_load(row0 + 8), wasm_v128_load(row1 + 8));
|
||||
v128_t t3 =
|
||||
wasm_i32x4_add(wasm_v128_load(row0 + 12), wasm_v128_load(row1 + 12));
|
||||
v128_t t4 =
|
||||
wasm_i32x4_add(wasm_v128_load(row0 + 16), wasm_v128_load(row1 + 16));
|
||||
row0 += 16;
|
||||
row1 += 16;
|
||||
v128_t w0 = wasm_i32x4_add(t0, t1);
|
||||
v128_t w1 = wasm_i32x4_add(t1, t2);
|
||||
v128_t w2 = wasm_i32x4_add(t2, t3);
|
||||
v128_t w3 = wasm_i32x4_add(t3, t4);
|
||||
t0 = t4;
|
||||
|
||||
v128_t u0 = wasm_i32x4_shuffle(w0, w1, 0, 4, 1, 5);
|
||||
v128_t u1 = wasm_i32x4_shuffle(w0, w1, 2, 6, 3, 7);
|
||||
v128_t u2 = wasm_i32x4_shuffle(w2, w3, 0, 4, 1, 5);
|
||||
v128_t u3 = wasm_i32x4_shuffle(w2, w3, 2, 6, 3, 7);
|
||||
v128_t sum_a = wasm_i64x2_shuffle(u0, u2, 0, 2);
|
||||
v128_t sum_b = wasm_i64x2_shuffle(u0, u2, 1, 3);
|
||||
v128_t sum_sq = wasm_i64x2_shuffle(u1, u3, 0, 2);
|
||||
v128_t sum_axb = wasm_i64x2_shuffle(u1, u3, 1, 3);
|
||||
|
||||
v128_t ab2 = wasm_i32x4_shl(wasm_i32x4_dot_i16x8(sum_a, sum_b), 1);
|
||||
v128_t a2b2 = wasm_i32x4_add(wasm_i32x4_dot_i16x8(sum_a, sum_a),
|
||||
wasm_i32x4_dot_i16x8(sum_b, sum_b));
|
||||
v128_t n1 = wasm_i32x4_add(ab2, vc1);
|
||||
v128_t n2 =
|
||||
wasm_i32x4_add(wasm_i32x4_sub(wasm_i32x4_shl(sum_axb, 7), ab2), vc2);
|
||||
v128_t d1 = wasm_i32x4_add(a2b2, vc1);
|
||||
v128_t d2 =
|
||||
wasm_i32x4_add(wasm_i32x4_sub(wasm_i32x4_shl(sum_sq, 6), a2b2), vc2);
|
||||
|
||||
v128_t num = wasm_f32x4_mul(wasm_f32x4_convert_i32x4(n1),
|
||||
wasm_f32x4_convert_i32x4(n2));
|
||||
v128_t den = wasm_f32x4_mul(wasm_f32x4_convert_i32x4(d1),
|
||||
wasm_f32x4_convert_i32x4(d2));
|
||||
total = wasm_f32x4_add(total, wasm_f32x4_div(num, den));
|
||||
}
|
||||
total = wasm_f32x4_add(total, wasm_i64x2_shuffle(total, total, 1, 0));
|
||||
total = wasm_f32x4_add(total, wasm_i32x4_shuffle(total, total, 1, 0, 3, 2));
|
||||
return wasm_f32x4_extract_lane(total, 0);
|
||||
}
|
||||
#endif // HAS_SSIMWINDOWROW_WASMSIMD
|
||||
|
||||
#if defined(HAS_ARGBDETECTROW_WASMSIMD)
|
||||
uint32_t ARGBDetectRow_WASMSIMD(const uint8_t* argb, int width) {
|
||||
const v128_t mask_rgb = wasm_i32x4_splat(0x00ffff00);
|
||||
const v128_t ones = wasm_i8x16_splat(-1);
|
||||
while (width >= 4) {
|
||||
v128_t v = wasm_v128_or(wasm_v128_load(argb), mask_rgb);
|
||||
uint32_t diff =
|
||||
(~(uint32_t)wasm_i8x16_bitmask(wasm_i8x16_eq(v, ones))) & 0xffffu;
|
||||
if (diff) {
|
||||
return (__builtin_ctz(diff) & 3) == 0 ? FOURCC_BGRA : FOURCC_ARGB;
|
||||
}
|
||||
argb += 16;
|
||||
width -= 4;
|
||||
}
|
||||
while (width > 0) {
|
||||
v128_t v = wasm_v128_or(wasm_v128_load32_zero(argb), mask_rgb);
|
||||
uint32_t diff =
|
||||
(~(uint32_t)wasm_i8x16_bitmask(wasm_i8x16_eq(v, ones))) & 0x9u;
|
||||
if (diff) {
|
||||
return (diff & 1u) ? FOURCC_BGRA : FOURCC_ARGB;
|
||||
}
|
||||
argb += 4;
|
||||
width -= 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif // HAS_ARGBDETECTROW_WASMSIMD
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
#endif
|
||||
|
||||
#endif // !defined(LIBYUV_DISABLE_WASM) && defined(__wasm_simd128__)
|
||||
+979
-192
File diff suppressed because it is too large.
Load diff
+4139
-1498
File diff suppressed because it is too large.
Load diff
+8374
-531
File diff suppressed because it is too large.
Load diff
+615
-833
File diff suppressed because it is too large.
Load diff
+3930
-1237
File diff suppressed because it is too large.
Load diff
@@ -94,7 +94,7 @@ int MJPGSize(const uint8_t* src_mjpg,
|
||||
int* width,
|
||||
int* height) {
|
||||
MJpegDecoder mjpeg_decoder;
|
||||
LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg);
|
||||
bool ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg);
|
||||
if (ret) {
|
||||
*width = mjpeg_decoder.GetWidth();
|
||||
*height = mjpeg_decoder.GetHeight();
|
||||
@@ -126,7 +126,7 @@ int MJPGToI420(const uint8_t* src_mjpg,
|
||||
|
||||
// TODO(fbarchard): Port MJpeg to C.
|
||||
MJpegDecoder mjpeg_decoder;
|
||||
LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg);
|
||||
bool ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg);
|
||||
if (ret && (mjpeg_decoder.GetWidth() != src_width ||
|
||||
mjpeg_decoder.GetHeight() != src_height)) {
|
||||
// ERROR: MJPEG frame has unexpected dimensions
|
||||
@@ -266,7 +266,7 @@ int MJPGToNV21(const uint8_t* src_mjpg,
|
||||
|
||||
// TODO(fbarchard): Port MJpeg to C.
|
||||
MJpegDecoder mjpeg_decoder;
|
||||
LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg);
|
||||
bool ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg);
|
||||
if (ret && (mjpeg_decoder.GetWidth() != src_width ||
|
||||
mjpeg_decoder.GetHeight() != src_height)) {
|
||||
// ERROR: MJPEG frame has unexpected dimensions
|
||||
@@ -328,6 +328,140 @@ int MJPGToNV21(const uint8_t* src_mjpg,
|
||||
return ret ? 0 : 1;
|
||||
}
|
||||
|
||||
static void JpegI420ToNV12(void* opaque,
|
||||
const uint8_t* const* data,
|
||||
const int* strides,
|
||||
int rows) {
|
||||
NV21Buffers* dest = (NV21Buffers*)(opaque);
|
||||
// Use NV21 with VU swapped.
|
||||
I420ToNV21(data[0], strides[0], data[2], strides[2], data[1], strides[1],
|
||||
dest->y, dest->y_stride, dest->vu, dest->vu_stride, dest->w, rows);
|
||||
dest->y += rows * dest->y_stride;
|
||||
dest->vu += ((rows + 1) >> 1) * dest->vu_stride;
|
||||
dest->h -= rows;
|
||||
}
|
||||
|
||||
static void JpegI422ToNV12(void* opaque,
|
||||
const uint8_t* const* data,
|
||||
const int* strides,
|
||||
int rows) {
|
||||
NV21Buffers* dest = (NV21Buffers*)(opaque);
|
||||
// Use NV21 with VU swapped.
|
||||
I422ToNV21(data[0], strides[0], data[2], strides[2], data[1], strides[1],
|
||||
dest->y, dest->y_stride, dest->vu, dest->vu_stride, dest->w, rows);
|
||||
dest->y += rows * dest->y_stride;
|
||||
dest->vu += ((rows + 1) >> 1) * dest->vu_stride;
|
||||
dest->h -= rows;
|
||||
}
|
||||
|
||||
static void JpegI444ToNV12(void* opaque,
|
||||
const uint8_t* const* data,
|
||||
const int* strides,
|
||||
int rows) {
|
||||
NV21Buffers* dest = (NV21Buffers*)(opaque);
|
||||
// Use NV21 with VU swapped.
|
||||
I444ToNV21(data[0], strides[0], data[2], strides[2], data[1], strides[1],
|
||||
dest->y, dest->y_stride, dest->vu, dest->vu_stride, dest->w, rows);
|
||||
dest->y += rows * dest->y_stride;
|
||||
dest->vu += ((rows + 1) >> 1) * dest->vu_stride;
|
||||
dest->h -= rows;
|
||||
}
|
||||
|
||||
static void JpegI400ToNV12(void* opaque,
|
||||
const uint8_t* const* data,
|
||||
const int* strides,
|
||||
int rows) {
|
||||
NV21Buffers* dest = (NV21Buffers*)(opaque);
|
||||
// Use NV21 since there is no UV plane.
|
||||
I400ToNV21(data[0], strides[0], dest->y, dest->y_stride, dest->vu,
|
||||
dest->vu_stride, dest->w, rows);
|
||||
dest->y += rows * dest->y_stride;
|
||||
dest->vu += ((rows + 1) >> 1) * dest->vu_stride;
|
||||
dest->h -= rows;
|
||||
}
|
||||
|
||||
// MJPG (Motion JPEG) to NV12.
|
||||
LIBYUV_API
|
||||
int MJPGToNV12(const uint8_t* sample,
|
||||
size_t sample_size,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_uv,
|
||||
int dst_stride_uv,
|
||||
int src_width,
|
||||
int src_height,
|
||||
int dst_width,
|
||||
int dst_height) {
|
||||
if (sample_size == kUnknownDataSize) {
|
||||
// ERROR: MJPEG frame size unknown
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TODO(fbarchard): Port MJpeg to C.
|
||||
MJpegDecoder mjpeg_decoder;
|
||||
bool ret = mjpeg_decoder.LoadFrame(sample, sample_size);
|
||||
if (ret && (mjpeg_decoder.GetWidth() != src_width ||
|
||||
mjpeg_decoder.GetHeight() != src_height)) {
|
||||
// ERROR: MJPEG frame has unexpected dimensions
|
||||
mjpeg_decoder.UnloadFrame();
|
||||
return 1; // runtime failure
|
||||
}
|
||||
if (ret) {
|
||||
// Use NV21Buffers but with UV instead of VU.
|
||||
NV21Buffers bufs = {dst_y, dst_stride_y, dst_uv,
|
||||
dst_stride_uv, dst_width, dst_height};
|
||||
// YUV420
|
||||
if (mjpeg_decoder.GetColorSpace() == MJpegDecoder::kColorSpaceYCbCr &&
|
||||
mjpeg_decoder.GetNumComponents() == 3 &&
|
||||
mjpeg_decoder.GetVertSampFactor(0) == 2 &&
|
||||
mjpeg_decoder.GetHorizSampFactor(0) == 2 &&
|
||||
mjpeg_decoder.GetVertSampFactor(1) == 1 &&
|
||||
mjpeg_decoder.GetHorizSampFactor(1) == 1 &&
|
||||
mjpeg_decoder.GetVertSampFactor(2) == 1 &&
|
||||
mjpeg_decoder.GetHorizSampFactor(2) == 1) {
|
||||
ret = mjpeg_decoder.DecodeToCallback(&JpegI420ToNV12, &bufs, dst_width,
|
||||
dst_height);
|
||||
// YUV422
|
||||
} else if (mjpeg_decoder.GetColorSpace() ==
|
||||
MJpegDecoder::kColorSpaceYCbCr &&
|
||||
mjpeg_decoder.GetNumComponents() == 3 &&
|
||||
mjpeg_decoder.GetVertSampFactor(0) == 1 &&
|
||||
mjpeg_decoder.GetHorizSampFactor(0) == 2 &&
|
||||
mjpeg_decoder.GetVertSampFactor(1) == 1 &&
|
||||
mjpeg_decoder.GetHorizSampFactor(1) == 1 &&
|
||||
mjpeg_decoder.GetVertSampFactor(2) == 1 &&
|
||||
mjpeg_decoder.GetHorizSampFactor(2) == 1) {
|
||||
ret = mjpeg_decoder.DecodeToCallback(&JpegI422ToNV12, &bufs, dst_width,
|
||||
dst_height);
|
||||
// YUV444
|
||||
} else if (mjpeg_decoder.GetColorSpace() ==
|
||||
MJpegDecoder::kColorSpaceYCbCr &&
|
||||
mjpeg_decoder.GetNumComponents() == 3 &&
|
||||
mjpeg_decoder.GetVertSampFactor(0) == 1 &&
|
||||
mjpeg_decoder.GetHorizSampFactor(0) == 1 &&
|
||||
mjpeg_decoder.GetVertSampFactor(1) == 1 &&
|
||||
mjpeg_decoder.GetHorizSampFactor(1) == 1 &&
|
||||
mjpeg_decoder.GetVertSampFactor(2) == 1 &&
|
||||
mjpeg_decoder.GetHorizSampFactor(2) == 1) {
|
||||
ret = mjpeg_decoder.DecodeToCallback(&JpegI444ToNV12, &bufs, dst_width,
|
||||
dst_height);
|
||||
// YUV400
|
||||
} else if (mjpeg_decoder.GetColorSpace() ==
|
||||
MJpegDecoder::kColorSpaceGrayscale &&
|
||||
mjpeg_decoder.GetNumComponents() == 1 &&
|
||||
mjpeg_decoder.GetVertSampFactor(0) == 1 &&
|
||||
mjpeg_decoder.GetHorizSampFactor(0) == 1) {
|
||||
ret = mjpeg_decoder.DecodeToCallback(&JpegI400ToNV12, &bufs, dst_width,
|
||||
dst_height);
|
||||
} else {
|
||||
// Unknown colorspace.
|
||||
mjpeg_decoder.UnloadFrame();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return ret ? 0 : 1;
|
||||
}
|
||||
|
||||
struct ARGBBuffers {
|
||||
uint8_t* argb;
|
||||
int argb_stride;
|
||||
@@ -397,7 +531,7 @@ int MJPGToARGB(const uint8_t* src_mjpg,
|
||||
|
||||
// TODO(fbarchard): Port MJpeg to C.
|
||||
MJpegDecoder mjpeg_decoder;
|
||||
LIBYUV_BOOL ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg);
|
||||
bool ret = mjpeg_decoder.LoadFrame(src_mjpg, src_size_mjpg);
|
||||
if (ret && (mjpeg_decoder.GetWidth() != src_width ||
|
||||
mjpeg_decoder.GetHeight() != src_height)) {
|
||||
// ERROR: MJPEG frame has unexpected dimensions
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
#include "libyuv/convert_argb.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libyuv/cpu_id.h"
|
||||
#ifdef HAVE_JPEG
|
||||
#include "libyuv/mjpeg_decoder.h"
|
||||
@@ -23,6 +28,280 @@ namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static int NV16ToARGB(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_argb,
|
||||
int dst_stride_argb,
|
||||
int width,
|
||||
int height) {
|
||||
int y;
|
||||
void (*NV12ToARGBRow)(
|
||||
const uint8_t* y_buf, const uint8_t* uv_buf, uint8_t* rgb_buf,
|
||||
const struct YuvConstants* yuvconstants, int width) = NV12ToARGBRow_C;
|
||||
if (!src_y || !src_uv || !dst_argb || width <= 0 || height == 0 ||
|
||||
height == INT_MIN) {
|
||||
return -1;
|
||||
}
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
dst_argb = dst_argb + (ptrdiff_t)(height - 1) * dst_stride_argb;
|
||||
dst_stride_argb = -dst_stride_argb;
|
||||
}
|
||||
#if defined(HAS_NV12TOARGBROW_SSSE3)
|
||||
if (TestCpuFlag(kCpuHasSSSE3)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_Any_SSSE3;
|
||||
if (IS_ALIGNED(width, 8)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_SSSE3;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_Any_AVX2;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_AVX512BW;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_Any_NEON;
|
||||
if (IS_ALIGNED(width, 8)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_NEON;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_SVE2)
|
||||
if (TestCpuFlag(kCpuHasSVE2)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_SVE2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_SME)
|
||||
if (TestCpuFlag(kCpuHasSME)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_SME;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_Any_LSX;
|
||||
if (IS_ALIGNED(width, 8)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_LSX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_Any_LASX;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_LASX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_RVV;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_HVX)
|
||||
if (TestCpuFlag(kCpuHasHVX)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_HVX;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_NV12TOARGBROW_WASMSIMD)
|
||||
if (TestCpuFlag(kCpuHasWASMSIMD)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_Any_WASMSIMD;
|
||||
if (IS_ALIGNED(width, 8)) {
|
||||
NV12ToARGBRow = NV12ToARGBRow_WASMSIMD;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (y = 0; y < height; ++y) {
|
||||
NV12ToARGBRow(src_y, src_uv, dst_argb, &kYuvI601Constants, width);
|
||||
dst_argb += dst_stride_argb;
|
||||
src_y += src_stride_y;
|
||||
src_uv += src_stride_uv;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int NV24ToARGB(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_argb,
|
||||
int dst_stride_argb,
|
||||
int width,
|
||||
int height) {
|
||||
int y;
|
||||
void (*I444ToARGBRow)(const uint8_t* y_buf, const uint8_t* u_buf,
|
||||
const uint8_t* v_buf, uint8_t* rgb_buf,
|
||||
const struct YuvConstants* yuvconstants, int width) =
|
||||
I444ToARGBRow_C;
|
||||
void (*SplitUVRow)(const uint8_t* src_uv, uint8_t* dst_u, uint8_t* dst_v,
|
||||
int width) = SplitUVRow_C;
|
||||
if (!src_y || !src_uv || !dst_argb || width <= 0 || height == 0 ||
|
||||
height == INT_MIN) {
|
||||
return -1;
|
||||
}
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
dst_argb = dst_argb + (ptrdiff_t)(height - 1) * dst_stride_argb;
|
||||
dst_stride_argb = -dst_stride_argb;
|
||||
}
|
||||
#if defined(HAS_I444TOARGBROW_SSSE3)
|
||||
if (TestCpuFlag(kCpuHasSSSE3)) {
|
||||
I444ToARGBRow = I444ToARGBRow_Any_SSSE3;
|
||||
if (IS_ALIGNED(width, 8)) {
|
||||
I444ToARGBRow = I444ToARGBRow_SSSE3;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_I444TOARGBROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
I444ToARGBRow = I444ToARGBRow_Any_AVX2;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
I444ToARGBRow = I444ToARGBRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_I444TOARGBROW_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
I444ToARGBRow = I444ToARGBRow_AVX512BW;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_I444TOARGBROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
I444ToARGBRow = I444ToARGBRow_Any_NEON;
|
||||
if (IS_ALIGNED(width, 8)) {
|
||||
I444ToARGBRow = I444ToARGBRow_NEON;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_I444TOARGBROW_SVE2)
|
||||
if (TestCpuFlag(kCpuHasSVE2)) {
|
||||
I444ToARGBRow = I444ToARGBRow_SVE2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_I444TOARGBROW_SME)
|
||||
if (TestCpuFlag(kCpuHasSME)) {
|
||||
I444ToARGBRow = I444ToARGBRow_SME;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_I444TOARGBROW_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
I444ToARGBRow = I444ToARGBRow_Any_LSX;
|
||||
if (IS_ALIGNED(width, 8)) {
|
||||
I444ToARGBRow = I444ToARGBRow_LSX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_I444TOARGBROW_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
I444ToARGBRow = I444ToARGBRow_Any_LASX;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
I444ToARGBRow = I444ToARGBRow_LASX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_I444TOARGBROW_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
I444ToARGBRow = I444ToARGBRow_RVV;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_I444TOARGBROW_HVX)
|
||||
if (TestCpuFlag(kCpuHasHVX)) {
|
||||
I444ToARGBRow = I444ToARGBRow_HVX;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAS_SPLITUVROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
SplitUVRow = SplitUVRow_Any_SSE2;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
SplitUVRow = SplitUVRow_SSE2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
SplitUVRow = SplitUVRow_Any_AVX2;
|
||||
if (IS_ALIGNED(width, 32)) {
|
||||
SplitUVRow = SplitUVRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
SplitUVRow = SplitUVRow_AVX512BW;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
SplitUVRow = SplitUVRow_Any_NEON;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
SplitUVRow = SplitUVRow_NEON;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_SVE2)
|
||||
if (TestCpuFlag(kCpuHasSVE2)) {
|
||||
SplitUVRow = SplitUVRow_SVE2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
SplitUVRow = SplitUVRow_Any_LSX;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
SplitUVRow = SplitUVRow_LSX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
SplitUVRow = SplitUVRow_Any_LASX;
|
||||
if (IS_ALIGNED(width, 32)) {
|
||||
SplitUVRow = SplitUVRow_LASX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
SplitUVRow = SplitUVRow_RVV;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_HVX)
|
||||
if (TestCpuFlag(kCpuHasHVX)) {
|
||||
SplitUVRow = SplitUVRow_HVX;
|
||||
}
|
||||
#endif
|
||||
|
||||
align_buffer_64(row_u, width);
|
||||
align_buffer_64(row_v, width);
|
||||
if (!row_u || !row_v) {
|
||||
free_aligned_buffer_64(row_u);
|
||||
free_aligned_buffer_64(row_v);
|
||||
return 1;
|
||||
}
|
||||
for (y = 0; y < height; ++y) {
|
||||
SplitUVRow(src_uv, row_u, row_v, width);
|
||||
I444ToARGBRow(src_y, row_u, row_v, dst_argb, &kYuvI601Constants, width);
|
||||
dst_argb += dst_stride_argb;
|
||||
src_y += src_stride_y;
|
||||
src_uv += src_stride_uv;
|
||||
}
|
||||
free_aligned_buffer_64(row_u);
|
||||
free_aligned_buffer_64(row_v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Convert camera sample to ARGB with cropping, rotation and vertical flip.
|
||||
// src_width is used for source stride computation
|
||||
// src_height is used to compute location of planes, and indicate inversion
|
||||
@@ -32,9 +311,6 @@ extern "C" {
|
||||
// TODO(fbarchard): Add the following:
|
||||
// H010ToARGB
|
||||
// I010ToARGB
|
||||
// J400ToARGB
|
||||
// J422ToARGB
|
||||
// J444ToARGB
|
||||
|
||||
LIBYUV_API
|
||||
int ConvertToARGB(const uint8_t* sample,
|
||||
@@ -49,12 +325,26 @@ int ConvertToARGB(const uint8_t* sample,
|
||||
int crop_height,
|
||||
enum RotationMode rotation,
|
||||
uint32_t fourcc) {
|
||||
if (src_height == INT_MIN || crop_height == INT_MIN) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int abs_src_height = (src_height < 0) ? -src_height : src_height;
|
||||
int abs_crop_height = (crop_height < 0) ? -crop_height : crop_height;
|
||||
|
||||
if (dst_argb == NULL || sample == NULL || src_width <= 0 ||
|
||||
src_width > INT_MAX / 4 || crop_width <= 0 || crop_width > INT_MAX / 4 ||
|
||||
src_height == 0 || crop_height == 0 || crop_x < 0 || crop_y < 0 ||
|
||||
crop_width > src_width || crop_x > src_width - crop_width ||
|
||||
abs_crop_height > abs_src_height ||
|
||||
crop_y > abs_src_height - abs_crop_height) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t format = CanonicalFourCC(fourcc);
|
||||
int aligned_src_width = (src_width + 1) & ~1;
|
||||
const uint8_t* src;
|
||||
const uint8_t* src_uv;
|
||||
int abs_src_height = (src_height < 0) ? -src_height : src_height;
|
||||
int inv_crop_height = (crop_height < 0) ? -crop_height : crop_height;
|
||||
int r = 0;
|
||||
|
||||
// One pass rotation is available for some formats. For the rest, convert
|
||||
@@ -62,24 +352,25 @@ int ConvertToARGB(const uint8_t* sample,
|
||||
// and then rotate the ARGB to the final destination buffer.
|
||||
// For in-place conversion, if destination dst_argb is same as source sample,
|
||||
// also enable temporary buffer.
|
||||
LIBYUV_BOOL need_buf =
|
||||
(rotation && format != FOURCC_ARGB) || dst_argb == sample;
|
||||
int need_buf = (rotation && format != FOURCC_ARGB) || dst_argb == sample;
|
||||
uint8_t* dest_argb = dst_argb;
|
||||
int dest_dst_stride_argb = dst_stride_argb;
|
||||
uint8_t* rotate_buffer = NULL;
|
||||
int abs_crop_height = (crop_height < 0) ? -crop_height : crop_height;
|
||||
int inv_crop_height = (crop_height < 0) ? -crop_height : crop_height;
|
||||
|
||||
if (dst_argb == NULL || sample == NULL || src_width <= 0 || crop_width <= 0 ||
|
||||
src_height == 0 || crop_height == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (src_height < 0) {
|
||||
inv_crop_height = -inv_crop_height;
|
||||
}
|
||||
|
||||
if (need_buf) {
|
||||
int argb_size = crop_width * 4 * abs_crop_height;
|
||||
rotate_buffer = (uint8_t*)malloc(argb_size); /* NOLINT */
|
||||
const uint64_t rotate_buffer_size =
|
||||
(uint64_t)crop_width * 4 * abs_crop_height;
|
||||
#if UINT64_MAX > SIZE_MAX
|
||||
if (rotate_buffer_size > SIZE_MAX) {
|
||||
return -1; // Invalid size.
|
||||
}
|
||||
#endif
|
||||
rotate_buffer = (uint8_t*)malloc((size_t)rotate_buffer_size);
|
||||
if (!rotate_buffer) {
|
||||
return 1; // Out of memory runtime error.
|
||||
}
|
||||
@@ -90,200 +381,337 @@ int ConvertToARGB(const uint8_t* sample,
|
||||
switch (format) {
|
||||
// Single plane formats
|
||||
case FOURCC_YUY2:
|
||||
src = sample + (aligned_src_width * crop_y + crop_x) * 2;
|
||||
src = sample + ((ptrdiff_t)aligned_src_width * crop_y + crop_x) * 2;
|
||||
r = YUY2ToARGB(src, aligned_src_width * 2, dst_argb, dst_stride_argb,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_UYVY:
|
||||
src = sample + (aligned_src_width * crop_y + crop_x) * 2;
|
||||
src = sample + ((ptrdiff_t)aligned_src_width * crop_y + crop_x) * 2;
|
||||
r = UYVYToARGB(src, aligned_src_width * 2, dst_argb, dst_stride_argb,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_24BG:
|
||||
src = sample + (src_width * crop_y + crop_x) * 3;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 3;
|
||||
r = RGB24ToARGB(src, src_width * 3, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_RAW:
|
||||
src = sample + (src_width * crop_y + crop_x) * 3;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 3;
|
||||
r = RAWToARGB(src, src_width * 3, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_ARGB:
|
||||
if (!need_buf && !rotation) {
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = ARGBToARGB(src, src_width * 4, dst_argb, dst_stride_argb,
|
||||
crop_width, inv_crop_height);
|
||||
}
|
||||
break;
|
||||
case FOURCC_BGRA:
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = BGRAToARGB(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_ABGR:
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = ABGRToARGB(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_RGBA:
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = RGBAToARGB(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_AR30:
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = AR30ToARGB(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_AB30:
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = AB30ToARGB(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_RGBP:
|
||||
src = sample + (src_width * crop_y + crop_x) * 2;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 2;
|
||||
r = RGB565ToARGB(src, src_width * 2, dst_argb, dst_stride_argb,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_RGBO:
|
||||
src = sample + (src_width * crop_y + crop_x) * 2;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 2;
|
||||
r = ARGB1555ToARGB(src, src_width * 2, dst_argb, dst_stride_argb,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_R444:
|
||||
src = sample + (src_width * crop_y + crop_x) * 2;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 2;
|
||||
r = ARGB4444ToARGB(src, src_width * 2, dst_argb, dst_stride_argb,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_I400:
|
||||
src = sample + src_width * crop_y + crop_x;
|
||||
src = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
r = I400ToARGB(src, src_width, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_J400:
|
||||
src = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
r = J400ToARGB(src, src_width, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
|
||||
// Biplanar formats
|
||||
case FOURCC_NV12:
|
||||
src = sample + (src_width * crop_y + crop_x);
|
||||
src_uv =
|
||||
sample + aligned_src_width * (abs_src_height + crop_y / 2) + crop_x;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
src_uv = sample +
|
||||
aligned_src_width * ((ptrdiff_t)abs_src_height + crop_y / 2) +
|
||||
(crop_x & ~1);
|
||||
r = NV12ToARGB(src, src_width, src_uv, aligned_src_width, dst_argb,
|
||||
dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_NV21:
|
||||
src = sample + (src_width * crop_y + crop_x);
|
||||
src_uv =
|
||||
sample + aligned_src_width * (abs_src_height + crop_y / 2) + crop_x;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
src_uv = sample +
|
||||
aligned_src_width * ((ptrdiff_t)abs_src_height + crop_y / 2) +
|
||||
(crop_x & ~1);
|
||||
// Call NV12 but with u and v parameters swapped.
|
||||
r = NV21ToARGB(src, src_width, src_uv, aligned_src_width, dst_argb,
|
||||
dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_M420:
|
||||
src = sample + (src_width * crop_y) * 12 / 8 + crop_x;
|
||||
r = M420ToARGB(src, src_width, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height);
|
||||
case FOURCC_NV16:
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
src_uv = sample +
|
||||
aligned_src_width * ((ptrdiff_t)abs_src_height + crop_y) +
|
||||
(crop_x & ~1);
|
||||
r = NV16ToARGB(src, src_width, src_uv, aligned_src_width, dst_argb,
|
||||
dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
|
||||
case FOURCC_NV24:
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
src_uv = sample + (ptrdiff_t)aligned_src_width * abs_src_height +
|
||||
(ptrdiff_t)aligned_src_width * 2 * crop_y +
|
||||
(ptrdiff_t)crop_x * 2;
|
||||
r = NV24ToARGB(src, src_width, src_uv, aligned_src_width * 2, dst_argb,
|
||||
dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_P010: {
|
||||
const uint16_t* src16 = (const uint16_t*)sample;
|
||||
const uint16_t* src_y16 =
|
||||
src16 + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint16_t* src_uv16 =
|
||||
src16 + ((ptrdiff_t)src_width * abs_src_height) +
|
||||
((ptrdiff_t)(crop_y / 2) * aligned_src_width) + ((crop_x / 2) * 2);
|
||||
r = P010ToARGBMatrix(src_y16, src_width, src_uv16, aligned_src_width,
|
||||
dst_argb, dst_stride_argb, &kYuvI601Constants,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
case FOURCC_P210: {
|
||||
const uint16_t* src16 = (const uint16_t*)sample;
|
||||
const uint16_t* src_y16 =
|
||||
src16 + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint16_t* src_uv16 =
|
||||
src16 + ((ptrdiff_t)src_width * abs_src_height) +
|
||||
((ptrdiff_t)crop_y * aligned_src_width) + ((crop_x / 2) * 2);
|
||||
r = P210ToARGBMatrix(src_y16, src_width, src_uv16, aligned_src_width,
|
||||
dst_argb, dst_stride_argb, &kYuvI601Constants,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
case FOURCC_P410: {
|
||||
const uint16_t* src16 = (const uint16_t*)sample;
|
||||
const uint16_t* src_y16 =
|
||||
src16 + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint16_t* src_uv16 =
|
||||
src16 + ((ptrdiff_t)src_width * abs_src_height) +
|
||||
((ptrdiff_t)crop_y * src_width * 2) + crop_x * 2;
|
||||
r = P410ToARGBMatrix(src_y16, src_width, src_uv16, src_width * 2,
|
||||
dst_argb, dst_stride_argb, &kYuvI601Constants,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
// Triplanar formats
|
||||
case FOURCC_I420:
|
||||
case FOURCC_YV12: {
|
||||
const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
|
||||
const uint8_t* src_y = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint8_t* src_u;
|
||||
const uint8_t* src_v;
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
int halfheight = (abs_src_height + 1) / 2;
|
||||
if (format == FOURCC_YV12) {
|
||||
src_v = sample + src_width * abs_src_height +
|
||||
(halfwidth * crop_y + crop_x) / 2;
|
||||
src_u = sample + src_width * abs_src_height +
|
||||
halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
|
||||
src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * (crop_y / 2) + crop_x / 2;
|
||||
src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)halfheight + crop_y / 2) + crop_x / 2;
|
||||
} else {
|
||||
src_u = sample + src_width * abs_src_height +
|
||||
(halfwidth * crop_y + crop_x) / 2;
|
||||
src_v = sample + src_width * abs_src_height +
|
||||
halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
|
||||
src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * (crop_y / 2) + crop_x / 2;
|
||||
src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)halfheight + crop_y / 2) + crop_x / 2;
|
||||
}
|
||||
r = I420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_H420: {
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
int halfheight = (abs_src_height + 1) / 2;
|
||||
const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
|
||||
const uint8_t* src_u = sample + src_width * abs_src_height +
|
||||
(halfwidth * crop_y + crop_x) / 2;
|
||||
const uint8_t* src_v = sample + src_width * abs_src_height +
|
||||
halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
|
||||
r = H420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_J420: {
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
int halfheight = (abs_src_height + 1) / 2;
|
||||
const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
|
||||
const uint8_t* src_u = sample + src_width * abs_src_height +
|
||||
(halfwidth * crop_y + crop_x) / 2;
|
||||
const uint8_t* src_v = sample + src_width * abs_src_height +
|
||||
halfwidth * (halfheight + crop_y / 2) + crop_x / 2;
|
||||
const uint8_t* src_y = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint8_t* src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * (crop_y / 2) + crop_x / 2;
|
||||
const uint8_t* src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)halfheight + crop_y / 2) +
|
||||
crop_x / 2;
|
||||
r = J420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_H420: {
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
int halfheight = (abs_src_height + 1) / 2;
|
||||
const uint8_t* src_y = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint8_t* src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * (crop_y / 2) + crop_x / 2;
|
||||
const uint8_t* src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)halfheight + crop_y / 2) +
|
||||
crop_x / 2;
|
||||
r = H420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_U420: {
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
int halfheight = (abs_src_height + 1) / 2;
|
||||
const uint8_t* src_y = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint8_t* src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * (crop_y / 2) + crop_x / 2;
|
||||
const uint8_t* src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)halfheight + crop_y / 2) +
|
||||
crop_x / 2;
|
||||
r = U420ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_I422:
|
||||
case FOURCC_YV16: {
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
const uint8_t* src_y = sample + src_width * crop_y + crop_x;
|
||||
const uint8_t* src_y = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u;
|
||||
const uint8_t* src_v;
|
||||
if (format == FOURCC_YV16) {
|
||||
src_v = sample + src_width * abs_src_height + halfwidth * crop_y +
|
||||
crop_x / 2;
|
||||
src_u = sample + src_width * abs_src_height +
|
||||
halfwidth * (abs_src_height + crop_y) + crop_x / 2;
|
||||
src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * crop_y + crop_x / 2;
|
||||
src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)abs_src_height + crop_y) + crop_x / 2;
|
||||
} else {
|
||||
src_u = sample + src_width * abs_src_height + halfwidth * crop_y +
|
||||
crop_x / 2;
|
||||
src_v = sample + src_width * abs_src_height +
|
||||
halfwidth * (abs_src_height + crop_y) + crop_x / 2;
|
||||
src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * crop_y + crop_x / 2;
|
||||
src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)abs_src_height + crop_y) + crop_x / 2;
|
||||
}
|
||||
r = I422ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_J422: {
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
const uint8_t* src_y = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * crop_y + crop_x / 2;
|
||||
const uint8_t* src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)abs_src_height + crop_y) +
|
||||
crop_x / 2;
|
||||
r = J422ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_H422: {
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
const uint8_t* src_y = sample + src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u =
|
||||
sample + src_width * abs_src_height + halfwidth * crop_y + crop_x / 2;
|
||||
const uint8_t* src_v = sample + src_width * abs_src_height +
|
||||
halfwidth * (abs_src_height + crop_y) + crop_x / 2;
|
||||
const uint8_t* src_y = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * crop_y + crop_x / 2;
|
||||
const uint8_t* src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)abs_src_height + crop_y) +
|
||||
crop_x / 2;
|
||||
r = H422ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_U422: {
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
const uint8_t* src_y = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * crop_y + crop_x / 2;
|
||||
const uint8_t* src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)abs_src_height + crop_y) +
|
||||
crop_x / 2;
|
||||
r = U422ToARGB(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_I444:
|
||||
case FOURCC_YV24: {
|
||||
const uint8_t* src_y = sample + src_width * crop_y + crop_x;
|
||||
const uint8_t* src_y = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u;
|
||||
const uint8_t* src_v;
|
||||
if (format == FOURCC_YV24) {
|
||||
src_v = sample + src_width * (abs_src_height + crop_y) + crop_x;
|
||||
src_u = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
|
||||
src_v =
|
||||
sample + src_width * ((ptrdiff_t)abs_src_height + crop_y) + crop_x;
|
||||
src_u = sample + src_width * ((ptrdiff_t)abs_src_height * 2 + crop_y) +
|
||||
crop_x;
|
||||
} else {
|
||||
src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
|
||||
src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
|
||||
src_u =
|
||||
sample + src_width * ((ptrdiff_t)abs_src_height + crop_y) + crop_x;
|
||||
src_v = sample + src_width * ((ptrdiff_t)abs_src_height * 2 + crop_y) +
|
||||
crop_x;
|
||||
}
|
||||
r = I444ToARGB(src_y, src_width, src_u, src_width, src_v, src_width,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_J444: {
|
||||
const uint8_t* src_y = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u =
|
||||
sample + src_width * ((ptrdiff_t)abs_src_height + crop_y) + crop_x;
|
||||
const uint8_t* src_v =
|
||||
sample + src_width * ((ptrdiff_t)abs_src_height * 2 + crop_y) +
|
||||
crop_x;
|
||||
r = J444ToARGB(src_y, src_width, src_u, src_width, src_v, src_width,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_H444: {
|
||||
const uint8_t* src_y = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u =
|
||||
sample + src_width * ((ptrdiff_t)abs_src_height + crop_y) + crop_x;
|
||||
const uint8_t* src_v =
|
||||
sample + src_width * ((ptrdiff_t)abs_src_height * 2 + crop_y) +
|
||||
crop_x;
|
||||
r = H444ToARGB(src_y, src_width, src_u, src_width, src_v, src_width,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
case FOURCC_U444: {
|
||||
const uint8_t* src_y = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u =
|
||||
sample + src_width * ((ptrdiff_t)abs_src_height + crop_y) + crop_x;
|
||||
const uint8_t* src_v =
|
||||
sample + src_width * ((ptrdiff_t)abs_src_height * 2 + crop_y) +
|
||||
crop_x;
|
||||
r = U444ToARGB(src_y, src_width, src_u, src_width, src_v, src_width,
|
||||
dst_argb, dst_stride_argb, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
case FOURCC_MJPG:
|
||||
r = MJPGToARGB(sample, sample_size, dst_argb, dst_stride_argb, src_width,
|
||||
@@ -301,7 +729,7 @@ int ConvertToARGB(const uint8_t* sample,
|
||||
}
|
||||
free(rotate_buffer);
|
||||
} else if (rotation) {
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = ARGBRotate(src, src_width * 4, dst_argb, dst_stride_argb, crop_width,
|
||||
inv_crop_height, rotation);
|
||||
}
|
||||
|
||||
@@ -8,10 +8,17 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libyuv/convert.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libyuv/cpu_id.h"
|
||||
#include "libyuv/planar_functions.h"
|
||||
#include "libyuv/row.h"
|
||||
#include "libyuv/video_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -19,6 +26,257 @@ namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static int NV16ToI420(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height) {
|
||||
int y;
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
// UV rows are halfwidth * 2 (even) bytes.
|
||||
int awidth = halfwidth * 2;
|
||||
void (*SplitUVRow)(const uint8_t* src_uv, uint8_t* dst_u, uint8_t* dst_v,
|
||||
int width) = SplitUVRow_C;
|
||||
void (*InterpolateRow)(uint8_t* dst_ptr, const uint8_t* src_ptr,
|
||||
ptrdiff_t src_stride, int dst_width,
|
||||
int source_y_fraction) = InterpolateRow_C;
|
||||
if ((!src_y && dst_y) || !src_uv || !dst_u || !dst_v || width <= 0 ||
|
||||
height == 0 || height == INT_MIN) {
|
||||
return -1;
|
||||
}
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
halfheight = (height + 1) >> 1;
|
||||
if (src_y) {
|
||||
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||
src_stride_y = -src_stride_y;
|
||||
}
|
||||
src_uv = src_uv + (ptrdiff_t)(height - 1) * src_stride_uv;
|
||||
src_stride_uv = -src_stride_uv;
|
||||
}
|
||||
if (dst_y) {
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
}
|
||||
#if defined(HAS_SPLITUVROW_SSE2)
|
||||
if (TestCpuFlag(kCpuHasSSE2)) {
|
||||
SplitUVRow = SplitUVRow_Any_SSE2;
|
||||
if (IS_ALIGNED(halfwidth, 16)) {
|
||||
SplitUVRow = SplitUVRow_SSE2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
SplitUVRow = SplitUVRow_Any_AVX2;
|
||||
if (IS_ALIGNED(halfwidth, 32)) {
|
||||
SplitUVRow = SplitUVRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
SplitUVRow = SplitUVRow_AVX512BW;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
SplitUVRow = SplitUVRow_Any_NEON;
|
||||
if (IS_ALIGNED(halfwidth, 16)) {
|
||||
SplitUVRow = SplitUVRow_NEON;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_SVE2)
|
||||
if (TestCpuFlag(kCpuHasSVE2)) {
|
||||
SplitUVRow = SplitUVRow_SVE2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
SplitUVRow = SplitUVRow_Any_LSX;
|
||||
if (IS_ALIGNED(halfwidth, 16)) {
|
||||
SplitUVRow = SplitUVRow_LSX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
SplitUVRow = SplitUVRow_Any_LASX;
|
||||
if (IS_ALIGNED(halfwidth, 32)) {
|
||||
SplitUVRow = SplitUVRow_LASX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_SPLITUVROW_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
SplitUVRow = SplitUVRow_RVV;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_INTERPOLATEROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
InterpolateRow = InterpolateRow_Any_AVX2;
|
||||
if (IS_ALIGNED(awidth, 32)) {
|
||||
InterpolateRow = InterpolateRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_INTERPOLATEROW_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
InterpolateRow = InterpolateRow_AVX512BW;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_INTERPOLATEROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
InterpolateRow = InterpolateRow_Any_NEON;
|
||||
if (IS_ALIGNED(awidth, 16)) {
|
||||
InterpolateRow = InterpolateRow_NEON;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_INTERPOLATEROW_SVE2)
|
||||
if (TestCpuFlag(kCpuHasSVE2)) {
|
||||
InterpolateRow = InterpolateRow_SVE2;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_INTERPOLATEROW_SME)
|
||||
if (TestCpuFlag(kCpuHasSME)) {
|
||||
InterpolateRow = InterpolateRow_SME;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_INTERPOLATEROW_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
InterpolateRow = InterpolateRow_Any_LSX;
|
||||
if (IS_ALIGNED(awidth, 16)) {
|
||||
InterpolateRow = InterpolateRow_LSX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_INTERPOLATEROW_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
InterpolateRow = InterpolateRow_Any_LASX;
|
||||
if (IS_ALIGNED(awidth, 32)) {
|
||||
InterpolateRow = InterpolateRow_LASX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_INTERPOLATEROW_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
InterpolateRow = InterpolateRow_RVV;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_INTERPOLATEROW_WASMSIMD)
|
||||
if (TestCpuFlag(kCpuHasWASMSIMD)) {
|
||||
InterpolateRow = InterpolateRow_Any_WASMSIMD;
|
||||
if (IS_ALIGNED(awidth, 16)) {
|
||||
InterpolateRow = InterpolateRow_WASMSIMD;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
align_buffer_64(row_uv, awidth);
|
||||
if (!row_uv) {
|
||||
return 1;
|
||||
}
|
||||
for (y = 0; y < halfheight; ++y) {
|
||||
if (y * 2 + 1 < height) {
|
||||
// Average 2 rows of UV with rounding (source_y_fraction 128).
|
||||
InterpolateRow(row_uv, src_uv, src_stride_uv, awidth, 128);
|
||||
SplitUVRow(row_uv, dst_u, dst_v, halfwidth);
|
||||
} else {
|
||||
SplitUVRow(src_uv, dst_u, dst_v, halfwidth);
|
||||
}
|
||||
src_uv += (ptrdiff_t)src_stride_uv * 2;
|
||||
dst_u += dst_stride_u;
|
||||
dst_v += dst_stride_v;
|
||||
}
|
||||
free_aligned_buffer_64(row_uv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int NV24ToI420(const uint8_t* src_y,
|
||||
int src_stride_y,
|
||||
const uint8_t* src_uv,
|
||||
int src_stride_uv,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
uint8_t* dst_u,
|
||||
int dst_stride_u,
|
||||
uint8_t* dst_v,
|
||||
int dst_stride_v,
|
||||
int width,
|
||||
int height) {
|
||||
int x, y;
|
||||
int halfwidth = (width + 1) >> 1;
|
||||
int halfheight = (height + 1) >> 1;
|
||||
void (*HalfRow)(const uint8_t* src_uv, ptrdiff_t src_uv_stride,
|
||||
uint8_t* dst_uv, int width) = HalfRow_C;
|
||||
if ((!src_y && dst_y) || !src_uv || !dst_u || !dst_v || width <= 0 ||
|
||||
height == 0 || height == INT_MIN) {
|
||||
return -1;
|
||||
}
|
||||
if (height < 0) {
|
||||
height = -height;
|
||||
halfheight = (height + 1) >> 1;
|
||||
if (src_y) {
|
||||
src_y = src_y + (ptrdiff_t)(height - 1) * src_stride_y;
|
||||
src_stride_y = -src_stride_y;
|
||||
}
|
||||
src_uv = src_uv + (ptrdiff_t)(height - 1) * src_stride_uv;
|
||||
src_stride_uv = -src_stride_uv;
|
||||
}
|
||||
if (dst_y) {
|
||||
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
|
||||
}
|
||||
#if defined(HAS_HALFROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
HalfRow = HalfRow_Any_AVX2;
|
||||
if (IS_ALIGNED(width * 2, 32)) {
|
||||
HalfRow = HalfRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
align_buffer_64(row_uv, width * 2);
|
||||
if (!row_uv) {
|
||||
return 1;
|
||||
}
|
||||
for (y = 0; y < halfheight; ++y) {
|
||||
if (y * 2 + 1 < height) {
|
||||
HalfRow(src_uv, src_stride_uv, row_uv, width * 2);
|
||||
} else {
|
||||
memcpy(row_uv, src_uv, (size_t)width * 2);
|
||||
}
|
||||
for (x = 0; x < halfwidth - 1; ++x) {
|
||||
dst_u[x] = (row_uv[x * 4 + 0] + row_uv[x * 4 + 2] + 1) >> 1;
|
||||
dst_v[x] = (row_uv[x * 4 + 1] + row_uv[x * 4 + 3] + 1) >> 1;
|
||||
}
|
||||
if (width & 1) {
|
||||
dst_u[halfwidth - 1] = row_uv[(halfwidth - 1) * 4 + 0];
|
||||
dst_v[halfwidth - 1] = row_uv[(halfwidth - 1) * 4 + 1];
|
||||
} else {
|
||||
dst_u[halfwidth - 1] = (row_uv[(halfwidth - 1) * 4 + 0] +
|
||||
row_uv[(halfwidth - 1) * 4 + 2] + 1) >>
|
||||
1;
|
||||
dst_v[halfwidth - 1] = (row_uv[(halfwidth - 1) * 4 + 1] +
|
||||
row_uv[(halfwidth - 1) * 4 + 3] + 1) >>
|
||||
1;
|
||||
}
|
||||
src_uv += (ptrdiff_t)src_stride_uv * 2;
|
||||
dst_u += dst_stride_u;
|
||||
dst_v += dst_stride_v;
|
||||
}
|
||||
free_aligned_buffer_64(row_uv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Convert camera sample to I420 with cropping, rotation and vertical flip.
|
||||
// src_width is used for source stride computation
|
||||
// src_height is used to compute location of planes, and indicate inversion
|
||||
@@ -41,18 +299,28 @@ int ConvertToI420(const uint8_t* sample,
|
||||
int crop_height,
|
||||
enum RotationMode rotation,
|
||||
uint32_t fourcc) {
|
||||
if (src_height == INT_MIN || crop_height == INT_MIN) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const int abs_src_height = (src_height < 0) ? -src_height : src_height;
|
||||
const int abs_crop_height = (crop_height < 0) ? -crop_height : crop_height;
|
||||
|
||||
if (!dst_y || !dst_u || !dst_v || !sample || src_width <= 0 ||
|
||||
src_width > INT_MAX / 4 || crop_width <= 0 || src_height == 0 ||
|
||||
crop_height == 0 || crop_x < 0 || crop_y < 0 || crop_width > src_width ||
|
||||
crop_x > src_width - crop_width || abs_crop_height > abs_src_height ||
|
||||
crop_y > abs_src_height - abs_crop_height) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t format = CanonicalFourCC(fourcc);
|
||||
int aligned_src_width = (src_width + 1) & ~1;
|
||||
const uint8_t* src;
|
||||
const uint8_t* src_uv;
|
||||
const int abs_src_height = (src_height < 0) ? -src_height : src_height;
|
||||
// TODO(nisse): Why allow crop_height < 0?
|
||||
const int abs_crop_height = (crop_height < 0) ? -crop_height : crop_height;
|
||||
int r = 0;
|
||||
LIBYUV_BOOL need_buf =
|
||||
(rotation && format != FOURCC_I420 && format != FOURCC_NV12 &&
|
||||
format != FOURCC_NV21 && format != FOURCC_YV12) ||
|
||||
dst_y == sample;
|
||||
int need_buf = (rotation && format != FOURCC_I420 && format != FOURCC_NV12 &&
|
||||
format != FOURCC_NV21 && format != FOURCC_YV12) ||
|
||||
dst_y == sample;
|
||||
uint8_t* tmp_y = dst_y;
|
||||
uint8_t* tmp_u = dst_u;
|
||||
uint8_t* tmp_v = dst_v;
|
||||
@@ -62,11 +330,7 @@ int ConvertToI420(const uint8_t* sample,
|
||||
uint8_t* rotate_buffer = NULL;
|
||||
const int inv_crop_height =
|
||||
(src_height < 0) ? -abs_crop_height : abs_crop_height;
|
||||
|
||||
if (!dst_y || !dst_u || !dst_v || !sample || src_width <= 0 ||
|
||||
crop_width <= 0 || src_height == 0 || crop_height == 0) {
|
||||
return -1;
|
||||
}
|
||||
int aligned_src_width = (src_width + 1) & ~1;
|
||||
|
||||
// One pass rotation is available for some formats. For the rest, convert
|
||||
// to I420 (with optional vertical flipping) into a temporary I420 buffer,
|
||||
@@ -74,9 +338,14 @@ int ConvertToI420(const uint8_t* sample,
|
||||
// For in-place conversion, if destination dst_y is same as source sample,
|
||||
// also enable temporary buffer.
|
||||
if (need_buf) {
|
||||
int y_size = crop_width * abs_crop_height;
|
||||
int uv_size = ((crop_width + 1) / 2) * ((abs_crop_height + 1) / 2);
|
||||
rotate_buffer = (uint8_t*)malloc(y_size + uv_size * 2); /* NOLINT */
|
||||
size_t y_size = (size_t)crop_width * abs_crop_height;
|
||||
size_t uv_size =
|
||||
(size_t)((crop_width + 1) / 2) * ((abs_crop_height + 1) / 2);
|
||||
if (uv_size > SIZE_MAX / 2 || y_size > SIZE_MAX - uv_size * 2) {
|
||||
return -1; // Invalid size.
|
||||
}
|
||||
const size_t rotate_buffer_size = y_size + uv_size * 2;
|
||||
rotate_buffer = (uint8_t*)malloc(rotate_buffer_size);
|
||||
if (!rotate_buffer) {
|
||||
return 1; // Out of memory runtime error.
|
||||
}
|
||||
@@ -89,119 +358,189 @@ int ConvertToI420(const uint8_t* sample,
|
||||
|
||||
switch (format) {
|
||||
// Single plane formats
|
||||
case FOURCC_YUY2:
|
||||
src = sample + (aligned_src_width * crop_y + crop_x) * 2;
|
||||
r = YUY2ToI420(src, aligned_src_width * 2, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
case FOURCC_YUY2: { // TODO(fbarchard): Find better odd crop fix.
|
||||
uint8_t* u = (crop_x & 1) ? dst_v : dst_u;
|
||||
uint8_t* v = (crop_x & 1) ? dst_u : dst_v;
|
||||
int stride_u = (crop_x & 1) ? dst_stride_v : dst_stride_u;
|
||||
int stride_v = (crop_x & 1) ? dst_stride_u : dst_stride_v;
|
||||
src = sample + ((ptrdiff_t)aligned_src_width * crop_y + crop_x) * 2;
|
||||
r = YUY2ToI420(src, aligned_src_width * 2, dst_y, dst_stride_y, u,
|
||||
stride_u, v, stride_v, crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_UYVY:
|
||||
src = sample + (aligned_src_width * crop_y + crop_x) * 2;
|
||||
r = UYVYToI420(src, aligned_src_width * 2, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
}
|
||||
case FOURCC_UYVY: {
|
||||
uint8_t* u = (crop_x & 1) ? dst_v : dst_u;
|
||||
uint8_t* v = (crop_x & 1) ? dst_u : dst_v;
|
||||
int stride_u = (crop_x & 1) ? dst_stride_v : dst_stride_u;
|
||||
int stride_v = (crop_x & 1) ? dst_stride_u : dst_stride_v;
|
||||
src = sample + ((ptrdiff_t)aligned_src_width * crop_y + crop_x) * 2;
|
||||
r = UYVYToI420(src, aligned_src_width * 2, dst_y, dst_stride_y, u,
|
||||
stride_u, v, stride_v, crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
case FOURCC_RGBP:
|
||||
src = sample + (src_width * crop_y + crop_x) * 2;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 2;
|
||||
r = RGB565ToI420(src, src_width * 2, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_RGBO:
|
||||
src = sample + (src_width * crop_y + crop_x) * 2;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 2;
|
||||
r = ARGB1555ToI420(src, src_width * 2, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_R444:
|
||||
src = sample + (src_width * crop_y + crop_x) * 2;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 2;
|
||||
r = ARGB4444ToI420(src, src_width * 2, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_24BG:
|
||||
src = sample + (src_width * crop_y + crop_x) * 3;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 3;
|
||||
r = RGB24ToI420(src, src_width * 3, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_RAW:
|
||||
src = sample + (src_width * crop_y + crop_x) * 3;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 3;
|
||||
r = RAWToI420(src, src_width * 3, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_ARGB:
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = ARGBToI420(src, src_width * 4, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_BGRA:
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = BGRAToI420(src, src_width * 4, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_ABGR:
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = ABGRToI420(src, src_width * 4, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_RGBA:
|
||||
src = sample + (src_width * crop_y + crop_x) * 4;
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = RGBAToI420(src, src_width * 4, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
// TODO(fbarchard): Add AR30 and AB30
|
||||
case FOURCC_AR30:
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = AR30ToI420(src, src_width * 4, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_AB30:
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x) * 4;
|
||||
r = AB30ToI420(src, src_width * 4, dst_y, dst_stride_y, dst_u,
|
||||
dst_stride_u, dst_v, dst_stride_v, crop_width,
|
||||
inv_crop_height);
|
||||
break;
|
||||
case FOURCC_I400:
|
||||
src = sample + src_width * crop_y + crop_x;
|
||||
src = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
r = I400ToI420(src, src_width, dst_y, dst_stride_y, dst_u, dst_stride_u,
|
||||
dst_v, dst_stride_v, crop_width, inv_crop_height);
|
||||
break;
|
||||
// Biplanar formats
|
||||
case FOURCC_NV12:
|
||||
src = sample + (src_width * crop_y + crop_x);
|
||||
src_uv = sample + (src_width * abs_src_height) +
|
||||
((crop_y / 2) * aligned_src_width) + ((crop_x / 2) * 2);
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
src_uv = sample + ((ptrdiff_t)src_width * abs_src_height) +
|
||||
((ptrdiff_t)(crop_y / 2) * aligned_src_width) +
|
||||
((crop_x / 2) * 2);
|
||||
r = NV12ToI420Rotate(src, src_width, src_uv, aligned_src_width, dst_y,
|
||||
dst_stride_y, dst_u, dst_stride_u, dst_v,
|
||||
dst_stride_v, crop_width, inv_crop_height, rotation);
|
||||
break;
|
||||
case FOURCC_NV21:
|
||||
src = sample + (src_width * crop_y + crop_x);
|
||||
src_uv = sample + (src_width * abs_src_height) +
|
||||
((crop_y / 2) * aligned_src_width) + ((crop_x / 2) * 2);
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
src_uv = sample + ((ptrdiff_t)src_width * abs_src_height) +
|
||||
((ptrdiff_t)(crop_y / 2) * aligned_src_width) +
|
||||
((crop_x / 2) * 2);
|
||||
// Call NV12 but with dst_u and dst_v parameters swapped.
|
||||
r = NV12ToI420Rotate(src, src_width, src_uv, aligned_src_width, dst_y,
|
||||
dst_stride_y, dst_v, dst_stride_v, dst_u,
|
||||
dst_stride_u, crop_width, inv_crop_height, rotation);
|
||||
break;
|
||||
case FOURCC_M420:
|
||||
src = sample + (src_width * crop_y) * 12 / 8 + crop_x;
|
||||
r = M420ToI420(src, src_width, dst_y, dst_stride_y, dst_u, dst_stride_u,
|
||||
dst_v, dst_stride_v, crop_width, inv_crop_height);
|
||||
case FOURCC_NV16:
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
src_uv = sample + ((ptrdiff_t)aligned_src_width * abs_src_height) +
|
||||
((ptrdiff_t)crop_y * aligned_src_width) + ((crop_x / 2) * 2);
|
||||
r = NV16ToI420(src, src_width, src_uv, aligned_src_width, dst_y,
|
||||
dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_NV24:
|
||||
src = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
src_uv = sample + ((ptrdiff_t)aligned_src_width * abs_src_height) +
|
||||
((ptrdiff_t)crop_y * aligned_src_width * 2) + (crop_x * 2);
|
||||
r = NV24ToI420(src, src_width, src_uv, aligned_src_width * 2, dst_y,
|
||||
dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
case FOURCC_P010: {
|
||||
const uint16_t* src16 = (const uint16_t*)sample;
|
||||
const uint16_t* src_y16 =
|
||||
src16 + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint16_t* src_uv16 =
|
||||
src16 + ((ptrdiff_t)src_width * abs_src_height) +
|
||||
((ptrdiff_t)(crop_y / 2) * aligned_src_width) + ((crop_x / 2) * 2);
|
||||
r = P010ToI420(src_y16, src_width, src_uv16, aligned_src_width, dst_y,
|
||||
dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
case FOURCC_P210: {
|
||||
const uint16_t* src16 = (const uint16_t*)sample;
|
||||
const uint16_t* src_y16 =
|
||||
src16 + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint16_t* src_uv16 =
|
||||
src16 + ((ptrdiff_t)src_width * abs_src_height) +
|
||||
((ptrdiff_t)crop_y * aligned_src_width) + ((crop_x / 2) * 2);
|
||||
r = P210ToI420(src_y16, src_width, src_uv16, aligned_src_width, dst_y,
|
||||
dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
case FOURCC_P410: {
|
||||
const uint16_t* src16 = (const uint16_t*)sample;
|
||||
const uint16_t* src_y16 =
|
||||
src16 + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint16_t* src_uv16 =
|
||||
src16 + ((ptrdiff_t)src_width * abs_src_height) +
|
||||
((ptrdiff_t)crop_y * src_width * 2) + crop_x * 2;
|
||||
r = P410ToI420(src_y16, src_width, src_uv16, src_width * 2, dst_y,
|
||||
dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v,
|
||||
crop_width, inv_crop_height);
|
||||
break;
|
||||
}
|
||||
// Triplanar formats
|
||||
case FOURCC_I420:
|
||||
case FOURCC_YV12: {
|
||||
const uint8_t* src_y = sample + (src_width * crop_y + crop_x);
|
||||
const uint8_t* src_y = sample + ((ptrdiff_t)src_width * crop_y + crop_x);
|
||||
const uint8_t* src_u;
|
||||
const uint8_t* src_v;
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
int halfheight = (abs_src_height + 1) / 2;
|
||||
if (format == FOURCC_YV12) {
|
||||
src_v = sample + src_width * abs_src_height + halfwidth * (crop_y / 2) +
|
||||
src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * (crop_y / 2) + (crop_x / 2);
|
||||
src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)halfheight + (crop_y / 2)) +
|
||||
(crop_x / 2);
|
||||
src_u = sample + src_width * abs_src_height +
|
||||
halfwidth * (halfheight + (crop_y / 2)) + (crop_x / 2);
|
||||
} else {
|
||||
src_u = sample + src_width * abs_src_height + halfwidth * (crop_y / 2) +
|
||||
src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * (crop_y / 2) + (crop_x / 2);
|
||||
src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)halfheight + (crop_y / 2)) +
|
||||
(crop_x / 2);
|
||||
src_v = sample + src_width * abs_src_height +
|
||||
halfwidth * (halfheight + (crop_y / 2)) + (crop_x / 2);
|
||||
}
|
||||
r = I420Rotate(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
|
||||
@@ -210,20 +549,20 @@ int ConvertToI420(const uint8_t* sample,
|
||||
}
|
||||
case FOURCC_I422:
|
||||
case FOURCC_YV16: {
|
||||
const uint8_t* src_y = sample + src_width * crop_y + crop_x;
|
||||
const uint8_t* src_y = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u;
|
||||
const uint8_t* src_v;
|
||||
int halfwidth = (src_width + 1) / 2;
|
||||
if (format == FOURCC_YV16) {
|
||||
src_v = sample + src_width * abs_src_height + halfwidth * crop_y +
|
||||
(crop_x / 2);
|
||||
src_u = sample + src_width * abs_src_height +
|
||||
halfwidth * (abs_src_height + crop_y) + (crop_x / 2);
|
||||
src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * crop_y + (crop_x / 2);
|
||||
src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)abs_src_height + crop_y) + (crop_x / 2);
|
||||
} else {
|
||||
src_u = sample + src_width * abs_src_height + halfwidth * crop_y +
|
||||
(crop_x / 2);
|
||||
src_v = sample + src_width * abs_src_height +
|
||||
halfwidth * (abs_src_height + crop_y) + (crop_x / 2);
|
||||
src_u = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
(ptrdiff_t)halfwidth * crop_y + (crop_x / 2);
|
||||
src_v = sample + (ptrdiff_t)src_width * abs_src_height +
|
||||
halfwidth * ((ptrdiff_t)abs_src_height + crop_y) + (crop_x / 2);
|
||||
}
|
||||
r = I422ToI420(src_y, src_width, src_u, halfwidth, src_v, halfwidth,
|
||||
dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
|
||||
@@ -232,15 +571,19 @@ int ConvertToI420(const uint8_t* sample,
|
||||
}
|
||||
case FOURCC_I444:
|
||||
case FOURCC_YV24: {
|
||||
const uint8_t* src_y = sample + src_width * crop_y + crop_x;
|
||||
const uint8_t* src_y = sample + (ptrdiff_t)src_width * crop_y + crop_x;
|
||||
const uint8_t* src_u;
|
||||
const uint8_t* src_v;
|
||||
if (format == FOURCC_YV24) {
|
||||
src_v = sample + src_width * (abs_src_height + crop_y) + crop_x;
|
||||
src_u = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
|
||||
src_v =
|
||||
sample + src_width * ((ptrdiff_t)abs_src_height + crop_y) + crop_x;
|
||||
src_u = sample + src_width * ((ptrdiff_t)abs_src_height * 2 + crop_y) +
|
||||
crop_x;
|
||||
} else {
|
||||
src_u = sample + src_width * (abs_src_height + crop_y) + crop_x;
|
||||
src_v = sample + src_width * (abs_src_height * 2 + crop_y) + crop_x;
|
||||
src_u =
|
||||
sample + src_width * ((ptrdiff_t)abs_src_height + crop_y) + crop_x;
|
||||
src_v = sample + src_width * ((ptrdiff_t)abs_src_height * 2 + crop_y) +
|
||||
crop_x;
|
||||
}
|
||||
r = I444ToI420(src_y, src_width, src_u, src_width, src_v, src_width,
|
||||
dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
|
||||
|
||||
+334
-82
@@ -20,9 +20,25 @@
|
||||
#endif
|
||||
|
||||
// For ArmCpuCaps() but unittested on all platforms
|
||||
#include <stdio.h>
|
||||
#include <stdio.h> // For fopen()
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__linux__) && (defined(__aarch64__) || defined(__loongarch__))
|
||||
#include <sys/auxv.h> // For getauxval()
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && defined(__aarch64__)
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#undef WIN32_EXTRA_LEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h> // For IsProcessorFeaturePresent()
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) && defined(__aarch64__)
|
||||
#include <sys/sysctl.h> // For sysctlbyname()
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
@@ -40,7 +56,6 @@ extern "C" {
|
||||
// cpu_info_ variable for SIMD instruction sets detected.
|
||||
LIBYUV_API int cpu_info_ = 0;
|
||||
|
||||
// TODO(fbarchard): Consider using int for cpuid so casting is not needed.
|
||||
// Low level cpuid for X86.
|
||||
#if (defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \
|
||||
defined(__x86_64__)) && \
|
||||
@@ -75,9 +90,9 @@ void CpuId(int info_eax, int info_ecx, int* cpu_info) {
|
||||
asm volatile(
|
||||
#if defined(__i386__) && defined(__PIC__)
|
||||
// Preserve ebx for fpic 32 bit.
|
||||
"mov %%ebx, %%edi \n"
|
||||
"mov %%ebx, %%edi \n"
|
||||
"cpuid \n"
|
||||
"xchg %%edi, %%ebx \n"
|
||||
"xchg %%edi, %%ebx \n"
|
||||
: "=D"(info_ebx),
|
||||
#else
|
||||
"cpuid \n"
|
||||
@@ -108,14 +123,14 @@ void CpuId(int eax, int ecx, int* cpu_info) {
|
||||
// }
|
||||
// For VS2013 and earlier 32 bit, the _xgetbv(0) optimizer produces bad code.
|
||||
// https://code.google.com/p/libyuv/issues/detail?id=529
|
||||
#if defined(_M_IX86) && (_MSC_VER < 1900)
|
||||
#if defined(_M_IX86) && defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||
#pragma optimize("g", off)
|
||||
#endif
|
||||
#if (defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \
|
||||
defined(__x86_64__)) && \
|
||||
!defined(__pnacl__) && !defined(__CLR_VER) && !defined(__native_client__)
|
||||
// X86 CPUs have xgetbv to detect OS saves high parts of ymm registers.
|
||||
int GetXCR0() {
|
||||
static int GetXCR0() {
|
||||
int xcr0 = 0;
|
||||
#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 160040219)
|
||||
xcr0 = (int)_xgetbv(0); // VS2010 SP1 required. NOLINT
|
||||
@@ -129,80 +144,258 @@ int GetXCR0() {
|
||||
#define GetXCR0() 0
|
||||
#endif // defined(_M_IX86) || defined(_M_X64) ..
|
||||
// Return optimization to previous setting.
|
||||
#if defined(_M_IX86) && (_MSC_VER < 1900)
|
||||
#if defined(_M_IX86) && defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||
#pragma optimize("g", on)
|
||||
#endif
|
||||
|
||||
// based on libvpx arm_cpudetect.c
|
||||
static int cpuinfo_search(const char* cpuinfo_line,
|
||||
const char* needle,
|
||||
int needle_len) {
|
||||
const char* p = strstr(cpuinfo_line, needle);
|
||||
return p && (p[needle_len] == ' ' || p[needle_len] == '\n');
|
||||
}
|
||||
|
||||
// Based on libvpx arm_cpudetect.c
|
||||
// For Arm, but public to allow testing on any CPU
|
||||
LIBYUV_API SAFEBUFFERS int ArmCpuCaps(const char* cpuinfo_name) {
|
||||
char cpuinfo_line[512];
|
||||
FILE* f = fopen(cpuinfo_name, "r");
|
||||
FILE* f = fopen(cpuinfo_name, "re");
|
||||
if (!f) {
|
||||
// Assume Neon if /proc/cpuinfo is unavailable.
|
||||
// This will occur for Chrome sandbox for Pepper or Render process.
|
||||
return kCpuHasNEON;
|
||||
}
|
||||
while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) {
|
||||
memset(cpuinfo_line, 0, sizeof(cpuinfo_line));
|
||||
int features = 0;
|
||||
while (fgets(cpuinfo_line, sizeof(cpuinfo_line), f)) {
|
||||
if (memcmp(cpuinfo_line, "Features", 8) == 0) {
|
||||
char* p = strstr(cpuinfo_line, " neon");
|
||||
if (p && (p[5] == ' ' || p[5] == '\n')) {
|
||||
fclose(f);
|
||||
return kCpuHasNEON;
|
||||
}
|
||||
// aarch64 uses asimd for Neon.
|
||||
p = strstr(cpuinfo_line, " asimd");
|
||||
if (p) {
|
||||
fclose(f);
|
||||
return kCpuHasNEON;
|
||||
if (cpuinfo_search(cpuinfo_line, " neon", 5)) {
|
||||
features |= kCpuHasNEON;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return 0;
|
||||
return features;
|
||||
}
|
||||
|
||||
// TODO(fbarchard): Consider read_msa_ir().
|
||||
// TODO(fbarchard): Add unittest.
|
||||
LIBYUV_API SAFEBUFFERS int MipsCpuCaps(const char* cpuinfo_name,
|
||||
const char ase[]) {
|
||||
char cpuinfo_line[512];
|
||||
FILE* f = fopen(cpuinfo_name, "r");
|
||||
if (!f) {
|
||||
// ase enabled if /proc/cpuinfo is unavailable.
|
||||
if (strcmp(ase, " msa") == 0) {
|
||||
return kCpuHasMSA;
|
||||
#ifdef __aarch64__
|
||||
#ifdef __linux__
|
||||
// Define hwcap values ourselves: building with an old auxv header where these
|
||||
// hwcap values are not defined should not prevent features from being enabled.
|
||||
#define YUV_AARCH64_HWCAP_ASIMDDP (1UL << 20)
|
||||
#define YUV_AARCH64_HWCAP_SVE (1UL << 22)
|
||||
#define YUV_AARCH64_HWCAP2_SVE2 (1UL << 1)
|
||||
#define YUV_AARCH64_HWCAP2_SVEF32MM (1UL << 10)
|
||||
#define YUV_AARCH64_HWCAP2_I8MM (1UL << 13)
|
||||
#define YUV_AARCH64_HWCAP2_SME (1UL << 23)
|
||||
#define YUV_AARCH64_HWCAP2_SME2 (1UL << 37)
|
||||
|
||||
// For AArch64, but public to allow testing on any CPU.
|
||||
LIBYUV_API SAFEBUFFERS int AArch64CpuCaps(unsigned long hwcap,
|
||||
unsigned long hwcap2) {
|
||||
// Neon is mandatory on AArch64, so enable regardless of hwcaps.
|
||||
int features = kCpuHasNEON;
|
||||
|
||||
// Don't try to enable later extensions unless earlier extensions are also
|
||||
// reported available. Some of these constraints aren't strictly required by
|
||||
// the architecture, but are satisfied by all micro-architectures of
|
||||
// interest. This also avoids an issue on some emulators where true
|
||||
// architectural constraints are not satisfied, e.g. SVE2 may be reported as
|
||||
// available while SVE is not.
|
||||
if (hwcap & YUV_AARCH64_HWCAP_ASIMDDP) {
|
||||
features |= kCpuHasNeonDotProd;
|
||||
if (hwcap2 & YUV_AARCH64_HWCAP2_I8MM) {
|
||||
features |= kCpuHasNeonI8MM;
|
||||
if (hwcap & YUV_AARCH64_HWCAP_SVE) {
|
||||
features |= kCpuHasSVE;
|
||||
if (hwcap2 & YUV_AARCH64_HWCAP2_SVEF32MM) {
|
||||
features |= kCpuHasSVEF32MM;
|
||||
}
|
||||
if (hwcap2 & YUV_AARCH64_HWCAP2_SVE2) {
|
||||
features |= kCpuHasSVE2;
|
||||
}
|
||||
}
|
||||
// SME may be present without SVE
|
||||
if (hwcap2 & YUV_AARCH64_HWCAP2_SME) {
|
||||
features |= kCpuHasSME;
|
||||
if (hwcap2 & YUV_AARCH64_HWCAP2_SME2) {
|
||||
features |= kCpuHasSME2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strcmp(ase, " mmi") == 0) {
|
||||
return kCpuHasMMI;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
while (fgets(cpuinfo_line, sizeof(cpuinfo_line) - 1, f)) {
|
||||
if (memcmp(cpuinfo_line, "ASEs implemented", 16) == 0) {
|
||||
char* p = strstr(cpuinfo_line, ase);
|
||||
if (p) {
|
||||
fclose(f);
|
||||
if (strcmp(ase, " msa") == 0) {
|
||||
return kCpuHasMSA;
|
||||
return features;
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
// For AArch64, but public to allow testing on any CPU.
|
||||
LIBYUV_API SAFEBUFFERS int AArch64CpuCaps(void) {
|
||||
// Neon is mandatory on AArch64, so enable unconditionally.
|
||||
int features = kCpuHasNEON;
|
||||
|
||||
// For more information on IsProcessorFeaturePresent(), see:
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent#parameters
|
||||
#ifdef PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE
|
||||
if (IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE)) {
|
||||
features |= kCpuHasNeonDotProd;
|
||||
}
|
||||
#endif
|
||||
// No Neon I8MM or SVE feature detection available here at time of writing.
|
||||
return features;
|
||||
}
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
static bool have_feature(const char* feature) {
|
||||
// For more information on sysctlbyname(), see:
|
||||
// https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics
|
||||
// If feature is "hw.optional.arm.sme_max_svl_b", this function returns
|
||||
// whether the value of sme_max_svl_b is nonzero.
|
||||
int64_t feature_present = 0;
|
||||
size_t size = sizeof(feature_present);
|
||||
if (sysctlbyname(feature, &feature_present, &size, NULL, 0) != 0) {
|
||||
return false;
|
||||
}
|
||||
return feature_present != 0;
|
||||
}
|
||||
|
||||
// For AArch64, but public to allow testing on any CPU.
|
||||
LIBYUV_API SAFEBUFFERS int AArch64CpuCaps(void) {
|
||||
// Neon is mandatory on AArch64, so enable unconditionally.
|
||||
int features = kCpuHasNEON;
|
||||
|
||||
if (have_feature("hw.optional.arm.FEAT_DotProd")) {
|
||||
features |= kCpuHasNeonDotProd;
|
||||
if (have_feature("hw.optional.arm.FEAT_I8MM")) {
|
||||
features |= kCpuHasNeonI8MM;
|
||||
// An Apple processor may have SME hardware (e.g. A18/A19), but the XNU
|
||||
// kernel only enables EL0 execution if sme_max_svl_b is nonzero.
|
||||
// macOS and iPadOS (e.g. on M4) support and enable user-mode SME, but iOS
|
||||
// disables user-mode SME, which causes SMSTART to trigger an
|
||||
// EXC_BAD_INSTRUCTION fault. See
|
||||
// https://github.com/pytorch/cpuinfo/issues/432.
|
||||
if (have_feature("hw.optional.arm.sme_max_svl_b") &&
|
||||
have_feature("hw.optional.arm.FEAT_SME")) {
|
||||
features |= kCpuHasSME;
|
||||
if (have_feature("hw.optional.arm.FEAT_SME2")) {
|
||||
features |= kCpuHasSME2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} else if (memcmp(cpuinfo_line, "cpu model", 9) == 0) {
|
||||
char* p = strstr(cpuinfo_line, "Loongson-3");
|
||||
if (p) {
|
||||
fclose(f);
|
||||
if (strcmp(ase, " mmi") == 0) {
|
||||
return kCpuHasMMI;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// No SVE feature detection available here at time of writing.
|
||||
return features;
|
||||
}
|
||||
|
||||
#else // !defined(__linux__) && !defined(_WIN32) && !defined(__APPLE__)
|
||||
// For AArch64, but public to allow testing on any CPU.
|
||||
LIBYUV_API SAFEBUFFERS int AArch64CpuCaps(void) {
|
||||
// Neon is mandatory on AArch64, so enable unconditionally.
|
||||
int features = kCpuHasNEON;
|
||||
|
||||
// TODO(libyuv:980) support feature detection on other platforms.
|
||||
|
||||
return features;
|
||||
}
|
||||
#endif
|
||||
#endif // defined(__aarch64__)
|
||||
|
||||
LIBYUV_API SAFEBUFFERS int RiscvCpuCaps(const char* cpuinfo_name) {
|
||||
char cpuinfo_line[512];
|
||||
int flag = 0;
|
||||
FILE* f = fopen(cpuinfo_name, "re");
|
||||
if (!f) {
|
||||
#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv) && __riscv_xlen == 64
|
||||
// Assume RVV if /proc/cpuinfo is unavailable.
|
||||
// This will occur for Chrome sandbox for Pepper or Render process.
|
||||
return kCpuHasRVV;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
memset(cpuinfo_line, 0, sizeof(cpuinfo_line));
|
||||
while (fgets(cpuinfo_line, sizeof(cpuinfo_line), f)) {
|
||||
if (memcmp(cpuinfo_line, "isa", 3) == 0) {
|
||||
// ISA string must begin with rv64{i,e,g} for a 64-bit processor.
|
||||
char* isa = strstr(cpuinfo_line, "rv64");
|
||||
if (isa) {
|
||||
size_t isa_len = strlen(isa);
|
||||
char* extensions;
|
||||
size_t extensions_len = 0;
|
||||
size_t std_isa_len;
|
||||
// Remove the new-line character at the end of string
|
||||
if (isa[isa_len - 1] == '\n') {
|
||||
isa[--isa_len] = '\0';
|
||||
}
|
||||
// 5 ISA characters
|
||||
if (isa_len < 5) {
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
// Skip {i,e,g} canonical checking.
|
||||
// Skip rvxxx
|
||||
isa += 5;
|
||||
// Find the very first occurrence of 's', 'x' or 'z'.
|
||||
// To detect multi-letter standard, non-standard, and
|
||||
// supervisor-level extensions.
|
||||
extensions = strpbrk(isa, "zxs");
|
||||
if (extensions) {
|
||||
extensions_len = strlen(extensions);
|
||||
// Multi-letter extensions are seperated by a single underscore
|
||||
// as described in RISC-V User-Level ISA V2.2.
|
||||
char* ext = extensions;
|
||||
while (ext) {
|
||||
char* next = strchr(ext, '_');
|
||||
if (next) {
|
||||
*next = '\0';
|
||||
next++;
|
||||
}
|
||||
// Search for the ZVFH (Vector FP16) extension.
|
||||
if (!strcmp(ext, "zvfh")) {
|
||||
flag |= kCpuHasRVVZVFH;
|
||||
}
|
||||
ext = next;
|
||||
}
|
||||
}
|
||||
std_isa_len = isa_len - extensions_len - 5;
|
||||
// Detect the v in the standard single-letter extensions.
|
||||
if (memchr(isa, 'v', std_isa_len)) {
|
||||
// The RVV implied the F extension.
|
||||
flag |= kCpuHasRVV;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv) && __riscv_xlen == 64
|
||||
// Assume RVV if /proc/cpuinfo is from x86 host running QEMU.
|
||||
else if ((memcmp(cpuinfo_line, "vendor_id\t: GenuineIntel", 24) == 0) ||
|
||||
(memcmp(cpuinfo_line, "vendor_id\t: AuthenticAMD", 24) == 0)) {
|
||||
fclose(f);
|
||||
return kCpuHasRVV;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
fclose(f);
|
||||
return 0;
|
||||
return flag;
|
||||
}
|
||||
|
||||
#if defined(__loongarch__) && defined(__linux__)
|
||||
// Define hwcap values ourselves: building with an old auxv header where these
|
||||
// hwcap values are not defined should not prevent features from being enabled.
|
||||
#define YUV_LOONGARCH_HWCAP_LSX (1 << 4)
|
||||
#define YUV_LOONGARCH_HWCAP_LASX (1 << 5)
|
||||
|
||||
LIBYUV_API SAFEBUFFERS int LoongArchCpuCaps(void) {
|
||||
int flag = 0;
|
||||
unsigned long hwcap = getauxval(AT_HWCAP);
|
||||
|
||||
if (hwcap & YUV_LOONGARCH_HWCAP_LSX)
|
||||
flag |= kCpuHasLSX;
|
||||
|
||||
if (hwcap & YUV_LOONGARCH_HWCAP_LASX)
|
||||
flag |= kCpuHasLASX;
|
||||
return flag;
|
||||
}
|
||||
#endif
|
||||
|
||||
static SAFEBUFFERS int GetCpuFlags(void) {
|
||||
int cpu_info = 0;
|
||||
#if !defined(__pnacl__) && !defined(__CLR_VER) && \
|
||||
@@ -211,62 +404,121 @@ static SAFEBUFFERS int GetCpuFlags(void) {
|
||||
int cpu_info0[4] = {0, 0, 0, 0};
|
||||
int cpu_info1[4] = {0, 0, 0, 0};
|
||||
int cpu_info7[4] = {0, 0, 0, 0};
|
||||
int cpu_einfo7[4] = {0, 0, 0, 0};
|
||||
int cpu_einfo1e[4] = {0, 0, 0, 0};
|
||||
int cpu_info24[4] = {0, 0, 0, 0};
|
||||
int cpu_info21[4] = {0, 0, 0, 0};
|
||||
int cpu_amdinfo21[4] = {0, 0, 0, 0};
|
||||
int cpu_extinfo0[4] = {0, 0, 0, 0};
|
||||
CpuId(0, 0, cpu_info0);
|
||||
CpuId(1, 0, cpu_info1);
|
||||
if (cpu_info0[0] >= 7) {
|
||||
CpuId(7, 0, cpu_info7);
|
||||
// Leaf 7 EAX reports the maximum supported sub-leaf.
|
||||
if (cpu_info7[0] >= 1) {
|
||||
CpuId(7, 1, cpu_einfo7);
|
||||
}
|
||||
}
|
||||
// Extended leaf 0x80000021 is only valid if the CPU reports it. Querying an
|
||||
// unsupported extended leaf returns data from the highest basic leaf on
|
||||
// Intel CPUs, which could spuriously set bits below.
|
||||
CpuId(0x80000000, 0, cpu_extinfo0);
|
||||
if ((unsigned)cpu_extinfo0[0] >= 0x80000021u) {
|
||||
CpuId(0x80000021, 0, cpu_amdinfo21);
|
||||
}
|
||||
if (cpu_info0[0] >= 0x1e) {
|
||||
CpuId(0x1e, 1, cpu_einfo1e);
|
||||
}
|
||||
if (cpu_info0[0] >= 0x21) {
|
||||
CpuId(0x21, 0, cpu_info21);
|
||||
}
|
||||
if (cpu_info0[0] >= 0x24) {
|
||||
CpuId(0x24, 0, cpu_info24);
|
||||
}
|
||||
cpu_info = kCpuHasX86 | ((cpu_info1[3] & 0x04000000) ? kCpuHasSSE2 : 0) |
|
||||
((cpu_info1[2] & 0x00000200) ? kCpuHasSSSE3 : 0) |
|
||||
((cpu_info1[2] & 0x00080000) ? kCpuHasSSE41 : 0) |
|
||||
((cpu_info1[2] & 0x00100000) ? kCpuHasSSE42 : 0) |
|
||||
((cpu_info7[1] & 0x00000200) ? kCpuHasERMS : 0);
|
||||
((cpu_info7[1] & 0x00000200) ? kCpuHasERMS : 0) |
|
||||
((cpu_info7[3] & 0x00000010) ? kCpuHasFSMR : 0);
|
||||
|
||||
// AVX requires OS saves YMM registers.
|
||||
if (((cpu_info1[2] & 0x1c000000) == 0x1c000000) && // AVX and OSXSave
|
||||
((GetXCR0() & 6) == 6)) { // Test OS saves YMM registers
|
||||
cpu_info |= kCpuHasAVX | ((cpu_info7[1] & 0x00000020) ? kCpuHasAVX2 : 0) |
|
||||
((cpu_info1[2] & 0x00001000) ? kCpuHasFMA3 : 0) |
|
||||
((cpu_info1[2] & 0x20000000) ? kCpuHasF16C : 0);
|
||||
((cpu_info1[2] & 0x20000000) ? kCpuHasF16C : 0) |
|
||||
((cpu_einfo7[0] & 0x00000010) ? kCpuHasAVXVNNI : 0) |
|
||||
((cpu_einfo7[3] & 0x00000010) ? kCpuHasAVXVNNIINT8 : 0);
|
||||
|
||||
cpu_info |= ((cpu_amdinfo21[0] & 0x00008000) ? kCpuHasERMS : 0);
|
||||
|
||||
// Detect AVX512bw
|
||||
if ((GetXCR0() & 0xe0) == 0xe0) {
|
||||
cpu_info |= (cpu_info7[1] & 0x40000000) ? kCpuHasAVX512BW : 0;
|
||||
cpu_info |= (cpu_info7[1] & 0x80000000) ? kCpuHasAVX512VL : 0;
|
||||
cpu_info |= (cpu_info7[2] & 0x00000002) ? kCpuHasAVX512VBMI : 0;
|
||||
cpu_info |= (cpu_info7[2] & 0x00000040) ? kCpuHasAVX512VBMI2 : 0;
|
||||
cpu_info |= (cpu_info7[2] & 0x00001000) ? kCpuHasAVX512VBITALG : 0;
|
||||
cpu_info |= (cpu_info7[2] & 0x00004000) ? kCpuHasAVX512VPOPCNTDQ : 0;
|
||||
cpu_info |= (cpu_info7[2] & 0x00000100) ? kCpuHasGFNI : 0;
|
||||
if ((GetXCR0() & 0xe0) == 0xe0 && (cpu_info7[1] & 0x00010000)) {
|
||||
cpu_info |= ((cpu_info7[1] & 0x40000000) ? kCpuHasAVX512BW : 0) |
|
||||
((cpu_info7[1] & 0x80000000) ? kCpuHasAVX512VL : 0) |
|
||||
((cpu_info7[2] & 0x00000002) ? kCpuHasAVX512VBMI : 0) |
|
||||
((cpu_info7[2] & 0x00000040) ? kCpuHasAVX512VBMI2 : 0) |
|
||||
((cpu_info7[2] & 0x00000800) ? kCpuHasAVX512VNNI : 0) |
|
||||
((cpu_info7[2] & 0x00001000) ? kCpuHasAVX512VBITALG : 0) |
|
||||
((cpu_einfo7[3] & 0x00080000) ? kCpuHasAVX10 : 0) |
|
||||
((cpu_info7[3] & 0x02000000) ? kCpuHasAMXINT8 : 0) |
|
||||
((cpu_info21[0] & 0x00800000) ? kCpuHasAVX512BMM : 0) |
|
||||
((cpu_einfo1e[0] & 0x00000040) ? kCpuHasAMXTF32 : 0);
|
||||
if (cpu_info0[0] >= 0x24 && (cpu_einfo7[3] & 0x00080000)) {
|
||||
cpu_info |= ((cpu_info24[1] & 0xFF) >= 2) ? kCpuHasAVX10_2 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(__mips__) && defined(__linux__)
|
||||
#if defined(__mips_msa)
|
||||
cpu_info = MipsCpuCaps("/proc/cpuinfo", " msa");
|
||||
#elif defined(_MIPS_ARCH_LOONGSON3A)
|
||||
cpu_info = MipsCpuCaps("/proc/cpuinfo", " mmi");
|
||||
#endif
|
||||
cpu_info |= kCpuHasMIPS;
|
||||
#endif
|
||||
#if defined(__arm__) || defined(__aarch64__)
|
||||
// gcc -mfpu=neon defines __ARM_NEON__
|
||||
// __ARM_NEON__ generates code that requires Neon. NaCL also requires Neon.
|
||||
// For Linux, /proc/cpuinfo can be tested but without that assume Neon.
|
||||
#if defined(__ARM_NEON__) || defined(__native_client__) || !defined(__linux__)
|
||||
cpu_info = kCpuHasNEON;
|
||||
// For aarch64(arm64), /proc/cpuinfo's feature is not complete, e.g. no neon
|
||||
// flag in it.
|
||||
// So for aarch64, neon enabling is hard coded here.
|
||||
#if defined(__loongarch__) && defined(__linux__)
|
||||
cpu_info = LoongArchCpuCaps();
|
||||
cpu_info |= kCpuHasLOONGARCH;
|
||||
#endif
|
||||
#if defined(__aarch64__)
|
||||
#if defined(__linux__)
|
||||
// getauxval is supported since Android SDK version 18, minimum at time of
|
||||
// writing is 21, so should be safe to always use this. If getauxval is
|
||||
// somehow disabled then getauxval returns 0, which will leave Neon enabled
|
||||
// since Neon is mandatory on AArch64.
|
||||
unsigned long hwcap = getauxval(AT_HWCAP);
|
||||
unsigned long hwcap2 = getauxval(AT_HWCAP2);
|
||||
cpu_info = AArch64CpuCaps(hwcap, hwcap2);
|
||||
#else
|
||||
cpu_info = AArch64CpuCaps();
|
||||
#endif
|
||||
cpu_info |= kCpuHasARM;
|
||||
#endif // __aarch64__
|
||||
#if defined(__arm__)
|
||||
// gcc -mfpu=neon defines __ARM_NEON__
|
||||
// __ARM_NEON__ generates code that requires Neon. NaCL also requires Neon.
|
||||
// For Linux, /proc/cpuinfo can be tested but without that assume Neon.
|
||||
// Linux arm parse text file for neon detect.
|
||||
#if defined(__linux__)
|
||||
cpu_info = ArmCpuCaps("/proc/cpuinfo");
|
||||
#elif defined(__ARM_NEON__)
|
||||
cpu_info = kCpuHasNEON;
|
||||
#else
|
||||
// Linux arm parse text file for neon detect.
|
||||
cpu_info = ArmCpuCaps("/proc/cpuinfo");
|
||||
cpu_info = 0;
|
||||
#endif
|
||||
cpu_info |= kCpuHasARM;
|
||||
#endif // __arm__
|
||||
#if defined(__riscv) && defined(__linux__)
|
||||
cpu_info = RiscvCpuCaps("/proc/cpuinfo");
|
||||
cpu_info |= kCpuHasRISCV;
|
||||
#endif // __riscv
|
||||
#if defined(__wasm__)
|
||||
cpu_info = kCpuHasWASM;
|
||||
#if !defined(LIBYUV_DISABLE_WASM) && defined(__wasm_simd128__)
|
||||
cpu_info |= kCpuHasWASMSIMD;
|
||||
#endif
|
||||
#endif // __wasm__
|
||||
#if defined(__hexagon__)
|
||||
cpu_info = kCpuHasHexagon;
|
||||
#if !defined(LIBYUV_DISABLE_HVX) && defined(__HVX__)
|
||||
cpu_info |= kCpuHasHVX;
|
||||
#endif
|
||||
#endif // __hexagon__
|
||||
cpu_info |= kCpuInitialized;
|
||||
return cpu_info;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
#ifdef HAVE_JPEG
|
||||
#include <assert.h>
|
||||
|
||||
#if !defined(__pnacl__) && !defined(__CLR_VER) && \
|
||||
!defined(COVERAGE_ENABLED) && !defined(TARGET_IPHONE_SIMULATOR)
|
||||
#if !defined(__pnacl__) && !defined(__CLR_VER) && !defined(COVERAGE_ENABLED)
|
||||
// Must be included before jpeglib.
|
||||
#include <setjmp.h>
|
||||
#define HAVE_SETJMP
|
||||
@@ -26,7 +25,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include <stdio.h> // For jpeglib.h.
|
||||
#include <stdio.h> // For jpeglib.h.
|
||||
#include <stdlib.h> // For calloc(), malloc(), and free().
|
||||
|
||||
// C++ build requires extern C for jpeg internals.
|
||||
#ifdef __cplusplus
|
||||
@@ -66,16 +66,17 @@ void ErrorHandler(jpeg_common_struct* cinfo);
|
||||
void OutputHandler(jpeg_common_struct* cinfo);
|
||||
|
||||
MJpegDecoder::MJpegDecoder()
|
||||
: has_scanline_padding_(LIBYUV_FALSE),
|
||||
: has_scanline_padding_(false),
|
||||
num_outbufs_(0),
|
||||
scanlines_(NULL),
|
||||
scanlines_sizes_(NULL),
|
||||
databuf_(NULL),
|
||||
databuf_strides_(NULL) {
|
||||
decompress_struct_ = new jpeg_decompress_struct;
|
||||
source_mgr_ = new jpeg_source_mgr;
|
||||
decompress_struct_ = static_cast<jpeg_decompress_struct*>(
|
||||
malloc(sizeof(jpeg_decompress_struct)));
|
||||
source_mgr_ = static_cast<jpeg_source_mgr*>(malloc(sizeof(jpeg_source_mgr)));
|
||||
#ifdef HAVE_SETJMP
|
||||
error_mgr_ = new SetJmpErrorMgr;
|
||||
error_mgr_ = static_cast<SetJmpErrorMgr*>(malloc(sizeof(SetJmpErrorMgr)));
|
||||
decompress_struct_->err = jpeg_std_error(&error_mgr_->base);
|
||||
// Override standard exit()-based error handler.
|
||||
error_mgr_->base.error_exit = &ErrorHandler;
|
||||
@@ -95,42 +96,45 @@ MJpegDecoder::MJpegDecoder()
|
||||
|
||||
MJpegDecoder::~MJpegDecoder() {
|
||||
jpeg_destroy_decompress(decompress_struct_);
|
||||
delete decompress_struct_;
|
||||
delete source_mgr_;
|
||||
free(decompress_struct_);
|
||||
free(source_mgr_);
|
||||
#ifdef HAVE_SETJMP
|
||||
delete error_mgr_;
|
||||
free(error_mgr_);
|
||||
#endif
|
||||
DestroyOutputBuffers();
|
||||
}
|
||||
|
||||
LIBYUV_BOOL MJpegDecoder::LoadFrame(const uint8_t* src, size_t src_len) {
|
||||
bool MJpegDecoder::LoadFrame(const uint8_t* src, size_t src_len) {
|
||||
if (!ValidateJpeg(src, src_len)) {
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
buf_.data = src;
|
||||
buf_.len = static_cast<int>(src_len);
|
||||
buf_.len = (int)src_len;
|
||||
buf_vec_.pos = 0;
|
||||
decompress_struct_->client_data = &buf_vec_;
|
||||
#ifdef HAVE_SETJMP
|
||||
if (setjmp(error_mgr_->setjmp_buffer)) {
|
||||
// We called jpeg_read_header, it experienced an error, and we called
|
||||
// longjmp() and rewound the stack to here. Return error.
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (jpeg_read_header(decompress_struct_, TRUE) != JPEG_HEADER_OK) {
|
||||
// ERROR: Bad MJPEG header
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
AllocOutputBuffers(GetNumComponents());
|
||||
for (int i = 0; i < num_outbufs_; ++i) {
|
||||
int scanlines_size = GetComponentScanlinesPerImcuRow(i);
|
||||
if (scanlines_sizes_[i] != scanlines_size) {
|
||||
if (scanlines_[i]) {
|
||||
delete scanlines_[i];
|
||||
}
|
||||
scanlines_[i] = new uint8_t*[scanlines_size];
|
||||
// databuf_[i] is sized by scanlines_size * stride, so a change in either
|
||||
// must trigger reallocation below. Remember the change before
|
||||
// scanlines_sizes_[i] is overwritten.
|
||||
bool scanlines_changed = scanlines_sizes_[i] != scanlines_size;
|
||||
if (scanlines_changed) {
|
||||
free(scanlines_[i]);
|
||||
scanlines_[i] =
|
||||
static_cast<uint8_t**>(malloc(scanlines_size * sizeof(uint8_t*)));
|
||||
scanlines_sizes_[i] = scanlines_size;
|
||||
}
|
||||
|
||||
@@ -141,20 +145,23 @@ LIBYUV_BOOL MJpegDecoder::LoadFrame(const uint8_t* src, size_t src_len) {
|
||||
// the next scanline) and will be overwritten when jpeglib writes out that
|
||||
// next scanline.
|
||||
int databuf_stride = GetComponentStride(i);
|
||||
// Cannot overflow:
|
||||
// - JPEG width is stored as an u16, so `databuf_stride` (width rounded up
|
||||
// to
|
||||
// DCTSIZE) is at most slightly larger than UINT16_MAX.
|
||||
// - Sampling factor is stored in 4 bits, so scanlines_size is < 16.
|
||||
int databuf_size = scanlines_size * databuf_stride;
|
||||
if (databuf_strides_[i] != databuf_stride) {
|
||||
if (databuf_[i]) {
|
||||
delete databuf_[i];
|
||||
}
|
||||
databuf_[i] = new uint8_t[databuf_size];
|
||||
if (scanlines_changed || databuf_strides_[i] != databuf_stride) {
|
||||
free(databuf_[i]);
|
||||
databuf_[i] = static_cast<uint8_t*>(malloc(databuf_size));
|
||||
databuf_strides_[i] = databuf_stride;
|
||||
}
|
||||
|
||||
if (GetComponentStride(i) != GetComponentWidth(i)) {
|
||||
has_scanline_padding_ = LIBYUV_TRUE;
|
||||
has_scanline_padding_ = true;
|
||||
}
|
||||
}
|
||||
return LIBYUV_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int DivideAndRoundUp(int numerator, int denominator) {
|
||||
@@ -231,50 +238,52 @@ int MJpegDecoder::GetComponentSize(int component) {
|
||||
return GetComponentWidth(component) * GetComponentHeight(component);
|
||||
}
|
||||
|
||||
LIBYUV_BOOL MJpegDecoder::UnloadFrame() {
|
||||
bool MJpegDecoder::UnloadFrame() {
|
||||
#ifdef HAVE_SETJMP
|
||||
if (setjmp(error_mgr_->setjmp_buffer)) {
|
||||
// We called jpeg_abort_decompress, it experienced an error, and we called
|
||||
// longjmp() and rewound the stack to here. Return error.
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
jpeg_abort_decompress(decompress_struct_);
|
||||
return LIBYUV_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO(fbarchard): Allow rectangle to be specified: x, y, width, height.
|
||||
LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes,
|
||||
int dst_width,
|
||||
int dst_height) {
|
||||
bool MJpegDecoder::DecodeToBuffers(uint8_t** planes,
|
||||
int dst_width,
|
||||
int dst_height) {
|
||||
if (dst_width != GetWidth() || dst_height > GetHeight()) {
|
||||
// ERROR: Bad dimensions
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
#ifdef HAVE_SETJMP
|
||||
if (setjmp(error_mgr_->setjmp_buffer)) {
|
||||
// We called into jpeglib, it experienced an error sometime during this
|
||||
// function call, and we called longjmp() and rewound the stack to here.
|
||||
// Return error.
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (!StartDecode()) {
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
SetScanlinePointers(databuf_);
|
||||
int lines_left = dst_height;
|
||||
// Compute amount of lines to skip to implement vertical crop.
|
||||
// TODO(fbarchard): Ensure skip is a multiple of maximum component
|
||||
// subsample. ie 2
|
||||
// Round skip down to a multiple of the maximum vertical sampling factor so
|
||||
// that every component skips a whole number of rows. The rows remaining
|
||||
// below the crop are still >= dst_height.
|
||||
int skip = (GetHeight() - dst_height) / 2;
|
||||
skip -= skip % decompress_struct_->max_v_samp_factor;
|
||||
if (skip > 0) {
|
||||
// There is no API to skip lines in the output data, so we read them
|
||||
// into the temp buffer.
|
||||
while (skip >= GetImageScanlinesPerImcuRow()) {
|
||||
if (!DecodeImcuRow()) {
|
||||
FinishDecode();
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
skip -= GetImageScanlinesPerImcuRow();
|
||||
}
|
||||
@@ -283,21 +292,25 @@ LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes,
|
||||
// copy the parts we want into the destination.
|
||||
if (!DecodeImcuRow()) {
|
||||
FinishDecode();
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
// Image lines wanted from this iMCU row, clamped to the destination.
|
||||
int image_lines_to_copy = GetImageScanlinesPerImcuRow() - skip;
|
||||
if (image_lines_to_copy > lines_left) {
|
||||
image_lines_to_copy = lines_left;
|
||||
}
|
||||
for (int i = 0; i < num_outbufs_; ++i) {
|
||||
// TODO(fbarchard): Compute skip to avoid this
|
||||
assert(skip % GetVertSubSampFactor(i) == 0);
|
||||
int rows_to_skip = DivideAndRoundDown(skip, GetVertSubSampFactor(i));
|
||||
int scanlines_to_copy =
|
||||
GetComponentScanlinesPerImcuRow(i) - rows_to_skip;
|
||||
DivideAndRoundUp(image_lines_to_copy, GetVertSubSampFactor(i));
|
||||
int data_to_skip = rows_to_skip * GetComponentStride(i);
|
||||
CopyPlane(databuf_[i] + data_to_skip, GetComponentStride(i), planes[i],
|
||||
GetComponentWidth(i), GetComponentWidth(i),
|
||||
scanlines_to_copy);
|
||||
planes[i] += scanlines_to_copy * GetComponentWidth(i);
|
||||
}
|
||||
lines_left -= (GetImageScanlinesPerImcuRow() - skip);
|
||||
lines_left -= image_lines_to_copy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +319,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes,
|
||||
lines_left -= GetImageScanlinesPerImcuRow()) {
|
||||
if (!DecodeImcuRow()) {
|
||||
FinishDecode();
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < num_outbufs_; ++i) {
|
||||
int scanlines_to_copy = GetComponentScanlinesPerImcuRow(i);
|
||||
@@ -320,7 +333,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes,
|
||||
// Have a partial iMCU row left over to decode.
|
||||
if (!DecodeImcuRow()) {
|
||||
FinishDecode();
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < num_outbufs_; ++i) {
|
||||
int scanlines_to_copy =
|
||||
@@ -333,34 +346,38 @@ LIBYUV_BOOL MJpegDecoder::DecodeToBuffers(uint8_t** planes,
|
||||
return FinishDecode();
|
||||
}
|
||||
|
||||
LIBYUV_BOOL MJpegDecoder::DecodeToCallback(CallbackFunction fn,
|
||||
void* opaque,
|
||||
int dst_width,
|
||||
int dst_height) {
|
||||
bool MJpegDecoder::DecodeToCallback(CallbackFunction fn,
|
||||
void* opaque,
|
||||
int dst_width,
|
||||
int dst_height) {
|
||||
if (dst_width != GetWidth() || dst_height > GetHeight()) {
|
||||
// ERROR: Bad dimensions
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
#ifdef HAVE_SETJMP
|
||||
if (setjmp(error_mgr_->setjmp_buffer)) {
|
||||
// We called into jpeglib, it experienced an error sometime during this
|
||||
// function call, and we called longjmp() and rewound the stack to here.
|
||||
// Return error.
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (!StartDecode()) {
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
SetScanlinePointers(databuf_);
|
||||
int lines_left = dst_height;
|
||||
// TODO(fbarchard): Compute amount of lines to skip to implement vertical crop
|
||||
// Compute amount of lines to skip to implement vertical crop.
|
||||
// Round skip down to a multiple of the maximum vertical sampling factor so
|
||||
// that every component skips a whole number of rows. The rows remaining
|
||||
// below the crop are still >= dst_height.
|
||||
int skip = (GetHeight() - dst_height) / 2;
|
||||
skip -= skip % decompress_struct_->max_v_samp_factor;
|
||||
if (skip > 0) {
|
||||
while (skip >= GetImageScanlinesPerImcuRow()) {
|
||||
if (!DecodeImcuRow()) {
|
||||
FinishDecode();
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
skip -= GetImageScanlinesPerImcuRow();
|
||||
}
|
||||
@@ -368,10 +385,9 @@ LIBYUV_BOOL MJpegDecoder::DecodeToCallback(CallbackFunction fn,
|
||||
// Have a partial iMCU row left over to skip.
|
||||
if (!DecodeImcuRow()) {
|
||||
FinishDecode();
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < num_outbufs_; ++i) {
|
||||
// TODO(fbarchard): Compute skip to avoid this
|
||||
assert(skip % GetVertSubSampFactor(i) == 0);
|
||||
int rows_to_skip = DivideAndRoundDown(skip, GetVertSubSampFactor(i));
|
||||
int data_to_skip = rows_to_skip * GetComponentStride(i);
|
||||
@@ -379,7 +395,11 @@ LIBYUV_BOOL MJpegDecoder::DecodeToCallback(CallbackFunction fn,
|
||||
// callback.
|
||||
databuf_[i] += data_to_skip;
|
||||
}
|
||||
// Image lines wanted from this iMCU row, clamped to the destination.
|
||||
int scanlines_to_copy = GetImageScanlinesPerImcuRow() - skip;
|
||||
if (scanlines_to_copy > lines_left) {
|
||||
scanlines_to_copy = lines_left;
|
||||
}
|
||||
(*fn)(opaque, databuf_, databuf_strides_, scanlines_to_copy);
|
||||
// Now change them back.
|
||||
for (int i = 0; i < num_outbufs_; ++i) {
|
||||
@@ -395,7 +415,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToCallback(CallbackFunction fn,
|
||||
lines_left -= GetImageScanlinesPerImcuRow()) {
|
||||
if (!DecodeImcuRow()) {
|
||||
FinishDecode();
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
(*fn)(opaque, databuf_, databuf_strides_, GetImageScanlinesPerImcuRow());
|
||||
}
|
||||
@@ -403,7 +423,7 @@ LIBYUV_BOOL MJpegDecoder::DecodeToCallback(CallbackFunction fn,
|
||||
// Have a partial iMCU row left over to decode.
|
||||
if (!DecodeImcuRow()) {
|
||||
FinishDecode();
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
(*fn)(opaque, databuf_, databuf_strides_, lines_left);
|
||||
}
|
||||
@@ -417,7 +437,6 @@ void init_source(j_decompress_ptr cinfo) {
|
||||
boolean fill_input_buffer(j_decompress_ptr cinfo) {
|
||||
BufferVector* buf_vec = reinterpret_cast<BufferVector*>(cinfo->client_data);
|
||||
if (buf_vec->pos >= buf_vec->len) {
|
||||
assert(0 && "No more data");
|
||||
// ERROR: No more data
|
||||
return FALSE;
|
||||
}
|
||||
@@ -429,7 +448,7 @@ boolean fill_input_buffer(j_decompress_ptr cinfo) {
|
||||
|
||||
void skip_input_data(j_decompress_ptr cinfo, long num_bytes) { // NOLINT
|
||||
jpeg_source_mgr* src = cinfo->src;
|
||||
size_t bytes = static_cast<size_t>(num_bytes);
|
||||
size_t bytes = (size_t)num_bytes;
|
||||
if (bytes > src->bytes_in_buffer) {
|
||||
src->next_input_byte = nullptr;
|
||||
src->bytes_in_buffer = 0;
|
||||
@@ -478,17 +497,11 @@ void MJpegDecoder::AllocOutputBuffers(int num_outbufs) {
|
||||
// it.
|
||||
DestroyOutputBuffers();
|
||||
|
||||
scanlines_ = new uint8_t**[num_outbufs];
|
||||
scanlines_sizes_ = new int[num_outbufs];
|
||||
databuf_ = new uint8_t*[num_outbufs];
|
||||
databuf_strides_ = new int[num_outbufs];
|
||||
|
||||
for (int i = 0; i < num_outbufs; ++i) {
|
||||
scanlines_[i] = NULL;
|
||||
scanlines_sizes_[i] = 0;
|
||||
databuf_[i] = NULL;
|
||||
databuf_strides_[i] = 0;
|
||||
}
|
||||
scanlines_ =
|
||||
static_cast<uint8_t***>(calloc(num_outbufs, sizeof(uint8_t**)));
|
||||
scanlines_sizes_ = static_cast<int*>(calloc(num_outbufs, sizeof(int)));
|
||||
databuf_ = static_cast<uint8_t**>(calloc(num_outbufs, sizeof(uint8_t*)));
|
||||
databuf_strides_ = static_cast<int*>(calloc(num_outbufs, sizeof(int)));
|
||||
|
||||
num_outbufs_ = num_outbufs;
|
||||
}
|
||||
@@ -496,13 +509,13 @@ void MJpegDecoder::AllocOutputBuffers(int num_outbufs) {
|
||||
|
||||
void MJpegDecoder::DestroyOutputBuffers() {
|
||||
for (int i = 0; i < num_outbufs_; ++i) {
|
||||
delete[] scanlines_[i];
|
||||
delete[] databuf_[i];
|
||||
free(scanlines_[i]);
|
||||
free(databuf_[i]);
|
||||
}
|
||||
delete[] scanlines_;
|
||||
delete[] databuf_;
|
||||
delete[] scanlines_sizes_;
|
||||
delete[] databuf_strides_;
|
||||
free(scanlines_);
|
||||
free(databuf_);
|
||||
free(scanlines_sizes_);
|
||||
free(databuf_strides_);
|
||||
scanlines_ = NULL;
|
||||
databuf_ = NULL;
|
||||
scanlines_sizes_ = NULL;
|
||||
@@ -511,29 +524,29 @@ void MJpegDecoder::DestroyOutputBuffers() {
|
||||
}
|
||||
|
||||
// JDCT_IFAST and do_block_smoothing improve performance substantially.
|
||||
LIBYUV_BOOL MJpegDecoder::StartDecode() {
|
||||
bool MJpegDecoder::StartDecode() {
|
||||
decompress_struct_->raw_data_out = TRUE;
|
||||
decompress_struct_->dct_method = JDCT_IFAST; // JDCT_ISLOW is default
|
||||
decompress_struct_->dither_mode = JDITHER_NONE;
|
||||
// Not applicable to 'raw':
|
||||
decompress_struct_->do_fancy_upsampling = (boolean)(LIBYUV_FALSE);
|
||||
decompress_struct_->do_fancy_upsampling = (boolean)(0);
|
||||
// Only for buffered mode:
|
||||
decompress_struct_->enable_2pass_quant = (boolean)(LIBYUV_FALSE);
|
||||
decompress_struct_->enable_2pass_quant = (boolean)(0);
|
||||
// Blocky but fast:
|
||||
decompress_struct_->do_block_smoothing = (boolean)(LIBYUV_FALSE);
|
||||
decompress_struct_->do_block_smoothing = (boolean)(0);
|
||||
|
||||
if (!jpeg_start_decompress(decompress_struct_)) {
|
||||
// ERROR: Couldn't start JPEG decompressor";
|
||||
return LIBYUV_FALSE;
|
||||
return false;
|
||||
}
|
||||
return LIBYUV_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
LIBYUV_BOOL MJpegDecoder::FinishDecode() {
|
||||
bool MJpegDecoder::FinishDecode() {
|
||||
// jpeglib considers it an error if we finish without decoding the whole
|
||||
// image, so we call "abort" rather than "finish".
|
||||
jpeg_abort_decompress(decompress_struct_);
|
||||
return LIBYUV_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MJpegDecoder::SetScanlinePointers(uint8_t** data) {
|
||||
@@ -546,7 +559,7 @@ void MJpegDecoder::SetScanlinePointers(uint8_t** data) {
|
||||
}
|
||||
}
|
||||
|
||||
inline LIBYUV_BOOL MJpegDecoder::DecodeImcuRow() {
|
||||
inline bool MJpegDecoder::DecodeImcuRow() {
|
||||
return (unsigned int)(GetImageScanlinesPerImcuRow()) ==
|
||||
jpeg_read_raw_data(decompress_struct_, scanlines_,
|
||||
GetImageScanlinesPerImcuRow());
|
||||
|
||||
@@ -18,7 +18,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Helper function to scan for EOI marker (0xff 0xd9).
|
||||
static LIBYUV_BOOL ScanEOI(const uint8_t* src_mjpg, size_t src_size_mjpg) {
|
||||
static int ScanEOI(const uint8_t* src_mjpg, size_t src_size_mjpg) {
|
||||
if (src_size_mjpg >= 2) {
|
||||
const uint8_t* end = src_mjpg + src_size_mjpg - 1;
|
||||
const uint8_t* it = src_mjpg;
|
||||
@@ -29,34 +29,34 @@ static LIBYUV_BOOL ScanEOI(const uint8_t* src_mjpg, size_t src_size_mjpg) {
|
||||
break;
|
||||
}
|
||||
if (it[1] == 0xd9) {
|
||||
return LIBYUV_TRUE; // Success: Valid jpeg.
|
||||
return 1; // Success: Valid jpeg.
|
||||
}
|
||||
++it; // Skip over current 0xff.
|
||||
}
|
||||
}
|
||||
// ERROR: Invalid jpeg end code not found. Size src_size_mjpg
|
||||
return LIBYUV_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Helper function to validate the jpeg appears intact.
|
||||
LIBYUV_BOOL ValidateJpeg(const uint8_t* src_mjpg, size_t src_size_mjpg) {
|
||||
int ValidateJpeg(const uint8_t* src_mjpg, size_t src_size_mjpg) {
|
||||
// Maximum size that ValidateJpeg will consider valid.
|
||||
const size_t kMaxJpegSize = 0x7fffffffull;
|
||||
const size_t kBackSearchSize = 1024;
|
||||
if (src_size_mjpg < 64 || src_size_mjpg > kMaxJpegSize || !src_mjpg) {
|
||||
// ERROR: Invalid jpeg size: src_size_mjpg
|
||||
return LIBYUV_FALSE;
|
||||
return 0;
|
||||
}
|
||||
// SOI marker
|
||||
if (src_mjpg[0] != 0xff || src_mjpg[1] != 0xd8 || src_mjpg[2] != 0xff) {
|
||||
// ERROR: Invalid jpeg initial start code
|
||||
return LIBYUV_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Look for the End Of Image (EOI) marker near the end of the buffer.
|
||||
if (src_size_mjpg > kBackSearchSize) {
|
||||
if (ScanEOI(src_mjpg + src_size_mjpg - kBackSearchSize, kBackSearchSize)) {
|
||||
return LIBYUV_TRUE; // Success: Valid jpeg.
|
||||
return 1; // Success: Valid jpeg.
|
||||
}
|
||||
// Reduce search size for forward search.
|
||||
src_size_mjpg = src_size_mjpg - kBackSearchSize + 1;
|
||||
|
||||
+4050
-918
File diff suppressed because it is too large.
Load diff
+1108
-164
File diff suppressed because it is too large.
Load diff
@@ -11,42 +11,50 @@
|
||||
#include "libyuv/rotate.h"
|
||||
#include "libyuv/rotate_row.h"
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TANY(NAMEANY, TPOS_SIMD, MASK) \
|
||||
void NAMEANY(const uint8_t* src, int src_stride, uint8_t* dst, \
|
||||
int dst_stride, int width) { \
|
||||
int r = width & MASK; \
|
||||
int n = width - r; \
|
||||
if (n > 0) { \
|
||||
TPOS_SIMD(src, src_stride, dst, dst_stride, n); \
|
||||
} \
|
||||
TransposeWx8_C(src + n, src_stride, dst + n * dst_stride, dst_stride, r); \
|
||||
#define TANY(NAMEANY, TPOS_SIMD, TPOS_C, MASK) \
|
||||
void NAMEANY(const uint8_t* src, int src_stride, uint8_t* dst, \
|
||||
int dst_stride, int width) { \
|
||||
int r = width & MASK; \
|
||||
int n = width - r; \
|
||||
if (n > 0) { \
|
||||
TPOS_SIMD(src, src_stride, dst, dst_stride, n); \
|
||||
} \
|
||||
ptrdiff_t np = n; \
|
||||
TPOS_C(src + np, src_stride, dst + np * dst_stride, dst_stride, r); \
|
||||
}
|
||||
|
||||
#ifdef HAS_TRANSPOSEWX8_NEON
|
||||
TANY(TransposeWx8_Any_NEON, TransposeWx8_NEON, 7)
|
||||
TANY(TransposeWx8_Any_NEON, TransposeWx8_NEON, TransposeWx8_C, 7)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX8_SSSE3
|
||||
TANY(TransposeWx8_Any_SSSE3, TransposeWx8_SSSE3, 7)
|
||||
#ifdef HAS_TRANSPOSEWX16_NEON
|
||||
TANY(TransposeWx16_Any_NEON, TransposeWx16_NEON, TransposeWx16_C, 15)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX8_MMI
|
||||
TANY(TransposeWx8_Any_MMI, TransposeWx8_MMI, 7)
|
||||
#ifdef HAS_TRANSPOSEWX8_AVX2
|
||||
TANY(TransposeWx8_Any_AVX2, TransposeWx8_AVX2, TransposeWx8_C, 15)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX8_FAST_SSSE3
|
||||
TANY(TransposeWx8_Fast_Any_SSSE3, TransposeWx8_Fast_SSSE3, 15)
|
||||
#ifdef HAS_TRANSPOSEWX16_AVX2
|
||||
TANY(TransposeWx16_Any_AVX2, TransposeWx16_AVX2, TransposeWx16_C, 15)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX16_MSA
|
||||
TANY(TransposeWx16_Any_MSA, TransposeWx16_MSA, 15)
|
||||
#ifdef HAS_TRANSPOSEWX8_LSX
|
||||
TANY(TransposeWx8_Any_LSX, TransposeWx8_LSX, TransposeWx8_C, 15)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX16_LASX
|
||||
TANY(TransposeWx16_Any_LASX, TransposeWx16_LASX, TransposeWx16_C, 15)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX8_WASMSIMD
|
||||
TANY(TransposeWx8_Any_WASMSIMD, TransposeWx8_WASMSIMD, TransposeWx8_C, 15)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX16_WASMSIMD
|
||||
TANY(TransposeWx16_Any_WASMSIMD, TransposeWx16_WASMSIMD, TransposeWx16_C, 15)
|
||||
#endif
|
||||
#undef TANY
|
||||
|
||||
#define TUVANY(NAMEANY, TPOS_SIMD, MASK) \
|
||||
#define TUVANY(NAMEANY, TPOS_SIMD, TPOS_C, MASK) \
|
||||
void NAMEANY(const uint8_t* src, int src_stride, uint8_t* dst_a, \
|
||||
int dst_stride_a, uint8_t* dst_b, int dst_stride_b, \
|
||||
int width) { \
|
||||
@@ -55,24 +63,126 @@ TANY(TransposeWx16_Any_MSA, TransposeWx16_MSA, 15)
|
||||
if (n > 0) { \
|
||||
TPOS_SIMD(src, src_stride, dst_a, dst_stride_a, dst_b, dst_stride_b, n); \
|
||||
} \
|
||||
TransposeUVWx8_C(src + n * 2, src_stride, dst_a + n * dst_stride_a, \
|
||||
dst_stride_a, dst_b + n * dst_stride_b, dst_stride_b, r); \
|
||||
ptrdiff_t np = n; \
|
||||
TPOS_C(src + np * 2, src_stride, dst_a + np * dst_stride_a, dst_stride_a, \
|
||||
dst_b + np * dst_stride_b, dst_stride_b, r); \
|
||||
}
|
||||
|
||||
#ifdef HAS_TRANSPOSEUVWX8_NEON
|
||||
TUVANY(TransposeUVWx8_Any_NEON, TransposeUVWx8_NEON, 7)
|
||||
TUVANY(TransposeUVWx8_Any_NEON, TransposeUVWx8_NEON, TransposeUVWx8_C, 7)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEUVWX8_SSE2
|
||||
TUVANY(TransposeUVWx8_Any_SSE2, TransposeUVWx8_SSE2, 7)
|
||||
#ifdef HAS_TRANSPOSEUVWX8_AVX2
|
||||
TUVANY(TransposeUVWx8_Any_AVX2, TransposeUVWx8_AVX2, TransposeUVWx8_C, 7)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEUVWX8_MMI
|
||||
TUVANY(TransposeUVWx8_Any_MMI, TransposeUVWx8_MMI, 7)
|
||||
#ifdef HAS_TRANSPOSEUVWX16_AVX2
|
||||
TUVANY(TransposeUVWx16_Any_AVX2, TransposeUVWx16_AVX2, TransposeUVWx16_C, 7)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEUVWX16_MSA
|
||||
TUVANY(TransposeUVWx16_Any_MSA, TransposeUVWx16_MSA, 7)
|
||||
#ifdef HAS_TRANSPOSEUVWX8_LSX
|
||||
TUVANY(TransposeUVWx8_Any_LSX, TransposeUVWx8_LSX, TransposeUVWx8_C, 7)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEUVWX16_LASX
|
||||
TUVANY(TransposeUVWx16_Any_LASX, TransposeUVWx16_LASX, TransposeUVWx16_C, 7)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEUVWX8_WASMSIMD
|
||||
TUVANY(TransposeUVWx8_Any_WASMSIMD,
|
||||
TransposeUVWx8_WASMSIMD,
|
||||
TransposeUVWx8_C,
|
||||
7)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEUVWX16_WASMSIMD
|
||||
TUVANY(TransposeUVWx16_Any_WASMSIMD,
|
||||
TransposeUVWx16_WASMSIMD,
|
||||
TransposeUVWx16_C,
|
||||
7)
|
||||
#endif
|
||||
#undef TUVANY
|
||||
|
||||
#define TANY32(NAMEANY, TPOS_SIMD, TPOS_C, MASK) \
|
||||
void NAMEANY(const uint8_t* src, int src_stride, uint8_t* dst, \
|
||||
int dst_stride, int width) { \
|
||||
int r = width & MASK; \
|
||||
int n = width - r; \
|
||||
if (n > 0) { \
|
||||
TPOS_SIMD(src, src_stride, dst, dst_stride, n); \
|
||||
} \
|
||||
if (r > 0) { \
|
||||
TPOS_C(src + (ptrdiff_t)n * src_stride, src_stride, \
|
||||
dst + (ptrdiff_t)n * 4, dst_stride, 4, r); \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef HAS_TRANSPOSEWX4_32_AVX2
|
||||
TANY32(TransposeWx4_32_Any_AVX2, TransposeWx4_32_AVX2, TransposeWxH_32_C, 3)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX4_32_LSX
|
||||
TANY32(TransposeWx4_32_Any_LSX, TransposeWx4_32_LSX, TransposeWxH_32_C, 3)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX4_32_LASX
|
||||
TANY32(TransposeWx4_32_Any_LASX, TransposeWx4_32_LASX, TransposeWxH_32_C, 7)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX4_32_WASMSIMD
|
||||
TANY32(TransposeWx4_32_Any_WASMSIMD,
|
||||
TransposeWx4_32_WASMSIMD,
|
||||
TransposeWxH_32_C,
|
||||
3)
|
||||
#endif
|
||||
#undef TANY32
|
||||
|
||||
#define TANY32_SRC(NAMEANY, TPOS_SIMD, MASK, HEIGHT) \
|
||||
void NAMEANY(const uint8_t* src, int src_stride, uint8_t* dst, \
|
||||
int dst_stride, int width) { \
|
||||
int r = width & MASK; \
|
||||
int n = width - r; \
|
||||
if (n > 0) { \
|
||||
TPOS_SIMD(src, src_stride, dst, dst_stride, n); \
|
||||
} \
|
||||
ptrdiff_t np = n; \
|
||||
TransposeWxH_32_C(src + np * 4, src_stride, dst + np * dst_stride, \
|
||||
dst_stride, r, HEIGHT); \
|
||||
}
|
||||
|
||||
#ifdef HAS_TRANSPOSEWX8_32_AVX2
|
||||
TANY32_SRC(TransposeWx8_32_Any_AVX2, TransposeWx8_32_AVX2, 3, 8)
|
||||
#endif
|
||||
#undef TANY32_SRC
|
||||
|
||||
#define TANY16(NAMEANY, TPOS_SIMD, MASK, HEIGHT) \
|
||||
void NAMEANY(const uint16_t* src, int src_stride, uint16_t* dst, \
|
||||
int dst_stride, int width) { \
|
||||
int r = width & MASK; \
|
||||
int n = width - r; \
|
||||
if (n > 0) { \
|
||||
TPOS_SIMD(src, src_stride, dst, dst_stride, n); \
|
||||
} \
|
||||
ptrdiff_t np = n; \
|
||||
TransposeWx8_16_C(src + np, src_stride, dst + np * dst_stride, dst_stride, \
|
||||
r); \
|
||||
if ((HEIGHT) == 16) { \
|
||||
TransposeWx8_16_C(src + np + 8 * src_stride, src_stride, \
|
||||
dst + np * dst_stride + 8, dst_stride, r); \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef HAS_TRANSPOSEWX8_16_NEON
|
||||
TANY16(TransposeWx8_16_Any_NEON, TransposeWx8_16_NEON, 7, 8)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX8_16_AVX2
|
||||
TANY16(TransposeWx8_16_Any_AVX2, TransposeWx8_16_AVX2, 7, 8)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX16_16_AVX2
|
||||
TANY16(TransposeWx16_16_Any_AVX2, TransposeWx16_16_AVX2, 7, 16)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX8_16_LSX
|
||||
TANY16(TransposeWx8_16_Any_LSX, TransposeWx8_16_LSX, 7, 8)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX16_16_LASX
|
||||
TANY16(TransposeWx16_16_Any_LASX, TransposeWx16_16_LASX, 7, 16)
|
||||
#endif
|
||||
#ifdef HAS_TRANSPOSEWX8_16_WASMSIMD
|
||||
TANY16(TransposeWx8_16_Any_WASMSIMD, TransposeWx8_16_WASMSIMD, 7, 8)
|
||||
#endif
|
||||
#undef TANY16
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
} // namespace libyuv
|
||||
|
||||
Loaded 100 of 211 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user