├── .editorconfig ├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ ├── assign_author.yml │ ├── build.yml │ ├── close_inactive_issues.yml │ └── update-gradle-wrapper.yml ├── .gitignore ├── .idea └── findbugs-idea.xml ├── LICENSE ├── LICENSE_LIBYUV.txt ├── PATENTS_LIBYUV.txt ├── README.md ├── VERSIONS ├── build.gradle.kts ├── bumpver.toml ├── commitlint.config.cjs ├── config └── detekt.yml ├── core ├── .gitignore ├── Android.mk ├── Application.mk ├── build.gradle.kts ├── consumer-proguard-rules.pro ├── deps │ ├── .gitignore │ └── libyuv │ │ ├── .clang-format │ │ ├── .gitignore │ │ ├── .gn │ │ ├── .vpython3 │ │ ├── AUTHORS │ │ ├── Android.bp │ │ ├── Android.mk │ │ ├── BUILD.gn │ │ ├── CM_linux_packages.cmake │ │ ├── CMakeLists.txt │ │ ├── DEPS │ │ ├── DIR_METADATA │ │ ├── LICENSE │ │ ├── OWNERS │ │ ├── PATENTS │ │ ├── PRESUBMIT.py │ │ ├── README.chromium │ │ ├── README.md │ │ ├── build_overrides │ │ ├── build.gni │ │ ├── gtest.gni │ │ └── partition_alloc.gni │ │ ├── codereview.settings │ │ ├── docs │ │ ├── deprecated_builds.md │ │ ├── environment_variables.md │ │ ├── feature_detection.md │ │ ├── filtering.md │ │ ├── formats.md │ │ ├── getting_started.md │ │ └── rotation.md │ │ ├── download_vs_toolchain.py │ │ ├── include │ │ ├── libyuv.h │ │ └── libyuv │ │ │ ├── basic_types.h │ │ │ ├── compare.h │ │ │ ├── compare_row.h │ │ │ ├── convert.h │ │ │ ├── convert_argb.h │ │ │ ├── convert_from.h │ │ │ ├── convert_from_argb.h │ │ │ ├── cpu_id.h │ │ │ ├── cpu_support.h │ │ │ ├── loongson_intrinsics.h │ │ │ ├── macros_msa.h │ │ │ ├── mjpeg_decoder.h │ │ │ ├── planar_functions.h │ │ │ ├── rotate.h │ │ │ ├── rotate_argb.h │ │ │ ├── rotate_row.h │ │ │ ├── row.h │ │ │ ├── row_sve.h │ │ │ ├── scale.h │ │ │ ├── scale_argb.h │ │ │ ├── scale_rgb.h │ │ │ ├── scale_row.h │ │ │ ├── scale_uv.h │ │ │ ├── version.h │ │ │ └── video_common.h │ │ ├── infra │ │ └── config │ │ │ ├── OWNERS │ │ │ ├── PRESUBMIT.py │ │ │ ├── README.md │ │ │ ├── codereview.settings │ │ │ ├── commit-queue.cfg │ │ │ ├── cr-buildbucket.cfg │ │ │ ├── luci-logdog.cfg │ │ │ ├── luci-milo.cfg │ │ │ ├── luci-scheduler.cfg │ │ │ ├── main.star │ │ │ ├── project.cfg │ │ │ └── realms.cfg │ │ ├── libyuv.gni │ │ ├── libyuv.gyp │ │ ├── libyuv.gypi │ │ ├── linux.mk │ │ ├── public.mk │ │ ├── pylintrc │ │ ├── riscv_script │ │ ├── prepare_toolchain_qemu.sh │ │ ├── riscv-clang.cmake │ │ └── run_qemu.sh │ │ ├── source │ │ ├── compare.cc │ │ ├── compare_common.cc │ │ ├── compare_gcc.cc │ │ ├── compare_msa.cc │ │ ├── compare_neon.cc │ │ ├── compare_neon64.cc │ │ ├── compare_win.cc │ │ ├── convert.cc │ │ ├── convert_argb.cc │ │ ├── convert_from.cc │ │ ├── convert_from_argb.cc │ │ ├── convert_jpeg.cc │ │ ├── convert_to_argb.cc │ │ ├── convert_to_i420.cc │ │ ├── cpu_id.cc │ │ ├── mjpeg_decoder.cc │ │ ├── mjpeg_validate.cc │ │ ├── planar_functions.cc │ │ ├── rotate.cc │ │ ├── rotate_any.cc │ │ ├── rotate_argb.cc │ │ ├── rotate_common.cc │ │ ├── rotate_gcc.cc │ │ ├── rotate_lsx.cc │ │ ├── rotate_msa.cc │ │ ├── rotate_neon.cc │ │ ├── rotate_neon64.cc │ │ ├── rotate_sme.cc │ │ ├── rotate_win.cc │ │ ├── row_any.cc │ │ ├── row_common.cc │ │ ├── row_gcc.cc │ │ ├── row_lasx.cc │ │ ├── row_lsx.cc │ │ ├── row_msa.cc │ │ ├── row_neon.cc │ │ ├── row_neon64.cc │ │ ├── row_rvv.cc │ │ ├── row_sme.cc │ │ ├── row_sve.cc │ │ ├── row_win.cc │ │ ├── scale.cc │ │ ├── scale_any.cc │ │ ├── scale_argb.cc │ │ ├── scale_common.cc │ │ ├── scale_gcc.cc │ │ ├── scale_lsx.cc │ │ ├── scale_msa.cc │ │ ├── scale_neon.cc │ │ ├── scale_neon64.cc │ │ ├── scale_rgb.cc │ │ ├── scale_rvv.cc │ │ ├── scale_sme.cc │ │ ├── scale_uv.cc │ │ ├── scale_win.cc │ │ ├── test.sh │ │ └── video_common.cc │ │ ├── tools_libyuv │ │ ├── OWNERS │ │ ├── autoroller │ │ │ ├── roll_deps.py │ │ │ └── unittests │ │ │ │ ├── roll_deps_test.py │ │ │ │ └── testdata │ │ │ │ ├── DEPS │ │ │ │ ├── DEPS.chromium.new │ │ │ │ └── DEPS.chromium.old │ │ ├── get_landmines.py │ │ ├── msan │ │ │ ├── OWNERS │ │ │ └── blacklist.txt │ │ └── ubsan │ │ │ ├── OWNERS │ │ │ ├── blacklist.txt │ │ │ └── vptr_blacklist.txt │ │ ├── unit_test │ │ ├── basictypes_test.cc │ │ ├── color_test.cc │ │ ├── compare_test.cc │ │ ├── convert_argb_test.cc │ │ ├── convert_test.cc │ │ ├── cpu_test.cc │ │ ├── cpu_thread_test.cc │ │ ├── math_test.cc │ │ ├── planar_test.cc │ │ ├── rotate_argb_test.cc │ │ ├── rotate_test.cc │ │ ├── scale_argb_test.cc │ │ ├── scale_plane_test.cc │ │ ├── scale_rgb_test.cc │ │ ├── scale_test.cc │ │ ├── scale_uv_test.cc │ │ ├── testdata │ │ │ ├── arm_v7.txt │ │ │ ├── mips.txt │ │ │ ├── mips_loongson2k.txt │ │ │ ├── mips_loongson3.txt │ │ │ ├── mips_loongson_mmi.txt │ │ │ ├── mips_msa.txt │ │ │ ├── riscv64.txt │ │ │ ├── riscv64_rvv.txt │ │ │ ├── riscv64_rvv_zvfh.txt │ │ │ ├── tegra3.txt │ │ │ ├── test0.jpg │ │ │ ├── test1.jpg │ │ │ ├── test2.jpg │ │ │ ├── test3.jpg │ │ │ └── test4.jpg │ │ ├── unit_test.cc │ │ ├── unit_test.h │ │ └── video_common_test.cc │ │ ├── util │ │ ├── Makefile │ │ ├── color.cc │ │ ├── compare.cc │ │ ├── cpuid.c │ │ ├── i444tonv12_eg.cc │ │ ├── psnr.cc │ │ ├── psnr.h │ │ ├── psnr_main.cc │ │ ├── ssim.cc │ │ ├── ssim.h │ │ ├── yuvconstants.c │ │ └── yuvconvert.cc │ │ └── winarm.mk ├── detekt-baseline.xml ├── lint-baseline.xml ├── script │ ├── convert.csv │ ├── convert.py │ ├── disable_dotprod.patch │ ├── disable_test_and_jpeg.patch │ ├── get-deps.sh │ ├── planar.csv │ ├── rotate.csv │ ├── scale.csv │ └── yuv_class.kt └── src │ ├── androidTest │ ├── AndroidManifest.xml │ └── java │ │ └── io │ │ └── github │ │ └── crow_misia │ │ └── libyuv │ │ ├── ColorGenerator.kt │ │ └── ConvertTest.kt │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── io │ │ └── github │ │ └── crow_misia │ │ └── libyuv │ │ ├── Ab30Buffer.kt │ │ ├── AbgrBuffer.kt │ │ ├── AbstractBuffer.kt │ │ ├── Ar30Buffer.kt │ │ ├── Argb1555Buffer.kt │ │ ├── Argb4444Buffer.kt │ │ ├── ArgbBuffer.kt │ │ ├── AyuvBuffer.kt │ │ ├── BgraBuffer.kt │ │ ├── BitmapConverter.kt │ │ ├── Buffer.kt │ │ ├── Buffer24.kt │ │ ├── Buffer32.kt │ │ ├── BufferExt.kt │ │ ├── BufferFactory.kt │ │ ├── BufferFirstAlpha.kt │ │ ├── BufferX400.kt │ │ ├── BufferX420.kt │ │ ├── BufferX422.kt │ │ ├── BufferX444.kt │ │ ├── BufferY.kt │ │ ├── BufferYUV.kt │ │ ├── CapacityCalculator.kt │ │ ├── FilterMode.kt │ │ ├── H420Buffer.kt │ │ ├── H422Buffer.kt │ │ ├── H444Buffer.kt │ │ ├── I400Buffer.kt │ │ ├── I420Buffer.kt │ │ ├── I422Buffer.kt │ │ ├── I444Buffer.kt │ │ ├── J400Buffer.kt │ │ ├── J420Buffer.kt │ │ ├── J422Buffer.kt │ │ ├── J444Buffer.kt │ │ ├── Nv12Buffer.kt │ │ ├── Nv21Buffer.kt │ │ ├── OffsetCalculator.kt │ │ ├── Plane.kt │ │ ├── PlaneNative.kt │ │ ├── PlanePrimitive.kt │ │ ├── PlaneProxy.kt │ │ ├── RawBuffer.kt │ │ ├── Rgb24Buffer.kt │ │ ├── Rgb565Buffer.kt │ │ ├── RgbaBuffer.kt │ │ ├── RotateMode.kt │ │ ├── U420Buffer.kt │ │ ├── U422Buffer.kt │ │ ├── U444Buffer.kt │ │ ├── UyvyBuffer.kt │ │ ├── Yuv.kt │ │ ├── Yuv24Buffer.kt │ │ ├── Yuy2Buffer.kt │ │ └── ext │ │ ├── ImageExt.kt │ │ └── ImageProxyExt.kt │ └── jni │ ├── Android.mk │ ├── compare.cpp │ ├── compare.h │ ├── const.h │ ├── convert.cpp │ ├── convert.h │ ├── convert_argb.cpp │ ├── convert_from.cpp │ ├── convert_from_argb.cpp │ ├── helper.cpp │ ├── jniload.cpp │ ├── jniutil.cpp │ ├── jniutil.h │ ├── macros.h │ ├── memcopy.cpp │ ├── nativehelper │ ├── scoped_bytes.h │ └── scoped_local_ref.h │ ├── planar_functions.cpp │ ├── planar_functions.h │ ├── rotate.cpp │ ├── rotate.h │ ├── rotate_argb.cpp │ ├── scale.cpp │ ├── scale.h │ ├── scale_argb.cpp │ └── scale_uv.cpp ├── debug.keystore ├── findbugs-android-exclude.xml ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lefthook.yaml ├── lint.xml ├── package.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── sample ├── .gitignore ├── build.gradle.kts ├── lint-baseline.xml └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── app │ │ └── MainActivity.kt │ └── res │ ├── layout │ └── activity_main.xml │ └── values │ ├── strings.xml │ └── styles.xml └── settings.gradle.kts /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | [*.{kt,kts}] 8 | indent_style = space 9 | indent_size=4 10 | max_line_length = 140 11 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | core/deps/* linguist-generated=true -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | groups: 6 | all: 7 | patterns: 8 | - "*" 9 | schedule: 10 | interval: "daily" 11 | 12 | - package-ecosystem: "gradle" 13 | directory: "/" 14 | groups: 15 | all: 16 | patterns: 17 | - "*" 18 | schedule: 19 | interval: "daily" 20 | 21 | - package-ecosystem: "npm" 22 | directory: "/" 23 | groups: 24 | all: 25 | patterns: 26 | - "*" 27 | schedule: 28 | interval: "daily" 29 | -------------------------------------------------------------------------------- /.github/workflows/assign_author.yml: -------------------------------------------------------------------------------- 1 | name: Assign author 2 | 3 | on: 4 | pull_request_target: 5 | types: [opened, reopened] 6 | 7 | permissions: 8 | pull-requests: write 9 | 10 | jobs: 11 | assignAuthor: 12 | timeout-minutes: 30 13 | name: Assign author to PR 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Assign author to PR 17 | uses: toshimaru/auto-author-assign@7e15cd70c245ad136377c3fab3479815df10d844 # v2.1.1 18 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: ['main'] 7 | paths-ignore: 8 | - '.npmignore' 9 | - '.husky/**' 10 | - '.idea/**' 11 | - '.vscode/**' 12 | - 'LICENSE' 13 | - 'LICENSE_LIBYUV.txt' 14 | - '*.md' 15 | - 'bumpver.toml' 16 | - 'package.json' 17 | - 'pnpm-lock.yaml' 18 | pull_request: 19 | paths-ignore: 20 | - '.npmignore' 21 | - '.husky/**' 22 | - '.idea/**' 23 | - '.vscode/**' 24 | - 'LICENSE' 25 | - 'LICENSE_LIBYUV.txt' 26 | - '*.md' 27 | - 'bumpver.toml' 28 | - 'package.json' 29 | - 'pnpm-lock.yaml' 30 | 31 | permissions: 32 | contents: write 33 | 34 | jobs: 35 | build: 36 | timeout-minutes: 30 37 | runs-on: ubuntu-latest 38 | if: contains(github.event.head_commit.message, '[skip build]') == false 39 | 40 | strategy: 41 | matrix: 42 | java-version: [17] 43 | 44 | steps: 45 | - name: Checkout 46 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 47 | 48 | - name: Setup JDK ${{ matrix.java-version }} 49 | uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 50 | with: 51 | distribution: temurin 52 | java-version: ${{ matrix.java-version }} 53 | 54 | - name: Setup Gradle to generate and submit dependency graphs 55 | uses: gradle/actions/setup-gradle@8379f6a1328ee0e06e2bb424dadb7b159856a326 # v4.4.0 56 | with: 57 | dependency-graph: generate-and-submit 58 | 59 | - name: Build with Gradle 60 | run: ./gradlew build 61 | -------------------------------------------------------------------------------- /.github/workflows/close_inactive_issues.yml: -------------------------------------------------------------------------------- 1 | name: Close inactive issues 2 | on: 3 | schedule: 4 | - cron: "30 1 * * *" 5 | 6 | permissions: 7 | issues: write 8 | pull-requests: write 9 | 10 | jobs: 11 | close-issues: 12 | timeout-minutes: 30 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0 16 | with: 17 | days-before-issue-stale: 30 18 | days-before-issue-close: 14 19 | stale-issue-message: "This issue is stale because it has been open for 30 days with no activity." 20 | close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." 21 | days-before-pr-stale: -1 22 | days-before-pr-close: -1 23 | -------------------------------------------------------------------------------- /.github/workflows/update-gradle-wrapper.yml: -------------------------------------------------------------------------------- 1 | name: Update Gradle Wrapper 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: "0 0 * * *" 7 | 8 | permissions: 9 | contents: write 10 | pull-requests: write 11 | 12 | jobs: 13 | update-gradle-wrapper: 14 | timeout-minutes: 30 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 19 | 20 | - name: Update Gradle Wrapper 21 | uses: gradle-update/update-gradle-wrapper-action@512b1875f3b6270828abfe77b247d5895a2da1e5 # v2.1.0 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Log Files 24 | *.log 25 | 26 | # Android Studio Navigation editor temp files 27 | .navigation/ 28 | 29 | # Android Studio captures folder 30 | captures/ 31 | 32 | # Intellij 33 | *.iml 34 | .idea/* 35 | 36 | # Keystore files 37 | *.jks 38 | release.keystore 39 | 40 | # External native build folder generated in Android Studio 2.2 and later 41 | .externalNativeBuild 42 | 43 | # Google Services (e.g. APIs or Firebase) 44 | google-services.json 45 | 46 | # macOS 47 | .DS_Store 48 | 49 | # Node.js 50 | node_modules/ 51 | 52 | # not ignore 53 | !.idea/codeStyleSettings.xml 54 | !.idea/findbugs-idea.xml 55 | 56 | core/.cxx/ 57 | Android.mk.orig 58 | .kotlin 59 | 60 | # Lefthook 61 | lefthook-local.* 62 | 63 | -------------------------------------------------------------------------------- /.idea/findbugs-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /LICENSE_LIBYUV.txt: -------------------------------------------------------------------------------- 1 | Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of Google nor the names of its contributors may 16 | be used to endorse or promote products derived from this software 17 | without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /PATENTS_LIBYUV.txt: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the LibYuv code package. 5 | 6 | Google hereby grants to you a perpetual, worldwide, non-exclusive, 7 | no-charge, irrevocable (except as stated in this section) patent 8 | license to make, have made, use, offer to sell, sell, import, 9 | transfer, and otherwise run, modify and propagate the contents of this 10 | implementation of the LibYuv code package, where such license applies 11 | only to those patent claims, both currently owned by Google and 12 | acquired in the future, licensable by Google that are necessarily 13 | infringed by this implementation of the LibYuv code package. This 14 | grant does not include claims that would be infringed only as a 15 | consequence of further modification of this implementation. If you or 16 | your agent or exclusive licensee institute or order or agree to the 17 | institution of patent litigation against any entity (including a 18 | cross-claim or counterclaim in a lawsuit) alleging that this 19 | implementation of the LibYuv code package or any code incorporated 20 | within this implementation of the LibYuv code package constitutes 21 | direct or contributory patent infringement, or inducement of patent 22 | infringement, then any patent rights granted to you under this License 23 | for this implementation of the LibYuv code package shall terminate as 24 | of the date such litigation is filed. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libyuv-anrdroid 2 | ================= 3 | 4 | [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/crow-misia/libyuv-android/build.yml)](https://github.com/crow-misia/libyuv-android/actions/workflows/build.yml) 5 | [![Maven Central Version](https://img.shields.io/maven-central/v/io.github.crow-misia.libyuv/libyuv-android)](https://central.sonatype.com/artifact/io.github.crow-misia.libyuv/libyuv-android) 6 | [![GitHub License](https://img.shields.io/github/license/crow-misia/libyuv-android)](LICENSE) 7 | 8 | ## Get Started 9 | 10 | ### Gradle 11 | 12 | Add dependencies (you can also add other modules that you need): 13 | 14 | `${latest.version}` is [![Maven Central Version](https://img.shields.io/maven-central/v/io.github.crow-misia.libyuv/libyuv-android)](https://central.sonatype.com/artifact/io.github.crow-misia.libyuv/libyuv-android) 15 | 16 | ```groovy 17 | dependencies { 18 | implementation "io.github.crow-misia.libyuv:libyuv-android:${latest.version}" 19 | } 20 | ``` 21 | 22 | Make sure that you have either `mavenCentral()` in the list of repositories: 23 | 24 | ``` 25 | repository { 26 | mavenCentral() 27 | } 28 | ``` 29 | 30 | ## License 31 | 32 | The code in libyuv (https://chromium.googlesource.com/libyuv/libyuv/) follows the license and patent descriptions of libyuv. 33 | See LICENSE_LIBYUV and PATENTS_LIBYUV under the root of this repository. The originals can be found at the following URL. 34 | 35 | https://chromium.googlesource.com/libyuv/libyuv/+/master/LICENSE 36 | https://chromium.googlesource.com/libyuv/libyuv/+/master/PATENTS 37 | 38 | ``` 39 | Copyright 2020, Zenichi Amano. 40 | 41 | Licensed under the Apache License, Version 2.0 (the "License"); 42 | you may not use this file except in compliance with the License. 43 | You may obtain a copy of the License at 44 | 45 | http://www.apache.org/licenses/LICENSE-2.0 46 | 47 | Unless required by applicable law or agreed to in writing, software 48 | distributed under the License is distributed on an "AS IS" BASIS, 49 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 50 | See the License for the specific language governing permissions and 51 | limitations under the License. 52 | ``` 53 | -------------------------------------------------------------------------------- /VERSIONS: -------------------------------------------------------------------------------- 1 | LIBYUV_VERSION=951e43439c3125bc55df43c01f13041a253a59dc 2 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | plugins { 3 | alias(libs.plugins.android.application) apply false 4 | alias(libs.plugins.android.library) apply false 5 | alias(libs.plugins.detekt) apply false 6 | alias(libs.plugins.dokka) apply false 7 | alias(libs.plugins.dokka.javadoc) apply false 8 | alias(libs.plugins.kotlin.android) apply false 9 | alias(libs.plugins.maven.publish) apply false 10 | } 11 | -------------------------------------------------------------------------------- /bumpver.toml: -------------------------------------------------------------------------------- 1 | [bumpver] 2 | current_version = "v0.43.0" 3 | version_pattern = "vMAJOR.MINOR.PATCH" 4 | commit_message = "chore: bump version {old_version} -> {new_version}" 5 | tag_message = "{new_version}" 6 | tag_scope = "default" 7 | pre_commit_hook = "" 8 | post_commit_hook = "" 9 | commit = true 10 | tag = true 11 | push = false 12 | 13 | [bumpver.file_patterns] 14 | "core/build.gradle.kts" = [ 15 | " const val VERSION = \"{pep440_version}\"", 16 | ] 17 | -------------------------------------------------------------------------------- /commitlint.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | } 4 | -------------------------------------------------------------------------------- /config/detekt.yml: -------------------------------------------------------------------------------- 1 | build: 2 | maxIssues: 0 3 | 4 | complexity: 5 | LongParameterList: 6 | active: false 7 | TooManyFunctions: 8 | active: false 9 | 10 | style: 11 | DestructuringDeclarationWithTooManyEntries: 12 | active: false 13 | MaxLineLength: 14 | active: false 15 | WildcardImport: 16 | active: false 17 | MagicNumber: 18 | active: false 19 | 20 | naming: 21 | PackageNaming: 22 | active: false 23 | -------------------------------------------------------------------------------- /core/.gitignore: -------------------------------------------------------------------------------- 1 | /obj 2 | /build 3 | /.externalNativeBuild 4 | -------------------------------------------------------------------------------- /core/Android.mk: -------------------------------------------------------------------------------- 1 | PROJECT_PATH := $(call my-dir) 2 | 3 | include $(PROJECT_PATH)/deps/libyuv/Android.mk 4 | include $(PROJECT_PATH)/src/main/jni/Android.mk 5 | -------------------------------------------------------------------------------- /core/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := all 2 | APP_OPTIM := release 3 | APP_CFLAGS += -O3 -ffunction-sections -fdata-sections -DLIBYUV_LEGACY_TYPES 4 | APP_CPPFLAGS += -O3 -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden 5 | APP_LDFLAGS += -Wl,--gc-sections 6 | -------------------------------------------------------------------------------- /core/consumer-proguard-rules.pro: -------------------------------------------------------------------------------- 1 | -dontwarn org.jetbrains.annotations.** 2 | 3 | -keepclasseswithmembernames class io.github.crow_misia.libyuv.Yuv { 4 | *; 5 | } 6 | -------------------------------------------------------------------------------- /core/deps/.gitignore: -------------------------------------------------------------------------------- 1 | *.tar.gz -------------------------------------------------------------------------------- /core/deps/libyuv/.clang-format: -------------------------------------------------------------------------------- 1 | # Defines the Chromium style for automatic reformatting. 2 | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html 3 | BasedOnStyle: Chromium 4 | --- 5 | Language: Java 6 | BasedOnStyle: Google 7 | -------------------------------------------------------------------------------- /core/deps/libyuv/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .landmines 3 | pin-log.txt 4 | /base 5 | /build 6 | /buildtools 7 | /google_apis 8 | /links 9 | /links.db 10 | /ios 11 | /mojo 12 | /native_client 13 | /net 14 | /out 15 | /unit_test/out 16 | /source/out 17 | /sde-avx-sse-transition-out.txt 18 | /testing 19 | /third_party 20 | /tools 21 | 22 | # Files generated by CMake build 23 | cmake_install.cmake 24 | CMakeCache.txt 25 | CMakeFiles/ 26 | yuvconvert 27 | libgtest.a 28 | libyuv.a 29 | libyuv_unittest 30 | 31 | # Files generated by winarm.mk build 32 | libyuv_arm.lib 33 | source/*.o 34 | 35 | # Files generated by perf 36 | perf.data 37 | perf.data.old 38 | -------------------------------------------------------------------------------- /core/deps/libyuv/.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import("//build/dotfile_settings.gni") 10 | 11 | # The location of the build configuration file. 12 | buildconfig = "//build/config/BUILDCONFIG.gn" 13 | 14 | # The python interpreter to use by default. On Windows, this will look 15 | # for python3.exe and python3.bat. 16 | script_executable = "python3" 17 | 18 | # The secondary source root is a parallel directory tree where 19 | # GN build files are placed when they can not be placed directly 20 | # in the source tree, e.g. for third party source trees. 21 | secondary_source = "//build/secondary/" 22 | 23 | # These are the targets to check headers for by default. The files in targets 24 | # matching these patterns (see "gn help label_pattern" for format) will have 25 | # their includes checked for proper dependencies when you run either 26 | # "gn check" or "gn gen --check". 27 | check_targets = [ "//libyuv/*" ] 28 | 29 | # These are the list of GN files that run exec_script. This allowlist exists 30 | # to force additional review for new uses of exec_script, which is strongly 31 | # discouraged except for gypi_to_gn calls. 32 | exec_script_allowlist = build_dotfile_settings.exec_script_allowlist + 33 | [ "//build_overrides/build.gni" ] 34 | 35 | default_args = { 36 | mac_sdk_min = "10.12" 37 | ios_deployment_target = "12.0" 38 | } 39 | -------------------------------------------------------------------------------- /core/deps/libyuv/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file like so: 2 | # Name or Organization 3 | 4 | Google Inc. 5 | 6 | Ho Cheung 7 | Ivan Pavlotskiy 8 | -------------------------------------------------------------------------------- /core/deps/libyuv/Android.mk: -------------------------------------------------------------------------------- 1 | # This is the Android makefile for libyuv for NDK. 2 | LOCAL_PATH:= $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_CPP_EXTENSION := .cc 7 | 8 | LOCAL_SRC_FILES := \ 9 | source/compare.cc \ 10 | source/compare_common.cc \ 11 | source/compare_gcc.cc \ 12 | source/compare_msa.cc \ 13 | source/compare_neon.cc \ 14 | source/compare_neon64.cc \ 15 | source/compare_win.cc \ 16 | source/convert.cc \ 17 | source/convert_argb.cc \ 18 | source/convert_from.cc \ 19 | source/convert_from_argb.cc \ 20 | source/convert_to_argb.cc \ 21 | source/convert_to_i420.cc \ 22 | source/cpu_id.cc \ 23 | source/planar_functions.cc \ 24 | source/rotate.cc \ 25 | source/rotate_any.cc \ 26 | source/rotate_argb.cc \ 27 | source/rotate_common.cc \ 28 | source/rotate_gcc.cc \ 29 | source/rotate_msa.cc \ 30 | source/rotate_neon.cc \ 31 | source/rotate_neon64.cc \ 32 | source/rotate_win.cc \ 33 | source/row_any.cc \ 34 | source/row_common.cc \ 35 | source/row_gcc.cc \ 36 | source/row_msa.cc \ 37 | source/row_neon.cc \ 38 | source/row_neon64.cc \ 39 | source/row_win.cc \ 40 | source/scale.cc \ 41 | source/scale_any.cc \ 42 | source/scale_argb.cc \ 43 | source/scale_common.cc \ 44 | source/scale_gcc.cc \ 45 | source/scale_msa.cc \ 46 | source/scale_neon.cc \ 47 | source/scale_neon64.cc \ 48 | source/scale_rgb.cc \ 49 | source/scale_uv.cc \ 50 | source/scale_win.cc \ 51 | source/video_common.cc 52 | 53 | common_CFLAGS := -Wall -fexceptions -DLIBYUV_DISABLE_SVE -DLIBYUV_DISABLE_NEON_DOTPROD -DLIBYUV_DISABLE_NEON_I8MM -DLIBYUV_DISABLE_SME 54 | 55 | LOCAL_CFLAGS += $(common_CFLAGS) 56 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include 57 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/include 58 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include 59 | 60 | LOCAL_MODULE := libyuv_static 61 | LOCAL_MODULE_TAGS := optional 62 | 63 | include $(BUILD_STATIC_LIBRARY) 64 | 65 | include $(CLEAR_VARS) 66 | 67 | LOCAL_WHOLE_STATIC_LIBRARIES := libyuv_static 68 | -------------------------------------------------------------------------------- /core/deps/libyuv/CM_linux_packages.cmake: -------------------------------------------------------------------------------- 1 | # determine the version number from the #define in libyuv/version.h 2 | EXECUTE_PROCESS ( 3 | COMMAND grep -Eo "LIBYUV_VERSION\ [0-9]+" include/libyuv/version.h 4 | COMMAND grep -Eo "[0-9]+" 5 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 6 | OUTPUT_VARIABLE YUV_VERSION_NUMBER 7 | OUTPUT_STRIP_TRAILING_WHITESPACE ) 8 | SET ( YUV_VER_MAJOR 0 ) 9 | SET ( YUV_VER_MINOR 0 ) 10 | SET ( YUV_VER_PATCH ${YUV_VERSION_NUMBER} ) 11 | SET ( YUV_VERSION ${YUV_VER_MAJOR}.${YUV_VER_MINOR}.${YUV_VER_PATCH} ) 12 | MESSAGE ( VERBOSE "Building ver.: ${YUV_VERSION}" ) 13 | 14 | # is this a 32-bit or 64-bit build? 15 | IF ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) 16 | SET ( YUV_BIT_SIZE 64 ) 17 | ELSEIF ( CMAKE_SIZEOF_VOID_P EQUAL 4 ) 18 | SET ( YUV_BIT_SIZE 32 ) 19 | ELSE () 20 | MESSAGE ( FATAL_ERROR "CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" ) 21 | ENDIF () 22 | 23 | # detect if this is a ARM build 24 | STRING (FIND "${CMAKE_CXX_COMPILER}" "arm-linux-gnueabihf-g++" pos) 25 | IF ( ${pos} EQUAL -1 ) 26 | SET ( YUV_CROSS_COMPILE_FOR_ARM7 FALSE ) 27 | ELSE () 28 | MESSAGE ( "Cross compiling for ARM7" ) 29 | SET ( YUV_CROSS_COMPILE_FOR_ARM7 TRUE ) 30 | ENDIF () 31 | STRING (FIND "${CMAKE_SYSTEM_PROCESSOR}" "arm" pos) 32 | IF ( ${pos} EQUAL -1 ) 33 | SET ( YUV_COMPILE_FOR_ARM7 FALSE ) 34 | ELSE () 35 | MESSAGE ( "Compiling for ARM" ) 36 | SET ( YUV_COMPILE_FOR_ARM7 TRUE ) 37 | ENDIF () 38 | 39 | # setup the sytem name, such as "x86-32", "amd-64", and "arm-32 40 | IF ( ${YUV_CROSS_COMPILE_FOR_ARM7} OR ${YUV_COMPILE_FOR_ARM7} ) 41 | SET ( YUV_SYSTEM_NAME "armhf-${YUV_BIT_SIZE}" ) 42 | ELSE () 43 | IF ( YUV_BIT_SIZE EQUAL 32 ) 44 | SET ( YUV_SYSTEM_NAME "x86-${YUV_BIT_SIZE}" ) 45 | ELSE () 46 | SET ( YUV_SYSTEM_NAME "amd-${YUV_BIT_SIZE}" ) 47 | ENDIF () 48 | ENDIF () 49 | MESSAGE ( VERBOSE "Packaging for: ${YUV_SYSTEM_NAME}" ) 50 | 51 | # define all the variables needed by CPack to create .deb and .rpm packages 52 | SET ( CPACK_PACKAGE_VENDOR "Frank Barchard" ) 53 | SET ( CPACK_PACKAGE_CONTACT "fbarchard@chromium.org" ) 54 | SET ( CPACK_PACKAGE_VERSION ${YUV_VERSION} ) 55 | SET ( CPACK_PACKAGE_VERSION_MAJOR ${YUV_VER_MAJOR} ) 56 | SET ( CPACK_PACKAGE_VERSION_MINOR ${YUV_VER_MINOR} ) 57 | SET ( CPACK_PACKAGE_VERSION_PATCH ${YUV_VER_PATCH} ) 58 | SET ( CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE ) 59 | SET ( CPACK_SYSTEM_NAME "linux-${YUV_SYSTEM_NAME}" ) 60 | SET ( CPACK_PACKAGE_NAME "libyuv" ) 61 | SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "YUV library" ) 62 | SET ( CPACK_PACKAGE_DESCRIPTION "YUV library and YUV conversion tool" ) 63 | SET ( CPACK_DEBIAN_PACKAGE_SECTION "other" ) 64 | SET ( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" ) 65 | SET ( CPACK_DEBIAN_PACKAGE_MAINTAINER "Frank Barchard " ) 66 | SET ( CPACK_GENERATOR "DEB;RPM" ) 67 | 68 | # create the .deb and .rpm files (you'll need build-essential and rpm tools) 69 | INCLUDE( CPack ) 70 | 71 | -------------------------------------------------------------------------------- /core/deps/libyuv/DIR_METADATA: -------------------------------------------------------------------------------- 1 | monorail { 2 | component: "Internals>Images>Codecs" 3 | } 4 | -------------------------------------------------------------------------------- /core/deps/libyuv/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of Google nor the names of its contributors may 16 | be used to endorse or promote products derived from this software 17 | without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /core/deps/libyuv/OWNERS: -------------------------------------------------------------------------------- 1 | mbonadei@chromium.org 2 | fbarchard@chromium.org 3 | magjed@chromium.org 4 | wtc@google.com 5 | jansson@google.com 6 | 7 | per-file *.gn=mbonadei@chromium.org,jansson@google.com 8 | per-file .gitignore=* 9 | per-file AUTHORS=* 10 | per-file DEPS=* 11 | per-file PRESUBMIT.py=mbonadei@chromium.org,jansson@google.com 12 | -------------------------------------------------------------------------------- /core/deps/libyuv/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the LibYuv code package. 5 | 6 | Google hereby grants to you a perpetual, worldwide, non-exclusive, 7 | no-charge, irrevocable (except as stated in this section) patent 8 | license to make, have made, use, offer to sell, sell, import, 9 | transfer, and otherwise run, modify and propagate the contents of this 10 | implementation of the LibYuv code package, where such license applies 11 | only to those patent claims, both currently owned by Google and 12 | acquired in the future, licensable by Google that are necessarily 13 | infringed by this implementation of the LibYuv code package. This 14 | grant does not include claims that would be infringed only as a 15 | consequence of further modification of this implementation. If you or 16 | your agent or exclusive licensee institute or order or agree to the 17 | institution of patent litigation against any entity (including a 18 | cross-claim or counterclaim in a lawsuit) alleging that this 19 | implementation of the LibYuv code package or any code incorporated 20 | within this implementation of the LibYuv code package constitutes 21 | direct or contributory patent infringement, or inducement of patent 22 | infringement, then any patent rights granted to you under this License 23 | for this implementation of the LibYuv code package shall terminate as 24 | of the date such litigation is filed. -------------------------------------------------------------------------------- /core/deps/libyuv/PRESUBMIT.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | # Runs PRESUBMIT.py in py3 mode by git cl presubmit. 10 | USE_PYTHON3 = True 11 | 12 | 13 | def _CommonChecks(input_api, output_api): 14 | """Checks common to both upload and commit.""" 15 | results = [] 16 | results.extend( 17 | input_api.canned_checks.RunPylint( 18 | input_api, 19 | output_api, 20 | files_to_skip=( 21 | r'^base[\\\/].*\.py$', 22 | r'^build[\\\/].*\.py$', 23 | r'^buildtools[\\\/].*\.py$', 24 | r'^ios[\\\/].*\.py$', 25 | r'^out.*[\\\/].*\.py$', 26 | r'^testing[\\\/].*\.py$', 27 | r'^third_party[\\\/].*\.py$', 28 | r'^tools[\\\/].*\.py$', 29 | # TODO(kjellander): should arguably be checked. 30 | r'^tools_libyuv[\\\/]valgrind[\\\/].*\.py$', 31 | r'^xcodebuild.*[\\\/].*\.py$', 32 | ), 33 | disabled_warnings=[ 34 | 'F0401', # Failed to import x 35 | 'E0611', # No package y in x 36 | 'W0232', # Class has no __init__ method 37 | ], 38 | pylintrc='pylintrc', 39 | version='2.7', 40 | ) 41 | ) 42 | return results 43 | 44 | 45 | def CheckChangeOnUpload(input_api, output_api): 46 | results = [] 47 | results.extend(_CommonChecks(input_api, output_api)) 48 | results.extend( 49 | input_api.canned_checks.CheckGNFormatted(input_api, output_api) 50 | ) 51 | return results 52 | 53 | 54 | def CheckChangeOnCommit(input_api, output_api): 55 | results = [] 56 | results.extend(_CommonChecks(input_api, output_api)) 57 | results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) 58 | results.extend( 59 | input_api.canned_checks.CheckChangeWasUploaded(input_api, output_api) 60 | ) 61 | results.extend( 62 | input_api.canned_checks.CheckChangeHasDescription(input_api, 63 | output_api) 64 | ) 65 | return results 66 | -------------------------------------------------------------------------------- /core/deps/libyuv/README.chromium: -------------------------------------------------------------------------------- 1 | Name: libyuv 2 | URL: https://chromium.googlesource.com/libyuv/libyuv/ 3 | Version: 1910 4 | License: BSD-3-Clause 5 | License File: LICENSE 6 | Shipped: yes 7 | Security Critical: yes 8 | 9 | Description: 10 | libyuv is an open source project that includes YUV conversion and scaling functionality. 11 | 12 | -------------------------------------------------------------------------------- /core/deps/libyuv/README.md: -------------------------------------------------------------------------------- 1 | **libyuv** is an open source project that includes YUV scaling and conversion functionality. 2 | 3 | * Scale YUV to prepare content for compression, with point, bilinear or box filter. 4 | * Convert to YUV from webcam formats for compression. 5 | * Convert to RGB formats for rendering/effects. 6 | * Rotate by 90/180/270 degrees to adjust for mobile devices in portrait mode. 7 | * Optimized for SSSE3/AVX2 on x86/x64. 8 | * Optimized for Neon/SVE2/SME on Arm. 9 | * Optimized for MSA on Mips. 10 | * Optimized for RVV on RISC-V. 11 | 12 | ### Development 13 | 14 | See [Getting started][1] for instructions on how to get started developing. 15 | 16 | You can also browse the [docs directory][2] for more documentation. 17 | 18 | [1]: ./docs/getting_started.md 19 | [2]: ./docs/ 20 | -------------------------------------------------------------------------------- /core/deps/libyuv/build_overrides/build.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | # Variable that can be used to support multiple build scenarios, like having 10 | # Chromium specific targets in a client project's GN file etc. 11 | build_with_chromium = false 12 | 13 | # Some non-Chromium builds don't support building java targets. 14 | enable_java_templates = true 15 | 16 | # Enables assertions on safety checks in libc++. 17 | enable_safe_libcxx = true 18 | 19 | # Allow using custom suppressions files (currently not used by libyuv). 20 | asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc" 21 | lsan_suppressions_file = "//build/sanitizers/lsan_suppressions.cc" 22 | tsan_suppressions_file = "//build/sanitizers/tsan_suppressions.cc" 23 | 24 | msan_blacklist_path = 25 | rebase_path("//tools_libyuv/msan/blacklist.txt", root_build_dir) 26 | ubsan_blacklist_path = 27 | rebase_path("//tools_libyuv/ubsan/blacklist.txt", root_build_dir) 28 | ubsan_vptr_blacklist_path = 29 | rebase_path("//tools_libyuv/ubsan/vptr_blacklist.txt", root_build_dir) 30 | 31 | # For Chromium, Android 32-bit non-component, non-clang builds hit a 4GiB size 32 | # limit, making them requiring symbol_level=2. WebRTC doesn't hit that problem 33 | # so we just ignore that assert. See https://crbug.com/648948 for more info. 34 | ignore_elf32_limitations = true 35 | 36 | # Use bundled hermetic Xcode installation maintained by Chromium, 37 | # except for local iOS builds where it is unsupported. 38 | # Allow for mac cross compile on linux machines. 39 | if (host_os == "mac" || host_os == "linux") { 40 | _result = exec_script("//build/mac/should_use_hermetic_xcode.py", 41 | [ target_os ], 42 | "value") 43 | assert(_result != 2, 44 | "Do not allow building targets with the default " + 45 | "hermetic toolchain if the minimum OS version is not met.") 46 | use_system_xcode = _result == 0 47 | } 48 | 49 | declare_args() { 50 | # Limits the defined //third_party/android_deps targets to only "buildCompile" 51 | # and "buildCompileNoDeps" targets. This is useful for third-party 52 | # repositories which do not use JUnit tests. For instance, 53 | # limit_android_deps == true removes "gn gen" requirement for 54 | # //third_party/robolectric . 55 | limit_android_deps = false 56 | 57 | # Allows googletest to pretty-print various absl types. 58 | # Defined here rather than in gtest.gni to match chromium. 59 | gtest_enable_absl_printers = true 60 | } 61 | -------------------------------------------------------------------------------- /core/deps/libyuv/build_overrides/gtest.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The LibYuv project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | # Include support for registering main function in multi-process tests. 10 | gtest_include_multiprocess = true 11 | 12 | # Include support for platform-specific operations across unit tests. 13 | gtest_include_platform_test = true 14 | 15 | # Exclude support for testing Objective C code on OS X and iOS. 16 | gtest_include_objc_support = true 17 | 18 | # Exclude support for flushing coverage files on iOS. 19 | gtest_include_ios_coverage = true 20 | -------------------------------------------------------------------------------- /core/deps/libyuv/build_overrides/partition_alloc.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | # Use default values for PartitionAlloc as standalone library from 10 | # base/allocator/partition_allocator/build_overrides/partition_alloc.gni 11 | use_partition_alloc_as_malloc_default = false 12 | use_allocator_shim_default = false 13 | enable_backup_ref_ptr_support_default = false 14 | enable_mte_checked_ptr_support_default = false 15 | put_ref_count_in_previous_slot_default = false 16 | enable_backup_ref_ptr_slow_checks_default = false 17 | enable_dangling_raw_ptr_checks_default = false 18 | -------------------------------------------------------------------------------- /core/deps/libyuv/codereview.settings: -------------------------------------------------------------------------------- 1 | # This file is used by `git cl` to get repository specific information. 2 | CODE_REVIEW_SERVER: codereview.chromium.org 3 | GERRIT_HOST: True 4 | PROJECT: libyuv 5 | VIEW_VC: https://chromium.googlesource.com/libyuv/libyuv/+/ 6 | -------------------------------------------------------------------------------- /core/deps/libyuv/docs/environment_variables.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | For test purposes, environment variables can be set to control libyuv behavior. These should only be used for testing, to narrow down bugs or to test performance. 4 | 5 | # CPU 6 | 7 | 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. 8 | 9 | ## All CPUs 10 | 11 | LIBYUV_DISABLE_ASM 12 | 13 | ## Intel CPUs 14 | 15 | LIBYUV_DISABLE_X86 16 | LIBYUV_DISABLE_SSE2 17 | LIBYUV_DISABLE_SSSE3 18 | LIBYUV_DISABLE_SSE41 19 | LIBYUV_DISABLE_SSE42 20 | LIBYUV_DISABLE_AVX 21 | LIBYUV_DISABLE_AVX2 22 | LIBYUV_DISABLE_ERMS 23 | LIBYUV_DISABLE_FMA3 24 | LIBYUV_DISABLE_F16C 25 | LIBYUV_DISABLE_AVX512BW 26 | LIBYUV_DISABLE_AVX512VL 27 | LIBYUV_DISABLE_AVX512VNNI 28 | LIBYUV_DISABLE_AVX512VBMI 29 | LIBYUV_DISABLE_AVX512VBMI2 30 | LIBYUV_DISABLE_AVX512VBITALG 31 | LIBYUV_DISABLE_AVX10 32 | LIBYUV_DISABLE_AVX10_2 33 | LIBYUV_DISABLE_AVXVNNI 34 | LIBYUV_DISABLE_AVXVNNIINT8 35 | LIBYUV_DISABLE_AMXINT8 36 | 37 | ## Arm CPUs 38 | 39 | LIBYUV_DISABLE_NEON 40 | LIBYUV_DISABLE_NEON_DOTPROD 41 | LIBYUV_DISABLE_NEON_I8MM 42 | LIBYUV_DISABLE_SVE 43 | LIBYUV_DISABLE_SVE2 44 | LIBYUV_DISABLE_SME 45 | 46 | ## MIPS CPUs 47 | 48 | LIBYUV_DISABLE_MSA 49 | 50 | ## LOONGARCH CPUs 51 | 52 | LIBYUV_DISABLE_LSX 53 | LIBYUV_DISABLE_LASX 54 | 55 | ## RISCV CPUs 56 | 57 | LIBYUV_DISABLE_RVV 58 | 59 | # Test Width/Height/Repeat 60 | 61 | The unittests default to a small image (128x72) to run fast. This can be set by environment variable to test a specific resolutions. 62 | You can also repeat the test a specified number of iterations, allowing benchmarking and profiling. 63 | 64 | set LIBYUV_WIDTH=1280 65 | set LIBYUV_HEIGHT=720 66 | set LIBYUV_REPEAT=999 67 | set LIBYUV_FLAGS=-1 68 | set LIBYUV_CPU_INFO=-1 69 | -------------------------------------------------------------------------------- /core/deps/libyuv/download_vs_toolchain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env vpython3 2 | 3 | # Copyright 2014 The LibYuv Project Authors. All rights reserved. 4 | # 5 | # Use of this source code is governed by a BSD-style license 6 | # that can be found in the LICENSE file in the root of the source 7 | # tree. An additional intellectual property rights grant can be found 8 | # in the file PATENTS. All contributing project authors may 9 | # be found in the AUTHORS file in the root of the source tree. 10 | 11 | # This script is used to run the vs_toolchain.py script to download the 12 | # Visual Studio toolchain. It's just a temporary measure while waiting for the 13 | # Chrome team to move find_depot_tools into src/build to get rid of these 14 | # workarounds (similar one in gyp_libyuv). 15 | 16 | import os 17 | import sys 18 | 19 | 20 | checkout_root = os.path.dirname(os.path.realpath(__file__)) 21 | sys.path.insert(0, os.path.join(checkout_root, 'build')) 22 | sys.path.insert(0, os.path.join(checkout_root, 'tools', 'find_depot_tools')) 23 | 24 | 25 | import vs_toolchain # pylint: disable=wrong-import-position 26 | 27 | 28 | if __name__ == '__main__': 29 | sys.exit(vs_toolchain.main()) 30 | -------------------------------------------------------------------------------- /core/deps/libyuv/include/libyuv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_H_ 12 | #define INCLUDE_LIBYUV_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/compare.h" 16 | #include "libyuv/convert.h" 17 | #include "libyuv/convert_argb.h" 18 | #include "libyuv/convert_from.h" 19 | #include "libyuv/convert_from_argb.h" 20 | #include "libyuv/cpu_id.h" 21 | #include "libyuv/mjpeg_decoder.h" 22 | #include "libyuv/planar_functions.h" 23 | #include "libyuv/rotate.h" 24 | #include "libyuv/rotate_argb.h" 25 | #include "libyuv/row.h" 26 | #include "libyuv/scale.h" 27 | #include "libyuv/scale_argb.h" 28 | #include "libyuv/scale_row.h" 29 | #include "libyuv/scale_uv.h" 30 | #include "libyuv/version.h" 31 | #include "libyuv/video_common.h" 32 | 33 | #endif // INCLUDE_LIBYUV_H_ 34 | -------------------------------------------------------------------------------- /core/deps/libyuv/include/libyuv/basic_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ 12 | #define INCLUDE_LIBYUV_BASIC_TYPES_H_ 13 | 14 | #include // For size_t and NULL 15 | 16 | #if !defined(INT_TYPES_DEFINED) && !defined(GG_LONGLONG) 17 | #define INT_TYPES_DEFINED 18 | 19 | #if defined(_MSC_VER) && (_MSC_VER < 1600) 20 | #include // for uintptr_t on x86 21 | typedef unsigned __int64 uint64_t; 22 | typedef __int64 int64_t; 23 | typedef unsigned int uint32_t; 24 | typedef int int32_t; 25 | typedef unsigned short uint16_t; 26 | typedef short int16_t; 27 | typedef unsigned char uint8_t; 28 | typedef signed char int8_t; 29 | #else 30 | #include // for uintptr_t and C99 types 31 | #endif // defined(_MSC_VER) && (_MSC_VER < 1600) 32 | // Types are deprecated. Enable this macro for legacy types. 33 | #ifdef LIBYUV_LEGACY_TYPES 34 | typedef uint64_t uint64; 35 | typedef int64_t int64; 36 | typedef uint32_t uint32; 37 | typedef int32_t int32; 38 | typedef uint16_t uint16; 39 | typedef int16_t int16; 40 | typedef uint8_t uint8; 41 | typedef int8_t int8; 42 | #endif // LIBYUV_LEGACY_TYPES 43 | #endif // INT_TYPES_DEFINED 44 | 45 | #if !defined(LIBYUV_API) 46 | #if defined(_WIN32) || defined(__CYGWIN__) 47 | #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) 48 | #define LIBYUV_API __declspec(dllexport) 49 | #elif defined(LIBYUV_USING_SHARED_LIBRARY) 50 | #define LIBYUV_API __declspec(dllimport) 51 | #else 52 | #define LIBYUV_API 53 | #endif // LIBYUV_BUILDING_SHARED_LIBRARY 54 | #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ 55 | (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ 56 | defined(LIBYUV_USING_SHARED_LIBRARY)) 57 | #define LIBYUV_API __attribute__((visibility("default"))) 58 | #else 59 | #define LIBYUV_API 60 | #endif // __GNUC__ 61 | #endif // LIBYUV_API 62 | 63 | // TODO(fbarchard): Remove bool macros. 64 | #define LIBYUV_BOOL int 65 | #define LIBYUV_FALSE 0 66 | #define LIBYUV_TRUE 1 67 | 68 | #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ 69 | -------------------------------------------------------------------------------- /core/deps/libyuv/include/libyuv/compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_COMPARE_H_ 12 | #define INCLUDE_LIBYUV_COMPARE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Compute a hash for specified memory. Seed of 5381 recommended. 22 | LIBYUV_API 23 | uint32_t HashDjb2(const uint8_t* src, uint64_t count, uint32_t seed); 24 | 25 | // Hamming Distance 26 | LIBYUV_API 27 | uint64_t ComputeHammingDistance(const uint8_t* src_a, 28 | const uint8_t* src_b, 29 | int count); 30 | 31 | // Scan an opaque argb image and return fourcc based on alpha offset. 32 | // Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown. 33 | LIBYUV_API 34 | uint32_t ARGBDetect(const uint8_t* argb, 35 | int stride_argb, 36 | int width, 37 | int height); 38 | 39 | // Sum Square Error - used to compute Mean Square Error or PSNR. 40 | LIBYUV_API 41 | uint64_t ComputeSumSquareError(const uint8_t* src_a, 42 | const uint8_t* src_b, 43 | int count); 44 | 45 | LIBYUV_API 46 | uint64_t ComputeSumSquareErrorPlane(const uint8_t* src_a, 47 | int stride_a, 48 | const uint8_t* src_b, 49 | int stride_b, 50 | int width, 51 | int height); 52 | 53 | static const int kMaxPsnr = 128; 54 | 55 | LIBYUV_API 56 | double SumSquareErrorToPsnr(uint64_t sse, uint64_t count); 57 | 58 | LIBYUV_API 59 | double CalcFramePsnr(const uint8_t* src_a, 60 | int stride_a, 61 | const uint8_t* src_b, 62 | int stride_b, 63 | int width, 64 | int height); 65 | 66 | LIBYUV_API 67 | double I420Psnr(const uint8_t* src_y_a, 68 | int stride_y_a, 69 | const uint8_t* src_u_a, 70 | int stride_u_a, 71 | const uint8_t* src_v_a, 72 | int stride_v_a, 73 | const uint8_t* src_y_b, 74 | int stride_y_b, 75 | const uint8_t* src_u_b, 76 | int stride_u_b, 77 | const uint8_t* src_v_b, 78 | int stride_v_b, 79 | int width, 80 | int height); 81 | 82 | LIBYUV_API 83 | double CalcFrameSsim(const uint8_t* src_a, 84 | int stride_a, 85 | const uint8_t* src_b, 86 | int stride_b, 87 | int width, 88 | int height); 89 | 90 | LIBYUV_API 91 | double I420Ssim(const uint8_t* src_y_a, 92 | int stride_y_a, 93 | const uint8_t* src_u_a, 94 | int stride_u_a, 95 | const uint8_t* src_v_a, 96 | int stride_v_a, 97 | const uint8_t* src_y_b, 98 | int stride_y_b, 99 | const uint8_t* src_u_b, 100 | int stride_u_b, 101 | const uint8_t* src_v_b, 102 | int stride_v_b, 103 | int width, 104 | int height); 105 | 106 | #ifdef __cplusplus 107 | } // extern "C" 108 | } // namespace libyuv 109 | #endif 110 | 111 | #endif // INCLUDE_LIBYUV_COMPARE_H_ 112 | -------------------------------------------------------------------------------- /core/deps/libyuv/include/libyuv/cpu_support.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_CPU_SUPPORT_H_ 12 | #define INCLUDE_LIBYUV_CPU_SUPPORT_H_ 13 | 14 | #ifdef __cplusplus 15 | namespace libyuv { 16 | extern "C" { 17 | #endif 18 | 19 | #if defined(__pnacl__) || defined(__CLR_VER) || \ 20 | (defined(__native_client__) && defined(__x86_64__)) || \ 21 | (defined(__i386__) && !defined(__SSE__) && !defined(__clang__)) 22 | #define LIBYUV_DISABLE_X86 23 | #endif 24 | 25 | #if defined(__native_client__) 26 | #define LIBYUV_DISABLE_NEON 27 | #endif 28 | 29 | // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 30 | #if defined(__has_feature) 31 | #if __has_feature(memory_sanitizer) 32 | #if !defined(LIBYUV_DISABLE_NEON) 33 | #define LIBYUV_DISABLE_NEON 34 | #endif 35 | #if !defined(LIBYUV_DISABLE_SME) 36 | #define LIBYUV_DISABLE_SME 37 | #endif 38 | #if !defined(LIBYUV_DISABLE_SVE) 39 | #define LIBYUV_DISABLE_SVE 40 | #endif 41 | #if !defined(LIBYUV_DISABLE_X86) 42 | #define LIBYUV_DISABLE_X86 43 | #endif 44 | #endif // __has_feature(memory_sanitizer) 45 | #endif // defined(__has_feature) 46 | 47 | // clang >= 3.5.0 required for Arm64. 48 | #if defined(__clang__) && defined(__aarch64__) && !defined(LIBYUV_DISABLE_NEON) 49 | #if (__clang_major__ < 3) || (__clang_major__ == 3 && (__clang_minor__ < 5)) 50 | #define LIBYUV_DISABLE_NEON 51 | #endif // clang >= 3.5 52 | #endif // __clang__ 53 | 54 | // GCC >= 4.7.0 required for AVX2. 55 | #if defined(__GNUC__) && !defined(LIBYUV_ENABLE_ROWWIN) && \ 56 | (defined(__x86_64__) || defined(__i386__)) 57 | #if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 7)) 58 | #define GCC_HAS_AVX2 1 59 | #endif // GNUC >= 4.7 60 | #endif // __GNUC__ 61 | 62 | // clang >= 3.4.0 required for AVX2. 63 | #if defined(__clang__) && !defined(LIBYUV_ENABLE_ROWWIN) && \ 64 | (defined(__x86_64__) || defined(__i386__)) 65 | #if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4)) 66 | #define CLANG_HAS_AVX2 1 67 | #endif // clang >= 3.4 68 | #endif // __clang__ 69 | 70 | // clang >= 6.0.0 required for AVX512. 71 | #if defined(__clang__) && !defined(LIBYUV_ENABLE_ROWWIN) && \ 72 | (defined(__x86_64__) || defined(__i386__)) 73 | // clang in xcode follows a different versioning scheme. 74 | // TODO(fbarchard): fix xcode 9 ios b/789. 75 | #if (__clang_major__ >= 7) && !defined(__APPLE__) 76 | #define CLANG_HAS_AVX512 1 77 | #endif // clang >= 7 78 | #endif // __clang__ 79 | 80 | // Visual C 2012 required for AVX2. 81 | #if defined(_M_IX86) && \ 82 | (!defined(__clang__) || defined(LIBYUV_ENABLE_ROWWIN)) && \ 83 | defined(_MSC_VER) && _MSC_VER >= 1700 84 | #define VISUALC_HAS_AVX2 1 85 | #endif // VisualStudio >= 2012 86 | 87 | // Clang 19 required for SME due to needing __arm_tpidr2_save from compiler-rt, 88 | // only enabled on Linux and Android (both define __linux__) for now. 89 | #if !defined(LIBYUV_DISABLE_SME) && defined(__aarch64__) && \ 90 | defined(__linux__) && defined(__clang__) && (__clang_major__ >= 19) 91 | #define CLANG_HAS_SME 1 92 | #endif 93 | 94 | #ifdef __cplusplus 95 | } // extern "C" 96 | } // namespace libyuv 97 | #endif 98 | 99 | #endif // INCLUDE_LIBYUV_CPU_SUPPORT_H_ 100 | -------------------------------------------------------------------------------- /core/deps/libyuv/include/libyuv/rotate_argb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_ROTATE_ARGB_H_ 12 | #define INCLUDE_LIBYUV_ROTATE_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/rotate.h" // For RotationMode. 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | // Rotate ARGB frame 23 | LIBYUV_API 24 | int ARGBRotate(const uint8_t* src_argb, 25 | int src_stride_argb, 26 | uint8_t* dst_argb, 27 | int dst_stride_argb, 28 | int src_width, 29 | int src_height, 30 | enum RotationMode mode); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | } // namespace libyuv 35 | #endif 36 | 37 | #endif // INCLUDE_LIBYUV_ROTATE_ARGB_H_ 38 | -------------------------------------------------------------------------------- /core/deps/libyuv/include/libyuv/scale_argb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_SCALE_ARGB_H_ 12 | #define INCLUDE_LIBYUV_SCALE_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/scale.h" // For FilterMode 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | LIBYUV_API 23 | int ARGBScale(const uint8_t* src_argb, 24 | int src_stride_argb, 25 | int src_width, 26 | int src_height, 27 | uint8_t* dst_argb, 28 | int dst_stride_argb, 29 | int dst_width, 30 | int dst_height, 31 | enum FilterMode filtering); 32 | 33 | // Clipped scale takes destination rectangle coordinates for clip values. 34 | LIBYUV_API 35 | int ARGBScaleClip(const uint8_t* src_argb, 36 | int src_stride_argb, 37 | int src_width, 38 | int src_height, 39 | uint8_t* dst_argb, 40 | int dst_stride_argb, 41 | int dst_width, 42 | int dst_height, 43 | int clip_x, 44 | int clip_y, 45 | int clip_width, 46 | int clip_height, 47 | enum FilterMode filtering); 48 | 49 | // Scale with YUV conversion to ARGB and clipping. 50 | LIBYUV_API 51 | int YUVToARGBScaleClip(const uint8_t* src_y, 52 | int src_stride_y, 53 | const uint8_t* src_u, 54 | int src_stride_u, 55 | const uint8_t* src_v, 56 | int src_stride_v, 57 | uint32_t src_fourcc, 58 | int src_width, 59 | int src_height, 60 | uint8_t* dst_argb, 61 | int dst_stride_argb, 62 | uint32_t dst_fourcc, 63 | int dst_width, 64 | int dst_height, 65 | int clip_x, 66 | int clip_y, 67 | int clip_width, 68 | int clip_height, 69 | enum FilterMode filtering); 70 | 71 | #ifdef __cplusplus 72 | } // extern "C" 73 | } // namespace libyuv 74 | #endif 75 | 76 | #endif // INCLUDE_LIBYUV_SCALE_ARGB_H_ 77 | -------------------------------------------------------------------------------- /core/deps/libyuv/include/libyuv/scale_rgb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_SCALE_RGB_H_ 12 | #define INCLUDE_LIBYUV_SCALE_RGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/scale.h" // For FilterMode 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | // RGB can be RAW, RGB24 or YUV24 23 | // RGB scales 24 bit images by converting a row at a time to ARGB 24 | // and using ARGB row functions to scale, then convert to RGB. 25 | // TODO(fbarchard): Allow input/output formats to be specified. 26 | LIBYUV_API 27 | int RGBScale(const uint8_t* src_rgb, 28 | int src_stride_rgb, 29 | int src_width, 30 | int src_height, 31 | uint8_t* dst_rgb, 32 | int dst_stride_rgb, 33 | int dst_width, 34 | int dst_height, 35 | enum FilterMode filtering); 36 | 37 | #ifdef __cplusplus 38 | } // extern "C" 39 | } // namespace libyuv 40 | #endif 41 | 42 | #endif // INCLUDE_LIBYUV_SCALE_UV_H_ 43 | -------------------------------------------------------------------------------- /core/deps/libyuv/include/libyuv/scale_uv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_SCALE_UV_H_ 12 | #define INCLUDE_LIBYUV_SCALE_UV_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/scale.h" // For FilterMode 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | LIBYUV_API 23 | int UVScale(const uint8_t* src_uv, 24 | int src_stride_uv, 25 | int src_width, 26 | int src_height, 27 | uint8_t* dst_uv, 28 | int dst_stride_uv, 29 | int dst_width, 30 | int dst_height, 31 | enum FilterMode filtering); 32 | 33 | // Scale a 16 bit UV image. 34 | // This function is currently incomplete, it can't handle all cases. 35 | LIBYUV_API 36 | int UVScale_16(const uint16_t* src_uv, 37 | int src_stride_uv, 38 | int src_width, 39 | int src_height, 40 | uint16_t* dst_uv, 41 | int dst_stride_uv, 42 | int dst_width, 43 | int dst_height, 44 | enum FilterMode filtering); 45 | 46 | #ifdef __cplusplus 47 | } // extern "C" 48 | } // namespace libyuv 49 | #endif 50 | 51 | #endif // INCLUDE_LIBYUV_SCALE_UV_H_ 52 | -------------------------------------------------------------------------------- /core/deps/libyuv/include/libyuv/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_VERSION_H_ 12 | #define INCLUDE_LIBYUV_VERSION_H_ 13 | 14 | #define LIBYUV_VERSION 1910 15 | 16 | #endif // INCLUDE_LIBYUV_VERSION_H_ 17 | -------------------------------------------------------------------------------- /core/deps/libyuv/infra/config/OWNERS: -------------------------------------------------------------------------------- 1 | fbarchard@chromium.org 2 | mbonadei@chromium.org 3 | jansson@google.com 4 | -------------------------------------------------------------------------------- /core/deps/libyuv/infra/config/PRESUBMIT.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The PDFium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | USE_PYTHON3 = True 6 | 7 | 8 | def CheckChangeOnUpload(input_api, output_api): 9 | return input_api.canned_checks.CheckChangedLUCIConfigs( 10 | input_api, output_api 11 | ) 12 | 13 | 14 | def CheckChangeOnCommit(input_api, output_api): 15 | return input_api.canned_checks.CheckChangedLUCIConfigs( 16 | input_api, output_api 17 | ) 18 | -------------------------------------------------------------------------------- /core/deps/libyuv/infra/config/README.md: -------------------------------------------------------------------------------- 1 | This folder contains libyuv project-wide configurations 2 | for chrome-infra services. 3 | -------------------------------------------------------------------------------- /core/deps/libyuv/infra/config/codereview.settings: -------------------------------------------------------------------------------- 1 | # This file is used by gcl and git-cl to get repository specific information. 2 | CODE_REVIEW_SERVER: codereview.chromium.org 3 | PROJECT: libyuv 4 | GERRIT_HOST: True 5 | VIEW_VC: https://chromium.googlesource.com/libyuv/libyuv/+/ 6 | 7 | -------------------------------------------------------------------------------- /core/deps/libyuv/infra/config/commit-queue.cfg: -------------------------------------------------------------------------------- 1 | # Auto-generated by lucicfg. 2 | # Do not modify manually. 3 | # 4 | # For the schema of this file, see Config message: 5 | # https://config.luci.app/schemas/projects:commit-queue.cfg 6 | 7 | cq_status_host: "chromium-cq-status.appspot.com" 8 | submit_options { 9 | max_burst: 4 10 | burst_delay { 11 | seconds: 480 12 | } 13 | } 14 | config_groups { 15 | name: "config" 16 | gerrit { 17 | url: "https://chromium-review.googlesource.com" 18 | projects { 19 | name: "libyuv/libyuv" 20 | ref_regexp: "refs/heads/infra/config" 21 | } 22 | } 23 | verifiers { 24 | gerrit_cq_ability { 25 | committer_list: "project-libyuv-committers" 26 | dry_run_access_list: "project-libyuv-tryjob-access" 27 | } 28 | tryjob { 29 | builders { 30 | name: "libyuv/try/presubmit" 31 | } 32 | retry_config { 33 | single_quota: 1 34 | global_quota: 2 35 | failure_weight: 1 36 | transient_failure_weight: 1 37 | timeout_weight: 2 38 | } 39 | } 40 | } 41 | } 42 | config_groups { 43 | name: "master" 44 | gerrit { 45 | url: "https://chromium-review.googlesource.com" 46 | projects { 47 | name: "libyuv/libyuv" 48 | ref_regexp: "refs/heads/main" 49 | ref_regexp: "refs/heads/master" 50 | } 51 | } 52 | verifiers { 53 | gerrit_cq_ability { 54 | committer_list: "project-libyuv-committers" 55 | dry_run_access_list: "project-libyuv-tryjob-access" 56 | } 57 | tryjob { 58 | builders { 59 | name: "libyuv/try/android" 60 | experiment_percentage: 100 61 | } 62 | builders { 63 | name: "libyuv/try/android_arm64" 64 | experiment_percentage: 100 65 | } 66 | builders { 67 | name: "libyuv/try/android_rel" 68 | experiment_percentage: 100 69 | } 70 | builders { 71 | name: "libyuv/try/android_x64" 72 | } 73 | builders { 74 | name: "libyuv/try/android_x86" 75 | } 76 | builders { 77 | name: "libyuv/try/ios_arm64" 78 | } 79 | builders { 80 | name: "libyuv/try/ios_arm64_rel" 81 | } 82 | builders { 83 | name: "libyuv/try/linux" 84 | } 85 | builders { 86 | name: "libyuv/try/linux_asan" 87 | } 88 | builders { 89 | name: "libyuv/try/linux_gcc" 90 | experiment_percentage: 100 91 | } 92 | builders { 93 | name: "libyuv/try/linux_msan" 94 | experiment_percentage: 100 95 | } 96 | builders { 97 | name: "libyuv/try/linux_rel" 98 | } 99 | builders { 100 | name: "libyuv/try/linux_tsan2" 101 | } 102 | builders { 103 | name: "libyuv/try/linux_ubsan" 104 | } 105 | builders { 106 | name: "libyuv/try/linux_ubsan_vptr" 107 | } 108 | builders { 109 | name: "libyuv/try/mac" 110 | } 111 | builders { 112 | name: "libyuv/try/mac_asan" 113 | } 114 | builders { 115 | name: "libyuv/try/mac_rel" 116 | } 117 | builders { 118 | name: "libyuv/try/win" 119 | } 120 | builders { 121 | name: "libyuv/try/win_clang" 122 | } 123 | builders { 124 | name: "libyuv/try/win_clang_rel" 125 | } 126 | builders { 127 | name: "libyuv/try/win_rel" 128 | } 129 | builders { 130 | name: "libyuv/try/win_x64_clang_rel" 131 | } 132 | builders { 133 | name: "libyuv/try/win_x64_rel" 134 | } 135 | retry_config { 136 | single_quota: 1 137 | global_quota: 2 138 | failure_weight: 1 139 | transient_failure_weight: 1 140 | timeout_weight: 2 141 | } 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /core/deps/libyuv/infra/config/luci-logdog.cfg: -------------------------------------------------------------------------------- 1 | # Auto-generated by lucicfg. 2 | # Do not modify manually. 3 | # 4 | # For the schema of this file, see ProjectConfig message: 5 | # https://config.luci.app/schemas/projects:luci-logdog.cfg 6 | 7 | reader_auth_groups: "all" 8 | writer_auth_groups: "luci-logdog-chromium-writers" 9 | archive_gs_bucket: "chromium-luci-logdog" 10 | -------------------------------------------------------------------------------- /core/deps/libyuv/infra/config/project.cfg: -------------------------------------------------------------------------------- 1 | # Auto-generated by lucicfg. 2 | # Do not modify manually. 3 | # 4 | # For the schema of this file, see ProjectCfg message: 5 | # https://config.luci.app/schemas/projects:project.cfg 6 | 7 | name: "libyuv" 8 | access: "group:all" 9 | lucicfg { 10 | version: "1.43.16" 11 | package_dir: "." 12 | config_dir: "." 13 | entry_point: "main.star" 14 | experiments: "crbug.com/1182002" 15 | } 16 | -------------------------------------------------------------------------------- /core/deps/libyuv/infra/config/realms.cfg: -------------------------------------------------------------------------------- 1 | # Auto-generated by lucicfg. 2 | # Do not modify manually. 3 | # 4 | # For the schema of this file, see RealmsCfg message: 5 | # https://config.luci.app/schemas/projects:realms.cfg 6 | 7 | realms { 8 | name: "@root" 9 | bindings { 10 | role: "role/buildbucket.owner" 11 | principals: "group:project-libyuv-admins" 12 | } 13 | bindings { 14 | role: "role/buildbucket.reader" 15 | principals: "group:all" 16 | } 17 | bindings { 18 | role: "role/configs.reader" 19 | principals: "group:all" 20 | } 21 | bindings { 22 | role: "role/configs.validator" 23 | principals: "user:libyuv-try-builder@chops-service-accounts.iam.gserviceaccount.com" 24 | } 25 | bindings { 26 | role: "role/logdog.reader" 27 | principals: "group:all" 28 | } 29 | bindings { 30 | role: "role/logdog.writer" 31 | principals: "group:luci-logdog-chromium-writers" 32 | } 33 | bindings { 34 | role: "role/scheduler.owner" 35 | principals: "group:project-libyuv-admins" 36 | } 37 | bindings { 38 | role: "role/scheduler.reader" 39 | principals: "group:all" 40 | } 41 | bindings { 42 | role: "role/swarming.taskTriggerer" 43 | principals: "group:project-libyuv-admins" 44 | } 45 | } 46 | realms { 47 | name: "ci" 48 | bindings { 49 | role: "role/buildbucket.builderServiceAccount" 50 | principals: "user:libyuv-ci-builder@chops-service-accounts.iam.gserviceaccount.com" 51 | } 52 | bindings { 53 | role: "role/scheduler.triggerer" 54 | principals: "user:libyuv-ci-builder@chops-service-accounts.iam.gserviceaccount.com" 55 | conditions { 56 | restrict { 57 | attribute: "scheduler.job.name" 58 | values: "Android Tester ARM32 Debug (Nexus 5X)" 59 | values: "Android Tester ARM32 Release (Nexus 5X)" 60 | values: "Android Tester ARM64 Debug (Nexus 5X)" 61 | } 62 | } 63 | } 64 | } 65 | realms { 66 | name: "cron" 67 | bindings { 68 | role: "role/buildbucket.builderServiceAccount" 69 | principals: "user:libyuv-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com" 70 | } 71 | } 72 | realms { 73 | name: "try" 74 | bindings { 75 | role: "role/buildbucket.builderServiceAccount" 76 | principals: "user:libyuv-try-builder@chops-service-accounts.iam.gserviceaccount.com" 77 | } 78 | bindings { 79 | role: "role/buildbucket.triggerer" 80 | principals: "group:project-libyuv-tryjob-access" 81 | principals: "group:service-account-cq" 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /core/deps/libyuv/libyuv.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import("//build/config/arm.gni") 10 | import("//build/config/loongarch64.gni") 11 | import("//build/config/mips.gni") 12 | import("//build_overrides/build.gni") 13 | 14 | declare_args() { 15 | libyuv_include_tests = !build_with_chromium 16 | libyuv_disable_jpeg = false 17 | libyuv_disable_rvv = false 18 | libyuv_use_neon = 19 | current_cpu == "arm64" || 20 | (current_cpu == "arm" && (arm_use_neon || arm_optionally_use_neon)) 21 | libyuv_use_sve = current_cpu == "arm64" 22 | 23 | # Restrict to (is_linux || is_android) to work around undefined symbol linker 24 | # errors on Fuchsia, macOS, and compilation errors on Windows. 25 | # TODO: bug 359006069 - Remove the restriction after the linker and 26 | # compilation errors are fixed. 27 | libyuv_use_sme = current_cpu == "arm64" && (is_linux || is_android) 28 | libyuv_use_msa = 29 | (current_cpu == "mips64el" || current_cpu == "mipsel") && mips_use_msa 30 | libyuv_use_mmi = 31 | (current_cpu == "mips64el" || current_cpu == "mipsel") && mips_use_mmi 32 | libyuv_use_lsx = current_cpu == "loong64" && loongarch64_use_lsx 33 | libyuv_use_lasx = current_cpu == "loong64" && loongarch64_use_lasx 34 | } 35 | -------------------------------------------------------------------------------- /core/deps/libyuv/libyuv.gypi: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'variables': { 11 | 'libyuv_sources': [ 12 | # includes. 13 | 'include/libyuv.h', 14 | 'include/libyuv/basic_types.h', 15 | 'include/libyuv/compare.h', 16 | 'include/libyuv/compare_row.h', 17 | 'include/libyuv/convert.h', 18 | 'include/libyuv/convert_argb.h', 19 | 'include/libyuv/convert_from.h', 20 | 'include/libyuv/convert_from_argb.h', 21 | 'include/libyuv/cpu_id.h', 22 | 'include/libyuv/cpu_support.h', 23 | 'include/libyuv/loongson_intrinsics.h', 24 | 'include/libyuv/macros_msa.h', 25 | 'include/libyuv/mjpeg_decoder.h', 26 | 'include/libyuv/planar_functions.h', 27 | 'include/libyuv/rotate.h', 28 | 'include/libyuv/rotate_argb.h', 29 | 'include/libyuv/rotate_row.h', 30 | 'include/libyuv/row.h', 31 | 'include/libyuv/scale.h', 32 | 'include/libyuv/scale_argb.h', 33 | 'include/libyuv/scale_rgb.h', 34 | 'include/libyuv/scale_row.h', 35 | 'include/libyuv/scale_uv.h', 36 | 'include/libyuv/version.h', 37 | 'include/libyuv/video_common.h', 38 | 39 | # sources. 40 | 'source/compare.cc', 41 | 'source/compare_common.cc', 42 | 'source/compare_gcc.cc', 43 | 'source/compare_msa.cc', 44 | 'source/compare_neon.cc', 45 | 'source/compare_neon64.cc', 46 | 'source/compare_win.cc', 47 | 'source/convert.cc', 48 | 'source/convert_argb.cc', 49 | 'source/convert_from.cc', 50 | 'source/convert_from_argb.cc', 51 | 'source/convert_jpeg.cc', 52 | 'source/convert_to_argb.cc', 53 | 'source/convert_to_i420.cc', 54 | 'source/cpu_id.cc', 55 | 'source/mjpeg_decoder.cc', 56 | 'source/mjpeg_validate.cc', 57 | 'source/planar_functions.cc', 58 | 'source/rotate.cc', 59 | 'source/rotate_any.cc', 60 | 'source/rotate_argb.cc', 61 | 'source/rotate_common.cc', 62 | 'source/rotate_gcc.cc', 63 | 'source/rotate_lsx.cc', 64 | 'source/rotate_msa.cc', 65 | 'source/rotate_neon.cc', 66 | 'source/rotate_neon64.cc', 67 | 'source/rotate_win.cc', 68 | 'source/row_any.cc', 69 | 'source/row_common.cc', 70 | 'source/row_gcc.cc', 71 | 'source/row_msa.cc', 72 | 'source/row_lasx.cc', 73 | 'source/row_lsx.cc', 74 | 'source/row_neon.cc', 75 | 'source/row_neon64.cc', 76 | 'source/row_win.cc', 77 | 'source/scale.cc', 78 | 'source/scale_any.cc', 79 | 'source/scale_argb.cc', 80 | 'source/scale_common.cc', 81 | 'source/scale_gcc.cc', 82 | 'source/scale_lsx.cc', 83 | 'source/scale_msa.cc', 84 | 'source/scale_neon.cc', 85 | 'source/scale_neon64.cc', 86 | 'source/scale_rgb.cc', 87 | 'source/scale_uv.cc', 88 | 'source/scale_win.cc', 89 | 'source/video_common.cc', 90 | ], 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /core/deps/libyuv/linux.mk: -------------------------------------------------------------------------------- 1 | # This is a generic makefile for libyuv for gcc. 2 | # make -f linux.mk CXX=clang++ 3 | 4 | CC?=gcc 5 | CFLAGS?=-O2 -fomit-frame-pointer 6 | CFLAGS+=-Iinclude/ 7 | 8 | CXX?=g++ 9 | CXXFLAGS?=-O2 -fomit-frame-pointer 10 | CXXFLAGS+=-Iinclude/ 11 | 12 | LOCAL_OBJ_FILES := \ 13 | source/compare.o \ 14 | source/compare_common.o \ 15 | source/compare_gcc.o \ 16 | source/compare_msa.o \ 17 | source/compare_neon.o \ 18 | source/compare_neon64.o \ 19 | source/compare_win.o \ 20 | source/convert.o \ 21 | source/convert_argb.o \ 22 | source/convert_from.o \ 23 | source/convert_from_argb.o \ 24 | source/convert_jpeg.o \ 25 | source/convert_to_argb.o \ 26 | source/convert_to_i420.o \ 27 | source/cpu_id.o \ 28 | source/mjpeg_decoder.o \ 29 | source/mjpeg_validate.o \ 30 | source/planar_functions.o \ 31 | source/rotate.o \ 32 | source/rotate_any.o \ 33 | source/rotate_argb.o \ 34 | source/rotate_common.o \ 35 | source/rotate_gcc.o \ 36 | source/rotate_lsx.o \ 37 | source/rotate_msa.o \ 38 | source/rotate_neon.o \ 39 | source/rotate_neon64.o \ 40 | source/rotate_win.o \ 41 | source/row_any.o \ 42 | source/row_common.o \ 43 | source/row_gcc.o \ 44 | source/row_lasx.o \ 45 | source/row_lsx.o \ 46 | source/row_msa.o \ 47 | source/row_neon.o \ 48 | source/row_neon64.o \ 49 | source/row_rvv.o \ 50 | source/row_win.o \ 51 | source/scale.o \ 52 | source/scale_any.o \ 53 | source/scale_argb.o \ 54 | source/scale_common.o \ 55 | source/scale_gcc.o \ 56 | source/scale_lsx.o \ 57 | source/scale_msa.o \ 58 | source/scale_neon.o \ 59 | source/scale_neon64.o \ 60 | source/scale_rgb.o \ 61 | source/scale_rvv.o \ 62 | source/scale_uv.o \ 63 | source/scale_win.o \ 64 | source/video_common.o 65 | 66 | .cc.o: 67 | $(CXX) -c $(CXXFLAGS) $*.cc -o $*.o 68 | 69 | .c.o: 70 | $(CC) -c $(CFLAGS) $*.c -o $*.o 71 | 72 | all: libyuv.a i444tonv12_eg yuvconvert yuvconstants cpuid psnr 73 | 74 | libyuv.a: $(LOCAL_OBJ_FILES) 75 | $(AR) $(ARFLAGS) $@ $(LOCAL_OBJ_FILES) 76 | 77 | # A C++ test utility that uses libyuv conversion. 78 | yuvconvert: util/yuvconvert.cc libyuv.a 79 | $(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/yuvconvert.cc libyuv.a 80 | 81 | # A C test utility that generates yuvconstants for yuv to rgb. 82 | yuvconstants: util/yuvconstants.c libyuv.a 83 | $(CXX) $(CXXFLAGS) -Iutil/ -lm -o $@ util/yuvconstants.c libyuv.a 84 | 85 | # A standalone test utility 86 | psnr: util/psnr.cc 87 | $(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/psnr.cc util/psnr_main.cc util/ssim.cc 88 | 89 | # A simple conversion example. 90 | i444tonv12_eg: util/i444tonv12_eg.cc libyuv.a 91 | $(CXX) $(CXXFLAGS) -o $@ util/i444tonv12_eg.cc libyuv.a 92 | 93 | # A C test utility that uses libyuv conversion from C. 94 | # gcc 4.4 and older require -fno-exceptions to avoid link error on __gxx_personality_v0 95 | # CC=gcc-4.4 CXXFLAGS=-fno-exceptions CXX=g++-4.4 make -f linux.mk 96 | cpuid: util/cpuid.c libyuv.a 97 | $(CC) $(CFLAGS) -o $@ util/cpuid.c libyuv.a 98 | 99 | clean: 100 | /bin/rm -f source/*.o *.ii *.s libyuv.a i444tonv12_eg yuvconvert yuvconstants cpuid psnr 101 | -------------------------------------------------------------------------------- /core/deps/libyuv/public.mk: -------------------------------------------------------------------------------- 1 | # This file contains all the common make variables which are useful for 2 | # anyone depending on this library. 3 | # Note that dependencies on NDK are not directly listed since NDK auto adds 4 | # them. 5 | 6 | LIBYUV_INCLUDES := $(LIBYUV_PATH)/include 7 | 8 | LIBYUV_C_FLAGS := 9 | 10 | LIBYUV_CPP_FLAGS := 11 | 12 | LIBYUV_LDLIBS := 13 | LIBYUV_DEP_MODULES := 14 | -------------------------------------------------------------------------------- /core/deps/libyuv/pylintrc: -------------------------------------------------------------------------------- 1 | [MESSAGES CONTROL] 2 | 3 | # Disable the message, report, category or checker with the given id(s). 4 | # TODO(kjellander): Reduce this list to as small as possible. 5 | disable=I0010,I0011,bad-continuation,broad-except,duplicate-code,eval-used,exec-used,fixme,invalid-name,missing-docstring,no-init,no-member,too-few-public-methods,too-many-ancestors,too-many-arguments,too-many-branches,too-many-function-args,too-many-instance-attributes,too-many-lines,too-many-locals,too-many-public-methods,too-many-return-statements,too-many-statements 6 | 7 | 8 | [REPORTS] 9 | 10 | # Don't write out full reports, just messages. 11 | reports=no 12 | 13 | 14 | [FORMAT] 15 | 16 | # Maximum number of characters on a single line. 17 | max-line-length=79 18 | 19 | # We use four spaces for indents. 20 | indent-string=' ' 21 | 22 | [BASIC] 23 | 24 | # List of builtins function names that should not be used, separated by a comma 25 | bad-functions=map,filter,apply,input 26 | 27 | # Naming style matching correct module names. 28 | module-naming-style=snake_case 29 | 30 | # Naming style matching correct constant names. 31 | const-naming-style=UPPER_CASE 32 | 33 | # Naming style matching correct class names. 34 | class-naming-style=PascalCase 35 | 36 | # Naming style matching correct function names. 37 | function-naming-style=snake_case 38 | 39 | # Regular expression matching correct method names. 40 | method-rgx=([a-z_][a-z0-9_]{2,}|setUp|tearDown)$ 41 | 42 | # Naming style matching correct attribute names. 43 | attr-naming-style=snake_case 44 | 45 | # Naming style matching correct argument names. 46 | argument-naming-style=snake_case 47 | 48 | # Naming style matching correct variable names. 49 | variable-naming-style=snake_case 50 | -------------------------------------------------------------------------------- /core/deps/libyuv/riscv_script/prepare_toolchain_qemu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ev 3 | 4 | # Download & build RISC-V Clang toolchain & QEMU emulator. 5 | # RISC-V Clang is for cross compile with the RISC-V Vector ISA. 6 | # RISC-V QEMU is used to run the test suite. 7 | # 8 | # Requirements: Linux host w/ working C++ compiler, git, cmake, ninja, wget, tar 9 | 10 | # NOTE: this script must be run from the top-level directory of the LIBYUV_SRC_DIR. 11 | 12 | RISCV_TRIPLE="riscv64-unknown-linux-gnu" 13 | RISCV_QEMU="qemu-riscv64" 14 | 15 | LIBYUV_SRC_DIR=$(pwd) 16 | BUILD_DIR="$LIBYUV_SRC_DIR"/build-toolchain-qemu 17 | INSTALL_QEMU="$BUILD_DIR"/riscv-qemu 18 | INSTALL_CLANG="$BUILD_DIR"/riscv-clang 19 | 20 | LLVM_VERSION="16.0.0" 21 | LLVM_NAME=llvm-project-"$LLVM_VERSION".src 22 | 23 | RISCV_GNU_TOOLCHAIN="$BUILD_DIR"/riscv-gnu-toolchain 24 | RISCV_CLANG_TOOLCHAIN="$BUILD_DIR"/"$LLVM_NAME" 25 | 26 | QEMU_NAME="qemu-7.0.0" 27 | 28 | mkdir -p "$BUILD_DIR" 29 | cd "$BUILD_DIR" 30 | 31 | # Download and install RISC-V GNU Toolchain (needed to build Clang) 32 | if [ ! -d "$RISCV_GNU_TOOLCHAIN" ] 33 | then 34 | git clone git@github.com:riscv/riscv-gnu-toolchain.git 35 | pushd "$RISCV_GNU_TOOLCHAIN" 36 | git submodule update --init --recursive 37 | ./configure --with-cmodel=medany --prefix="$INSTALL_CLANG" 38 | ionice nice make linux -j `nproc` install 39 | popd 40 | fi 41 | 42 | # Download Clang toolchain & build cross compiler 43 | if [ ! -d "$RISCV_CLANG_TOOLCHAIN" ] 44 | then 45 | wget https://github.com/llvm/llvm-project/releases/download/llvmorg-"$LLVM_VERSION"/"$LLVM_NAME".tar.xz 46 | tar xvJf "$LLVM_NAME".tar.xz 47 | pushd "$RISCV_CLANG_TOOLCHAIN" 48 | cmake -DCMAKE_INSTALL_PREFIX="$INSTALL_CLANG" \ 49 | -DCMAKE_BUILD_TYPE=Release \ 50 | -DLLVM_TARGETS_TO_BUILD="RISCV" \ 51 | -DLLVM_ENABLE_PROJECTS="clang" \ 52 | -DLLVM_DEFAULT_TARGET_TRIPLE="$RISCV_TRIPLE" \ 53 | -DLLVM_INSTALL_TOOLCHAIN_ONLY=On \ 54 | -DDEFAULT_SYSROOT=../sysroot \ 55 | -G "Ninja" "$RISCV_CLANG_TOOLCHAIN"/llvm 56 | ionice nice ninja -j `nproc` 57 | ionice nice ninja -j `nproc` install 58 | popd 59 | pushd "$INSTALL_CLANG"/bin 60 | ln -sf clang "$RISCV_TRIPLE"-clang 61 | ln -sf clang++ "$RISCV_TRIPLE"-clang++ 62 | popd 63 | fi 64 | 65 | # Download QEMU and build the riscv64 Linux usermode emulator 66 | if [ ! -d "$QEMU_NAME" ] 67 | then 68 | wget https://download.qemu.org/"$QEMU_NAME".tar.xz 69 | tar xvJf "$QEMU_NAME".tar.xz 70 | pushd "$QEMU_NAME" 71 | ./configure --target-list=riscv64-linux-user --prefix="$INSTALL_QEMU" 72 | ionice nice make -j `nproc` install 73 | popd 74 | fi 75 | -------------------------------------------------------------------------------- /core/deps/libyuv/riscv_script/riscv-clang.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_CROSSCOMPILING TRUE) 2 | set(CMAKE_SYSTEM_NAME "Linux") 3 | set(CMAKE_SYSTEM_PROCESSOR "riscv64") 4 | 5 | option(USE_RVV "Enable riscv vector or not." ON) 6 | option(USE_AUTO_VECTORIZER "Enable riscv auto vectorizer or not." OFF) 7 | 8 | # Avoid to use system path for cross-compile 9 | set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE) 10 | 11 | set(TOOLCHAIN_PATH "" CACHE STRING "The toolcahin path.") 12 | if(NOT TOOLCHAIN_PATH) 13 | set(TOOLCHAIN_PATH ${CMAKE_SOURCE_DIR}/build-toolchain-qemu/riscv-clang) 14 | endif() 15 | 16 | set(TOOLCHAIN_PREFIX "riscv64-unknown-linux-gnu-" CACHE STRING "The toolcahin prefix.") 17 | 18 | # toolchain setting 19 | set(CMAKE_C_COMPILER "${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}clang") 20 | set(CMAKE_CXX_COMPILER "${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}clang++") 21 | 22 | # CMake will just use the host-side tools for the following tools, so we setup them here. 23 | set(CMAKE_C_COMPILER_AR "${TOOLCHAIN_PATH}/bin/llvm-ar") 24 | set(CMAKE_CXX_COMPILER_AR "${TOOLCHAIN_PATH}/bin/llvm-ar") 25 | set(CMAKE_C_COMPILER_RANLIB "${TOOLCHAIN_PATH}/bin/llvm-ranlib") 26 | set(CMAKE_CXX_COMPILER_RANLIB "${TOOLCHAIN_PATH}/bin/llvm-ranlib") 27 | set(CMAKE_OBJDUMP "${TOOLCHAIN_PATH}/bin/llvm-objdump") 28 | set(CMAKE_OBJCOPY "${TOOLCHAIN_PATH}/bin/llvm-objcopy") 29 | 30 | # compile options 31 | set(RISCV_COMPILER_FLAGS "" CACHE STRING "Compile flags") 32 | # if user provides RISCV_COMPILER_FLAGS, appeding compile flags is avoided. 33 | if(RISCV_COMPILER_FLAGS STREQUAL "") 34 | message(STATUS "USE_RVV: ${USE_RVV}") 35 | message(STATUS "USE_AUTO_VECTORIZER: ${USE_AUTO_VECTORIZER}") 36 | if(USE_RVV) 37 | list(APPEND RISCV_COMPILER_FLAGS "-march=rv64gcv") 38 | if(NOT USE_AUTO_VECTORIZER) 39 | # Disable auto-vectorizer 40 | add_compile_options(-fno-vectorize -fno-slp-vectorize) 41 | endif() 42 | else() 43 | list(APPEND RISCV_COMPILER_FLAGS "-march=rv64gc") 44 | endif() 45 | endif() 46 | add_compile_options("-Wuninitialized") 47 | message(STATUS "RISCV_COMPILER_FLAGS: ${RISCV_COMPILER_FLAGS}") 48 | 49 | set(CMAKE_C_FLAGS "${RISCV_COMPILER_FLAGS} ${CMAKE_C_FLAGS}") 50 | set(CMAKE_CXX_FLAGS "${RISCV_COMPILER_FLAGS} ${CMAKE_CXX_FLAGS}") 51 | 52 | set(RISCV_LINKER_FLAGS "-lstdc++ -lpthread -lm -ldl") 53 | set(RISCV_LINKER_FLAGS_EXE) 54 | set(CMAKE_SHARED_LINKER_FLAGS "${RISCV_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") 55 | set(CMAKE_MODULE_LINKER_FLAGS "${RISCV_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}") 56 | set(CMAKE_EXE_LINKER_FLAGS "${RISCV_LINKER_FLAGS} ${RISCV_LINKER_FLAGS_EXE} ${CMAKE_EXE_LINKER_FLAGS}") 57 | -------------------------------------------------------------------------------- /core/deps/libyuv/riscv_script/run_qemu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | set -e 4 | 5 | USE_RVV="${USE_RVV:-OFF}" 6 | TOOLCHAIN_PATH="${TOOLCHAIN_PATH:-../../build-toolchain-qemu/riscv-clang}" 7 | QEMU_PREFIX_PATH="${QEMU_PREFIX_PATH:-../../build-toolchain-qemu/riscv-qemu/}" 8 | 9 | if [ "${USE_RVV}" = "ON" ];then 10 | 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" 11 | else 12 | QEMU_OPTION="-cpu rv64,zba=true,zbb=true,zbc=true,zbs=true -L ${TOOLCHAIN_PATH}/sysroot" 13 | fi 14 | 15 | $QEMU_PREFIX_PATH/bin/qemu-riscv64 $QEMU_OPTION $@ 16 | -------------------------------------------------------------------------------- /core/deps/libyuv/source/compare_common.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/basic_types.h" 12 | 13 | #include "libyuv/compare_row.h" 14 | 15 | #ifdef __cplusplus 16 | namespace libyuv { 17 | extern "C" { 18 | #endif 19 | 20 | // Hakmem method for hamming distance. 21 | uint32_t HammingDistance_C(const uint8_t* src_a, 22 | const uint8_t* src_b, 23 | int count) { 24 | uint32_t diff = 0u; 25 | 26 | int i; 27 | for (i = 0; i < count - 3; i += 4) { 28 | uint32_t x = *((const uint32_t*)src_a) ^ *((const uint32_t*)src_b); 29 | uint32_t u = x - ((x >> 1) & 0x55555555); 30 | u = ((u >> 2) & 0x33333333) + (u & 0x33333333); 31 | diff += ((((u + (u >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24); 32 | src_a += 4; 33 | src_b += 4; 34 | } 35 | 36 | for (; i < count; ++i) { 37 | uint32_t x = *src_a ^ *src_b; 38 | uint32_t u = x - ((x >> 1) & 0x55); 39 | u = ((u >> 2) & 0x33) + (u & 0x33); 40 | diff += (u + (u >> 4)) & 0x0f; 41 | src_a += 1; 42 | src_b += 1; 43 | } 44 | 45 | return diff; 46 | } 47 | 48 | uint32_t SumSquareError_C(const uint8_t* src_a, 49 | const uint8_t* src_b, 50 | int count) { 51 | uint32_t sse = 0u; 52 | int i; 53 | for (i = 0; i < count; ++i) { 54 | int diff = src_a[i] - src_b[i]; 55 | sse += (uint32_t)(diff * diff); 56 | } 57 | return sse; 58 | } 59 | 60 | // hash seed of 5381 recommended. 61 | // Internal C version of HashDjb2 with int sized count for efficiency. 62 | uint32_t HashDjb2_C(const uint8_t* src, int count, uint32_t seed) { 63 | uint32_t hash = seed; 64 | int i; 65 | for (i = 0; i < count; ++i) { 66 | hash += (hash << 5) + src[i]; 67 | } 68 | return hash; 69 | } 70 | 71 | #ifdef __cplusplus 72 | } // extern "C" 73 | } // namespace libyuv 74 | #endif 75 | -------------------------------------------------------------------------------- /core/deps/libyuv/source/compare_msa.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/basic_types.h" 12 | 13 | #include "libyuv/compare_row.h" 14 | #include "libyuv/row.h" 15 | 16 | // This module is for GCC MSA 17 | #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) 18 | #include "libyuv/macros_msa.h" 19 | 20 | #ifdef __cplusplus 21 | namespace libyuv { 22 | extern "C" { 23 | #endif 24 | 25 | uint32_t HammingDistance_MSA(const uint8_t* src_a, 26 | const uint8_t* src_b, 27 | int count) { 28 | uint32_t diff = 0u; 29 | int i; 30 | v16u8 src0, src1, src2, src3; 31 | v2i64 vec0 = {0}, vec1 = {0}; 32 | 33 | for (i = 0; i < count; i += 32) { 34 | src0 = (v16u8)__msa_ld_b((v16i8*)src_a, 0); 35 | src1 = (v16u8)__msa_ld_b((v16i8*)src_a, 16); 36 | src2 = (v16u8)__msa_ld_b((v16i8*)src_b, 0); 37 | src3 = (v16u8)__msa_ld_b((v16i8*)src_b, 16); 38 | src0 ^= src2; 39 | src1 ^= src3; 40 | vec0 += __msa_pcnt_d((v2i64)src0); 41 | vec1 += __msa_pcnt_d((v2i64)src1); 42 | src_a += 32; 43 | src_b += 32; 44 | } 45 | 46 | vec0 += vec1; 47 | diff = (uint32_t)__msa_copy_u_w((v4i32)vec0, 0); 48 | diff += (uint32_t)__msa_copy_u_w((v4i32)vec0, 2); 49 | return diff; 50 | } 51 | 52 | uint32_t SumSquareError_MSA(const uint8_t* src_a, 53 | const uint8_t* src_b, 54 | int count) { 55 | uint32_t sse = 0u; 56 | int i; 57 | v16u8 src0, src1, src2, src3; 58 | v8i16 vec0, vec1, vec2, vec3; 59 | v4i32 reg0 = {0}, reg1 = {0}, reg2 = {0}, reg3 = {0}; 60 | v2i64 tmp0; 61 | 62 | for (i = 0; i < count; i += 32) { 63 | src0 = (v16u8)__msa_ld_b((v16i8*)src_a, 0); 64 | src1 = (v16u8)__msa_ld_b((v16i8*)src_a, 16); 65 | src2 = (v16u8)__msa_ld_b((v16i8*)src_b, 0); 66 | src3 = (v16u8)__msa_ld_b((v16i8*)src_b, 16); 67 | vec0 = (v8i16)__msa_ilvr_b((v16i8)src2, (v16i8)src0); 68 | vec1 = (v8i16)__msa_ilvl_b((v16i8)src2, (v16i8)src0); 69 | vec2 = (v8i16)__msa_ilvr_b((v16i8)src3, (v16i8)src1); 70 | vec3 = (v8i16)__msa_ilvl_b((v16i8)src3, (v16i8)src1); 71 | vec0 = __msa_hsub_u_h((v16u8)vec0, (v16u8)vec0); 72 | vec1 = __msa_hsub_u_h((v16u8)vec1, (v16u8)vec1); 73 | vec2 = __msa_hsub_u_h((v16u8)vec2, (v16u8)vec2); 74 | vec3 = __msa_hsub_u_h((v16u8)vec3, (v16u8)vec3); 75 | reg0 = __msa_dpadd_s_w(reg0, vec0, vec0); 76 | reg1 = __msa_dpadd_s_w(reg1, vec1, vec1); 77 | reg2 = __msa_dpadd_s_w(reg2, vec2, vec2); 78 | reg3 = __msa_dpadd_s_w(reg3, vec3, vec3); 79 | src_a += 32; 80 | src_b += 32; 81 | } 82 | 83 | reg0 += reg1; 84 | reg2 += reg3; 85 | reg0 += reg2; 86 | tmp0 = __msa_hadd_s_d(reg0, reg0); 87 | sse = (uint32_t)__msa_copy_u_w((v4i32)tmp0, 0); 88 | sse += (uint32_t)__msa_copy_u_w((v4i32)tmp0, 2); 89 | return sse; 90 | } 91 | 92 | #ifdef __cplusplus 93 | } // extern "C" 94 | } // namespace libyuv 95 | #endif 96 | 97 | #endif // !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) 98 | -------------------------------------------------------------------------------- /core/deps/libyuv/source/compare_neon.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/basic_types.h" 12 | 13 | #include "libyuv/compare_row.h" 14 | #include "libyuv/row.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | #if !defined(LIBYUV_DISABLE_NEON) && defined(__ARM_NEON__) && \ 22 | !defined(__aarch64__) 23 | 24 | // 256 bits at a time 25 | // uses short accumulator which restricts count to 131 KB 26 | uint32_t HammingDistance_NEON(const uint8_t* src_a, 27 | const uint8_t* src_b, 28 | int count) { 29 | uint32_t diff; 30 | 31 | asm volatile( 32 | "vmov.u16 q4, #0 \n" // accumulator 33 | 34 | "1: \n" 35 | "vld1.8 {q0, q1}, [%0]! \n" 36 | "vld1.8 {q2, q3}, [%1]! \n" 37 | "veor.32 q0, q0, q2 \n" 38 | "veor.32 q1, q1, q3 \n" 39 | "vcnt.i8 q0, q0 \n" 40 | "vcnt.i8 q1, q1 \n" 41 | "subs %2, %2, #32 \n" 42 | "vadd.u8 q0, q0, q1 \n" // 16 byte counts 43 | "vpadal.u8 q4, q0 \n" // 8 shorts 44 | "bgt 1b \n" 45 | 46 | "vpaddl.u16 q0, q4 \n" // 4 ints 47 | "vpadd.u32 d0, d0, d1 \n" 48 | "vpadd.u32 d0, d0, d0 \n" 49 | "vmov.32 %3, d0[0] \n" 50 | 51 | : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(diff) 52 | : 53 | : "cc", "q0", "q1", "q2", "q3", "q4"); 54 | return diff; 55 | } 56 | 57 | uint32_t SumSquareError_NEON(const uint8_t* src_a, 58 | const uint8_t* src_b, 59 | int count) { 60 | uint32_t sse; 61 | asm volatile( 62 | "vmov.u8 q8, #0 \n" 63 | "vmov.u8 q10, #0 \n" 64 | "vmov.u8 q9, #0 \n" 65 | "vmov.u8 q11, #0 \n" 66 | 67 | "1: \n" 68 | "vld1.8 {q0}, [%0]! \n" 69 | "vld1.8 {q1}, [%1]! \n" 70 | "subs %2, %2, #16 \n" 71 | "vsubl.u8 q2, d0, d2 \n" 72 | "vsubl.u8 q3, d1, d3 \n" 73 | "vmlal.s16 q8, d4, d4 \n" 74 | "vmlal.s16 q9, d6, d6 \n" 75 | "vmlal.s16 q10, d5, d5 \n" 76 | "vmlal.s16 q11, d7, d7 \n" 77 | "bgt 1b \n" 78 | 79 | "vadd.u32 q8, q8, q9 \n" 80 | "vadd.u32 q10, q10, q11 \n" 81 | "vadd.u32 q11, q8, q10 \n" 82 | "vpaddl.u32 q1, q11 \n" 83 | "vadd.u64 d0, d2, d3 \n" 84 | "vmov.32 %3, d0[0] \n" 85 | : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse) 86 | : 87 | : "memory", "cc", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11"); 88 | return sse; 89 | } 90 | 91 | #endif // defined(__ARM_NEON__) && !defined(__aarch64__) 92 | 93 | #ifdef __cplusplus 94 | } // extern "C" 95 | } // namespace libyuv 96 | #endif 97 | -------------------------------------------------------------------------------- /core/deps/libyuv/source/mjpeg_validate.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/mjpeg_decoder.h" 12 | 13 | #include // For memchr. 14 | 15 | #ifdef __cplusplus 16 | namespace libyuv { 17 | extern "C" { 18 | #endif 19 | 20 | // Helper function to scan for EOI marker (0xff 0xd9). 21 | static LIBYUV_BOOL ScanEOI(const uint8_t* src_mjpg, size_t src_size_mjpg) { 22 | if (src_size_mjpg >= 2) { 23 | const uint8_t* end = src_mjpg + src_size_mjpg - 1; 24 | const uint8_t* it = src_mjpg; 25 | while (it < end) { 26 | // TODO(fbarchard): scan for 0xd9 instead. 27 | it = (const uint8_t*)(memchr(it, 0xff, end - it)); 28 | if (it == NULL) { 29 | break; 30 | } 31 | if (it[1] == 0xd9) { 32 | return LIBYUV_TRUE; // Success: Valid jpeg. 33 | } 34 | ++it; // Skip over current 0xff. 35 | } 36 | } 37 | // ERROR: Invalid jpeg end code not found. Size src_size_mjpg 38 | return LIBYUV_FALSE; 39 | } 40 | 41 | // Helper function to validate the jpeg appears intact. 42 | LIBYUV_BOOL ValidateJpeg(const uint8_t* src_mjpg, size_t src_size_mjpg) { 43 | // Maximum size that ValidateJpeg will consider valid. 44 | const size_t kMaxJpegSize = 0x7fffffffull; 45 | const size_t kBackSearchSize = 1024; 46 | if (src_size_mjpg < 64 || src_size_mjpg > kMaxJpegSize || !src_mjpg) { 47 | // ERROR: Invalid jpeg size: src_size_mjpg 48 | return LIBYUV_FALSE; 49 | } 50 | // SOI marker 51 | if (src_mjpg[0] != 0xff || src_mjpg[1] != 0xd8 || src_mjpg[2] != 0xff) { 52 | // ERROR: Invalid jpeg initial start code 53 | return LIBYUV_FALSE; 54 | } 55 | 56 | // Look for the End Of Image (EOI) marker near the end of the buffer. 57 | if (src_size_mjpg > kBackSearchSize) { 58 | if (ScanEOI(src_mjpg + src_size_mjpg - kBackSearchSize, kBackSearchSize)) { 59 | return LIBYUV_TRUE; // Success: Valid jpeg. 60 | } 61 | // Reduce search size for forward search. 62 | src_size_mjpg = src_size_mjpg - kBackSearchSize + 1; 63 | } 64 | // Step over SOI marker and scan for EOI. 65 | return ScanEOI(src_mjpg + 2, src_size_mjpg - 2); 66 | } 67 | 68 | #ifdef __cplusplus 69 | } // extern "C" 70 | } // namespace libyuv 71 | #endif 72 | -------------------------------------------------------------------------------- /core/deps/libyuv/source/rotate_any.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/rotate.h" 12 | #include "libyuv/rotate_row.h" 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | #define TANY(NAMEANY, TPOS_SIMD, TPOS_C, MASK) \ 22 | void NAMEANY(const uint8_t* src, int src_stride, uint8_t* dst, \ 23 | int dst_stride, int width) { \ 24 | int r = width & MASK; \ 25 | int n = width - r; \ 26 | if (n > 0) { \ 27 | TPOS_SIMD(src, src_stride, dst, dst_stride, n); \ 28 | } \ 29 | TPOS_C(src + n, src_stride, dst + n * dst_stride, dst_stride, r); \ 30 | } 31 | 32 | #ifdef HAS_TRANSPOSEWX8_NEON 33 | TANY(TransposeWx8_Any_NEON, TransposeWx8_NEON, TransposeWx8_C, 7) 34 | #endif 35 | #ifdef HAS_TRANSPOSEWX16_NEON 36 | TANY(TransposeWx16_Any_NEON, TransposeWx16_NEON, TransposeWx16_C, 15) 37 | #endif 38 | #ifdef HAS_TRANSPOSEWX8_SSSE3 39 | TANY(TransposeWx8_Any_SSSE3, TransposeWx8_SSSE3, TransposeWx8_C, 7) 40 | #endif 41 | #ifdef HAS_TRANSPOSEWX8_FAST_SSSE3 42 | TANY(TransposeWx8_Fast_Any_SSSE3, TransposeWx8_Fast_SSSE3, TransposeWx8_C, 15) 43 | #endif 44 | #ifdef HAS_TRANSPOSEWX16_MSA 45 | TANY(TransposeWx16_Any_MSA, TransposeWx16_MSA, TransposeWx16_C, 15) 46 | #endif 47 | #ifdef HAS_TRANSPOSEWX16_LSX 48 | TANY(TransposeWx16_Any_LSX, TransposeWx16_LSX, TransposeWx16_C, 15) 49 | #endif 50 | #undef TANY 51 | 52 | #define TUVANY(NAMEANY, TPOS_SIMD, MASK) \ 53 | void NAMEANY(const uint8_t* src, int src_stride, uint8_t* dst_a, \ 54 | int dst_stride_a, uint8_t* dst_b, int dst_stride_b, \ 55 | int width) { \ 56 | int r = width & MASK; \ 57 | int n = width - r; \ 58 | if (n > 0) { \ 59 | TPOS_SIMD(src, src_stride, dst_a, dst_stride_a, dst_b, dst_stride_b, n); \ 60 | } \ 61 | TransposeUVWx8_C(src + n * 2, src_stride, dst_a + n * dst_stride_a, \ 62 | dst_stride_a, dst_b + n * dst_stride_b, dst_stride_b, r); \ 63 | } 64 | 65 | #ifdef HAS_TRANSPOSEUVWX8_NEON 66 | TUVANY(TransposeUVWx8_Any_NEON, TransposeUVWx8_NEON, 7) 67 | #endif 68 | #ifdef HAS_TRANSPOSEUVWX8_SSE2 69 | TUVANY(TransposeUVWx8_Any_SSE2, TransposeUVWx8_SSE2, 7) 70 | #endif 71 | #ifdef HAS_TRANSPOSEUVWX16_MSA 72 | TUVANY(TransposeUVWx16_Any_MSA, TransposeUVWx16_MSA, 7) 73 | #endif 74 | #ifdef HAS_TRANSPOSEUVWX16_LSX 75 | TUVANY(TransposeUVWx16_Any_LSX, TransposeUVWx16_LSX, 7) 76 | #endif 77 | #undef TUVANY 78 | 79 | #ifdef __cplusplus 80 | } // extern "C" 81 | } // namespace libyuv 82 | #endif 83 | -------------------------------------------------------------------------------- /core/deps/libyuv/source/scale_rgb.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/scale.h" /* For FilterMode */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "libyuv/convert_argb.h" 20 | #include "libyuv/convert_from_argb.h" 21 | #include "libyuv/row.h" 22 | #include "libyuv/scale_argb.h" 23 | #include "libyuv/scale_rgb.h" 24 | 25 | #ifdef __cplusplus 26 | namespace libyuv { 27 | extern "C" { 28 | #endif 29 | 30 | // Scale a 24 bit image. 31 | // Converts to ARGB as intermediate step 32 | 33 | LIBYUV_API 34 | int RGBScale(const uint8_t* src_rgb, 35 | int src_stride_rgb, 36 | int src_width, 37 | int src_height, 38 | uint8_t* dst_rgb, 39 | int dst_stride_rgb, 40 | int dst_width, 41 | int dst_height, 42 | enum FilterMode filtering) { 43 | int r; 44 | if (!src_rgb || !dst_rgb || src_width <= 0 || src_width > INT_MAX / 4 || 45 | src_height == 0 || dst_width <= 0 || dst_width > INT_MAX / 4 || 46 | dst_height <= 0) { 47 | return -1; 48 | } 49 | const int abs_src_height = (src_height < 0) ? -src_height : src_height; 50 | const uint64_t src_argb_size = (uint64_t)src_width * abs_src_height * 4; 51 | const uint64_t dst_argb_size = (uint64_t)dst_width * dst_height * 4; 52 | if (src_argb_size > (UINT64_MAX - dst_argb_size)) { 53 | return -1; // Invalid size. 54 | } 55 | const uint64_t argb_size = src_argb_size + dst_argb_size; 56 | if (argb_size > SIZE_MAX) { 57 | return -1; // Invalid size. 58 | } 59 | uint8_t* src_argb = (uint8_t*)malloc((size_t)argb_size); 60 | if (!src_argb) { 61 | return 1; // Out of memory runtime error. 62 | } 63 | uint8_t* dst_argb = src_argb + (size_t)src_argb_size; 64 | 65 | r = RGB24ToARGB(src_rgb, src_stride_rgb, src_argb, src_width * 4, src_width, 66 | src_height); 67 | if (!r) { 68 | r = ARGBScale(src_argb, src_width * 4, src_width, abs_src_height, dst_argb, 69 | dst_width * 4, dst_width, dst_height, filtering); 70 | if (!r) { 71 | r = ARGBToRGB24(dst_argb, dst_width * 4, dst_rgb, dst_stride_rgb, 72 | dst_width, dst_height); 73 | } 74 | } 75 | free(src_argb); 76 | return r; 77 | } 78 | 79 | #ifdef __cplusplus 80 | } // extern "C" 81 | } // namespace libyuv 82 | #endif 83 | -------------------------------------------------------------------------------- /core/deps/libyuv/source/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | 4 | function runbenchmark1 { 5 | perf record /google/src/cloud/fbarchard/clean/google3/blaze-bin/third_party/libyuv/libyuv_test --gunit_filter=*$1 --libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=1000 --libyuv_flags=-1 --libyuv_cpu_info=-1 6 | perf report | grep AVX 7 | } 8 | 9 | runbenchmark1 ABGRToI420 10 | runbenchmark1 Android420ToI420 11 | runbenchmark1 ARGBToI420 12 | runbenchmark1 Convert16To8Plane 13 | runbenchmark1 ConvertToARGB 14 | runbenchmark1 ConvertToI420 15 | runbenchmark1 CopyPlane 16 | runbenchmark1 H010ToAB30 17 | runbenchmark1 H010ToAR30 18 | runbenchmark1 HalfFloatPlane 19 | runbenchmark1 I010ToAB30 20 | runbenchmark1 I010ToAR30 21 | runbenchmark1 I420Copy 22 | runbenchmark1 I420Psnr 23 | runbenchmark1 I420Scale 24 | runbenchmark1 I420Ssim 25 | runbenchmark1 I420ToARGB 26 | runbenchmark1 I420ToNV12 27 | runbenchmark1 I420ToUYVY 28 | runbenchmark1 I422ToI420 29 | runbenchmark1 InitCpuFlags 30 | runbenchmark1 J420ToARGB 31 | runbenchmark1 NV12ToARGB 32 | runbenchmark1 NV12ToI420 33 | runbenchmark1 NV12ToI420Rotate 34 | runbenchmark1 SetCpuFlags 35 | runbenchmark1 YUY2ToI420 36 | -------------------------------------------------------------------------------- /core/deps/libyuv/source/video_common.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/video_common.h" 12 | 13 | #ifdef __cplusplus 14 | namespace libyuv { 15 | extern "C" { 16 | #endif 17 | 18 | struct FourCCAliasEntry { 19 | uint32_t alias; 20 | uint32_t canonical; 21 | }; 22 | 23 | #define NUM_ALIASES 18 24 | static const struct FourCCAliasEntry kFourCCAliases[NUM_ALIASES] = { 25 | {FOURCC_IYUV, FOURCC_I420}, 26 | {FOURCC_YU12, FOURCC_I420}, 27 | {FOURCC_YU16, FOURCC_I422}, 28 | {FOURCC_YU24, FOURCC_I444}, 29 | {FOURCC_YUYV, FOURCC_YUY2}, 30 | {FOURCC_YUVS, FOURCC_YUY2}, // kCMPixelFormat_422YpCbCr8_yuvs 31 | {FOURCC_HDYC, FOURCC_UYVY}, 32 | {FOURCC_2VUY, FOURCC_UYVY}, // kCMPixelFormat_422YpCbCr8 33 | {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. 34 | {FOURCC_DMB1, FOURCC_MJPG}, 35 | {FOURCC_BA81, FOURCC_BGGR}, // deprecated. 36 | {FOURCC_RGB3, FOURCC_RAW}, 37 | {FOURCC_BGR3, FOURCC_24BG}, 38 | {FOURCC_CM32, FOURCC_BGRA}, // kCMPixelFormat_32ARGB 39 | {FOURCC_CM24, FOURCC_RAW}, // kCMPixelFormat_24RGB 40 | {FOURCC_L555, FOURCC_RGBO}, // kCMPixelFormat_16LE555 41 | {FOURCC_L565, FOURCC_RGBP}, // kCMPixelFormat_16LE565 42 | {FOURCC_5551, FOURCC_RGBO}, // kCMPixelFormat_16LE5551 43 | }; 44 | // TODO(fbarchard): Consider mapping kCMPixelFormat_32BGRA to FOURCC_ARGB. 45 | // {FOURCC_BGRA, FOURCC_ARGB}, // kCMPixelFormat_32BGRA 46 | 47 | LIBYUV_API 48 | uint32_t CanonicalFourCC(uint32_t fourcc) { 49 | int i; 50 | for (i = 0; i < NUM_ALIASES; ++i) { 51 | if (kFourCCAliases[i].alias == fourcc) { 52 | return kFourCCAliases[i].canonical; 53 | } 54 | } 55 | // Not an alias, so return it as-is. 56 | return fourcc; 57 | } 58 | 59 | #ifdef __cplusplus 60 | } // extern "C" 61 | } // namespace libyuv 62 | #endif 63 | -------------------------------------------------------------------------------- /core/deps/libyuv/tools_libyuv/OWNERS: -------------------------------------------------------------------------------- 1 | mbonadei@chromium.org 2 | fbarchard@chromium.org 3 | pbos@chromium.org 4 | 5 | -------------------------------------------------------------------------------- /core/deps/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS: -------------------------------------------------------------------------------- 1 | # DEPS file for unit tests. 2 | 3 | vars = { 4 | 'chromium_git': 'https://chromium.googlesource.com', 5 | 'chromium_revision': '1b9c098a08e40114e44b6c1ec33ddf95c40b901d', 6 | 'ignored_str': Str(''), 7 | } 8 | 9 | deps = { 10 | # Entry that is a directory in Chromium, so we're using a Git subtree mirror for it. 11 | 'src/build': 12 | Var('chromium_git') + '/chromium/src/build' + '@' + '52f7afeca991d96d68cf0507e20dbdd5b845691f', 13 | 14 | # Entry that's also a DEPS entry in the Chromium DEPS file. 15 | 'src/buildtools': 16 | Var('chromium_git') + '/chromium/buildtools.git' + '@' + '64e38f0cebdde27aa0cfb405f330063582f9ac76', 17 | 18 | # Entry only present in libyuv, not Chromium. 19 | 'src/third_party/gflags/src': 20 | Var('chromium_git') + '/external/github.com/gflags/gflags@03bebcb065c83beff83d50ae025a55a4bf94dfca', 21 | } 22 | -------------------------------------------------------------------------------- /core/deps/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new: -------------------------------------------------------------------------------- 1 | # DEPS file for unit tests. 2 | 3 | vars = { 4 | 'chromium_git': 'https://chromium.googlesource.com', 5 | 6 | # This is updated compared to the DEPS.chromium.old file. 7 | 'buildtools_revision': '55ad626b08ef971fd82a62b7abb325359542952b', 8 | } 9 | 10 | deps = { 11 | 'src/buildtools': 12 | Var('chromium_git') + '/chromium/buildtools.git' + '@' + Var('buildtools_revision'), 13 | } 14 | -------------------------------------------------------------------------------- /core/deps/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old: -------------------------------------------------------------------------------- 1 | # DEPS file for unit tests. 2 | 3 | vars = { 4 | 'chromium_git': 'https://chromium.googlesource.com', 5 | 6 | # This is and older revision than DEPS.chromium.new file. 7 | 'buildtools_revision': '64e38f0cebdde27aa0cfb405f330063582f9ac76', 8 | } 9 | 10 | deps = { 11 | 'src/buildtools': 12 | Var('chromium_git') + '/chromium/buildtools.git' + '@' + Var('buildtools_revision'), 13 | } 14 | -------------------------------------------------------------------------------- /core/deps/libyuv/tools_libyuv/get_landmines.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2016 The LibYuv Project Authors. All rights reserved. 4 | # 5 | # Use of this source code is governed by a BSD-style license 6 | # that can be found in the LICENSE file in the root of the source 7 | # tree. An additional intellectual property rights grant can be found 8 | # in the file PATENTS. All contributing project authors may 9 | # be found in the AUTHORS file in the root of the source tree. 10 | 11 | """ 12 | This file emits the list of reasons why a particular build needs to be 13 | clobbered (or a list of 'landmines'). 14 | """ 15 | 16 | import sys 17 | 18 | 19 | def print_landmines(): 20 | """ALL LANDMINES ARE EMITTED FROM HERE.""" 21 | # DO NOT add landmines as part of a regular CL. Landmines are a last-effort 22 | # bandaid fix if a CL that got landed has a build dependency bug and all 23 | # bots need to be cleaned up. If you're writing a new CL that causes build 24 | # dependency problems, fix the dependency problems instead of adding a 25 | # landmine. 26 | # See the Chromium version in src/build/get_landmines.py for usage 27 | # examples. 28 | print('Clobber to remove GYP artifacts after switching bots to GN.') 29 | print('Another try to remove GYP artifacts after switching bots to GN.') 30 | 31 | 32 | def main(): 33 | print_landmines() 34 | return 0 35 | 36 | 37 | if __name__ == '__main__': 38 | sys.exit(main()) 39 | -------------------------------------------------------------------------------- /core/deps/libyuv/tools_libyuv/msan/OWNERS: -------------------------------------------------------------------------------- 1 | mbonadei@chromium.org 2 | fbarchard@chromium.org 3 | pbos@chromium.org 4 | -------------------------------------------------------------------------------- /core/deps/libyuv/tools_libyuv/msan/blacklist.txt: -------------------------------------------------------------------------------- 1 | # The rules in this file are only applied at compile time. 2 | # Because the Chrome buildsystem does not automatically touch the files 3 | # mentioned here, changing this file requires clobbering all MSan bots. 4 | # 5 | # Please think twice before you add or remove these rules. 6 | 7 | # This is a stripped down copy of Chromium's blacklist.txt, to enable 8 | # adding libyuv-specific blacklist entries. 9 | 10 | -------------------------------------------------------------------------------- /core/deps/libyuv/tools_libyuv/ubsan/OWNERS: -------------------------------------------------------------------------------- 1 | mbonadei@chromium.org 2 | fbarchard@chromium.org 3 | pbos@chromium.org 4 | -------------------------------------------------------------------------------- /core/deps/libyuv/tools_libyuv/ubsan/blacklist.txt: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # UBSan blacklist. 3 | # Please think twice before you add or remove these rules. 4 | 5 | # This is a stripped down copy of Chromium's blacklist.txt, to enable 6 | # adding WebRTC-specific blacklist entries. 7 | 8 | ############################################################################# 9 | # YASM does some funny things that UBsan doesn't like. 10 | # https://crbug.com/489901 11 | src:*/third_party/yasm/* 12 | 13 | ############################################################################# 14 | # Ignore system libraries. 15 | src:*/usr/* 16 | -------------------------------------------------------------------------------- /core/deps/libyuv/tools_libyuv/ubsan/vptr_blacklist.txt: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # UBSan vptr blacklist. 3 | # Function and type based blacklisting use a mangled name, and it is especially 4 | # tricky to represent C++ types. For now, any possible changes by name manglings 5 | # are simply represented as wildcard expressions of regexp, and thus it might be 6 | # over-blacklisted. 7 | # 8 | # Please think twice before you add or remove these rules. 9 | # 10 | # This is a stripped down copy of Chromium's vptr_blacklist.txt, to enable 11 | # adding libyuv-specific blacklist entries. 12 | 13 | ############################################################################# 14 | # Using raw pointer values. 15 | # 16 | # A raw pointer value (16) is used to infer the field offset by 17 | # GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET. 18 | 19 | # Example: 20 | # src:*/third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc 21 | 22 | ############################################################################# 23 | # UBsan goes into an infinite recursion when __dynamic_cast instrumented with 24 | # "vptr". See crbug.com/609786. 25 | src:*/third_party/libc\+\+abi/trunk/src/private_typeinfo.cpp 26 | -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/basictypes_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "../unit_test/unit_test.h" 12 | #include "libyuv/basic_types.h" 13 | 14 | namespace libyuv { 15 | 16 | TEST_F(LibYUVBaseTest, SizeOfTypes) { 17 | int8_t i8 = -1; 18 | uint8_t u8 = 1u; 19 | int16_t i16 = -1; 20 | uint16_t u16 = 1u; 21 | int32_t i32 = -1; 22 | uint32_t u32 = 1u; 23 | int64_t i64 = -1; 24 | uint64_t u64 = 1u; 25 | EXPECT_EQ(1u, sizeof(i8)); 26 | EXPECT_EQ(1u, sizeof(u8)); 27 | EXPECT_EQ(2u, sizeof(i16)); 28 | EXPECT_EQ(2u, sizeof(u16)); 29 | EXPECT_EQ(4u, sizeof(i32)); 30 | EXPECT_EQ(4u, sizeof(u32)); 31 | EXPECT_EQ(8u, sizeof(i64)); 32 | EXPECT_EQ(8u, sizeof(u64)); 33 | EXPECT_GT(0, i8); 34 | EXPECT_LT(0u, u8); 35 | EXPECT_GT(0, i16); 36 | EXPECT_LT(0u, u16); 37 | EXPECT_GT(0, i32); 38 | EXPECT_LT(0u, u32); 39 | EXPECT_GT(0, i64); 40 | EXPECT_LT(0u, u64); 41 | } 42 | 43 | } // namespace libyuv 44 | -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/cpu_thread_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | 13 | #include "libyuv/cpu_id.h" 14 | 15 | #if defined(__clang__) && !defined(__wasm__) 16 | #if __has_include() 17 | #define LIBYUV_HAVE_PTHREAD 1 18 | #endif 19 | #elif defined(__linux__) 20 | #define LIBYUV_HAVE_PTHREAD 1 21 | #endif 22 | 23 | #ifdef LIBYUV_HAVE_PTHREAD 24 | #include 25 | #endif 26 | 27 | namespace libyuv { 28 | 29 | #ifdef LIBYUV_HAVE_PTHREAD 30 | static void* ThreadMain(void* arg) { 31 | int* flags = static_cast(arg); 32 | 33 | *flags = TestCpuFlag(kCpuInitialized); 34 | return nullptr; 35 | } 36 | #endif // LIBYUV_HAVE_PTHREAD 37 | 38 | // Call TestCpuFlag() from two threads. ThreadSanitizer should not report any 39 | // data race. 40 | TEST(LibYUVCpuThreadTest, TestCpuFlagMultipleThreads) { 41 | #ifdef LIBYUV_HAVE_PTHREAD 42 | int cpu_flags1; 43 | int cpu_flags2; 44 | int ret; 45 | pthread_t thread1; 46 | pthread_t thread2; 47 | 48 | MaskCpuFlags(0); // Reset to 0 to allow auto detect. 49 | ret = pthread_create(&thread1, nullptr, ThreadMain, &cpu_flags1); 50 | ASSERT_EQ(ret, 0); 51 | ret = pthread_create(&thread2, nullptr, ThreadMain, &cpu_flags2); 52 | ASSERT_EQ(ret, 0); 53 | ret = pthread_join(thread1, nullptr); 54 | EXPECT_EQ(ret, 0); 55 | ret = pthread_join(thread2, nullptr); 56 | EXPECT_EQ(ret, 0); 57 | EXPECT_EQ(cpu_flags1, cpu_flags2); 58 | #else 59 | printf("pthread unavailable; Test skipped."); 60 | #endif // LIBYUV_HAVE_PTHREAD 61 | } 62 | 63 | } // namespace libyuv 64 | -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/arm_v7.txt: -------------------------------------------------------------------------------- 1 | Processor : ARMv7 Processor rev 5 (v7l) 2 | BogoMIPS : 795.44 3 | Features : swp half thumb fastmult vfp edsp iwmmxt thumbee vfpv3 vfpv3d16 4 | CPU implementer : 0x56 5 | CPU architecture: 7 6 | CPU variant : 0x0 7 | CPU part : 0x581 8 | CPU revision : 5 9 | 10 | Hardware : OLPC XO-1.75 11 | Revision : 0000 12 | Serial : 0000000000000000 13 | -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/mips.txt: -------------------------------------------------------------------------------- 1 | system type : generic-loongson-machine 2 | machine : loongson,generic 3 | processor : 0 4 | 5 | isa : mips1 mips2 mips3 mips4 mips5 mips32r1 mips32r2 mips64r1 mips64r2 6 | ASEs implemented : vz 7 | shadow register sets : 1 8 | -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/mips_loongson2k.txt: -------------------------------------------------------------------------------- 1 | system type : Loongson2K-SBC 2 | machine : loongson,LS2k1000-EVP 3 | processor : 0 4 | cpu model : Loongson-2K V0.3 FPU V0.1 5 | BogoMIPS : 1980.41 6 | -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/mips_loongson3.txt: -------------------------------------------------------------------------------- 1 | system type : generic-loongson-machine 2 | machine : Unknown 3 | processor : 0 4 | cpu model : ICT Loongson-3 V0.9 FPU V0.1 5 | model name : ICT Loongson-3A R3 (Loongson-3A3000) @ 1500MHz 6 | BogoMIPS : 2990.15 7 | 8 | isa : mips1 mips2 mips3 mips4 mips5 mips32r1 mips32r2 mips64r1 mips64r2 9 | ASEs implemented : dsp dsp2 vz 10 | shadow register sets : 1 11 | -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/mips_loongson_mmi.txt: -------------------------------------------------------------------------------- 1 | system type : generic-loongson-machine 2 | machine : loongson,generic 3 | processor : 0 4 | 5 | isa : mips1 mips2 mips3 mips4 mips5 mips32r1 mips32r2 mips64r1 mips64r2 6 | ASEs implemented : vz loongson-mmi loongson-ext 7 | shadow register sets : 1 8 | -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/mips_msa.txt: -------------------------------------------------------------------------------- 1 | system type : generic-loongson-machine 2 | machine : loongson,generic 3 | processor : 0 4 | 5 | isa : mips1 mips2 mips3 mips4 mips5 mips32r1 mips32r2 mips64r1 mips64r2 6 | ASEs implemented : vz msa 7 | shadow register sets : 1 8 | -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/riscv64.txt: -------------------------------------------------------------------------------- 1 | processor : 0 2 | hart : 1 3 | isa : rv64imac 4 | mmu : sv48 -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/riscv64_rvv.txt: -------------------------------------------------------------------------------- 1 | processor : 0 2 | hart : 1 3 | isa : rv64imafdcv 4 | mmu : sv48 -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/riscv64_rvv_zvfh.txt: -------------------------------------------------------------------------------- 1 | processor : 0 2 | hart : 1 3 | isa : rv64imafdcv_zfh_zvfh 4 | mmu : sv48 -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/tegra3.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crow-misia/libyuv-android/4c82dfad703adcb1329b3079ae59a3abd1fd4794/core/deps/libyuv/unit_test/testdata/tegra3.txt -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/test0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crow-misia/libyuv-android/4c82dfad703adcb1329b3079ae59a3abd1fd4794/core/deps/libyuv/unit_test/testdata/test0.jpg -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/test1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crow-misia/libyuv-android/4c82dfad703adcb1329b3079ae59a3abd1fd4794/core/deps/libyuv/unit_test/testdata/test1.jpg -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/test2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crow-misia/libyuv-android/4c82dfad703adcb1329b3079ae59a3abd1fd4794/core/deps/libyuv/unit_test/testdata/test2.jpg -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/test3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crow-misia/libyuv-android/4c82dfad703adcb1329b3079ae59a3abd1fd4794/core/deps/libyuv/unit_test/testdata/test3.jpg -------------------------------------------------------------------------------- /core/deps/libyuv/unit_test/testdata/test4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crow-misia/libyuv-android/4c82dfad703adcb1329b3079ae59a3abd1fd4794/core/deps/libyuv/unit_test/testdata/test4.jpg -------------------------------------------------------------------------------- /core/deps/libyuv/util/Makefile: -------------------------------------------------------------------------------- 1 | psnr: psnr.cc ssim.cc psnr_main.cc 2 | ifeq ($(CXX),icl) 3 | $(CXX) /arch:SSE2 /Ox /openmp psnr.cc ssim.cc psnr_main.cc 4 | else 5 | $(CXX) -msse2 -O3 -fopenmp -static -o psnr psnr.cc ssim.cc psnr_main.cc -Wl,--strip-all 6 | endif 7 | 8 | # for MacOS 9 | # /usr/local/bin/g++-7 -msse2 -O3 -fopenmp -Bstatic -o psnr psnr.cc ssim.cc psnr_main.cc 10 | -------------------------------------------------------------------------------- /core/deps/libyuv/util/compare.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "libyuv/basic_types.h" 17 | #include "libyuv/compare.h" 18 | #include "libyuv/version.h" 19 | 20 | int main(int argc, char** argv) { 21 | if (argc < 1) { 22 | printf("libyuv compare v%d\n", LIBYUV_VERSION); 23 | printf("compare file1.yuv file2.yuv\n"); 24 | return -1; 25 | } 26 | char* name1 = argv[1]; 27 | char* name2 = (argc > 2) ? argv[2] : NULL; 28 | FILE* fin1 = fopen(name1, "rb"); 29 | FILE* fin2 = name2 ? fopen(name2, "rb") : NULL; 30 | 31 | const int kBlockSize = 32768; 32 | uint8_t buf1[kBlockSize]; 33 | uint8_t buf2[kBlockSize]; 34 | uint32_t hash1 = 5381; 35 | uint32_t hash2 = 5381; 36 | uint64_t sum_square_err = 0; 37 | uint64_t size_min = 0; 38 | int amt1 = 0; 39 | int amt2 = 0; 40 | do { 41 | amt1 = static_cast(fread(buf1, 1, kBlockSize, fin1)); 42 | if (amt1 > 0) { 43 | hash1 = libyuv::HashDjb2(buf1, amt1, hash1); 44 | } 45 | if (fin2) { 46 | amt2 = static_cast(fread(buf2, 1, kBlockSize, fin2)); 47 | if (amt2 > 0) { 48 | hash2 = libyuv::HashDjb2(buf2, amt2, hash2); 49 | } 50 | int amt_min = (amt1 < amt2) ? amt1 : amt2; 51 | size_min += amt_min; 52 | sum_square_err += libyuv::ComputeSumSquareError(buf1, buf2, amt_min); 53 | } 54 | } while (amt1 > 0 || amt2 > 0); 55 | 56 | printf("hash1 %x", hash1); 57 | if (fin2) { 58 | printf(", hash2 %x", hash2); 59 | double mse = 60 | static_cast(sum_square_err) / static_cast(size_min); 61 | printf(", mse %.2f", mse); 62 | double psnr = libyuv::SumSquareErrorToPsnr(sum_square_err, size_min); 63 | printf(", psnr %.2f\n", psnr); 64 | fclose(fin2); 65 | } 66 | fclose(fin1); 67 | } 68 | -------------------------------------------------------------------------------- /core/deps/libyuv/util/i444tonv12_eg.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "libyuv/convert.h" 3 | 4 | #include // for printf 5 | #include // for memset 6 | 7 | int main(int, char**) { 8 | unsigned char src_i444[640 * 400 * 3]; 9 | unsigned char dst_nv12[640 * 400 * 3 / 2]; 10 | 11 | for (size_t i = 0; i < sizeof(src_i444); ++i) { 12 | src_i444[i] = i & 255; 13 | } 14 | memset(dst_nv12, 0, sizeof(dst_nv12)); 15 | libyuv::I444ToNV12(&src_i444[0], 640, // source Y 16 | &src_i444[640 * 400], 640, // source U 17 | &src_i444[640 * 400 * 2], 640, // source V 18 | &dst_nv12[0], 640, // dest Y 19 | &dst_nv12[640 * 400], 640, // dest UV 20 | 640, 400); // width and height 21 | 22 | int checksum = 0; 23 | for (size_t i = 0; i < sizeof(dst_nv12); ++i) { 24 | checksum += dst_nv12[i]; 25 | } 26 | printf("checksum %x %s\n", checksum, checksum == 0x2ec0c00 ? "PASS" : "FAIL"); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /core/deps/libyuv/util/psnr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Get PSNR for video sequence. Assuming RAW 4:2:0 Y:Cb:Cr format 12 | 13 | #ifndef UTIL_PSNR_H_ // NOLINT 14 | #define UTIL_PSNR_H_ 15 | 16 | #include // For log10() 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #if !defined(INT_TYPES_DEFINED) && !defined(UINT8_TYPE_DEFINED) 23 | typedef unsigned char uint8_t; 24 | #define UINT8_TYPE_DEFINED 25 | #endif 26 | 27 | static const double kMaxPSNR = 128.0; 28 | 29 | // libyuv provides this function when linking library for jpeg support. 30 | // TODO(fbarchard): make psnr lib compatible subset of libyuv. 31 | #if !defined(HAVE_JPEG) 32 | // Computer Sum of Squared Error (SSE). 33 | // Pass this to ComputePSNR for final result. 34 | double ComputeSumSquareError(const uint8_t* src_a, 35 | const uint8_t* src_b, 36 | int count); 37 | #endif 38 | 39 | // PSNR formula: psnr = 10 * log10 (Peak Signal^2 * size / sse) 40 | // Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match). 41 | double ComputePSNR(double sse, double size); 42 | 43 | #ifdef __cplusplus 44 | } // extern "C" 45 | #endif 46 | 47 | #endif // UTIL_PSNR_H_ // NOLINT 48 | -------------------------------------------------------------------------------- /core/deps/libyuv/util/ssim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Get SSIM for video sequence. Assuming RAW 4:2:0 Y:Cb:Cr format 12 | 13 | #ifndef UTIL_SSIM_H_ 14 | #define UTIL_SSIM_H_ 15 | 16 | #include // For log10() 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #if !defined(INT_TYPES_DEFINED) && !defined(UINT8_TYPE_DEFINED) 23 | typedef unsigned char uint8_t; 24 | #define UINT8_TYPE_DEFINED 25 | #endif 26 | 27 | double CalcSSIM(const uint8_t* org, 28 | const uint8_t* rec, 29 | const int image_width, 30 | const int image_height); 31 | 32 | double CalcLSSIM(double ssim); 33 | 34 | #ifdef __cplusplus 35 | } // extern "C" 36 | #endif 37 | 38 | #endif // UTIL_SSIM_H_ 39 | -------------------------------------------------------------------------------- /core/deps/libyuv/winarm.mk: -------------------------------------------------------------------------------- 1 | # This is a generic makefile for libyuv for Windows Arm. 2 | # call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_arm\vcvarsx86_arm.bat" 3 | # nmake /f winarm.mk 4 | # make -f winarm.mk 5 | # nmake /f winarm.mk clean 6 | # consider /arch:ARMv7VE 7 | CC=cl 8 | CCFLAGS=/Ox /nologo /Iinclude /DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP 9 | AR=lib 10 | ARFLAGS=/MACHINE:ARM /NOLOGO /SUBSYSTEM:NATIVE 11 | RM=cmd /c del 12 | 13 | LOCAL_OBJ_FILES = \ 14 | source/compare.o\ 15 | source/compare_common.o\ 16 | source/convert.o\ 17 | source/convert_argb.o\ 18 | source/convert_from.o\ 19 | source/convert_from_argb.o\ 20 | source/convert_to_argb.o\ 21 | source/convert_to_i420.o\ 22 | source/cpu_id.o\ 23 | source/planar_functions.o\ 24 | source/rotate.o\ 25 | source/rotate_any.o\ 26 | source/rotate_argb.o\ 27 | source/rotate_common.o\ 28 | source/row_any.o\ 29 | source/row_common.o\ 30 | source/scale.o\ 31 | source/scale_any.o\ 32 | source/scale_argb.o\ 33 | source/scale_common.o\ 34 | source/scale_uv.o\ 35 | source/video_common.o 36 | 37 | .cc.o: 38 | $(CC) /c $(CCFLAGS) $*.cc /Fo$@ 39 | 40 | all: libyuv_arm.lib winarm.mk 41 | 42 | libyuv_arm.lib: $(LOCAL_OBJ_FILES) winarm.mk 43 | $(AR) $(ARFLAGS) /OUT:$@ $(LOCAL_OBJ_FILES) 44 | 45 | clean: 46 | $(RM) "source\*.o" libyuv_arm.lib 47 | 48 | -------------------------------------------------------------------------------- /core/detekt-baseline.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LargeClass:Yuv.kt$Yuv 6 | 7 | 8 | -------------------------------------------------------------------------------- /core/lint-baseline.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /core/script/convert.csv: -------------------------------------------------------------------------------- 1 | source,target,name,comment 2 | I444,I420,, 3 | I444,NV12,, 4 | I444,NV21,, 5 | I422,I420,, 6 | I422,I444,, 7 | I422,NV21,, 8 | I420,I420,, 9 | I400,I420,,Convert I400 (grey) to I420 10 | I400,NV21,,Convert I400 (grey) to NV21 / NV12 11 | NV12,I420,, 12 | NV21,I420,, 13 | YUY2,I420,, 14 | UYVY,I420,, 15 | AYUV,NV12,, 16 | AYUV,NV21,, 17 | ARGB,I420,,ARGB little endian (bgra in memory) to I420 18 | BGRA,I420,,BGRA little endian (argb in memory) to I420 19 | ABGR,I420,,ABGR little endian (rgba in memory) to I420 20 | RGBA,I420,,RGBA little endian (abgr in memory) to I420 21 | RGB24,I420,,RGB little endian (bgr in memory) to I420 22 | RGB24,J420,,RGB little endian (bgr in memory) to J420 23 | RAW,I420,,RGB big endian (rgb in memory) to I420 24 | RAW,J420,,RGB big endian (rgb in memory) to J420 25 | RGB565,I420,,RGB16 (RGBP fourcc) little endian to I420 26 | ARGB1555,I420,,RGB15 (RGBO fourcc) little endian to I420 27 | ARGB4444,I420,,RGB12 (R444 fourcc) little endian to I420 28 | RGB24,J400,,RGB little endian (bgr in memory) to J400 29 | RAW,J400,,RGB big endian (rgb in memory) to J400 30 | ARGB,ARGB,, 31 | J420,ARGB,, 32 | J420,ABGR,, 33 | H420,ARGB,, 34 | H420,ABGR,, 35 | U420,ARGB,, 36 | U420,ABGR,, 37 | I422,ARGB,, 38 | J422,ARGB,, 39 | J422,ABGR,, 40 | H422,ARGB,, 41 | H422,ABGR,, 42 | U422,ARGB,, 43 | U422,ABGR,, 44 | I444,ARGB,, 45 | I444,ABGR,, 46 | J444,ARGB,, 47 | J444,ABGR,, 48 | H444,ARGB,, 49 | H444,ABGR,, 50 | U444,ARGB,, 51 | U444,ABGR,, 52 | I444,RGB24,, 53 | I444,RAW,, 54 | I400,ARGB,,Convert I400 (grey) to ARGB. Reverse of ARGBToI400 55 | J400,ARGB,,Convert J400 (jpeg grey) to ARGB 56 | NV12,ARGB,, 57 | NV21,ARGB,, 58 | NV12,ABGR,, 59 | NV21,ABGR,, 60 | NV12,RGB24,, 61 | NV21,RGB24,, 62 | NV21,YUV24,, 63 | NV12,RAW,, 64 | NV21,RAW,, 65 | YUY2,ARGB,, 66 | UYVY,ARGB,, 67 | BGRA,ARGB,,BGRA little endian (argb in memory) to ARGB 68 | ABGR,ARGB,,ABGR little endian (rgba in memory) to ARGB 69 | RGBA,ARGB,,RGBA little endian (abgr in memory) to ARGB 70 | RGB24,ARGB,,RGB little endian (bgr in memory) to ARGB 71 | RAW,ARGB,,RGB big endian (rgb in memory) to ARGB 72 | RAW,RGBA,,RGB big endian (rgb in memory) to RGBA 73 | RGB565,ARGB,,RGB16 (RGBP fourcc) little endian to ARGB 74 | ARGB1555,ARGB,,RGB15 (RGBO fourcc) little endian to ARGB 75 | ARGB4444,ARGB,,RGB12 (R444 fourcc) little endian to ARGB 76 | AR30,ARGB,, 77 | AR30,ABGR,, 78 | AR30,AB30,, 79 | NV12,RGB565,, 80 | I422,BGRA,, 81 | I422,ABGR,, 82 | I422,RGBA,, 83 | I420,ARGB,, 84 | I420,BGRA,, 85 | I420,ABGR,, 86 | I420,RGBA,, 87 | I420,RGB24,, 88 | I420,RAW,, 89 | H420,RGB24,, 90 | H420,RAW,, 91 | J420,RGB24,, 92 | J420,RAW,, 93 | I422,RGB24,, 94 | I422,RAW,, 95 | I420,RGB565,, 96 | J420,RGB565,, 97 | H420,RGB565,, 98 | I422,RGB565,, 99 | I420,ARGB1555,, 100 | I420,ARGB4444,, 101 | I420,AR30,, 102 | I420,AB30,, 103 | H420,AR30,, 104 | H420,AB30,, 105 | I420,I422,, 106 | I420,I444,, 107 | I400,I400,,"Copy to I400. Source can be I420, I422, I444, I400, NV12 or NV21" 108 | I420,NV12,, 109 | I420,NV21,, 110 | I420,YUY2,, 111 | I420,UYVY,, 112 | ARGB,BGRA,, 113 | ARGB,ABGR,, 114 | ARGB,RGBA,, 115 | ARGB,RGB24,, 116 | ARGB,RAW,, 117 | ARGB,RGB565,, 118 | ARGB,ARGB1555,, 119 | ARGB,ARGB4444,, 120 | ARGB,I444,, 121 | ARGB,I422,, 122 | ARGB,J420,,Convert ARGB to J420. (JPeg full range I420) 123 | ARGB,J422,, 124 | ARGB,J400,,Convert ARGB to J400. (JPeg full range) 125 | ABGR,J420,,Convert ABGR to J420. (JPeg full range I420) 126 | ABGR,J422,, 127 | ABGR,J400,,Convert ABGR to J400. (JPeg full range) 128 | RGBA,J400,,Convert RGBA to J400. (JPeg full range) 129 | ARGB,I400,, 130 | ARGB,NV12,, 131 | ARGB,NV21,, 132 | ABGR,NV12,, 133 | ABGR,NV21,, 134 | ARGB,YUY2,, 135 | ARGB,UYVY,, 136 | -------------------------------------------------------------------------------- /core/script/disable_test_and_jpeg.patch: -------------------------------------------------------------------------------- 1 | diff -ur a/Android.mk b/Android.mk 2 | --- a/Android.mk 2020-06-27 10:07:20.000000000 +0900 3 | +++ b/Android.mk 2020-06-27 10:08:14.000000000 +0900 4 | @@ -54,14 +54,6 @@ 5 | source/video_common.cc 6 | 7 | common_CFLAGS := -Wall -fexceptions 8 | -ifneq ($(LIBYUV_DISABLE_JPEG), "yes") 9 | -LOCAL_SRC_FILES += \ 10 | - source/convert_jpeg.cc \ 11 | - source/mjpeg_decoder.cc \ 12 | - source/mjpeg_validate.cc 13 | -common_CFLAGS += -DHAVE_JPEG 14 | -LOCAL_SHARED_LIBRARIES := libjpeg 15 | -endif 16 | 17 | LOCAL_CFLAGS += $(common_CFLAGS) 18 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include 19 | @@ -75,39 +66,4 @@ 20 | 21 | include $(CLEAR_VARS) 22 | 23 | LOCAL_WHOLE_STATIC_LIBRARIES := libyuv_static 24 | -LOCAL_MODULE := libyuv 25 | -ifneq ($(LIBYUV_DISABLE_JPEG), "yes") 26 | -LOCAL_SHARED_LIBRARIES := libjpeg 27 | -endif 28 | - 29 | -include $(BUILD_SHARED_LIBRARY) 30 | - 31 | -include $(CLEAR_VARS) 32 | -LOCAL_STATIC_LIBRARIES := libyuv_static 33 | -LOCAL_SHARED_LIBRARIES := libjpeg 34 | -LOCAL_MODULE_TAGS := tests 35 | -LOCAL_CPP_EXTENSION := .cc 36 | -LOCAL_C_INCLUDES += $(LOCAL_PATH)/include 37 | -LOCAL_SRC_FILES := \ 38 | - unit_test/basictypes_test.cc \ 39 | - unit_test/color_test.cc \ 40 | - unit_test/compare_test.cc \ 41 | - unit_test/convert_argb_test.cc \ 42 | - unit_test/convert_test.cc \ 43 | - unit_test/cpu_test.cc \ 44 | - unit_test/cpu_thread_test.cc \ 45 | - unit_test/math_test.cc \ 46 | - unit_test/planar_test.cc \ 47 | - unit_test/rotate_argb_test.cc \ 48 | - unit_test/rotate_test.cc \ 49 | - unit_test/scale_argb_test.cc \ 50 | - unit_test/scale_plane_test.cc \ 51 | - unit_test/scale_rgb_test.cc \ 52 | - unit_test/scale_test.cc \ 53 | - unit_test/scale_uv_test.cc \ 54 | - unit_test/unit_test.cc \ 55 | - unit_test/video_common_test.cc 56 | - 57 | -LOCAL_MODULE := libyuv_unittest 58 | -include $(BUILD_NATIVE_TEST) 59 | -------------------------------------------------------------------------------- /core/script/get-deps.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -ue -o pipefail 4 | 5 | export LC_ALL=C 6 | 7 | CURDIR=$(cd $(dirname $0)/..; pwd) 8 | 9 | . $CURDIR/../VERSIONS 10 | 11 | # libyuv 12 | rm -rf $CURDIR/deps/libyuv 13 | mkdir -p $CURDIR/deps/libyuv 14 | if [ ! -e $CURDIR/deps/libyuv.${LIBYUV_VERSION}.tar.gz ]; then 15 | curl -Lo $CURDIR/deps/libyuv.${LIBYUV_VERSION}.tar.gz https://chromium.googlesource.com/libyuv/libyuv/+archive/${LIBYUV_VERSION}.tar.gz 16 | fi 17 | pushd $CURDIR/deps/libyuv 18 | tar xf $CURDIR/deps/libyuv.${LIBYUV_VERSION}.tar.gz 19 | popd 20 | pushd $CURDIR/deps/libyuv 21 | patch -u -p1 --no-backup-if-mismatch < $CURDIR/script/disable_test_and_jpeg.patch 22 | patch -u -p1 --no-backup-if-mismatch < $CURDIR/script/disable_dotprod.patch 23 | popd 24 | -------------------------------------------------------------------------------- /core/script/planar.csv: -------------------------------------------------------------------------------- 1 | source,target,name,comment 2 | I422,I422,, 3 | I444,I444,, 4 | NV12,NV12,, 5 | YUY2,I422,, 6 | UYVY,I422,, 7 | YUY2,NV12,, 8 | UYVY,NV12,, 9 | NV21,NV12,, 10 | I420,I400,, 11 | I420,mirror,, 12 | I400,mirror,, 13 | NV12,mirror,, 14 | ARGB,mirror,, 15 | RGB24,mirror,, 16 | RAW,RGB24,, 17 | I422,YUY2,, 18 | I422,UYVY,, 19 | ARGB,ARGB,planarARGBAttenuate,Convert unattentuated ARGB to preattenuated ARGB 20 | ARGB,ARGB,planarARGBUnattenuate,Convert preattentuated ARGB to unattenuated ARGB 21 | ARGB,ARGB,planarARGBGrayTo,Convert ARGB to gray scale ARGB 22 | ARGB,ARGB,planarARGBCopyAlpha,Copy Alpha channel of ARGB to alpha of ARGB 23 | ARGB,A,planarARGBExtractAlpha,Extract the alpha channel from ARGB 24 | Y,ARGB,planarARGBCopyYToAlpha,Copy Y channel to Alpha of ARGB 25 | -------------------------------------------------------------------------------- /core/script/rotate.csv: -------------------------------------------------------------------------------- 1 | source,target,,comment 2 | I420,I420,, 3 | I422,I422,, 4 | I444,I444,, 5 | NV12,I420,,Rotate NV12 input and store in I420 6 | Android420,I420,,"Convert Android420 to I420 with rotation. \"rotation\" can be 0, 90, 180 or 270" 7 | ARGB,ARGB,, 8 | NV12,NV12,, 9 | NV21,NV21,, 10 | NV12,NV21,, 11 | Plane,Plane,rotateRotatePlane,"Rotate a plane by 0, 90, 180, or 270" 12 | UV,SplitUV,rotateSplitRotateUV,Rotate UV and split into planar. width and height expected to be half size for NV12 13 | -------------------------------------------------------------------------------- /core/script/scale.csv: -------------------------------------------------------------------------------- 1 | format,name,comment 2 | Plane,scaleScalePlane, 3 | I420,, 4 | I422,, 5 | I444,, 6 | NV12,, 7 | ARGB,, 8 | UV,, 9 | -------------------------------------------------------------------------------- /core/src/androidTest/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /core/src/androidTest/java/io/github/crow_misia/libyuv/ColorGenerator.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.graphics.* 4 | 5 | class ColorGenerator( 6 | val steps: Int, 7 | initialHue: Float = 0.0f, 8 | ) { 9 | private val hueStep: Float = 360F / steps 10 | private var currentHue = initialHue 11 | 12 | fun nextColor(): Int { 13 | val hsv = floatArrayOf(currentHue, 1.0F, 1.0F) 14 | currentHue = (currentHue + hueStep) % 360F 15 | return Color.HSVToColor(255, hsv) 16 | } 17 | } -------------------------------------------------------------------------------- /core/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/AbstractBuffer.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.graphics.Rect 4 | import java.io.OutputStream 5 | import java.nio.ByteBuffer 6 | import java.util.concurrent.atomic.AtomicReference 7 | 8 | abstract class AbstractBuffer( 9 | internal var buffer: ByteBuffer?, 10 | cropRect: Rect, 11 | planes: Array, 12 | releaseCallback: Runnable?, 13 | ) : Buffer { 14 | override var planes: Array = planes 15 | internal set 16 | 17 | override var cropRect: Rect = cropRect 18 | set(value) { 19 | val tmp = Rect(value) 20 | if (!tmp.intersect(0, 0, width, height)) { 21 | tmp.setEmpty() 22 | } 23 | field = tmp 24 | } 25 | 26 | private val releaseCallback = AtomicReference(releaseCallback) 27 | 28 | override fun close() { 29 | buffer = null 30 | releaseCallback.getAndSet(null)?.run() 31 | planes = emptyArray() 32 | } 33 | 34 | override fun asBuffer(): ByteBuffer { 35 | val result = buffer ?: run { 36 | val size = planes.sumOf { it.bufferSize } 37 | val buffer = ByteBuffer.allocateDirect(size).also { 38 | buffer = it 39 | } 40 | return buffer 41 | } 42 | result.rewind() 43 | return result 44 | } 45 | 46 | override fun asByteArray(): ByteArray { 47 | val size = planes.sumOf { it.bufferSize } 48 | val buffer = ByteArray(size) 49 | 50 | asByteArray(buffer) 51 | 52 | return buffer 53 | } 54 | 55 | override fun asByteArray(dst: ByteArray): Int { 56 | var dstOffset = 0 57 | planes.forEach { plane -> 58 | val remain = dst.size - dstOffset 59 | val size = minOf(plane.bufferSize, remain) 60 | Yuv.memcopy(dst, dstOffset, plane.buffer, 0, size) 61 | dstOffset += size 62 | } 63 | return dstOffset 64 | } 65 | 66 | override fun write(dst: OutputStream): Int { 67 | val tmpBufferSize = planes.maxOf { it.bufferSize } 68 | val tmpBuffer = ByteArray(tmpBufferSize) 69 | var ret = 0 70 | planes.forEach { plane -> 71 | val size = plane.bufferSize 72 | Yuv.memcopy(tmpBuffer, 0, plane.buffer, 0, size) 73 | dst.write(tmpBuffer, 0, size) 74 | ret += size 75 | } 76 | return ret 77 | } 78 | 79 | override fun write(dst: ByteBuffer) { 80 | var dstOffset = 0 81 | planes.forEach { plane -> 82 | val remain = dst.capacity() - dstOffset 83 | val size = minOf(plane.bufferSize, remain) 84 | Yuv.memcopy(dst, dstOffset, plane.buffer, 0, size) 85 | dstOffset += plane.bufferSize 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BgraBuffer.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.graphics.Rect 4 | import java.nio.ByteBuffer 5 | 6 | /** 7 | * BGRA little endian (argb in memory) 8 | */ 9 | class BgraBuffer private constructor( 10 | buffer: ByteBuffer?, 11 | override val plane: Plane, 12 | override val width: Int, 13 | override val height: Int, 14 | cropRect: Rect, 15 | releaseCallback: Runnable?, 16 | ) : AbstractBuffer(buffer, cropRect, arrayOf(plane), releaseCallback), Buffer32 { 17 | override fun getPlaneOffset(planeIndex: Int, rowStride: RowStride, left: Int, top: Int): Int { 18 | return rowStride * top + left.shl(2) 19 | } 20 | 21 | fun convertTo(dst: I420Buffer) { 22 | val (fixedWidth, fixedHeight) = calculateSize(dst) 23 | Yuv.convertBGRAToI420( 24 | srcBGRA = plane.buffer, srcStrideBGRA = plane.rowStride, srcOffsetBGRA = offset(0), 25 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 26 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 27 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 28 | width = fixedWidth, height = fixedHeight, 29 | ) 30 | } 31 | 32 | fun convertTo(dst: ArgbBuffer) { 33 | val (fixedWidth, fixedHeight) = calculateSize(dst) 34 | Yuv.convertBGRAToARGB( 35 | srcBGRA = plane.buffer, srcStrideBGRA = plane.rowStride, srcOffsetBGRA = offset(0), 36 | dstARGB = dst.plane.buffer, dstStrideARGB = dst.plane.rowStride, dstOffsetARGB = dst.offset(0), 37 | width = fixedWidth, height = fixedHeight, 38 | ) 39 | } 40 | 41 | companion object Factory : BufferFactory32, CapacityCalculator { 42 | override fun calculate(width: Int, height: Int): Plane1Capacities { 43 | val stride = width.shl(2) 44 | val capacity = stride * height 45 | return Plane1Capacities( 46 | planeStride = RowStride(stride), 47 | planeCapacity = Capacity(capacity), 48 | ) 49 | } 50 | 51 | override fun allocate(width: Int, height: Int, cropRect: Rect): BgraBuffer { 52 | val (capacity, stride) = calculate(width, height) 53 | val (buffer) = createByteBuffer(listOf(capacity)) 54 | return BgraBuffer( 55 | buffer = buffer, 56 | plane = PlanePrimitive(stride, buffer), 57 | width = width, 58 | height = height, 59 | cropRect = cropRect, 60 | ) { 61 | Yuv.freeNativeBuffer(buffer) 62 | } 63 | } 64 | 65 | override fun wrap(buffer: ByteBuffer, width: Int, height: Int, cropRect: Rect): BgraBuffer { 66 | check(buffer.isDirect) { "Unsupported non-direct ByteBuffer." } 67 | 68 | val (capacity, stride) = calculate(width, height) 69 | val sliceBuffer = buffer.sliceRange(0, capacity.value) 70 | return BgraBuffer( 71 | buffer = sliceBuffer, 72 | plane = PlanePrimitive(stride, sliceBuffer), 73 | width = width, 74 | height = height, 75 | cropRect = cropRect, 76 | releaseCallback = null, 77 | ) 78 | } 79 | 80 | override fun wrap(plane: Plane, width: Int, height: Int, cropRect: Rect): BgraBuffer { 81 | return BgraBuffer( 82 | buffer = plane.buffer, 83 | plane = plane, 84 | width = width, 85 | height = height, 86 | cropRect = cropRect, 87 | releaseCallback = null, 88 | ) 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BitmapConverter.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.graphics.Bitmap 4 | 5 | interface BitmapConverter { 6 | fun asBitmap(): Bitmap 7 | } 8 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/Buffer.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.graphics.Rect 4 | import androidx.annotation.RestrictTo 5 | import java.io.Closeable 6 | import java.io.OutputStream 7 | import java.nio.ByteBuffer 8 | 9 | interface Buffer : Closeable { 10 | /** 11 | * Planes. 12 | */ 13 | val planes: Array 14 | 15 | /** 16 | * Image width. 17 | */ 18 | val width: Int 19 | 20 | /** 21 | * Image height. 22 | */ 23 | val height: Int 24 | 25 | /** 26 | * Image crop rectangle. 27 | */ 28 | val cropRect: Rect 29 | 30 | /** 31 | * Get as ByteBuffer. 32 | */ 33 | fun asBuffer(): ByteBuffer 34 | 35 | /** 36 | * Get as Byte Array. 37 | */ 38 | fun asByteArray(): ByteArray 39 | 40 | /** 41 | * Get as Byte Array. 42 | * 43 | * @param dst destination Byte Array 44 | * @return output data size 45 | */ 46 | fun asByteArray(dst: ByteArray): Int 47 | 48 | /** 49 | * Write image data. 50 | * 51 | * @param dst destination OutputStream 52 | * @return output data size 53 | */ 54 | fun write(dst: OutputStream): Int 55 | 56 | /** 57 | * Write image data. 58 | * 59 | * @param dst destination ByteBuffer 60 | */ 61 | fun write(dst: ByteBuffer) 62 | 63 | @RestrictTo(RestrictTo.Scope.LIBRARY) 64 | fun getPlaneOffset(planeIndex: Int, rowStride: RowStride, left: Int, top: Int): Int 65 | } 66 | 67 | internal fun minWidth(width: Int, vararg other: Rect): Int { 68 | var min = width 69 | for (e in other) { 70 | min = minOf(min, e.width()) 71 | } 72 | return min 73 | } 74 | 75 | internal fun minHeight(height: Int, vararg other: Rect): Int { 76 | var min = height 77 | for (e in other) min = minOf(min, e.height()) 78 | return min 79 | } 80 | 81 | internal fun Buffer.calculateSize(dst: Buffer): Pair { 82 | return Pair( 83 | minWidth(cropRect, dst.cropRect), 84 | minHeight(cropRect, dst.cropRect), 85 | ) 86 | } 87 | 88 | internal fun Buffer.minWidth(vararg other: Rect): Int { 89 | return minWidth(cropRect.width(), *other) 90 | } 91 | 92 | internal fun Buffer.minHeight(vararg other: Rect): Int { 93 | return minHeight(cropRect.height(), *other) 94 | } 95 | 96 | internal fun Buffer.offset(planeIndex: Int): Int { 97 | return planes[planeIndex].offset(this, planeIndex) 98 | } 99 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/Buffer24.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | /** 4 | * 24 bpp Buffer. 5 | */ 6 | interface Buffer24> : Buffer { 7 | val plane: Plane 8 | 9 | fun mirrorTo(dst: BUFFER) { 10 | val (fixedWidth, fixedHeight) = calculateSize(dst) 11 | Yuv.planarRGB24Mirror( 12 | srcRGB24 = plane.buffer, srcStrideRGB24 = plane.rowStride, srcOffsetRGB24 = offset(0), 13 | dstRGB24 = dst.plane.buffer, dstStrideRGB24 = dst.plane.rowStride, dstOffsetRGB24 = dst.offset(0), 14 | width = fixedWidth, height = fixedHeight, 15 | ) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/Buffer32.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.graphics.Rect 4 | 5 | /** 6 | * 32 bpp Buffer. 7 | */ 8 | interface Buffer32> : Buffer { 9 | val plane: Plane 10 | 11 | fun convertTo(dst: BUFFER) { 12 | val (fixedWidth, fixedHeight) = calculateSize(dst) 13 | Yuv.convertARGBCopy( 14 | srcARGB = plane.buffer, srcStrideARGB = plane.rowStride, srcOffsetARGB = offset(0), 15 | dstARGB = dst.plane.buffer, dstStrideARGB = dst.plane.rowStride, dstOffsetARGB = dst.offset(0), 16 | width = fixedWidth, height = fixedHeight, 17 | ) 18 | } 19 | 20 | fun mirrorTo(dst: BUFFER) { 21 | val (fixedWidth, fixedHeight) = calculateSize(dst) 22 | Yuv.planarARGBMirror( 23 | srcARGB = plane.buffer, srcStrideARGB = plane.rowStride, srcOffsetARGB = offset(0), 24 | dstARGB = dst.plane.buffer, dstStrideARGB = dst.plane.rowStride, dstOffsetARGB = dst.offset(0), 25 | width = fixedWidth, height = fixedHeight, 26 | ) 27 | } 28 | 29 | fun rotate(dst: BUFFER, rotateMode: RotateMode) { 30 | Yuv.rotateARGBRotate( 31 | srcARGB = plane.buffer, srcStrideARGB = plane.rowStride, srcOffsetARGB = offset(0), 32 | dstARGB = dst.plane.buffer, dstStrideARGB = dst.plane.rowStride, dstOffsetARGB = dst.offset(0), 33 | width = rotateMode.calculateWidth(this, dst), 34 | height = rotateMode.calculateHeight(this, dst), 35 | rotateMode = rotateMode.degrees, 36 | ) 37 | } 38 | 39 | fun scale(dst: BUFFER, filterMode: FilterMode) { 40 | Yuv.scaleARGBScale( 41 | srcARGB = plane.buffer, srcStrideARGB = plane.rowStride, srcOffsetARGB = offset(0), 42 | srcWidth = cropRect.width(), srcHeight = cropRect.height(), 43 | dstARGB = dst.plane.buffer, dstStrideARGB = dst.plane.rowStride, dstOffsetARGB = dst.offset(0), 44 | dstWidth = dst.cropRect.width(), dstHeight = dst.cropRect.height(), 45 | filterMode = filterMode.mode, 46 | ) 47 | } 48 | 49 | fun scaleClip(dst: BUFFER, rect: Rect, filterMode: FilterMode) { 50 | Yuv.scaleARGBScaleClip( 51 | srcARGB = plane.buffer, srcStrideARGB = plane.rowStride, srcOffsetARGB = offset(0), 52 | srcWidth = cropRect.width(), srcHeight = cropRect.height(), 53 | dstARGB = dst.plane.buffer, dstStrideARGB = dst.plane.rowStride, dstOffsetARGB = dst.offset(0), 54 | dstWidth = dst.cropRect.width(), dstHeight = dst.cropRect.height(), 55 | clipX = rect.left, clipY = rect.top, 56 | clipWidth = rect.width(), clipHeight = rect.height(), 57 | filterMode = filterMode.mode, 58 | ) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BufferExt.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.graphics.Bitmap 4 | import java.nio.ByteBuffer 5 | 6 | internal fun ByteBuffer.toBitmap(width: Int, height: Int, config: Bitmap.Config): Bitmap { 7 | return Bitmap.createBitmap(width, height, config).also { 8 | position(0) 9 | it.copyPixelsFromBuffer(this) 10 | } 11 | } 12 | 13 | internal fun ByteBuffer.copy(dst: ByteArray, dstOffset: Int = 0, srcOffset: Int = 0, length: Int = limit()) { 14 | val srcObj: Any = if (isDirect) this else array() 15 | check(dst.size >= length) { "dst size is less than length" } 16 | 17 | Yuv.memcopy(dst, dstOffset, srcObj, srcOffset, length) 18 | } 19 | 20 | internal fun createByteBuffer(capacities: List): Array { 21 | check(capacities.isNotEmpty()) 22 | 23 | val whole = Yuv.allocNativeBuffer(capacities.sumOf { it.value }) 24 | return whole.sliceByLength(capacities) 25 | } 26 | 27 | internal fun ByteBuffer.sliceRange(offset: Int, length: Int): ByteBuffer { 28 | execute { _, _ -> 29 | position(offset) 30 | limit(offset + length) 31 | 32 | return slice() 33 | } 34 | } 35 | 36 | internal fun ByteBuffer.sliceByLength(capacities: List): Array { 37 | check(capacities.isNotEmpty()) 38 | 39 | execute { _, limit -> 40 | var offset = 0 41 | var index = 0 42 | val num = capacities.size 43 | val results = arrayOfNulls(num + 1) 44 | capacities.forEach { sliceLength -> 45 | position(offset) 46 | offset += sliceLength.value 47 | limit(offset) 48 | results[index++] = slice() 49 | } 50 | check(offset <= limit) { "buffer limit is bigger than expected" } 51 | 52 | results[index] = this 53 | return results.requireNoNulls() 54 | } 55 | } 56 | 57 | internal inline fun ByteBuffer.execute(func: (position: Int, limit: Int) -> T): T { 58 | // backup 59 | val previousPosition = position() 60 | val previousLimit = limit() 61 | 62 | try { 63 | return func(previousPosition, previousLimit) 64 | } finally { 65 | // restore 66 | position(previousPosition) 67 | limit(previousLimit) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BufferFactory.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.graphics.Rect 4 | import java.nio.ByteBuffer 5 | 6 | interface BufferFactory { 7 | fun allocate(width: Int, height: Int): BUFFER { 8 | return allocate(width, height, Rect(0, 0, width, height)) 9 | } 10 | 11 | fun allocate(width: Int, height: Int, cropRect: Rect): BUFFER 12 | 13 | fun wrap(buffer: ByteBuffer, width: Int, height: Int): BUFFER { 14 | return wrap(buffer, width, height, Rect(0, 0, width, height)) 15 | } 16 | 17 | fun wrap(buffer: ByteBuffer, width: Int, height: Int, cropRect: Rect): BUFFER 18 | } 19 | 20 | interface BufferFactory24> : BufferFactory { 21 | fun wrap(plane: Plane, width: Int, height: Int): BUFFER { 22 | return wrap(plane, width, height, Rect(0, 0, width, height)) 23 | } 24 | 25 | fun wrap(plane: Plane, width: Int, height: Int, cropRect: Rect): BUFFER 26 | } 27 | 28 | interface BufferFactory32> : BufferFactory { 29 | fun wrap(plane: Plane, width: Int, height: Int): BUFFER { 30 | return wrap(plane, width, height, Rect(0, 0, width, height)) 31 | } 32 | 33 | fun wrap(plane: Plane, width: Int, height: Int, cropRect: Rect): BUFFER 34 | } 35 | 36 | interface BufferFactoryY> : BufferFactory { 37 | fun wrap(planeY: Plane, width: Int, height: Int): BUFFER { 38 | return wrap(planeY, width, height, Rect(0, 0, width, height)) 39 | } 40 | 41 | fun wrap(planeY: Plane, width: Int, height: Int, cropRect: Rect): BUFFER 42 | } 43 | interface BufferFactoryYUV : BufferFactory { 44 | fun wrap(planeY: Plane, planeU: Plane, planeV: Plane, width: Int, height: Int): BUFFER { 45 | return wrap(planeY, planeU, planeV, width, height, Rect(0, 0, width, height)) 46 | } 47 | 48 | fun wrap(planeY: Plane, planeU: Plane, planeV: Plane, width: Int, height: Int, cropRect: Rect): BUFFER 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BufferFirstAlpha.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | /** 4 | * Has first Alpha channel. 5 | */ 6 | interface BufferFirstAlpha : Buffer { 7 | val plane: Plane 8 | 9 | fun copyAlphaTo(dst: AbgrBuffer) { 10 | val (fixedWidth, fixedHeight) = calculateSize(dst) 11 | Yuv.planarARGBCopyAlpha( 12 | srcARGB = plane.buffer, srcStrideARGB = plane.rowStride, srcOffsetARGB = offset(0), 13 | dstARGB = dst.plane.buffer, dstStrideARGB = dst.plane.rowStride, dstOffsetARGB = dst.offset(0), 14 | width = fixedWidth, height = fixedHeight, 15 | ) 16 | } 17 | 18 | fun copyAlphaTo(dst: ArgbBuffer) { 19 | val (fixedWidth, fixedHeight) = calculateSize(dst) 20 | Yuv.planarARGBCopyAlpha( 21 | srcARGB = plane.buffer, srcStrideARGB = plane.rowStride, srcOffsetARGB = offset(0), 22 | dstARGB = dst.plane.buffer, dstStrideARGB = dst.plane.rowStride, dstOffsetARGB = dst.offset(0), 23 | width = fixedWidth, height = fixedHeight, 24 | ) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BufferX400.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | /** 4 | * YUV(4:0:0 8bpp) Buffer. 5 | */ 6 | interface BufferX400, BUFFERX420 : BufferX420> : BufferY { 7 | fun convertTo(dst: BUFFERX420) { 8 | val (fixedWidth, fixedHeight) = calculateSize(dst) 9 | Yuv.convertI400Copy( 10 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 11 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 12 | width = fixedWidth, height = fixedHeight, 13 | ) 14 | } 15 | 16 | fun mirrorTo(dst: BUFFER) { 17 | val (fixedWidth, fixedHeight) = calculateSize(dst) 18 | Yuv.planarI400Mirror( 19 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 20 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 21 | width = fixedWidth, height = fixedHeight, 22 | ) 23 | } 24 | 25 | fun rotate(dst: BUFFER, rotateMode: RotateMode) { 26 | Yuv.rotateRotatePlane( 27 | src = planeY.buffer, srcStride = planeY.rowStride, srcOffset = offset(0), 28 | dst = dst.planeY.buffer, dstStride = dst.planeY.rowStride, dstOffset = dst.offset(0), 29 | width = rotateMode.calculateWidth(this, dst), 30 | height = rotateMode.calculateHeight(this, dst), 31 | rotateMode = rotateMode.degrees, 32 | ) 33 | } 34 | 35 | fun scale(dst: BUFFER, filterMode: FilterMode) { 36 | Yuv.scaleScalePlane( 37 | src = planeY.buffer, srcStride = planeY.rowStride, srcOffset = offset(0), 38 | srcWidth = cropRect.width(), srcHeight = cropRect.height(), 39 | dst = dst.planeY.buffer, dstStride = dst.planeY.rowStride, dstOffset = dst.offset(0), 40 | dstWidth = dst.cropRect.width(), dstHeight = dst.cropRect.height(), 41 | filterMode = filterMode.mode, 42 | ) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BufferX420.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | /** 4 | * YUV(4:2:0 12bpp) Buffer. 5 | */ 6 | interface BufferX420> : BufferYUV { 7 | fun convertTo(dst: BUFFER) { 8 | val (fixedWidth, fixedHeight) = calculateSize(dst) 9 | Yuv.convertI420Copy( 10 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 11 | srcU = planeU.buffer, srcStrideU = planeU.rowStride, srcOffsetU = offset(1), 12 | srcV = planeV.buffer, srcStrideV = planeV.rowStride, srcOffsetV = offset(2), 13 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 14 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 15 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 16 | width = fixedWidth, height = fixedHeight, 17 | ) 18 | } 19 | 20 | fun mirrorTo(dst: BUFFER) { 21 | val (fixedWidth, fixedHeight) = calculateSize(dst) 22 | Yuv.planarI420Mirror( 23 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 24 | srcU = planeU.buffer, srcStrideU = planeU.rowStride, srcOffsetU = offset(1), 25 | srcV = planeV.buffer, srcStrideV = planeV.rowStride, srcOffsetV = offset(2), 26 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 27 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 28 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 29 | width = fixedWidth, height = fixedHeight, 30 | ) 31 | } 32 | 33 | fun rotate(dst: BUFFER, rotateMode: RotateMode) { 34 | Yuv.rotateI420Rotate( 35 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 36 | srcU = planeU.buffer, srcStrideU = planeU.rowStride, srcOffsetU = offset(1), 37 | srcV = planeV.buffer, srcStrideV = planeV.rowStride, srcOffsetV = offset(2), 38 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 39 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 40 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 41 | width = rotateMode.calculateWidth(this, dst), 42 | height = rotateMode.calculateHeight(this, dst), 43 | rotateMode = rotateMode.degrees, 44 | ) 45 | } 46 | 47 | fun scale(dst: BUFFER, filterMode: FilterMode) { 48 | Yuv.scaleI420Scale( 49 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 50 | srcU = planeU.buffer, srcStrideU = planeU.rowStride, srcOffsetU = offset(1), 51 | srcV = planeV.buffer, srcStrideV = planeV.rowStride, srcOffsetV = offset(2), 52 | srcWidth = cropRect.width(), srcHeight = cropRect.height(), 53 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 54 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 55 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 56 | dstWidth = dst.cropRect.width(), dstHeight = dst.cropRect.height(), 57 | filterMode = filterMode.mode, 58 | ) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BufferX422.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | /** 4 | * YUV(4:2:2 16bpp) Buffer. 5 | */ 6 | interface BufferX422> : BufferYUV { 7 | fun convertTo(dst: BUFFER) { 8 | val (fixedWidth, fixedHeight) = calculateSize(dst) 9 | Yuv.planarI422Copy( 10 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 11 | srcU = planeU.buffer, srcStrideU = planeU.rowStride, srcOffsetU = offset(1), 12 | srcV = planeV.buffer, srcStrideV = planeV.rowStride, srcOffsetV = offset(2), 13 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 14 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 15 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 16 | width = fixedWidth, height = fixedHeight, 17 | ) 18 | } 19 | 20 | fun rotate(dst: BUFFER, rotateMode: RotateMode) { 21 | Yuv.rotateI422Rotate( 22 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 23 | srcU = planeU.buffer, srcStrideU = planeU.rowStride, srcOffsetU = offset(1), 24 | srcV = planeV.buffer, srcStrideV = planeV.rowStride, srcOffsetV = offset(2), 25 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 26 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 27 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 28 | width = rotateMode.calculateWidth(this, dst), 29 | height = rotateMode.calculateHeight(this, dst), 30 | rotateMode = rotateMode.degrees, 31 | ) 32 | } 33 | 34 | fun scale(dst: BUFFER, filterMode: FilterMode) { 35 | Yuv.scaleI422Scale( 36 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 37 | srcU = planeU.buffer, srcStrideU = planeU.rowStride, srcOffsetU = offset(1), 38 | srcV = planeV.buffer, srcStrideV = planeV.rowStride, srcOffsetV = offset(2), 39 | srcWidth = cropRect.width(), srcHeight = cropRect.height(), 40 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 41 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 42 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 43 | dstWidth = dst.cropRect.width(), dstHeight = dst.cropRect.height(), 44 | filterMode = filterMode.mode, 45 | ) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BufferX444.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | /** 4 | * YUV(4:4:4 24bpp) Buffer. 5 | */ 6 | interface BufferX444> : BufferYUV { 7 | fun convertTo(dst: BUFFER) { 8 | val (fixedWidth, fixedHeight) = calculateSize(dst) 9 | Yuv.planarI444Copy( 10 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 11 | srcU = planeU.buffer, srcStrideU = planeU.rowStride, srcOffsetU = offset(1), 12 | srcV = planeV.buffer, srcStrideV = planeV.rowStride, srcOffsetV = offset(2), 13 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 14 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 15 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 16 | width = fixedWidth, height = fixedHeight, 17 | ) 18 | } 19 | 20 | fun rotate(dst: BUFFER, rotateMode: RotateMode) { 21 | Yuv.rotateI444Rotate( 22 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 23 | srcU = planeU.buffer, srcStrideU = planeU.rowStride, srcOffsetU = offset(1), 24 | srcV = planeV.buffer, srcStrideV = planeV.rowStride, srcOffsetV = offset(2), 25 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 26 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 27 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 28 | width = rotateMode.calculateWidth(this, dst), 29 | height = rotateMode.calculateHeight(this, dst), 30 | rotateMode = rotateMode.degrees, 31 | ) 32 | } 33 | 34 | fun scale(dst: BUFFER, filterMode: FilterMode) { 35 | Yuv.scaleI444Scale( 36 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 37 | srcU = planeU.buffer, srcStrideU = planeU.rowStride, srcOffsetU = offset(1), 38 | srcV = planeV.buffer, srcStrideV = planeV.rowStride, srcOffsetV = offset(2), 39 | srcWidth = cropRect.width(), srcHeight = cropRect.height(), 40 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 41 | dstU = dst.planeU.buffer, dstStrideU = dst.planeU.rowStride, dstOffsetU = dst.offset(1), 42 | dstV = dst.planeV.buffer, dstStrideV = dst.planeV.rowStride, dstOffsetV = dst.offset(2), 43 | dstWidth = dst.cropRect.width(), dstHeight = dst.cropRect.height(), 44 | filterMode = filterMode.mode, 45 | ) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BufferY.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | /** 4 | * Y Buffer. 5 | */ 6 | interface BufferY> : Buffer { 7 | val planeY: Plane 8 | 9 | fun convertTo(dst: BUFFER) { 10 | val (fixedWidth, fixedHeight) = calculateSize(dst) 11 | Yuv.convertI400Copy( 12 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 13 | dstY = dst.planeY.buffer, dstStrideY = dst.planeY.rowStride, dstOffsetY = dst.offset(0), 14 | width = fixedWidth, height = fixedHeight, 15 | ) 16 | } 17 | 18 | fun copyAlpha(dst: BufferFirstAlpha) { 19 | val (fixedWidth, fixedHeight) = calculateSize(dst) 20 | Yuv.planarARGBCopyYToAlpha( 21 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 22 | dstARGB = dst.plane.buffer, dstStrideARGB = dst.plane.rowStride, dstOffsetARGB = dst.offset(0), 23 | width = fixedWidth, height = fixedHeight, 24 | ) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/BufferYUV.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | /** 4 | * YUV Buffer. 5 | */ 6 | interface BufferYUV : Buffer { 7 | val planeY: Plane 8 | val planeU: Plane 9 | val planeV: Plane 10 | } 11 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/CapacityCalculator.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | interface CapacityCalculator { 4 | fun calculate(width: Int, height: Int): CAPACITIES 5 | } 6 | 7 | @JvmInline 8 | value class Capacity(val value: Int) { 9 | override fun toString(): String = value.toString() 10 | } 11 | 12 | @JvmInline 13 | value class RowStride(val value: Int) { 14 | override fun toString(): String = value.toString() 15 | 16 | operator fun times(other: Int): Int { 17 | return value * other 18 | } 19 | } 20 | 21 | interface PlaneCapacities 22 | 23 | data class Plane1Capacities( 24 | val planeCapacity: Capacity, 25 | val planeStride: RowStride, 26 | ) : PlaneCapacities 27 | 28 | data class Plane2Capacities( 29 | val plane1Capacity: Capacity, 30 | val plane2Capacity: Capacity, 31 | val plane1Stride: RowStride, 32 | val plane2Stride: RowStride, 33 | ) : PlaneCapacities 34 | 35 | data class Plane3Capacities( 36 | val plane1Capacity: Capacity, 37 | val plane2Capacity: Capacity, 38 | val plane3Capacity: Capacity, 39 | val plane1Stride: RowStride, 40 | val plane2Stride: RowStride, 41 | val plane3Stride: RowStride, 42 | ) : PlaneCapacities 43 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/FilterMode.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | /** 4 | * Filter Mode 5 | */ 6 | enum class FilterMode(val mode: Int) { 7 | NONE(0), 8 | LINEAR(1), 9 | BILINEAR(2), 10 | BOX(3), 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/J400Buffer.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.graphics.Rect 4 | import java.nio.ByteBuffer 5 | 6 | /** 7 | * J400 (jpeg grey) YUV Format. 4:0:0 8bpp 8 | */ 9 | class J400Buffer private constructor( 10 | buffer: ByteBuffer?, 11 | override val planeY: Plane, 12 | override val width: Int, 13 | override val height: Int, 14 | cropRect: Rect, 15 | releaseCallback: Runnable?, 16 | ) : AbstractBuffer(buffer, cropRect, arrayOf(planeY), releaseCallback), BufferX400, BufferY { 17 | override fun getPlaneOffset(planeIndex: Int, rowStride: RowStride, left: Int, top: Int): Int { 18 | return rowStride * top + left 19 | } 20 | 21 | fun convertTo(dst: ArgbBuffer) { 22 | val (fixedWidth, fixedHeight) = calculateSize(dst) 23 | Yuv.convertJ400ToARGB( 24 | srcY = planeY.buffer, srcStrideY = planeY.rowStride, srcOffsetY = offset(0), 25 | dstARGB = dst.plane.buffer, dstStrideARGB = dst.plane.rowStride, dstOffsetARGB = dst.offset(0), 26 | width = fixedWidth, height = fixedHeight, 27 | ) 28 | } 29 | 30 | companion object Factory : BufferFactoryY, CapacityCalculator { 31 | override fun calculate(width: Int, height: Int): Plane1Capacities { 32 | return Plane1Capacities( 33 | planeStride = RowStride(width), 34 | planeCapacity = Capacity(width * height), 35 | ) 36 | } 37 | 38 | override fun allocate(width: Int, height: Int, cropRect: Rect): J400Buffer { 39 | val (capacity, stride) = calculate(width, height) 40 | val (buffer) = createByteBuffer(listOf(capacity)) 41 | return J400Buffer( 42 | buffer = buffer, 43 | planeY = PlanePrimitive(stride, buffer), 44 | width = width, 45 | height = height, 46 | cropRect = cropRect, 47 | ) { 48 | Yuv.freeNativeBuffer(buffer) 49 | } 50 | } 51 | 52 | override fun wrap(buffer: ByteBuffer, width: Int, height: Int, cropRect: Rect): J400Buffer { 53 | check(buffer.isDirect) { "Unsupported non-direct ByteBuffer." } 54 | 55 | val (capacity, stride) = calculate(width, height) 56 | val sliceBuffer = buffer.sliceRange(0, capacity.value) 57 | return J400Buffer( 58 | buffer = sliceBuffer, 59 | planeY = PlanePrimitive(stride, sliceBuffer), 60 | width = width, 61 | height = height, 62 | cropRect = cropRect, 63 | releaseCallback = null, 64 | ) 65 | } 66 | 67 | override fun wrap(planeY: Plane, width: Int, height: Int, cropRect: Rect): J400Buffer { 68 | return J400Buffer( 69 | buffer = planeY.buffer, 70 | planeY = planeY, 71 | width = width, 72 | height = height, 73 | cropRect = cropRect, 74 | releaseCallback = null, 75 | ) 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/OffsetCalculator.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | fun interface OffsetCalculator { 4 | fun calculate(left: Int, top: Int, rowStride: RowStride): Int 5 | } 6 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/Plane.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("unused") 2 | 3 | package io.github.crow_misia.libyuv 4 | 5 | import android.graphics.Rect 6 | import java.math.BigInteger 7 | import java.nio.ByteBuffer 8 | import kotlin.math.min 9 | 10 | abstract class Plane { 11 | abstract val rowStride: RowStride 12 | abstract val buffer: ByteBuffer 13 | abstract val bufferSize: Int 14 | 15 | fun getRowStride(): Int = rowStride.value 16 | 17 | fun hashDjb2(): Long = hashDjb2(5381) 18 | 19 | fun hashDjb2(seed: Long): Long { 20 | return Yuv.hashDjb2( 21 | src = buffer, 22 | count = buffer.capacity().toLong(), 23 | seed = seed, 24 | ) 25 | } 26 | 27 | fun hammingDistance(other: Plane): BigInteger { 28 | return BigInteger(Yuv.computeHammingDistance( 29 | srcA = buffer, 30 | srcB = other.buffer, 31 | count = min(buffer.capacity(), other.buffer.capacity()), 32 | )) 33 | } 34 | 35 | fun computeSumSquareError(other: Plane, width: Int, height: Int): BigInteger { 36 | return BigInteger(Yuv.computeSumSquareErrorPlane( 37 | srcA = buffer, srcStrideA = rowStride, 38 | srcB = other.buffer, srcStrideB = other.rowStride, 39 | width = width, height = height, 40 | )) 41 | } 42 | 43 | fun calculateFramePsnr(other: Plane, width: Int, height: Int): Double { 44 | return Yuv.calcFramePsnr( 45 | srcA = buffer, srcStrideA = rowStride, 46 | srcB = other.buffer, srcStrideB = other.rowStride, 47 | width = width, height = height, 48 | ) 49 | } 50 | 51 | fun calculateFrameSsim(other: Plane, width: Int, height: Int): Double { 52 | return Yuv.calcFrameSsim( 53 | srcA = buffer, srcStrideA = rowStride, 54 | srcB = other.buffer, srcStrideB = other.rowStride, 55 | width = width, height = height, 56 | ) 57 | } 58 | 59 | fun setValue(top: Int = 0, left: Int = 0, width: Int, height: Int, value: Int) { 60 | setValue(Rect(top, left, top + width, top + height), value) 61 | } 62 | 63 | fun setValue(rect: Rect, value: Int) { 64 | Yuv.planarSetPlane( 65 | dstY = buffer, dstStrideY = rowStride, dstOffsetY = rect.top * rowStride.value + rect.left, 66 | width = rect.width(), height = rect.height(), 67 | value = value, 68 | ) 69 | } 70 | 71 | internal fun offset(buffer: Buffer, planeIndex: Int): Int { 72 | val cropRect = buffer.cropRect 73 | return buffer.getPlaneOffset(planeIndex, rowStride, cropRect.left, cropRect.top) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/PlaneNative.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.media.Image 4 | import java.nio.ByteBuffer 5 | 6 | data class PlaneNative @JvmOverloads constructor( 7 | private val plane: Image.Plane, 8 | override val buffer: ByteBuffer = plane.buffer, 9 | override val bufferSize: Int = buffer.capacity(), 10 | ) : Plane() { 11 | override val rowStride: RowStride = RowStride(plane.rowStride) 12 | } 13 | 14 | fun Image.Plane.asPlane(bufferSize: Int = buffer.capacity()): Plane { 15 | return PlaneNative( 16 | plane = this, 17 | buffer = buffer, 18 | bufferSize = bufferSize, 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/PlanePrimitive.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import java.nio.ByteBuffer 4 | 5 | data class PlanePrimitive( 6 | override val rowStride: RowStride, 7 | override val buffer: ByteBuffer, 8 | override val bufferSize: Int = buffer.capacity(), 9 | ) : Plane() { 10 | companion object { 11 | @JvmStatic 12 | @JvmOverloads 13 | fun create( 14 | rowStride: Int, 15 | buffer: ByteBuffer, 16 | bufferSize: Int = buffer.capacity(), 17 | ) = PlanePrimitive( 18 | rowStride = RowStride(rowStride), 19 | buffer = buffer, 20 | bufferSize = bufferSize, 21 | ) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/PlaneProxy.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import androidx.camera.core.ImageProxy 4 | import java.nio.ByteBuffer 5 | 6 | data class PlaneProxy @JvmOverloads constructor( 7 | private val proxy: ImageProxy.PlaneProxy, 8 | override val buffer: ByteBuffer = proxy.buffer, 9 | override val bufferSize: Int = buffer.capacity(), 10 | ) : Plane() { 11 | override val rowStride: RowStride = RowStride(proxy.rowStride) 12 | } 13 | 14 | fun ImageProxy.PlaneProxy.asPlane(bufferSize: Int = buffer.capacity()): Plane { 15 | return PlaneProxy( 16 | proxy = this, 17 | buffer = buffer, 18 | bufferSize = bufferSize, 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/RotateMode.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import kotlin.math.min 4 | 5 | /** 6 | * Rotate Mode 7 | */ 8 | enum class RotateMode(val degrees: Int) { 9 | ROTATE_0(0), 10 | ROTATE_90(90), 11 | ROTATE_180(180), 12 | ROTATE_270(270); 13 | 14 | internal fun calculateWidth(src: Buffer, dst: Buffer): Int { 15 | return when (this) { 16 | ROTATE_0, ROTATE_180 -> min(src.cropRect.width(), dst.cropRect.width()) 17 | ROTATE_90, ROTATE_270 -> min(src.cropRect.width(), dst.cropRect.height()) 18 | } 19 | } 20 | 21 | internal fun calculateHeight(src: Buffer, dst: Buffer): Int { 22 | return when (this) { 23 | ROTATE_0, ROTATE_180 -> min(src.cropRect.height(), dst.cropRect.height()) 24 | ROTATE_90, ROTATE_270 -> min(src.cropRect.height(), dst.cropRect.width()) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/io/github/crow_misia/libyuv/Yuv24Buffer.kt: -------------------------------------------------------------------------------- 1 | package io.github.crow_misia.libyuv 2 | 3 | import android.graphics.Rect 4 | import java.nio.ByteBuffer 5 | 6 | /** 7 | * YUV 24bpp 8 | */ 9 | class Yuv24Buffer private constructor( 10 | buffer: ByteBuffer?, 11 | override val plane: Plane, 12 | override val width: Int, 13 | override val height: Int, 14 | cropRect: Rect, 15 | releaseCallback: Runnable?, 16 | ) : AbstractBuffer(buffer, cropRect, arrayOf(plane), releaseCallback), Buffer24 { 17 | override fun getPlaneOffset(planeIndex: Int, rowStride: RowStride, left: Int, top: Int): Int { 18 | return rowStride * top + left * 3 19 | } 20 | 21 | companion object Factory : BufferFactory24, CapacityCalculator { 22 | override fun calculate(width: Int, height: Int): Plane1Capacities { 23 | val stride = width * 3 24 | val capacity = stride * height 25 | return Plane1Capacities( 26 | planeStride = RowStride(stride), 27 | planeCapacity = Capacity(capacity), 28 | ) 29 | } 30 | 31 | override fun allocate(width: Int, height: Int, cropRect: Rect): Yuv24Buffer { 32 | val (capacity, stride) = calculate(width, height) 33 | val (buffer) = createByteBuffer(listOf(capacity)) 34 | return Yuv24Buffer( 35 | buffer = buffer, 36 | plane = PlanePrimitive(stride, buffer), 37 | width = width, 38 | height = height, 39 | cropRect = cropRect, 40 | ) { 41 | Yuv.freeNativeBuffer(buffer) 42 | } 43 | } 44 | 45 | override fun wrap(buffer: ByteBuffer, width: Int, height: Int, cropRect: Rect): Yuv24Buffer { 46 | check(buffer.isDirect) { "Unsupported non-direct ByteBuffer." } 47 | 48 | val (capacity, stride) = calculate(width, height) 49 | val sliceBuffer = buffer.sliceRange(0, capacity.value) 50 | return Yuv24Buffer( 51 | buffer = sliceBuffer, 52 | plane = PlanePrimitive(stride, sliceBuffer), 53 | width = width, 54 | height = height, 55 | cropRect = cropRect, 56 | releaseCallback = null, 57 | ) 58 | } 59 | 60 | override fun wrap(plane: Plane, width: Int, height: Int, cropRect: Rect): Yuv24Buffer { 61 | return Yuv24Buffer( 62 | buffer = plane.buffer, 63 | plane = plane, 64 | width = width, 65 | height = height, 66 | cropRect = cropRect, 67 | releaseCallback = null, 68 | ) 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /core/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := libyuv_android 6 | 7 | LOCAL_SRC_FILES := \ 8 | compare.cpp \ 9 | convert.cpp \ 10 | convert_argb.cpp \ 11 | convert_from.cpp \ 12 | convert_from_argb.cpp \ 13 | helper.cpp \ 14 | jniload.cpp \ 15 | jniutil.cpp \ 16 | memcopy.cpp \ 17 | planar_functions.cpp \ 18 | rotate.cpp \ 19 | rotate_argb.cpp \ 20 | scale.cpp \ 21 | scale_argb.cpp \ 22 | scale_uv.cpp 23 | 24 | LOCAL_EXPORT_C_INCLUDES := \ 25 | $(LOCAL_PATH)/nativehelper \ 26 | $(PROJECT_PATH)/deps/libyuv/include 27 | 28 | LOCAL_STATIC_LIBRARIES := libyuv_static 29 | 30 | include $(BUILD_SHARED_LIBRARY) 31 | -------------------------------------------------------------------------------- /core/src/main/jni/compare.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBYUV_JNI_COMPARE_H_ 2 | #define LIBYUV_JNI_COMPARE_H_ 3 | 4 | #include "jniutil.h" 5 | #include "macros.h" 6 | #include "nativehelper/scoped_bytes.h" 7 | 8 | #endif //LIBYUV_JNI_COMPARE_H_ 9 | -------------------------------------------------------------------------------- /core/src/main/jni/const.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBYUV_JNI_CONST_H_ 2 | #define LIBYUV_JNI_CONST_H_ 3 | 4 | #include 5 | 6 | #define LIBYUV_JNI_VERSION JNI_VERSION_1_6 7 | 8 | #define JNI_METHOD_NAME(name) \ 9 | Java_io_github_crow_1misia_libyuv_Yuv_##name 10 | 11 | #define JNI_DEFINE_METHOD(type, name, args...) \ 12 | JNIEXPORT type JNICALL JNI_METHOD_NAME(name)(JNIEnv *env, jobject, ##args) 13 | 14 | #endif // LIBYUV_JNI_CONST_H_ 15 | -------------------------------------------------------------------------------- /core/src/main/jni/convert_from.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "convert.h" 3 | 4 | using namespace libyuv; 5 | using namespace libyuv::jniutil; 6 | extern "C" { 7 | 8 | // Convert 8 bit YUV to 10 bit. 9 | // #define H420ToH010 I420ToI010 10 | // I420ToI010 11 | 12 | // Convert 8 bit YUV to 12 bit. 13 | // #define H420ToH012 I420ToI012 14 | // I420ToI012 15 | 16 | PLANES_3_TO_3(I420ToI422, y, u, v, y, u, v); 17 | 18 | PLANES_3_TO_3(I420ToI444, y, u, v, y, u, v); 19 | 20 | // Copy to I400. Source can be I420, I422, I444, I400, NV12 or NV21. 21 | PLANES_1_TO_1(I400Copy, y, y); 22 | 23 | PLANES_3_TO_2(I420ToNV12, y, u, v, y, uv); 24 | 25 | PLANES_3_TO_2(I420ToNV21, y, u, v, y, vu); 26 | 27 | PLANES_3_TO_1(I420ToYUY2, y, u, v, yuy2); 28 | 29 | PLANES_3_TO_1(I420ToUYVY, y, u, v, uyvy); 30 | 31 | // Convert I420 to specified format. 32 | // ConvertFromI420 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/jni/convert_from_argb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "convert.h" 3 | 4 | using namespace libyuv; 5 | using namespace libyuv::jniutil; 6 | extern "C" { 7 | 8 | // Copy ARGB to ARGB. duplicate 9 | // #define ARGBToARGB ARGBCopy 10 | // ARGBCopy 11 | 12 | // Convert ARGB To BGRA. 13 | PLANES_1_TO_1(ARGBToBGRA, argb, bgra); 14 | 15 | // Convert ARGB To ABGR. 16 | PLANES_1_TO_1(ARGBToABGR, argb, abgr); 17 | 18 | // Convert ARGB To RGBA. 19 | PLANES_1_TO_1(ARGBToRGBA, argb, rgba); 20 | 21 | // #define ARGBToAB30 ABGRToAR30 22 | // #define ABGRToAB30 ARGBToAR30 23 | 24 | // Convert ABGR To AR30. 25 | // ABGRToAR30 26 | 27 | // Convert ARGB To AR30. 28 | // ARGBToAR30 29 | 30 | // #define ABGRToRGB24 ARGBToRAW 31 | // #define ABGRToRAW ARGBToRGB24 32 | 33 | // Convert ARGB To RGB24. 34 | PLANES_1_TO_1(ARGBToRGB24, argb, rgb24); 35 | 36 | // Convert ARGB To RAW. 37 | PLANES_1_TO_1(ARGBToRAW, argb, raw); 38 | 39 | // Convert ARGB To RGB565. 40 | PLANES_1_TO_1(ARGBToRGB565, argb, rgb565); 41 | 42 | // Convert ARGB To RGB565 with 4x4 dither matrix (16 bytes). 43 | // ARGBToRGB565Dither 44 | 45 | // Convert ARGB To ARGB1555. 46 | PLANES_1_TO_1(ARGBToARGB1555, argb, argb1555); 47 | 48 | // Convert ARGB To ARGB4444. 49 | PLANES_1_TO_1(ARGBToARGB4444, argb, argb4444); 50 | 51 | // Convert ARGB To I444. 52 | PLANES_1_TO_3(ARGBToI444, argb, y, u, v); 53 | 54 | // Convert ARGB to AR64. 55 | // ARGBToAR64 56 | 57 | // Convert ABGR to AB64. 58 | // #define ABGRToAB64 ARGBToAR64 59 | 60 | // Convert ARGB to AB64. 61 | // ARGBToAB64 62 | 63 | // Convert ABGR to AR64. 64 | // #define ABGRToAR64 ARGBToAB64 65 | 66 | // Convert ARGB To I422. 67 | PLANES_1_TO_3(ARGBToI422, argb, y, u, v); 68 | 69 | // Convert ARGB To I420. (also in convert.h) 70 | // ARGBToI420 71 | 72 | // Convert ARGB to J420. (JPeg full range I420) 73 | PLANES_1_TO_3(ARGBToJ420, argb, yj, uj, vj); 74 | 75 | // Convert ARGB to J422. 76 | PLANES_1_TO_3(ARGBToJ422, argb, yj, uj, vj); 77 | 78 | // Convert ARGB to J400. (JPeg full range) 79 | PLANES_1_TO_1(ARGBToJ400, argb, yj); 80 | 81 | // Convert ABGR to J420. (JPeg full range I420) 82 | PLANES_1_TO_3(ABGRToJ420, abgr, yj, uj, vj); 83 | 84 | // Convert ABGR to J422. 85 | PLANES_1_TO_3(ABGRToJ422, abgr, yj, uj, vj); 86 | 87 | // Convert ABGR to J400. (JPeg full range) 88 | PLANES_1_TO_1(ABGRToJ400, abgr, yj); 89 | 90 | // Convert RGBA to J400. (JPeg full range) 91 | PLANES_1_TO_1(RGBAToJ400, rgba, yj); 92 | 93 | // Convert ARGB to I400. 94 | PLANES_1_TO_1(ARGBToI400, argb, y); 95 | 96 | // Convert ARGB to G. (Reverse of J400toARGB, which replicates G back to ARGB) 97 | // ARGBToG 98 | 99 | // Convert ARGB To NV12. 100 | PLANES_1_TO_2(ARGBToNV12, argb, y, uv); 101 | 102 | // Convert ARGB To NV21. 103 | PLANES_1_TO_2(ARGBToNV21, argb, y, vu); 104 | 105 | // Convert ABGR To NV12. 106 | PLANES_1_TO_2(ABGRToNV12, abgr, y, uv); 107 | 108 | // Convert ABGR To NV21. 109 | PLANES_1_TO_2(ABGRToNV21, abgr, y, vu); 110 | 111 | // Convert ARGB To YUY2. 112 | PLANES_1_TO_1(ARGBToYUY2, argb, yuy2); 113 | 114 | // Convert ARGB To UYVY. 115 | PLANES_1_TO_1(ARGBToUYVY, argb, uyvy); 116 | 117 | // RAW to JNV21 full range NV21 118 | // RAWToJNV21 119 | 120 | } 121 | -------------------------------------------------------------------------------- /core/src/main/jni/helper.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "macros.h" 3 | 4 | extern "C" { 5 | 6 | JNI_DEFINE_METHOD(jobject, allocNativeBuffer, jint size) { 7 | void* buffer = malloc((size_t) size); 8 | return env->NewDirectByteBuffer(buffer, size); 9 | } 10 | 11 | JNI_DEFINE_METHOD(void, freeNativeBuffer, jobject directRef) { 12 | void *buffer = env->GetDirectBufferAddress(directRef); 13 | if (buffer != nullptr) { 14 | free(buffer); 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/main/jni/jniload.cpp: -------------------------------------------------------------------------------- 1 | #include "const.h" 2 | #include "jniutil.h" 3 | 4 | extern "C" { 5 | 6 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { 7 | JNIEnv *env; 8 | if (vm->GetEnv(reinterpret_cast(&env), LIBYUV_JNI_VERSION) != JNI_OK) { 9 | return JNI_ERR; 10 | } 11 | libyuv::jniutil::init(vm, env); 12 | 13 | return LIBYUV_JNI_VERSION; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/jni/jniutil.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "jniutil.h" 4 | 5 | namespace libyuv { 6 | namespace jniutil { 7 | 8 | JavaVM *gJavaVM; 9 | 10 | jclass byteArrayClass; 11 | 12 | void init(JavaVM* vm, JNIEnv* env) { 13 | gJavaVM = vm; 14 | 15 | byteArrayClass = findClass(env, "[B"); 16 | } 17 | 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /core/src/main/jni/jniutil.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBYUV_JNI_JNIUTIL_H_ 2 | #define LIBYUV_JNI_JNIUTIL_H_ 3 | 4 | #include 5 | #include "nativehelper/scoped_local_ref.h" 6 | 7 | namespace libyuv { 8 | namespace jniutil { 9 | 10 | extern JavaVM *gJavaVM; 11 | 12 | extern jclass byteArrayClass; 13 | 14 | void init(JavaVM *vm, JNIEnv *env); 15 | 16 | inline jclass findClass(JNIEnv* env, const char* name) { 17 | ScopedLocalRef localClass(env, env->FindClass(name)); 18 | return reinterpret_cast(env->NewGlobalRef(localClass.get())); 19 | } 20 | 21 | inline int throwException(JNIEnv *env, const char* className, const char *message) { 22 | ScopedLocalRef clazz(env, env->FindClass(className)); 23 | if (clazz.get() == nullptr) { 24 | // Class not found 25 | return -1; 26 | } 27 | if (env->ThrowNew(clazz.get(), message) != JNI_OK) { 28 | // an exception, most likely OOM 29 | return -1; 30 | } 31 | return 0; 32 | } 33 | 34 | inline int throwNullPointerException(JNIEnv *env, const char *message) { 35 | return throwException(env, "java/lang/NullPointerException", message); 36 | } 37 | 38 | inline int throwIllegalArgumentException(JNIEnv *env, const char *message) { 39 | return throwException(env, "java/lang/IllegalArgumentException", message); 40 | } 41 | 42 | inline int throwIllegalStateException(JNIEnv *env, const char *message) { 43 | return throwException(env, "java/lang/IllegalStateException", message); 44 | } 45 | 46 | } 47 | } 48 | 49 | #endif // LIBYUV_JNI_JNIUTIL_H_ 50 | -------------------------------------------------------------------------------- /core/src/main/jni/macros.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBYUV_JNI_MACROS_H_ 2 | #define LIBYUV_JNI_MACROS_H_ 3 | 4 | #include 5 | #include 6 | #include "const.h" 7 | 8 | #define DISALLOW_COPY_AND_ASSIGN(ClassName) \ 9 | ClassName(const ClassName&); \ 10 | void operator=(const ClassName&); 11 | 12 | #define DECLARE_BUFFER_SRC(jbuf, buf, dummy_retval) \ 13 | ScopedBytesRO scoped_##buf(env, jbuf); \ 14 | const uint8_t *buf = reinterpret_cast(scoped_##buf.get()); \ 15 | if (buf == nullptr) { \ 16 | throwIllegalArgumentException(env, "ByteBuffer " #buf " is not available"); \ 17 | return dummy_retval; \ 18 | } 19 | 20 | #define DECLARE_BUFFER_SRC_WITH_OFFSET(jbuf, buf, jOffset, offset, dummy_retval) \ 21 | DECLARE_OFFSET(jOffset, offset, dummy_retval); \ 22 | ScopedBytesRO scoped_##buf(env, jbuf); \ 23 | const uint8_t *buf = reinterpret_cast(scoped_##buf.get() + offset); \ 24 | if (buf == nullptr) { \ 25 | throwIllegalArgumentException(env, "ByteBuffer " #buf " is not available"); \ 26 | return dummy_retval; \ 27 | } 28 | 29 | #define DECLARE_BUFFER_DST(jbuf, buf, dummy_retval) \ 30 | ScopedBytesRW scoped_##buf(env, jbuf); \ 31 | uint8_t *buf = reinterpret_cast(scoped_##buf.get()); \ 32 | if (buf == nullptr) { \ 33 | throwIllegalArgumentException(env, "ByteBuffer " #buf " is not available"); \ 34 | return dummy_retval; \ 35 | } 36 | 37 | #define DECLARE_BUFFER_DST_WITH_OFFSET(jbuf, buf, jOffset, offset, dummy_retval) \ 38 | DECLARE_OFFSET(jOffset, offset, dummy_retval); \ 39 | ScopedBytesRW scoped_##buf(env, jbuf); \ 40 | uint8_t *buf = reinterpret_cast(scoped_##buf.get() + offset); \ 41 | if (buf == nullptr) { \ 42 | throwIllegalArgumentException(env, "ByteBuffer " #buf " is not available"); \ 43 | return dummy_retval; \ 44 | } 45 | 46 | #define DECLARE_STRIDE(jStride, stride, dummy_retval) \ 47 | int stride = jStride; \ 48 | if (stride < 0) { \ 49 | throwIllegalArgumentException(env, "Stride " #stride " must be positive"); \ 50 | return dummy_retval; \ 51 | } 52 | 53 | #define DECLARE_OFFSET(jOffset, offset, dummy_retval) \ 54 | int offset = jOffset; \ 55 | if (offset < 0) { \ 56 | throwIllegalArgumentException(env, "Offset " #offset " must be positive"); \ 57 | return dummy_retval; \ 58 | } 59 | 60 | #define SRC_PLANE(name) \ 61 | DECLARE_BUFFER_SRC(j_src_##name, src_##name,); \ 62 | DECLARE_STRIDE(j_src_stride_##name, src_stride_##name,); 63 | 64 | #define SRC_PLANE_OFFSET(name) \ 65 | DECLARE_BUFFER_SRC_WITH_OFFSET(j_src_##name, src_##name, j_src_offset_##name, src_offset_##name,); \ 66 | DECLARE_STRIDE(j_src_stride_##name, src_stride_##name,); 67 | 68 | #define SRC_PLANE_RET(name,dummy_retval) \ 69 | DECLARE_BUFFER_SRC(j_src_##name, src_##name,dummy_retval); \ 70 | DECLARE_STRIDE(j_src_stride_##name, src_stride_##name,dummy_retval); 71 | 72 | #define DST_PLANE(name) \ 73 | DECLARE_BUFFER_DST(j_dst_##name, dst_##name,); \ 74 | DECLARE_STRIDE(j_dst_stride_##name, dst_stride_##name,); 75 | 76 | #define DST_PLANE_OFFSET(name) \ 77 | DECLARE_BUFFER_DST_WITH_OFFSET(j_dst_##name, dst_##name, j_dst_offset_##name, dst_offset_##name,); \ 78 | DECLARE_STRIDE(j_dst_stride_##name, dst_stride_##name,); 79 | 80 | #define CALL(NAME, ...) \ 81 | int result = NAME(__VA_ARGS__); \ 82 | if (result != 0) { \ 83 | throwIllegalStateException(env, #NAME " failed"); \ 84 | return; \ 85 | } 86 | 87 | #endif // LIBYUV_JNI_MACROS_H_ 88 | -------------------------------------------------------------------------------- /core/src/main/jni/memcopy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "const.h" 3 | #include "jniutil.h" 4 | #include "nativehelper/scoped_bytes.h" 5 | 6 | extern "C" { 7 | 8 | JNI_DEFINE_METHOD(void, memcopy, 9 | jobject j_dst, jint dst_offset, 10 | jobject j_src, jint src_offset, 11 | jint length) { 12 | ScopedBytesRW dst(env, j_dst); 13 | if (dst.get() == nullptr) { 14 | return; 15 | } 16 | ScopedBytesRO src(env, j_src); 17 | if (src.get() == nullptr) { 18 | return; 19 | } 20 | memmove(dst.get() + dst_offset, src.get() + src_offset, static_cast(length)); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/jni/nativehelper/scoped_bytes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SCOPED_BYTES_H_ 18 | #define SCOPED_BYTES_H_ 19 | 20 | #include 21 | #include 22 | #include "../jniutil.h" 23 | #include "../macros.h" 24 | 25 | /** 26 | * ScopedBytesRO and ScopedBytesRW attempt to paper over the differences between byte[]s and 27 | * ByteBuffers. This in turn helps paper over the differences between non-direct ByteBuffers backed 28 | * by byte[]s, direct ByteBuffers backed by bytes[]s, and direct ByteBuffers not backed by byte[]s. 29 | * (On Android, this last group only contains MappedByteBuffers.) 30 | */ 31 | template 32 | class ScopedBytes { 33 | public: 34 | ScopedBytes(JNIEnv* env, jobject object) 35 | : mEnv(env), mObject(object), mByteArray(nullptr), mPtr(nullptr) 36 | { 37 | if (mObject == nullptr) { 38 | libyuv::jniutil::throwNullPointerException(mEnv, nullptr); 39 | } else if (mEnv->IsInstanceOf(mObject, libyuv::jniutil::byteArrayClass)) { 40 | mByteArray = reinterpret_cast(mObject); 41 | mPtr = mEnv->GetByteArrayElements(mByteArray, nullptr); 42 | } else { 43 | mPtr = reinterpret_cast(mEnv->GetDirectBufferAddress(mObject)); 44 | } 45 | } 46 | ~ScopedBytes() { 47 | if (mByteArray != nullptr) { 48 | mEnv->ReleaseByteArrayElements(mByteArray, mPtr, readOnly ? JNI_ABORT : 0); 49 | } 50 | } 51 | private: 52 | JNIEnv* mEnv; 53 | jobject mObject; 54 | jbyteArray mByteArray; 55 | protected: 56 | jbyte* mPtr; 57 | private: 58 | // Disallow copy and assignment. 59 | DISALLOW_COPY_AND_ASSIGN(ScopedBytes); 60 | }; 61 | 62 | class ScopedBytesRO : public ScopedBytes { 63 | public: 64 | ScopedBytesRO(JNIEnv* env, jobject object) : ScopedBytes(env, object) {} 65 | inline const jbyte* get() const { 66 | return mPtr; 67 | } 68 | }; 69 | 70 | class ScopedBytesRW : public ScopedBytes { 71 | public: 72 | ScopedBytesRW(JNIEnv* env, jobject object) : ScopedBytes(env, object) {} 73 | inline jbyte* get() { 74 | return mPtr; 75 | } 76 | }; 77 | 78 | #endif // SCOPEDLOCALREF_H_ -------------------------------------------------------------------------------- /core/src/main/jni/nativehelper/scoped_local_ref.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SCOPED_LOCAL_REF_H__ 18 | #define SCOPED_LOCAL_REF_H__ 19 | 20 | #include 21 | #include 22 | #include "../macros.h" 23 | 24 | // A smart pointer that deletes a JNI local reference when it goes out of scope. 25 | template 26 | class ScopedLocalRef { 27 | public: 28 | ScopedLocalRef(JNIEnv* env, T localRef) : mEnv(env), mLocalRef(localRef) {} 29 | 30 | ~ScopedLocalRef() { 31 | reset(); 32 | } 33 | 34 | void reset(T ptr = nullptr) { 35 | if (ptr != mLocalRef) { 36 | if (mLocalRef != nullptr) { 37 | mEnv->DeleteLocalRef(mLocalRef); 38 | } 39 | mLocalRef = ptr; 40 | } 41 | } 42 | 43 | T get() const { 44 | return mLocalRef; 45 | } 46 | 47 | private: 48 | JNIEnv* mEnv; 49 | T mLocalRef; 50 | 51 | DISALLOW_COPY_AND_ASSIGN(ScopedLocalRef); 52 | }; 53 | 54 | #endif // SCOPED_LOCAL_REF_H__ -------------------------------------------------------------------------------- /core/src/main/jni/rotate_argb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "rotate.h" 3 | 4 | using namespace libyuv; 5 | using namespace libyuv::jniutil; 6 | 7 | extern "C" { 8 | 9 | // Rotate ARGB frame 10 | PLANES_1_TO_1_R(ARGBRotate, argb, argb); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /core/src/main/jni/scale.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "scale.h" 3 | 4 | using namespace libyuv; 5 | using namespace libyuv::jniutil; 6 | 7 | extern "C" { 8 | 9 | // Scale a YUV plane. 10 | PLANES_1_TO_1_V(ScalePlane, p, p) 11 | 12 | // ScalePlane_16 13 | 14 | // Sample is expected to be in the low 12 bits. 15 | // ScalePlane_12 16 | 17 | // Scales a YUV 4:2:0 image from the src width and height to the 18 | // dst width and height. 19 | PLANES_3_TO_3(I420Scale, y, u, v, y, u, v) 20 | 21 | // I420Scale_16 22 | 23 | // I420Scale_12 24 | 25 | // Scales a YUV 4:4:4 image from the src width and height to the 26 | // dst width and height. 27 | PLANES_3_TO_3(I444Scale, y, u, v, y, u, v) 28 | 29 | // I444Scale_16 30 | 31 | // I444Scale_12 32 | 33 | // Scales a YUV 4:2:2 image from the src width and height to the 34 | // dst width and height. 35 | PLANES_3_TO_3(I422Scale, y, u, v, y, u, v) 36 | 37 | // I422Scale_16 38 | 39 | // I422Scale_12 40 | 41 | // Scales an NV12 image from the src width and height to the 42 | // dst width and height. 43 | PLANES_2_TO_2(NV12Scale, y, uv, y, uv) 44 | 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/jni/scale_argb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "scale.h" 3 | 4 | using namespace libyuv; 5 | using namespace libyuv::jniutil; 6 | 7 | extern "C" { 8 | 9 | PLANES_1_TO_1(ARGBScale, argb, argb) 10 | 11 | // Clipped scale takes destination rectangle coordinates for clip values. 12 | PLANES_1_TO_1_CLIP(ARGBScaleClip, argb, argb) 13 | 14 | // Scale with YUV conversion to ARGB and clipping. 15 | // YUVToARGBScaleClip 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/jni/scale_uv.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "scale.h" 3 | 4 | using namespace libyuv; 5 | using namespace libyuv::jniutil; 6 | 7 | extern "C" { 8 | 9 | PLANES_1_TO_1(UVScale, uv, uv) 10 | 11 | // Scale a 16 bit UV image. 12 | // UVScale_16 13 | 14 | } 15 | -------------------------------------------------------------------------------- /debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crow-misia/libyuv-android/4c82dfad703adcb1329b3079ae59a3abd1fd4794/debug.keystore -------------------------------------------------------------------------------- /findbugs-android-exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Build options 2 | android.enableBuildScriptClasspathCheck=false 3 | android.nonTransitiveRClass=true 4 | android.useAndroidX=true 5 | android.enableR8.fullMode=true 6 | kotlin.code.style=official 7 | kotlin.incremental.usePreciseJavaTracking=true 8 | org.gradle.jvmargs=-Xmx1536m -Dfile.encoding=UTF-8 9 | org.gradle.parallel=true 10 | org.gradle.caching=true 11 | org.gradle.configuration-cache=true 12 | org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled 13 | org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true 14 | -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | ## Generated by $ ./gradlew refreshVersions 2 | 3 | [versions] 4 | 5 | android-gradle-plugin = "8.10.1" 6 | 7 | android-tools-desugar_jdk_libs = "2.1.5" 8 | 9 | androidx-camera = "1.5.0-beta01" 10 | 11 | androidx-activity = "1.10.1" 12 | 13 | androidx-appcompat = "1.7.0" 14 | 15 | androidx-test-ext-junit = "1.2.1" 16 | 17 | androidx-test-ext-truth = "1.6.0" 18 | 19 | androidx-test-espresso = "3.6.1" 20 | 21 | androidx-test-runner = "1.6.2" 22 | 23 | androidx-test-rules = "1.6.1" 24 | 25 | detekt = "1.23.8" 26 | 27 | dokka = "2.0.0" 28 | 29 | kotlin = "2.1.21" 30 | 31 | maven-publish = "0.32.0" 32 | 33 | truth = "1.4.4" 34 | 35 | [libraries] 36 | 37 | androidx-annotation = { group = "androidx.annotation", name = "annotation", version = "1.9.1" } 38 | 39 | androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "androidx-activity" } 40 | 41 | androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" } 42 | 43 | androidx-camera-core = { group = "androidx.camera", name = "camera-core", version.ref = "androidx-camera" } 44 | 45 | androidx-test-ext-junit-ktx = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "androidx-test-ext-junit" } 46 | 47 | androidx-test-ext-truth = { group = "androidx.test.ext", name = "truth", version.ref = "androidx-test-ext-truth" } 48 | 49 | androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidx-test-espresso" } 50 | 51 | androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidx-test-runner" } 52 | 53 | androidx-test-rules = { group = "androidx.test", name = "rules", version.ref = "androidx-test-rules" } 54 | 55 | desugar-jdk-libs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "android-tools-desugar_jdk_libs" } 56 | 57 | kotlin-bom = { group = "org.jetbrains.kotlin", name = "kotlin-bom", version.ref = "kotlin" } 58 | 59 | kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib" } 60 | 61 | truth = { group = "com.google.truth", name = "truth", version.ref = "truth" } 62 | 63 | [plugins] 64 | 65 | android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" } 66 | 67 | android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" } 68 | 69 | detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } 70 | 71 | dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } 72 | 73 | dokka-javadoc = { id = "org.jetbrains.dokka-javadoc", version.ref = "dokka" } 74 | 75 | kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } 76 | 77 | maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" } 78 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crow-misia/libyuv-android/4c82dfad703adcb1329b3079ae59a3abd1fd4794/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionSha256Sum=845952a9d6afa783db70bb3b0effaae45ae5542ca2bb7929619e8af49cb634cf 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip 5 | networkTimeout=10000 6 | validateDistributionUrl=true 7 | zipStoreBase=GRADLE_USER_HOME 8 | zipStorePath=wrapper/dists 9 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH= 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /lefthook.yaml: -------------------------------------------------------------------------------- 1 | # yaml-language-server: $schema=https://json.schemastore.org/lefthook.json 2 | # vim: set ts=2 sw=2 tw=0 fo=cnqoj 3 | 4 | assert_lefthook_installed: true 5 | skip_lfs: true 6 | 7 | commit-msg: 8 | parallel: true 9 | commands: 10 | lint: 11 | run: pnpm exec commitlint --edit {1} 12 | 13 | -------------------------------------------------------------------------------- /lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "preinstall": "pnpm dlx only-allow pnpm", 5 | "ncu": "npm-check-updates -u" 6 | }, 7 | "dependencies": { 8 | "@commitlint/cli": "19.8.1", 9 | "@commitlint/config-conventional": "19.8.1", 10 | "lefthook": "1.11.13", 11 | "npm-check-updates": "18.0.1" 12 | }, 13 | "packageManager": "pnpm@10.11.0", 14 | "engines": { 15 | "node": ">=20.x", 16 | "npm": "use pnpm", 17 | "pnpm": ">=9", 18 | "yarn": "use pnpm" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | onlyBuiltDependencies: 2 | - lefthook 3 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget 2 | 3 | plugins { 4 | alias(libs.plugins.android.application) 5 | alias(libs.plugins.kotlin.android) 6 | } 7 | 8 | android { 9 | compileSdk = 35 10 | defaultConfig { 11 | namespace = "app" 12 | applicationId = "com.github.crow_misia.libyuv" 13 | minSdk = 21 14 | targetSdk = 35 15 | versionCode = 1 16 | versionName = "1.0.0" 17 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" 18 | } 19 | 20 | lint { 21 | textReport = true 22 | checkDependencies = true 23 | baseline = file("lint-baseline.xml") 24 | } 25 | 26 | buildFeatures { 27 | viewBinding = true 28 | } 29 | 30 | buildTypes { 31 | release { 32 | isMinifyEnabled = true 33 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") 34 | signingConfig = signingConfigs.named("debug").get() 35 | } 36 | } 37 | 38 | compileOptions { 39 | isCoreLibraryDesugaringEnabled = true 40 | sourceCompatibility = JavaVersion.VERSION_17 41 | targetCompatibility = JavaVersion.VERSION_17 42 | } 43 | } 44 | 45 | kotlin { 46 | compilerOptions { 47 | jvmTarget = JvmTarget.JVM_17 48 | } 49 | } 50 | 51 | dependencies { 52 | coreLibraryDesugaring(libs.desugar.jdk.libs) 53 | 54 | implementation(project(":core")) 55 | 56 | implementation(libs.androidx.activity) 57 | implementation(libs.androidx.appcompat) 58 | } 59 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Application 4 | 5 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |