├── .gitignore ├── README.md ├── app ├── CMakeLists.txt ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── cpp │ ├── ConstDefine.h │ ├── LibyuvUtil.cpp │ ├── LibyuvUtil.h │ └── native-bridge.cpp │ ├── java │ └── com │ │ └── sharry │ │ └── sample │ │ └── libyuv │ │ ├── LibyuvUtil.java │ │ └── MainActivity.kt │ ├── jniLibs │ ├── armeabi-v7a │ │ └── libyuv.so │ └── include │ │ ├── libyuv.h │ │ └── libyuv │ │ ├── basic_types.h │ │ ├── compare.h │ │ ├── compare_row.h │ │ ├── convert.h │ │ ├── convert_argb.h │ │ ├── convert_from.h │ │ ├── convert_from_argb.h │ │ ├── cpu_id.h │ │ ├── macros_msa.h │ │ ├── mjpeg_decoder.h │ │ ├── planar_functions.h │ │ ├── rotate.h │ │ ├── rotate_argb.h │ │ ├── rotate_row.h │ │ ├── row.h │ │ ├── scale.h │ │ ├── scale_argb.h │ │ ├── scale_row.h │ │ ├── version.h │ │ └── video_common.h │ └── 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 │ ├── 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 ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea 38 | 39 | 40 | # Keystore files 41 | *.jks 42 | 43 | # external files 44 | .externalNativeBuild/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LibyuvSample 2 | 使用入口如下 3 | 4 | ``` 5 | package com.sharry.sample.libyuv; 6 | 7 | import android.graphics.Bitmap; 8 | 9 | /** 10 | * 处理 YUV 的工具类 11 | * 12 | * @author Sharry Contact me. 13 | * @version 1.0 14 | * @since 2019-07-23 15 | */ 16 | public class LibyuvUtil { 17 | 18 | static { 19 | System.loadLibrary("yuv-sample"); 20 | } 21 | 22 | /** 23 | * 将 NV21 转 I420 24 | */ 25 | public static native void convertNV21ToI420(byte[] src, byte[] dst, int width, int height); 26 | 27 | /** 28 | * 压缩 I420 数据 29 | *

