├── .gitignore ├── ImageUtils.iml ├── LICENSE ├── README.md ├── YuvUtils ├── .gitignore ├── build.gradle ├── libs │ ├── arm64-v8a │ │ └── libyuv_static.a │ ├── armeabi-v7a │ │ └── libyuv_static.a │ ├── armeabi │ │ └── libyuv_static.a │ ├── x86 │ │ └── libyuv_static.a │ └── x86_64 │ │ └── libyuv_static.a ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── yancy │ │ └── yuvutils │ │ ├── ImageUtils.kt │ │ ├── YuvUtils.kt │ │ ├── annotation │ │ ├── RotateDegree.java │ │ ├── SupportFilter.java │ │ └── SupportFormat.java │ │ └── entry │ │ ├── ClipRect.kt │ │ └── ImageInfo.kt │ ├── jni │ ├── CMakeLists.txt │ ├── YuvUtils.cpp │ ├── YuvUtils.h │ ├── core │ │ └── ColorConvert.cpp │ ├── head │ │ ├── ColorConvert.hpp │ │ └── cppToJavaHelper.hpp │ ├── include │ │ ├── libyuv.h │ │ └── libyuv │ │ │ ├── basic_types.h │ │ │ ├── compare.h │ │ │ ├── convert.h │ │ │ ├── convert_argb.h │ │ │ ├── convert_from.h │ │ │ ├── convert_from_argb.h │ │ │ ├── cpu_id.h │ │ │ ├── mjpeg_decoder.h │ │ │ ├── planar_functions.h │ │ │ ├── rotate.h │ │ │ ├── rotate_argb.h │ │ │ ├── row.h │ │ │ ├── scale.h │ │ │ ├── scale_argb.h │ │ │ ├── scale_row.h │ │ │ ├── version.h │ │ │ └── video_common.h │ └── logger.hpp │ └── res │ └── values │ └── strings.xml ├── app ├── .gitignore ├── ImageUtils-app.iml ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── yancy │ │ └── imageutils │ │ ├── LogUtils.kt │ │ ├── MainActivity.kt │ │ ├── PermissionUtil.kt │ │ └── test │ │ ├── Test.java │ │ └── Test01.kt │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── layout │ └── activity_main.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ ├── ic_launcher_round.png │ └── test.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── doc ├── Android中常用图像格式说明.md └── ImageUtils库接口说明文档.md ├── gradle.properties ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libyuv ├── jni │ ├── .gitignore │ ├── AUTHORS │ ├── Android.mk │ ├── Application.mk │ ├── BUILD.gn │ ├── CMakeLists.txt │ ├── DEPS │ ├── LICENSE │ ├── LICENSE_THIRD_PARTY │ ├── OWNERS │ ├── PATENTS │ ├── PRESUBMIT.py │ ├── README.chromium │ ├── all.gyp │ ├── chromium │ │ ├── .gclient │ │ └── README │ ├── codereview.settings │ ├── docs │ │ ├── deprecated_builds.md │ │ ├── environment_variables.md │ │ ├── filtering.md │ │ ├── formats.md │ │ ├── getting_started.md │ │ └── rotation.md │ ├── download_vs_toolchain.py │ ├── drover.properties │ ├── gyp_libyuv │ ├── gyp_libyuv.py │ ├── include │ │ ├── libyuv.h │ │ └── libyuv │ │ │ ├── basic_types.h │ │ │ ├── compare.h │ │ │ ├── convert.h │ │ │ ├── convert_argb.h │ │ │ ├── convert_from.h │ │ │ ├── convert_from_argb.h │ │ │ ├── cpu_id.h │ │ │ ├── mjpeg_decoder.h │ │ │ ├── planar_functions.h │ │ │ ├── rotate.h │ │ │ ├── rotate_argb.h │ │ │ ├── row.h │ │ │ ├── scale.h │ │ │ ├── scale_argb.h │ │ │ ├── scale_row.h │ │ │ ├── version.h │ │ │ └── video_common.h │ ├── libyuv.gyp │ ├── libyuv.gypi │ ├── libyuv_nacl.gyp │ ├── libyuv_test.gyp │ ├── linux.mk │ ├── public.mk │ ├── setup_links.py │ ├── source │ │ ├── compare.cc │ │ ├── compare_common.cc │ │ ├── compare_gcc.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_argb.cc │ │ ├── rotate_mips.cc │ │ ├── rotate_neon.cc │ │ ├── rotate_neon64.cc │ │ ├── row_any.cc │ │ ├── row_common.cc │ │ ├── row_gcc.cc │ │ ├── row_mips.cc │ │ ├── row_neon.cc │ │ ├── row_neon64.cc │ │ ├── row_win.cc │ │ ├── scale.cc │ │ ├── scale_any.cc │ │ ├── scale_argb.cc │ │ ├── scale_common.cc │ │ ├── scale_gcc.cc │ │ ├── scale_mips.cc │ │ ├── scale_neon.cc │ │ ├── scale_neon64.cc │ │ ├── scale_win.cc │ │ └── video_common.cc │ ├── sync_chromium.py │ ├── tools │ │ └── valgrind-libyuv │ │ │ ├── libyuv_tests.bat │ │ │ ├── libyuv_tests.py │ │ │ ├── libyuv_tests.sh │ │ │ ├── memcheck │ │ │ ├── OWNERS │ │ │ ├── PRESUBMIT.py │ │ │ ├── suppressions.txt │ │ │ ├── suppressions_mac.txt │ │ │ └── suppressions_win32.txt │ │ │ └── tsan │ │ │ ├── OWNERS │ │ │ ├── PRESUBMIT.py │ │ │ ├── suppressions.txt │ │ │ ├── suppressions_mac.txt │ │ │ └── suppressions_win32.txt │ ├── unit_test │ │ ├── basictypes_test.cc │ │ ├── color_test.cc │ │ ├── compare_test.cc │ │ ├── convert_test.cc │ │ ├── cpu_test.cc │ │ ├── math_test.cc │ │ ├── planar_test.cc │ │ ├── rotate_argb_test.cc │ │ ├── rotate_test.cc │ │ ├── scale_argb_test.cc │ │ ├── scale_color_test.cc │ │ ├── scale_test.cc │ │ ├── testdata │ │ │ ├── arm_v7.txt │ │ │ ├── juno.txt │ │ │ └── tegra3.txt │ │ ├── unit_test.cc │ │ ├── unit_test.h │ │ ├── version_test.cc │ │ └── video_common_test.cc │ ├── util │ │ ├── compare.cc │ │ ├── convert.cc │ │ ├── cpuid.c │ │ ├── psnr.cc │ │ ├── psnr.h │ │ ├── psnr_main.cc │ │ ├── ssim.cc │ │ └── ssim.h │ └── winarm.mk ├── obj │ └── local │ │ ├── arm64-v8a │ │ └── libyuv_static.a │ │ ├── armeabi-v7a │ │ └── libyuv_static.a │ │ ├── armeabi │ │ └── libyuv_static.a │ │ ├── x86 │ │ └── libyuv_static.a │ │ └── x86_64 │ │ └── libyuv_static.a └── readme.md ├── local.properties └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | /.idea/ 22 | /.gradle/ 23 | /ImageUtils.iml 24 | 25 | -------------------------------------------------------------------------------- /ImageUtils.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ImageUtils 2 | 3 | ## 写在前面 4 | 该图像处理库底层依赖的是 Google 开源的 `libyuv` 框架,因该框架功能之强大,支持图像格式之繁多,目前这里只针对 Android 中常用的图像格式之间互相操作进行了相关封装操作,方便 `Java` / `Kotlin` 进行无缝调用。 5 | 6 | ## 功能说明 7 | - [x] 支持 `RGB_565`、`ARGB_8888`、`RGB24`、`I420`、`NV21` 5中格式图像之间互相转换操作 8 | - [x] 支持将 `Bitmap` 转换成以上五种图像格式操作 9 | - [x] 支持将以上格式的图像转换成 `Bitmap` 操作 10 | - [x] 支持以上格式图像之间互相旋转、裁剪操作 11 | - [x] 支持以上格式图像之间缩放操作 12 | - [x] 支持以上格式图像之间镜像操作 13 | - [x] 底层依赖 `libyuv` 框架,安全、稳定、高效 14 | 15 | 关于具体接口说明,请 [点击此处](https://github.com/Reign9201/ImageUtils/blob/master/doc/ImageUtils%E5%BA%93%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3.md) 16 | 17 | 关于图像格式说明,请 [点击此处](https://github.com/Reign9201/ImageUtils/blob/master/doc/Android%E4%B8%AD%E5%B8%B8%E7%94%A8%E5%9B%BE%E5%83%8F%E6%A0%BC%E5%BC%8F%E8%AF%B4%E6%98%8E.md) 18 | 19 | --- 20 | 21 | ## 使用说明 22 | ### Gradle 依赖 23 | - **Step 1**. Add the JitPack repository to your build file 24 | 25 | Add it in your root build.gradle at the end of repositories: 26 | ``` 27 | allprojects { 28 | repositories { 29 | ... 30 | maven { url 'https://jitpack.io' } 31 | } 32 | } 33 | ``` 34 | - **Step 2**. Add the dependency 35 | ``` 36 | dependencies { 37 | implementation 'com.github.Reign9201:ImageUtils:v0.1-alpha' 38 | } 39 | ``` 40 | 41 | ### 简单使用 42 | 43 | 例如,我们将相机采集的预览流转换成Android手机能显示的 Bitmap: 44 | ```Kotlin 45 | // 一般相机预览流为 NV21格式,而且是旋转了270的 46 | val bitmap:Bitmap? = ImageUtils.nv21ToBitmap8888(data, width, height, 270) 47 | ``` 48 | 49 | 50 | 例如,我们从手机相机中采集了一段人脸预览流,经过人脸识别采集到了人脸框,此时我们需要根据识别后的人脸框将人脸从整个预览流中抠下来,我们可以这么操作: 51 | 52 | ```Kotlin 53 | fun onPreviewFrame(data: ByteArray, width: Int, height: Int, faceRect: Rect) { 54 | // 返回值为人脸识别后抠出的脸图 55 | val faceBitmap: Bitmap? = YuvUtils.dataClipRotateToBitmap( 56 | data, // 采集的原始预览流 57 | 1, // Android 相机一般采集的是 NV21 格式的,因此是 1 58 | width, // 原始图像宽 59 | height, // 原始图像高 60 | 270, // Android设备一般是 270 ,当然可以自己改,此处只是演示 61 | faceRect, // 人脸识别后的人脸框数据 62 | 5, // 生成Bitmap格式,5表示 ARGB_8888 63 | false // 不进行优先裁剪 64 | ) 65 | } 66 | ``` 67 | 68 | 更多其他操作,请参见 [文档说明](https://github.com/Reign9201/ImageUtils/blob/master/doc/ImageUtils%E5%BA%93%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3.md)。 69 | 70 | --- 71 | 72 | ## License 73 | ``` 74 | Copyright 2020 Yanjun Xu 75 | 76 | Licensed under the Apache License, Version 2.0 (the "License"); 77 | you may not use this file except in compliance with the License. 78 | You may obtain a copy of the License at 79 | 80 | http://www.apache.org/licenses/LICENSE-2.0 81 | 82 | Unless required by applicable law or agreed to in writing, software 83 | distributed under the License is distributed on an "AS IS" BASIS, 84 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 85 | See the License for the specific language governing permissions and 86 | limitations under the License. 87 | ``` -------------------------------------------------------------------------------- /YuvUtils/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.cxx 3 | consumer-rules.pro 4 | YuvUtils.iml 5 | /.externalNativeBuild 6 | -------------------------------------------------------------------------------- /YuvUtils/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | //apply plugin: 'com.github.dcendents.android-maven' 5 | android { 6 | compileSdkVersion 28 7 | buildToolsVersion = '28.0.3' 8 | 9 | defaultConfig { 10 | minSdkVersion 19 11 | targetSdkVersion 28 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | //consumerProguardFiles 'consumer-rules.pro' 16 | 17 | externalNativeBuild { 18 | cmake { 19 | cppFlags '-std=c++11', //支持c++11标准 20 | '-frtti', //支持运行时类型检查 21 | '-fexceptions', //支持异常处理 22 | '-Wno-switch-enum -Wno-switch', // 23 | '-fopenmp', //支持并行计算 24 | '-Os -Oz', //开启编译优化-Os 优化GCC -Oz优化Clang 25 | '-fvisibility=hidden', //隐藏elf符号表,可以减少 so 文件大小 26 | '-fvisibility-inlines-hidden', //隐藏所有内联函数,从而减小导出符号表的大小,既能缩减文件的大小,还能提高运行性能 27 | '-ffunction-sections -fdata-sections' //删除无用函数,减小so文件大小 28 | 29 | arguments '-DANDROID_PLATFORM=android-23', 30 | '-DANDROID_TOOLCHAIN=clang', 31 | '-DANDROID_STL=gnustl_static' 32 | 33 | //abiFilters /*'x86', 'armeabi', */ 'armeabi-v7a'/*,'arm64-v8a'*/ 34 | abiFilters 'armeabi-v7a' 35 | } 36 | } 37 | } 38 | 39 | buildTypes { 40 | release { 41 | minifyEnabled false 42 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 43 | } 44 | } 45 | 46 | 47 | 48 | externalNativeBuild { 49 | cmake { 50 | path "src/main/jni/CMakeLists.txt" 51 | } 52 | } 53 | 54 | sourceSets { 55 | main { 56 | jniLibs.srcDir 'src/main/libs' 57 | jni.srcDirs = [] 58 | } 59 | } 60 | 61 | } 62 | 63 | dependencies { 64 | implementation fileTree(dir: 'libs', include: ['*.jar']) 65 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 66 | implementation 'com.android.support:appcompat-v7:28.0.0' 67 | } 68 | repositories { 69 | mavenCentral() 70 | } 71 | -------------------------------------------------------------------------------- /YuvUtils/libs/arm64-v8a/libyuv_static.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/YuvUtils/libs/arm64-v8a/libyuv_static.a -------------------------------------------------------------------------------- /YuvUtils/libs/armeabi-v7a/libyuv_static.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/YuvUtils/libs/armeabi-v7a/libyuv_static.a -------------------------------------------------------------------------------- /YuvUtils/libs/armeabi/libyuv_static.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/YuvUtils/libs/armeabi/libyuv_static.a -------------------------------------------------------------------------------- /YuvUtils/libs/x86/libyuv_static.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/YuvUtils/libs/x86/libyuv_static.a -------------------------------------------------------------------------------- /YuvUtils/libs/x86_64/libyuv_static.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/YuvUtils/libs/x86_64/libyuv_static.a -------------------------------------------------------------------------------- /YuvUtils/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /YuvUtils/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /YuvUtils/src/main/java/com/yancy/yuvutils/annotation/RotateDegree.java: -------------------------------------------------------------------------------- 1 | package com.yancy.yuvutils.annotation; 2 | 3 | import androidx.annotation.IntDef; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | 7 | /** 8 | * 说明:角度限制 9 | * 10 | * @author Yancy 11 | * @date 2019/12/4 12 | */ 13 | @IntDef({-90, 0, 90, 180, 270}) 14 | @Retention(RetentionPolicy.SOURCE) 15 | public @interface RotateDegree { 16 | } 17 | -------------------------------------------------------------------------------- /YuvUtils/src/main/java/com/yancy/yuvutils/annotation/SupportFilter.java: -------------------------------------------------------------------------------- 1 | package com.yancy.yuvutils.annotation; 2 | 3 | import androidx.annotation.IntDef; 4 | 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | /** 9 | * 说明: 10 | * 11 | * @author Yancy 12 | * @date 2019/12/4 13 | */ 14 | @IntDef({0, 1, 2, 3}) 15 | @Retention(RetentionPolicy.SOURCE) 16 | public @interface SupportFilter { 17 | } 18 | -------------------------------------------------------------------------------- /YuvUtils/src/main/java/com/yancy/yuvutils/annotation/SupportFormat.java: -------------------------------------------------------------------------------- 1 | package com.yancy.yuvutils.annotation; 2 | 3 | import androidx.annotation.IntDef; 4 | 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | 8 | /** 9 | * 说明: 10 | * 11 | * @author Yancy 12 | * @date 2019/12/4 13 | */ 14 | @IntDef({1, 2, 3, 4, 5}) 15 | @Retention(RetentionPolicy.SOURCE) 16 | public @interface SupportFormat { 17 | } 18 | -------------------------------------------------------------------------------- /YuvUtils/src/main/java/com/yancy/yuvutils/entry/ClipRect.kt: -------------------------------------------------------------------------------- 1 | package com.yancy.yuvutils.entry 2 | 3 | import android.graphics.Rect 4 | 5 | /** 6 | * 说明: 7 | * @author Yancy 8 | * @date 2020/1/15 9 | */ 10 | data class ClipRect(val left: Int, val top: Int, val width: Int, val height: Int) { 11 | 12 | fun convert(): Rect { 13 | return Rect(left, top, left + width, top + height) 14 | } 15 | } -------------------------------------------------------------------------------- /YuvUtils/src/main/java/com/yancy/yuvutils/entry/ImageInfo.kt: -------------------------------------------------------------------------------- 1 | package com.yancy.yuvutils.entry 2 | 3 | 4 | import android.graphics.Bitmap 5 | import android.graphics.Rect 6 | import com.yancy.yuvutils.annotation.RotateDegree 7 | 8 | /** 9 | * 说明:图像数据data 10 | * @author Yancy 11 | * @date 2019/11/29 12 | */ 13 | class ImageInfo( 14 | val data: ByteArray, 15 | val dataFormat: ImageFormat, 16 | val width: Int, 17 | val height: Int, 18 | @RotateDegree val degree: Int = 0, 19 | val rect: Rect? = null, 20 | val bitmapConfig: Bitmap.Config = Bitmap.Config.ARGB_8888, 21 | val priorityClip: Boolean = true 22 | ) 23 | 24 | @Suppress("UNUSED") 25 | enum class ImageFormat(var format: Int) { 26 | NV21(1), 27 | I420(2), 28 | RGB_565(3), 29 | BGR_888(4), 30 | ARGB_8888(5) 31 | } 32 | 33 | /** 34 | * libyuv做图像缩放时候的过滤模式 35 | */ 36 | @Suppress("UNUSED") 37 | enum class FilterMode(var filter: Int) { 38 | /** 39 | * Point sample; Fastest. 40 | */ 41 | FilterNone(0), 42 | 43 | /** 44 | * Filter horizontally only. 45 | */ 46 | FilterLinear(1), 47 | 48 | /** 49 | * Faster than box, but lower quality scaling down. 50 | */ 51 | FilterBilinear(2), 52 | 53 | /** 54 | * Highest quality. 55 | */ 56 | FilterBox(3) 57 | } -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | set(APP_PLATFORM android-16) 4 | 5 | set(LIBS_DIRECTORY ${CMAKE_SOURCE_DIR}/../../../libs) 6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 7 | set(APP_ABI armeabi-v7a) 8 | 9 | include_directories( 10 | ${ANDROID_NDK}/platforms/android-16/arch-arm/usr/include 11 | ${ANDROID_NDK}/platforms/android-16/arch-arm/usr/include/android 12 | include 13 | ) 14 | 15 | add_library(libyuv_static SHARED IMPORTED) 16 | set_target_properties(libyuv_static PROPERTIES IMPORTED_LOCATION ${LIBS_DIRECTORY}/${ANDROID_ABI}/libyuv_static.a) 17 | 18 | 19 | add_library( 20 | YuvUtils 21 | SHARED 22 | YuvUtils.cpp 23 | core/ColorConvert.cpp 24 | ) 25 | 26 | 27 | find_library(log-lib log) 28 | find_library(jnigraphics-lib jnigraphics) 29 | 30 | target_link_libraries( 31 | YuvUtils 32 | libyuv_static 33 | ${log-lib} 34 | ${jnigraphics-lib} 35 | ) -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/YuvUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by XuYanjun on 2019/11/12. 3 | // 4 | 5 | #ifndef IMAGEUTILS_YUVUTILS_H 6 | #define IMAGEUTILS_YUVUTILS_H 7 | 8 | #include "head/ColorConvert.hpp" 9 | #include 10 | #include 11 | #include "logger.hpp" 12 | 13 | //using namespace libyuv; 14 | typedef struct ConvertData { 15 | int dataSize; 16 | libyuv::RotationMode rotateMode; 17 | uint32 format; 18 | int targetWidth; 19 | int targetHeight; 20 | int crop_x = 0; 21 | int crop_y = 0; 22 | } ConvertData; 23 | 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | 30 | 31 | /////////////////////////////////////////////////////////////////////////////////////////////// 32 | 33 | JNIEXPORT jbyteArray bitmapToNV21(JNIEnv *env, jclass clazz, jobject jbitmap); 34 | 35 | JNIEXPORT jbyteArray bitmapToRgb565(JNIEnv *env, jclass clazz, jobject jbitmap); 36 | 37 | JNIEXPORT jbyteArray bitmapToRgb24(JNIEnv *env, jclass clazz, jobject jbitmap); 38 | 39 | JNIEXPORT jbyteArray bitmapToRgba(JNIEnv *env, jclass clazz, jobject jbitmap); 40 | 41 | JNIEXPORT jbyteArray bitmapToI420(JNIEnv *env, jclass clazz, jobject jbitmap); 42 | 43 | 44 | 45 | /////////////////////////////////////////////////////////////////////////////////////////////// 46 | 47 | JNIEXPORT jbyteArray intArrayToByteArray(JNIEnv *env, jclass clazz, jintArray intArray); 48 | JNIEXPORT jintArray byteArrayToIntArray(JNIEnv *env, jclass clazz, jbyteArray byteArray); 49 | 50 | 51 | /////////////////////////////////////////////////////////////////////////////////////////////// 52 | JNIEXPORT jbyteArray imageFormatConvert(JNIEnv *env, jclass clazz, 53 | jbyteArray src_data, jint width, jint height, 54 | jint dataFormat, jint targetFormat); 55 | 56 | JNIEXPORT jobject imageToBitmap(JNIEnv *env, jclass clazz, 57 | jbyteArray src_data, jint width, jint height, 58 | jint dataFormat, jint bitmapConfig); 59 | 60 | JNIEXPORT jobject dataClipRotateToBitmap(JNIEnv *env, jclass clazz, 61 | jbyteArray byteArray, jint dataFormat, 62 | jint width, jint height, jint degree, 63 | jobject rect, jint bitmapConfig, 64 | jboolean priorityClip); 65 | 66 | JNIEXPORT jbyteArray dataClipRotate(JNIEnv *env, jclass clazz, 67 | jbyteArray byteArray, jint dataFormat, 68 | jint width, jint height, jint degree, 69 | jobject rect, jint targetFormat, 70 | jboolean priorityClip); 71 | 72 | /////////////////////////////////////////////////////////////////////////////////////////////// 73 | 74 | JNIEXPORT jbyteArray dataMirror(JNIEnv *env, jclass clazz, 75 | jbyteArray byteArray, jint width, jint height, 76 | jint dataFormat, jint targetFormat, 77 | jboolean isVerticalMirror); 78 | 79 | JNIEXPORT jbyteArray dataScale(JNIEnv *env, jclass clazz, 80 | jbyteArray byteArray, jint width, jint height, 81 | jint dstWidth, jint dstHeight, 82 | jint dataFormat, jint targetFormat, 83 | jint filterMode); 84 | /////////////////////////////////////////////////////////////////////////////////////////////// 85 | 86 | jbyte *checkDataAndConvert(JNIEnv *env, jbyteArray yuv420Data, int dataSize); 87 | 88 | int convertDataHandle(JNIEnv *env, jint dataFormat, 89 | jint width, jint height, 90 | jint degree, jobject rect, jboolean priorityClip, 91 | ConvertData *convertData); 92 | 93 | jbyteArray 94 | __ImageConvert__(JNIEnv *env, jbyteArray src_data, jint width, jint height, jint dataFormat, jint targetFormat, __convert__ convert); 95 | 96 | jobject 97 | __ImageToBitmap__(JNIEnv *env, jbyteArray src_data, jint width, jint height, jint dataFormat, jint targetFormat, __convert__ convert); 98 | 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | #endif //IMAGEUTILS_YUVUTILS_H 105 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/head/ColorConvert.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by XuYanjun on 2019/11/20. 3 | // 4 | 5 | #ifndef IMAGEUTILS_COLORCONVERT_HPP 6 | #define IMAGEUTILS_COLORCONVERT_HPP 7 | 8 | #include 9 | #include 10 | 11 | typedef int __convert__(const uint8 *src_data, int width, int height, uint8 *dst_data); 12 | 13 | namespace yancy { 14 | typedef enum ImageFormat { 15 | NONE = 0, 16 | NV21 = 1, 17 | I420 = 2, 18 | RGB565 = 3, 19 | RGB24 = 4, // ie. BGR888 20 | ARGB_8888 = 5 // in libyuv is ABGR format 21 | } ImageFormat; 22 | 23 | ImageFormat getFormat(int formatValue); 24 | 25 | libyuv::FilterMode getFilterMode(int filterMode); 26 | 27 | int getDataSize(int width, int height, int dataFormat); 28 | 29 | int NV21ToRGBA(const uint8 *src_nv21_data, int width, int height, uint8 *dst_rgba); 30 | 31 | int NV21ToRGB565(const uint8 *src_nv21_data, int width, int height, uint8 *dst_rgba); 32 | 33 | int NV21ToI420(const uint8 *src_nv21_data, int width, int height, uint8 *dst_I420); 34 | 35 | int NV21ToRGB24(const uint8 *src_nv21_data, int width, int height, uint8 *dst_rgb24_data); 36 | 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | int I420ToRGBA(const uint8 *src_i420_data, int width, int height, uint8 *dst_rgba_data); 40 | 41 | int I420ToRGB565(const uint8 *src_i420_data, int width, int height, uint8 *dst_rgb_data); 42 | 43 | int I420ToNV21(const uint8 *src_i420_data, int width, int height, uint8 *dst_nv21_data); 44 | 45 | int I420ToRGB24(const uint8 *src_i420_data, int width, int height, uint8 *dst_rgb24_data); 46 | 47 | /////////////////////////////////////////////////////////////////////////////////// 48 | 49 | int RGBAToNV21(const uint8 *src_rgba_data, int width, int height, uint8 *dst_nv21_data); 50 | 51 | int RGBAToI420(const uint8 *src_rgba_data, int width, int height, uint8 *dst_i420_data); 52 | 53 | int RGBAToRGB565(const uint8 *src_rgba_data, int width, int height, uint8 *dst_rgb_data); 54 | 55 | int RGBAToRGB24(const uint8 *src_rgba_data, int width, int height, uint8 *dst_rgb24_data); 56 | 57 | /////////////////////////////////////////////////////////////////////////////////// 58 | 59 | int RGB24ToNV21(const uint8 *src_rgb24_data, int width, int height, uint8 *dst_nv21_data); 60 | 61 | int RGB24ToI420(const uint8 *src_rgb24_data, int width, int height, uint8 *dst_i420_data); 62 | 63 | int RGB24ToRGB565(const uint8 *src_rgb24_data, int width, int height, uint8 *dst_rgb_data); 64 | 65 | int RGB24ToRGBA(const uint8 *src_rgb24_data, int width, int height, uint8 *dst_rgba_data); 66 | 67 | /////////////////////////////////////////////////////////////////////////////////// 68 | 69 | int RGB565ToNV21(const uint8 *src_rgb_data, int width, int height, uint8 *dst_nv21_data); 70 | 71 | int RGB565ToI420(const uint8 *src_rgb_data, int width, int height, uint8 *dst_i420_data); 72 | 73 | int RGB565ToRGBA(const uint8 *src_rgb_data, int width, int height, uint8 *dst_rgba_data); 74 | 75 | int RGB565ToRGB24(const uint8 *src_rgb_data, int width, int height, uint8 *dst_rgb24_data); 76 | 77 | /////////////////////////////////////////////////////////////////////////////////// 78 | 79 | int DataConvert(uint8 *src_data, int src_width, int src_height, int src_data_size, 80 | uint8 *dst_data, int dst_width, int dst_height, 81 | int degree, uint32 src_format, int dst_format, 82 | libyuv::RotationMode rotateMode, int crop_x, int corp_y); 83 | 84 | 85 | int DataMirror(const uint8 *src_data, int width, int height, uint8 **dst_data, int src_fourcc, 86 | int dst_fourcc, 87 | bool vertical_mirror = false); 88 | 89 | int DataScale(const uint8 *src_data, int src_width, int src_height, 90 | uint8 **dst_data, int dst_width, int dst_height, 91 | int src_format, int dst_format, 92 | libyuv::FilterMode filterMode); 93 | 94 | 95 | /////////////////////////////////////////////////////////////////////////////////// 96 | int __I420MirrorToI420__(const uint8 *src_data, uint8 **dst_data, int width, int height, bool vertical_mirror = false); 97 | 98 | int __DataMirror__(const uint8 *src_data, int src_width, int src_height, uint8 **dst_data, bool vertical_mirror, 99 | __convert__ pre_convert, __convert__ next_convert); 100 | 101 | /////////////////////////////////////////////////////////////////////////////////// 102 | 103 | int __I420ScaleToI420__(const uint8 *src_data, int src_width, int src_height, uint8 **dst_data, int dst_width, int dst_height, 104 | 105 | libyuv::FilterMode filterMode); 106 | 107 | int __DataScale__(const uint8 *src_data, int src_width, int src_height, uint8 **dst_data, int dst_width, int dst_height, 108 | libyuv::FilterMode filterMode, __convert__ pre_convert, __convert__ next_convert); 109 | 110 | 111 | } 112 | 113 | 114 | #endif //IMAGEUTILS_COLORCONVERT_HPP 115 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/head/cppToJavaHelper.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by XuYanjun on 2019/11/19. 3 | // 4 | 5 | #ifndef IMAGEUTILS_CPPTOJAVAHELPER_HPP 6 | #define IMAGEUTILS_CPPTOJAVAHELPER_HPP 7 | 8 | #include 9 | #include 10 | 11 | enum BitmapFormat { 12 | ARGB_8888, 13 | RGB_565 14 | }; 15 | 16 | const char *formatToStr(BitmapFormat format) { 17 | switch (format) { 18 | case RGB_565: 19 | return "RGB_565"; 20 | case ARGB_8888: 21 | default: 22 | return "ARGB_8888"; 23 | } 24 | } 25 | 26 | /** 27 | * 生成 Bitmap 28 | * @tparam Func 数据类型转换模版 29 | * @param env jni---env 30 | * @param width 图像宽 31 | * @param height 图像搞 32 | * @param callback 模版函数回调方法 33 | * @param format 图像格式 34 | * @return 返回 Bitmap 对象给 Java 层 35 | */ 36 | template 37 | jobject createBitmap(JNIEnv *env, jbyteArray data, jbyte *src_data, int width, int height, Func callback, 38 | BitmapFormat format = ARGB_8888); 39 | 40 | template 41 | jbyteArray 42 | createColorBytes(JNIEnv *env, jbyteArray data, jbyte *src_data, int dataSize, Func callback); 43 | 44 | template 45 | jbyteArray bitmapToByteArray(JNIEnv *env, jobject jbitmap, Func callback); 46 | 47 | #endif //IMAGEUTILS_CPPTOJAVAHELPER_HPP 48 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/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_ // NOLINT 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/version.h" 30 | #include "libyuv/video_common.h" 31 | 32 | #endif // INCLUDE_LIBYUV_H_ NOLINT 33 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/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_ // NOLINT 12 | #define INCLUDE_LIBYUV_BASIC_TYPES_H_ 13 | 14 | #include // for NULL, size_t 15 | 16 | #if defined(__ANDROID__) || (defined(_MSC_VER) && (_MSC_VER < 1600)) 17 | #include // for uintptr_t on x86 18 | #else 19 | #include // for uintptr_t 20 | #endif 21 | 22 | #ifndef GG_LONGLONG 23 | #ifndef INT_TYPES_DEFINED 24 | #define INT_TYPES_DEFINED 25 | #ifdef COMPILER_MSVC 26 | typedef unsigned __int64 uint64; 27 | typedef __int64 int64; 28 | #ifndef INT64_C 29 | #define INT64_C(x) x ## I64 30 | #endif 31 | #ifndef UINT64_C 32 | #define UINT64_C(x) x ## UI64 33 | #endif 34 | #define INT64_F "I64" 35 | #else // COMPILER_MSVC 36 | #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 37 | typedef unsigned long uint64; // NOLINT 38 | typedef long int64; // NOLINT 39 | #ifndef INT64_C 40 | #define INT64_C(x) x ## L 41 | #endif 42 | #ifndef UINT64_C 43 | #define UINT64_C(x) x ## UL 44 | #endif 45 | #define INT64_F "l" 46 | #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 47 | typedef unsigned long long uint64; // NOLINT 48 | typedef long long int64; // NOLINT 49 | #ifndef INT64_C 50 | #define INT64_C(x) x ## LL 51 | #endif 52 | #ifndef UINT64_C 53 | #define UINT64_C(x) x ## ULL 54 | #endif 55 | #define INT64_F "ll" 56 | #endif // __LP64__ 57 | #endif // COMPILER_MSVC 58 | typedef unsigned int uint32; 59 | typedef int int32; 60 | typedef unsigned short uint16; // NOLINT 61 | typedef short int16; // NOLINT 62 | typedef unsigned char uint8; 63 | typedef signed char int8; 64 | #endif // INT_TYPES_DEFINED 65 | #endif // GG_LONGLONG 66 | 67 | // Detect compiler is for x86 or x64. 68 | #if defined(__x86_64__) || defined(_M_X64) || \ 69 | defined(__i386__) || defined(_M_IX86) 70 | #define CPU_X86 1 71 | #endif 72 | // Detect compiler is for ARM. 73 | #if defined(__arm__) || defined(_M_ARM) 74 | #define CPU_ARM 1 75 | #endif 76 | 77 | #ifndef ALIGNP 78 | #ifdef __cplusplus 79 | #define ALIGNP(p, t) \ 80 | (reinterpret_cast(((reinterpret_cast(p) + \ 81 | ((t) - 1)) & ~((t) - 1)))) 82 | #else 83 | #define ALIGNP(p, t) \ 84 | ((uint8*)((((uintptr_t)(p) + ((t) - 1)) & ~((t) - 1)))) /* NOLINT */ 85 | #endif 86 | #endif 87 | 88 | #if !defined(LIBYUV_API) 89 | #if defined(_WIN32) || defined(__CYGWIN__) 90 | #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) 91 | #define LIBYUV_API __declspec(dllexport) 92 | #elif defined(LIBYUV_USING_SHARED_LIBRARY) 93 | #define LIBYUV_API __declspec(dllimport) 94 | #else 95 | #define LIBYUV_API 96 | #endif // LIBYUV_BUILDING_SHARED_LIBRARY 97 | #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ 98 | (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ 99 | defined(LIBYUV_USING_SHARED_LIBRARY)) 100 | #define LIBYUV_API __attribute__ ((visibility ("default"))) 101 | #else 102 | #define LIBYUV_API 103 | #endif // __GNUC__ 104 | #endif // LIBYUV_API 105 | 106 | #define LIBYUV_BOOL int 107 | #define LIBYUV_FALSE 0 108 | #define LIBYUV_TRUE 1 109 | 110 | // Visual C x86 or GCC little endian. 111 | #if defined(__x86_64__) || defined(_M_X64) || \ 112 | defined(__i386__) || defined(_M_IX86) || \ 113 | defined(__arm__) || defined(_M_ARM) || \ 114 | (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 115 | #define LIBYUV_LITTLE_ENDIAN 116 | #endif 117 | 118 | #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ NOLINT 119 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/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_ // NOLINT 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 HashDjb2(const uint8* src, uint64 count, uint32 seed); 24 | 25 | // Scan an opaque argb image and return fourcc based on alpha offset. 26 | // Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown. 27 | LIBYUV_API 28 | uint32 ARGBDetect(const uint8* argb, int stride_argb, int width, int height); 29 | 30 | // Sum Square Error - used to compute Mean Square Error or PSNR. 31 | LIBYUV_API 32 | uint64 ComputeSumSquareError(const uint8* src_a, 33 | const uint8* src_b, int count); 34 | 35 | LIBYUV_API 36 | uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a, 37 | const uint8* src_b, int stride_b, 38 | int width, int height); 39 | 40 | static const int kMaxPsnr = 128; 41 | 42 | LIBYUV_API 43 | double SumSquareErrorToPsnr(uint64 sse, uint64 count); 44 | 45 | LIBYUV_API 46 | double CalcFramePsnr(const uint8* src_a, int stride_a, 47 | const uint8* src_b, int stride_b, 48 | int width, int height); 49 | 50 | LIBYUV_API 51 | double I420Psnr(const uint8* src_y_a, int stride_y_a, 52 | const uint8* src_u_a, int stride_u_a, 53 | const uint8* src_v_a, int stride_v_a, 54 | const uint8* src_y_b, int stride_y_b, 55 | const uint8* src_u_b, int stride_u_b, 56 | const uint8* src_v_b, int stride_v_b, 57 | int width, int height); 58 | 59 | LIBYUV_API 60 | double CalcFrameSsim(const uint8* src_a, int stride_a, 61 | const uint8* src_b, int stride_b, 62 | int width, int height); 63 | 64 | LIBYUV_API 65 | double I420Ssim(const uint8* src_y_a, int stride_y_a, 66 | const uint8* src_u_a, int stride_u_a, 67 | const uint8* src_v_a, int stride_v_a, 68 | const uint8* src_y_b, int stride_y_b, 69 | const uint8* src_u_b, int stride_u_b, 70 | const uint8* src_v_b, int stride_v_b, 71 | int width, int height); 72 | 73 | #ifdef __cplusplus 74 | } // extern "C" 75 | } // namespace libyuv 76 | #endif 77 | 78 | #endif // INCLUDE_LIBYUV_COMPARE_H_ NOLINT 79 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/include/libyuv/cpu_id.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_CPU_ID_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_CPU_ID_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // TODO(fbarchard): Consider overlapping bits for different architectures. 22 | // Internal flag to indicate cpuid requires initialization. 23 | #define kCpuInit 0x1 24 | 25 | // These flags are only valid on ARM processors. 26 | static const int kCpuHasARM = 0x2; 27 | static const int kCpuHasNEON = 0x4; 28 | // 0x8 reserved for future ARM flag. 29 | 30 | // These flags are only valid on x86 processors. 31 | static const int kCpuHasX86 = 0x10; 32 | static const int kCpuHasSSE2 = 0x20; 33 | static const int kCpuHasSSSE3 = 0x40; 34 | static const int kCpuHasSSE41 = 0x80; 35 | static const int kCpuHasSSE42 = 0x100; 36 | static const int kCpuHasAVX = 0x200; 37 | static const int kCpuHasAVX2 = 0x400; 38 | static const int kCpuHasERMS = 0x800; 39 | static const int kCpuHasFMA3 = 0x1000; 40 | // 0x2000, 0x4000, 0x8000 reserved for future X86 flags. 41 | 42 | // These flags are only valid on MIPS processors. 43 | static const int kCpuHasMIPS = 0x10000; 44 | static const int kCpuHasMIPS_DSP = 0x20000; 45 | static const int kCpuHasMIPS_DSPR2 = 0x40000; 46 | 47 | // Internal function used to auto-init. 48 | LIBYUV_API 49 | int InitCpuFlags(void); 50 | 51 | // Internal function for parsing /proc/cpuinfo. 52 | LIBYUV_API 53 | int ArmCpuCaps(const char* cpuinfo_name); 54 | 55 | // Detect CPU has SSE2 etc. 56 | // Test_flag parameter should be one of kCpuHas constants above. 57 | // returns non-zero if instruction set is detected 58 | static __inline int TestCpuFlag(int test_flag) { 59 | LIBYUV_API extern int cpu_info_; 60 | return (cpu_info_ == kCpuInit ? InitCpuFlags() : cpu_info_) & test_flag; 61 | } 62 | 63 | // For testing, allow CPU flags to be disabled. 64 | // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. 65 | // MaskCpuFlags(-1) to enable all cpu specific optimizations. 66 | // MaskCpuFlags(0) to disable all cpu specific optimizations. 67 | LIBYUV_API 68 | void MaskCpuFlags(int enable_flags); 69 | 70 | // Low level cpuid for X86. Returns zeros on other CPUs. 71 | // eax is the info type that you want. 72 | // ecx is typically the cpu number, and should normally be zero. 73 | LIBYUV_API 74 | void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info); 75 | 76 | #ifdef __cplusplus 77 | } // extern "C" 78 | } // namespace libyuv 79 | #endif 80 | 81 | #endif // INCLUDE_LIBYUV_CPU_ID_H_ NOLINT 82 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/include/libyuv/rotate.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_ROTATE_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_ROTATE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Supported rotation. 22 | typedef enum RotationMode { 23 | kRotate0 = 0, // No rotation. 24 | kRotate90 = 90, // Rotate 90 degrees clockwise. 25 | kRotate180 = 180, // Rotate 180 degrees. 26 | kRotate270 = 270, // Rotate 270 degrees clockwise. 27 | 28 | // Deprecated. 29 | kRotateNone = 0, 30 | kRotateClockwise = 90, 31 | kRotateCounterClockwise = 270, 32 | } RotationModeEnum; 33 | 34 | // Rotate I420 frame. 35 | LIBYUV_API 36 | int I420Rotate(const uint8* src_y, int src_stride_y, 37 | const uint8* src_u, int src_stride_u, 38 | const uint8* src_v, int src_stride_v, 39 | uint8* dst_y, int dst_stride_y, 40 | uint8* dst_u, int dst_stride_u, 41 | uint8* dst_v, int dst_stride_v, 42 | int src_width, int src_height, enum RotationMode mode); 43 | 44 | // Rotate NV12 input and store in I420. 45 | LIBYUV_API 46 | int NV12ToI420Rotate(const uint8* src_y, int src_stride_y, 47 | const uint8* src_uv, int src_stride_uv, 48 | uint8* dst_y, int dst_stride_y, 49 | uint8* dst_u, int dst_stride_u, 50 | uint8* dst_v, int dst_stride_v, 51 | int src_width, int src_height, enum RotationMode mode); 52 | 53 | // Rotate a plane by 0, 90, 180, or 270. 54 | LIBYUV_API 55 | int RotatePlane(const uint8* src, int src_stride, 56 | uint8* dst, int dst_stride, 57 | int src_width, int src_height, enum RotationMode mode); 58 | 59 | // Rotate planes by 90, 180, 270. Deprecated. 60 | LIBYUV_API 61 | void RotatePlane90(const uint8* src, int src_stride, 62 | uint8* dst, int dst_stride, 63 | int width, int height); 64 | 65 | LIBYUV_API 66 | void RotatePlane180(const uint8* src, int src_stride, 67 | uint8* dst, int dst_stride, 68 | int width, int height); 69 | 70 | LIBYUV_API 71 | void RotatePlane270(const uint8* src, int src_stride, 72 | uint8* dst, int dst_stride, 73 | int width, int height); 74 | 75 | LIBYUV_API 76 | void RotateUV90(const uint8* src, int src_stride, 77 | uint8* dst_a, int dst_stride_a, 78 | uint8* dst_b, int dst_stride_b, 79 | int width, int height); 80 | 81 | // Rotations for when U and V are interleaved. 82 | // These functions take one input pointer and 83 | // split the data into two buffers while 84 | // rotating them. Deprecated. 85 | LIBYUV_API 86 | void RotateUV180(const uint8* src, int src_stride, 87 | uint8* dst_a, int dst_stride_a, 88 | uint8* dst_b, int dst_stride_b, 89 | int width, int height); 90 | 91 | LIBYUV_API 92 | void RotateUV270(const uint8* src, int src_stride, 93 | uint8* dst_a, int dst_stride_a, 94 | uint8* dst_b, int dst_stride_b, 95 | int width, int height); 96 | 97 | // The 90 and 270 functions are based on transposes. 98 | // Doing a transpose with reversing the read/write 99 | // order will result in a rotation by +- 90 degrees. 100 | // Deprecated. 101 | LIBYUV_API 102 | void TransposePlane(const uint8* src, int src_stride, 103 | uint8* dst, int dst_stride, 104 | int width, int height); 105 | 106 | LIBYUV_API 107 | void TransposeUV(const uint8* src, int src_stride, 108 | uint8* dst_a, int dst_stride_a, 109 | uint8* dst_b, int dst_stride_b, 110 | int width, int height); 111 | 112 | #ifdef __cplusplus 113 | } // extern "C" 114 | } // namespace libyuv 115 | #endif 116 | 117 | #endif // INCLUDE_LIBYUV_ROTATE_H_ NOLINT 118 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/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_ // NOLINT 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* src_argb, int src_stride_argb, 25 | uint8* dst_argb, int dst_stride_argb, 26 | int src_width, int src_height, enum RotationMode mode); 27 | 28 | #ifdef __cplusplus 29 | } // extern "C" 30 | } // namespace libyuv 31 | #endif 32 | 33 | #endif // INCLUDE_LIBYUV_ROTATE_ARGB_H_ NOLINT 34 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/include/libyuv/scale.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_SCALE_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_SCALE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Supported filtering. 22 | typedef enum FilterMode { 23 | kFilterNone = 0, // Point sample; Fastest. 24 | kFilterLinear = 1, // Filter horizontally only. 25 | kFilterBilinear = 2, // Faster than box, but lower quality scaling down. 26 | kFilterBox = 3 // Highest quality. 27 | } FilterModeEnum; 28 | 29 | // Scale a YUV plane. 30 | LIBYUV_API 31 | void ScalePlane(const uint8* src, int src_stride, 32 | int src_width, int src_height, 33 | uint8* dst, int dst_stride, 34 | int dst_width, int dst_height, 35 | enum FilterMode filtering); 36 | 37 | LIBYUV_API 38 | void ScalePlane_16(const uint16* src, int src_stride, 39 | int src_width, int src_height, 40 | uint16* dst, int dst_stride, 41 | int dst_width, int dst_height, 42 | enum FilterMode filtering); 43 | 44 | // Scales a YUV 4:2:0 image from the src width and height to the 45 | // dst width and height. 46 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is 47 | // used. This produces basic (blocky) quality at the fastest speed. 48 | // If filtering is kFilterBilinear, interpolation is used to produce a better 49 | // quality image, at the expense of speed. 50 | // If filtering is kFilterBox, averaging is used to produce ever better 51 | // quality image, at further expense of speed. 52 | // Returns 0 if successful. 53 | 54 | LIBYUV_API 55 | int I420Scale(const uint8* src_y, int src_stride_y, 56 | const uint8* src_u, int src_stride_u, 57 | const uint8* src_v, int src_stride_v, 58 | int src_width, int src_height, 59 | uint8* dst_y, int dst_stride_y, 60 | uint8* dst_u, int dst_stride_u, 61 | uint8* dst_v, int dst_stride_v, 62 | int dst_width, int dst_height, 63 | enum FilterMode filtering); 64 | 65 | LIBYUV_API 66 | int I420Scale_16(const uint16* src_y, int src_stride_y, 67 | const uint16* src_u, int src_stride_u, 68 | const uint16* src_v, int src_stride_v, 69 | int src_width, int src_height, 70 | uint16* dst_y, int dst_stride_y, 71 | uint16* dst_u, int dst_stride_u, 72 | uint16* dst_v, int dst_stride_v, 73 | int dst_width, int dst_height, 74 | enum FilterMode filtering); 75 | 76 | #ifdef __cplusplus 77 | // Legacy API. Deprecated. 78 | LIBYUV_API 79 | int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, 80 | int src_stride_y, int src_stride_u, int src_stride_v, 81 | int src_width, int src_height, 82 | uint8* dst_y, uint8* dst_u, uint8* dst_v, 83 | int dst_stride_y, int dst_stride_u, int dst_stride_v, 84 | int dst_width, int dst_height, 85 | LIBYUV_BOOL interpolate); 86 | 87 | // Legacy API. Deprecated. 88 | LIBYUV_API 89 | int ScaleOffset(const uint8* src_i420, int src_width, int src_height, 90 | uint8* dst_i420, int dst_width, int dst_height, int dst_yoffset, 91 | LIBYUV_BOOL interpolate); 92 | 93 | // For testing, allow disabling of specialized scalers. 94 | LIBYUV_API 95 | void SetUseReferenceImpl(LIBYUV_BOOL use); 96 | #endif // __cplusplus 97 | 98 | #ifdef __cplusplus 99 | } // extern "C" 100 | } // namespace libyuv 101 | #endif 102 | 103 | #endif // INCLUDE_LIBYUV_SCALE_H_ NOLINT 104 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/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_ // NOLINT 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* src_argb, int src_stride_argb, 24 | int src_width, int src_height, 25 | uint8* dst_argb, int dst_stride_argb, 26 | int dst_width, int dst_height, 27 | enum FilterMode filtering); 28 | 29 | // Clipped scale takes destination rectangle coordinates for clip values. 30 | LIBYUV_API 31 | int ARGBScaleClip(const uint8* src_argb, int src_stride_argb, 32 | int src_width, int src_height, 33 | uint8* dst_argb, int dst_stride_argb, 34 | int dst_width, int dst_height, 35 | int clip_x, int clip_y, int clip_width, int clip_height, 36 | enum FilterMode filtering); 37 | 38 | // TODO(fbarchard): Implement this. 39 | // Scale with YUV conversion to ARGB and clipping. 40 | LIBYUV_API 41 | int YUVToARGBScaleClip(const uint8* src_y, int src_stride_y, 42 | const uint8* src_u, int src_stride_u, 43 | const uint8* src_v, int src_stride_v, 44 | uint32 src_fourcc, 45 | int src_width, int src_height, 46 | uint8* dst_argb, int dst_stride_argb, 47 | uint32 dst_fourcc, 48 | int dst_width, int dst_height, 49 | int clip_x, int clip_y, int clip_width, int clip_height, 50 | enum FilterMode filtering); 51 | 52 | #ifdef __cplusplus 53 | } // extern "C" 54 | } // namespace libyuv 55 | #endif 56 | 57 | #endif // INCLUDE_LIBYUV_SCALE_ARGB_H_ NOLINT 58 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/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_ // NOLINT 12 | #define INCLUDE_LIBYUV_VERSION_H_ 13 | 14 | #define LIBYUV_VERSION 1419 15 | 16 | #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT 17 | -------------------------------------------------------------------------------- /YuvUtils/src/main/jni/logger.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by XuYanjun on 2019/6/20. 3 | // 4 | 5 | #ifndef FACESDK_LOGGER_HPP 6 | #define FACESDK_LOGGER_HPP 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define LOG_TAG "YuvUtils" 13 | 14 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) 15 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) 16 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) 17 | using namespace std; 18 | 19 | static stringstream ss; 20 | static bool debugger = true; 21 | 22 | class logger { 23 | 24 | public: 25 | static void setDebug(bool isDebug) { 26 | debugger = isDebug; 27 | } 28 | 29 | static unsigned long getTime() { 30 | struct timeval tv; 31 | gettimeofday(&tv, NULL); 32 | return static_cast(tv.tv_sec * 1000 + tv.tv_usec / 1000); 33 | } 34 | 35 | static void printTime(string msg, unsigned long startTime) { 36 | if (!debugger) { return;} 37 | msg += ":%ld"; 38 | __android_log_print(ANDROID_LOG_INFO, "FaceSdkEngine_TIME", msg.c_str(), getTime() - startTime); 39 | } 40 | 41 | 42 | template 43 | static void debug(const T &value) { 44 | if (!debugger) { return;} 45 | ss << value; 46 | LOGD("%s", ss.str().c_str()); 47 | ss.str(""); 48 | ss.clear(); 49 | } 50 | 51 | template 52 | static void debug(const T &value, const Args &... arg) { 53 | if (!debugger) { return;} 54 | ss << value; 55 | debug(arg...); 56 | } 57 | 58 | template 59 | static void error(const T &value) { 60 | if (!debugger) { return;} 61 | ss << value; 62 | LOGE("%s", ss.str().c_str()); 63 | ss.str(""); 64 | ss.clear(); 65 | } 66 | 67 | template 68 | static void error(const T &value, const Args &... arg) { 69 | if (!debugger) { return;} 70 | ss << value; 71 | error(arg...); 72 | } 73 | }; 74 | 75 | 76 | #endif //FACESDK_LOGGER_HPP 77 | -------------------------------------------------------------------------------- /YuvUtils/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | YuvUtils 3 | 4 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | app.iml 3 | /ImageUtils-app.iml -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | apply plugin: 'kotlin-android' 4 | 5 | apply plugin: 'kotlin-android-extensions' 6 | 7 | android { 8 | compileSdkVersion 28 9 | buildToolsVersion "28.0.3" 10 | defaultConfig { 11 | applicationId "com.yancy.imageutils" 12 | minSdkVersion 23 13 | targetSdkVersion 28 14 | versionCode 1 15 | versionName "1.0" 16 | /*ndk{ 17 | abiFilters 'armeabi-v7a' 18 | }*/ 19 | } 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | 27 | sourceSets { 28 | main { 29 | jniLibs.srcDirs = ['libs','src/main/jinLibs'] 30 | } 31 | } 32 | } 33 | 34 | dependencies { 35 | // implementation fileTree(dir: 'libs', include: ['*.jar','*.aar']) 36 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 37 | implementation 'androidx.appcompat:appcompat:1.1.0' 38 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 39 | // api project(':ImageConvertUtils') 40 | implementation project(':YuvUtils') 41 | } 42 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/yancy/imageutils/LogUtils.kt: -------------------------------------------------------------------------------- 1 | package com.yancy.imageutils 2 | 3 | import android.util.Log 4 | 5 | /** 6 | * 说明:日志打印类 7 | * 8 | * @author Yancy 9 | * @date 2018/9/20 10 | */ 11 | object LogUtils { 12 | private var TAG = "YuvUtils" 13 | private var openLog = true 14 | @JvmStatic 15 | fun setTag(tag: String) { 16 | TAG = tag 17 | } 18 | 19 | @JvmStatic 20 | fun closeLog() { 21 | openLog = false 22 | } 23 | 24 | @JvmStatic 25 | fun v(tag: String, msg: String) { 26 | if (openLog) { 27 | Log.v(tag, msg) 28 | } 29 | } 30 | 31 | @JvmStatic 32 | fun v(msg: String) { 33 | v(TAG, msg) 34 | } 35 | 36 | @JvmStatic 37 | fun d(tag: String, msg: String) { 38 | if (openLog) { 39 | Log.d(tag, msg) 40 | } 41 | } 42 | 43 | @JvmStatic 44 | fun d(msg: String) { 45 | d(TAG, msg) 46 | } 47 | 48 | @JvmStatic 49 | fun i(tag: String, msg: String) { 50 | if (openLog) { 51 | Log.i(tag, msg) 52 | } 53 | } 54 | 55 | @JvmStatic 56 | fun i(msg: String) { 57 | i(TAG, msg) 58 | } 59 | 60 | @JvmStatic 61 | fun w(tag: String, msg: String) { 62 | if (openLog) { 63 | Log.w(tag, msg) 64 | } 65 | } 66 | 67 | @JvmStatic 68 | fun w(msg: String) { 69 | w(TAG, msg) 70 | } 71 | 72 | @JvmStatic 73 | fun e(msg: String) { 74 | e(TAG, msg) 75 | } 76 | 77 | @JvmStatic 78 | fun e(tag: String, msg: String) { 79 | if (openLog) { 80 | Log.e(tag, msg) 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/com/yancy/imageutils/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.yancy.imageutils 2 | 3 | import android.Manifest 4 | import android.graphics.* 5 | import androidx.appcompat.app.AppCompatActivity 6 | import android.os.Bundle 7 | import com.yancy.imageutils.test.Test 8 | import com.yancy.yuvutils.ImageUtils 9 | import com.yancy.yuvutils.YuvUtils 10 | import com.yancy.yuvutils.entry.ClipRect 11 | import kotlinx.android.synthetic.main.activity_main.* 12 | import java.nio.ByteBuffer 13 | import java.nio.IntBuffer 14 | 15 | class MainActivity : AppCompatActivity() { 16 | 17 | override fun onCreate(savedInstanceState: Bundle?) { 18 | super.onCreate(savedInstanceState) 19 | setContentView(R.layout.activity_main) 20 | PermissionUtil.addPermission( 21 | this, 22 | Manifest.permission.WRITE_EXTERNAL_STORAGE, 23 | Manifest.permission.CAMERA, 24 | Manifest.permission.READ_PHONE_STATE 25 | ) 26 | .request(this) 27 | 28 | // val bitmap = BitmapFactory.decodeFile("/sdcard/bg04.jpg") 29 | val bitmap = BitmapFactory.decodeFile("/sdcard/test__1.png") 30 | // val bitmap = BitmapFactory.decodeFile("/sdcard/test.png") 31 | val width = bitmap.width 32 | val height = bitmap.height 33 | if (bitmap == null) { 34 | LogUtils.e("bitmap is null.") 35 | return 36 | } 37 | LogUtils.d("width = $width, height = $height") //533 300 38 | 39 | 40 | imageView.setImageBitmap(bitmap) 41 | 42 | val i420Data = YuvUtils.bitmapToNV21(bitmap) 43 | LogUtils.e("size = ${i420Data?.size}") 44 | 45 | 46 | // 532 302 47 | val rect = Rect(0,100,300,400) 48 | //ClipRect() 49 | val targetImg = 50 | YuvUtils.dataClipRotateToBitmap(i420Data!!, 1, width, height, 270, null, 5, false) 51 | targetIv.setImageBitmap(targetImg) 52 | // targetIv.setImageBitmap(ImageUtils.i420ToBitmap8888(i420Data!!, width, height)) 53 | 54 | 55 | } 56 | 57 | 58 | private fun test() { 59 | 60 | val bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888) 61 | bitmap.eraseColor(Color.parseColor("#336699")) 62 | // imageView.setImageBitmap(bitmap) 63 | val rgba = IntArray(1 * 1) 64 | bitmap.getPixels(rgba, 0, 1, 0, 0, 1, 1) 65 | 66 | LogUtils.e("rgba = ${Test.convert01(rgba[0])}") 67 | val byteArray = ByteArray(1 * 1 * 4) 68 | val byteBuffer = ByteBuffer.wrap(byteArray) 69 | bitmap.copyPixelsToBuffer(byteBuffer) 70 | 71 | LogUtils.e(Test.convert(byteArray[0])) 72 | LogUtils.e(Test.convert(byteArray[1])) 73 | LogUtils.e(Test.convert(byteArray[2])) 74 | LogUtils.e(Test.convert(byteArray[3])) 75 | } 76 | 77 | 78 | private fun rgb24Convert(bitmap: Bitmap, width: Int, height: Int) { 79 | 80 | ImageUtils.apply { 81 | val rgb24Bytes = bitmapToRgb24(bitmap) 82 | //val rgb24Clip = rgb24Clip(rgb24Bytes!!, width, height, Rect(100, 100, 300, 300)) 83 | //imageView.setImageBitmap(rgb24ToBitmap8888(rgb24Clip!!,200,200)) 84 | 85 | val rgb24Scale = rgb24Scale(rgb24Bytes!!, width, height, 800, 800) 86 | imageView.setImageBitmap(rgb24ToBitmap8888(rgb24Scale!!, 800, 800)) 87 | 88 | imageView.setImageBitmap(rgb24ToBitmap565(rgb24Rotate(rgb24Bytes, width, height, 90)!!, height, width)) 89 | 90 | imageView.setImageBitmap(rgb24ToBitmap565(rgb24Mirror(rgb24Bytes, width, height)!!, width, height)) 91 | 92 | imageView.setImageBitmap(i420ToBitmap8888(rgb24ToI420(rgb24Bytes, width, height)!!, width, height)) 93 | imageView.setImageBitmap(nv21ToBitmap8888(rgb24ToNV21(rgb24Bytes, width, height)!!, width, height)) 94 | imageView.setImageBitmap(rgbaToBitmap8888(rgb24ToRgba(rgb24Bytes, width, height)!!, width, height)) 95 | imageView.setImageBitmap(rgb565ToBitmap8888(rgb24ToRgb565(rgb24Bytes, width, height)!!, width, height)) 96 | } 97 | 98 | 99 | } 100 | 101 | 102 | private fun rgbaConvert(bitmap: Bitmap, width: Int, height: Int) { 103 | //提取Bitmap数据 104 | val rgbaBytes = ByteArray(width * height * 4) 105 | val dst = ByteBuffer.wrap(rgbaBytes) 106 | bitmap.copyPixelsToBuffer(dst) 107 | 108 | ImageUtils.apply { 109 | //imageView.setImageBitmap(rgbaToBitmap8888(rgbaBytes,width,height)) 110 | //imageView.setImageBitmap(rgbaToBitmap565(rgbaBytes,width,height)) 111 | 112 | val i420Bytes = rgbaToI420(rgbaBytes, width, height) 113 | //imageView.setImageBitmap(i420ToBitmap8888(i420Bytes!!,width,height)) 114 | //imageView.setImageBitmap(i420ToBitmap565(i420Bytes!!,width,height)) 115 | 116 | val nv21Bytes = rgbaToNV21(rgbaBytes, width, height) 117 | //imageView.setImageBitmap(nv21ToBitmap8888(nv21Bytes!!,width,height)) 118 | //imageView.setImageBitmap(nv21ToBitmap565(nv21Bytes!!,width,height)) 119 | 120 | val rgb24Bytes = rgbaToRgb24(rgbaBytes, width, height) 121 | //imageView.setImageBitmap(rgb24ToBitmap8888(rgb24Bytes!!,width,height)) 122 | //imageView.setImageBitmap(rgb24ToBitmap565(rgb24Bytes!!,width,height)) 123 | 124 | val rgb565Bytes = rgbaToRgb565(rgbaBytes, width, height) 125 | //imageView.setImageBitmap(rgb565ToBitmap8888(rgb565Bytes!!,width,height)) 126 | imageView.setImageBitmap(rgb565ToBitmap565(rgb565Bytes!!, width, height)) 127 | } 128 | 129 | 130 | } 131 | 132 | fun onPreviewFrame(data: ByteArray, width: Int, height: Int) { 133 | val bitmap: Bitmap? = ImageUtils.nv21ToBitmap8888(data, width, height, 270) 134 | 135 | //我们还可以用二次封装的调用 136 | ImageUtils.nv21ToBitmap8888(data, width, height) 137 | 138 | 139 | } 140 | 141 | } 142 | -------------------------------------------------------------------------------- /app/src/main/java/com/yancy/imageutils/PermissionUtil.kt: -------------------------------------------------------------------------------- 1 | package com.yancy.imageutils 2 | 3 | import android.app.Activity 4 | import android.content.pm.PackageManager 5 | import androidx.core.app.ActivityCompat 6 | import androidx.core.content.ContextCompat 7 | 8 | /** 9 | * 说明: 10 | * @author Yancy 11 | * @date 2019/6/4 12 | */ 13 | object PermissionUtil { 14 | interface PermissionCallback { 15 | /** 16 | * 当权限被拒绝,且点了不在提示之后,再次申请权限,如果设置了回调,会执行该方法 17 | */ 18 | fun callback() 19 | } 20 | 21 | private var callback: PermissionCallback? = null 22 | private val list = ArrayList() 23 | private const val REQUEST_CODE = 1000 24 | 25 | 26 | @JvmStatic 27 | fun addPermission(activity: Activity, vararg permissions: String): PermissionUtil { 28 | permissions.forEach { 29 | if (ContextCompat.checkSelfPermission(activity.applicationContext, it) != PackageManager.PERMISSION_GRANTED) { 30 | list.add(it) 31 | } 32 | } 33 | return this 34 | } 35 | 36 | fun request(activity: Activity) { 37 | if (list.isNotEmpty()) ActivityCompat.requestPermissions(activity, list.toTypedArray(), REQUEST_CODE) 38 | } 39 | 40 | @JvmStatic 41 | fun onRequestPermissionsResult(activity: Activity, requestCode: Int, permissions: Array, grantResults: IntArray) { 42 | if (requestCode == REQUEST_CODE) { 43 | for (index in 0..permissions.size) { 44 | val rationale = ActivityCompat.shouldShowRequestPermissionRationale(activity, permissions[index]) 45 | val grant = grantResults[index] 46 | if (!rationale && grant == PackageManager.PERMISSION_DENIED) { 47 | if (callback != null) { 48 | callback!!.callback() 49 | } 50 | } 51 | break 52 | } 53 | list.clear() 54 | } 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /app/src/main/java/com/yancy/imageutils/test/Test.java: -------------------------------------------------------------------------------- 1 | package com.yancy.imageutils.test; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.renderscript.Allocation; 6 | import android.renderscript.Element; 7 | import android.renderscript.RenderScript; 8 | import android.renderscript.ScriptIntrinsicYuvToRGB; 9 | import android.renderscript.Type; 10 | import android.text.TextUtils; 11 | 12 | import com.yancy.yuvutils.ImageUtils; 13 | 14 | import java.io.ByteArrayOutputStream; 15 | import java.io.File; 16 | import java.io.FileOutputStream; 17 | import java.io.IOException; 18 | 19 | 20 | /** 21 | * 说明: 22 | * 23 | * @author Yancy 24 | * @date 2019/11/11 25 | */ 26 | public class Test { 27 | 28 | public static String convert(byte data){ 29 | return Integer.toHexString(data & 0xff); 30 | } 31 | 32 | 33 | public static String convert01(int data) { 34 | return Integer.toHexString(data); 35 | } 36 | public static void main(String[] args) { 37 | Bitmap bitmap = Bitmap.createBitmap(1,1,Bitmap.Config.ARGB_8888); 38 | } 39 | 40 | public static Bitmap nv21BytesToBitmap(Context context, byte[] data, int width, int height) { 41 | if (data.length != height * 3 / 2 * width) { 42 | return null; 43 | } 44 | RenderScript rs = RenderScript.create(context); 45 | ScriptIntrinsicYuvToRGB yuvToRgbIntrinsic = ScriptIntrinsicYuvToRGB.create(rs, 46 | Element.U8_4(rs)); 47 | Type.Builder yuvBuilder = new Type.Builder(rs, Element.U8(rs)).setX(data.length); 48 | Type t1 = yuvBuilder.create(); 49 | Allocation in = Allocation.createTyped(rs, t1, Allocation.USAGE_SCRIPT); 50 | Type.Builder rgbaBuilder = new Type.Builder(rs, Element.RGBA_8888(rs)).setX(width) 51 | .setY(height); 52 | Type t2 = rgbaBuilder.create(); 53 | Allocation out = Allocation.createTyped(rs, t2, Allocation.USAGE_SCRIPT); 54 | in.copyFrom(data); 55 | yuvToRgbIntrinsic.setInput(in); 56 | yuvToRgbIntrinsic.forEach(out); 57 | Bitmap bmpout = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); 58 | out.copyTo(bmpout); 59 | rs.destroy(); 60 | yuvToRgbIntrinsic.destroy(); 61 | t1.destroy(); 62 | t2.destroy(); 63 | in.destroy(); 64 | out.destroy(); 65 | 66 | return bmpout; 67 | } 68 | 69 | public static void saveBitmapToPNG(Bitmap bitmap, String imagePath, String imageName) { 70 | if (TextUtils.isEmpty(imageName)) { 71 | return; 72 | } 73 | String png = ".png"; 74 | String fileName = imageName.toLowerCase().endsWith(png) ? imageName : imageName + png; 75 | saveBitmapToLocal(bitmap, imagePath, fileName, Bitmap.CompressFormat.PNG); 76 | } 77 | 78 | /** 79 | * 保存图片到本地 80 | * 81 | * @param bitmap 图像源bitmap 82 | * @param imagePath 保存图片的路径 83 | * @param imageName 保存图片的名称 84 | * @param format 保存文件的格式{@link Bitmap.CompressFormat} 85 | */ 86 | public static void saveBitmapToLocal(Bitmap bitmap, String imagePath, String imageName, Bitmap.CompressFormat format) { 87 | if (bitmap == null || TextUtils.isEmpty(imagePath) || TextUtils.isEmpty(imageName)) { 88 | return; 89 | } 90 | File dir = new File(imagePath); 91 | if (!dir.exists()) { 92 | dir.mkdirs(); 93 | } 94 | byte[] bytes = bitmap2Bytes(bitmap, format); 95 | FileOutputStream fos = null; 96 | try { 97 | fos = new FileOutputStream(new File(dir, imageName)); 98 | fos.write(bytes); 99 | fos.flush(); 100 | } catch (IOException ignore) { 101 | 102 | } finally { 103 | if (fos != null) { 104 | try { 105 | fos.close(); 106 | } catch (IOException e) { 107 | e.printStackTrace(); 108 | } 109 | } 110 | } 111 | } 112 | 113 | public static byte[] bitmap2Bytes(final Bitmap bitmap, final Bitmap.CompressFormat format) { 114 | if (bitmap == null) { 115 | return null; 116 | } 117 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 118 | bitmap.compress(format, 100, baos); 119 | return baos.toByteArray(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /app/src/main/java/com/yancy/imageutils/test/Test01.kt: -------------------------------------------------------------------------------- 1 | package com.yancy.imageutils.test 2 | 3 | /** 4 | * 说明: 5 | * @author Yancy 6 | * @date 2019/11/11 7 | */ 8 | fun main(){ 9 | ""?.apply { 10 | print(999) 11 | } 12 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-xhdpi/test.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ImageUtils 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext.kotlin_version = '1.3.50' 5 | repositories { 6 | google() 7 | jcenter() 8 | 9 | } 10 | dependencies { 11 | // 3.5.2 这个版本就是一个坑逼!!!!!!无法将armeabi-v7a的 so打进 apk 12 | // classpath 'com.android.tools.build:gradle:3.5.2' 13 | classpath 'com.android.tools.build:gradle:3.2.1' 14 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 15 | // classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | google() 22 | jcenter() 23 | } 24 | } 25 | 26 | task clean(type: Delete) { 27 | delete rootProject.buildDir 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Nov 11 14:17:10 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /libyuv/jni/.gitignore: -------------------------------------------------------------------------------- 1 | .gn 2 | build 3 | buildtools 4 | chromium/.gclient.tmp 5 | chromium/.gclient.tmp_entries 6 | chromium/.last_sync_chromium 7 | chromium/src/ 8 | google_apis 9 | links 10 | net 11 | out/ 12 | testing 13 | third_party/ 14 | tools/android 15 | tools/clang 16 | tools/find_depot_tools.py 17 | tools/generate_library_loader 18 | tools/gn 19 | tools/gyp 20 | tools/memory 21 | tools/python 22 | tools/valgrind 23 | tools/win 24 | 25 | # Files generated by CMake build 26 | CMakeFiles/ 27 | CMakeCache.txt 28 | Makefile 29 | convert 30 | libgtest.a 31 | libyuv.a 32 | libyuv_unittest 33 | cmake_install.cmake 34 | -------------------------------------------------------------------------------- /libyuv/jni/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file like so: 2 | # Name or Organization 3 | 4 | Google Inc. 5 | -------------------------------------------------------------------------------- /libyuv/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # This is the Android makefile for libyuv for both platform and 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_neon64.cc \ 12 | source/compare_gcc.cc \ 13 | source/convert.cc \ 14 | source/convert_argb.cc \ 15 | source/convert_from.cc \ 16 | source/convert_from_argb.cc \ 17 | source/convert_to_argb.cc \ 18 | source/convert_to_i420.cc \ 19 | source/cpu_id.cc \ 20 | source/planar_functions.cc \ 21 | source/rotate.cc \ 22 | source/rotate_argb.cc \ 23 | source/rotate_mips.cc \ 24 | source/rotate_neon64.cc \ 25 | source/row_any.cc \ 26 | source/row_common.cc \ 27 | source/row_mips.cc \ 28 | source/row_neon64.cc \ 29 | source/row_gcc.cc \ 30 | source/scale.cc \ 31 | source/scale_any.cc \ 32 | source/scale_argb.cc \ 33 | source/scale_common.cc \ 34 | source/scale_mips.cc \ 35 | source/scale_neon64.cc \ 36 | source/scale_gcc.cc \ 37 | source/video_common.cc 38 | 39 | # TODO(fbarchard): Enable mjpeg encoder. 40 | # source/mjpeg_decoder.cc 41 | # source/convert_jpeg.cc 42 | # source/mjpeg_validate.cc 43 | 44 | ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 45 | LOCAL_CFLAGS += -DLIBYUV_NEON 46 | LOCAL_SRC_FILES += \ 47 | source/compare_neon.cc.neon \ 48 | source/rotate_neon.cc.neon \ 49 | source/row_neon.cc.neon \ 50 | source/scale_neon.cc.neon 51 | endif 52 | 53 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include 54 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/include 55 | 56 | LOCAL_MODULE := libyuv_static 57 | LOCAL_MODULE_TAGS := optional 58 | 59 | include $(BUILD_STATIC_LIBRARY) 60 | 61 | -------------------------------------------------------------------------------- /libyuv/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := armeabi-v7a x86 x86_64 armeabi arm64-v8a 2 | APP_PLATFORM := android-16 3 | APP_STL := stlport_static 4 | APP_CPPFLAGS += -fno-rtti 5 | -------------------------------------------------------------------------------- /libyuv/jni/BUILD.gn: -------------------------------------------------------------------------------- 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 | import("//build/config/arm.gni") 10 | 11 | config("libyuv_config") { 12 | include_dirs = [ 13 | ".", 14 | "include", 15 | ] 16 | } 17 | 18 | use_neon = current_cpu == "arm" && (arm_use_neon || arm_optionally_use_neon) 19 | 20 | source_set("libyuv") { 21 | sources = [ 22 | "include/libyuv.h", 23 | "include/libyuv/basic_types.h", 24 | "include/libyuv/compare.h", 25 | "include/libyuv/convert.h", 26 | "include/libyuv/convert_argb.h", 27 | "include/libyuv/convert_from.h", 28 | "include/libyuv/convert_from_argb.h", 29 | "include/libyuv/cpu_id.h", 30 | "include/libyuv/mjpeg_decoder.h", 31 | "include/libyuv/planar_functions.h", 32 | "include/libyuv/rotate.h", 33 | "include/libyuv/rotate_argb.h", 34 | "include/libyuv/row.h", 35 | "include/libyuv/scale.h", 36 | "include/libyuv/scale_argb.h", 37 | "include/libyuv/scale_row.h", 38 | "include/libyuv/version.h", 39 | "include/libyuv/video_common.h", 40 | 41 | # sources. 42 | "source/compare.cc", 43 | "source/compare_common.cc", 44 | "source/compare_gcc.cc", 45 | "source/compare_win.cc", 46 | "source/convert.cc", 47 | "source/convert_argb.cc", 48 | "source/convert_from.cc", 49 | "source/convert_from_argb.cc", 50 | "source/convert_jpeg.cc", 51 | "source/convert_to_argb.cc", 52 | "source/convert_to_i420.cc", 53 | "source/cpu_id.cc", 54 | "source/mjpeg_decoder.cc", 55 | "source/mjpeg_validate.cc", 56 | "source/planar_functions.cc", 57 | "source/rotate.cc", 58 | "source/rotate_argb.cc", 59 | "source/rotate_mips.cc", 60 | "source/row_any.cc", 61 | "source/row_common.cc", 62 | "source/row_mips.cc", 63 | "source/row_gcc.cc", 64 | "source/row_win.cc", 65 | "source/scale.cc", 66 | "source/scale_any.cc", 67 | "source/scale_argb.cc", 68 | "source/scale_common.cc", 69 | "source/scale_mips.cc", 70 | "source/scale_gcc.cc", 71 | "source/scale_win.cc", 72 | "source/video_common.cc", 73 | ] 74 | 75 | configs -= [ "//build/config/compiler:chromium_code" ] 76 | configs += [ "//build/config/compiler:no_chromium_code" ] 77 | 78 | public_configs = [ ":libyuv_config" ] 79 | 80 | defines = [] 81 | 82 | if (!is_ios) { 83 | defines += [ "HAVE_JPEG" ] 84 | } 85 | 86 | if (is_msan) { 87 | # MemorySanitizer does not support assembly code yet. 88 | # http://crbug.com/344505 89 | defines += [ "LIBYUV_DISABLE_X86" ] 90 | } 91 | 92 | deps = [ 93 | "//third_party:jpeg", 94 | ] 95 | 96 | if (use_neon) { 97 | deps += [ ":libyuv_neon" ] 98 | } 99 | } 100 | 101 | if (use_neon) { 102 | static_library("libyuv_neon") { 103 | sources = [ 104 | "source/compare_neon.cc", 105 | "source/compare_neon64.cc", 106 | "source/rotate_neon.cc", 107 | "source/rotate_neon64.cc", 108 | "source/row_neon.cc", 109 | "source/row_neon64.cc", 110 | "source/scale_neon.cc", 111 | "source/scale_neon64.cc", 112 | ] 113 | 114 | public_configs = [ ":libyuv_config" ] 115 | 116 | configs -= [ "//build/config/compiler:compiler_arm_fpu" ] 117 | cflags = [ "-mfpu=neon" ] 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /libyuv/jni/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | # CMakeLists for libyuv 4 | # Originally created for "roxlu build system" to compile libyuv on windows 5 | # Run with -DTEST=ON to build unit tests 6 | option(TEST "Built unit tests" OFF) 7 | 8 | set(ly_base_dir ${CMAKE_CURRENT_LIST_DIR}) 9 | set(ly_src_dir ${ly_base_dir}/source/) 10 | set(ly_inc_dir ${ly_base_dir}/include) 11 | set(ly_lib_name "yuv") 12 | 13 | set(ly_source_files 14 | ${ly_src_dir}/compare.cc 15 | ${ly_src_dir}/compare_common.cc 16 | ${ly_src_dir}/compare_neon.cc 17 | ${ly_src_dir}/compare_gcc.cc 18 | ${ly_src_dir}/compare_win.cc 19 | ${ly_src_dir}/convert.cc 20 | ${ly_src_dir}/convert_argb.cc 21 | ${ly_src_dir}/convert_from.cc 22 | ${ly_src_dir}/convert_from_argb.cc 23 | ${ly_src_dir}/convert_jpeg.cc 24 | ${ly_src_dir}/convert_to_argb.cc 25 | ${ly_src_dir}/convert_to_i420.cc 26 | ${ly_src_dir}/cpu_id.cc 27 | ${ly_src_dir}/mjpeg_decoder.cc 28 | ${ly_src_dir}/mjpeg_validate.cc 29 | ${ly_src_dir}/planar_functions.cc 30 | ${ly_src_dir}/rotate.cc 31 | ${ly_src_dir}/rotate_argb.cc 32 | ${ly_src_dir}/rotate_mips.cc 33 | ${ly_src_dir}/rotate_neon.cc 34 | ${ly_src_dir}/row_any.cc 35 | ${ly_src_dir}/row_common.cc 36 | ${ly_src_dir}/row_mips.cc 37 | ${ly_src_dir}/row_neon.cc 38 | ${ly_src_dir}/row_gcc.cc 39 | ${ly_src_dir}/row_win.cc 40 | ${ly_src_dir}/scale.cc 41 | ${ly_src_dir}/scale_any.cc 42 | ${ly_src_dir}/scale_argb.cc 43 | ${ly_src_dir}/scale_common.cc 44 | ${ly_src_dir}/scale_mips.cc 45 | ${ly_src_dir}/scale_neon.cc 46 | ${ly_src_dir}/scale_gcc.cc 47 | ${ly_src_dir}/scale_win.cc 48 | ${ly_src_dir}/video_common.cc 49 | ) 50 | 51 | set(ly_unittest_sources 52 | ${ly_base_dir}/unit_test/basictypes_test.cc 53 | ${ly_base_dir}/unit_test/color_test.cc 54 | ${ly_base_dir}/unit_test/compare_test.cc 55 | ${ly_base_dir}/unit_test/convert_test.cc 56 | ${ly_base_dir}/unit_test/cpu_test.cc 57 | ${ly_base_dir}/unit_test/math_test.cc 58 | ${ly_base_dir}/unit_test/planar_test.cc 59 | ${ly_base_dir}/unit_test/rotate_argb_test.cc 60 | ${ly_base_dir}/unit_test/rotate_test.cc 61 | ${ly_base_dir}/unit_test/scale_argb_test.cc 62 | ${ly_base_dir}/unit_test/scale_color_test.cc 63 | ${ly_base_dir}/unit_test/scale_test.cc 64 | ${ly_base_dir}/unit_test/unit_test.cc 65 | ${ly_base_dir}/unit_test/video_common_test.cc 66 | ${ly_base_dir}/unit_test/version_test.cc 67 | ) 68 | 69 | set(ly_header_files 70 | ${ly_inc_dir}/libyuv/basic_types.h 71 | ${ly_inc_dir}/libyuv/compare.h 72 | ${ly_inc_dir}/libyuv/convert.h 73 | ${ly_inc_dir}/libyuv/convert_argb.h 74 | ${ly_inc_dir}/libyuv/convert_from.h 75 | ${ly_inc_dir}/libyuv/convert_from_argb.h 76 | ${ly_inc_dir}/libyuv/cpu_id.h 77 | ${ly_inc_dir}/libyuv/planar_functions.h 78 | ${ly_inc_dir}/libyuv/rotate.h 79 | ${ly_inc_dir}/libyuv/rotate_argb.h 80 | ${ly_inc_dir}/libyuv/row.h 81 | ${ly_inc_dir}/libyuv/scale.h 82 | ${ly_inc_dir}/libyuv/scale_argb.h 83 | ${ly_inc_dir}/libyuv/scale_row.h 84 | ${ly_inc_dir}/libyuv/version.h 85 | ${ly_inc_dir}/libyuv/video_common.h 86 | ${ly_inc_dir}/libyuv/mjpeg_decoder.h 87 | ) 88 | 89 | include_directories(${ly_inc_dir}) 90 | 91 | add_library(${ly_lib_name} STATIC ${ly_source_files}) 92 | 93 | add_executable(convert ${ly_base_dir}/util/convert.cc) 94 | target_link_libraries(convert ${ly_lib_name}) 95 | 96 | include(FindJPEG) 97 | if (JPEG_FOUND) 98 | include_directories(${JPEG_INCLUDE_DIR}) 99 | target_link_libraries(convert ${JPEG_LIBRARY}) 100 | add_definitions(-DHAVE_JPEG) 101 | endif() 102 | 103 | if(TEST) 104 | find_library(GTEST_LIBRARY gtest) 105 | if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND") 106 | set(GTEST_SRC_DIR /usr/src/gtest) 107 | if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc) 108 | message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}") 109 | set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc) 110 | add_library(gtest STATIC ${gtest_sources}) 111 | include_directories(${GTEST_SRC_DIR}) 112 | set(GTEST_LIBRARY gtest) 113 | else() 114 | message(FATAL_ERROR "TEST is set but unable to find gtest library") 115 | endif() 116 | endif() 117 | 118 | add_executable(libyuv_unittest ${ly_unittest_sources}) 119 | target_link_libraries(libyuv_unittest ${ly_lib_name} ${GTEST_LIBRARY} pthread) 120 | if (JPEG_FOUND) 121 | target_link_libraries(libyuv_unittest ${JPEG_LIBRARY}) 122 | endif() 123 | endif() 124 | 125 | if(NACL AND NACL_LIBC STREQUAL "newlib") 126 | target_link_libraries(libyuv_unittest glibc-compat) 127 | endif() 128 | 129 | install(TARGETS ${ly_lib_name} DESTINATION lib) 130 | install(FILES ${ly_header_files} DESTINATION include/libyuv) 131 | install(FILES ${ly_inc_dir}/libyuv.h DESTINATION include/) 132 | -------------------------------------------------------------------------------- /libyuv/jni/DEPS: -------------------------------------------------------------------------------- 1 | vars = { 2 | # Override root_dir in your .gclient's custom_vars to specify a custom root 3 | # folder name. 4 | "root_dir": "trunk", 5 | "extra_gyp_flag": "-Dextra_gyp_flag=0", 6 | 7 | # Roll the Chromium Git hash to pick up newer versions of all the 8 | # dependencies and tools linked to in setup_links.py. 9 | 'chromium_revision': '3dba19a90208ee9c5890cffda0490c517cbdf43e', 10 | } 11 | 12 | hooks = [ 13 | { 14 | # Clone chromium and its deps. 15 | "name": "sync chromium", 16 | "pattern": ".", 17 | "action": ["python", "-u", Var("root_dir") + "/sync_chromium.py", 18 | "--target-revision", Var("chromium_revision")], 19 | }, 20 | { 21 | # Create links to shared dependencies in Chromium. 22 | "name": "setup_links", 23 | "pattern": ".", 24 | "action": ["python", Var("root_dir") + "/setup_links.py"], 25 | }, 26 | { 27 | # A change to a .gyp, .gypi, or to GYP itself should run the generator. 28 | "pattern": ".", 29 | "action": ["python", Var("root_dir") + "/gyp_libyuv"], 30 | }, 31 | ] 32 | -------------------------------------------------------------------------------- /libyuv/jni/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 | -------------------------------------------------------------------------------- /libyuv/jni/LICENSE_THIRD_PARTY: -------------------------------------------------------------------------------- 1 | This source tree contains third party source code which is governed by third 2 | party licenses. This file contains references to files which are under other 3 | licenses than the one provided in the LICENSE file in the root of the source 4 | tree. 5 | 6 | Files governed by third party licenses: 7 | source/x86inc.asm 8 | 9 | -------------------------------------------------------------------------------- /libyuv/jni/OWNERS: -------------------------------------------------------------------------------- 1 | fbarchard@chromium.org 2 | mflodman@chromium.org 3 | -------------------------------------------------------------------------------- /libyuv/jni/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. -------------------------------------------------------------------------------- /libyuv/jni/PRESUBMIT.py: -------------------------------------------------------------------------------- 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 | import re 10 | import sys 11 | 12 | 13 | def GetDefaultTryConfigs(bots=None): 14 | """Returns a list of ('bot', set(['tests']), optionally filtered by [bots]. 15 | 16 | For WebRTC purposes, we always return an empty list of tests, since we want 17 | to run all tests by default on all our trybots. 18 | """ 19 | return { 'tryserver.libyuv': dict((bot, []) for bot in bots)} 20 | 21 | 22 | # pylint: disable=W0613 23 | def GetPreferredTryMasters(project, change): 24 | files = change.LocalPaths() 25 | bots = [ 26 | 'win', 27 | 'win_rel', 28 | 'win_x64_rel', 29 | 'mac', 30 | 'mac_rel', 31 | 'mac_x64_rel', 32 | 'ios', 33 | 'ios_rel', 34 | 'ios_arm64', 35 | 'ios_arm64_rel', 36 | 'mac_asan', 37 | 'linux', 38 | 'linux_rel', 39 | 'linux_memcheck', 40 | 'linux_tsan2', 41 | 'linux_asan', 42 | 'android', 43 | 'android_rel', 44 | 'android_clang', 45 | 'android_arm64', 46 | ] 47 | if not files or all(re.search(r'[\\/]OWNERS$', f) for f in files): 48 | return {} 49 | return GetDefaultTryConfigs(bots) 50 | -------------------------------------------------------------------------------- /libyuv/jni/README.chromium: -------------------------------------------------------------------------------- 1 | Name: libyuv 2 | URL: http://code.google.com/p/libyuv/ 3 | Version: 1419 4 | License: BSD 5 | License File: LICENSE 6 | 7 | Description: 8 | libyuv is an open source project that includes YUV conversion and scaling functionality. 9 | -------------------------------------------------------------------------------- /libyuv/jni/all.gyp: -------------------------------------------------------------------------------- 1 | # Copyright 2013 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 | # all.gyp and All target are for benefit of android gyp build. 10 | { 11 | 'targets': [ 12 | { 13 | 'target_name': 'All', 14 | 'type': 'none', 15 | 'dependencies': [ 16 | 'libyuv.gyp:*', 17 | 'libyuv_test.gyp:*', 18 | ], 19 | }, 20 | ], 21 | } 22 | -------------------------------------------------------------------------------- /libyuv/jni/chromium/.gclient: -------------------------------------------------------------------------------- 1 | solutions = [{ 2 | 'name': 'src', 3 | 'url': 'https://chromium.googlesource.com/chromium/src.git', 4 | 'deps_file': '.DEPS.git', 5 | 'managed': False, 6 | 'custom_deps': { 7 | # Skip syncing some large dependencies Libyuv will never need. 8 | 'src/chrome/tools/test/reference_build/chrome_linux': None, 9 | 'src/chrome/tools/test/reference_build/chrome_mac': None, 10 | 'src/chrome/tools/test/reference_build/chrome_win': None, 11 | 'src/native_client': None, 12 | 'src/third_party/ffmpeg': None, 13 | 'src/third_party/WebKit': None, 14 | 'src/v8': None, 15 | }, 16 | 'safesync_url': '' 17 | }] 18 | 19 | cache_dir = None 20 | -------------------------------------------------------------------------------- /libyuv/jni/chromium/README: -------------------------------------------------------------------------------- 1 | This .gclient file is used to do download a copy of Chromium. 2 | Libyuv uses the Chromium build toolchain and a number of shared 3 | dependencies by creating symlinks to folders in this checkout, 4 | using the ../setup_links.py script. 5 | 6 | -------------------------------------------------------------------------------- /libyuv/jni/codereview.settings: -------------------------------------------------------------------------------- 1 | # This file is used by gcl to get repository specific information. 2 | # The LibYuv code review is via WebRtc's code review 3 | CODE_REVIEW_SERVER: webrtc-codereview.appspot.com 4 | #CC_LIST: 5 | VIEW_VC: https://code.google.com/p/libyuv/source/detail?r= 6 | #STATUS: 7 | FORCE_HTTPS_COMMIT_URL: True 8 | PROJECT: libyuv 9 | TRY_ON_UPLOAD: False 10 | TRYSERVER_ROOT: src 11 | TRYSERVER_SVN_URL: svn://svn.chromium.org/chrome-try/try-libyuv 12 | #GITCL_PREUPLOAD: 13 | #GITCL_PREDCOMMIT: 14 | -------------------------------------------------------------------------------- /libyuv/jni/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 | LIBYUV_DISABLE_ASM 11 | 12 | ## Intel CPUs 13 | LIBYUV_DISABLE_X86 14 | LIBYUV_DISABLE_SSE2 15 | LIBYUV_DISABLE_SSSE3 16 | LIBYUV_DISABLE_SSE41 17 | LIBYUV_DISABLE_SSE42 18 | LIBYUV_DISABLE_AVX 19 | LIBYUV_DISABLE_AVX2 20 | LIBYUV_DISABLE_ERMS 21 | LIBYUV_DISABLE_FMA3 22 | LIBYUV_DISABLE_F16C 23 | LIBYUV_DISABLE_AVX512BW 24 | LIBYUV_DISABLE_AVX512VL 25 | LIBYUV_DISABLE_AVX512VBMI 26 | LIBYUV_DISABLE_AVX512VBMI2 27 | LIBYUV_DISABLE_AVX512VBITALG 28 | LIBYUV_DISABLE_AVX512VPOPCNTDQ 29 | LIBYUV_DISABLE_GFNI 30 | 31 | ## ARM CPUs 32 | 33 | LIBYUV_DISABLE_NEON 34 | 35 | ## MIPS CPUs 36 | LIBYUV_DISABLE_MSA 37 | LIBYUV_DISABLE_MMI 38 | 39 | # Test Width/Height/Repeat 40 | 41 | The unittests default to a small image (128x72) to run fast. This can be set by environment variable to test a specific resolutions. 42 | You can also repeat the test a specified number of iterations, allowing benchmarking and profiling. 43 | 44 | set LIBYUV_WIDTH=1280 45 | set LIBYUV_HEIGHT=720 46 | set LIBYUV_REPEAT=999 47 | set LIBYUV_FLAGS=-1 48 | set LIBYUV_CPU_INFO=-1 49 | -------------------------------------------------------------------------------- /libyuv/jni/docs/rotation.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Rotation by multiplies of 90 degrees allows mobile devices to rotate webcams from landscape to portrait. The higher level functions ConvertToI420 and ConvertToARGB allow rotation of any format. Optimized functionality is supported for I420, ARGB, NV12 and NV21. 4 | 5 | # ConvertToI420 6 | 7 | int ConvertToI420(const uint8* src_frame, size_t src_size, 8 | uint8* dst_y, int dst_stride_y, 9 | uint8* dst_u, int dst_stride_u, 10 | uint8* dst_v, int dst_stride_v, 11 | int crop_x, int crop_y, 12 | int src_width, int src_height, 13 | int crop_width, int crop_height, 14 | enum RotationMode rotation, 15 | uint32 format); 16 | 17 | This function crops, converts, and rotates. You should think of it in that order. 18 | * Crops the original image, which is src_width x src_height, to crop_width x crop_height. At this point the image is still not rotated. 19 | * Converts the cropped region to I420. Supports inverted source for src_height negative. 20 | * Rotates by 90, 180 or 270 degrees. 21 | The buffer the caller provides should account for rotation. Be especially important to get stride of the destination correct. 22 | 23 | e.g. 24 | 640 x 480 NV12 captured
25 | Crop to 640 x 360
26 | Rotate by 90 degrees to 360 x 640.
27 | Caller passes stride of 360 for Y and 360 / 2 for U and V.
28 | Caller passes crop_width of 640, crop_height of 360.
29 | 30 | # ConvertToARGB 31 | 32 | int ConvertToARGB(const uint8* src_frame, size_t src_size, 33 | uint8* dst_argb, int dst_stride_argb, 34 | int crop_x, int crop_y, 35 | int src_width, int src_height, 36 | int crop_width, int crop_height, 37 | enum RotationMode rotation, 38 | uint32 format); 39 | 40 | Same as I420, but implementation is less optimized - reads columns and writes rows, 16 bytes at a time. 41 | 42 | # I420Rotate 43 | 44 | int I420Rotate(const uint8* src_y, int src_stride_y, 45 | const uint8* src_u, int src_stride_u, 46 | const uint8* src_v, int src_stride_v, 47 | uint8* dst_y, int dst_stride_y, 48 | uint8* dst_u, int dst_stride_u, 49 | uint8* dst_v, int dst_stride_v, 50 | int src_width, int src_height, enum RotationMode mode); 51 | 52 | Destination is rotated, so pass dst_stride_y etc that consider rotation.
53 | Rotate by 180 can be done in place, but 90 and 270 can not. 54 | 55 | Implementation (Neon/SSE2) uses 8 x 8 block transpose, so best efficiency is with sizes and pointers that are aligned to 8. 56 | 57 | Cropping can be achieved by adjusting the src_y/u/v pointers and src_width, src_height. 58 | 59 | Lower level plane functions are provided, allowing other planar formats to be rotated. (e.g. I444) 60 | 61 | For other planar YUV formats (I444, I422, I411, I400, NV16, NV24), the planar functions are exposed and can be called directly 62 | 63 | 64 | // Rotate a plane by 0, 90, 180, or 270. 65 | int RotatePlane(const uint8* src, int src_stride, 66 | uint8* dst, int dst_stride, 67 | int src_width, int src_height, enum RotationMode mode); 68 | 69 | # ARGBRotate 70 | 71 | LIBYUV_API 72 | int ARGBRotate(const uint8* src_argb, int src_stride_argb, 73 | uint8* dst_argb, int dst_stride_argb, 74 | int src_width, int src_height, enum RotationMode mode); 75 | 76 | Same as I420, but implementation is less optimized - reads columns and writes rows. 77 | 78 | Rotate by 90, or any angle, can be achieved using ARGBAffine. 79 | 80 | # Mirror - Horizontal Flip 81 | 82 | Mirror functions for horizontally flipping an image, which can be useful for 'self view' of a webcam. 83 | 84 | int I420Mirror(const uint8* src_y, int src_stride_y, 85 | const uint8* src_u, int src_stride_u, 86 | const uint8* src_v, int src_stride_v, 87 | uint8* dst_y, int dst_stride_y, 88 | uint8* dst_u, int dst_stride_u, 89 | uint8* dst_v, int dst_stride_v, 90 | int width, int height); 91 | int ARGBMirror(const uint8* src_argb, int src_stride_argb, 92 | uint8* dst_argb, int dst_stride_argb, 93 | int width, int height); 94 | 95 | Mirror functionality can also be achieved with the I420Scale and ARGBScale functions by passing negative width and/or height. 96 | 97 | # Invert - Vertical Flip 98 | 99 | Inverting can be achieved with almost any libyuv function by passing a negative source height. 100 | 101 | I420Mirror and ARGBMirror can also be used to rotate by 180 degrees by passing a negative height. 102 | 103 | # Cropping - Vertical Flip 104 | 105 | When cropping from a subsampled format like NV21, the method of setting the start pointers wont work for odd crop start y on the UV plane. 106 | If the height after cropping will be odd, invert the source - point to the last row, negate the strides, and pass negative height, which 107 | will re-invert the image as the conversion outputs. 108 | -------------------------------------------------------------------------------- /libyuv/jni/download_vs_toolchain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 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 26 | 27 | 28 | if __name__ == '__main__': 29 | sys.exit(vs_toolchain.main()) 30 | -------------------------------------------------------------------------------- /libyuv/jni/drover.properties: -------------------------------------------------------------------------------- 1 | BASE_URL = "https://libyuv.googlecode.com/svn" 2 | TRUNK_URL = BASE_URL + "/trunk" 3 | BRANCH_URL = BASE_URL + "/branches/$branch" 4 | SKIP_CHECK_WORKING = True 5 | FILE_PATTERN = file_pattern_ = r"[ ]+([MADUC])[ ]+/((?:trunk|branches/.*?)(.*)/(.*))" 6 | PROMPT_FOR_AUTHOR = False 7 | -------------------------------------------------------------------------------- /libyuv/jni/gyp_libyuv: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 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 GYP for libyuv. It contains selected parts of the 12 | # main function from the src/build/gyp_chromium file. 13 | 14 | import glob 15 | import os 16 | import shlex 17 | import sys 18 | 19 | checkout_root = os.path.dirname(os.path.realpath(__file__)) 20 | 21 | sys.path.insert(0, os.path.join(checkout_root, 'build')) 22 | import gyp_chromium 23 | import gyp_helper 24 | import vs_toolchain 25 | 26 | sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib')) 27 | import gyp 28 | 29 | def GetSupplementalFiles(): 30 | """Returns a list of the supplemental files that are included in all GYP 31 | sources.""" 32 | # Can't use the one in gyp_chromium since the directory location of the root 33 | # is different. 34 | return glob.glob(os.path.join(checkout_root, '*', 'supplement.gypi')) 35 | 36 | 37 | if __name__ == '__main__': 38 | args = sys.argv[1:] 39 | 40 | # This could give false positives since it doesn't actually do real option 41 | # parsing. Oh well. 42 | gyp_file_specified = False 43 | for arg in args: 44 | if arg.endswith('.gyp'): 45 | gyp_file_specified = True 46 | break 47 | 48 | # If we didn't get a file, assume 'all.gyp' in the root of the checkout. 49 | if not gyp_file_specified: 50 | # Because of a bug in gyp, simply adding the abspath to all.gyp doesn't 51 | # work, but chdir'ing and adding the relative path does. Spooky :/ 52 | os.chdir(checkout_root) 53 | args.append('all.gyp') 54 | 55 | # There shouldn't be a circular dependency relationship between .gyp files, 56 | args.append('--no-circular-check') 57 | 58 | # Default to ninja unless GYP_GENERATORS is set. 59 | if not os.environ.get('GYP_GENERATORS'): 60 | os.environ['GYP_GENERATORS'] = 'ninja' 61 | 62 | vs2013_runtime_dll_dirs = None 63 | if int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')): 64 | vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() 65 | 66 | # Enforce gyp syntax checking. This adds about 20% execution time. 67 | args.append('--check') 68 | 69 | supplemental_includes = gyp_chromium.GetSupplementalFiles() 70 | gyp_vars_dict = gyp_chromium.GetGypVars(supplemental_includes) 71 | 72 | # Automatically turn on crosscompile support for platforms that need it. 73 | if all(('ninja' in os.environ.get('GYP_GENERATORS', ''), 74 | gyp_vars_dict.get('OS') in ['android', 'ios'], 75 | 'GYP_CROSSCOMPILE' not in os.environ)): 76 | os.environ['GYP_CROSSCOMPILE'] = '1' 77 | 78 | args.extend(['-I' + i for i in 79 | gyp_chromium.additional_include_files(supplemental_includes, 80 | args)]) 81 | 82 | # Set the gyp depth variable to the root of the checkout. 83 | args.append('--depth=' + os.path.relpath(checkout_root)) 84 | 85 | print 'Updating projects from gyp files...' 86 | sys.stdout.flush() 87 | 88 | # Off we go... 89 | gyp_rc = gyp.main(args) 90 | 91 | if vs2013_runtime_dll_dirs: 92 | x64_runtime, x86_runtime = vs2013_runtime_dll_dirs 93 | vs_toolchain.CopyVsRuntimeDlls( 94 | os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()), 95 | (x86_runtime, x64_runtime)) 96 | 97 | sys.exit(gyp_rc) 98 | -------------------------------------------------------------------------------- /libyuv/jni/gyp_libyuv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 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 | 12 | # This script is a modified copy of the src/build/gyp_chromium.py file. 13 | # It is needed for parallel processing. 14 | 15 | # This file is (possibly, depending on python version) imported by 16 | # gyp_libyuv when GYP_PARALLEL=1 and it creates sub-processes 17 | # through the multiprocessing library. 18 | 19 | # Importing in Python 2.6 (fixed in 2.7) on Windows doesn't search for 20 | # imports that don't end in .py (and aren't directories with an 21 | # __init__.py). This wrapper makes "import gyp_libyuv" work with 22 | # those old versions and makes it possible to execute gyp_libyuv.py 23 | # directly on Windows where the extension is useful. 24 | 25 | import os 26 | 27 | path = os.path.abspath(os.path.split(__file__)[0]) 28 | execfile(os.path.join(path, 'gyp_libyuv')) 29 | -------------------------------------------------------------------------------- /libyuv/jni/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_ // NOLINT 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/version.h" 30 | #include "libyuv/video_common.h" 31 | 32 | #endif // INCLUDE_LIBYUV_H_ NOLINT 33 | -------------------------------------------------------------------------------- /libyuv/jni/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_ // NOLINT 12 | #define INCLUDE_LIBYUV_BASIC_TYPES_H_ 13 | 14 | #include // for NULL, size_t 15 | 16 | #if defined(__ANDROID__) || (defined(_MSC_VER) && (_MSC_VER < 1600)) 17 | #include // for uintptr_t on x86 18 | #else 19 | #include // for uintptr_t 20 | #endif 21 | 22 | #ifndef GG_LONGLONG 23 | #ifndef INT_TYPES_DEFINED 24 | #define INT_TYPES_DEFINED 25 | #ifdef COMPILER_MSVC 26 | typedef unsigned __int64 uint64; 27 | typedef __int64 int64; 28 | #ifndef INT64_C 29 | #define INT64_C(x) x ## I64 30 | #endif 31 | #ifndef UINT64_C 32 | #define UINT64_C(x) x ## UI64 33 | #endif 34 | #define INT64_F "I64" 35 | #else // COMPILER_MSVC 36 | #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 37 | typedef unsigned long uint64; // NOLINT 38 | typedef long int64; // NOLINT 39 | #ifndef INT64_C 40 | #define INT64_C(x) x ## L 41 | #endif 42 | #ifndef UINT64_C 43 | #define UINT64_C(x) x ## UL 44 | #endif 45 | #define INT64_F "l" 46 | #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 47 | typedef unsigned long long uint64; // NOLINT 48 | typedef long long int64; // NOLINT 49 | #ifndef INT64_C 50 | #define INT64_C(x) x ## LL 51 | #endif 52 | #ifndef UINT64_C 53 | #define UINT64_C(x) x ## ULL 54 | #endif 55 | #define INT64_F "ll" 56 | #endif // __LP64__ 57 | #endif // COMPILER_MSVC 58 | typedef unsigned int uint32; 59 | typedef int int32; 60 | typedef unsigned short uint16; // NOLINT 61 | typedef short int16; // NOLINT 62 | typedef unsigned char uint8; 63 | typedef signed char int8; 64 | #endif // INT_TYPES_DEFINED 65 | #endif // GG_LONGLONG 66 | 67 | // Detect compiler is for x86 or x64. 68 | #if defined(__x86_64__) || defined(_M_X64) || \ 69 | defined(__i386__) || defined(_M_IX86) 70 | #define CPU_X86 1 71 | #endif 72 | // Detect compiler is for ARM. 73 | #if defined(__arm__) || defined(_M_ARM) 74 | #define CPU_ARM 1 75 | #endif 76 | 77 | #ifndef ALIGNP 78 | #ifdef __cplusplus 79 | #define ALIGNP(p, t) \ 80 | (reinterpret_cast(((reinterpret_cast(p) + \ 81 | ((t) - 1)) & ~((t) - 1)))) 82 | #else 83 | #define ALIGNP(p, t) \ 84 | ((uint8*)((((uintptr_t)(p) + ((t) - 1)) & ~((t) - 1)))) /* NOLINT */ 85 | #endif 86 | #endif 87 | 88 | #if !defined(LIBYUV_API) 89 | #if defined(_WIN32) || defined(__CYGWIN__) 90 | #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) 91 | #define LIBYUV_API __declspec(dllexport) 92 | #elif defined(LIBYUV_USING_SHARED_LIBRARY) 93 | #define LIBYUV_API __declspec(dllimport) 94 | #else 95 | #define LIBYUV_API 96 | #endif // LIBYUV_BUILDING_SHARED_LIBRARY 97 | #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ 98 | (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ 99 | defined(LIBYUV_USING_SHARED_LIBRARY)) 100 | #define LIBYUV_API __attribute__ ((visibility ("default"))) 101 | #else 102 | #define LIBYUV_API 103 | #endif // __GNUC__ 104 | #endif // LIBYUV_API 105 | 106 | #define LIBYUV_BOOL int 107 | #define LIBYUV_FALSE 0 108 | #define LIBYUV_TRUE 1 109 | 110 | // Visual C x86 or GCC little endian. 111 | #if defined(__x86_64__) || defined(_M_X64) || \ 112 | defined(__i386__) || defined(_M_IX86) || \ 113 | defined(__arm__) || defined(_M_ARM) || \ 114 | (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 115 | #define LIBYUV_LITTLE_ENDIAN 116 | #endif 117 | 118 | #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ NOLINT 119 | -------------------------------------------------------------------------------- /libyuv/jni/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_ // NOLINT 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 HashDjb2(const uint8* src, uint64 count, uint32 seed); 24 | 25 | // Scan an opaque argb image and return fourcc based on alpha offset. 26 | // Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown. 27 | LIBYUV_API 28 | uint32 ARGBDetect(const uint8* argb, int stride_argb, int width, int height); 29 | 30 | // Sum Square Error - used to compute Mean Square Error or PSNR. 31 | LIBYUV_API 32 | uint64 ComputeSumSquareError(const uint8* src_a, 33 | const uint8* src_b, int count); 34 | 35 | LIBYUV_API 36 | uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a, 37 | const uint8* src_b, int stride_b, 38 | int width, int height); 39 | 40 | static const int kMaxPsnr = 128; 41 | 42 | LIBYUV_API 43 | double SumSquareErrorToPsnr(uint64 sse, uint64 count); 44 | 45 | LIBYUV_API 46 | double CalcFramePsnr(const uint8* src_a, int stride_a, 47 | const uint8* src_b, int stride_b, 48 | int width, int height); 49 | 50 | LIBYUV_API 51 | double I420Psnr(const uint8* src_y_a, int stride_y_a, 52 | const uint8* src_u_a, int stride_u_a, 53 | const uint8* src_v_a, int stride_v_a, 54 | const uint8* src_y_b, int stride_y_b, 55 | const uint8* src_u_b, int stride_u_b, 56 | const uint8* src_v_b, int stride_v_b, 57 | int width, int height); 58 | 59 | LIBYUV_API 60 | double CalcFrameSsim(const uint8* src_a, int stride_a, 61 | const uint8* src_b, int stride_b, 62 | int width, int height); 63 | 64 | LIBYUV_API 65 | double I420Ssim(const uint8* src_y_a, int stride_y_a, 66 | const uint8* src_u_a, int stride_u_a, 67 | const uint8* src_v_a, int stride_v_a, 68 | const uint8* src_y_b, int stride_y_b, 69 | const uint8* src_u_b, int stride_u_b, 70 | const uint8* src_v_b, int stride_v_b, 71 | int width, int height); 72 | 73 | #ifdef __cplusplus 74 | } // extern "C" 75 | } // namespace libyuv 76 | #endif 77 | 78 | #endif // INCLUDE_LIBYUV_COMPARE_H_ NOLINT 79 | -------------------------------------------------------------------------------- /libyuv/jni/include/libyuv/cpu_id.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_CPU_ID_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_CPU_ID_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // TODO(fbarchard): Consider overlapping bits for different architectures. 22 | // Internal flag to indicate cpuid requires initialization. 23 | #define kCpuInit 0x1 24 | 25 | // These flags are only valid on ARM processors. 26 | static const int kCpuHasARM = 0x2; 27 | static const int kCpuHasNEON = 0x4; 28 | // 0x8 reserved for future ARM flag. 29 | 30 | // These flags are only valid on x86 processors. 31 | static const int kCpuHasX86 = 0x10; 32 | static const int kCpuHasSSE2 = 0x20; 33 | static const int kCpuHasSSSE3 = 0x40; 34 | static const int kCpuHasSSE41 = 0x80; 35 | static const int kCpuHasSSE42 = 0x100; 36 | static const int kCpuHasAVX = 0x200; 37 | static const int kCpuHasAVX2 = 0x400; 38 | static const int kCpuHasERMS = 0x800; 39 | static const int kCpuHasFMA3 = 0x1000; 40 | // 0x2000, 0x4000, 0x8000 reserved for future X86 flags. 41 | 42 | // These flags are only valid on MIPS processors. 43 | static const int kCpuHasMIPS = 0x10000; 44 | static const int kCpuHasMIPS_DSP = 0x20000; 45 | static const int kCpuHasMIPS_DSPR2 = 0x40000; 46 | 47 | // Internal function used to auto-init. 48 | LIBYUV_API 49 | int InitCpuFlags(void); 50 | 51 | // Internal function for parsing /proc/cpuinfo. 52 | LIBYUV_API 53 | int ArmCpuCaps(const char* cpuinfo_name); 54 | 55 | // Detect CPU has SSE2 etc. 56 | // Test_flag parameter should be one of kCpuHas constants above. 57 | // returns non-zero if instruction set is detected 58 | static __inline int TestCpuFlag(int test_flag) { 59 | LIBYUV_API extern int cpu_info_; 60 | return (cpu_info_ == kCpuInit ? InitCpuFlags() : cpu_info_) & test_flag; 61 | } 62 | 63 | // For testing, allow CPU flags to be disabled. 64 | // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. 65 | // MaskCpuFlags(-1) to enable all cpu specific optimizations. 66 | // MaskCpuFlags(0) to disable all cpu specific optimizations. 67 | LIBYUV_API 68 | void MaskCpuFlags(int enable_flags); 69 | 70 | // Low level cpuid for X86. Returns zeros on other CPUs. 71 | // eax is the info type that you want. 72 | // ecx is typically the cpu number, and should normally be zero. 73 | LIBYUV_API 74 | void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info); 75 | 76 | #ifdef __cplusplus 77 | } // extern "C" 78 | } // namespace libyuv 79 | #endif 80 | 81 | #endif // INCLUDE_LIBYUV_CPU_ID_H_ NOLINT 82 | -------------------------------------------------------------------------------- /libyuv/jni/include/libyuv/rotate.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_ROTATE_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_ROTATE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Supported rotation. 22 | typedef enum RotationMode { 23 | kRotate0 = 0, // No rotation. 24 | kRotate90 = 90, // Rotate 90 degrees clockwise. 25 | kRotate180 = 180, // Rotate 180 degrees. 26 | kRotate270 = 270, // Rotate 270 degrees clockwise. 27 | 28 | // Deprecated. 29 | kRotateNone = 0, 30 | kRotateClockwise = 90, 31 | kRotateCounterClockwise = 270, 32 | } RotationModeEnum; 33 | 34 | // Rotate I420 frame. 35 | LIBYUV_API 36 | int I420Rotate(const uint8* src_y, int src_stride_y, 37 | const uint8* src_u, int src_stride_u, 38 | const uint8* src_v, int src_stride_v, 39 | uint8* dst_y, int dst_stride_y, 40 | uint8* dst_u, int dst_stride_u, 41 | uint8* dst_v, int dst_stride_v, 42 | int src_width, int src_height, enum RotationMode mode); 43 | 44 | // Rotate NV12 input and store in I420. 45 | LIBYUV_API 46 | int NV12ToI420Rotate(const uint8* src_y, int src_stride_y, 47 | const uint8* src_uv, int src_stride_uv, 48 | uint8* dst_y, int dst_stride_y, 49 | uint8* dst_u, int dst_stride_u, 50 | uint8* dst_v, int dst_stride_v, 51 | int src_width, int src_height, enum RotationMode mode); 52 | 53 | // Rotate a plane by 0, 90, 180, or 270. 54 | LIBYUV_API 55 | int RotatePlane(const uint8* src, int src_stride, 56 | uint8* dst, int dst_stride, 57 | int src_width, int src_height, enum RotationMode mode); 58 | 59 | // Rotate planes by 90, 180, 270. Deprecated. 60 | LIBYUV_API 61 | void RotatePlane90(const uint8* src, int src_stride, 62 | uint8* dst, int dst_stride, 63 | int width, int height); 64 | 65 | LIBYUV_API 66 | void RotatePlane180(const uint8* src, int src_stride, 67 | uint8* dst, int dst_stride, 68 | int width, int height); 69 | 70 | LIBYUV_API 71 | void RotatePlane270(const uint8* src, int src_stride, 72 | uint8* dst, int dst_stride, 73 | int width, int height); 74 | 75 | LIBYUV_API 76 | void RotateUV90(const uint8* src, int src_stride, 77 | uint8* dst_a, int dst_stride_a, 78 | uint8* dst_b, int dst_stride_b, 79 | int width, int height); 80 | 81 | // Rotations for when U and V are interleaved. 82 | // These functions take one input pointer and 83 | // split the data into two buffers while 84 | // rotating them. Deprecated. 85 | LIBYUV_API 86 | void RotateUV180(const uint8* src, int src_stride, 87 | uint8* dst_a, int dst_stride_a, 88 | uint8* dst_b, int dst_stride_b, 89 | int width, int height); 90 | 91 | LIBYUV_API 92 | void RotateUV270(const uint8* src, int src_stride, 93 | uint8* dst_a, int dst_stride_a, 94 | uint8* dst_b, int dst_stride_b, 95 | int width, int height); 96 | 97 | // The 90 and 270 functions are based on transposes. 98 | // Doing a transpose with reversing the read/write 99 | // order will result in a rotation by +- 90 degrees. 100 | // Deprecated. 101 | LIBYUV_API 102 | void TransposePlane(const uint8* src, int src_stride, 103 | uint8* dst, int dst_stride, 104 | int width, int height); 105 | 106 | LIBYUV_API 107 | void TransposeUV(const uint8* src, int src_stride, 108 | uint8* dst_a, int dst_stride_a, 109 | uint8* dst_b, int dst_stride_b, 110 | int width, int height); 111 | 112 | #ifdef __cplusplus 113 | } // extern "C" 114 | } // namespace libyuv 115 | #endif 116 | 117 | #endif // INCLUDE_LIBYUV_ROTATE_H_ NOLINT 118 | -------------------------------------------------------------------------------- /libyuv/jni/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_ // NOLINT 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* src_argb, int src_stride_argb, 25 | uint8* dst_argb, int dst_stride_argb, 26 | int src_width, int src_height, enum RotationMode mode); 27 | 28 | #ifdef __cplusplus 29 | } // extern "C" 30 | } // namespace libyuv 31 | #endif 32 | 33 | #endif // INCLUDE_LIBYUV_ROTATE_ARGB_H_ NOLINT 34 | -------------------------------------------------------------------------------- /libyuv/jni/include/libyuv/scale.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_SCALE_H_ // NOLINT 12 | #define INCLUDE_LIBYUV_SCALE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Supported filtering. 22 | typedef enum FilterMode { 23 | kFilterNone = 0, // Point sample; Fastest. 24 | kFilterLinear = 1, // Filter horizontally only. 25 | kFilterBilinear = 2, // Faster than box, but lower quality scaling down. 26 | kFilterBox = 3 // Highest quality. 27 | } FilterModeEnum; 28 | 29 | // Scale a YUV plane. 30 | LIBYUV_API 31 | void ScalePlane(const uint8* src, int src_stride, 32 | int src_width, int src_height, 33 | uint8* dst, int dst_stride, 34 | int dst_width, int dst_height, 35 | enum FilterMode filtering); 36 | 37 | LIBYUV_API 38 | void ScalePlane_16(const uint16* src, int src_stride, 39 | int src_width, int src_height, 40 | uint16* dst, int dst_stride, 41 | int dst_width, int dst_height, 42 | enum FilterMode filtering); 43 | 44 | // Scales a YUV 4:2:0 image from the src width and height to the 45 | // dst width and height. 46 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is 47 | // used. This produces basic (blocky) quality at the fastest speed. 48 | // If filtering is kFilterBilinear, interpolation is used to produce a better 49 | // quality image, at the expense of speed. 50 | // If filtering is kFilterBox, averaging is used to produce ever better 51 | // quality image, at further expense of speed. 52 | // Returns 0 if successful. 53 | 54 | LIBYUV_API 55 | int I420Scale(const uint8* src_y, int src_stride_y, 56 | const uint8* src_u, int src_stride_u, 57 | const uint8* src_v, int src_stride_v, 58 | int src_width, int src_height, 59 | uint8* dst_y, int dst_stride_y, 60 | uint8* dst_u, int dst_stride_u, 61 | uint8* dst_v, int dst_stride_v, 62 | int dst_width, int dst_height, 63 | enum FilterMode filtering); 64 | 65 | LIBYUV_API 66 | int I420Scale_16(const uint16* src_y, int src_stride_y, 67 | const uint16* src_u, int src_stride_u, 68 | const uint16* src_v, int src_stride_v, 69 | int src_width, int src_height, 70 | uint16* dst_y, int dst_stride_y, 71 | uint16* dst_u, int dst_stride_u, 72 | uint16* dst_v, int dst_stride_v, 73 | int dst_width, int dst_height, 74 | enum FilterMode filtering); 75 | 76 | #ifdef __cplusplus 77 | // Legacy API. Deprecated. 78 | LIBYUV_API 79 | int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, 80 | int src_stride_y, int src_stride_u, int src_stride_v, 81 | int src_width, int src_height, 82 | uint8* dst_y, uint8* dst_u, uint8* dst_v, 83 | int dst_stride_y, int dst_stride_u, int dst_stride_v, 84 | int dst_width, int dst_height, 85 | LIBYUV_BOOL interpolate); 86 | 87 | // Legacy API. Deprecated. 88 | LIBYUV_API 89 | int ScaleOffset(const uint8* src_i420, int src_width, int src_height, 90 | uint8* dst_i420, int dst_width, int dst_height, int dst_yoffset, 91 | LIBYUV_BOOL interpolate); 92 | 93 | // For testing, allow disabling of specialized scalers. 94 | LIBYUV_API 95 | void SetUseReferenceImpl(LIBYUV_BOOL use); 96 | #endif // __cplusplus 97 | 98 | #ifdef __cplusplus 99 | } // extern "C" 100 | } // namespace libyuv 101 | #endif 102 | 103 | #endif // INCLUDE_LIBYUV_SCALE_H_ NOLINT 104 | -------------------------------------------------------------------------------- /libyuv/jni/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_ // NOLINT 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* src_argb, int src_stride_argb, 24 | int src_width, int src_height, 25 | uint8* dst_argb, int dst_stride_argb, 26 | int dst_width, int dst_height, 27 | enum FilterMode filtering); 28 | 29 | // Clipped scale takes destination rectangle coordinates for clip values. 30 | LIBYUV_API 31 | int ARGBScaleClip(const uint8* src_argb, int src_stride_argb, 32 | int src_width, int src_height, 33 | uint8* dst_argb, int dst_stride_argb, 34 | int dst_width, int dst_height, 35 | int clip_x, int clip_y, int clip_width, int clip_height, 36 | enum FilterMode filtering); 37 | 38 | // TODO(fbarchard): Implement this. 39 | // Scale with YUV conversion to ARGB and clipping. 40 | LIBYUV_API 41 | int YUVToARGBScaleClip(const uint8* src_y, int src_stride_y, 42 | const uint8* src_u, int src_stride_u, 43 | const uint8* src_v, int src_stride_v, 44 | uint32 src_fourcc, 45 | int src_width, int src_height, 46 | uint8* dst_argb, int dst_stride_argb, 47 | uint32 dst_fourcc, 48 | int dst_width, int dst_height, 49 | int clip_x, int clip_y, int clip_width, int clip_height, 50 | enum FilterMode filtering); 51 | 52 | #ifdef __cplusplus 53 | } // extern "C" 54 | } // namespace libyuv 55 | #endif 56 | 57 | #endif // INCLUDE_LIBYUV_SCALE_ARGB_H_ NOLINT 58 | -------------------------------------------------------------------------------- /libyuv/jni/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_ // NOLINT 12 | #define INCLUDE_LIBYUV_VERSION_H_ 13 | 14 | #define LIBYUV_VERSION 1419 15 | 16 | #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT 17 | -------------------------------------------------------------------------------- /libyuv/jni/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/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/version.h', 30 | 'include/libyuv/video_common.h', 31 | 32 | # sources. 33 | 'source/compare.cc', 34 | 'source/compare_common.cc', 35 | 'source/compare_gcc.cc', 36 | 'source/compare_win.cc', 37 | 'source/convert.cc', 38 | 'source/convert_argb.cc', 39 | 'source/convert_from.cc', 40 | 'source/convert_from_argb.cc', 41 | 'source/convert_jpeg.cc', 42 | 'source/convert_to_argb.cc', 43 | 'source/convert_to_i420.cc', 44 | 'source/cpu_id.cc', 45 | 'source/mjpeg_decoder.cc', 46 | 'source/mjpeg_validate.cc', 47 | 'source/planar_functions.cc', 48 | 'source/rotate.cc', 49 | 'source/rotate_argb.cc', 50 | 'source/rotate_mips.cc', 51 | 'source/row_any.cc', 52 | 'source/row_common.cc', 53 | 'source/row_mips.cc', 54 | 'source/row_gcc.cc', 55 | 'source/row_win.cc', 56 | 'source/scale.cc', 57 | 'source/scale_argb.cc', 58 | 'source/scale_any.cc', 59 | 'source/scale_common.cc', 60 | 'source/scale_mips.cc', 61 | 'source/scale_gcc.cc', 62 | 'source/scale_win.cc', 63 | 'source/video_common.cc', 64 | ], 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /libyuv/jni/libyuv_nacl.gyp: -------------------------------------------------------------------------------- 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 | 'includes': [ 11 | 'libyuv.gypi', 12 | '../../native_client/build/untrusted.gypi', 13 | ], 14 | 'targets': [ 15 | { 16 | 'target_name': 'libyuv_nacl', 17 | 'type': 'none', 18 | 'variables': { 19 | 'nlib_target': 'libyuv_nacl.a', 20 | 'build_glibc': 0, 21 | 'build_newlib': 0, 22 | 'build_pnacl_newlib': 1, 23 | }, 24 | 'include_dirs': [ 25 | 'include', 26 | ], 27 | 'direct_dependent_settings': { 28 | 'include_dirs': [ 29 | 'include', 30 | ], 31 | }, 32 | 'sources': [ 33 | '<@(libyuv_sources)', 34 | ], 35 | }, # target libyuv_nacl 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /libyuv/jni/libyuv_test.gyp: -------------------------------------------------------------------------------- 1 | # Copyright 2011 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_disable_jpeg%': 0, 12 | 'libyuv_enable_svn%': 0, 13 | }, 14 | 'targets': [ 15 | { 16 | 'target_name': 'libyuv_unittest', 17 | 'type': 'executable', 18 | 'dependencies': [ 19 | 'libyuv.gyp:libyuv', 20 | # The tests are based on gtest 21 | 'testing/gtest.gyp:gtest', 22 | 'testing/gtest.gyp:gtest_main', 23 | ], 24 | 'defines': [ 25 | # Enable the following 3 macros to turn off assembly for specified CPU. 26 | # 'LIBYUV_DISABLE_X86', 27 | # 'LIBYUV_DISABLE_NEON', 28 | # 'LIBYUV_DISABLE_MIPS', 29 | # Enable the following macro to build libyuv as a shared library (dll). 30 | # 'LIBYUV_USING_SHARED_LIBRARY', 31 | ], 32 | 'sources': [ 33 | # headers 34 | 'unit_test/unit_test.h', 35 | 36 | # sources 37 | 'unit_test/basictypes_test.cc', 38 | 'unit_test/compare_test.cc', 39 | 'unit_test/color_test.cc', 40 | 'unit_test/convert_test.cc', 41 | 'unit_test/cpu_test.cc', 42 | 'unit_test/math_test.cc', 43 | 'unit_test/planar_test.cc', 44 | 'unit_test/rotate_argb_test.cc', 45 | 'unit_test/rotate_test.cc', 46 | 'unit_test/scale_argb_test.cc', 47 | 'unit_test/scale_color_test.cc', 48 | 'unit_test/scale_test.cc', 49 | 'unit_test/unit_test.cc', 50 | 'unit_test/video_common_test.cc', 51 | 'unit_test/version_test.cc', 52 | ], 53 | 'conditions': [ 54 | [ 'libyuv_enable_svn == 1', { 55 | 'defines': [ 56 | 'LIBYUV_SVNREVISION="= 7) \ 84 | or target_arch == "arm64") \ 85 | and (arm_neon == 1 or arm_neon_optional == 1)', { 86 | 'defines': [ 87 | 'LIBYUV_NEON' 88 | ], 89 | }], 90 | ], # conditions 91 | }, 92 | 93 | { 94 | 'target_name': 'compare', 95 | 'type': 'executable', 96 | 'dependencies': [ 97 | 'libyuv.gyp:libyuv', 98 | ], 99 | 'sources': [ 100 | # sources 101 | 'util/compare.cc', 102 | ], 103 | 'conditions': [ 104 | ['OS=="linux"', { 105 | 'cflags': [ 106 | '-fexceptions', 107 | ], 108 | }], 109 | ], # conditions 110 | }, 111 | { 112 | 'target_name': 'convert', 113 | 'type': 'executable', 114 | 'dependencies': [ 115 | 'libyuv.gyp:libyuv', 116 | ], 117 | 'sources': [ 118 | # sources 119 | 'util/convert.cc', 120 | ], 121 | 'conditions': [ 122 | ['OS=="linux"', { 123 | 'cflags': [ 124 | '-fexceptions', 125 | ], 126 | }], 127 | ], # conditions 128 | }, 129 | # TODO(fbarchard): Enable SSE2 and OpenMP for better performance. 130 | { 131 | 'target_name': 'psnr', 132 | 'type': 'executable', 133 | 'sources': [ 134 | # sources 135 | 'util/psnr_main.cc', 136 | 'util/psnr.cc', 137 | 'util/ssim.cc', 138 | ], 139 | 'dependencies': [ 140 | 'libyuv.gyp:libyuv', 141 | ], 142 | 'conditions': [ 143 | [ 'OS == "ios" and target_subarch == 64', { 144 | 'defines': [ 145 | 'LIBYUV_DISABLE_NEON' 146 | ], 147 | }], 148 | 149 | [ 'OS != "ios" and libyuv_disable_jpeg != 1', { 150 | 'defines': [ 151 | 'HAVE_JPEG', 152 | ], 153 | }], 154 | ], # conditions 155 | }, 156 | 157 | { 158 | 'target_name': 'cpuid', 159 | 'type': 'executable', 160 | 'sources': [ 161 | # sources 162 | 'util/cpuid.c', 163 | ], 164 | 'dependencies': [ 165 | 'libyuv.gyp:libyuv', 166 | ], 167 | }, 168 | ], # targets 169 | } 170 | 171 | # Local Variables: 172 | # tab-width:2 173 | # indent-tabs-mode:nil 174 | # End: 175 | # vim: set expandtab tabstop=2 shiftwidth=2: 176 | -------------------------------------------------------------------------------- /libyuv/jni/linux.mk: -------------------------------------------------------------------------------- 1 | # This is a generic makefile for libyuv for gcc. 2 | # make -f linux.mk CXX=clang++ 3 | 4 | CXX?=g++ 5 | CXXFLAGS?=-O2 -fomit-frame-pointer 6 | CXXFLAGS+=-Iinclude/ 7 | 8 | LOCAL_OBJ_FILES := \ 9 | source/compare.o \ 10 | source/compare_common.o \ 11 | source/compare_gcc.o \ 12 | source/convert.o \ 13 | source/convert_argb.o \ 14 | source/convert_from.o \ 15 | source/convert_from_argb.o \ 16 | source/convert_to_argb.o \ 17 | source/convert_to_i420.o \ 18 | source/cpu_id.o \ 19 | source/planar_functions.o \ 20 | source/rotate.o \ 21 | source/rotate_argb.o \ 22 | source/rotate_mips.o \ 23 | source/row_any.o \ 24 | source/row_common.o \ 25 | source/row_mips.o \ 26 | source/row_gcc.o \ 27 | source/scale.o \ 28 | source/scale_argb.o \ 29 | source/scale_common.o \ 30 | source/scale_mips.o \ 31 | source/scale_gcc.o \ 32 | source/video_common.o 33 | 34 | .cc.o: 35 | $(CXX) -c $(CXXFLAGS) $*.cc -o $*.o 36 | 37 | all: libyuv.a convert 38 | 39 | libyuv.a: $(LOCAL_OBJ_FILES) 40 | $(AR) $(ARFLAGS) $@ $(LOCAL_OBJ_FILES) 41 | 42 | # A test utility that uses libyuv conversion. 43 | convert: util/convert.cc libyuv.a 44 | $(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/convert.cc libyuv.a 45 | 46 | clean: 47 | /bin/rm -f source/*.o *.ii *.s libyuv.a convert 48 | 49 | -------------------------------------------------------------------------------- /libyuv/jni/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 | -------------------------------------------------------------------------------- /libyuv/jni/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 | #ifdef __cplusplus 14 | namespace libyuv { 15 | extern "C" { 16 | #endif 17 | 18 | uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count) { 19 | uint32 sse = 0u; 20 | int i; 21 | for (i = 0; i < count; ++i) { 22 | int diff = src_a[i] - src_b[i]; 23 | sse += (uint32)(diff * diff); 24 | } 25 | return sse; 26 | } 27 | 28 | // hash seed of 5381 recommended. 29 | // Internal C version of HashDjb2 with int sized count for efficiency. 30 | uint32 HashDjb2_C(const uint8* src, int count, uint32 seed) { 31 | uint32 hash = seed; 32 | int i; 33 | for (i = 0; i < count; ++i) { 34 | hash += (hash << 5) + src[i]; 35 | } 36 | return hash; 37 | } 38 | 39 | #ifdef __cplusplus 40 | } // extern "C" 41 | } // namespace libyuv 42 | #endif 43 | -------------------------------------------------------------------------------- /libyuv/jni/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 | #include "libyuv/row.h" 13 | 14 | #ifdef __cplusplus 15 | namespace libyuv { 16 | extern "C" { 17 | #endif 18 | 19 | #if !defined(LIBYUV_DISABLE_NEON) && defined(__ARM_NEON__) && \ 20 | !defined(__aarch64__) 21 | 22 | uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count) { 23 | volatile uint32 sse; 24 | asm volatile ( 25 | "vmov.u8 q8, #0 \n" 26 | "vmov.u8 q10, #0 \n" 27 | "vmov.u8 q9, #0 \n" 28 | "vmov.u8 q11, #0 \n" 29 | 30 | ".p2align 2 \n" 31 | "1: \n" 32 | MEMACCESS(0) 33 | "vld1.8 {q0}, [%0]! \n" 34 | MEMACCESS(1) 35 | "vld1.8 {q1}, [%1]! \n" 36 | "subs %2, %2, #16 \n" 37 | "vsubl.u8 q2, d0, d2 \n" 38 | "vsubl.u8 q3, d1, d3 \n" 39 | "vmlal.s16 q8, d4, d4 \n" 40 | "vmlal.s16 q9, d6, d6 \n" 41 | "vmlal.s16 q10, d5, d5 \n" 42 | "vmlal.s16 q11, d7, d7 \n" 43 | "bgt 1b \n" 44 | 45 | "vadd.u32 q8, q8, q9 \n" 46 | "vadd.u32 q10, q10, q11 \n" 47 | "vadd.u32 q11, q8, q10 \n" 48 | "vpaddl.u32 q1, q11 \n" 49 | "vadd.u64 d0, d2, d3 \n" 50 | "vmov.32 %3, d0[0] \n" 51 | : "+r"(src_a), 52 | "+r"(src_b), 53 | "+r"(count), 54 | "=r"(sse) 55 | : 56 | : "memory", "cc", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11"); 57 | return sse; 58 | } 59 | 60 | #endif // defined(__ARM_NEON__) && !defined(__aarch64__) 61 | 62 | #ifdef __cplusplus 63 | } // extern "C" 64 | } // namespace libyuv 65 | #endif 66 | -------------------------------------------------------------------------------- /libyuv/jni/source/compare_neon64.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 | #include "libyuv/row.h" 13 | 14 | #ifdef __cplusplus 15 | namespace libyuv { 16 | extern "C" { 17 | #endif 18 | 19 | #if !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__) 20 | 21 | uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count) { 22 | volatile uint32 sse; 23 | asm volatile ( 24 | "eor v16.16b, v16.16b, v16.16b \n" 25 | "eor v18.16b, v18.16b, v18.16b \n" 26 | "eor v17.16b, v17.16b, v17.16b \n" 27 | "eor v19.16b, v19.16b, v19.16b \n" 28 | 29 | ".p2align 2 \n" 30 | "1: \n" 31 | MEMACCESS(0) 32 | "ld1 {v0.16b}, [%0], #16 \n" 33 | MEMACCESS(1) 34 | "ld1 {v1.16b}, [%1], #16 \n" 35 | "subs %w2, %w2, #16 \n" 36 | "usubl v2.8h, v0.8b, v1.8b \n" 37 | "usubl2 v3.8h, v0.16b, v1.16b \n" 38 | "smlal v16.4s, v2.4h, v2.4h \n" 39 | "smlal v17.4s, v3.4h, v3.4h \n" 40 | "smlal2 v18.4s, v2.8h, v2.8h \n" 41 | "smlal2 v19.4s, v3.8h, v3.8h \n" 42 | "b.gt 1b \n" 43 | 44 | "add v16.4s, v16.4s, v17.4s \n" 45 | "add v18.4s, v18.4s, v19.4s \n" 46 | "add v19.4s, v16.4s, v18.4s \n" 47 | "addv s0, v19.4s \n" 48 | "fmov %w3, s0 \n" 49 | : "+r"(src_a), 50 | "+r"(src_b), 51 | "+r"(count), 52 | "=r"(sse) 53 | : 54 | : "cc", "v0", "v1", "v2", "v3", "v16", "v17", "v18", "v19"); 55 | return sse; 56 | } 57 | 58 | #endif // !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__) 59 | 60 | #ifdef __cplusplus 61 | } // extern "C" 62 | } // namespace libyuv 63 | #endif 64 | -------------------------------------------------------------------------------- /libyuv/jni/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 | // Enable this to try scasb implementation. 21 | // #define ENABLE_SCASB 1 22 | 23 | #ifdef ENABLE_SCASB 24 | 25 | // Multiple of 1. 26 | __declspec(naked) 27 | const uint8* ScanRow_ERMS(const uint8* src, uint32 val, int count) { 28 | __asm { 29 | mov edx, edi 30 | mov edi, [esp + 4] // src 31 | mov eax, [esp + 8] // val 32 | mov ecx, [esp + 12] // count 33 | repne scasb 34 | jne sr99 35 | mov eax, edi 36 | sub eax, 1 37 | mov edi, edx 38 | ret 39 | 40 | sr99: 41 | mov eax, 0 42 | mov edi, edx 43 | ret 44 | } 45 | } 46 | #endif 47 | 48 | // Helper function to scan for EOI marker. 49 | static LIBYUV_BOOL ScanEOI(const uint8* sample, size_t sample_size) { 50 | const uint8* end = sample + sample_size - 1; 51 | const uint8* it = sample; 52 | for (;;) { 53 | #ifdef ENABLE_SCASB 54 | it = ScanRow_ERMS(it, 0xff, end - it); 55 | #else 56 | it = static_cast(memchr(it, 0xff, end - it)); 57 | #endif 58 | if (it == NULL) { 59 | break; 60 | } 61 | if (it[1] == 0xd9) { 62 | return LIBYUV_TRUE; // Success: Valid jpeg. 63 | } 64 | ++it; // Skip over current 0xff. 65 | } 66 | // ERROR: Invalid jpeg end code not found. Size sample_size 67 | return LIBYUV_FALSE; 68 | } 69 | 70 | // Helper function to validate the jpeg appears intact. 71 | LIBYUV_BOOL ValidateJpeg(const uint8* sample, size_t sample_size) { 72 | const size_t kBackSearchSize = 1024; 73 | if (sample_size < 64) { 74 | // ERROR: Invalid jpeg size: sample_size 75 | return LIBYUV_FALSE; 76 | } 77 | if (sample[0] != 0xff || sample[1] != 0xd8) { // Start Of Image 78 | // ERROR: Invalid jpeg initial start code 79 | return LIBYUV_FALSE; 80 | } 81 | // Step over SOI marker. 82 | sample += 2; 83 | sample_size -= 2; 84 | 85 | // Look for the End Of Image (EOI) marker in the end kilobyte of the buffer. 86 | if (sample_size > kBackSearchSize) { 87 | if (ScanEOI(sample + sample_size - kBackSearchSize, kBackSearchSize)) { 88 | return LIBYUV_TRUE; // Success: Valid jpeg. 89 | } 90 | // Reduce search size for forward search. 91 | sample_size = sample_size - kBackSearchSize + 1; 92 | } 93 | return ScanEOI(sample, sample_size); 94 | 95 | } 96 | 97 | #ifdef __cplusplus 98 | } // extern "C" 99 | } // namespace libyuv 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /libyuv/jni/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 | 12 | #include "libyuv/video_common.h" 13 | 14 | #ifdef __cplusplus 15 | namespace libyuv { 16 | extern "C" { 17 | #endif 18 | 19 | #define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0])) 20 | 21 | struct FourCCAliasEntry { 22 | uint32 alias; 23 | uint32 canonical; 24 | }; 25 | 26 | static const struct FourCCAliasEntry kFourCCAliases[] = { 27 | {FOURCC_IYUV, FOURCC_I420}, 28 | {FOURCC_YU16, FOURCC_I422}, 29 | {FOURCC_YU24, FOURCC_I444}, 30 | {FOURCC_YUYV, FOURCC_YUY2}, 31 | {FOURCC_YUVS, FOURCC_YUY2}, // kCMPixelFormat_422YpCbCr8_yuvs 32 | {FOURCC_HDYC, FOURCC_UYVY}, 33 | {FOURCC_2VUY, FOURCC_UYVY}, // kCMPixelFormat_422YpCbCr8 34 | {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. 35 | {FOURCC_DMB1, FOURCC_MJPG}, 36 | {FOURCC_BA81, FOURCC_BGGR}, // deprecated. 37 | {FOURCC_RGB3, FOURCC_RAW }, 38 | {FOURCC_BGR3, FOURCC_24BG}, 39 | {FOURCC_CM32, FOURCC_BGRA}, // kCMPixelFormat_32ARGB 40 | {FOURCC_CM24, FOURCC_RAW }, // kCMPixelFormat_24RGB 41 | {FOURCC_L555, FOURCC_RGBO}, // kCMPixelFormat_16LE555 42 | {FOURCC_L565, FOURCC_RGBP}, // kCMPixelFormat_16LE565 43 | {FOURCC_5551, FOURCC_RGBO}, // kCMPixelFormat_16LE5551 44 | }; 45 | // TODO(fbarchard): Consider mapping kCMPixelFormat_32BGRA to FOURCC_ARGB. 46 | // {FOURCC_BGRA, FOURCC_ARGB}, // kCMPixelFormat_32BGRA 47 | 48 | LIBYUV_API 49 | uint32 CanonicalFourCC(uint32 fourcc) { 50 | int i; 51 | for (i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) { 52 | if (kFourCCAliases[i].alias == fourcc) { 53 | return kFourCCAliases[i].canonical; 54 | } 55 | } 56 | // Not an alias, so return it as-is. 57 | return fourcc; 58 | } 59 | 60 | #ifdef __cplusplus 61 | } // extern "C" 62 | } // namespace libyuv 63 | #endif 64 | 65 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/libyuv_tests.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: Copyright (c) 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 | :: This script is a copy of chrome_tests.bat with the following changes: 11 | :: - Invokes libyuv_tests.py instead of chrome_tests.py 12 | :: - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make 13 | :: it possible to execute the Python scripts properly. 14 | 15 | :: TODO(timurrrr): batch files 'export' all the variables to the parent shell 16 | set THISDIR=%~dp0 17 | set TOOL_NAME="unknown" 18 | 19 | :: Get the tool name and put it into TOOL_NAME {{{1 20 | :: NB: SHIFT command doesn't modify %* 21 | :PARSE_ARGS_LOOP 22 | if %1 == () GOTO:TOOLNAME_NOT_FOUND 23 | if %1 == --tool GOTO:TOOLNAME_FOUND 24 | SHIFT 25 | goto :PARSE_ARGS_LOOP 26 | 27 | :TOOLNAME_NOT_FOUND 28 | echo "Please specify a tool (tsan or drmemory) by using --tool flag" 29 | exit /B 1 30 | 31 | :TOOLNAME_FOUND 32 | SHIFT 33 | set TOOL_NAME=%1 34 | :: }}} 35 | if "%TOOL_NAME%" == "drmemory" GOTO :SETUP_DRMEMORY 36 | if "%TOOL_NAME%" == "drmemory_light" GOTO :SETUP_DRMEMORY 37 | if "%TOOL_NAME%" == "drmemory_full" GOTO :SETUP_DRMEMORY 38 | if "%TOOL_NAME%" == "drmemory_pattern" GOTO :SETUP_DRMEMORY 39 | if "%TOOL_NAME%" == "tsan" GOTO :SETUP_TSAN 40 | echo "Unknown tool: `%TOOL_NAME%`! Only tsan and drmemory are supported." 41 | exit /B 1 42 | 43 | :SETUP_DRMEMORY 44 | if NOT "%DRMEMORY_COMMAND%"=="" GOTO :RUN_TESTS 45 | :: Set up DRMEMORY_COMMAND to invoke Dr. Memory {{{1 46 | set DRMEMORY_PATH=%THISDIR%..\..\third_party\drmemory 47 | set DRMEMORY_SFX=%DRMEMORY_PATH%\drmemory-windows-sfx.exe 48 | if EXIST %DRMEMORY_SFX% GOTO DRMEMORY_BINARY_OK 49 | echo "Can't find Dr. Memory executables." 50 | echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory" 51 | echo "for the instructions on how to get them." 52 | exit /B 1 53 | 54 | :DRMEMORY_BINARY_OK 55 | %DRMEMORY_SFX% -o%DRMEMORY_PATH%\unpacked -y 56 | set DRMEMORY_COMMAND=%DRMEMORY_PATH%\unpacked\bin\drmemory.exe 57 | :: }}} 58 | goto :RUN_TESTS 59 | 60 | :SETUP_TSAN 61 | :: Set up PIN_COMMAND to invoke TSan {{{1 62 | set TSAN_PATH=%THISDIR%..\..\third_party\tsan 63 | set TSAN_SFX=%TSAN_PATH%\tsan-x86-windows-sfx.exe 64 | if EXIST %TSAN_SFX% GOTO TSAN_BINARY_OK 65 | echo "Can't find ThreadSanitizer executables." 66 | echo "See http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/threadsanitizer-on-windows" 67 | echo "for the instructions on how to get them." 68 | exit /B 1 69 | 70 | :TSAN_BINARY_OK 71 | %TSAN_SFX% -o%TSAN_PATH%\unpacked -y 72 | set PIN_COMMAND=%TSAN_PATH%\unpacked\tsan-x86-windows\tsan.bat 73 | :: }}} 74 | goto :RUN_TESTS 75 | 76 | :RUN_TESTS 77 | set PYTHONPATH=%THISDIR%..\python\google;%THISDIR%..\valgrind 78 | set RUNNING_ON_VALGRIND=yes 79 | python %THISDIR%libyuv_tests.py %* 80 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/libyuv_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 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 | # Set up some paths and re-direct the arguments to libyuv_tests.py 11 | 12 | # This script is a copy of the chrome_tests.sh wrapper script with the following 13 | # changes: 14 | # - The locate_valgrind.sh of Chromium's Valgrind scripts dir is used to locate 15 | # the Valgrind framework install. 16 | # - libyuv_tests.py is invoked instead of chrome_tests.py. 17 | # - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make it 18 | # possible to execute the Python scripts properly. 19 | 20 | export THISDIR=`dirname $0` 21 | ARGV_COPY="$@" 22 | 23 | # We need to set CHROME_VALGRIND iff using Memcheck or TSan-Valgrind: 24 | # tools/valgrind-libyuv/libyuv_tests.sh --tool memcheck 25 | # or 26 | # tools/valgrind-libyuv/libyuv_tests.sh --tool=memcheck 27 | # (same for "--tool=tsan") 28 | tool="memcheck" # Default to memcheck. 29 | while (( "$#" )) 30 | do 31 | if [[ "$1" == "--tool" ]] 32 | then 33 | tool="$2" 34 | shift 35 | elif [[ "$1" =~ --tool=(.*) ]] 36 | then 37 | tool="${BASH_REMATCH[1]}" 38 | fi 39 | shift 40 | done 41 | 42 | NEEDS_VALGRIND=0 43 | NEEDS_DRMEMORY=0 44 | 45 | case "$tool" in 46 | "memcheck") 47 | NEEDS_VALGRIND=1 48 | ;; 49 | "tsan" | "tsan_rv") 50 | if [ "`uname -s`" == CYGWIN* ] 51 | then 52 | NEEDS_PIN=1 53 | else 54 | NEEDS_VALGRIND=1 55 | fi 56 | ;; 57 | "drmemory" | "drmemory_light" | "drmemory_full" | "drmemory_pattern") 58 | NEEDS_DRMEMORY=1 59 | ;; 60 | esac 61 | 62 | # For Libyuv, we'll use the locate_valgrind.sh script in Chromium's Valgrind 63 | # scripts dir to locate the Valgrind framework install 64 | CHROME_VALGRIND_SCRIPTS=$THISDIR/../valgrind 65 | 66 | if [ "$NEEDS_VALGRIND" == "1" ] 67 | then 68 | CHROME_VALGRIND=`sh $CHROME_VALGRIND_SCRIPTS/locate_valgrind.sh` 69 | if [ "$CHROME_VALGRIND" = "" ] 70 | then 71 | # locate_valgrind.sh failed 72 | exit 1 73 | fi 74 | echo "Using valgrind binaries from ${CHROME_VALGRIND}" 75 | 76 | PATH="${CHROME_VALGRIND}/bin:$PATH" 77 | # We need to set these variables to override default lib paths hard-coded into 78 | # Valgrind binary. 79 | export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind" 80 | export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind" 81 | 82 | # Clean up some /tmp directories that might be stale due to interrupted 83 | # chrome_tests.py execution. 84 | # FYI: 85 | # -mtime +1 <- only print files modified more than 24h ago, 86 | # -print0/-0 are needed to handle possible newlines in the filenames. 87 | echo "Cleanup /tmp from Valgrind stuff" 88 | find /tmp -maxdepth 1 \(\ 89 | -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \ 90 | \) -mtime +1 -print0 | xargs -0 rm -rf 91 | fi 92 | 93 | if [ "$NEEDS_DRMEMORY" == "1" ] 94 | then 95 | if [ -z "$DRMEMORY_COMMAND" ] 96 | then 97 | DRMEMORY_PATH="$THISDIR/../../third_party/drmemory" 98 | DRMEMORY_SFX="$DRMEMORY_PATH/drmemory-windows-sfx.exe" 99 | if [ ! -f "$DRMEMORY_SFX" ] 100 | then 101 | echo "Can't find Dr. Memory executables." 102 | echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory" 103 | echo "for the instructions on how to get them." 104 | exit 1 105 | fi 106 | 107 | chmod +x "$DRMEMORY_SFX" # Cygwin won't run it without +x. 108 | "$DRMEMORY_SFX" -o"$DRMEMORY_PATH/unpacked" -y 109 | export DRMEMORY_COMMAND="$DRMEMORY_PATH/unpacked/bin/drmemory.exe" 110 | fi 111 | fi 112 | 113 | if [ "$NEEDS_PIN" == "1" ] 114 | then 115 | if [ -z "$PIN_COMMAND" ] 116 | then 117 | # Set up PIN_COMMAND to invoke TSan. 118 | TSAN_PATH="$THISDIR/../../third_party/tsan" 119 | TSAN_SFX="$TSAN_PATH/tsan-x86-windows-sfx.exe" 120 | echo "$TSAN_SFX" 121 | if [ ! -f $TSAN_SFX ] 122 | then 123 | echo "Can't find ThreadSanitizer executables." 124 | echo "See http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/threadsanitizer-on-windows" 125 | echo "for the instructions on how to get them." 126 | exit 1 127 | fi 128 | 129 | chmod +x "$TSAN_SFX" # Cygwin won't run it without +x. 130 | "$TSAN_SFX" -o"$TSAN_PATH"/unpacked -y 131 | export PIN_COMMAND="$TSAN_PATH/unpacked/tsan-x86-windows/tsan.bat" 132 | fi 133 | fi 134 | 135 | # Add Chrome's Valgrind scripts dir to the PYTHON_PATH since it contains 136 | # the scripts that are needed for this script to run 137 | PYTHONPATH=$THISDIR/../python/google:$CHROME_VALGRIND_SCRIPTS python \ 138 | "$THISDIR/libyuv_tests.py" $ARGV_COPY 139 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/memcheck/OWNERS: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/memcheck/PRESUBMIT.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) 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 | Copied from Chrome's src/tools/valgrind/memcheck/PRESUBMIT.py 12 | 13 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 14 | for more details on the presubmit API built into gcl. 15 | """ 16 | 17 | import os 18 | import re 19 | import sys 20 | 21 | def CheckChange(input_api, output_api): 22 | """Checks the memcheck suppressions files for bad data.""" 23 | 24 | # Add the path to the Chrome valgrind dir to the import path: 25 | tools_vg_path = os.path.join(input_api.PresubmitLocalPath(), '..', '..', 26 | 'valgrind') 27 | sys.path.append(tools_vg_path) 28 | import suppressions 29 | 30 | sup_regex = re.compile('suppressions.*\.txt$') 31 | suppressions = {} 32 | errors = [] 33 | check_for_memcheck = False 34 | # skip_next_line has 3 possible values: 35 | # - False: don't skip the next line. 36 | # - 'skip_suppression_name': the next line is a suppression name, skip. 37 | # - 'skip_param': the next line is a system call parameter error, skip. 38 | skip_next_line = False 39 | for f in filter(lambda x: sup_regex.search(x.LocalPath()), 40 | input_api.AffectedFiles()): 41 | for line, line_num in zip(f.NewContents(), 42 | xrange(1, len(f.NewContents()) + 1)): 43 | line = line.lstrip() 44 | if line.startswith('#') or not line: 45 | continue 46 | 47 | if skip_next_line: 48 | if skip_next_line == 'skip_suppression_name': 49 | if 'insert_a_suppression_name_here' in line: 50 | errors.append('"insert_a_suppression_name_here" is not a valid ' 51 | 'suppression name') 52 | if suppressions.has_key(line): 53 | if f.LocalPath() == suppressions[line][1]: 54 | errors.append('suppression with name "%s" at %s line %s ' 55 | 'has already been defined at line %s' % 56 | (line, f.LocalPath(), line_num, 57 | suppressions[line][1])) 58 | else: 59 | errors.append('suppression with name "%s" at %s line %s ' 60 | 'has already been defined at %s line %s' % 61 | (line, f.LocalPath(), line_num, 62 | suppressions[line][0], suppressions[line][1])) 63 | else: 64 | suppressions[line] = (f, line_num) 65 | check_for_memcheck = True; 66 | skip_next_line = False 67 | continue 68 | if check_for_memcheck: 69 | if not line.startswith('Memcheck:'): 70 | errors.append('"%s" should be "Memcheck:..." in %s line %s' % 71 | (line, f.LocalPath(), line_num)) 72 | check_for_memcheck = False; 73 | if line == '{': 74 | skip_next_line = 'skip_suppression_name' 75 | continue 76 | if line == "Memcheck:Param": 77 | skip_next_line = 'skip_param' 78 | continue 79 | 80 | if (line.startswith('fun:') or line.startswith('obj:') or 81 | line.startswith('Memcheck:') or line == '}' or 82 | line == '...'): 83 | continue 84 | errors.append('"%s" is probably wrong: %s line %s' % (line, f.LocalPath(), 85 | line_num)) 86 | if errors: 87 | return [output_api.PresubmitError('\n'.join(errors))] 88 | return [] 89 | 90 | def CheckChangeOnUpload(input_api, output_api): 91 | return CheckChange(input_api, output_api) 92 | 93 | def CheckChangeOnCommit(input_api, output_api): 94 | return CheckChange(input_api, output_api) 95 | 96 | def GetPreferredTrySlaves(): 97 | # We don't have any memcheck slaves yet, so there's no use for this method. 98 | # When we have, the slave name(s) should be put into this list. 99 | return [] 100 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/memcheck/suppressions.txt: -------------------------------------------------------------------------------- 1 | # This file is used in addition to the one already maintained in Chrome. 2 | # It acts as a place holder for future additions for this project. 3 | # It must exist for the Python wrapper script to work properly. 4 | 5 | 6 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/memcheck/suppressions_mac.txt: -------------------------------------------------------------------------------- 1 | # This file is used in addition to the one already maintained in Chrome. 2 | # It acts as a place holder for future additions for this project. 3 | # It must exist for the Python wrapper script to work properly. 4 | 5 | 6 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/memcheck/suppressions_win32.txt: -------------------------------------------------------------------------------- 1 | # This file is used in addition to the one already maintained in Chrome. 2 | # It acts as a place holder for future additions for this project. 3 | # It must exist for the Python wrapper script to work properly. 4 | 5 | 6 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/tsan/OWNERS: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/tsan/PRESUBMIT.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) 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 | import os 11 | import re 12 | import sys 13 | 14 | """ 15 | Copied from Chrome's src/tools/valgrind/tsan/PRESUBMIT.py 16 | 17 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 18 | for more details on the presubmit API built into gcl. 19 | """ 20 | 21 | def CheckChange(input_api, output_api): 22 | """Checks the TSan suppressions files for bad suppressions.""" 23 | 24 | # Add the path to the Chrome valgrind dir to the import path: 25 | tools_vg_path = os.path.join(input_api.PresubmitLocalPath(), '..', '..', 26 | 'valgrind') 27 | sys.path.append(tools_vg_path) 28 | import suppressions 29 | 30 | return suppressions.PresubmitCheck(input_api, output_api) 31 | 32 | def CheckChangeOnUpload(input_api, output_api): 33 | return CheckChange(input_api, output_api) 34 | 35 | def CheckChangeOnCommit(input_api, output_api): 36 | return CheckChange(input_api, output_api) 37 | 38 | def GetPreferredTrySlaves(): 39 | # We don't have any tsan slaves yet, so there's no use for this method. 40 | # When we have, the slave name(s) should be put into this list. 41 | return [] 42 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/tsan/suppressions.txt: -------------------------------------------------------------------------------- 1 | # This file is used in addition to the one already maintained in Chrome. 2 | # It acts as a place holder for future additions for this project. 3 | # It must exist for the Python wrapper script to work properly. 4 | 5 | 6 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/tsan/suppressions_mac.txt: -------------------------------------------------------------------------------- 1 | # This file is used in addition to the one already maintained in Chrome. 2 | # It acts as a place holder for future additions for this project. 3 | # It must exist for the Python wrapper script to work properly. 4 | 5 | 6 | -------------------------------------------------------------------------------- /libyuv/jni/tools/valgrind-libyuv/tsan/suppressions_win32.txt: -------------------------------------------------------------------------------- 1 | # This file is used in addition to the one already maintained in Chrome. 2 | # It acts as a place holder for future additions for this project. 3 | # It must exist for the Python wrapper script to work properly. 4 | 5 | 6 | -------------------------------------------------------------------------------- /libyuv/jni/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(libyuvTest, Endian) { 17 | uint16 v16 = 0x1234u; 18 | uint8 first_byte = *reinterpret_cast(&v16); 19 | #if defined(LIBYUV_LITTLE_ENDIAN) 20 | EXPECT_EQ(0x34u, first_byte); 21 | #else 22 | EXPECT_EQ(0x12u, first_byte); 23 | #endif 24 | } 25 | 26 | TEST_F(libyuvTest, SizeOfTypes) { 27 | int8 i8 = -1; 28 | uint8 u8 = 1u; 29 | int16 i16 = -1; 30 | uint16 u16 = 1u; 31 | int32 i32 = -1; 32 | uint32 u32 = 1u; 33 | int64 i64 = -1; 34 | uint64 u64 = 1u; 35 | EXPECT_EQ(1u, sizeof(i8)); 36 | EXPECT_EQ(1u, sizeof(u8)); 37 | EXPECT_EQ(2u, sizeof(i16)); 38 | EXPECT_EQ(2u, sizeof(u16)); 39 | EXPECT_EQ(4u, sizeof(i32)); 40 | EXPECT_EQ(4u, sizeof(u32)); 41 | EXPECT_EQ(8u, sizeof(i64)); 42 | EXPECT_EQ(8u, sizeof(u64)); 43 | EXPECT_GT(0, i8); 44 | EXPECT_LT(0u, u8); 45 | EXPECT_GT(0, i16); 46 | EXPECT_LT(0u, u16); 47 | EXPECT_GT(0, i32); 48 | EXPECT_LT(0u, u32); 49 | EXPECT_GT(0, i64); 50 | EXPECT_LT(0u, u64); 51 | } 52 | 53 | TEST_F(libyuvTest, SizeOfConstants) { 54 | EXPECT_EQ(8u, sizeof(INT64_C(0))); 55 | EXPECT_EQ(8u, sizeof(UINT64_C(0))); 56 | EXPECT_EQ(8u, sizeof(INT64_C(0x1234567887654321))); 57 | EXPECT_EQ(8u, sizeof(UINT64_C(0x8765432112345678))); 58 | } 59 | 60 | } // namespace libyuv 61 | -------------------------------------------------------------------------------- /libyuv/jni/unit_test/cpu_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 12 | #include 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/cpu_id.h" 16 | #include "libyuv/row.h" // For HAS_ARGBSHUFFLEROW_AVX2. 17 | #include "libyuv/version.h" 18 | #include "../unit_test/unit_test.h" 19 | 20 | namespace libyuv { 21 | 22 | TEST_F(libyuvTest, TestCpuHas) { 23 | int cpu_flags = TestCpuFlag(-1); 24 | printf("Cpu Flags %x\n", cpu_flags); 25 | int has_arm = TestCpuFlag(kCpuHasARM); 26 | printf("Has ARM %x\n", has_arm); 27 | int has_neon = TestCpuFlag(kCpuHasNEON); 28 | printf("Has NEON %x\n", has_neon); 29 | int has_x86 = TestCpuFlag(kCpuHasX86); 30 | printf("Has X86 %x\n", has_x86); 31 | int has_sse2 = TestCpuFlag(kCpuHasSSE2); 32 | printf("Has SSE2 %x\n", has_sse2); 33 | int has_ssse3 = TestCpuFlag(kCpuHasSSSE3); 34 | printf("Has SSSE3 %x\n", has_ssse3); 35 | int has_sse41 = TestCpuFlag(kCpuHasSSE41); 36 | printf("Has SSE4.1 %x\n", has_sse41); 37 | int has_sse42 = TestCpuFlag(kCpuHasSSE42); 38 | printf("Has SSE4.2 %x\n", has_sse42); 39 | int has_avx = TestCpuFlag(kCpuHasAVX); 40 | printf("Has AVX %x\n", has_avx); 41 | int has_avx2 = TestCpuFlag(kCpuHasAVX2); 42 | printf("Has AVX2 %x\n", has_avx2); 43 | int has_erms = TestCpuFlag(kCpuHasERMS); 44 | printf("Has ERMS %x\n", has_erms); 45 | int has_fma3 = TestCpuFlag(kCpuHasFMA3); 46 | printf("Has FMA3 %x\n", has_fma3); 47 | int has_mips = TestCpuFlag(kCpuHasMIPS); 48 | printf("Has MIPS %x\n", has_mips); 49 | int has_mips_dsp = TestCpuFlag(kCpuHasMIPS_DSP); 50 | printf("Has MIPS DSP %x\n", has_mips_dsp); 51 | int has_mips_dspr2 = TestCpuFlag(kCpuHasMIPS_DSPR2); 52 | printf("Has MIPS DSPR2 %x\n", has_mips_dspr2); 53 | } 54 | 55 | TEST_F(libyuvTest, TestCompilerHasAVX2) { 56 | #ifdef _MSC_VER 57 | printf("_MSC_VER %d\n", _MSC_VER); 58 | #endif 59 | #if !defined(LIBYUV_DISABLE_X86) && (defined(GCC_HAS_AVX2) || \ 60 | defined(CLANG_HAS_AVX2) || defined(VISUALC_HAS_AVX2)) 61 | printf("Has AVX2 1\n"); 62 | // If compiler supports AVX2, the following function is expected to exist: 63 | #if !defined(HAS_ARGBSHUFFLEROW_AVX2) 64 | EXPECT_TRUE(0); // HAS_ARGBSHUFFLEROW_AVX2 was expected. 65 | #endif 66 | #else 67 | printf("Has AVX2 0\n"); 68 | // If compiler does not support AVX2, the following function not expected: 69 | #if defined(HAS_ARGBSHUFFLEROW_AVX2) 70 | EXPECT_TRUE(0); // HAS_ARGBSHUFFLEROW_AVX2 was not expected. 71 | #endif 72 | #endif 73 | } 74 | 75 | #if defined(__i386__) || defined(__x86_64__) || \ 76 | defined(_M_IX86) || defined(_M_X64) 77 | TEST_F(libyuvTest, TestCpuId) { 78 | int has_x86 = TestCpuFlag(kCpuHasX86); 79 | if (has_x86) { 80 | uint32 cpu_info[4]; 81 | // Vendor ID: 82 | // AuthenticAMD AMD processor 83 | // CentaurHauls Centaur processor 84 | // CyrixInstead Cyrix processor 85 | // GenuineIntel Intel processor 86 | // GenuineTMx86 Transmeta processor 87 | // Geode by NSC National Semiconductor processor 88 | // NexGenDriven NexGen processor 89 | // RiseRiseRise Rise Technology processor 90 | // SiS SiS SiS SiS processor 91 | // UMC UMC UMC UMC processor 92 | CpuId(0, 0, cpu_info); 93 | cpu_info[0] = cpu_info[1]; // Reorder output 94 | cpu_info[1] = cpu_info[3]; 95 | cpu_info[3] = 0; 96 | printf("Cpu Vendor: %s %x %x %x\n", reinterpret_cast(&cpu_info[0]), 97 | cpu_info[0], cpu_info[1], cpu_info[2]); 98 | EXPECT_EQ(12, strlen(reinterpret_cast(&cpu_info[0]))); 99 | 100 | // CPU Family and Model 101 | // 3:0 - Stepping 102 | // 7:4 - Model 103 | // 11:8 - Family 104 | // 13:12 - Processor Type 105 | // 19:16 - Extended Model 106 | // 27:20 - Extended Family 107 | CpuId(1, 0, cpu_info); 108 | int family = ((cpu_info[0] >> 8) & 0x0f) | ((cpu_info[0] >> 16) & 0xff0); 109 | int model = ((cpu_info[0] >> 4) & 0x0f) | ((cpu_info[0] >> 12) & 0xf0); 110 | printf("Cpu Family %d (0x%x), Model %d (0x%x)\n", family, family, 111 | model, model); 112 | } 113 | } 114 | #endif 115 | 116 | static int FileExists(const char* file_name) { 117 | FILE* f = fopen(file_name, "r"); 118 | if (!f) { 119 | return 0; 120 | } 121 | fclose(f); 122 | return 1; 123 | } 124 | 125 | TEST_F(libyuvTest, TestLinuxNeon) { 126 | if (FileExists("../../unit_test/testdata/arm_v7.txt")) { 127 | EXPECT_EQ(0, ArmCpuCaps("../../unit_test/testdata/arm_v7.txt")); 128 | EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/tegra3.txt")); 129 | EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/juno.txt")); 130 | } else { 131 | printf("WARNING: unable to load \"../../unit_test/testdata/arm_v7.txt\"\n"); 132 | } 133 | #if defined(__linux__) && defined(__ARM_NEON__) 134 | EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("/proc/cpuinfo")); 135 | #endif 136 | } 137 | 138 | } // namespace libyuv 139 | -------------------------------------------------------------------------------- /libyuv/jni/unit_test/math_test.cc: -------------------------------------------------------------------------------- 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 | #include 12 | #include 13 | #include 14 | 15 | #include "libyuv/basic_types.h" 16 | #include "libyuv/cpu_id.h" 17 | #include "libyuv/row.h" 18 | #include "libyuv/scale.h" 19 | #include "libyuv/scale_row.h" 20 | #include "../unit_test/unit_test.h" 21 | 22 | namespace libyuv { 23 | 24 | TEST_F(libyuvTest, TestFixedDiv) { 25 | int num[1280]; 26 | int div[1280]; 27 | int result_opt[1280]; 28 | int result_c[1280]; 29 | 30 | EXPECT_EQ(0x10000, libyuv::FixedDiv(1, 1)); 31 | EXPECT_EQ(0x7fff0000, libyuv::FixedDiv(0x7fff, 1)); 32 | // TODO(fbarchard): Avoid the following that throw exceptions. 33 | // EXPECT_EQ(0x100000000, libyuv::FixedDiv(0x10000, 1)); 34 | // EXPECT_EQ(0x80000000, libyuv::FixedDiv(0x8000, 1)); 35 | 36 | EXPECT_EQ(0x20000, libyuv::FixedDiv(640 * 2, 640)); 37 | EXPECT_EQ(0x30000, libyuv::FixedDiv(640 * 3, 640)); 38 | EXPECT_EQ(0x40000, libyuv::FixedDiv(640 * 4, 640)); 39 | EXPECT_EQ(0x50000, libyuv::FixedDiv(640 * 5, 640)); 40 | EXPECT_EQ(0x60000, libyuv::FixedDiv(640 * 6, 640)); 41 | EXPECT_EQ(0x70000, libyuv::FixedDiv(640 * 7, 640)); 42 | EXPECT_EQ(0x80000, libyuv::FixedDiv(640 * 8, 640)); 43 | EXPECT_EQ(0xa0000, libyuv::FixedDiv(640 * 10, 640)); 44 | EXPECT_EQ(0x20000, libyuv::FixedDiv(960 * 2, 960)); 45 | EXPECT_EQ(0x08000, libyuv::FixedDiv(640 / 2, 640)); 46 | EXPECT_EQ(0x04000, libyuv::FixedDiv(640 / 4, 640)); 47 | EXPECT_EQ(0x20000, libyuv::FixedDiv(1080 * 2, 1080)); 48 | EXPECT_EQ(0x20000, libyuv::FixedDiv(200000, 100000)); 49 | EXPECT_EQ(0x18000, libyuv::FixedDiv(150000, 100000)); 50 | EXPECT_EQ(0x20000, libyuv::FixedDiv(40000, 20000)); 51 | EXPECT_EQ(0x20000, libyuv::FixedDiv(-40000, -20000)); 52 | EXPECT_EQ(-0x20000, libyuv::FixedDiv(40000, -20000)); 53 | EXPECT_EQ(-0x20000, libyuv::FixedDiv(-40000, 20000)); 54 | EXPECT_EQ(0x10000, libyuv::FixedDiv(4095, 4095)); 55 | EXPECT_EQ(0x10000, libyuv::FixedDiv(4096, 4096)); 56 | EXPECT_EQ(0x10000, libyuv::FixedDiv(4097, 4097)); 57 | EXPECT_EQ(123 * 65536, libyuv::FixedDiv(123, 1)); 58 | 59 | for (int i = 1; i < 4100; ++i) { 60 | EXPECT_EQ(0x10000, libyuv::FixedDiv(i, i)); 61 | EXPECT_EQ(0x20000, libyuv::FixedDiv(i * 2, i)); 62 | EXPECT_EQ(0x30000, libyuv::FixedDiv(i * 3, i)); 63 | EXPECT_EQ(0x40000, libyuv::FixedDiv(i * 4, i)); 64 | EXPECT_EQ(0x08000, libyuv::FixedDiv(i, i * 2)); 65 | EXPECT_NEAR(16384 * 65536 / i, libyuv::FixedDiv(16384, i), 1); 66 | } 67 | EXPECT_EQ(123 * 65536, libyuv::FixedDiv(123, 1)); 68 | 69 | srandom(time(NULL)); 70 | MemRandomize(reinterpret_cast(&num[0]), sizeof(num)); 71 | MemRandomize(reinterpret_cast(&div[0]), sizeof(div)); 72 | for (int j = 0; j < 1280; ++j) { 73 | if (div[j] == 0) { 74 | div[j] = 1280; 75 | } 76 | num[j] &= 0xffff; // Clamp to avoid divide overflow. 77 | } 78 | for (int i = 0; i < benchmark_pixels_div1280_; ++i) { 79 | for (int j = 0; j < 1280; ++j) { 80 | result_opt[j] = libyuv::FixedDiv(num[j], div[j]); 81 | } 82 | } 83 | for (int j = 0; j < 1280; ++j) { 84 | result_c[j] = libyuv::FixedDiv_C(num[j], div[j]); 85 | EXPECT_NEAR(result_c[j], result_opt[j], 1); 86 | } 87 | } 88 | 89 | TEST_F(libyuvTest, TestFixedDiv_Opt) { 90 | int num[1280]; 91 | int div[1280]; 92 | int result_opt[1280]; 93 | int result_c[1280]; 94 | 95 | srandom(time(NULL)); 96 | MemRandomize(reinterpret_cast(&num[0]), sizeof(num)); 97 | MemRandomize(reinterpret_cast(&div[0]), sizeof(div)); 98 | for (int j = 0; j < 1280; ++j) { 99 | num[j] &= 4095; // Make numerator smaller. 100 | div[j] &= 4095; // Make divisor smaller. 101 | if (div[j] == 0) { 102 | div[j] = 1280; 103 | } 104 | } 105 | 106 | int has_x86 = TestCpuFlag(kCpuHasX86); 107 | for (int i = 0; i < benchmark_pixels_div1280_; ++i) { 108 | if (has_x86) { 109 | for (int j = 0; j < 1280; ++j) { 110 | result_opt[j] = libyuv::FixedDiv(num[j], div[j]); 111 | } 112 | } else { 113 | for (int j = 0; j < 1280; ++j) { 114 | result_opt[j] = libyuv::FixedDiv_C(num[j], div[j]); 115 | } 116 | } 117 | } 118 | for (int j = 0; j < 1280; ++j) { 119 | result_c[j] = libyuv::FixedDiv_C(num[j], div[j]); 120 | EXPECT_NEAR(result_c[j], result_opt[j], 1); 121 | } 122 | } 123 | 124 | TEST_F(libyuvTest, TestFixedDiv1_Opt) { 125 | int num[1280]; 126 | int div[1280]; 127 | int result_opt[1280]; 128 | int result_c[1280]; 129 | 130 | srandom(time(NULL)); 131 | MemRandomize(reinterpret_cast(&num[0]), sizeof(num)); 132 | MemRandomize(reinterpret_cast(&div[0]), sizeof(div)); 133 | for (int j = 0; j < 1280; ++j) { 134 | num[j] &= 4095; // Make numerator smaller. 135 | div[j] &= 4095; // Make divisor smaller. 136 | if (div[j] <= 1) { 137 | div[j] = 1280; 138 | } 139 | } 140 | 141 | int has_x86 = TestCpuFlag(kCpuHasX86); 142 | for (int i = 0; i < benchmark_pixels_div1280_; ++i) { 143 | if (has_x86) { 144 | for (int j = 0; j < 1280; ++j) { 145 | result_opt[j] = libyuv::FixedDiv1(num[j], div[j]); 146 | } 147 | } else { 148 | for (int j = 0; j < 1280; ++j) { 149 | result_opt[j] = libyuv::FixedDiv1_C(num[j], div[j]); 150 | } 151 | } 152 | } 153 | for (int j = 0; j < 1280; ++j) { 154 | result_c[j] = libyuv::FixedDiv1_C(num[j], div[j]); 155 | EXPECT_NEAR(result_c[j], result_opt[j], 1); 156 | } 157 | } 158 | 159 | } // namespace libyuv 160 | -------------------------------------------------------------------------------- /libyuv/jni/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 | -------------------------------------------------------------------------------- /libyuv/jni/unit_test/testdata/juno.txt: -------------------------------------------------------------------------------- 1 | Processor : AArch64 Processor rev 0 (aarch64) 2 | processor : 0 3 | processor : 1 4 | processor : 2 5 | processor : 3 6 | processor : 4 7 | processor : 5 8 | Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 9 | CPU implementer : 0x41 10 | CPU architecture: AArch64 11 | CPU variant : 0x0 12 | CPU part : 0xd07 13 | CPU revision : 0 14 | 15 | Hardware : Juno 16 | -------------------------------------------------------------------------------- /libyuv/jni/unit_test/testdata/tegra3.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/libyuv/jni/unit_test/testdata/tegra3.txt -------------------------------------------------------------------------------- /libyuv/jni/unit_test/unit_test.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 "../unit_test/unit_test.h" 12 | 13 | #include // For getenv() 14 | 15 | #include 16 | 17 | // Change this to 1000 for benchmarking. 18 | // TODO(fbarchard): Add command line parsing to pass this as option. 19 | #define BENCHMARK_ITERATIONS 1 20 | 21 | libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128), 22 | benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(128), 23 | benchmark_height_(72), disable_cpu_flags_(0) { 24 | const char* repeat = getenv("LIBYUV_REPEAT"); 25 | if (repeat) { 26 | benchmark_iterations_ = atoi(repeat); // NOLINT 27 | // For quicker unittests, default is 128 x 72. But when benchmarking, 28 | // default to 720p. Allow size to specify. 29 | if (benchmark_iterations_ > 1) { 30 | benchmark_width_ = 1280; 31 | benchmark_height_ = 720; 32 | } 33 | } 34 | const char* width = getenv("LIBYUV_WIDTH"); 35 | if (width) { 36 | benchmark_width_ = atoi(width); // NOLINT 37 | } 38 | const char* height = getenv("LIBYUV_HEIGHT"); 39 | if (height) { 40 | benchmark_height_ = atoi(height); // NOLINT 41 | } 42 | const char* cpu_flags = getenv("LIBYUV_FLAGS"); 43 | if (cpu_flags) { 44 | disable_cpu_flags_ = atoi(cpu_flags); // NOLINT 45 | } 46 | benchmark_pixels_div256_ = static_cast(( 47 | static_cast(Abs(benchmark_width_)) * 48 | static_cast(Abs(benchmark_height_)) * 49 | static_cast(benchmark_iterations_) + 255.0) / 256.0); 50 | benchmark_pixels_div1280_ = static_cast(( 51 | static_cast(Abs(benchmark_width_)) * 52 | static_cast(Abs(benchmark_height_)) * 53 | static_cast(benchmark_iterations_) + 1279.0) / 1280.0); 54 | } 55 | 56 | int main(int argc, char** argv) { 57 | ::testing::InitGoogleTest(&argc, argv); 58 | return RUN_ALL_TESTS(); 59 | } 60 | -------------------------------------------------------------------------------- /libyuv/jni/unit_test/unit_test.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 UNIT_TEST_UNIT_TEST_H_ // NOLINT 12 | #define UNIT_TEST_UNIT_TEST_H_ 13 | 14 | #ifdef WIN32 15 | #include 16 | #else 17 | #include 18 | #include 19 | #endif 20 | 21 | #include 22 | 23 | #include "libyuv/basic_types.h" 24 | 25 | static __inline int Abs(int v) { 26 | return v >= 0 ? v : -v; 27 | } 28 | 29 | #define OFFBY 0 30 | 31 | #define align_buffer_page_end(var, size) \ 32 | uint8* var; \ 33 | uint8* var##_mem; \ 34 | var##_mem = reinterpret_cast(malloc((((size) + 4095) & ~4095) + \ 35 | OFFBY)); \ 36 | var = var##_mem + (-(size) & 4095) + OFFBY; 37 | 38 | #define free_aligned_buffer_page_end(var) \ 39 | free(var##_mem); \ 40 | var = 0; 41 | 42 | #ifdef WIN32 43 | static inline double get_time() { 44 | LARGE_INTEGER t, f; 45 | QueryPerformanceCounter(&t); 46 | QueryPerformanceFrequency(&f); 47 | return static_cast(t.QuadPart) / static_cast(f.QuadPart); 48 | } 49 | 50 | #define random rand 51 | #define srandom srand 52 | #else 53 | static inline double get_time() { 54 | struct timeval t; 55 | struct timezone tzp; 56 | gettimeofday(&t, &tzp); 57 | return t.tv_sec + t.tv_usec * 1e-6; 58 | } 59 | #endif 60 | 61 | static inline void MemRandomize(uint8* dst, int64 len) { 62 | int64 i; 63 | for (i = 0; i < len - 1; i += 2) { 64 | *reinterpret_cast(dst) = random(); 65 | dst += 2; 66 | } 67 | for (; i < len; ++i) { 68 | *dst++ = random(); 69 | } 70 | } 71 | 72 | class libyuvTest : public ::testing::Test { 73 | protected: 74 | libyuvTest(); 75 | 76 | const int rotate_max_w_; 77 | const int rotate_max_h_; 78 | 79 | int benchmark_iterations_; // Default 1. Use 1000 for benchmarking. 80 | int benchmark_width_; // Default 1280. Use 640 for benchmarking VGA. 81 | int benchmark_height_; // Default 720. Use 360 for benchmarking VGA. 82 | int benchmark_pixels_div256_; // Total pixels to benchmark / 256. 83 | int benchmark_pixels_div1280_; // Total pixels to benchmark / 1280. 84 | int disable_cpu_flags_; // Default 0. Use -1 for benchmarking. 85 | }; 86 | 87 | #endif // UNIT_TEST_UNIT_TEST_H_ NOLINT 88 | -------------------------------------------------------------------------------- /libyuv/jni/unit_test/version_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 12 | #include 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/version.h" 16 | #include "../unit_test/unit_test.h" 17 | 18 | namespace libyuv { 19 | 20 | // Tests SVN version against include/libyuv/version.h 21 | // SVN version is bumped by documentation changes as well as code. 22 | // Although the versions should match, once checked in, a tolerance is allowed. 23 | TEST_F(libyuvTest, TestVersion) { 24 | EXPECT_GE(LIBYUV_VERSION, 169); // 169 is first version to support version. 25 | printf("LIBYUV_VERSION %d\n", LIBYUV_VERSION); 26 | #ifdef LIBYUV_SVNREVISION 27 | const char *ver = strchr(LIBYUV_SVNREVISION, ':'); 28 | if (ver) { 29 | ++ver; 30 | } else { 31 | ver = LIBYUV_SVNREVISION; 32 | } 33 | int svn_revision = atoi(ver); // NOLINT 34 | printf("LIBYUV_SVNREVISION %d\n", svn_revision); 35 | EXPECT_NEAR(LIBYUV_VERSION, svn_revision, 20); // Allow version to be close. 36 | if (LIBYUV_VERSION != svn_revision) { 37 | printf("WARNING - Versions do not match.\n"); 38 | } 39 | #else 40 | printf("WARNING - SVN Version unavailable. Test not run.\n"); 41 | #endif 42 | } 43 | 44 | } // namespace libyuv 45 | -------------------------------------------------------------------------------- /libyuv/jni/unit_test/video_common_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 12 | #include 13 | 14 | #include "libyuv/video_common.h" 15 | #include "../unit_test/unit_test.h" 16 | 17 | namespace libyuv { 18 | 19 | // Tests FourCC codes in video common, which are used for ConvertToI420(). 20 | 21 | static bool TestValidChar(uint32 onecc) { 22 | if ((onecc >= '0' && onecc <= '9') || 23 | (onecc >= 'A' && onecc <= 'Z') || 24 | (onecc >= 'a' && onecc <= 'z') || 25 | (onecc == ' ') || (onecc == 0xff)) { 26 | return true; 27 | } 28 | return false; 29 | } 30 | 31 | static bool TestValidFourCC(uint32 fourcc, int bpp) { 32 | if (!TestValidChar(fourcc & 0xff) || 33 | !TestValidChar((fourcc >> 8) & 0xff) || 34 | !TestValidChar((fourcc >> 16) & 0xff) || 35 | !TestValidChar((fourcc >> 24) & 0xff)) { 36 | return false; 37 | } 38 | if (bpp < 0 || bpp > 32) { 39 | return false; 40 | } 41 | return true; 42 | } 43 | 44 | TEST_F(libyuvTest, TestCanonicalFourCC) { 45 | EXPECT_EQ(FOURCC_I420, CanonicalFourCC(FOURCC_IYUV)); 46 | EXPECT_EQ(FOURCC_I422, CanonicalFourCC(FOURCC_YU16)); 47 | EXPECT_EQ(FOURCC_I444, CanonicalFourCC(FOURCC_YU24)); 48 | EXPECT_EQ(FOURCC_YUY2, CanonicalFourCC(FOURCC_YUYV)); 49 | EXPECT_EQ(FOURCC_YUY2, CanonicalFourCC(FOURCC_YUVS)); 50 | EXPECT_EQ(FOURCC_UYVY, CanonicalFourCC(FOURCC_HDYC)); 51 | EXPECT_EQ(FOURCC_UYVY, CanonicalFourCC(FOURCC_2VUY)); 52 | EXPECT_EQ(FOURCC_MJPG, CanonicalFourCC(FOURCC_JPEG)); 53 | EXPECT_EQ(FOURCC_MJPG, CanonicalFourCC(FOURCC_DMB1)); 54 | EXPECT_EQ(FOURCC_RAW, CanonicalFourCC(FOURCC_RGB3)); 55 | EXPECT_EQ(FOURCC_24BG, CanonicalFourCC(FOURCC_BGR3)); 56 | EXPECT_EQ(FOURCC_BGRA, CanonicalFourCC(FOURCC_CM32)); 57 | EXPECT_EQ(FOURCC_RAW, CanonicalFourCC(FOURCC_CM24)); 58 | EXPECT_EQ(FOURCC_RGBO, CanonicalFourCC(FOURCC_L555)); 59 | EXPECT_EQ(FOURCC_RGBP, CanonicalFourCC(FOURCC_L565)); 60 | EXPECT_EQ(FOURCC_RGBO, CanonicalFourCC(FOURCC_5551)); 61 | } 62 | 63 | TEST_F(libyuvTest, TestFourCC) { 64 | EXPECT_TRUE(TestValidFourCC(FOURCC_I420, FOURCC_BPP_I420)); 65 | EXPECT_TRUE(TestValidFourCC(FOURCC_I420, FOURCC_BPP_I420)); 66 | EXPECT_TRUE(TestValidFourCC(FOURCC_I422, FOURCC_BPP_I422)); 67 | EXPECT_TRUE(TestValidFourCC(FOURCC_I444, FOURCC_BPP_I444)); 68 | EXPECT_TRUE(TestValidFourCC(FOURCC_I411, FOURCC_BPP_I411)); 69 | EXPECT_TRUE(TestValidFourCC(FOURCC_I400, FOURCC_BPP_I400)); 70 | EXPECT_TRUE(TestValidFourCC(FOURCC_NV21, FOURCC_BPP_NV21)); 71 | EXPECT_TRUE(TestValidFourCC(FOURCC_NV12, FOURCC_BPP_NV12)); 72 | EXPECT_TRUE(TestValidFourCC(FOURCC_YUY2, FOURCC_BPP_YUY2)); 73 | EXPECT_TRUE(TestValidFourCC(FOURCC_UYVY, FOURCC_BPP_UYVY)); 74 | EXPECT_TRUE(TestValidFourCC(FOURCC_M420, FOURCC_BPP_M420)); 75 | EXPECT_TRUE(TestValidFourCC(FOURCC_Q420, FOURCC_BPP_Q420)); // deprecated. 76 | EXPECT_TRUE(TestValidFourCC(FOURCC_ARGB, FOURCC_BPP_ARGB)); 77 | EXPECT_TRUE(TestValidFourCC(FOURCC_BGRA, FOURCC_BPP_BGRA)); 78 | EXPECT_TRUE(TestValidFourCC(FOURCC_ABGR, FOURCC_BPP_ABGR)); 79 | EXPECT_TRUE(TestValidFourCC(FOURCC_24BG, FOURCC_BPP_24BG)); 80 | EXPECT_TRUE(TestValidFourCC(FOURCC_RAW, FOURCC_BPP_RAW)); 81 | EXPECT_TRUE(TestValidFourCC(FOURCC_RGBA, FOURCC_BPP_RGBA)); 82 | EXPECT_TRUE(TestValidFourCC(FOURCC_RGBP, FOURCC_BPP_RGBP)); 83 | EXPECT_TRUE(TestValidFourCC(FOURCC_RGBO, FOURCC_BPP_RGBO)); 84 | EXPECT_TRUE(TestValidFourCC(FOURCC_R444, FOURCC_BPP_R444)); 85 | EXPECT_TRUE(TestValidFourCC(FOURCC_MJPG, FOURCC_BPP_MJPG)); 86 | EXPECT_TRUE(TestValidFourCC(FOURCC_YV12, FOURCC_BPP_YV12)); 87 | EXPECT_TRUE(TestValidFourCC(FOURCC_YV16, FOURCC_BPP_YV16)); 88 | EXPECT_TRUE(TestValidFourCC(FOURCC_YV24, FOURCC_BPP_YV24)); 89 | EXPECT_TRUE(TestValidFourCC(FOURCC_YU12, FOURCC_BPP_YU12)); 90 | EXPECT_TRUE(TestValidFourCC(FOURCC_IYUV, FOURCC_BPP_IYUV)); 91 | EXPECT_TRUE(TestValidFourCC(FOURCC_YU16, FOURCC_BPP_YU16)); 92 | EXPECT_TRUE(TestValidFourCC(FOURCC_YU24, FOURCC_BPP_YU24)); 93 | EXPECT_TRUE(TestValidFourCC(FOURCC_YUYV, FOURCC_BPP_YUYV)); 94 | EXPECT_TRUE(TestValidFourCC(FOURCC_YUVS, FOURCC_BPP_YUVS)); 95 | EXPECT_TRUE(TestValidFourCC(FOURCC_HDYC, FOURCC_BPP_HDYC)); 96 | EXPECT_TRUE(TestValidFourCC(FOURCC_2VUY, FOURCC_BPP_2VUY)); 97 | EXPECT_TRUE(TestValidFourCC(FOURCC_JPEG, FOURCC_BPP_JPEG)); 98 | EXPECT_TRUE(TestValidFourCC(FOURCC_DMB1, FOURCC_BPP_DMB1)); 99 | EXPECT_TRUE(TestValidFourCC(FOURCC_BA81, FOURCC_BPP_BA81)); 100 | EXPECT_TRUE(TestValidFourCC(FOURCC_RGB3, FOURCC_BPP_RGB3)); 101 | EXPECT_TRUE(TestValidFourCC(FOURCC_BGR3, FOURCC_BPP_BGR3)); 102 | EXPECT_TRUE(TestValidFourCC(FOURCC_H264, FOURCC_BPP_H264)); 103 | EXPECT_TRUE(TestValidFourCC(FOURCC_ANY, FOURCC_BPP_ANY)); 104 | } 105 | 106 | } // namespace libyuv 107 | -------------------------------------------------------------------------------- /libyuv/jni/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 buf1[kBlockSize]; 33 | uint8 buf2[kBlockSize]; 34 | uint32 hash1 = 5381; 35 | uint32 hash2 = 5381; 36 | uint64 sum_square_err = 0; 37 | uint64 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) hash1 = libyuv::HashDjb2(buf1, amt1, hash1); 43 | if (fin2) { 44 | amt2 = static_cast(fread(buf2, 1, kBlockSize, fin2)); 45 | if (amt2 > 0) hash2 = libyuv::HashDjb2(buf2, amt2, hash2); 46 | int amt_min = (amt1 < amt2) ? amt1 : amt2; 47 | size_min += amt_min; 48 | sum_square_err += libyuv::ComputeSumSquareError(buf1, buf2, amt_min); 49 | } 50 | } while (amt1 > 0 || amt2 > 0); 51 | 52 | printf("hash1 %x", hash1); 53 | if (fin2) { 54 | printf(", hash2 %x", hash2); 55 | double mse = static_cast(sum_square_err) / 56 | static_cast(size_min); 57 | printf(", mse %.2f", mse); 58 | double psnr = libyuv::SumSquareErrorToPsnr(sum_square_err, size_min); 59 | printf(", psnr %.2f\n", psnr); 60 | fclose(fin2); 61 | } 62 | fclose(fin1); 63 | } 64 | -------------------------------------------------------------------------------- /libyuv/jni/util/cpuid.c: -------------------------------------------------------------------------------- 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 | 15 | #define INCLUDE_LIBYUV_COMPARE_H_ 16 | #include "libyuv.h" 17 | #include "./psnr.h" 18 | #include "./ssim.h" 19 | 20 | int main(int argc, const char* argv[]) { 21 | int cpu_flags = TestCpuFlag(-1); 22 | int has_arm = TestCpuFlag(kCpuHasARM); 23 | int has_mips = TestCpuFlag(kCpuHasMIPS); 24 | int has_x86 = TestCpuFlag(kCpuHasX86); 25 | #if defined(__i386__) || defined(__x86_64__) || \ 26 | defined(_M_IX86) || defined(_M_X64) 27 | if (has_x86) { 28 | uint32 family, model, cpu_info[4]; 29 | // Vendor ID: 30 | // AuthenticAMD AMD processor 31 | // CentaurHauls Centaur processor 32 | // CyrixInstead Cyrix processor 33 | // GenuineIntel Intel processor 34 | // GenuineTMx86 Transmeta processor 35 | // Geode by NSC National Semiconductor processor 36 | // NexGenDriven NexGen processor 37 | // RiseRiseRise Rise Technology processor 38 | // SiS SiS SiS SiS processor 39 | // UMC UMC UMC UMC processor 40 | CpuId(0, 0, &cpu_info[0]); 41 | cpu_info[0] = cpu_info[1]; // Reorder output 42 | cpu_info[1] = cpu_info[3]; 43 | cpu_info[3] = 0; 44 | printf("Cpu Vendor: %s\n", (char*)(&cpu_info[0])); 45 | 46 | // CPU Family and Model 47 | // 3:0 - Stepping 48 | // 7:4 - Model 49 | // 11:8 - Family 50 | // 13:12 - Processor Type 51 | // 19:16 - Extended Model 52 | // 27:20 - Extended Family 53 | CpuId(1, 0, &cpu_info[0]); 54 | family = ((cpu_info[0] >> 8) & 0x0f) | ((cpu_info[0] >> 16) & 0xff0); 55 | model = ((cpu_info[0] >> 4) & 0x0f) | ((cpu_info[0] >> 12) & 0xf0); 56 | printf("Cpu Family %d (0x%x), Model %d (0x%x)\n", family, family, 57 | model, model); 58 | } 59 | #endif 60 | printf("Cpu Flags %x\n", cpu_flags); 61 | printf("Has ARM %x\n", has_arm); 62 | printf("Has MIPS %x\n", has_mips); 63 | printf("Has X86 %x\n", has_x86); 64 | if (has_arm) { 65 | int has_neon = TestCpuFlag(kCpuHasNEON); 66 | printf("Has NEON %x\n", has_neon); 67 | } 68 | if (has_mips) { 69 | int has_mips_dsp = TestCpuFlag(kCpuHasMIPS_DSP); 70 | int has_mips_dspr2 = TestCpuFlag(kCpuHasMIPS_DSPR2); 71 | printf("Has MIPS DSP %x\n", has_mips_dsp); 72 | printf("Has MIPS DSPR2 %x\n", has_mips_dspr2); 73 | } 74 | if (has_x86) { 75 | int has_sse2 = TestCpuFlag(kCpuHasSSE2); 76 | int has_ssse3 = TestCpuFlag(kCpuHasSSSE3); 77 | int has_sse41 = TestCpuFlag(kCpuHasSSE41); 78 | int has_sse42 = TestCpuFlag(kCpuHasSSE42); 79 | int has_avx = TestCpuFlag(kCpuHasAVX); 80 | int has_avx2 = TestCpuFlag(kCpuHasAVX2); 81 | int has_erms = TestCpuFlag(kCpuHasERMS); 82 | int has_fma3 = TestCpuFlag(kCpuHasFMA3); 83 | printf("Has SSE2 %x\n", has_sse2); 84 | printf("Has SSSE3 %x\n", has_ssse3); 85 | printf("Has SSE4.1 %x\n", has_sse41); 86 | printf("Has SSE4.2 %x\n", has_sse42); 87 | printf("Has AVX %x\n", has_avx); 88 | printf("Has AVX2 %x\n", has_avx2); 89 | printf("Has ERMS %x\n", has_erms); 90 | printf("Has FMA3 %x\n", has_fma3); 91 | } 92 | return 0; 93 | } 94 | 95 | -------------------------------------------------------------------------------- /libyuv/jni/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; 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* org, const uint8* rec, int size); 35 | #endif 36 | 37 | // PSNR formula: psnr = 10 * log10 (Peak Signal^2 * size / sse) 38 | // Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match). 39 | double ComputePSNR(double sse, double size); 40 | 41 | #ifdef __cplusplus 42 | } // extern "C" 43 | #endif 44 | 45 | #endif // UTIL_PSNR_H_ // NOLINT 46 | -------------------------------------------------------------------------------- /libyuv/jni/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_ // NOLINT 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; 24 | #define UINT8_TYPE_DEFINED 25 | #endif 26 | 27 | double CalcSSIM(const uint8* org, const uint8* rec, 28 | const int image_width, const int image_height); 29 | 30 | double CalcLSSIM(double ssim); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | #endif 35 | 36 | #endif // UTIL_SSIM_H_ // NOLINT 37 | -------------------------------------------------------------------------------- /libyuv/jni/winarm.mk: -------------------------------------------------------------------------------- 1 | # This is a generic makefile for libyuv for Windows Arm. 2 | # nmake /f winarm.mk 3 | # make -f winarm.mk 4 | # nmake /f winarm.mk clean 5 | # consider /arch:ARMv7VE 6 | CC=cl 7 | CCFLAGS=/Ox /nologo /Iinclude /DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP 8 | AR=lib 9 | ARFLAGS=/MACHINE:ARM /NOLOGO /SUBSYSTEM:NATIVE 10 | RM=cmd /c del 11 | 12 | LOCAL_OBJ_FILES = \ 13 | source/compare.o\ 14 | source/compare_common.o\ 15 | source/convert.o\ 16 | source/convert_argb.o\ 17 | source/convert_from.o\ 18 | source/convert_from_argb.o\ 19 | source/convert_to_argb.o\ 20 | source/convert_to_i420.o\ 21 | source/cpu_id.o\ 22 | source/planar_functions.o\ 23 | source/rotate.o\ 24 | source/rotate_argb.o\ 25 | source/row_any.o\ 26 | source/row_common.o\ 27 | source/scale.o\ 28 | source/scale_argb.o\ 29 | source/scale_common.o\ 30 | source/video_common.o 31 | 32 | .cc.o: 33 | $(CC) /c $(CCFLAGS) $*.cc /Fo$@ 34 | 35 | all: libyuv_arm.lib winarm.mk 36 | 37 | libyuv_arm.lib: $(LOCAL_OBJ_FILES) winarm.mk 38 | $(AR) $(ARFLAGS) /OUT:$@ $(LOCAL_OBJ_FILES) 39 | 40 | clean: 41 | $(RM) "source\*.o" libyuv_arm.lib 42 | 43 | -------------------------------------------------------------------------------- /libyuv/obj/local/arm64-v8a/libyuv_static.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/libyuv/obj/local/arm64-v8a/libyuv_static.a -------------------------------------------------------------------------------- /libyuv/obj/local/armeabi-v7a/libyuv_static.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/libyuv/obj/local/armeabi-v7a/libyuv_static.a -------------------------------------------------------------------------------- /libyuv/obj/local/armeabi/libyuv_static.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/libyuv/obj/local/armeabi/libyuv_static.a -------------------------------------------------------------------------------- /libyuv/obj/local/x86/libyuv_static.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/libyuv/obj/local/x86/libyuv_static.a -------------------------------------------------------------------------------- /libyuv/obj/local/x86_64/libyuv_static.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/libyuv/obj/local/x86_64/libyuv_static.a -------------------------------------------------------------------------------- /libyuv/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reign9201/ImageUtils/5774f112a0e79560ed8e0a022bc7dca44d25117e/libyuv/readme.md -------------------------------------------------------------------------------- /local.properties: -------------------------------------------------------------------------------- 1 | ## This file must *NOT* be checked into Version Control Systems, 2 | # as it contains information specific to your local configuration. 3 | # 4 | # Location of the SDK. This is only used by Gradle. 5 | # For customization when using a Version Control System, please read the 6 | # header note. 7 | #Mon Nov 18 15:09:31 CST 2019 8 | ndk.dir=D\:\\Android\\sdk\\android-ndk-r16b-windows-x86_64\\android-ndk-r16b 9 | sdk.dir=D\:\\Android\\Sdk 10 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | //include ':ImageConvertUtils' 3 | include ':YuvUtils' 4 | rootProject.name = 'ImageUtils' 5 | --------------------------------------------------------------------------------