diff --git a/all.gyp b/all.gyp index 88a748427..cc72d9d6f 100644 --- a/all.gyp +++ b/all.gyp @@ -1,21 +1,21 @@ -# Copyright 2013 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. - -# all.gyp and All target are for benefit of android gyp build. -{ - 'targets': [ - { - 'target_name': 'All', - 'type': 'none', - 'dependencies': [ - 'libyuv.gyp:*', - 'libyuv_test.gyp:*', - ], - }, - ], -} +# Copyright 2013 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. + +# all.gyp and All target are for benefit of android gyp build. +{ + 'targets': [ + { + 'target_name': 'All', + 'type': 'none', + 'dependencies': [ + 'libyuv.gyp:*', + 'libyuv_test.gyp:*', + ], + }, + ], +} diff --git a/public.mk b/public.mk index 090d8cb65..1342307a5 100644 --- a/public.mk +++ b/public.mk @@ -1,13 +1,13 @@ -# This file contains all the common make variables which are useful for -# anyone depending on this library. -# Note that dependencies on NDK are not directly listed since NDK auto adds -# them. - -LIBYUV_INCLUDES := $(LIBYUV_PATH)/include - -LIBYUV_C_FLAGS := - -LIBYUV_CPP_FLAGS := - -LIBYUV_LDLIBS := -LIBYUV_DEP_MODULES := +# This file contains all the common make variables which are useful for +# anyone depending on this library. +# Note that dependencies on NDK are not directly listed since NDK auto adds +# them. + +LIBYUV_INCLUDES := $(LIBYUV_PATH)/include + +LIBYUV_C_FLAGS := + +LIBYUV_CPP_FLAGS := + +LIBYUV_LDLIBS := +LIBYUV_DEP_MODULES := diff --git a/source/compare_msa.cc b/source/compare_msa.cc index e944235f0..0b807d37b 100644 --- a/source/compare_msa.cc +++ b/source/compare_msa.cc @@ -1,97 +1,97 @@ -/* - * 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) +/* + * 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) diff --git a/tools_libyuv/valgrind/libyuv_tests.bat b/tools_libyuv/valgrind/libyuv_tests.bat index e37f09eb2..5fceca676 100644 --- a/tools_libyuv/valgrind/libyuv_tests.bat +++ b/tools_libyuv/valgrind/libyuv_tests.bat @@ -1,79 +1,79 @@ -@echo off -:: Copyright (c) 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. - -:: This script is a copy of chrome_tests.bat with the following changes: -:: - Invokes libyuv_tests.py instead of chrome_tests.py -:: - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make -:: it possible to execute the Python scripts properly. - -:: TODO(timurrrr): batch files 'export' all the variables to the parent shell -set THISDIR=%~dp0 -set TOOL_NAME="unknown" - -:: Get the tool name and put it into TOOL_NAME {{{1 -:: NB: SHIFT command doesn't modify %* -:PARSE_ARGS_LOOP - if %1 == () GOTO:TOOLNAME_NOT_FOUND - if %1 == --tool GOTO:TOOLNAME_FOUND - SHIFT - goto :PARSE_ARGS_LOOP - -:TOOLNAME_NOT_FOUND -echo "Please specify a tool (tsan or drmemory) by using --tool flag" -exit /B 1 - -:TOOLNAME_FOUND -SHIFT -set TOOL_NAME=%1 -:: }}} -if "%TOOL_NAME%" == "drmemory" GOTO :SETUP_DRMEMORY -if "%TOOL_NAME%" == "drmemory_light" GOTO :SETUP_DRMEMORY -if "%TOOL_NAME%" == "drmemory_full" GOTO :SETUP_DRMEMORY -if "%TOOL_NAME%" == "drmemory_pattern" GOTO :SETUP_DRMEMORY -if "%TOOL_NAME%" == "tsan" GOTO :SETUP_TSAN -echo "Unknown tool: `%TOOL_NAME%`! Only tsan and drmemory are supported." -exit /B 1 - -:SETUP_DRMEMORY -if NOT "%DRMEMORY_COMMAND%"=="" GOTO :RUN_TESTS -:: Set up DRMEMORY_COMMAND to invoke Dr. Memory {{{1 -set DRMEMORY_PATH=%THISDIR%..\..\third_party\drmemory -set DRMEMORY_SFX=%DRMEMORY_PATH%\drmemory-windows-sfx.exe -if EXIST %DRMEMORY_SFX% GOTO DRMEMORY_BINARY_OK -echo "Can't find Dr. Memory executables." -echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory" -echo "for the instructions on how to get them." -exit /B 1 - -:DRMEMORY_BINARY_OK -%DRMEMORY_SFX% -o%DRMEMORY_PATH%\unpacked -y -set DRMEMORY_COMMAND=%DRMEMORY_PATH%\unpacked\bin\drmemory.exe -:: }}} -goto :RUN_TESTS - -:SETUP_TSAN -:: Set up PIN_COMMAND to invoke TSan {{{1 -set TSAN_PATH=%THISDIR%..\..\third_party\tsan -set TSAN_SFX=%TSAN_PATH%\tsan-x86-windows-sfx.exe -if EXIST %TSAN_SFX% GOTO TSAN_BINARY_OK -echo "Can't find ThreadSanitizer executables." -echo "See http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/threadsanitizer-on-windows" -echo "for the instructions on how to get them." -exit /B 1 - -:TSAN_BINARY_OK -%TSAN_SFX% -o%TSAN_PATH%\unpacked -y -set PIN_COMMAND=%TSAN_PATH%\unpacked\tsan-x86-windows\tsan.bat -:: }}} -goto :RUN_TESTS - -:RUN_TESTS -set PYTHONPATH=%THISDIR%..\python\google;%THISDIR%..\valgrind -set RUNNING_ON_VALGRIND=yes -python %THISDIR%libyuv_tests.py %* +@echo off +:: Copyright (c) 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. + +:: This script is a copy of chrome_tests.bat with the following changes: +:: - Invokes libyuv_tests.py instead of chrome_tests.py +:: - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make +:: it possible to execute the Python scripts properly. + +:: TODO(timurrrr): batch files 'export' all the variables to the parent shell +set THISDIR=%~dp0 +set TOOL_NAME="unknown" + +:: Get the tool name and put it into TOOL_NAME {{{1 +:: NB: SHIFT command doesn't modify %* +:PARSE_ARGS_LOOP + if %1 == () GOTO:TOOLNAME_NOT_FOUND + if %1 == --tool GOTO:TOOLNAME_FOUND + SHIFT + goto :PARSE_ARGS_LOOP + +:TOOLNAME_NOT_FOUND +echo "Please specify a tool (tsan or drmemory) by using --tool flag" +exit /B 1 + +:TOOLNAME_FOUND +SHIFT +set TOOL_NAME=%1 +:: }}} +if "%TOOL_NAME%" == "drmemory" GOTO :SETUP_DRMEMORY +if "%TOOL_NAME%" == "drmemory_light" GOTO :SETUP_DRMEMORY +if "%TOOL_NAME%" == "drmemory_full" GOTO :SETUP_DRMEMORY +if "%TOOL_NAME%" == "drmemory_pattern" GOTO :SETUP_DRMEMORY +if "%TOOL_NAME%" == "tsan" GOTO :SETUP_TSAN +echo "Unknown tool: `%TOOL_NAME%`! Only tsan and drmemory are supported." +exit /B 1 + +:SETUP_DRMEMORY +if NOT "%DRMEMORY_COMMAND%"=="" GOTO :RUN_TESTS +:: Set up DRMEMORY_COMMAND to invoke Dr. Memory {{{1 +set DRMEMORY_PATH=%THISDIR%..\..\third_party\drmemory +set DRMEMORY_SFX=%DRMEMORY_PATH%\drmemory-windows-sfx.exe +if EXIST %DRMEMORY_SFX% GOTO DRMEMORY_BINARY_OK +echo "Can't find Dr. Memory executables." +echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory" +echo "for the instructions on how to get them." +exit /B 1 + +:DRMEMORY_BINARY_OK +%DRMEMORY_SFX% -o%DRMEMORY_PATH%\unpacked -y +set DRMEMORY_COMMAND=%DRMEMORY_PATH%\unpacked\bin\drmemory.exe +:: }}} +goto :RUN_TESTS + +:SETUP_TSAN +:: Set up PIN_COMMAND to invoke TSan {{{1 +set TSAN_PATH=%THISDIR%..\..\third_party\tsan +set TSAN_SFX=%TSAN_PATH%\tsan-x86-windows-sfx.exe +if EXIST %TSAN_SFX% GOTO TSAN_BINARY_OK +echo "Can't find ThreadSanitizer executables." +echo "See http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/threadsanitizer-on-windows" +echo "for the instructions on how to get them." +exit /B 1 + +:TSAN_BINARY_OK +%TSAN_SFX% -o%TSAN_PATH%\unpacked -y +set PIN_COMMAND=%TSAN_PATH%\unpacked\tsan-x86-windows\tsan.bat +:: }}} +goto :RUN_TESTS + +:RUN_TESTS +set PYTHONPATH=%THISDIR%..\python\google;%THISDIR%..\valgrind +set RUNNING_ON_VALGRIND=yes +python %THISDIR%libyuv_tests.py %* diff --git a/unit_test/testdata/juno.txt b/unit_test/testdata/juno.txt index c275be742..dd465272b 100644 --- a/unit_test/testdata/juno.txt +++ b/unit_test/testdata/juno.txt @@ -1,15 +1,15 @@ -Processor : AArch64 Processor rev 0 (aarch64) -processor : 0 -processor : 1 -processor : 2 -processor : 3 -processor : 4 -processor : 5 -Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 -CPU implementer : 0x41 -CPU architecture: AArch64 -CPU variant : 0x0 -CPU part : 0xd07 -CPU revision : 0 - -Hardware : Juno +Processor : AArch64 Processor rev 0 (aarch64) +processor : 0 +processor : 1 +processor : 2 +processor : 3 +processor : 4 +processor : 5 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 +CPU implementer : 0x41 +CPU architecture: AArch64 +CPU variant : 0x0 +CPU part : 0xd07 +CPU revision : 0 + +Hardware : Juno