30 | * 执行顺序为:缩放->旋转->镜像 31 | * 32 | * @param src 原始数据 33 | * @param srcWidth 原始宽度 34 | * @param srcHeight 原始高度 35 | * @param dst 输出数据 36 | * @param dstWidth 输出宽度 37 | * @param dstHeight 输出高度 38 | * @param degree 旋转(90, 180, 270) 39 | * @param isMirror 镜像(镜像在旋转之后) 40 | */ 41 | public static native void compressI420(byte[] src, int srcWidth, int srcHeight, 42 | byte[] dst, int dstWidth, int dstHeight, 43 | int degree, boolean isMirror); 44 | 45 | /** 46 | * 将 I420 数据注入到 Bitmap 中 47 | */ 48 | public static native void convertI420ToBitmap(byte[] src, Bitmap dst, int width, int height); 49 | 50 | /** 51 | * 将 I420 转 NV12 52 | */ 53 | public static native void convertI420ToNV12(byte[] src, byte[] dst, int width, int height); 54 | } 55 | 56 | ``` 57 | -------------------------------------------------------------------------------- /app/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMake 最小编译版本 2 | CMAKE_MINIMUM_REQUIRED(VERSION 3.4.1) 3 | 4 | # 指定需要使用的头文件 5 | INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/main/jniLibs/include) 6 | # 指定外部链接库目录 7 | LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/main/jniLibs/armeabi-v7a) 8 | 9 | # 添加要打包的资源 10 | FILE(GLOB SRC_LISTS "${PROJECT_SOURCE_DIR}/src/main/cpp/*.cpp" "${PROJECT_SOURCE_DIR}/src/main/cpp/*.c") 11 | add_library( 12 | yuv-sample 13 | SHARED 14 | ${SRC_LISTS} 15 | ) 16 | 17 | # 将打包的 so 链接到项目中 18 | target_link_libraries( 19 | # 目标库 20 | yuv-sample 21 | # other libs 22 | yuv 23 | # Android libs 24 | jnigraphics 25 | log 26 | ) -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion 28 7 | defaultConfig { 8 | minSdkVersion 19 9 | targetSdkVersion 28 10 | externalNativeBuild { 11 | ndk { 12 | abiFilters "armeabi-v7a" 13 | } 14 | } 15 | } 16 | externalNativeBuild { 17 | cmake { 18 | path "CMakeLists.txt" 19 | } 20 | } 21 | sourceSets { 22 | main { 23 | jniLibs.srcDirs = ['src/main/jniLibs'] 24 | } 25 | } 26 | } 27 | 28 | dependencies { 29 | implementation fileTree(dir: 'libs', include: ['*.jar']) 30 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 31 | implementation 'androidx.appcompat:appcompat:1.0.2' 32 | implementation 'androidx.core:core-ktx:1.0.2' 33 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 34 | } 35 | -------------------------------------------------------------------------------- /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 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/cpp/ConstDefine.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Sharry Choo on 2019-06-17. 3 | // 4 | #ifndef SCAMERA_CONSTDEFINE_H 5 | #define SCAMERA_CONSTDEFINE_H 6 | 7 | #include 8 | 9 | #define TAG "SCamera-Native" 10 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) 11 | #define NV21_UTIL_CLASS_NAME "com/sharry/sample/libyuv/LibyuvUtil" 12 | #endif //SCAMERA_CONSTDEFINE_H 13 | -------------------------------------------------------------------------------- /app/src/main/cpp/LibyuvUtil.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Sharry Choo on 2019-07-24. 3 | // 4 | 5 | #include "LibyuvUtil.h" 6 | #include "libyuv.h" 7 | 8 | void LibyuvUtil::NV21ToI420(jbyte *src, jbyte *dst, int width, int height) { 9 | // NV21 参数 10 | jint src_y_size = width * height; 11 | jbyte *src_y = src; 12 | jbyte *src_vu = src + src_y_size; 13 | // I420 参数 14 | jint dst_y_size = width * height; 15 | jint dst_u_size = dst_y_size >> 2; 16 | jbyte *dst_y = dst; 17 | jbyte *dst_u = dst + dst_y_size; 18 | jbyte *dst_v = dst + dst_y_size + dst_u_size; 19 | /** 20 | *

 21 |     * int NV21ToI420(const uint8_t* src_y,
 22 |     *          int src_stride_y,
 23 |     *          const uint8_t* src_vu,
 24 |     *          int src_stride_vu,
 25 |     *          uint8_t* dst_y,
 26 |     *          int dst_stride_y,
 27 |     *          uint8_t* dst_u,
 28 |     *          int dst_stride_u,
 29 |     *          uint8_t* dst_v,
 30 |     *          int dst_stride_v,
 31 |     *          int width,
 32 |     *          int height);
 33 |     * 
34 | *

35 | * stride 为颜色分量的跨距: 它描述一行像素中, 该颜色分量所占的 byte 数目, YUV 每个通道均为 1byte(8bit) 36 | *

37 | * stride_y: Y 是最全的, 一行中有 width 个像素, 也就有 width 个 Y 38 | * stride_u: YUV420 的采样为 Y:U:V = 4:1:1, 从整体的存储来看, 一个 Y 分量的数目为 U/V 的四倍 39 | * 但从一行上来看, width 个 Y, 它会用到 width/2 个 U 40 | * stride_v: 同 stride_u 的分析方式 41 | */ 42 | libyuv::NV21ToI420( 43 | (uint8_t *) src_y, width, 44 | (uint8_t *) src_vu, width, 45 | (uint8_t *) dst_y, width, 46 | (uint8_t *) dst_u, width >> 1, 47 | (uint8_t *) dst_v, width >> 1, 48 | width, height 49 | ); 50 | } 51 | 52 | void LibyuvUtil::I420ToNV12(jbyte *src, jbyte *dst, int width, int height) { 53 | 54 | jint src_y_size = width * height; 55 | jint src_u_size = src_y_size >> 2; 56 | jbyte *src_y = src; 57 | jbyte *src_u = src + src_y_size; 58 | jbyte *src_v = src + src_y_size + src_u_size; 59 | 60 | jint dst_y_size = width * height; 61 | jbyte *dst_y = dst; 62 | jbyte *dst_uv = dst + dst_y_size; 63 | 64 | libyuv::I420ToNV12( 65 | (uint8_t *) src_y, width, 66 | (uint8_t *) src_u, width >> 1, 67 | (uint8_t *) src_v, width >> 1, 68 | (uint8_t *) dst_y, width, 69 | (uint8_t *) dst_uv, width, 70 | width, height 71 | ); 72 | } 73 | 74 | void LibyuvUtil::I420ToABGR(jbyte *src, int width, int height, void *dst, int dst_stride) { 75 | jint src_y_size = width * height; 76 | jint src_u_size = src_y_size >> 2; 77 | jbyte *src_y = src; 78 | jbyte *src_u = src + src_y_size; 79 | jbyte *src_v = src + src_y_size + src_u_size; 80 | libyuv::I420ToABGR( 81 | (uint8_t *) src_y, width, 82 | (uint8_t *) src_u, width >> 1, 83 | (uint8_t *) src_v, width >> 1, 84 | (uint8_t *) dst, dst_stride, 85 | width, height 86 | ); 87 | } 88 | 89 | void LibyuvUtil::I420ToNV21(jbyte *src, jbyte *dst, int width, int height) { 90 | jint src_y_size = width * height; 91 | jint src_u_size = src_y_size >> 2; 92 | jbyte *src_y = src; 93 | jbyte *src_u = src + src_y_size; 94 | jbyte *src_v = src + src_y_size + src_u_size; 95 | 96 | jint dst_y_size = width * height; 97 | jbyte *dst_y = dst; 98 | jbyte *dst_vu = dst + dst_y_size; 99 | 100 | libyuv::I420ToNV21( 101 | (uint8_t *) src_y, width, 102 | (uint8_t *) src_u, width >> 1, 103 | (uint8_t *) src_v, width >> 1, 104 | (uint8_t *) dst_y, width, 105 | (uint8_t *) dst_vu, width, 106 | width, height 107 | ); 108 | } 109 | 110 | void LibyuvUtil::I420Scale(jbyte *src, int src_width, int src_height, jbyte *dst, 111 | int dst_width, int dst_height) { 112 | jint src_y_size = src_width * src_height; 113 | jint src_u_size = src_y_size >> 2; 114 | jbyte *src_y = src; 115 | jbyte *src_u = src + src_y_size; 116 | jbyte *src_v = src + src_y_size + src_u_size; 117 | 118 | jint dst_y_size = dst_width * dst_height; 119 | jint dst_u_size = dst_y_size >> 2; 120 | jbyte *dst_y = dst; 121 | jbyte *dst_u = dst + dst_y_size; 122 | jbyte *dst_v = dst + dst_y_size + dst_u_size; 123 | 124 | libyuv::I420Scale( 125 | (uint8_t *) src_y, src_width, 126 | (uint8_t *) src_u, src_width >> 1, 127 | (uint8_t *) src_v, src_width >> 1, 128 | src_width, src_height, 129 | (uint8_t *) dst_y, dst_width, 130 | (uint8_t *) dst_u, dst_width >> 1, 131 | (uint8_t *) dst_v, dst_width >> 1, 132 | dst_width, dst_height, 133 | libyuv::FilterMode::kFilterNone 134 | ); 135 | 136 | } 137 | 138 | void LibyuvUtil::I420Rotate(jbyte *src, jbyte *dst, int &width, int &height, 139 | int degree) { 140 | jint src_y_size = width * height; 141 | jint src_u_size = src_y_size >> 2; 142 | jbyte *src_y = src; 143 | jbyte *src_u = src + src_y_size; 144 | jbyte *src_v = src + src_y_size + src_u_size; 145 | 146 | jbyte *dst_y = dst; 147 | jbyte *dst_u = dst + src_y_size; 148 | jbyte *dst_v = dst + src_y_size + src_u_size; 149 | 150 | libyuv::I420Rotate( 151 | (uint8_t *) src_y, width, 152 | (uint8_t *) src_u, width >> 1, 153 | (uint8_t *) src_v, width >> 1, 154 | (uint8_t *) dst_y, height, 155 | (uint8_t *) dst_u, height >> 1, 156 | (uint8_t *) dst_v, height >> 1, 157 | width, height, (libyuv::RotationMode) degree 158 | ); 159 | // 若为 90 / 270, 则翻转宽高 160 | if (degree == libyuv::kRotate90 || degree == libyuv::kRotate270) { 161 | width += height; 162 | height = width - height; 163 | width -= height; 164 | } 165 | } 166 | 167 | void LibyuvUtil::I420Mirror(jbyte *src, jbyte *dst, int width, int height) { 168 | jint src_y_size = width * height; 169 | jint src_u_size = src_y_size >> 2; 170 | jbyte *src_y = src; 171 | jbyte *src_u = src + src_y_size; 172 | jbyte *src_v = src + src_y_size + src_u_size; 173 | 174 | jbyte *dst_y = dst; 175 | jbyte *dst_u = dst + src_y_size; 176 | jbyte *dst_v = dst + src_y_size + src_u_size; 177 | 178 | libyuv::I420Mirror((uint8_t *) src_y, width, 179 | (uint8_t *) src_u, width >> 1, 180 | (uint8_t *) src_v, width >> 1, 181 | (uint8_t *) dst_y, width, 182 | (uint8_t *) dst_u, width >> 1, 183 | (uint8_t *) dst_v, width >> 1, 184 | width, height); 185 | } 186 | 187 | void LibyuvUtil::I420Crop(jbyte *src, int src_width, int src_height, jbyte *dst, int dst_width, 188 | int dst_height, int left, int top) { 189 | jint dst_y_size = dst_width * dst_height; 190 | jint dst_u_size = dst_y_size >> 2; 191 | jbyte *dst_y = dst; 192 | jbyte *dst_u = dst + dst_y_size; 193 | jbyte *dst_v = dst + dst_y_size + dst_u_size; 194 | 195 | libyuv::ConvertToI420( 196 | (uint8_t *) src, (size_t) src_width * src_height * 3 / 2, 197 | (uint8_t *) dst_y, dst_width, 198 | (uint8_t *) dst_u, dst_width >> 1, 199 | (uint8_t *) dst_v, dst_width >> 1, 200 | left, top, 201 | src_width, src_height, 202 | dst_width, dst_height, 203 | libyuv::kRotate0, libyuv::FOURCC_I420 204 | ); 205 | 206 | } 207 | -------------------------------------------------------------------------------- /app/src/main/cpp/LibyuvUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Sharry Choo on 2019-07-24. 3 | // 4 | 5 | #ifndef SMEDIA_LIBYUVUTILS_H 6 | #define SMEDIA_LIBYUVUTILS_H 7 | 8 | #include 9 | 10 | class LibyuvUtil { 11 | 12 | public: 13 | static void NV21ToI420(jbyte *src, jbyte *dst, int width, int height); 14 | 15 | static void I420ToNV12(jbyte *src, jbyte *dst, int width, int height); 16 | 17 | static void I420ToNV21(jbyte *src, jbyte *dst, int width, int height); 18 | 19 | static void I420ToABGR(jbyte *src, int width, int height, void *dst, int dst_stride); 20 | 21 | static void I420Scale(jbyte *src, int src_width, int src_height, jbyte *dst, 22 | int dst_width, int dst_height); 23 | 24 | static void I420Rotate(jbyte *src, jbyte *dst, int &width, int &height, int degree); 25 | 26 | static void I420Mirror(jbyte *src, jbyte *dst, int width, int height); 27 | 28 | static void I420Crop(jbyte *src, int src_width, int src_height, jbyte *dst, 29 | int dst_width, int dst_height, int left, int top); 30 | }; 31 | 32 | 33 | #endif //SMEDIA_LIBYUVUTILS_H 34 | -------------------------------------------------------------------------------- /app/src/main/cpp/native-bridge.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "ConstDefine.h" 5 | #include "LibyuvUtil.h" 6 | 7 | int registerNativeMethods(JNIEnv *env, jclass cls); 8 | 9 | extern "C" 10 | JNIEXPORT jint JNICALL 11 | JNI_OnLoad(JavaVM *javaVM, void *reserverd) { 12 | // 通过初始化方法获取 JavaVM 13 | JNIEnv *env; 14 | if (javaVM->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { 15 | return -1; 16 | } 17 | jclass jAudioPlayerCls = env->FindClass(NV21_UTIL_CLASS_NAME); 18 | jAudioPlayerCls = reinterpret_cast(env->NewGlobalRef(jAudioPlayerCls)); 19 | if (!jAudioPlayerCls) { 20 | LOGE("Fail to create global reference for %s", NV21_UTIL_CLASS_NAME); 21 | } 22 | int res = registerNativeMethods(env, jAudioPlayerCls); 23 | if (res != 0) { 24 | LOGE("Failed to register native methods for class %s ", NV21_UTIL_CLASS_NAME); 25 | } 26 | env->DeleteGlobalRef(jAudioPlayerCls); 27 | return JNI_VERSION_1_6; 28 | } 29 | 30 | namespace libyuv_util { 31 | 32 | void convertI420ToNV12(JNIEnv *env, jclass, jbyteArray i420_src, jbyteArray nv12_dst, int width, 33 | int height) { 34 | jbyte *src = env->GetByteArrayElements(i420_src, NULL); 35 | jbyte *dst = env->GetByteArrayElements(nv12_dst, NULL); 36 | // 执行转换 I420 -> NV12 的转换 37 | LibyuvUtil::I420ToNV12(src, dst, width, height); 38 | // 释放资源 39 | env->ReleaseByteArrayElements(i420_src, src, 0); 40 | env->ReleaseByteArrayElements(nv12_dst, dst, 0); 41 | } 42 | 43 | void compressI420(JNIEnv *env, jclass, jbyteArray i420_src, int src_width, 44 | int src_height, jbyteArray i420_dst, int dst_width, 45 | int dst_height, int degree, jboolean isMirror) { 46 | jbyte *src = env->GetByteArrayElements(i420_src, NULL); 47 | const int dst_size = dst_width * dst_height * 3 / 2; 48 | // step1: 缩放处理 49 | jbyte *scaled = src; 50 | if (src_width != dst_width || src_height != dst_height) { 51 | scaled = new jbyte[dst_size]; 52 | LibyuvUtil::I420Scale(src, src_width, src_height, scaled, dst_width, 53 | dst_height); 54 | } 55 | // step2: 旋转处理 56 | jbyte *rotated = scaled; 57 | if (degree != 0) { 58 | rotated = new jbyte[dst_size]; 59 | // 若为 90/270 旋转之后会反转 width 和 height 60 | LibyuvUtil::I420Rotate(scaled, rotated, dst_width, dst_height, degree); 61 | if (scaled != src) { 62 | delete[]scaled; 63 | } 64 | } 65 | // step3: 镜像处理 66 | jbyte *mirrored = rotated; 67 | if (isMirror) { 68 | mirrored = new jbyte[dst_size]; 69 | LibyuvUtil::I420Mirror(rotated, mirrored, dst_width, dst_height); 70 | if (rotated != src) { 71 | delete[]rotated; 72 | } 73 | } 74 | // step4: 将数据拷贝到 dst 中 75 | jbyte *dst = env->GetByteArrayElements(i420_dst, NULL); 76 | memcpy(dst, mirrored, (size_t) dst_size); 77 | // 释放资源 78 | if (mirrored != src) { 79 | delete[]mirrored; 80 | } 81 | env->ReleaseByteArrayElements(i420_src, src, 0); 82 | env->ReleaseByteArrayElements(i420_dst, dst, 0); 83 | } 84 | 85 | void convertI420ToBitmap(JNIEnv *env, jclass, jbyteArray nv21_src, jobject bitmap, int width, 86 | int height) { 87 | jbyte *src = env->GetByteArrayElements(nv21_src, NULL); 88 | // 锁定画布 89 | void *dst_argb; 90 | AndroidBitmap_lockPixels(env, bitmap, &dst_argb); 91 | // 获取 bitmap 的信息 92 | AndroidBitmapInfo info; 93 | AndroidBitmap_getInfo(env, bitmap, &info); 94 | if (info.format == ANDROID_BITMAP_FORMAT_RGBA_8888) { 95 | // ABGR 的 stride 为 4 * width 96 | LibyuvUtil::I420ToABGR(src, width, height, dst_argb, info.stride); 97 | } else { 98 | // ignore. 99 | } 100 | // 解锁画布 101 | AndroidBitmap_unlockPixels(env, bitmap); 102 | // 释放通过 jbyteArray 创建的 jbyte* 103 | env->ReleaseByteArrayElements(nv21_src, src, 0); 104 | } 105 | 106 | void convertNV21ToI420(JNIEnv *env, jclass, jbyteArray nv21_src, jbyteArray nv12_dst, int width, 107 | int height) { 108 | jbyte *src = env->GetByteArrayElements(nv21_src, NULL); 109 | jbyte *dst = env->GetByteArrayElements(nv12_dst, NULL); 110 | // 执行转换 111 | LibyuvUtil::NV21ToI420(src, dst, width, height); 112 | // 释放通过 jbyteArray 创建的 jbyte* 113 | env->ReleaseByteArrayElements(nv21_src, src, 0); 114 | env->ReleaseByteArrayElements(nv12_dst, dst, 0); 115 | } 116 | } 117 | 118 | JNINativeMethod libyuv_util_methods[] = { 119 | {"convertNV21ToI420", "([B[BII)V", (void *) libyuv_util::convertNV21ToI420}, 120 | {"convertI420ToNV12", "([B[BII)V", (void *) libyuv_util::convertI420ToNV12}, 121 | {"convertI420ToBitmap", "([BLandroid/graphics/Bitmap;II)V", (void *) libyuv_util::convertI420ToBitmap}, 122 | {"compressI420", "([BII[BIIIZ)V", (void *) libyuv_util::compressI420}, 123 | }; 124 | 125 | int registerNativeMethods(JNIEnv *env, jclass cls) { 126 | return env->RegisterNatives(cls, libyuv_util_methods, 127 | sizeof(libyuv_util_methods) / sizeof(libyuv_util_methods[0])); 128 | } 129 | 130 | -------------------------------------------------------------------------------- /app/src/main/java/com/sharry/sample/libyuv/LibyuvUtil.java: -------------------------------------------------------------------------------- 1 | package com.sharry.sample.libyuv; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | /** 6 | * 处理 YUV 的工具类 7 | * 8 | * @author Sharry Contact me. 9 | * @version 1.0 10 | * @since 2019-07-23 11 | */ 12 | public class LibyuvUtil { 13 | 14 | static { 15 | System.loadLibrary("yuv-sample"); 16 | } 17 | 18 | /** 19 | * 将 NV21 转 I420 20 | */ 21 | public static native void convertNV21ToI420(byte[] src, byte[] dst, int width, int height); 22 | 23 | /** 24 | * 压缩 I420 数据 25 | *

26 | * 执行顺序为:缩放->旋转->镜像 27 | * 28 | * @param src 原始数据 29 | * @param srcWidth 原始宽度 30 | * @param srcHeight 原始高度 31 | * @param dst 输出数据 32 | * @param dstWidth 输出宽度 33 | * @param dstHeight 输出高度 34 | * @param degree 旋转(90, 180, 270) 35 | * @param isMirror 镜像(镜像在旋转之后) 36 | */ 37 | public static native void compressI420(byte[] src, int srcWidth, int srcHeight, 38 | byte[] dst, int dstWidth, int dstHeight, 39 | int degree, boolean isMirror); 40 | 41 | /** 42 | * 将 I420 数据注入到 Bitmap 中 43 | */ 44 | public static native void convertI420ToBitmap(byte[] src, Bitmap dst, int width, int height); 45 | 46 | /** 47 | * 将 I420 转 NV12 48 | */ 49 | public static native void convertI420ToNV12(byte[] src, byte[] dst, int width, int height); 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/sharry/sample/libyuv/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.sharry.sample.libyuv 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | 6 | class MainActivity : AppCompatActivity() { 7 | 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_main) 11 | // 测试代码 12 | val width = 100 13 | val height = 100 14 | val nv21Bytes = ByteArray(width * height * 3 / 2) 15 | val i420Bytes = ByteArray(width * height * 3 / 2) 16 | LibyuvUtil.convertNV21ToI420(nv21Bytes, i420Bytes, width, height) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi-v7a/libyuv.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/app/src/main/jniLibs/armeabi-v7a/libyuv.so -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_H_ 12 | #define INCLUDE_LIBYUV_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/compare.h" 16 | #include "libyuv/convert.h" 17 | #include "libyuv/convert_argb.h" 18 | #include "libyuv/convert_from.h" 19 | #include "libyuv/convert_from_argb.h" 20 | #include "libyuv/cpu_id.h" 21 | #include "libyuv/mjpeg_decoder.h" 22 | #include "libyuv/planar_functions.h" 23 | #include "libyuv/rotate.h" 24 | #include "libyuv/rotate_argb.h" 25 | #include "libyuv/row.h" 26 | #include "libyuv/scale.h" 27 | #include "libyuv/scale_argb.h" 28 | #include "libyuv/scale_row.h" 29 | #include "libyuv/version.h" 30 | #include "libyuv/video_common.h" 31 | 32 | #endif // INCLUDE_LIBYUV_H_ 33 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/basic_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ 12 | #define INCLUDE_LIBYUV_BASIC_TYPES_H_ 13 | 14 | #include // For size_t and NULL 15 | 16 | #if !defined(INT_TYPES_DEFINED) && !defined(GG_LONGLONG) 17 | #define INT_TYPES_DEFINED 18 | 19 | #if defined(_MSC_VER) && (_MSC_VER < 1600) 20 | #include // for uintptr_t on x86 21 | typedef unsigned __int64 uint64_t; 22 | typedef __int64 int64_t; 23 | typedef unsigned int uint32_t; 24 | typedef int int32_t; 25 | typedef unsigned short uint16_t; 26 | typedef short int16_t; 27 | typedef unsigned char uint8_t; 28 | typedef signed char int8_t; 29 | #else 30 | #include // for uintptr_t and C99 types 31 | #endif // defined(_MSC_VER) && (_MSC_VER < 1600) 32 | // Types are deprecated. Enable this macro for legacy types. 33 | #ifdef LIBYUV_LEGACY_TYPES 34 | typedef uint64_t uint64; 35 | typedef int64_t int64; 36 | typedef uint32_t uint32; 37 | typedef int32_t int32; 38 | typedef uint16_t uint16; 39 | typedef int16_t int16; 40 | typedef uint8_t uint8; 41 | typedef int8_t int8; 42 | #endif // LIBYUV_LEGACY_TYPES 43 | #endif // INT_TYPES_DEFINED 44 | 45 | #if !defined(LIBYUV_API) 46 | #if defined(_WIN32) || defined(__CYGWIN__) 47 | #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) 48 | #define LIBYUV_API __declspec(dllexport) 49 | #elif defined(LIBYUV_USING_SHARED_LIBRARY) 50 | #define LIBYUV_API __declspec(dllimport) 51 | #else 52 | #define LIBYUV_API 53 | #endif // LIBYUV_BUILDING_SHARED_LIBRARY 54 | #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ 55 | (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ 56 | defined(LIBYUV_USING_SHARED_LIBRARY)) 57 | #define LIBYUV_API __attribute__((visibility("default"))) 58 | #else 59 | #define LIBYUV_API 60 | #endif // __GNUC__ 61 | #endif // LIBYUV_API 62 | 63 | // TODO(fbarchard): Remove bool macros. 64 | #define LIBYUV_BOOL int 65 | #define LIBYUV_FALSE 0 66 | #define LIBYUV_TRUE 1 67 | 68 | #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ 69 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_COMPARE_H_ 12 | #define INCLUDE_LIBYUV_COMPARE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Compute a hash for specified memory. Seed of 5381 recommended. 22 | LIBYUV_API 23 | uint32_t HashDjb2(const uint8_t* src, uint64_t count, uint32_t seed); 24 | 25 | // Hamming Distance 26 | LIBYUV_API 27 | uint64_t ComputeHammingDistance(const uint8_t* src_a, 28 | const uint8_t* src_b, 29 | int count); 30 | 31 | // Scan an opaque argb image and return fourcc based on alpha offset. 32 | // Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown. 33 | LIBYUV_API 34 | uint32_t ARGBDetect(const uint8_t* argb, 35 | int stride_argb, 36 | int width, 37 | int height); 38 | 39 | // Sum Square Error - used to compute Mean Square Error or PSNR. 40 | LIBYUV_API 41 | uint64_t ComputeSumSquareError(const uint8_t* src_a, 42 | const uint8_t* src_b, 43 | int count); 44 | 45 | LIBYUV_API 46 | uint64_t ComputeSumSquareErrorPlane(const uint8_t* src_a, 47 | int stride_a, 48 | const uint8_t* src_b, 49 | int stride_b, 50 | int width, 51 | int height); 52 | 53 | static const int kMaxPsnr = 128; 54 | 55 | LIBYUV_API 56 | double SumSquareErrorToPsnr(uint64_t sse, uint64_t count); 57 | 58 | LIBYUV_API 59 | double CalcFramePsnr(const uint8_t* src_a, 60 | int stride_a, 61 | const uint8_t* src_b, 62 | int stride_b, 63 | int width, 64 | int height); 65 | 66 | LIBYUV_API 67 | double I420Psnr(const uint8_t* src_y_a, 68 | int stride_y_a, 69 | const uint8_t* src_u_a, 70 | int stride_u_a, 71 | const uint8_t* src_v_a, 72 | int stride_v_a, 73 | const uint8_t* src_y_b, 74 | int stride_y_b, 75 | const uint8_t* src_u_b, 76 | int stride_u_b, 77 | const uint8_t* src_v_b, 78 | int stride_v_b, 79 | int width, 80 | int height); 81 | 82 | LIBYUV_API 83 | double CalcFrameSsim(const uint8_t* src_a, 84 | int stride_a, 85 | const uint8_t* src_b, 86 | int stride_b, 87 | int width, 88 | int height); 89 | 90 | LIBYUV_API 91 | double I420Ssim(const uint8_t* src_y_a, 92 | int stride_y_a, 93 | const uint8_t* src_u_a, 94 | int stride_u_a, 95 | const uint8_t* src_v_a, 96 | int stride_v_a, 97 | const uint8_t* src_y_b, 98 | int stride_y_b, 99 | const uint8_t* src_u_b, 100 | int stride_u_b, 101 | const uint8_t* src_v_b, 102 | int stride_v_b, 103 | int width, 104 | int height); 105 | 106 | #ifdef __cplusplus 107 | } // extern "C" 108 | } // namespace libyuv 109 | #endif 110 | 111 | #endif // INCLUDE_LIBYUV_COMPARE_H_ 112 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/compare_row.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 | #ifndef INCLUDE_LIBYUV_COMPARE_ROW_H_ 12 | #define INCLUDE_LIBYUV_COMPARE_ROW_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | #if defined(__pnacl__) || defined(__CLR_VER) || \ 22 | (defined(__native_client__) && defined(__x86_64__)) || \ 23 | (defined(__i386__) && !defined(__SSE__) && !defined(__clang__)) 24 | #define LIBYUV_DISABLE_X86 25 | #endif 26 | #if defined(__native_client__) 27 | #define LIBYUV_DISABLE_NEON 28 | #endif 29 | // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 30 | #if defined(__has_feature) 31 | #if __has_feature(memory_sanitizer) 32 | #define LIBYUV_DISABLE_X86 33 | #endif 34 | #endif 35 | // Visual C 2012 required for AVX2. 36 | #if defined(_M_IX86) && !defined(__clang__) && defined(_MSC_VER) && \ 37 | _MSC_VER >= 1700 38 | #define VISUALC_HAS_AVX2 1 39 | #endif // VisualStudio >= 2012 40 | 41 | // clang >= 3.4.0 required for AVX2. 42 | #if defined(__clang__) && (defined(__x86_64__) || defined(__i386__)) 43 | #if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4)) 44 | #define CLANG_HAS_AVX2 1 45 | #endif // clang >= 3.4 46 | #endif // __clang__ 47 | 48 | // The following are available for Visual C and GCC: 49 | #if !defined(LIBYUV_DISABLE_X86) && \ 50 | (defined(__x86_64__) || defined(__i386__) || defined(_M_IX86)) 51 | #define HAS_HASHDJB2_SSE41 52 | #define HAS_SUMSQUAREERROR_SSE2 53 | #define HAS_HAMMINGDISTANCE_SSE42 54 | #endif 55 | 56 | // The following are available for Visual C and clangcl 32 bit: 57 | #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER) && \ 58 | (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2)) 59 | #define HAS_HASHDJB2_AVX2 60 | #define HAS_SUMSQUAREERROR_AVX2 61 | #endif 62 | 63 | // The following are available for GCC and clangcl 64 bit: 64 | #if !defined(LIBYUV_DISABLE_X86) && \ 65 | (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER))) 66 | #define HAS_HAMMINGDISTANCE_SSSE3 67 | #endif 68 | 69 | // The following are available for GCC and clangcl 64 bit: 70 | #if !defined(LIBYUV_DISABLE_X86) && defined(CLANG_HAS_AVX2) && \ 71 | (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER))) 72 | #define HAS_HAMMINGDISTANCE_AVX2 73 | #endif 74 | 75 | // The following are available for Neon: 76 | #if !defined(LIBYUV_DISABLE_NEON) && \ 77 | (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__)) 78 | #define HAS_SUMSQUAREERROR_NEON 79 | #define HAS_HAMMINGDISTANCE_NEON 80 | #endif 81 | 82 | #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) 83 | #define HAS_HAMMINGDISTANCE_MSA 84 | #define HAS_SUMSQUAREERROR_MSA 85 | #endif 86 | 87 | #if !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A) 88 | #define HAS_HAMMINGDISTANCE_MMI 89 | #define HAS_SUMSQUAREERROR_MMI 90 | #endif 91 | 92 | uint32_t HammingDistance_C(const uint8_t* src_a, 93 | const uint8_t* src_b, 94 | int count); 95 | uint32_t HammingDistance_SSE42(const uint8_t* src_a, 96 | const uint8_t* src_b, 97 | int count); 98 | uint32_t HammingDistance_SSSE3(const uint8_t* src_a, 99 | const uint8_t* src_b, 100 | int count); 101 | uint32_t HammingDistance_AVX2(const uint8_t* src_a, 102 | const uint8_t* src_b, 103 | int count); 104 | uint32_t HammingDistance_NEON(const uint8_t* src_a, 105 | const uint8_t* src_b, 106 | int count); 107 | uint32_t HammingDistance_MSA(const uint8_t* src_a, 108 | const uint8_t* src_b, 109 | int count); 110 | uint32_t HammingDistance_MMI(const uint8_t* src_a, 111 | const uint8_t* src_b, 112 | int count); 113 | uint32_t SumSquareError_C(const uint8_t* src_a, 114 | const uint8_t* src_b, 115 | int count); 116 | uint32_t SumSquareError_SSE2(const uint8_t* src_a, 117 | const uint8_t* src_b, 118 | int count); 119 | uint32_t SumSquareError_AVX2(const uint8_t* src_a, 120 | const uint8_t* src_b, 121 | int count); 122 | uint32_t SumSquareError_NEON(const uint8_t* src_a, 123 | const uint8_t* src_b, 124 | int count); 125 | uint32_t SumSquareError_MSA(const uint8_t* src_a, 126 | const uint8_t* src_b, 127 | int count); 128 | uint32_t SumSquareError_MMI(const uint8_t* src_a, 129 | const uint8_t* src_b, 130 | int count); 131 | 132 | uint32_t HashDjb2_C(const uint8_t* src, int count, uint32_t seed); 133 | uint32_t HashDjb2_SSE41(const uint8_t* src, int count, uint32_t seed); 134 | uint32_t HashDjb2_AVX2(const uint8_t* src, int count, uint32_t seed); 135 | 136 | #ifdef __cplusplus 137 | } // extern "C" 138 | } // namespace libyuv 139 | #endif 140 | 141 | #endif // INCLUDE_LIBYUV_COMPARE_ROW_H_ 142 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/convert.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_CONVERT_H_ 12 | #define INCLUDE_LIBYUV_CONVERT_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #include "libyuv/rotate.h" // For enum RotationMode. 17 | 18 | // TODO(fbarchard): fix WebRTC source to include following libyuv headers: 19 | #include "libyuv/convert_argb.h" // For WebRTC I420ToARGB. b/620 20 | #include "libyuv/convert_from.h" // For WebRTC ConvertFromI420. b/620 21 | #include "libyuv/planar_functions.h" // For WebRTC I420Rect, CopyPlane. b/618 22 | 23 | #ifdef __cplusplus 24 | namespace libyuv { 25 | extern "C" { 26 | #endif 27 | 28 | // Convert I444 to I420. 29 | LIBYUV_API 30 | int I444ToI420(const uint8_t* src_y, 31 | int src_stride_y, 32 | const uint8_t* src_u, 33 | int src_stride_u, 34 | const uint8_t* src_v, 35 | int src_stride_v, 36 | uint8_t* dst_y, 37 | int dst_stride_y, 38 | uint8_t* dst_u, 39 | int dst_stride_u, 40 | uint8_t* dst_v, 41 | int dst_stride_v, 42 | int width, 43 | int height); 44 | 45 | // Convert I444 to NV21. 46 | LIBYUV_API 47 | int I444ToNV21(const uint8_t* src_y, 48 | int src_stride_y, 49 | const uint8_t* src_u, 50 | int src_stride_u, 51 | const uint8_t* src_v, 52 | int src_stride_v, 53 | uint8_t* dst_y, 54 | int dst_stride_y, 55 | uint8_t* dst_vu, 56 | int dst_stride_vu, 57 | int width, 58 | int height); 59 | 60 | // Convert I422 to I420. 61 | LIBYUV_API 62 | int I422ToI420(const uint8_t* src_y, 63 | int src_stride_y, 64 | const uint8_t* src_u, 65 | int src_stride_u, 66 | const uint8_t* src_v, 67 | int src_stride_v, 68 | uint8_t* dst_y, 69 | int dst_stride_y, 70 | uint8_t* dst_u, 71 | int dst_stride_u, 72 | uint8_t* dst_v, 73 | int dst_stride_v, 74 | int width, 75 | int height); 76 | 77 | // Convert I422 to NV21. 78 | LIBYUV_API 79 | int I422ToNV21(const uint8_t* src_y, 80 | int src_stride_y, 81 | const uint8_t* src_u, 82 | int src_stride_u, 83 | const uint8_t* src_v, 84 | int src_stride_v, 85 | uint8_t* dst_y, 86 | int dst_stride_y, 87 | uint8_t* dst_vu, 88 | int dst_stride_vu, 89 | int width, 90 | int height); 91 | 92 | // Copy I420 to I420. 93 | #define I420ToI420 I420Copy 94 | LIBYUV_API 95 | int I420Copy(const uint8_t* src_y, 96 | int src_stride_y, 97 | const uint8_t* src_u, 98 | int src_stride_u, 99 | const uint8_t* src_v, 100 | int src_stride_v, 101 | uint8_t* dst_y, 102 | int dst_stride_y, 103 | uint8_t* dst_u, 104 | int dst_stride_u, 105 | uint8_t* dst_v, 106 | int dst_stride_v, 107 | int width, 108 | int height); 109 | 110 | // Copy I010 to I010 111 | #define I010ToI010 I010Copy 112 | #define H010ToH010 I010Copy 113 | LIBYUV_API 114 | int I010Copy(const uint16_t* src_y, 115 | int src_stride_y, 116 | const uint16_t* src_u, 117 | int src_stride_u, 118 | const uint16_t* src_v, 119 | int src_stride_v, 120 | uint16_t* dst_y, 121 | int dst_stride_y, 122 | uint16_t* dst_u, 123 | int dst_stride_u, 124 | uint16_t* dst_v, 125 | int dst_stride_v, 126 | int width, 127 | int height); 128 | 129 | // Convert 10 bit YUV to 8 bit 130 | #define H010ToH420 I010ToI420 131 | LIBYUV_API 132 | int I010ToI420(const uint16_t* src_y, 133 | int src_stride_y, 134 | const uint16_t* src_u, 135 | int src_stride_u, 136 | const uint16_t* src_v, 137 | int src_stride_v, 138 | uint8_t* dst_y, 139 | int dst_stride_y, 140 | uint8_t* dst_u, 141 | int dst_stride_u, 142 | uint8_t* dst_v, 143 | int dst_stride_v, 144 | int width, 145 | int height); 146 | 147 | // Convert I400 (grey) to I420. 148 | LIBYUV_API 149 | int I400ToI420(const uint8_t* src_y, 150 | int src_stride_y, 151 | uint8_t* dst_y, 152 | int dst_stride_y, 153 | uint8_t* dst_u, 154 | int dst_stride_u, 155 | uint8_t* dst_v, 156 | int dst_stride_v, 157 | int width, 158 | int height); 159 | 160 | // Convert I400 (grey) to NV21. 161 | LIBYUV_API 162 | int I400ToNV21(const uint8_t* src_y, 163 | int src_stride_y, 164 | uint8_t* dst_y, 165 | int dst_stride_y, 166 | uint8_t* dst_vu, 167 | int dst_stride_vu, 168 | int width, 169 | int height); 170 | 171 | #define J400ToJ420 I400ToI420 172 | 173 | // Convert NV12 to I420. 174 | LIBYUV_API 175 | int NV12ToI420(const uint8_t* src_y, 176 | int src_stride_y, 177 | const uint8_t* src_uv, 178 | int src_stride_uv, 179 | uint8_t* dst_y, 180 | int dst_stride_y, 181 | uint8_t* dst_u, 182 | int dst_stride_u, 183 | uint8_t* dst_v, 184 | int dst_stride_v, 185 | int width, 186 | int height); 187 | 188 | // Convert NV21 to I420. 189 | LIBYUV_API 190 | int NV21ToI420(const uint8_t* src_y, 191 | int src_stride_y, 192 | const uint8_t* src_vu, 193 | int src_stride_vu, 194 | uint8_t* dst_y, 195 | int dst_stride_y, 196 | uint8_t* dst_u, 197 | int dst_stride_u, 198 | uint8_t* dst_v, 199 | int dst_stride_v, 200 | int width, 201 | int height); 202 | 203 | // Convert YUY2 to I420. 204 | LIBYUV_API 205 | int YUY2ToI420(const uint8_t* src_yuy2, 206 | int src_stride_yuy2, 207 | uint8_t* dst_y, 208 | int dst_stride_y, 209 | uint8_t* dst_u, 210 | int dst_stride_u, 211 | uint8_t* dst_v, 212 | int dst_stride_v, 213 | int width, 214 | int height); 215 | 216 | // Convert UYVY to I420. 217 | LIBYUV_API 218 | int UYVYToI420(const uint8_t* src_uyvy, 219 | int src_stride_uyvy, 220 | uint8_t* dst_y, 221 | int dst_stride_y, 222 | uint8_t* dst_u, 223 | int dst_stride_u, 224 | uint8_t* dst_v, 225 | int dst_stride_v, 226 | int width, 227 | int height); 228 | 229 | // Convert AYUV to NV12. 230 | LIBYUV_API 231 | int AYUVToNV12(const uint8_t* src_ayuv, 232 | int src_stride_ayuv, 233 | uint8_t* dst_y, 234 | int dst_stride_y, 235 | uint8_t* dst_uv, 236 | int dst_stride_uv, 237 | int width, 238 | int height); 239 | 240 | // Convert AYUV to NV21. 241 | LIBYUV_API 242 | int AYUVToNV21(const uint8_t* src_ayuv, 243 | int src_stride_ayuv, 244 | uint8_t* dst_y, 245 | int dst_stride_y, 246 | uint8_t* dst_vu, 247 | int dst_stride_vu, 248 | int width, 249 | int height); 250 | 251 | // Convert M420 to I420. 252 | LIBYUV_API 253 | int M420ToI420(const uint8_t* src_m420, 254 | int src_stride_m420, 255 | uint8_t* dst_y, 256 | int dst_stride_y, 257 | uint8_t* dst_u, 258 | int dst_stride_u, 259 | uint8_t* dst_v, 260 | int dst_stride_v, 261 | int width, 262 | int height); 263 | 264 | // Convert Android420 to I420. 265 | LIBYUV_API 266 | int Android420ToI420(const uint8_t* src_y, 267 | int src_stride_y, 268 | const uint8_t* src_u, 269 | int src_stride_u, 270 | const uint8_t* src_v, 271 | int src_stride_v, 272 | int src_pixel_stride_uv, 273 | uint8_t* dst_y, 274 | int dst_stride_y, 275 | uint8_t* dst_u, 276 | int dst_stride_u, 277 | uint8_t* dst_v, 278 | int dst_stride_v, 279 | int width, 280 | int height); 281 | 282 | // ARGB little endian (bgra in memory) to I420. 283 | LIBYUV_API 284 | int ARGBToI420(const uint8_t* src_argb, 285 | int src_stride_argb, 286 | uint8_t* dst_y, 287 | int dst_stride_y, 288 | uint8_t* dst_u, 289 | int dst_stride_u, 290 | uint8_t* dst_v, 291 | int dst_stride_v, 292 | int width, 293 | int height); 294 | 295 | // BGRA little endian (argb in memory) to I420. 296 | LIBYUV_API 297 | int BGRAToI420(const uint8_t* src_bgra, 298 | int src_stride_bgra, 299 | uint8_t* dst_y, 300 | int dst_stride_y, 301 | uint8_t* dst_u, 302 | int dst_stride_u, 303 | uint8_t* dst_v, 304 | int dst_stride_v, 305 | int width, 306 | int height); 307 | 308 | // ABGR little endian (rgba in memory) to I420. 309 | LIBYUV_API 310 | int ABGRToI420(const uint8_t* src_abgr, 311 | int src_stride_abgr, 312 | uint8_t* dst_y, 313 | int dst_stride_y, 314 | uint8_t* dst_u, 315 | int dst_stride_u, 316 | uint8_t* dst_v, 317 | int dst_stride_v, 318 | int width, 319 | int height); 320 | 321 | // RGBA little endian (abgr in memory) to I420. 322 | LIBYUV_API 323 | int RGBAToI420(const uint8_t* src_rgba, 324 | int src_stride_rgba, 325 | uint8_t* dst_y, 326 | int dst_stride_y, 327 | uint8_t* dst_u, 328 | int dst_stride_u, 329 | uint8_t* dst_v, 330 | int dst_stride_v, 331 | int width, 332 | int height); 333 | 334 | // RGB little endian (bgr in memory) to I420. 335 | LIBYUV_API 336 | int RGB24ToI420(const uint8_t* src_rgb24, 337 | int src_stride_rgb24, 338 | uint8_t* dst_y, 339 | int dst_stride_y, 340 | uint8_t* dst_u, 341 | int dst_stride_u, 342 | uint8_t* dst_v, 343 | int dst_stride_v, 344 | int width, 345 | int height); 346 | 347 | // RGB little endian (bgr in memory) to J420. 348 | LIBYUV_API 349 | int RGB24ToJ420(const uint8_t* src_rgb24, 350 | int src_stride_rgb24, 351 | uint8_t* dst_y, 352 | int dst_stride_y, 353 | uint8_t* dst_u, 354 | int dst_stride_u, 355 | uint8_t* dst_v, 356 | int dst_stride_v, 357 | int width, 358 | int height); 359 | 360 | // RGB big endian (rgb in memory) to I420. 361 | LIBYUV_API 362 | int RAWToI420(const uint8_t* src_raw, 363 | int src_stride_raw, 364 | uint8_t* dst_y, 365 | int dst_stride_y, 366 | uint8_t* dst_u, 367 | int dst_stride_u, 368 | uint8_t* dst_v, 369 | int dst_stride_v, 370 | int width, 371 | int height); 372 | 373 | // RGB16 (RGBP fourcc) little endian to I420. 374 | LIBYUV_API 375 | int RGB565ToI420(const uint8_t* src_rgb565, 376 | int src_stride_rgb565, 377 | uint8_t* dst_y, 378 | int dst_stride_y, 379 | uint8_t* dst_u, 380 | int dst_stride_u, 381 | uint8_t* dst_v, 382 | int dst_stride_v, 383 | int width, 384 | int height); 385 | 386 | // RGB15 (RGBO fourcc) little endian to I420. 387 | LIBYUV_API 388 | int ARGB1555ToI420(const uint8_t* src_argb1555, 389 | int src_stride_argb1555, 390 | uint8_t* dst_y, 391 | int dst_stride_y, 392 | uint8_t* dst_u, 393 | int dst_stride_u, 394 | uint8_t* dst_v, 395 | int dst_stride_v, 396 | int width, 397 | int height); 398 | 399 | // RGB12 (R444 fourcc) little endian to I420. 400 | LIBYUV_API 401 | int ARGB4444ToI420(const uint8_t* src_argb4444, 402 | int src_stride_argb4444, 403 | uint8_t* dst_y, 404 | int dst_stride_y, 405 | uint8_t* dst_u, 406 | int dst_stride_u, 407 | uint8_t* dst_v, 408 | int dst_stride_v, 409 | int width, 410 | int height); 411 | 412 | // RGB little endian (bgr in memory) to J400. 413 | LIBYUV_API 414 | int RGB24ToJ400(const uint8_t* src_rgb24, 415 | int src_stride_rgb24, 416 | uint8_t* dst_yj, 417 | int dst_stride_yj, 418 | int width, 419 | int height); 420 | 421 | #ifdef HAVE_JPEG 422 | // src_width/height provided by capture. 423 | // dst_width/height for clipping determine final size. 424 | LIBYUV_API 425 | int MJPGToI420(const uint8_t* sample, 426 | size_t sample_size, 427 | uint8_t* dst_y, 428 | int dst_stride_y, 429 | uint8_t* dst_u, 430 | int dst_stride_u, 431 | uint8_t* dst_v, 432 | int dst_stride_v, 433 | int src_width, 434 | int src_height, 435 | int dst_width, 436 | int dst_height); 437 | 438 | // JPEG to NV21 439 | LIBYUV_API 440 | int MJPGToNV21(const uint8_t* sample, 441 | size_t sample_size, 442 | uint8_t* dst_y, 443 | int dst_stride_y, 444 | uint8_t* dst_vu, 445 | int dst_stride_vu, 446 | int src_width, 447 | int src_height, 448 | int dst_width, 449 | int dst_height); 450 | 451 | // Query size of MJPG in pixels. 452 | LIBYUV_API 453 | int MJPGSize(const uint8_t* sample, 454 | size_t sample_size, 455 | int* width, 456 | int* height); 457 | #endif 458 | 459 | // Convert camera sample to I420 with cropping, rotation and vertical flip. 460 | // "src_size" is needed to parse MJPG. 461 | // "dst_stride_y" number of bytes in a row of the dst_y plane. 462 | // Normally this would be the same as dst_width, with recommended alignment 463 | // to 16 bytes for better efficiency. 464 | // If rotation of 90 or 270 is used, stride is affected. The caller should 465 | // allocate the I420 buffer according to rotation. 466 | // "dst_stride_u" number of bytes in a row of the dst_u plane. 467 | // Normally this would be the same as (dst_width + 1) / 2, with 468 | // recommended alignment to 16 bytes for better efficiency. 469 | // If rotation of 90 or 270 is used, stride is affected. 470 | // "crop_x" and "crop_y" are starting position for cropping. 471 | // To center, crop_x = (src_width - dst_width) / 2 472 | // crop_y = (src_height - dst_height) / 2 473 | // "src_width" / "src_height" is size of src_frame in pixels. 474 | // "src_height" can be negative indicating a vertically flipped image source. 475 | // "crop_width" / "crop_height" is the size to crop the src to. 476 | // Must be less than or equal to src_width/src_height 477 | // Cropping parameters are pre-rotation. 478 | // "rotation" can be 0, 90, 180 or 270. 479 | // "fourcc" is a fourcc. ie 'I420', 'YUY2' 480 | // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure. 481 | LIBYUV_API 482 | int ConvertToI420(const uint8_t* sample, 483 | size_t sample_size, 484 | uint8_t* dst_y, 485 | int dst_stride_y, 486 | uint8_t* dst_u, 487 | int dst_stride_u, 488 | uint8_t* dst_v, 489 | int dst_stride_v, 490 | int crop_x, 491 | int crop_y, 492 | int src_width, 493 | int src_height, 494 | int crop_width, 495 | int crop_height, 496 | enum RotationMode rotation, 497 | uint32_t fourcc); 498 | 499 | #ifdef __cplusplus 500 | } // extern "C" 501 | } // namespace libyuv 502 | #endif 503 | 504 | #endif // INCLUDE_LIBYUV_CONVERT_H_ 505 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/convert_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_CONVERT_ARGB_H_ 12 | #define INCLUDE_LIBYUV_CONVERT_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #include "libyuv/rotate.h" // For enum RotationMode. 17 | 18 | // TODO(fbarchard): This set of functions should exactly match convert.h 19 | // TODO(fbarchard): Add tests. Create random content of right size and convert 20 | // with C vs Opt and or to I420 and compare. 21 | // TODO(fbarchard): Some of these functions lack parameter setting. 22 | 23 | #ifdef __cplusplus 24 | namespace libyuv { 25 | extern "C" { 26 | #endif 27 | 28 | // Alias. 29 | #define ARGBToARGB ARGBCopy 30 | 31 | // Copy ARGB to ARGB. 32 | LIBYUV_API 33 | int ARGBCopy(const uint8_t* src_argb, 34 | int src_stride_argb, 35 | uint8_t* dst_argb, 36 | int dst_stride_argb, 37 | int width, 38 | int height); 39 | 40 | // Convert I420 to ARGB. 41 | LIBYUV_API 42 | int I420ToARGB(const uint8_t* src_y, 43 | int src_stride_y, 44 | const uint8_t* src_u, 45 | int src_stride_u, 46 | const uint8_t* src_v, 47 | int src_stride_v, 48 | uint8_t* dst_argb, 49 | int dst_stride_argb, 50 | int width, 51 | int height); 52 | 53 | // Duplicate prototype for function in convert_from.h for remoting. 54 | LIBYUV_API 55 | int I420ToABGR(const uint8_t* src_y, 56 | int src_stride_y, 57 | const uint8_t* src_u, 58 | int src_stride_u, 59 | const uint8_t* src_v, 60 | int src_stride_v, 61 | uint8_t* dst_abgr, 62 | int dst_stride_abgr, 63 | int width, 64 | int height); 65 | 66 | // Convert I010 to ARGB. 67 | LIBYUV_API 68 | int I010ToARGB(const uint16_t* src_y, 69 | int src_stride_y, 70 | const uint16_t* src_u, 71 | int src_stride_u, 72 | const uint16_t* src_v, 73 | int src_stride_v, 74 | uint8_t* dst_argb, 75 | int dst_stride_argb, 76 | int width, 77 | int height); 78 | 79 | // Convert I010 to ARGB. 80 | LIBYUV_API 81 | int I010ToARGB(const uint16_t* src_y, 82 | int src_stride_y, 83 | const uint16_t* src_u, 84 | int src_stride_u, 85 | const uint16_t* src_v, 86 | int src_stride_v, 87 | uint8_t* dst_argb, 88 | int dst_stride_argb, 89 | int width, 90 | int height); 91 | 92 | // Convert I010 to ABGR. 93 | LIBYUV_API 94 | int I010ToABGR(const uint16_t* src_y, 95 | int src_stride_y, 96 | const uint16_t* src_u, 97 | int src_stride_u, 98 | const uint16_t* src_v, 99 | int src_stride_v, 100 | uint8_t* dst_abgr, 101 | int dst_stride_abgr, 102 | int width, 103 | int height); 104 | 105 | // Convert H010 to ARGB. 106 | LIBYUV_API 107 | int H010ToARGB(const uint16_t* src_y, 108 | int src_stride_y, 109 | const uint16_t* src_u, 110 | int src_stride_u, 111 | const uint16_t* src_v, 112 | int src_stride_v, 113 | uint8_t* dst_argb, 114 | int dst_stride_argb, 115 | int width, 116 | int height); 117 | 118 | // Convert H010 to ABGR. 119 | LIBYUV_API 120 | int H010ToABGR(const uint16_t* src_y, 121 | int src_stride_y, 122 | const uint16_t* src_u, 123 | int src_stride_u, 124 | const uint16_t* src_v, 125 | int src_stride_v, 126 | uint8_t* dst_abgr, 127 | int dst_stride_abgr, 128 | int width, 129 | int height); 130 | 131 | // Convert I422 to ARGB. 132 | LIBYUV_API 133 | int I422ToARGB(const uint8_t* src_y, 134 | int src_stride_y, 135 | const uint8_t* src_u, 136 | int src_stride_u, 137 | const uint8_t* src_v, 138 | int src_stride_v, 139 | uint8_t* dst_argb, 140 | int dst_stride_argb, 141 | int width, 142 | int height); 143 | 144 | // Convert I444 to ARGB. 145 | LIBYUV_API 146 | int I444ToARGB(const uint8_t* src_y, 147 | int src_stride_y, 148 | const uint8_t* src_u, 149 | int src_stride_u, 150 | const uint8_t* src_v, 151 | int src_stride_v, 152 | uint8_t* dst_argb, 153 | int dst_stride_argb, 154 | int width, 155 | int height); 156 | 157 | // Convert J444 to ARGB. 158 | LIBYUV_API 159 | int J444ToARGB(const uint8_t* src_y, 160 | int src_stride_y, 161 | const uint8_t* src_u, 162 | int src_stride_u, 163 | const uint8_t* src_v, 164 | int src_stride_v, 165 | uint8_t* dst_argb, 166 | int dst_stride_argb, 167 | int width, 168 | int height); 169 | 170 | // Convert I444 to ABGR. 171 | LIBYUV_API 172 | int I444ToABGR(const uint8_t* src_y, 173 | int src_stride_y, 174 | const uint8_t* src_u, 175 | int src_stride_u, 176 | const uint8_t* src_v, 177 | int src_stride_v, 178 | uint8_t* dst_abgr, 179 | int dst_stride_abgr, 180 | int width, 181 | int height); 182 | 183 | // Convert I420 with Alpha to preattenuated ARGB. 184 | LIBYUV_API 185 | int I420AlphaToARGB(const uint8_t* src_y, 186 | int src_stride_y, 187 | const uint8_t* src_u, 188 | int src_stride_u, 189 | const uint8_t* src_v, 190 | int src_stride_v, 191 | const uint8_t* src_a, 192 | int src_stride_a, 193 | uint8_t* dst_argb, 194 | int dst_stride_argb, 195 | int width, 196 | int height, 197 | int attenuate); 198 | 199 | // Convert I420 with Alpha to preattenuated ABGR. 200 | LIBYUV_API 201 | int I420AlphaToABGR(const uint8_t* src_y, 202 | int src_stride_y, 203 | const uint8_t* src_u, 204 | int src_stride_u, 205 | const uint8_t* src_v, 206 | int src_stride_v, 207 | const uint8_t* src_a, 208 | int src_stride_a, 209 | uint8_t* dst_abgr, 210 | int dst_stride_abgr, 211 | int width, 212 | int height, 213 | int attenuate); 214 | 215 | // Convert I400 (grey) to ARGB. Reverse of ARGBToI400. 216 | LIBYUV_API 217 | int I400ToARGB(const uint8_t* src_y, 218 | int src_stride_y, 219 | uint8_t* dst_argb, 220 | int dst_stride_argb, 221 | int width, 222 | int height); 223 | 224 | // Convert J400 (jpeg grey) to ARGB. 225 | LIBYUV_API 226 | int J400ToARGB(const uint8_t* src_y, 227 | int src_stride_y, 228 | uint8_t* dst_argb, 229 | int dst_stride_argb, 230 | int width, 231 | int height); 232 | 233 | // Alias. 234 | #define YToARGB I400ToARGB 235 | 236 | // Convert NV12 to ARGB. 237 | LIBYUV_API 238 | int NV12ToARGB(const uint8_t* src_y, 239 | int src_stride_y, 240 | const uint8_t* src_uv, 241 | int src_stride_uv, 242 | uint8_t* dst_argb, 243 | int dst_stride_argb, 244 | int width, 245 | int height); 246 | 247 | // Convert NV21 to ARGB. 248 | LIBYUV_API 249 | int NV21ToARGB(const uint8_t* src_y, 250 | int src_stride_y, 251 | const uint8_t* src_vu, 252 | int src_stride_vu, 253 | uint8_t* dst_argb, 254 | int dst_stride_argb, 255 | int width, 256 | int height); 257 | 258 | // Convert NV12 to ABGR. 259 | LIBYUV_API 260 | int NV12ToABGR(const uint8_t* src_y, 261 | int src_stride_y, 262 | const uint8_t* src_uv, 263 | int src_stride_uv, 264 | uint8_t* dst_abgr, 265 | int dst_stride_abgr, 266 | int width, 267 | int height); 268 | 269 | // Convert NV21 to ABGR. 270 | LIBYUV_API 271 | int NV21ToABGR(const uint8_t* src_y, 272 | int src_stride_y, 273 | const uint8_t* src_vu, 274 | int src_stride_vu, 275 | uint8_t* dst_abgr, 276 | int dst_stride_abgr, 277 | int width, 278 | int height); 279 | 280 | // Convert NV12 to RGB24. 281 | LIBYUV_API 282 | int NV12ToRGB24(const uint8_t* src_y, 283 | int src_stride_y, 284 | const uint8_t* src_uv, 285 | int src_stride_uv, 286 | uint8_t* dst_rgb24, 287 | int dst_stride_rgb24, 288 | int width, 289 | int height); 290 | 291 | // Convert NV21 to RGB24. 292 | LIBYUV_API 293 | int NV21ToRGB24(const uint8_t* src_y, 294 | int src_stride_y, 295 | const uint8_t* src_vu, 296 | int src_stride_vu, 297 | uint8_t* dst_rgb24, 298 | int dst_stride_rgb24, 299 | int width, 300 | int height); 301 | 302 | // Convert NV21 to YUV24. 303 | LIBYUV_API 304 | int NV21ToYUV24(const uint8_t* src_y, 305 | int src_stride_y, 306 | const uint8_t* src_vu, 307 | int src_stride_vu, 308 | uint8_t* dst_yuv24, 309 | int dst_stride_yuv24, 310 | int width, 311 | int height); 312 | 313 | // Convert NV12 to RAW. 314 | LIBYUV_API 315 | int NV12ToRAW(const uint8_t* src_y, 316 | int src_stride_y, 317 | const uint8_t* src_uv, 318 | int src_stride_uv, 319 | uint8_t* dst_raw, 320 | int dst_stride_raw, 321 | int width, 322 | int height); 323 | 324 | // Convert NV21 to RAW. 325 | LIBYUV_API 326 | int NV21ToRAW(const uint8_t* src_y, 327 | int src_stride_y, 328 | const uint8_t* src_vu, 329 | int src_stride_vu, 330 | uint8_t* dst_raw, 331 | int dst_stride_raw, 332 | int width, 333 | int height); 334 | 335 | // Convert M420 to ARGB. 336 | LIBYUV_API 337 | int M420ToARGB(const uint8_t* src_m420, 338 | int src_stride_m420, 339 | uint8_t* dst_argb, 340 | int dst_stride_argb, 341 | int width, 342 | int height); 343 | 344 | // Convert YUY2 to ARGB. 345 | LIBYUV_API 346 | int YUY2ToARGB(const uint8_t* src_yuy2, 347 | int src_stride_yuy2, 348 | uint8_t* dst_argb, 349 | int dst_stride_argb, 350 | int width, 351 | int height); 352 | 353 | // Convert UYVY to ARGB. 354 | LIBYUV_API 355 | int UYVYToARGB(const uint8_t* src_uyvy, 356 | int src_stride_uyvy, 357 | uint8_t* dst_argb, 358 | int dst_stride_argb, 359 | int width, 360 | int height); 361 | 362 | // Convert J420 to ARGB. 363 | LIBYUV_API 364 | int J420ToARGB(const uint8_t* src_y, 365 | int src_stride_y, 366 | const uint8_t* src_u, 367 | int src_stride_u, 368 | const uint8_t* src_v, 369 | int src_stride_v, 370 | uint8_t* dst_argb, 371 | int dst_stride_argb, 372 | int width, 373 | int height); 374 | 375 | // Convert J422 to ARGB. 376 | LIBYUV_API 377 | int J422ToARGB(const uint8_t* src_y, 378 | int src_stride_y, 379 | const uint8_t* src_u, 380 | int src_stride_u, 381 | const uint8_t* src_v, 382 | int src_stride_v, 383 | uint8_t* dst_argb, 384 | int dst_stride_argb, 385 | int width, 386 | int height); 387 | 388 | // Convert J420 to ABGR. 389 | LIBYUV_API 390 | int J420ToABGR(const uint8_t* src_y, 391 | int src_stride_y, 392 | const uint8_t* src_u, 393 | int src_stride_u, 394 | const uint8_t* src_v, 395 | int src_stride_v, 396 | uint8_t* dst_abgr, 397 | int dst_stride_abgr, 398 | int width, 399 | int height); 400 | 401 | // Convert J422 to ABGR. 402 | LIBYUV_API 403 | int J422ToABGR(const uint8_t* src_y, 404 | int src_stride_y, 405 | const uint8_t* src_u, 406 | int src_stride_u, 407 | const uint8_t* src_v, 408 | int src_stride_v, 409 | uint8_t* dst_abgr, 410 | int dst_stride_abgr, 411 | int width, 412 | int height); 413 | 414 | // Convert H420 to ARGB. 415 | LIBYUV_API 416 | int H420ToARGB(const uint8_t* src_y, 417 | int src_stride_y, 418 | const uint8_t* src_u, 419 | int src_stride_u, 420 | const uint8_t* src_v, 421 | int src_stride_v, 422 | uint8_t* dst_argb, 423 | int dst_stride_argb, 424 | int width, 425 | int height); 426 | 427 | // Convert H422 to ARGB. 428 | LIBYUV_API 429 | int H422ToARGB(const uint8_t* src_y, 430 | int src_stride_y, 431 | const uint8_t* src_u, 432 | int src_stride_u, 433 | const uint8_t* src_v, 434 | int src_stride_v, 435 | uint8_t* dst_argb, 436 | int dst_stride_argb, 437 | int width, 438 | int height); 439 | 440 | // Convert H420 to ABGR. 441 | LIBYUV_API 442 | int H420ToABGR(const uint8_t* src_y, 443 | int src_stride_y, 444 | const uint8_t* src_u, 445 | int src_stride_u, 446 | const uint8_t* src_v, 447 | int src_stride_v, 448 | uint8_t* dst_abgr, 449 | int dst_stride_abgr, 450 | int width, 451 | int height); 452 | 453 | // Convert H422 to ABGR. 454 | LIBYUV_API 455 | int H422ToABGR(const uint8_t* src_y, 456 | int src_stride_y, 457 | const uint8_t* src_u, 458 | int src_stride_u, 459 | const uint8_t* src_v, 460 | int src_stride_v, 461 | uint8_t* dst_abgr, 462 | int dst_stride_abgr, 463 | int width, 464 | int height); 465 | 466 | // Convert H010 to ARGB. 467 | LIBYUV_API 468 | int H010ToARGB(const uint16_t* src_y, 469 | int src_stride_y, 470 | const uint16_t* src_u, 471 | int src_stride_u, 472 | const uint16_t* src_v, 473 | int src_stride_v, 474 | uint8_t* dst_argb, 475 | int dst_stride_argb, 476 | int width, 477 | int height); 478 | 479 | // Convert I010 to AR30. 480 | LIBYUV_API 481 | int I010ToAR30(const uint16_t* src_y, 482 | int src_stride_y, 483 | const uint16_t* src_u, 484 | int src_stride_u, 485 | const uint16_t* src_v, 486 | int src_stride_v, 487 | uint8_t* dst_ar30, 488 | int dst_stride_ar30, 489 | int width, 490 | int height); 491 | 492 | // Convert H010 to AR30. 493 | LIBYUV_API 494 | int H010ToAR30(const uint16_t* src_y, 495 | int src_stride_y, 496 | const uint16_t* src_u, 497 | int src_stride_u, 498 | const uint16_t* src_v, 499 | int src_stride_v, 500 | uint8_t* dst_ar30, 501 | int dst_stride_ar30, 502 | int width, 503 | int height); 504 | 505 | // Convert I010 to AB30. 506 | LIBYUV_API 507 | int I010ToAB30(const uint16_t* src_y, 508 | int src_stride_y, 509 | const uint16_t* src_u, 510 | int src_stride_u, 511 | const uint16_t* src_v, 512 | int src_stride_v, 513 | uint8_t* dst_ab30, 514 | int dst_stride_ab30, 515 | int width, 516 | int height); 517 | 518 | // Convert H010 to AB30. 519 | LIBYUV_API 520 | int H010ToAB30(const uint16_t* src_y, 521 | int src_stride_y, 522 | const uint16_t* src_u, 523 | int src_stride_u, 524 | const uint16_t* src_v, 525 | int src_stride_v, 526 | uint8_t* dst_ab30, 527 | int dst_stride_ab30, 528 | int width, 529 | int height); 530 | 531 | // BGRA little endian (argb in memory) to ARGB. 532 | LIBYUV_API 533 | int BGRAToARGB(const uint8_t* src_bgra, 534 | int src_stride_bgra, 535 | uint8_t* dst_argb, 536 | int dst_stride_argb, 537 | int width, 538 | int height); 539 | 540 | // ABGR little endian (rgba in memory) to ARGB. 541 | LIBYUV_API 542 | int ABGRToARGB(const uint8_t* src_abgr, 543 | int src_stride_abgr, 544 | uint8_t* dst_argb, 545 | int dst_stride_argb, 546 | int width, 547 | int height); 548 | 549 | // RGBA little endian (abgr in memory) to ARGB. 550 | LIBYUV_API 551 | int RGBAToARGB(const uint8_t* src_rgba, 552 | int src_stride_rgba, 553 | uint8_t* dst_argb, 554 | int dst_stride_argb, 555 | int width, 556 | int height); 557 | 558 | // Deprecated function name. 559 | #define BG24ToARGB RGB24ToARGB 560 | 561 | // RGB little endian (bgr in memory) to ARGB. 562 | LIBYUV_API 563 | int RGB24ToARGB(const uint8_t* src_rgb24, 564 | int src_stride_rgb24, 565 | uint8_t* dst_argb, 566 | int dst_stride_argb, 567 | int width, 568 | int height); 569 | 570 | // RGB big endian (rgb in memory) to ARGB. 571 | LIBYUV_API 572 | int RAWToARGB(const uint8_t* src_raw, 573 | int src_stride_raw, 574 | uint8_t* dst_argb, 575 | int dst_stride_argb, 576 | int width, 577 | int height); 578 | 579 | // RGB16 (RGBP fourcc) little endian to ARGB. 580 | LIBYUV_API 581 | int RGB565ToARGB(const uint8_t* src_rgb565, 582 | int src_stride_rgb565, 583 | uint8_t* dst_argb, 584 | int dst_stride_argb, 585 | int width, 586 | int height); 587 | 588 | // RGB15 (RGBO fourcc) little endian to ARGB. 589 | LIBYUV_API 590 | int ARGB1555ToARGB(const uint8_t* src_argb1555, 591 | int src_stride_argb1555, 592 | uint8_t* dst_argb, 593 | int dst_stride_argb, 594 | int width, 595 | int height); 596 | 597 | // RGB12 (R444 fourcc) little endian to ARGB. 598 | LIBYUV_API 599 | int ARGB4444ToARGB(const uint8_t* src_argb4444, 600 | int src_stride_argb4444, 601 | uint8_t* dst_argb, 602 | int dst_stride_argb, 603 | int width, 604 | int height); 605 | 606 | // Aliases 607 | #define AB30ToARGB AR30ToABGR 608 | #define AB30ToABGR AR30ToARGB 609 | #define AB30ToAR30 AR30ToAB30 610 | 611 | // Convert AR30 To ARGB. 612 | LIBYUV_API 613 | int AR30ToARGB(const uint8_t* src_ar30, 614 | int src_stride_ar30, 615 | uint8_t* dst_argb, 616 | int dst_stride_argb, 617 | int width, 618 | int height); 619 | 620 | // Convert AR30 To ABGR. 621 | LIBYUV_API 622 | int AR30ToABGR(const uint8_t* src_ar30, 623 | int src_stride_ar30, 624 | uint8_t* dst_abgr, 625 | int dst_stride_abgr, 626 | int width, 627 | int height); 628 | 629 | // Convert AR30 To AB30. 630 | LIBYUV_API 631 | int AR30ToAB30(const uint8_t* src_ar30, 632 | int src_stride_ar30, 633 | uint8_t* dst_ab30, 634 | int dst_stride_ab30, 635 | int width, 636 | int height); 637 | 638 | #ifdef HAVE_JPEG 639 | // src_width/height provided by capture 640 | // dst_width/height for clipping determine final size. 641 | LIBYUV_API 642 | int MJPGToARGB(const uint8_t* sample, 643 | size_t sample_size, 644 | uint8_t* dst_argb, 645 | int dst_stride_argb, 646 | int src_width, 647 | int src_height, 648 | int dst_width, 649 | int dst_height); 650 | #endif 651 | 652 | // Convert Android420 to ARGB. 653 | LIBYUV_API 654 | int Android420ToARGB(const uint8_t* src_y, 655 | int src_stride_y, 656 | const uint8_t* src_u, 657 | int src_stride_u, 658 | const uint8_t* src_v, 659 | int src_stride_v, 660 | int src_pixel_stride_uv, 661 | uint8_t* dst_argb, 662 | int dst_stride_argb, 663 | int width, 664 | int height); 665 | 666 | // Convert Android420 to ABGR. 667 | LIBYUV_API 668 | int Android420ToABGR(const uint8_t* src_y, 669 | int src_stride_y, 670 | const uint8_t* src_u, 671 | int src_stride_u, 672 | const uint8_t* src_v, 673 | int src_stride_v, 674 | int src_pixel_stride_uv, 675 | uint8_t* dst_abgr, 676 | int dst_stride_abgr, 677 | int width, 678 | int height); 679 | 680 | // Convert camera sample to ARGB with cropping, rotation and vertical flip. 681 | // "sample_size" is needed to parse MJPG. 682 | // "dst_stride_argb" number of bytes in a row of the dst_argb plane. 683 | // Normally this would be the same as dst_width, with recommended alignment 684 | // to 16 bytes for better efficiency. 685 | // If rotation of 90 or 270 is used, stride is affected. The caller should 686 | // allocate the I420 buffer according to rotation. 687 | // "dst_stride_u" number of bytes in a row of the dst_u plane. 688 | // Normally this would be the same as (dst_width + 1) / 2, with 689 | // recommended alignment to 16 bytes for better efficiency. 690 | // If rotation of 90 or 270 is used, stride is affected. 691 | // "crop_x" and "crop_y" are starting position for cropping. 692 | // To center, crop_x = (src_width - dst_width) / 2 693 | // crop_y = (src_height - dst_height) / 2 694 | // "src_width" / "src_height" is size of src_frame in pixels. 695 | // "src_height" can be negative indicating a vertically flipped image source. 696 | // "crop_width" / "crop_height" is the size to crop the src to. 697 | // Must be less than or equal to src_width/src_height 698 | // Cropping parameters are pre-rotation. 699 | // "rotation" can be 0, 90, 180 or 270. 700 | // "fourcc" is a fourcc. ie 'I420', 'YUY2' 701 | // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure. 702 | LIBYUV_API 703 | int ConvertToARGB(const uint8_t* sample, 704 | size_t sample_size, 705 | uint8_t* dst_argb, 706 | int dst_stride_argb, 707 | int crop_x, 708 | int crop_y, 709 | int src_width, 710 | int src_height, 711 | int crop_width, 712 | int crop_height, 713 | enum RotationMode rotation, 714 | uint32_t fourcc); 715 | 716 | #ifdef __cplusplus 717 | } // extern "C" 718 | } // namespace libyuv 719 | #endif 720 | 721 | #endif // INCLUDE_LIBYUV_CONVERT_ARGB_H_ 722 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/convert_from.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_CONVERT_FROM_H_ 12 | #define INCLUDE_LIBYUV_CONVERT_FROM_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/rotate.h" 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | // See Also convert.h for conversions from formats to I420. 23 | 24 | // Convert 8 bit YUV to 10 bit. 25 | #define H420ToH010 I420ToI010 26 | int I420ToI010(const uint8_t* src_y, 27 | int src_stride_y, 28 | const uint8_t* src_u, 29 | int src_stride_u, 30 | const uint8_t* src_v, 31 | int src_stride_v, 32 | uint16_t* dst_y, 33 | int dst_stride_y, 34 | uint16_t* dst_u, 35 | int dst_stride_u, 36 | uint16_t* dst_v, 37 | int dst_stride_v, 38 | int width, 39 | int height); 40 | 41 | LIBYUV_API 42 | int I420ToI422(const uint8_t* src_y, 43 | int src_stride_y, 44 | const uint8_t* src_u, 45 | int src_stride_u, 46 | const uint8_t* src_v, 47 | int src_stride_v, 48 | uint8_t* dst_y, 49 | int dst_stride_y, 50 | uint8_t* dst_u, 51 | int dst_stride_u, 52 | uint8_t* dst_v, 53 | int dst_stride_v, 54 | int width, 55 | int height); 56 | 57 | LIBYUV_API 58 | int I420ToI444(const uint8_t* src_y, 59 | int src_stride_y, 60 | const uint8_t* src_u, 61 | int src_stride_u, 62 | const uint8_t* src_v, 63 | int src_stride_v, 64 | uint8_t* dst_y, 65 | int dst_stride_y, 66 | uint8_t* dst_u, 67 | int dst_stride_u, 68 | uint8_t* dst_v, 69 | int dst_stride_v, 70 | int width, 71 | int height); 72 | 73 | // Copy to I400. Source can be I420, I422, I444, I400, NV12 or NV21. 74 | LIBYUV_API 75 | int I400Copy(const uint8_t* src_y, 76 | int src_stride_y, 77 | uint8_t* dst_y, 78 | int dst_stride_y, 79 | int width, 80 | int height); 81 | 82 | LIBYUV_API 83 | int I420ToNV12(const uint8_t* src_y, 84 | int src_stride_y, 85 | const uint8_t* src_u, 86 | int src_stride_u, 87 | const uint8_t* src_v, 88 | int src_stride_v, 89 | uint8_t* dst_y, 90 | int dst_stride_y, 91 | uint8_t* dst_uv, 92 | int dst_stride_uv, 93 | int width, 94 | int height); 95 | 96 | LIBYUV_API 97 | int I420ToNV21(const uint8_t* src_y, 98 | int src_stride_y, 99 | const uint8_t* src_u, 100 | int src_stride_u, 101 | const uint8_t* src_v, 102 | int src_stride_v, 103 | uint8_t* dst_y, 104 | int dst_stride_y, 105 | uint8_t* dst_vu, 106 | int dst_stride_vu, 107 | int width, 108 | int height); 109 | 110 | LIBYUV_API 111 | int I420ToYUY2(const uint8_t* src_y, 112 | int src_stride_y, 113 | const uint8_t* src_u, 114 | int src_stride_u, 115 | const uint8_t* src_v, 116 | int src_stride_v, 117 | uint8_t* dst_yuy2, 118 | int dst_stride_yuy2, 119 | int width, 120 | int height); 121 | 122 | LIBYUV_API 123 | int I420ToUYVY(const uint8_t* src_y, 124 | int src_stride_y, 125 | const uint8_t* src_u, 126 | int src_stride_u, 127 | const uint8_t* src_v, 128 | int src_stride_v, 129 | uint8_t* dst_uyvy, 130 | int dst_stride_uyvy, 131 | int width, 132 | int height); 133 | 134 | LIBYUV_API 135 | int I420ToARGB(const uint8_t* src_y, 136 | int src_stride_y, 137 | const uint8_t* src_u, 138 | int src_stride_u, 139 | const uint8_t* src_v, 140 | int src_stride_v, 141 | uint8_t* dst_argb, 142 | int dst_stride_argb, 143 | int width, 144 | int height); 145 | 146 | LIBYUV_API 147 | int I420ToBGRA(const uint8_t* src_y, 148 | int src_stride_y, 149 | const uint8_t* src_u, 150 | int src_stride_u, 151 | const uint8_t* src_v, 152 | int src_stride_v, 153 | uint8_t* dst_bgra, 154 | int dst_stride_bgra, 155 | int width, 156 | int height); 157 | 158 | LIBYUV_API 159 | int I420ToABGR(const uint8_t* src_y, 160 | int src_stride_y, 161 | const uint8_t* src_u, 162 | int src_stride_u, 163 | const uint8_t* src_v, 164 | int src_stride_v, 165 | uint8_t* dst_abgr, 166 | int dst_stride_abgr, 167 | int width, 168 | int height); 169 | 170 | LIBYUV_API 171 | int I420ToRGBA(const uint8_t* src_y, 172 | int src_stride_y, 173 | const uint8_t* src_u, 174 | int src_stride_u, 175 | const uint8_t* src_v, 176 | int src_stride_v, 177 | uint8_t* dst_rgba, 178 | int dst_stride_rgba, 179 | int width, 180 | int height); 181 | 182 | LIBYUV_API 183 | int I420ToRGB24(const uint8_t* src_y, 184 | int src_stride_y, 185 | const uint8_t* src_u, 186 | int src_stride_u, 187 | const uint8_t* src_v, 188 | int src_stride_v, 189 | uint8_t* dst_rgb24, 190 | int dst_stride_rgb24, 191 | int width, 192 | int height); 193 | 194 | LIBYUV_API 195 | int I420ToRAW(const uint8_t* src_y, 196 | int src_stride_y, 197 | const uint8_t* src_u, 198 | int src_stride_u, 199 | const uint8_t* src_v, 200 | int src_stride_v, 201 | uint8_t* dst_raw, 202 | int dst_stride_raw, 203 | int width, 204 | int height); 205 | 206 | LIBYUV_API 207 | int H420ToRGB24(const uint8_t* src_y, 208 | int src_stride_y, 209 | const uint8_t* src_u, 210 | int src_stride_u, 211 | const uint8_t* src_v, 212 | int src_stride_v, 213 | uint8_t* dst_rgb24, 214 | int dst_stride_rgb24, 215 | int width, 216 | int height); 217 | 218 | LIBYUV_API 219 | int H420ToRAW(const uint8_t* src_y, 220 | int src_stride_y, 221 | const uint8_t* src_u, 222 | int src_stride_u, 223 | const uint8_t* src_v, 224 | int src_stride_v, 225 | uint8_t* dst_raw, 226 | int dst_stride_raw, 227 | int width, 228 | int height); 229 | 230 | LIBYUV_API 231 | int I420ToRGB565(const uint8_t* src_y, 232 | int src_stride_y, 233 | const uint8_t* src_u, 234 | int src_stride_u, 235 | const uint8_t* src_v, 236 | int src_stride_v, 237 | uint8_t* dst_rgb565, 238 | int dst_stride_rgb565, 239 | int width, 240 | int height); 241 | 242 | LIBYUV_API 243 | int J420ToRGB565(const uint8_t* src_y, 244 | int src_stride_y, 245 | const uint8_t* src_u, 246 | int src_stride_u, 247 | const uint8_t* src_v, 248 | int src_stride_v, 249 | uint8_t* dst_rgb565, 250 | int dst_stride_rgb565, 251 | int width, 252 | int height); 253 | 254 | LIBYUV_API 255 | int H420ToRGB565(const uint8_t* src_y, 256 | int src_stride_y, 257 | const uint8_t* src_u, 258 | int src_stride_u, 259 | const uint8_t* src_v, 260 | int src_stride_v, 261 | uint8_t* dst_rgb565, 262 | int dst_stride_rgb565, 263 | int width, 264 | int height); 265 | 266 | LIBYUV_API 267 | int I422ToRGB565(const uint8_t* src_y, 268 | int src_stride_y, 269 | const uint8_t* src_u, 270 | int src_stride_u, 271 | const uint8_t* src_v, 272 | int src_stride_v, 273 | uint8_t* dst_rgb565, 274 | int dst_stride_rgb565, 275 | int width, 276 | int height); 277 | 278 | // Convert I420 To RGB565 with 4x4 dither matrix (16 bytes). 279 | // Values in dither matrix from 0 to 7 recommended. 280 | // The order of the dither matrix is first byte is upper left. 281 | 282 | LIBYUV_API 283 | int I420ToRGB565Dither(const uint8_t* src_y, 284 | int src_stride_y, 285 | const uint8_t* src_u, 286 | int src_stride_u, 287 | const uint8_t* src_v, 288 | int src_stride_v, 289 | uint8_t* dst_rgb565, 290 | int dst_stride_rgb565, 291 | const uint8_t* dither4x4, 292 | int width, 293 | int height); 294 | 295 | LIBYUV_API 296 | int I420ToARGB1555(const uint8_t* src_y, 297 | int src_stride_y, 298 | const uint8_t* src_u, 299 | int src_stride_u, 300 | const uint8_t* src_v, 301 | int src_stride_v, 302 | uint8_t* dst_argb1555, 303 | int dst_stride_argb1555, 304 | int width, 305 | int height); 306 | 307 | LIBYUV_API 308 | int I420ToARGB4444(const uint8_t* src_y, 309 | int src_stride_y, 310 | const uint8_t* src_u, 311 | int src_stride_u, 312 | const uint8_t* src_v, 313 | int src_stride_v, 314 | uint8_t* dst_argb4444, 315 | int dst_stride_argb4444, 316 | int width, 317 | int height); 318 | 319 | // Convert I420 to AR30. 320 | LIBYUV_API 321 | int I420ToAR30(const uint8_t* src_y, 322 | int src_stride_y, 323 | const uint8_t* src_u, 324 | int src_stride_u, 325 | const uint8_t* src_v, 326 | int src_stride_v, 327 | uint8_t* dst_ar30, 328 | int dst_stride_ar30, 329 | int width, 330 | int height); 331 | 332 | // Convert H420 to AR30. 333 | LIBYUV_API 334 | int H420ToAR30(const uint8_t* src_y, 335 | int src_stride_y, 336 | const uint8_t* src_u, 337 | int src_stride_u, 338 | const uint8_t* src_v, 339 | int src_stride_v, 340 | uint8_t* dst_ar30, 341 | int dst_stride_ar30, 342 | int width, 343 | int height); 344 | 345 | // Convert I420 to specified format. 346 | // "dst_sample_stride" is bytes in a row for the destination. Pass 0 if the 347 | // buffer has contiguous rows. Can be negative. A multiple of 16 is optimal. 348 | LIBYUV_API 349 | int ConvertFromI420(const uint8_t* y, 350 | int y_stride, 351 | const uint8_t* u, 352 | int u_stride, 353 | const uint8_t* v, 354 | int v_stride, 355 | uint8_t* dst_sample, 356 | int dst_sample_stride, 357 | int width, 358 | int height, 359 | uint32_t fourcc); 360 | 361 | #ifdef __cplusplus 362 | } // extern "C" 363 | } // namespace libyuv 364 | #endif 365 | 366 | #endif // INCLUDE_LIBYUV_CONVERT_FROM_H_ 367 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/convert_from_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_CONVERT_FROM_ARGB_H_ 12 | #define INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Copy ARGB to ARGB. 22 | #define ARGBToARGB ARGBCopy 23 | LIBYUV_API 24 | int ARGBCopy(const uint8_t* src_argb, 25 | int src_stride_argb, 26 | uint8_t* dst_argb, 27 | int dst_stride_argb, 28 | int width, 29 | int height); 30 | 31 | // Convert ARGB To BGRA. 32 | LIBYUV_API 33 | int ARGBToBGRA(const uint8_t* src_argb, 34 | int src_stride_argb, 35 | uint8_t* dst_bgra, 36 | int dst_stride_bgra, 37 | int width, 38 | int height); 39 | 40 | // Convert ARGB To ABGR. 41 | LIBYUV_API 42 | int ARGBToABGR(const uint8_t* src_argb, 43 | int src_stride_argb, 44 | uint8_t* dst_abgr, 45 | int dst_stride_abgr, 46 | int width, 47 | int height); 48 | 49 | // Convert ARGB To RGBA. 50 | LIBYUV_API 51 | int ARGBToRGBA(const uint8_t* src_argb, 52 | int src_stride_argb, 53 | uint8_t* dst_rgba, 54 | int dst_stride_rgba, 55 | int width, 56 | int height); 57 | 58 | // Aliases 59 | #define ARGBToAB30 ABGRToAR30 60 | #define ABGRToAB30 ARGBToAR30 61 | 62 | // Convert ABGR To AR30. 63 | LIBYUV_API 64 | int ABGRToAR30(const uint8_t* src_abgr, 65 | int src_stride_abgr, 66 | uint8_t* dst_ar30, 67 | int dst_stride_ar30, 68 | int width, 69 | int height); 70 | 71 | // Convert ARGB To AR30. 72 | LIBYUV_API 73 | int ARGBToAR30(const uint8_t* src_argb, 74 | int src_stride_argb, 75 | uint8_t* dst_ar30, 76 | int dst_stride_ar30, 77 | int width, 78 | int height); 79 | 80 | // Convert ARGB To RGB24. 81 | LIBYUV_API 82 | int ARGBToRGB24(const uint8_t* src_argb, 83 | int src_stride_argb, 84 | uint8_t* dst_rgb24, 85 | int dst_stride_rgb24, 86 | int width, 87 | int height); 88 | 89 | // Convert ARGB To RAW. 90 | LIBYUV_API 91 | int ARGBToRAW(const uint8_t* src_argb, 92 | int src_stride_argb, 93 | uint8_t* dst_raw, 94 | int dst_stride_raw, 95 | int width, 96 | int height); 97 | 98 | // Convert ARGB To RGB565. 99 | LIBYUV_API 100 | int ARGBToRGB565(const uint8_t* src_argb, 101 | int src_stride_argb, 102 | uint8_t* dst_rgb565, 103 | int dst_stride_rgb565, 104 | int width, 105 | int height); 106 | 107 | // Convert ARGB To RGB565 with 4x4 dither matrix (16 bytes). 108 | // Values in dither matrix from 0 to 7 recommended. 109 | // The order of the dither matrix is first byte is upper left. 110 | // TODO(fbarchard): Consider pointer to 2d array for dither4x4. 111 | // const uint8_t(*dither)[4][4]; 112 | LIBYUV_API 113 | int ARGBToRGB565Dither(const uint8_t* src_argb, 114 | int src_stride_argb, 115 | uint8_t* dst_rgb565, 116 | int dst_stride_rgb565, 117 | const uint8_t* dither4x4, 118 | int width, 119 | int height); 120 | 121 | // Convert ARGB To ARGB1555. 122 | LIBYUV_API 123 | int ARGBToARGB1555(const uint8_t* src_argb, 124 | int src_stride_argb, 125 | uint8_t* dst_argb1555, 126 | int dst_stride_argb1555, 127 | int width, 128 | int height); 129 | 130 | // Convert ARGB To ARGB4444. 131 | LIBYUV_API 132 | int ARGBToARGB4444(const uint8_t* src_argb, 133 | int src_stride_argb, 134 | uint8_t* dst_argb4444, 135 | int dst_stride_argb4444, 136 | int width, 137 | int height); 138 | 139 | // Convert ARGB To I444. 140 | LIBYUV_API 141 | int ARGBToI444(const uint8_t* src_argb, 142 | int src_stride_argb, 143 | uint8_t* dst_y, 144 | int dst_stride_y, 145 | uint8_t* dst_u, 146 | int dst_stride_u, 147 | uint8_t* dst_v, 148 | int dst_stride_v, 149 | int width, 150 | int height); 151 | 152 | // Convert ARGB To I422. 153 | LIBYUV_API 154 | int ARGBToI422(const uint8_t* src_argb, 155 | int src_stride_argb, 156 | uint8_t* dst_y, 157 | int dst_stride_y, 158 | uint8_t* dst_u, 159 | int dst_stride_u, 160 | uint8_t* dst_v, 161 | int dst_stride_v, 162 | int width, 163 | int height); 164 | 165 | // Convert ARGB To I420. (also in convert.h) 166 | LIBYUV_API 167 | int ARGBToI420(const uint8_t* src_argb, 168 | int src_stride_argb, 169 | uint8_t* dst_y, 170 | int dst_stride_y, 171 | uint8_t* dst_u, 172 | int dst_stride_u, 173 | uint8_t* dst_v, 174 | int dst_stride_v, 175 | int width, 176 | int height); 177 | 178 | // Convert ARGB to J420. (JPeg full range I420). 179 | LIBYUV_API 180 | int ARGBToJ420(const uint8_t* src_argb, 181 | int src_stride_argb, 182 | uint8_t* dst_yj, 183 | int dst_stride_yj, 184 | uint8_t* dst_u, 185 | int dst_stride_u, 186 | uint8_t* dst_v, 187 | int dst_stride_v, 188 | int width, 189 | int height); 190 | 191 | // Convert ARGB to J422. 192 | LIBYUV_API 193 | int ARGBToJ422(const uint8_t* src_argb, 194 | int src_stride_argb, 195 | uint8_t* dst_yj, 196 | int dst_stride_yj, 197 | uint8_t* dst_u, 198 | int dst_stride_u, 199 | uint8_t* dst_v, 200 | int dst_stride_v, 201 | int width, 202 | int height); 203 | 204 | // Convert ARGB to J400. (JPeg full range). 205 | LIBYUV_API 206 | int ARGBToJ400(const uint8_t* src_argb, 207 | int src_stride_argb, 208 | uint8_t* dst_yj, 209 | int dst_stride_yj, 210 | int width, 211 | int height); 212 | 213 | // Convert ARGB to I400. 214 | LIBYUV_API 215 | int ARGBToI400(const uint8_t* src_argb, 216 | int src_stride_argb, 217 | uint8_t* dst_y, 218 | int dst_stride_y, 219 | int width, 220 | int height); 221 | 222 | // Convert ARGB to G. (Reverse of J400toARGB, which replicates G back to ARGB) 223 | LIBYUV_API 224 | int ARGBToG(const uint8_t* src_argb, 225 | int src_stride_argb, 226 | uint8_t* dst_g, 227 | int dst_stride_g, 228 | int width, 229 | int height); 230 | 231 | // Convert ARGB To NV12. 232 | LIBYUV_API 233 | int ARGBToNV12(const uint8_t* src_argb, 234 | int src_stride_argb, 235 | uint8_t* dst_y, 236 | int dst_stride_y, 237 | uint8_t* dst_uv, 238 | int dst_stride_uv, 239 | int width, 240 | int height); 241 | 242 | // Convert ARGB To NV21. 243 | LIBYUV_API 244 | int ARGBToNV21(const uint8_t* src_argb, 245 | int src_stride_argb, 246 | uint8_t* dst_y, 247 | int dst_stride_y, 248 | uint8_t* dst_vu, 249 | int dst_stride_vu, 250 | int width, 251 | int height); 252 | 253 | // Convert ARGB To NV21. 254 | LIBYUV_API 255 | int ARGBToNV21(const uint8_t* src_argb, 256 | int src_stride_argb, 257 | uint8_t* dst_y, 258 | int dst_stride_y, 259 | uint8_t* dst_vu, 260 | int dst_stride_vu, 261 | int width, 262 | int height); 263 | 264 | // Convert ARGB To YUY2. 265 | LIBYUV_API 266 | int ARGBToYUY2(const uint8_t* src_argb, 267 | int src_stride_argb, 268 | uint8_t* dst_yuy2, 269 | int dst_stride_yuy2, 270 | int width, 271 | int height); 272 | 273 | // Convert ARGB To UYVY. 274 | LIBYUV_API 275 | int ARGBToUYVY(const uint8_t* src_argb, 276 | int src_stride_argb, 277 | uint8_t* dst_uyvy, 278 | int dst_stride_uyvy, 279 | int width, 280 | int height); 281 | 282 | #ifdef __cplusplus 283 | } // extern "C" 284 | } // namespace libyuv 285 | #endif 286 | 287 | #endif // INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_ 288 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/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_ 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 | // Internal flag to indicate cpuid requires initialization. 22 | static const int kCpuInitialized = 0x1; 23 | 24 | // These flags are only valid on ARM processors. 25 | static const int kCpuHasARM = 0x2; 26 | static const int kCpuHasNEON = 0x4; 27 | // 0x8 reserved for future ARM flag. 28 | 29 | // These flags are only valid on x86 processors. 30 | static const int kCpuHasX86 = 0x10; 31 | static const int kCpuHasSSE2 = 0x20; 32 | static const int kCpuHasSSSE3 = 0x40; 33 | static const int kCpuHasSSE41 = 0x80; 34 | static const int kCpuHasSSE42 = 0x100; // unused at this time. 35 | static const int kCpuHasAVX = 0x200; 36 | static const int kCpuHasAVX2 = 0x400; 37 | static const int kCpuHasERMS = 0x800; 38 | static const int kCpuHasFMA3 = 0x1000; 39 | static const int kCpuHasF16C = 0x2000; 40 | static const int kCpuHasGFNI = 0x4000; 41 | static const int kCpuHasAVX512BW = 0x8000; 42 | static const int kCpuHasAVX512VL = 0x10000; 43 | static const int kCpuHasAVX512VBMI = 0x20000; 44 | static const int kCpuHasAVX512VBMI2 = 0x40000; 45 | static const int kCpuHasAVX512VBITALG = 0x80000; 46 | static const int kCpuHasAVX512VPOPCNTDQ = 0x100000; 47 | 48 | // These flags are only valid on MIPS processors. 49 | static const int kCpuHasMIPS = 0x200000; 50 | static const int kCpuHasMSA = 0x400000; 51 | static const int kCpuHasMMI = 0x800000; 52 | 53 | // Optional init function. TestCpuFlag does an auto-init. 54 | // Returns cpu_info flags. 55 | LIBYUV_API 56 | int InitCpuFlags(void); 57 | 58 | // Detect CPU has SSE2 etc. 59 | // Test_flag parameter should be one of kCpuHas constants above. 60 | // Returns non-zero if instruction set is detected 61 | static __inline int TestCpuFlag(int test_flag) { 62 | LIBYUV_API extern int cpu_info_; 63 | #ifdef __ATOMIC_RELAXED 64 | int cpu_info = __atomic_load_n(&cpu_info_, __ATOMIC_RELAXED); 65 | #else 66 | int cpu_info = cpu_info_; 67 | #endif 68 | return (!cpu_info ? InitCpuFlags() : cpu_info) & test_flag; 69 | } 70 | 71 | // Internal function for parsing /proc/cpuinfo. 72 | LIBYUV_API 73 | int ArmCpuCaps(const char* cpuinfo_name); 74 | 75 | // For testing, allow CPU flags to be disabled. 76 | // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. 77 | // MaskCpuFlags(-1) to enable all cpu specific optimizations. 78 | // MaskCpuFlags(1) to disable all cpu specific optimizations. 79 | // MaskCpuFlags(0) to reset state so next call will auto init. 80 | // Returns cpu_info flags. 81 | LIBYUV_API 82 | int MaskCpuFlags(int enable_flags); 83 | 84 | // Sets the CPU flags to |cpu_flags|, bypassing the detection code. |cpu_flags| 85 | // should be a valid combination of the kCpuHas constants above and include 86 | // kCpuInitialized. Use this method when running in a sandboxed process where 87 | // the detection code might fail (as it might access /proc/cpuinfo). In such 88 | // cases the cpu_info can be obtained from a non sandboxed process by calling 89 | // InitCpuFlags() and passed to the sandboxed process (via command line 90 | // parameters, IPC...) which can then call this method to initialize the CPU 91 | // flags. 92 | // Notes: 93 | // - when specifying 0 for |cpu_flags|, the auto initialization is enabled 94 | // again. 95 | // - enabling CPU features that are not supported by the CPU will result in 96 | // undefined behavior. 97 | // TODO(fbarchard): consider writing a helper function that translates from 98 | // other library CPU info to libyuv CPU info and add a .md doc that explains 99 | // CPU detection. 100 | static __inline void SetCpuFlags(int cpu_flags) { 101 | LIBYUV_API extern int cpu_info_; 102 | #ifdef __ATOMIC_RELAXED 103 | __atomic_store_n(&cpu_info_, cpu_flags, __ATOMIC_RELAXED); 104 | #else 105 | cpu_info_ = cpu_flags; 106 | #endif 107 | } 108 | 109 | // Low level cpuid for X86. Returns zeros on other CPUs. 110 | // eax is the info type that you want. 111 | // ecx is typically the cpu number, and should normally be zero. 112 | LIBYUV_API 113 | void CpuId(int info_eax, int info_ecx, int* cpu_info); 114 | 115 | #ifdef __cplusplus 116 | } // extern "C" 117 | } // namespace libyuv 118 | #endif 119 | 120 | #endif // INCLUDE_LIBYUV_CPU_ID_H_ 121 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/macros_msa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 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_MACROS_MSA_H_ 12 | #define INCLUDE_LIBYUV_MACROS_MSA_H_ 13 | 14 | #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) 15 | #include 16 | #include 17 | 18 | #if (__mips_isa_rev >= 6) 19 | #define LW(psrc) \ 20 | ({ \ 21 | const uint8_t* psrc_lw_m = (const uint8_t*)(psrc); \ 22 | uint32_t val_m; \ 23 | asm volatile("lw %[val_m], %[psrc_lw_m] \n" \ 24 | : [val_m] "=r"(val_m) \ 25 | : [psrc_lw_m] "m"(*psrc_lw_m)); \ 26 | val_m; \ 27 | }) 28 | 29 | #if (__mips == 64) 30 | #define LD(psrc) \ 31 | ({ \ 32 | const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \ 33 | uint64_t val_m = 0; \ 34 | asm volatile("ld %[val_m], %[psrc_ld_m] \n" \ 35 | : [val_m] "=r"(val_m) \ 36 | : [psrc_ld_m] "m"(*psrc_ld_m)); \ 37 | val_m; \ 38 | }) 39 | #else // !(__mips == 64) 40 | #define LD(psrc) \ 41 | ({ \ 42 | const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \ 43 | uint32_t val0_m, val1_m; \ 44 | uint64_t val_m = 0; \ 45 | val0_m = LW(psrc_ld_m); \ 46 | val1_m = LW(psrc_ld_m + 4); \ 47 | val_m = (uint64_t)(val1_m); /* NOLINT */ \ 48 | val_m = (uint64_t)((val_m << 32) & 0xFFFFFFFF00000000); /* NOLINT */ \ 49 | val_m = (uint64_t)(val_m | (uint64_t)val0_m); /* NOLINT */ \ 50 | val_m; \ 51 | }) 52 | #endif // (__mips == 64) 53 | 54 | #define SW(val, pdst) \ 55 | ({ \ 56 | uint8_t* pdst_sw_m = (uint8_t*)(pdst); /* NOLINT */ \ 57 | uint32_t val_m = (val); \ 58 | asm volatile("sw %[val_m], %[pdst_sw_m] \n" \ 59 | : [pdst_sw_m] "=m"(*pdst_sw_m) \ 60 | : [val_m] "r"(val_m)); \ 61 | }) 62 | 63 | #if (__mips == 64) 64 | #define SD(val, pdst) \ 65 | ({ \ 66 | uint8_t* pdst_sd_m = (uint8_t*)(pdst); /* NOLINT */ \ 67 | uint64_t val_m = (val); \ 68 | asm volatile("sd %[val_m], %[pdst_sd_m] \n" \ 69 | : [pdst_sd_m] "=m"(*pdst_sd_m) \ 70 | : [val_m] "r"(val_m)); \ 71 | }) 72 | #else // !(__mips == 64) 73 | #define SD(val, pdst) \ 74 | ({ \ 75 | uint8_t* pdst_sd_m = (uint8_t*)(pdst); /* NOLINT */ \ 76 | uint32_t val0_m, val1_m; \ 77 | val0_m = (uint32_t)((val)&0x00000000FFFFFFFF); \ 78 | val1_m = (uint32_t)(((val) >> 32) & 0x00000000FFFFFFFF); \ 79 | SW(val0_m, pdst_sd_m); \ 80 | SW(val1_m, pdst_sd_m + 4); \ 81 | }) 82 | #endif // !(__mips == 64) 83 | #else // !(__mips_isa_rev >= 6) 84 | #define LW(psrc) \ 85 | ({ \ 86 | const uint8_t* psrc_lw_m = (const uint8_t*)(psrc); \ 87 | uint32_t val_m; \ 88 | asm volatile("ulw %[val_m], %[psrc_lw_m] \n" \ 89 | : [val_m] "=r"(val_m) \ 90 | : [psrc_lw_m] "m"(*psrc_lw_m)); \ 91 | val_m; \ 92 | }) 93 | 94 | #if (__mips == 64) 95 | #define LD(psrc) \ 96 | ({ \ 97 | const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \ 98 | uint64_t val_m = 0; \ 99 | asm volatile("uld %[val_m], %[psrc_ld_m] \n" \ 100 | : [val_m] "=r"(val_m) \ 101 | : [psrc_ld_m] "m"(*psrc_ld_m)); \ 102 | val_m; \ 103 | }) 104 | #else // !(__mips == 64) 105 | #define LD(psrc) \ 106 | ({ \ 107 | const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \ 108 | uint32_t val0_m, val1_m; \ 109 | uint64_t val_m = 0; \ 110 | val0_m = LW(psrc_ld_m); \ 111 | val1_m = LW(psrc_ld_m + 4); \ 112 | val_m = (uint64_t)(val1_m); /* NOLINT */ \ 113 | val_m = (uint64_t)((val_m << 32) & 0xFFFFFFFF00000000); /* NOLINT */ \ 114 | val_m = (uint64_t)(val_m | (uint64_t)val0_m); /* NOLINT */ \ 115 | val_m; \ 116 | }) 117 | #endif // (__mips == 64) 118 | 119 | #define SW(val, pdst) \ 120 | ({ \ 121 | uint8_t* pdst_sw_m = (uint8_t*)(pdst); /* NOLINT */ \ 122 | uint32_t val_m = (val); \ 123 | asm volatile("usw %[val_m], %[pdst_sw_m] \n" \ 124 | : [pdst_sw_m] "=m"(*pdst_sw_m) \ 125 | : [val_m] "r"(val_m)); \ 126 | }) 127 | 128 | #define SD(val, pdst) \ 129 | ({ \ 130 | uint8_t* pdst_sd_m = (uint8_t*)(pdst); /* NOLINT */ \ 131 | uint32_t val0_m, val1_m; \ 132 | val0_m = (uint32_t)((val)&0x00000000FFFFFFFF); \ 133 | val1_m = (uint32_t)(((val) >> 32) & 0x00000000FFFFFFFF); \ 134 | SW(val0_m, pdst_sd_m); \ 135 | SW(val1_m, pdst_sd_m + 4); \ 136 | }) 137 | #endif // (__mips_isa_rev >= 6) 138 | 139 | // TODO(fbarchard): Consider removing __VAR_ARGS versions. 140 | #define LD_B(RTYPE, psrc) *((RTYPE*)(psrc)) /* NOLINT */ 141 | #define LD_UB(...) LD_B(const v16u8, __VA_ARGS__) 142 | 143 | #define ST_B(RTYPE, in, pdst) *((RTYPE*)(pdst)) = (in) /* NOLINT */ 144 | #define ST_UB(...) ST_B(v16u8, __VA_ARGS__) 145 | 146 | #define ST_H(RTYPE, in, pdst) *((RTYPE*)(pdst)) = (in) /* NOLINT */ 147 | #define ST_UH(...) ST_H(v8u16, __VA_ARGS__) 148 | 149 | /* Description : Load two vectors with 16 'byte' sized elements 150 | Arguments : Inputs - psrc, stride 151 | Outputs - out0, out1 152 | Return Type - as per RTYPE 153 | Details : Load 16 byte elements in 'out0' from (psrc) 154 | Load 16 byte elements in 'out1' from (psrc + stride) 155 | */ 156 | #define LD_B2(RTYPE, psrc, stride, out0, out1) \ 157 | { \ 158 | out0 = LD_B(RTYPE, (psrc)); \ 159 | out1 = LD_B(RTYPE, (psrc) + stride); \ 160 | } 161 | #define LD_UB2(...) LD_B2(const v16u8, __VA_ARGS__) 162 | 163 | #define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) \ 164 | { \ 165 | LD_B2(RTYPE, (psrc), stride, out0, out1); \ 166 | LD_B2(RTYPE, (psrc) + 2 * stride, stride, out2, out3); \ 167 | } 168 | #define LD_UB4(...) LD_B4(const v16u8, __VA_ARGS__) 169 | 170 | /* Description : Store two vectors with stride each having 16 'byte' sized 171 | elements 172 | Arguments : Inputs - in0, in1, pdst, stride 173 | Details : Store 16 byte elements from 'in0' to (pdst) 174 | Store 16 byte elements from 'in1' to (pdst + stride) 175 | */ 176 | #define ST_B2(RTYPE, in0, in1, pdst, stride) \ 177 | { \ 178 | ST_B(RTYPE, in0, (pdst)); \ 179 | ST_B(RTYPE, in1, (pdst) + stride); \ 180 | } 181 | #define ST_UB2(...) ST_B2(v16u8, __VA_ARGS__) 182 | 183 | #define ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride) \ 184 | { \ 185 | ST_B2(RTYPE, in0, in1, (pdst), stride); \ 186 | ST_B2(RTYPE, in2, in3, (pdst) + 2 * stride, stride); \ 187 | } 188 | #define ST_UB4(...) ST_B4(v16u8, __VA_ARGS__) 189 | 190 | /* Description : Store vectors of 8 halfword elements with stride 191 | Arguments : Inputs - in0, in1, pdst, stride 192 | Details : Store 8 halfword elements from 'in0' to (pdst) 193 | Store 8 halfword elements from 'in1' to (pdst + stride) 194 | */ 195 | #define ST_H2(RTYPE, in0, in1, pdst, stride) \ 196 | { \ 197 | ST_H(RTYPE, in0, (pdst)); \ 198 | ST_H(RTYPE, in1, (pdst) + stride); \ 199 | } 200 | #define ST_UH2(...) ST_H2(v8u16, __VA_ARGS__) 201 | 202 | // TODO(fbarchard): Consider using __msa_vshf_b and __msa_ilvr_b directly. 203 | /* Description : Shuffle byte vector elements as per mask vector 204 | Arguments : Inputs - in0, in1, in2, in3, mask0, mask1 205 | Outputs - out0, out1 206 | Return Type - as per RTYPE 207 | Details : Byte elements from 'in0' & 'in1' are copied selectively to 208 | 'out0' as per control vector 'mask0' 209 | */ 210 | #define VSHF_B2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) \ 211 | { \ 212 | out0 = (RTYPE)__msa_vshf_b((v16i8)mask0, (v16i8)in1, (v16i8)in0); \ 213 | out1 = (RTYPE)__msa_vshf_b((v16i8)mask1, (v16i8)in3, (v16i8)in2); \ 214 | } 215 | #define VSHF_B2_UB(...) VSHF_B2(v16u8, __VA_ARGS__) 216 | 217 | /* Description : Interleave both left and right half of input vectors 218 | Arguments : Inputs - in0, in1 219 | Outputs - out0, out1 220 | Return Type - as per RTYPE 221 | Details : Right half of byte elements from 'in0' and 'in1' are 222 | interleaved and written to 'out0' 223 | */ 224 | #define ILVRL_B2(RTYPE, in0, in1, out0, out1) \ 225 | { \ 226 | out0 = (RTYPE)__msa_ilvr_b((v16i8)in0, (v16i8)in1); \ 227 | out1 = (RTYPE)__msa_ilvl_b((v16i8)in0, (v16i8)in1); \ 228 | } 229 | #define ILVRL_B2_UB(...) ILVRL_B2(v16u8, __VA_ARGS__) 230 | 231 | #endif /* !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) */ 232 | 233 | #endif // INCLUDE_LIBYUV_MACROS_MSA_H_ 234 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/mjpeg_decoder.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_MJPEG_DECODER_H_ 12 | #define INCLUDE_LIBYUV_MJPEG_DECODER_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | // NOTE: For a simplified public API use convert.h MJPGToI420(). 18 | 19 | struct jpeg_common_struct; 20 | struct jpeg_decompress_struct; 21 | struct jpeg_source_mgr; 22 | 23 | namespace libyuv { 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | LIBYUV_BOOL ValidateJpeg(const uint8_t* sample, size_t sample_size); 30 | 31 | #ifdef __cplusplus 32 | } // extern "C" 33 | #endif 34 | 35 | static const uint32_t kUnknownDataSize = 0xFFFFFFFF; 36 | 37 | enum JpegSubsamplingType { 38 | kJpegYuv420, 39 | kJpegYuv422, 40 | kJpegYuv444, 41 | kJpegYuv400, 42 | kJpegUnknown 43 | }; 44 | 45 | struct Buffer { 46 | const uint8_t* data; 47 | int len; 48 | }; 49 | 50 | struct BufferVector { 51 | Buffer* buffers; 52 | int len; 53 | int pos; 54 | }; 55 | 56 | struct SetJmpErrorMgr; 57 | 58 | // MJPEG ("Motion JPEG") is a pseudo-standard video codec where the frames are 59 | // simply independent JPEG images with a fixed huffman table (which is omitted). 60 | // It is rarely used in video transmission, but is common as a camera capture 61 | // format, especially in Logitech devices. This class implements a decoder for 62 | // MJPEG frames. 63 | // 64 | // See http://tools.ietf.org/html/rfc2435 65 | class LIBYUV_API MJpegDecoder { 66 | public: 67 | typedef void (*CallbackFunction)(void* opaque, 68 | const uint8_t* const* data, 69 | const int* strides, 70 | int rows); 71 | 72 | static const int kColorSpaceUnknown; 73 | static const int kColorSpaceGrayscale; 74 | static const int kColorSpaceRgb; 75 | static const int kColorSpaceYCbCr; 76 | static const int kColorSpaceCMYK; 77 | static const int kColorSpaceYCCK; 78 | 79 | MJpegDecoder(); 80 | ~MJpegDecoder(); 81 | 82 | // Loads a new frame, reads its headers, and determines the uncompressed 83 | // image format. 84 | // Returns LIBYUV_TRUE if image looks valid and format is supported. 85 | // If return value is LIBYUV_TRUE, then the values for all the following 86 | // getters are populated. 87 | // src_len is the size of the compressed mjpeg frame in bytes. 88 | LIBYUV_BOOL LoadFrame(const uint8_t* src, size_t src_len); 89 | 90 | // Returns width of the last loaded frame in pixels. 91 | int GetWidth(); 92 | 93 | // Returns height of the last loaded frame in pixels. 94 | int GetHeight(); 95 | 96 | // Returns format of the last loaded frame. The return value is one of the 97 | // kColorSpace* constants. 98 | int GetColorSpace(); 99 | 100 | // Number of color components in the color space. 101 | int GetNumComponents(); 102 | 103 | // Sample factors of the n-th component. 104 | int GetHorizSampFactor(int component); 105 | 106 | int GetVertSampFactor(int component); 107 | 108 | int GetHorizSubSampFactor(int component); 109 | 110 | int GetVertSubSampFactor(int component); 111 | 112 | // Public for testability. 113 | int GetImageScanlinesPerImcuRow(); 114 | 115 | // Public for testability. 116 | int GetComponentScanlinesPerImcuRow(int component); 117 | 118 | // Width of a component in bytes. 119 | int GetComponentWidth(int component); 120 | 121 | // Height of a component. 122 | int GetComponentHeight(int component); 123 | 124 | // Width of a component in bytes with padding for DCTSIZE. Public for testing. 125 | int GetComponentStride(int component); 126 | 127 | // Size of a component in bytes. 128 | int GetComponentSize(int component); 129 | 130 | // Call this after LoadFrame() if you decide you don't want to decode it 131 | // after all. 132 | LIBYUV_BOOL UnloadFrame(); 133 | 134 | // Decodes the entire image into a one-buffer-per-color-component format. 135 | // dst_width must match exactly. dst_height must be <= to image height; if 136 | // less, the image is cropped. "planes" must have size equal to at least 137 | // GetNumComponents() and they must point to non-overlapping buffers of size 138 | // at least GetComponentSize(i). The pointers in planes are incremented 139 | // to point to after the end of the written i420Bytes. 140 | // TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded. 141 | LIBYUV_BOOL DecodeToBuffers(uint8_t** planes, int dst_width, int dst_height); 142 | 143 | // Decodes the entire image and passes the i420Bytes via repeated calls to a 144 | // callback function. Each call will get the i420Bytes for a whole number of 145 | // image scanlines. 146 | // TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded. 147 | LIBYUV_BOOL DecodeToCallback(CallbackFunction fn, 148 | void* opaque, 149 | int dst_width, 150 | int dst_height); 151 | 152 | // The helper function which recognizes the jpeg sub-sampling type. 153 | static JpegSubsamplingType JpegSubsamplingTypeHelper( 154 | int* subsample_x, 155 | int* subsample_y, 156 | int number_of_components); 157 | 158 | private: 159 | void AllocOutputBuffers(int num_outbufs); 160 | void DestroyOutputBuffers(); 161 | 162 | LIBYUV_BOOL StartDecode(); 163 | LIBYUV_BOOL FinishDecode(); 164 | 165 | void SetScanlinePointers(uint8_t** data); 166 | LIBYUV_BOOL DecodeImcuRow(); 167 | 168 | int GetComponentScanlinePadding(int component); 169 | 170 | // A buffer holding the input i420Bytes for a frame. 171 | Buffer buf_; 172 | BufferVector buf_vec_; 173 | 174 | jpeg_decompress_struct* decompress_struct_; 175 | jpeg_source_mgr* source_mgr_; 176 | SetJmpErrorMgr* error_mgr_; 177 | 178 | // LIBYUV_TRUE iff at least one component has scanline padding. (i.e., 179 | // GetComponentScanlinePadding() != 0.) 180 | LIBYUV_BOOL has_scanline_padding_; 181 | 182 | // Temporaries used to point to scanline outputs. 183 | int num_outbufs_; // Outermost size of all arrays below. 184 | uint8_t*** scanlines_; 185 | int* scanlines_sizes_; 186 | // Temporary buffer used for decoding when we can't decode directly to the 187 | // output buffers. Large enough for just one iMCU row. 188 | uint8_t** databuf_; 189 | int* databuf_strides_; 190 | }; 191 | 192 | } // namespace libyuv 193 | 194 | #endif // __cplusplus 195 | #endif // INCLUDE_LIBYUV_MJPEG_DECODER_H_ 196 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/planar_functions.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_PLANAR_FUNCTIONS_H_ 12 | #define INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | // TODO(fbarchard): Remove the following headers includes. 17 | #include "libyuv/convert.h" 18 | #include "libyuv/convert_argb.h" 19 | 20 | #ifdef __cplusplus 21 | namespace libyuv { 22 | extern "C" { 23 | #endif 24 | 25 | // TODO(fbarchard): Move cpu macros to row.h 26 | #if defined(__pnacl__) || defined(__CLR_VER) || \ 27 | (defined(__native_client__) && defined(__x86_64__)) || \ 28 | (defined(__i386__) && !defined(__SSE__) && !defined(__clang__)) 29 | #define LIBYUV_DISABLE_X86 30 | #endif 31 | // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 32 | #if defined(__has_feature) 33 | #if __has_feature(memory_sanitizer) 34 | #define LIBYUV_DISABLE_X86 35 | #endif 36 | #endif 37 | // The following are available on all x86 platforms: 38 | #if !defined(LIBYUV_DISABLE_X86) && \ 39 | (defined(_M_IX86) || defined(__x86_64__) || defined(__i386__)) 40 | #define HAS_ARGBAFFINEROW_SSE2 41 | #endif 42 | 43 | // Copy a plane of i420Bytes. 44 | LIBYUV_API 45 | void CopyPlane(const uint8_t* src_y, 46 | int src_stride_y, 47 | uint8_t* dst_y, 48 | int dst_stride_y, 49 | int width, 50 | int height); 51 | 52 | LIBYUV_API 53 | void CopyPlane_16(const uint16_t* src_y, 54 | int src_stride_y, 55 | uint16_t* dst_y, 56 | int dst_stride_y, 57 | int width, 58 | int height); 59 | 60 | LIBYUV_API 61 | void Convert16To8Plane(const uint16_t* src_y, 62 | int src_stride_y, 63 | uint8_t* dst_y, 64 | int dst_stride_y, 65 | int scale, // 16384 for 10 bits 66 | int width, 67 | int height); 68 | 69 | LIBYUV_API 70 | void Convert8To16Plane(const uint8_t* src_y, 71 | int src_stride_y, 72 | uint16_t* dst_y, 73 | int dst_stride_y, 74 | int scale, // 1024 for 10 bits 75 | int width, 76 | int height); 77 | 78 | // Set a plane of i420Bytes to a 32 bit value. 79 | LIBYUV_API 80 | void SetPlane(uint8_t* dst_y, 81 | int dst_stride_y, 82 | int width, 83 | int height, 84 | uint32_t value); 85 | 86 | // Split interleaved UV plane into separate U and V planes. 87 | LIBYUV_API 88 | void SplitUVPlane(const uint8_t* src_uv, 89 | int src_stride_uv, 90 | uint8_t* dst_u, 91 | int dst_stride_u, 92 | uint8_t* dst_v, 93 | int dst_stride_v, 94 | int width, 95 | int height); 96 | 97 | // Merge separate U and V planes into one interleaved UV plane. 98 | LIBYUV_API 99 | void MergeUVPlane(const uint8_t* src_u, 100 | int src_stride_u, 101 | const uint8_t* src_v, 102 | int src_stride_v, 103 | uint8_t* dst_uv, 104 | int dst_stride_uv, 105 | int width, 106 | int height); 107 | 108 | // Swap U and V channels in interleaved UV plane. 109 | LIBYUV_API 110 | void SwapUVPlane(const uint8_t* src_uv, 111 | int src_stride_uv, 112 | uint8_t* dst_vu, 113 | int dst_stride_vu, 114 | int width, 115 | int height); 116 | 117 | // Split interleaved RGB plane into separate R, G and B planes. 118 | LIBYUV_API 119 | void SplitRGBPlane(const uint8_t* src_rgb, 120 | int src_stride_rgb, 121 | uint8_t* dst_r, 122 | int dst_stride_r, 123 | uint8_t* dst_g, 124 | int dst_stride_g, 125 | uint8_t* dst_b, 126 | int dst_stride_b, 127 | int width, 128 | int height); 129 | 130 | // Merge separate R, G and B planes into one interleaved RGB plane. 131 | LIBYUV_API 132 | void MergeRGBPlane(const uint8_t* src_r, 133 | int src_stride_r, 134 | const uint8_t* src_g, 135 | int src_stride_g, 136 | const uint8_t* src_b, 137 | int src_stride_b, 138 | uint8_t* dst_rgb, 139 | int dst_stride_rgb, 140 | int width, 141 | int height); 142 | 143 | // Copy I400. Supports inverting. 144 | LIBYUV_API 145 | int I400ToI400(const uint8_t* src_y, 146 | int src_stride_y, 147 | uint8_t* dst_y, 148 | int dst_stride_y, 149 | int width, 150 | int height); 151 | 152 | #define J400ToJ400 I400ToI400 153 | 154 | // Copy I422 to I422. 155 | #define I422ToI422 I422Copy 156 | LIBYUV_API 157 | int I422Copy(const uint8_t* src_y, 158 | int src_stride_y, 159 | const uint8_t* src_u, 160 | int src_stride_u, 161 | const uint8_t* src_v, 162 | int src_stride_v, 163 | uint8_t* dst_y, 164 | int dst_stride_y, 165 | uint8_t* dst_u, 166 | int dst_stride_u, 167 | uint8_t* dst_v, 168 | int dst_stride_v, 169 | int width, 170 | int height); 171 | 172 | // Copy I444 to I444. 173 | #define I444ToI444 I444Copy 174 | LIBYUV_API 175 | int I444Copy(const uint8_t* src_y, 176 | int src_stride_y, 177 | const uint8_t* src_u, 178 | int src_stride_u, 179 | const uint8_t* src_v, 180 | int src_stride_v, 181 | uint8_t* dst_y, 182 | int dst_stride_y, 183 | uint8_t* dst_u, 184 | int dst_stride_u, 185 | uint8_t* dst_v, 186 | int dst_stride_v, 187 | int width, 188 | int height); 189 | 190 | // Convert YUY2 to I422. 191 | LIBYUV_API 192 | int YUY2ToI422(const uint8_t* src_yuy2, 193 | int src_stride_yuy2, 194 | uint8_t* dst_y, 195 | int dst_stride_y, 196 | uint8_t* dst_u, 197 | int dst_stride_u, 198 | uint8_t* dst_v, 199 | int dst_stride_v, 200 | int width, 201 | int height); 202 | 203 | // Convert UYVY to I422. 204 | LIBYUV_API 205 | int UYVYToI422(const uint8_t* src_uyvy, 206 | int src_stride_uyvy, 207 | uint8_t* dst_y, 208 | int dst_stride_y, 209 | uint8_t* dst_u, 210 | int dst_stride_u, 211 | uint8_t* dst_v, 212 | int dst_stride_v, 213 | int width, 214 | int height); 215 | 216 | LIBYUV_API 217 | int YUY2ToNV12(const uint8_t* src_yuy2, 218 | int src_stride_yuy2, 219 | uint8_t* dst_y, 220 | int dst_stride_y, 221 | uint8_t* dst_uv, 222 | int dst_stride_uv, 223 | int width, 224 | int height); 225 | 226 | LIBYUV_API 227 | int UYVYToNV12(const uint8_t* src_uyvy, 228 | int src_stride_uyvy, 229 | uint8_t* dst_y, 230 | int dst_stride_y, 231 | uint8_t* dst_uv, 232 | int dst_stride_uv, 233 | int width, 234 | int height); 235 | 236 | // Convert NV21 to NV12. 237 | LIBYUV_API 238 | int NV21ToNV12(const uint8_t* src_y, 239 | int src_stride_y, 240 | const uint8_t* src_vu, 241 | int src_stride_vu, 242 | uint8_t* dst_y, 243 | int dst_stride_y, 244 | uint8_t* dst_uv, 245 | int dst_stride_uv, 246 | int width, 247 | int height); 248 | 249 | LIBYUV_API 250 | int YUY2ToY(const uint8_t* src_yuy2, 251 | int src_stride_yuy2, 252 | uint8_t* dst_y, 253 | int dst_stride_y, 254 | int width, 255 | int height); 256 | 257 | // Convert I420 to I400. (calls CopyPlane ignoring u/v). 258 | LIBYUV_API 259 | int I420ToI400(const uint8_t* src_y, 260 | int src_stride_y, 261 | const uint8_t* src_u, 262 | int src_stride_u, 263 | const uint8_t* src_v, 264 | int src_stride_v, 265 | uint8_t* dst_y, 266 | int dst_stride_y, 267 | int width, 268 | int height); 269 | 270 | // Alias 271 | #define J420ToJ400 I420ToI400 272 | #define I420ToI420Mirror I420Mirror 273 | 274 | // I420 mirror. 275 | LIBYUV_API 276 | int I420Mirror(const uint8_t* src_y, 277 | int src_stride_y, 278 | const uint8_t* src_u, 279 | int src_stride_u, 280 | const uint8_t* src_v, 281 | int src_stride_v, 282 | uint8_t* dst_y, 283 | int dst_stride_y, 284 | uint8_t* dst_u, 285 | int dst_stride_u, 286 | uint8_t* dst_v, 287 | int dst_stride_v, 288 | int width, 289 | int height); 290 | 291 | // Alias 292 | #define I400ToI400Mirror I400Mirror 293 | 294 | // I400 mirror. A single plane is mirrored horizontally. 295 | // Pass negative height to achieve 180 degree rotation. 296 | LIBYUV_API 297 | int I400Mirror(const uint8_t* src_y, 298 | int src_stride_y, 299 | uint8_t* dst_y, 300 | int dst_stride_y, 301 | int width, 302 | int height); 303 | 304 | // Alias 305 | #define ARGBToARGBMirror ARGBMirror 306 | 307 | // ARGB mirror. 308 | LIBYUV_API 309 | int ARGBMirror(const uint8_t* src_argb, 310 | int src_stride_argb, 311 | uint8_t* dst_argb, 312 | int dst_stride_argb, 313 | int width, 314 | int height); 315 | 316 | // Convert NV12 to RGB565. 317 | LIBYUV_API 318 | int NV12ToRGB565(const uint8_t* src_y, 319 | int src_stride_y, 320 | const uint8_t* src_uv, 321 | int src_stride_uv, 322 | uint8_t* dst_rgb565, 323 | int dst_stride_rgb565, 324 | int width, 325 | int height); 326 | 327 | // I422ToARGB is in convert_argb.h 328 | // Convert I422 to BGRA. 329 | LIBYUV_API 330 | int I422ToBGRA(const uint8_t* src_y, 331 | int src_stride_y, 332 | const uint8_t* src_u, 333 | int src_stride_u, 334 | const uint8_t* src_v, 335 | int src_stride_v, 336 | uint8_t* dst_bgra, 337 | int dst_stride_bgra, 338 | int width, 339 | int height); 340 | 341 | // Convert I422 to ABGR. 342 | LIBYUV_API 343 | int I422ToABGR(const uint8_t* src_y, 344 | int src_stride_y, 345 | const uint8_t* src_u, 346 | int src_stride_u, 347 | const uint8_t* src_v, 348 | int src_stride_v, 349 | uint8_t* dst_abgr, 350 | int dst_stride_abgr, 351 | int width, 352 | int height); 353 | 354 | // Convert I422 to RGBA. 355 | LIBYUV_API 356 | int I422ToRGBA(const uint8_t* src_y, 357 | int src_stride_y, 358 | const uint8_t* src_u, 359 | int src_stride_u, 360 | const uint8_t* src_v, 361 | int src_stride_v, 362 | uint8_t* dst_rgba, 363 | int dst_stride_rgba, 364 | int width, 365 | int height); 366 | 367 | // Alias 368 | #define RGB24ToRAW RAWToRGB24 369 | 370 | LIBYUV_API 371 | int RAWToRGB24(const uint8_t* src_raw, 372 | int src_stride_raw, 373 | uint8_t* dst_rgb24, 374 | int dst_stride_rgb24, 375 | int width, 376 | int height); 377 | 378 | // Draw a rectangle into I420. 379 | LIBYUV_API 380 | int I420Rect(uint8_t* dst_y, 381 | int dst_stride_y, 382 | uint8_t* dst_u, 383 | int dst_stride_u, 384 | uint8_t* dst_v, 385 | int dst_stride_v, 386 | int x, 387 | int y, 388 | int width, 389 | int height, 390 | int value_y, 391 | int value_u, 392 | int value_v); 393 | 394 | // Draw a rectangle into ARGB. 395 | LIBYUV_API 396 | int ARGBRect(uint8_t* dst_argb, 397 | int dst_stride_argb, 398 | int dst_x, 399 | int dst_y, 400 | int width, 401 | int height, 402 | uint32_t value); 403 | 404 | // Convert ARGB to gray rotate ARGB. 405 | LIBYUV_API 406 | int ARGBGrayTo(const uint8_t* src_argb, 407 | int src_stride_argb, 408 | uint8_t* dst_argb, 409 | int dst_stride_argb, 410 | int width, 411 | int height); 412 | 413 | // Make a rectangle of ARGB gray rotate. 414 | LIBYUV_API 415 | int ARGBGray(uint8_t* dst_argb, 416 | int dst_stride_argb, 417 | int dst_x, 418 | int dst_y, 419 | int width, 420 | int height); 421 | 422 | // Make a rectangle of ARGB Sepia tone. 423 | LIBYUV_API 424 | int ARGBSepia(uint8_t* dst_argb, 425 | int dst_stride_argb, 426 | int dst_x, 427 | int dst_y, 428 | int width, 429 | int height); 430 | 431 | // Apply a matrix rotation to each ARGB pixel. 432 | // matrix_argb is 4 signed ARGB values. -128 to 127 representing -2 to 2. 433 | // The first 4 coefficients apply to B, G, R, A and produce B of the output. 434 | // The next 4 coefficients apply to B, G, R, A and produce G of the output. 435 | // The next 4 coefficients apply to B, G, R, A and produce R of the output. 436 | // The last 4 coefficients apply to B, G, R, A and produce A of the output. 437 | LIBYUV_API 438 | int ARGBColorMatrix(const uint8_t* src_argb, 439 | int src_stride_argb, 440 | uint8_t* dst_argb, 441 | int dst_stride_argb, 442 | const int8_t* matrix_argb, 443 | int width, 444 | int height); 445 | 446 | // Deprecated. Use ARGBColorMatrix instead. 447 | // Apply a matrix rotation to each ARGB pixel. 448 | // matrix_argb is 3 signed ARGB values. -128 to 127 representing -1 to 1. 449 | // The first 4 coefficients apply to B, G, R, A and produce B of the output. 450 | // The next 4 coefficients apply to B, G, R, A and produce G of the output. 451 | // The last 4 coefficients apply to B, G, R, A and produce R of the output. 452 | LIBYUV_API 453 | int RGBColorMatrix(uint8_t* dst_argb, 454 | int dst_stride_argb, 455 | const int8_t* matrix_rgb, 456 | int dst_x, 457 | int dst_y, 458 | int width, 459 | int height); 460 | 461 | // Apply a color table each ARGB pixel. 462 | // Table contains 256 ARGB values. 463 | LIBYUV_API 464 | int ARGBColorTable(uint8_t* dst_argb, 465 | int dst_stride_argb, 466 | const uint8_t* table_argb, 467 | int dst_x, 468 | int dst_y, 469 | int width, 470 | int height); 471 | 472 | // Apply a color table each ARGB pixel but preserve destination alpha. 473 | // Table contains 256 ARGB values. 474 | LIBYUV_API 475 | int RGBColorTable(uint8_t* dst_argb, 476 | int dst_stride_argb, 477 | const uint8_t* table_argb, 478 | int dst_x, 479 | int dst_y, 480 | int width, 481 | int height); 482 | 483 | // Apply a luma/color table each ARGB pixel but preserve destination alpha. 484 | // Table contains 32768 values indexed by [Y][C] where 7 it 7 bit luma from 485 | // RGB (YJ style) and C is an 8 bit color component (R, G or B). 486 | LIBYUV_API 487 | int ARGBLumaColorTable(const uint8_t* src_argb, 488 | int src_stride_argb, 489 | uint8_t* dst_argb, 490 | int dst_stride_argb, 491 | const uint8_t* luma, 492 | int width, 493 | int height); 494 | 495 | // Apply a 3 term polynomial to ARGB values. 496 | // poly points to a 4x4 matrix. The first row is constants. The 2nd row is 497 | // coefficients for b, g, r and a. The 3rd row is coefficients for b squared, 498 | // g squared, r squared and a squared. The 4rd row is coefficients for b to 499 | // the 3, g to the 3, r to the 3 and a to the 3. The values are summed and 500 | // result clamped to 0 to 255. 501 | // A polynomial approximation can be dirived using software such as 'R'. 502 | 503 | LIBYUV_API 504 | int ARGBPolynomial(const uint8_t* src_argb, 505 | int src_stride_argb, 506 | uint8_t* dst_argb, 507 | int dst_stride_argb, 508 | const float* poly, 509 | int width, 510 | int height); 511 | 512 | // Convert plane of 16 bit shorts to half floats. 513 | // Source values are multiplied by rotate before storing as half float. 514 | LIBYUV_API 515 | int HalfFloatPlane(const uint16_t* src_y, 516 | int src_stride_y, 517 | uint16_t* dst_y, 518 | int dst_stride_y, 519 | float scale, 520 | int width, 521 | int height); 522 | 523 | // Convert a buffer of bytes to floats, rotate the values and store as floats. 524 | LIBYUV_API 525 | int ByteToFloat(const uint8_t* src_y, float* dst_y, float scale, int width); 526 | 527 | // Quantize a rectangle of ARGB. Alpha unaffected. 528 | // rotate is a 16 bit fractional fixed point scaler between 0 and 65535. 529 | // interval_size should be a value between 1 and 255. 530 | // interval_offset should be a value between 0 and 255. 531 | LIBYUV_API 532 | int ARGBQuantize(uint8_t* dst_argb, 533 | int dst_stride_argb, 534 | int scale, 535 | int interval_size, 536 | int interval_offset, 537 | int dst_x, 538 | int dst_y, 539 | int width, 540 | int height); 541 | 542 | // Copy ARGB to ARGB. 543 | LIBYUV_API 544 | int ARGBCopy(const uint8_t* src_argb, 545 | int src_stride_argb, 546 | uint8_t* dst_argb, 547 | int dst_stride_argb, 548 | int width, 549 | int height); 550 | 551 | // Copy Alpha channel of ARGB to alpha of ARGB. 552 | LIBYUV_API 553 | int ARGBCopyAlpha(const uint8_t* src_argb, 554 | int src_stride_argb, 555 | uint8_t* dst_argb, 556 | int dst_stride_argb, 557 | int width, 558 | int height); 559 | 560 | // Extract the alpha channel from ARGB. 561 | LIBYUV_API 562 | int ARGBExtractAlpha(const uint8_t* src_argb, 563 | int src_stride_argb, 564 | uint8_t* dst_a, 565 | int dst_stride_a, 566 | int width, 567 | int height); 568 | 569 | // Copy Y channel to Alpha of ARGB. 570 | LIBYUV_API 571 | int ARGBCopyYToAlpha(const uint8_t* src_y, 572 | int src_stride_y, 573 | uint8_t* dst_argb, 574 | int dst_stride_argb, 575 | int width, 576 | int height); 577 | 578 | typedef void (*ARGBBlendRow)(const uint8_t* src_argb0, 579 | const uint8_t* src_argb1, 580 | uint8_t* dst_argb, 581 | int width); 582 | 583 | // Get function to Alpha Blend ARGB pixels and store to destination. 584 | LIBYUV_API 585 | ARGBBlendRow GetARGBBlend(); 586 | 587 | // Alpha Blend ARGB images and store to destination. 588 | // Source is pre-multiplied by alpha using ARGBAttenuate. 589 | // Alpha of destination is set to 255. 590 | LIBYUV_API 591 | int ARGBBlend(const uint8_t* src_argb0, 592 | int src_stride_argb0, 593 | const uint8_t* src_argb1, 594 | int src_stride_argb1, 595 | uint8_t* dst_argb, 596 | int dst_stride_argb, 597 | int width, 598 | int height); 599 | 600 | // Alpha Blend plane and store to destination. 601 | // Source is not pre-multiplied by alpha. 602 | LIBYUV_API 603 | int BlendPlane(const uint8_t* src_y0, 604 | int src_stride_y0, 605 | const uint8_t* src_y1, 606 | int src_stride_y1, 607 | const uint8_t* alpha, 608 | int alpha_stride, 609 | uint8_t* dst_y, 610 | int dst_stride_y, 611 | int width, 612 | int height); 613 | 614 | // Alpha Blend YUV images and store to destination. 615 | // Source is not pre-multiplied by alpha. 616 | // Alpha is full width x height and subsampled to half size to apply to UV. 617 | LIBYUV_API 618 | int I420Blend(const uint8_t* src_y0, 619 | int src_stride_y0, 620 | const uint8_t* src_u0, 621 | int src_stride_u0, 622 | const uint8_t* src_v0, 623 | int src_stride_v0, 624 | const uint8_t* src_y1, 625 | int src_stride_y1, 626 | const uint8_t* src_u1, 627 | int src_stride_u1, 628 | const uint8_t* src_v1, 629 | int src_stride_v1, 630 | const uint8_t* alpha, 631 | int alpha_stride, 632 | uint8_t* dst_y, 633 | int dst_stride_y, 634 | uint8_t* dst_u, 635 | int dst_stride_u, 636 | uint8_t* dst_v, 637 | int dst_stride_v, 638 | int width, 639 | int height); 640 | 641 | // Multiply ARGB image by ARGB image. Shifted down by 8. Saturates to 255. 642 | LIBYUV_API 643 | int ARGBMultiply(const uint8_t* src_argb0, 644 | int src_stride_argb0, 645 | const uint8_t* src_argb1, 646 | int src_stride_argb1, 647 | uint8_t* dst_argb, 648 | int dst_stride_argb, 649 | int width, 650 | int height); 651 | 652 | // Add ARGB image with ARGB image. Saturates to 255. 653 | LIBYUV_API 654 | int ARGBAdd(const uint8_t* src_argb0, 655 | int src_stride_argb0, 656 | const uint8_t* src_argb1, 657 | int src_stride_argb1, 658 | uint8_t* dst_argb, 659 | int dst_stride_argb, 660 | int width, 661 | int height); 662 | 663 | // Subtract ARGB image (argb1) from ARGB image (argb0). Saturates to 0. 664 | LIBYUV_API 665 | int ARGBSubtract(const uint8_t* src_argb0, 666 | int src_stride_argb0, 667 | const uint8_t* src_argb1, 668 | int src_stride_argb1, 669 | uint8_t* dst_argb, 670 | int dst_stride_argb, 671 | int width, 672 | int height); 673 | 674 | // Convert I422 to YUY2. 675 | LIBYUV_API 676 | int I422ToYUY2(const uint8_t* src_y, 677 | int src_stride_y, 678 | const uint8_t* src_u, 679 | int src_stride_u, 680 | const uint8_t* src_v, 681 | int src_stride_v, 682 | uint8_t* dst_yuy2, 683 | int dst_stride_yuy2, 684 | int width, 685 | int height); 686 | 687 | // Convert I422 to UYVY. 688 | LIBYUV_API 689 | int I422ToUYVY(const uint8_t* src_y, 690 | int src_stride_y, 691 | const uint8_t* src_u, 692 | int src_stride_u, 693 | const uint8_t* src_v, 694 | int src_stride_v, 695 | uint8_t* dst_uyvy, 696 | int dst_stride_uyvy, 697 | int width, 698 | int height); 699 | 700 | // Convert unattentuated ARGB to preattenuated ARGB. 701 | LIBYUV_API 702 | int ARGBAttenuate(const uint8_t* src_argb, 703 | int src_stride_argb, 704 | uint8_t* dst_argb, 705 | int dst_stride_argb, 706 | int width, 707 | int height); 708 | 709 | // Convert preattentuated ARGB to unattenuated ARGB. 710 | LIBYUV_API 711 | int ARGBUnattenuate(const uint8_t* src_argb, 712 | int src_stride_argb, 713 | uint8_t* dst_argb, 714 | int dst_stride_argb, 715 | int width, 716 | int height); 717 | 718 | // Internal function - do not call directly. 719 | // Computes table of cumulative sum for image where the value is the sum 720 | // of all values above and to the left of the entry. Used by ARGBBlur. 721 | LIBYUV_API 722 | int ARGBComputeCumulativeSum(const uint8_t* src_argb, 723 | int src_stride_argb, 724 | int32_t* dst_cumsum, 725 | int dst_stride32_cumsum, 726 | int width, 727 | int height); 728 | 729 | // Blur ARGB image. 730 | // dst_cumsum table of width * (height + 1) * 16 bytes aligned to 731 | // 16 byte boundary. 732 | // dst_stride32_cumsum is number of ints in a row (width * 4). 733 | // radius is number of pixels around the center. e.g. 1 = 3x3. 2=5x5. 734 | // Blur is optimized for radius of 5 (11x11) or less. 735 | LIBYUV_API 736 | int ARGBBlur(const uint8_t* src_argb, 737 | int src_stride_argb, 738 | uint8_t* dst_argb, 739 | int dst_stride_argb, 740 | int32_t* dst_cumsum, 741 | int dst_stride32_cumsum, 742 | int width, 743 | int height, 744 | int radius); 745 | 746 | // Multiply ARGB image by ARGB value. 747 | LIBYUV_API 748 | int ARGBShade(const uint8_t* src_argb, 749 | int src_stride_argb, 750 | uint8_t* dst_argb, 751 | int dst_stride_argb, 752 | int width, 753 | int height, 754 | uint32_t value); 755 | 756 | // Interpolate between two images using specified amount of interpolation 757 | // (0 to 255) and store to destination. 758 | // 'interpolation' is specified as 8 bit fraction where 0 means 100% src0 759 | // and 255 means 1% src0 and 99% src1. 760 | LIBYUV_API 761 | int InterpolatePlane(const uint8_t* src0, 762 | int src_stride0, 763 | const uint8_t* src1, 764 | int src_stride1, 765 | uint8_t* dst, 766 | int dst_stride, 767 | int width, 768 | int height, 769 | int interpolation); 770 | 771 | // Interpolate between two ARGB images using specified amount of interpolation 772 | // Internally calls InterpolatePlane with width * 4 (bpp). 773 | LIBYUV_API 774 | int ARGBInterpolate(const uint8_t* src_argb0, 775 | int src_stride_argb0, 776 | const uint8_t* src_argb1, 777 | int src_stride_argb1, 778 | uint8_t* dst_argb, 779 | int dst_stride_argb, 780 | int width, 781 | int height, 782 | int interpolation); 783 | 784 | // Interpolate between two YUV images using specified amount of interpolation 785 | // Internally calls InterpolatePlane on each plane where the U and V planes 786 | // are half width and half height. 787 | LIBYUV_API 788 | int I420Interpolate(const uint8_t* src0_y, 789 | int src0_stride_y, 790 | const uint8_t* src0_u, 791 | int src0_stride_u, 792 | const uint8_t* src0_v, 793 | int src0_stride_v, 794 | const uint8_t* src1_y, 795 | int src1_stride_y, 796 | const uint8_t* src1_u, 797 | int src1_stride_u, 798 | const uint8_t* src1_v, 799 | int src1_stride_v, 800 | uint8_t* dst_y, 801 | int dst_stride_y, 802 | uint8_t* dst_u, 803 | int dst_stride_u, 804 | uint8_t* dst_v, 805 | int dst_stride_v, 806 | int width, 807 | int height, 808 | int interpolation); 809 | 810 | // Row function for copying pixels from a source with a slope to a row 811 | // of destination. Useful for scaling, rotation, mirror, texture mapping. 812 | LIBYUV_API 813 | void ARGBAffineRow_C(const uint8_t* src_argb, 814 | int src_argb_stride, 815 | uint8_t* dst_argb, 816 | const float* uv_dudv, 817 | int width); 818 | // TODO(fbarchard): Move ARGBAffineRow_SSE2 to row.h 819 | LIBYUV_API 820 | void ARGBAffineRow_SSE2(const uint8_t* src_argb, 821 | int src_argb_stride, 822 | uint8_t* dst_argb, 823 | const float* uv_dudv, 824 | int width); 825 | 826 | // Shuffle ARGB channel order. e.g. BGRA to ARGB. 827 | // shuffler is 16 bytes and must be aligned. 828 | LIBYUV_API 829 | int ARGBShuffle(const uint8_t* src_bgra, 830 | int src_stride_bgra, 831 | uint8_t* dst_argb, 832 | int dst_stride_argb, 833 | const uint8_t* shuffler, 834 | int width, 835 | int height); 836 | 837 | // Sobel ARGB effect with planar output. 838 | LIBYUV_API 839 | int ARGBSobelToPlane(const uint8_t* src_argb, 840 | int src_stride_argb, 841 | uint8_t* dst_y, 842 | int dst_stride_y, 843 | int width, 844 | int height); 845 | 846 | // Sobel ARGB effect. 847 | LIBYUV_API 848 | int ARGBSobel(const uint8_t* src_argb, 849 | int src_stride_argb, 850 | uint8_t* dst_argb, 851 | int dst_stride_argb, 852 | int width, 853 | int height); 854 | 855 | // Sobel ARGB effect w/ Sobel X, Sobel, Sobel Y in ARGB. 856 | LIBYUV_API 857 | int ARGBSobelXY(const uint8_t* src_argb, 858 | int src_stride_argb, 859 | uint8_t* dst_argb, 860 | int dst_stride_argb, 861 | int width, 862 | int height); 863 | 864 | #ifdef __cplusplus 865 | } // extern "C" 866 | } // namespace libyuv 867 | #endif 868 | 869 | #endif // INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ 870 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/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_ 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_t* src_y, 37 | int src_stride_y, 38 | const uint8_t* src_u, 39 | int src_stride_u, 40 | const uint8_t* src_v, 41 | int src_stride_v, 42 | uint8_t* dst_y, 43 | int dst_stride_y, 44 | uint8_t* dst_u, 45 | int dst_stride_u, 46 | uint8_t* dst_v, 47 | int dst_stride_v, 48 | int width, 49 | int height, 50 | enum RotationMode mode); 51 | 52 | // Rotate I444 frame. 53 | LIBYUV_API 54 | int I444Rotate(const uint8_t* src_y, 55 | int src_stride_y, 56 | const uint8_t* src_u, 57 | int src_stride_u, 58 | const uint8_t* src_v, 59 | int src_stride_v, 60 | uint8_t* dst_y, 61 | int dst_stride_y, 62 | uint8_t* dst_u, 63 | int dst_stride_u, 64 | uint8_t* dst_v, 65 | int dst_stride_v, 66 | int width, 67 | int height, 68 | enum RotationMode mode); 69 | 70 | // Rotate NV12 input and store in I420. 71 | LIBYUV_API 72 | int NV12ToI420Rotate(const uint8_t* src_y, 73 | int src_stride_y, 74 | const uint8_t* src_uv, 75 | int src_stride_uv, 76 | uint8_t* dst_y, 77 | int dst_stride_y, 78 | uint8_t* dst_u, 79 | int dst_stride_u, 80 | uint8_t* dst_v, 81 | int dst_stride_v, 82 | int width, 83 | int height, 84 | enum RotationMode mode); 85 | 86 | // Rotate a plane by 0, 90, 180, or 270. 87 | LIBYUV_API 88 | int RotatePlane(const uint8_t* src, 89 | int src_stride, 90 | uint8_t* dst, 91 | int dst_stride, 92 | int width, 93 | int height, 94 | enum RotationMode mode); 95 | 96 | // Rotate planes by 90, 180, 270. Deprecated. 97 | LIBYUV_API 98 | void RotatePlane90(const uint8_t* src, 99 | int src_stride, 100 | uint8_t* dst, 101 | int dst_stride, 102 | int width, 103 | int height); 104 | 105 | LIBYUV_API 106 | void RotatePlane180(const uint8_t* src, 107 | int src_stride, 108 | uint8_t* dst, 109 | int dst_stride, 110 | int width, 111 | int height); 112 | 113 | LIBYUV_API 114 | void RotatePlane270(const uint8_t* src, 115 | int src_stride, 116 | uint8_t* dst, 117 | int dst_stride, 118 | int width, 119 | int height); 120 | 121 | LIBYUV_API 122 | void RotateUV90(const uint8_t* src, 123 | int src_stride, 124 | uint8_t* dst_a, 125 | int dst_stride_a, 126 | uint8_t* dst_b, 127 | int dst_stride_b, 128 | int width, 129 | int height); 130 | 131 | // Rotations for when U and V are interleaved. 132 | // These functions take one input pointer and 133 | // split the i420Bytes into two buffers while 134 | // rotating them. Deprecated. 135 | LIBYUV_API 136 | void RotateUV180(const uint8_t* src, 137 | int src_stride, 138 | uint8_t* dst_a, 139 | int dst_stride_a, 140 | uint8_t* dst_b, 141 | int dst_stride_b, 142 | int width, 143 | int height); 144 | 145 | LIBYUV_API 146 | void RotateUV270(const uint8_t* src, 147 | int src_stride, 148 | uint8_t* dst_a, 149 | int dst_stride_a, 150 | uint8_t* dst_b, 151 | int dst_stride_b, 152 | int width, 153 | int height); 154 | 155 | // The 90 and 270 functions are based on transposes. 156 | // Doing a transpose with reversing the read/write 157 | // order will result in a rotation by +- 90 degrees. 158 | // Deprecated. 159 | LIBYUV_API 160 | void TransposePlane(const uint8_t* src, 161 | int src_stride, 162 | uint8_t* dst, 163 | int dst_stride, 164 | int width, 165 | int height); 166 | 167 | LIBYUV_API 168 | void TransposeUV(const uint8_t* src, 169 | int src_stride, 170 | uint8_t* dst_a, 171 | int dst_stride_a, 172 | uint8_t* dst_b, 173 | int dst_stride_b, 174 | int width, 175 | int height); 176 | 177 | #ifdef __cplusplus 178 | } // extern "C" 179 | } // namespace libyuv 180 | #endif 181 | 182 | #endif // INCLUDE_LIBYUV_ROTATE_H_ 183 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/rotate_argb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_ROTATE_ARGB_H_ 12 | #define INCLUDE_LIBYUV_ROTATE_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/rotate.h" // For RotationMode. 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | // Rotate ARGB frame 23 | LIBYUV_API 24 | int ARGBRotate(const uint8_t* src_argb, 25 | int src_stride_argb, 26 | uint8_t* dst_argb, 27 | int dst_stride_argb, 28 | int src_width, 29 | int src_height, 30 | enum RotationMode mode); 31 | 32 | #ifdef __cplusplus 33 | } // extern "C" 34 | } // namespace libyuv 35 | #endif 36 | 37 | #endif // INCLUDE_LIBYUV_ROTATE_ARGB_H_ 38 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/rotate_row.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 | #ifndef INCLUDE_LIBYUV_ROTATE_ROW_H_ 12 | #define INCLUDE_LIBYUV_ROTATE_ROW_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | #if defined(__pnacl__) || defined(__CLR_VER) || \ 22 | (defined(__native_client__) && defined(__x86_64__)) || \ 23 | (defined(__i386__) && !defined(__SSE__) && !defined(__clang__)) 24 | #define LIBYUV_DISABLE_X86 25 | #endif 26 | #if defined(__native_client__) 27 | #define LIBYUV_DISABLE_NEON 28 | #endif 29 | // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 30 | #if defined(__has_feature) 31 | #if __has_feature(memory_sanitizer) 32 | #define LIBYUV_DISABLE_X86 33 | #endif 34 | #endif 35 | // The following are available for Visual C and clangcl 32 bit: 36 | #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER) 37 | #define HAS_TRANSPOSEWX8_SSSE3 38 | #define HAS_TRANSPOSEUVWX8_SSE2 39 | #endif 40 | 41 | // The following are available for GCC 32 or 64 bit: 42 | #if !defined(LIBYUV_DISABLE_X86) && (defined(__i386__) || defined(__x86_64__)) 43 | #define HAS_TRANSPOSEWX8_SSSE3 44 | #endif 45 | 46 | // The following are available for 64 bit GCC: 47 | #if !defined(LIBYUV_DISABLE_X86) && defined(__x86_64__) 48 | #define HAS_TRANSPOSEWX8_FAST_SSSE3 49 | #define HAS_TRANSPOSEUVWX8_SSE2 50 | #endif 51 | 52 | #if !defined(LIBYUV_DISABLE_NEON) && \ 53 | (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__)) 54 | #define HAS_TRANSPOSEWX8_NEON 55 | #define HAS_TRANSPOSEUVWX8_NEON 56 | #endif 57 | 58 | #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) 59 | #define HAS_TRANSPOSEWX16_MSA 60 | #define HAS_TRANSPOSEUVWX16_MSA 61 | #endif 62 | 63 | #if !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A) 64 | #define HAS_TRANSPOSEWX8_MMI 65 | #define HAS_TRANSPOSEUVWX8_MMI 66 | #endif 67 | 68 | void TransposeWxH_C(const uint8_t* src, 69 | int src_stride, 70 | uint8_t* dst, 71 | int dst_stride, 72 | int width, 73 | int height); 74 | 75 | void TransposeWx8_C(const uint8_t* src, 76 | int src_stride, 77 | uint8_t* dst, 78 | int dst_stride, 79 | int width); 80 | void TransposeWx16_C(const uint8_t* src, 81 | int src_stride, 82 | uint8_t* dst, 83 | int dst_stride, 84 | int width); 85 | void TransposeWx8_NEON(const uint8_t* src, 86 | int src_stride, 87 | uint8_t* dst, 88 | int dst_stride, 89 | int width); 90 | void TransposeWx8_SSSE3(const uint8_t* src, 91 | int src_stride, 92 | uint8_t* dst, 93 | int dst_stride, 94 | int width); 95 | void TransposeWx8_MMI(const uint8_t* src, 96 | int src_stride, 97 | uint8_t* dst, 98 | int dst_stride, 99 | int width); 100 | void TransposeWx8_Fast_SSSE3(const uint8_t* src, 101 | int src_stride, 102 | uint8_t* dst, 103 | int dst_stride, 104 | int width); 105 | void TransposeWx16_MSA(const uint8_t* src, 106 | int src_stride, 107 | uint8_t* dst, 108 | int dst_stride, 109 | int width); 110 | 111 | void TransposeWx8_Any_NEON(const uint8_t* src, 112 | int src_stride, 113 | uint8_t* dst, 114 | int dst_stride, 115 | int width); 116 | void TransposeWx8_Any_SSSE3(const uint8_t* src, 117 | int src_stride, 118 | uint8_t* dst, 119 | int dst_stride, 120 | int width); 121 | void TransposeWx8_Any_MMI(const uint8_t* src, 122 | int src_stride, 123 | uint8_t* dst, 124 | int dst_stride, 125 | int width); 126 | void TransposeWx8_Fast_Any_SSSE3(const uint8_t* src, 127 | int src_stride, 128 | uint8_t* dst, 129 | int dst_stride, 130 | int width); 131 | void TransposeWx16_Any_MSA(const uint8_t* src, 132 | int src_stride, 133 | uint8_t* dst, 134 | int dst_stride, 135 | int width); 136 | 137 | void TransposeUVWxH_C(const uint8_t* src, 138 | int src_stride, 139 | uint8_t* dst_a, 140 | int dst_stride_a, 141 | uint8_t* dst_b, 142 | int dst_stride_b, 143 | int width, 144 | int height); 145 | 146 | void TransposeUVWx8_C(const uint8_t* src, 147 | int src_stride, 148 | uint8_t* dst_a, 149 | int dst_stride_a, 150 | uint8_t* dst_b, 151 | int dst_stride_b, 152 | int width); 153 | void TransposeUVWx16_C(const uint8_t* src, 154 | int src_stride, 155 | uint8_t* dst_a, 156 | int dst_stride_a, 157 | uint8_t* dst_b, 158 | int dst_stride_b, 159 | int width); 160 | void TransposeUVWx8_SSE2(const uint8_t* src, 161 | int src_stride, 162 | uint8_t* dst_a, 163 | int dst_stride_a, 164 | uint8_t* dst_b, 165 | int dst_stride_b, 166 | int width); 167 | void TransposeUVWx8_NEON(const uint8_t* src, 168 | int src_stride, 169 | uint8_t* dst_a, 170 | int dst_stride_a, 171 | uint8_t* dst_b, 172 | int dst_stride_b, 173 | int width); 174 | void TransposeUVWx8_MMI(const uint8_t* src, 175 | int src_stride, 176 | uint8_t* dst_a, 177 | int dst_stride_a, 178 | uint8_t* dst_b, 179 | int dst_stride_b, 180 | int width); 181 | void TransposeUVWx16_MSA(const uint8_t* src, 182 | int src_stride, 183 | uint8_t* dst_a, 184 | int dst_stride_a, 185 | uint8_t* dst_b, 186 | int dst_stride_b, 187 | int width); 188 | 189 | void TransposeUVWx8_Any_SSE2(const uint8_t* src, 190 | int src_stride, 191 | uint8_t* dst_a, 192 | int dst_stride_a, 193 | uint8_t* dst_b, 194 | int dst_stride_b, 195 | int width); 196 | void TransposeUVWx8_Any_NEON(const uint8_t* src, 197 | int src_stride, 198 | uint8_t* dst_a, 199 | int dst_stride_a, 200 | uint8_t* dst_b, 201 | int dst_stride_b, 202 | int width); 203 | void TransposeUVWx8_Any_MMI(const uint8_t* src, 204 | int src_stride, 205 | uint8_t* dst_a, 206 | int dst_stride_a, 207 | uint8_t* dst_b, 208 | int dst_stride_b, 209 | int width); 210 | void TransposeUVWx16_Any_MSA(const uint8_t* src, 211 | int src_stride, 212 | uint8_t* dst_a, 213 | int dst_stride_a, 214 | uint8_t* dst_b, 215 | int dst_stride_b, 216 | int width); 217 | 218 | #ifdef __cplusplus 219 | } // extern "C" 220 | } // namespace libyuv 221 | #endif 222 | 223 | #endif // INCLUDE_LIBYUV_ROTATE_ROW_H_ 224 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/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_ 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_t* src, 32 | int src_stride, 33 | int src_width, 34 | int src_height, 35 | uint8_t* dst, 36 | int dst_stride, 37 | int dst_width, 38 | int dst_height, 39 | enum FilterMode filtering); 40 | 41 | LIBYUV_API 42 | void ScalePlane_16(const uint16_t* src, 43 | int src_stride, 44 | int src_width, 45 | int src_height, 46 | uint16_t* dst, 47 | int dst_stride, 48 | int dst_width, 49 | int dst_height, 50 | enum FilterMode filtering); 51 | 52 | // Scales a YUV 4:2:0 image from the src width and height to the 53 | // dst width and height. 54 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is 55 | // used. This produces basic (blocky) quality at the fastest speed. 56 | // If filtering is kFilterBilinear, interpolation is used to produce a better 57 | // quality image, at the expense of speed. 58 | // If filtering is kFilterBox, averaging is used to produce ever better 59 | // quality image, at further expense of speed. 60 | // Returns 0 if successful. 61 | 62 | LIBYUV_API 63 | int I420Scale(const uint8_t* src_y, 64 | int src_stride_y, 65 | const uint8_t* src_u, 66 | int src_stride_u, 67 | const uint8_t* src_v, 68 | int src_stride_v, 69 | int src_width, 70 | int src_height, 71 | uint8_t* dst_y, 72 | int dst_stride_y, 73 | uint8_t* dst_u, 74 | int dst_stride_u, 75 | uint8_t* dst_v, 76 | int dst_stride_v, 77 | int dst_width, 78 | int dst_height, 79 | enum FilterMode filtering); 80 | 81 | LIBYUV_API 82 | int I420Scale_16(const uint16_t* src_y, 83 | int src_stride_y, 84 | const uint16_t* src_u, 85 | int src_stride_u, 86 | const uint16_t* src_v, 87 | int src_stride_v, 88 | int src_width, 89 | int src_height, 90 | uint16_t* dst_y, 91 | int dst_stride_y, 92 | uint16_t* dst_u, 93 | int dst_stride_u, 94 | uint16_t* dst_v, 95 | int dst_stride_v, 96 | int dst_width, 97 | int dst_height, 98 | enum FilterMode filtering); 99 | 100 | // Scales a YUV 4:4:4 image from the src width and height to the 101 | // dst width and height. 102 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is 103 | // used. This produces basic (blocky) quality at the fastest speed. 104 | // If filtering is kFilterBilinear, interpolation is used to produce a better 105 | // quality image, at the expense of speed. 106 | // If filtering is kFilterBox, averaging is used to produce ever better 107 | // quality image, at further expense of speed. 108 | // Returns 0 if successful. 109 | 110 | LIBYUV_API 111 | int I444Scale(const uint8_t* src_y, 112 | int src_stride_y, 113 | const uint8_t* src_u, 114 | int src_stride_u, 115 | const uint8_t* src_v, 116 | int src_stride_v, 117 | int src_width, 118 | int src_height, 119 | uint8_t* dst_y, 120 | int dst_stride_y, 121 | uint8_t* dst_u, 122 | int dst_stride_u, 123 | uint8_t* dst_v, 124 | int dst_stride_v, 125 | int dst_width, 126 | int dst_height, 127 | enum FilterMode filtering); 128 | 129 | LIBYUV_API 130 | int I444Scale_16(const uint16_t* src_y, 131 | int src_stride_y, 132 | const uint16_t* src_u, 133 | int src_stride_u, 134 | const uint16_t* src_v, 135 | int src_stride_v, 136 | int src_width, 137 | int src_height, 138 | uint16_t* dst_y, 139 | int dst_stride_y, 140 | uint16_t* dst_u, 141 | int dst_stride_u, 142 | uint16_t* dst_v, 143 | int dst_stride_v, 144 | int dst_width, 145 | int dst_height, 146 | enum FilterMode filtering); 147 | 148 | #ifdef __cplusplus 149 | // Legacy API. Deprecated. 150 | LIBYUV_API 151 | int Scale(const uint8_t* src_y, 152 | const uint8_t* src_u, 153 | const uint8_t* src_v, 154 | int src_stride_y, 155 | int src_stride_u, 156 | int src_stride_v, 157 | int src_width, 158 | int src_height, 159 | uint8_t* dst_y, 160 | uint8_t* dst_u, 161 | uint8_t* dst_v, 162 | int dst_stride_y, 163 | int dst_stride_u, 164 | int dst_stride_v, 165 | int dst_width, 166 | int dst_height, 167 | LIBYUV_BOOL interpolate); 168 | 169 | // For testing, allow disabling of specialized scalers. 170 | LIBYUV_API 171 | void SetUseReferenceImpl(LIBYUV_BOOL use); 172 | #endif // __cplusplus 173 | 174 | #ifdef __cplusplus 175 | } // extern "C" 176 | } // namespace libyuv 177 | #endif 178 | 179 | #endif // INCLUDE_LIBYUV_SCALE_H_ 180 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/scale_argb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_SCALE_ARGB_H_ 12 | #define INCLUDE_LIBYUV_SCALE_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/scale.h" // For FilterMode 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | LIBYUV_API 23 | int ARGBScale(const uint8_t* src_argb, 24 | int src_stride_argb, 25 | int src_width, 26 | int src_height, 27 | uint8_t* dst_argb, 28 | int dst_stride_argb, 29 | int dst_width, 30 | int dst_height, 31 | enum FilterMode filtering); 32 | 33 | // Clipped rotate takes destination rectangle coordinates for clip values. 34 | LIBYUV_API 35 | int ARGBScaleClip(const uint8_t* src_argb, 36 | int src_stride_argb, 37 | int src_width, 38 | int src_height, 39 | uint8_t* dst_argb, 40 | int dst_stride_argb, 41 | int dst_width, 42 | int dst_height, 43 | int clip_x, 44 | int clip_y, 45 | int clip_width, 46 | int clip_height, 47 | enum FilterMode filtering); 48 | 49 | // Scale with YUV conversion to ARGB and clipping. 50 | LIBYUV_API 51 | int YUVToARGBScaleClip(const uint8_t* src_y, 52 | int src_stride_y, 53 | const uint8_t* src_u, 54 | int src_stride_u, 55 | const uint8_t* src_v, 56 | int src_stride_v, 57 | uint32_t src_fourcc, 58 | int src_width, 59 | int src_height, 60 | uint8_t* dst_argb, 61 | int dst_stride_argb, 62 | uint32_t dst_fourcc, 63 | int dst_width, 64 | int dst_height, 65 | int clip_x, 66 | int clip_y, 67 | int clip_width, 68 | int clip_height, 69 | enum FilterMode filtering); 70 | 71 | #ifdef __cplusplus 72 | } // extern "C" 73 | } // namespace libyuv 74 | #endif 75 | 76 | #endif // INCLUDE_LIBYUV_SCALE_ARGB_H_ 77 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_VERSION_H_ 12 | #define INCLUDE_LIBYUV_VERSION_H_ 13 | 14 | #define LIBYUV_VERSION 1733 15 | 16 | #endif // INCLUDE_LIBYUV_VERSION_H_ 17 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/include/libyuv/video_common.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 | // Common definitions for video, including fourcc and VideoFormat. 12 | 13 | #ifndef INCLUDE_LIBYUV_VIDEO_COMMON_H_ 14 | #define INCLUDE_LIBYUV_VIDEO_COMMON_H_ 15 | 16 | #include "libyuv/basic_types.h" 17 | 18 | #ifdef __cplusplus 19 | namespace libyuv { 20 | extern "C" { 21 | #endif 22 | 23 | ////////////////////////////////////////////////////////////////////////////// 24 | // Definition of FourCC codes 25 | ////////////////////////////////////////////////////////////////////////////// 26 | 27 | // Convert four characters to a FourCC code. 28 | // Needs to be a macro otherwise the OS X compiler complains when the kFormat* 29 | // constants are used in a switch. 30 | #ifdef __cplusplus 31 | #define FOURCC(a, b, c, d) \ 32 | ((static_cast(a)) | (static_cast(b) << 8) | \ 33 | (static_cast(c) << 16) | /* NOLINT */ \ 34 | (static_cast(d) << 24)) /* NOLINT */ 35 | #else 36 | #define FOURCC(a, b, c, d) \ 37 | (((uint32_t)(a)) | ((uint32_t)(b) << 8) | /* NOLINT */ \ 38 | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) /* NOLINT */ 39 | #endif 40 | 41 | // Some pages discussing FourCC codes: 42 | // http://www.fourcc.org/yuv.php 43 | // http://v4l2spec.bytesex.org/spec/book1.htm 44 | // http://developer.apple.com/quicktime/icefloe/dispatch020.html 45 | // http://msdn.microsoft.com/library/windows/desktop/dd206750.aspx#nv12 46 | // http://people.xiph.org/~xiphmont/containers/nut/nut4cc.txt 47 | 48 | // FourCC codes grouped according to implementation efficiency. 49 | // Primary formats should convert in 1 efficient step. 50 | // Secondary formats are converted in 2 steps. 51 | // Auxilliary formats call primary converters. 52 | enum FourCC { 53 | // 9 Primary YUV formats: 5 planar, 2 biplanar, 2 packed. 54 | FOURCC_I420 = FOURCC('I', '4', '2', '0'), 55 | FOURCC_I422 = FOURCC('I', '4', '2', '2'), 56 | FOURCC_I444 = FOURCC('I', '4', '4', '4'), 57 | FOURCC_I400 = FOURCC('I', '4', '0', '0'), 58 | FOURCC_NV21 = FOURCC('N', 'V', '2', '1'), 59 | FOURCC_NV12 = FOURCC('N', 'V', '1', '2'), 60 | FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'), 61 | FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'), 62 | FOURCC_H010 = FOURCC('H', '0', '1', '0'), // unofficial fourcc. 10 bit lsb 63 | 64 | // 1 Secondary YUV format: row biplanar. 65 | FOURCC_M420 = FOURCC('M', '4', '2', '0'), 66 | 67 | // 11 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp, 1 10 bpc 68 | FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'), 69 | FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'), 70 | FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'), 71 | FOURCC_AR30 = FOURCC('A', 'R', '3', '0'), // 10 bit per channel. 2101010. 72 | FOURCC_AB30 = FOURCC('A', 'B', '3', '0'), // ABGR version of 10 bit 73 | FOURCC_24BG = FOURCC('2', '4', 'B', 'G'), 74 | FOURCC_RAW = FOURCC('r', 'a', 'w', ' '), 75 | FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'), 76 | FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE. 77 | FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // argb1555 LE. 78 | FOURCC_R444 = FOURCC('R', '4', '4', '4'), // argb4444 LE. 79 | 80 | // 1 Primary Compressed YUV format. 81 | FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'), 82 | 83 | // 8 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias. 84 | FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'), 85 | FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'), 86 | FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'), 87 | FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'), // Linux version of I420. 88 | FOURCC_J420 = FOURCC('J', '4', '2', '0'), 89 | FOURCC_J400 = FOURCC('J', '4', '0', '0'), // unofficial fourcc 90 | FOURCC_H420 = FOURCC('H', '4', '2', '0'), // unofficial fourcc 91 | FOURCC_H422 = FOURCC('H', '4', '2', '2'), // unofficial fourcc 92 | 93 | // 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc. 94 | FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420. 95 | FOURCC_YU16 = FOURCC('Y', 'U', '1', '6'), // Alias for I422. 96 | FOURCC_YU24 = FOURCC('Y', 'U', '2', '4'), // Alias for I444. 97 | FOURCC_YUYV = FOURCC('Y', 'U', 'Y', 'V'), // Alias for YUY2. 98 | FOURCC_YUVS = FOURCC('y', 'u', 'v', 's'), // Alias for YUY2 on Mac. 99 | FOURCC_HDYC = FOURCC('H', 'D', 'Y', 'C'), // Alias for UYVY. 100 | FOURCC_2VUY = FOURCC('2', 'v', 'u', 'y'), // Alias for UYVY on Mac. 101 | FOURCC_JPEG = FOURCC('J', 'P', 'E', 'G'), // Alias for MJPG. 102 | FOURCC_DMB1 = FOURCC('d', 'm', 'b', '1'), // Alias for MJPG on Mac. 103 | FOURCC_BA81 = FOURCC('B', 'A', '8', '1'), // Alias for BGGR. 104 | FOURCC_RGB3 = FOURCC('R', 'G', 'B', '3'), // Alias for RAW. 105 | FOURCC_BGR3 = FOURCC('B', 'G', 'R', '3'), // Alias for 24BG. 106 | FOURCC_CM32 = FOURCC(0, 0, 0, 32), // Alias for BGRA kCMPixelFormat_32ARGB 107 | FOURCC_CM24 = FOURCC(0, 0, 0, 24), // Alias for RAW kCMPixelFormat_24RGB 108 | FOURCC_L555 = FOURCC('L', '5', '5', '5'), // Alias for RGBO. 109 | FOURCC_L565 = FOURCC('L', '5', '6', '5'), // Alias for RGBP. 110 | FOURCC_5551 = FOURCC('5', '5', '5', '1'), // Alias for RGBO. 111 | 112 | // deprecated formats. Not supported, but defined for backward compatibility. 113 | FOURCC_I411 = FOURCC('I', '4', '1', '1'), 114 | FOURCC_Q420 = FOURCC('Q', '4', '2', '0'), 115 | FOURCC_RGGB = FOURCC('R', 'G', 'G', 'B'), 116 | FOURCC_BGGR = FOURCC('B', 'G', 'G', 'R'), 117 | FOURCC_GRBG = FOURCC('G', 'R', 'B', 'G'), 118 | FOURCC_GBRG = FOURCC('G', 'B', 'R', 'G'), 119 | FOURCC_H264 = FOURCC('H', '2', '6', '4'), 120 | 121 | // Match any fourcc. 122 | FOURCC_ANY = -1, 123 | }; 124 | 125 | enum FourCCBpp { 126 | // Canonical fourcc codes used in our code. 127 | FOURCC_BPP_I420 = 12, 128 | FOURCC_BPP_I422 = 16, 129 | FOURCC_BPP_I444 = 24, 130 | FOURCC_BPP_I411 = 12, 131 | FOURCC_BPP_I400 = 8, 132 | FOURCC_BPP_NV21 = 12, 133 | FOURCC_BPP_NV12 = 12, 134 | FOURCC_BPP_YUY2 = 16, 135 | FOURCC_BPP_UYVY = 16, 136 | FOURCC_BPP_M420 = 12, 137 | FOURCC_BPP_Q420 = 12, 138 | FOURCC_BPP_ARGB = 32, 139 | FOURCC_BPP_BGRA = 32, 140 | FOURCC_BPP_ABGR = 32, 141 | FOURCC_BPP_RGBA = 32, 142 | FOURCC_BPP_AR30 = 32, 143 | FOURCC_BPP_AB30 = 32, 144 | FOURCC_BPP_24BG = 24, 145 | FOURCC_BPP_RAW = 24, 146 | FOURCC_BPP_RGBP = 16, 147 | FOURCC_BPP_RGBO = 16, 148 | FOURCC_BPP_R444 = 16, 149 | FOURCC_BPP_RGGB = 8, 150 | FOURCC_BPP_BGGR = 8, 151 | FOURCC_BPP_GRBG = 8, 152 | FOURCC_BPP_GBRG = 8, 153 | FOURCC_BPP_YV12 = 12, 154 | FOURCC_BPP_YV16 = 16, 155 | FOURCC_BPP_YV24 = 24, 156 | FOURCC_BPP_YU12 = 12, 157 | FOURCC_BPP_J420 = 12, 158 | FOURCC_BPP_J400 = 8, 159 | FOURCC_BPP_H420 = 12, 160 | FOURCC_BPP_H422 = 16, 161 | FOURCC_BPP_H010 = 24, 162 | FOURCC_BPP_MJPG = 0, // 0 means unknown. 163 | FOURCC_BPP_H264 = 0, 164 | FOURCC_BPP_IYUV = 12, 165 | FOURCC_BPP_YU16 = 16, 166 | FOURCC_BPP_YU24 = 24, 167 | FOURCC_BPP_YUYV = 16, 168 | FOURCC_BPP_YUVS = 16, 169 | FOURCC_BPP_HDYC = 16, 170 | FOURCC_BPP_2VUY = 16, 171 | FOURCC_BPP_JPEG = 1, 172 | FOURCC_BPP_DMB1 = 1, 173 | FOURCC_BPP_BA81 = 8, 174 | FOURCC_BPP_RGB3 = 24, 175 | FOURCC_BPP_BGR3 = 24, 176 | FOURCC_BPP_CM32 = 32, 177 | FOURCC_BPP_CM24 = 24, 178 | 179 | // Match any fourcc. 180 | FOURCC_BPP_ANY = 0, // 0 means unknown. 181 | }; 182 | 183 | // Converts fourcc aliases into canonical ones. 184 | LIBYUV_API uint32_t CanonicalFourCC(uint32_t fourcc); 185 | 186 | #ifdef __cplusplus 187 | } // extern "C" 188 | } // namespace libyuv 189 | #endif 190 | 191 | #endif // INCLUDE_LIBYUV_VIDEO_COMMON_H_ 192 | -------------------------------------------------------------------------------- /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/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | -------------------------------------------------------------------------------- /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/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/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 | My Application 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.31' 5 | repositories { 6 | google() 7 | jcenter() 8 | 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.2.0' 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | 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.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharryChoo/LibyuvSample/229ccca1cb62a976b06f025f81d6c631dd207deb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jul 25 22:05:20 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-4.10-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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------