├── .gitignore ├── .idea ├── encodings.xml ├── gradle.xml ├── kotlinc.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── hzl │ │ └── libyuvdemo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── hzl │ │ │ └── libyuvdemo │ │ │ ├── MainActivity.java │ │ │ ├── MainApplication.java │ │ │ ├── contacts │ │ │ └── Contacts.java │ │ │ ├── listener │ │ │ ├── CameraPictureListener.java │ │ │ ├── CameraSurfaceListener.java │ │ │ └── CameraYUVDataListener.java │ │ │ ├── manager │ │ │ ├── CameraSurfaceManager.java │ │ │ └── CameraSurfaceView.java │ │ │ └── util │ │ │ ├── CameraUtil.java │ │ │ ├── PermissionsUtils.java │ │ │ └── SPUtil.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── layout_camera.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 │ │ ├── camera_change.png │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ ├── image_close.png │ │ ├── image_focus.png │ │ └── take_picture.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── hzl │ └── libyuvdemo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libyuv ├── .gitignore ├── CMakeLists.txt ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── libyuv │ │ └── util │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── cpp │ │ ├── YuvJni.cpp │ │ └── libyuv │ │ │ ├── .clang-format │ │ │ ├── .gitignore │ │ │ ├── .gn │ │ │ ├── AUTHORS │ │ │ ├── Android.mk │ │ │ ├── BUILD.gn │ │ │ ├── CM_linux_packages.cmake │ │ │ ├── CMakeLists.txt │ │ │ ├── DEPS │ │ │ ├── LICENSE │ │ │ ├── LICENSE_THIRD_PARTY │ │ │ ├── OWNERS │ │ │ ├── PATENTS │ │ │ ├── PRESUBMIT.py │ │ │ ├── README.chromium │ │ │ ├── README.md │ │ │ ├── all.gyp │ │ │ ├── build_overrides │ │ │ ├── build.gni │ │ │ └── gtest.gni │ │ │ ├── cleanup_links.py │ │ │ ├── codereview.settings │ │ │ ├── docs │ │ │ ├── deprecated_builds.md │ │ │ ├── environment_variables.md │ │ │ ├── filtering.md │ │ │ ├── formats.md │ │ │ ├── getting_started.md │ │ │ └── rotation.md │ │ │ ├── download_vs_toolchain.py │ │ │ ├── gyp_libyuv │ │ │ ├── gyp_libyuv.py │ │ │ ├── include │ │ │ ├── libyuv.h │ │ │ └── libyuv │ │ │ │ ├── basic_types.h │ │ │ │ ├── compare.h │ │ │ │ ├── compare_row.h │ │ │ │ ├── convert.h │ │ │ │ ├── convert_argb.h │ │ │ │ ├── convert_from.h │ │ │ │ ├── convert_from_argb.h │ │ │ │ ├── cpu_id.h │ │ │ │ ├── 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 │ │ │ ├── infra │ │ │ └── config │ │ │ │ ├── OWNERS │ │ │ │ ├── README.md │ │ │ │ └── cq.cfg │ │ │ ├── libyuv.gni │ │ │ ├── libyuv.gyp │ │ │ ├── libyuv.gypi │ │ │ ├── libyuv_nacl.gyp │ │ │ ├── libyuv_test.gyp │ │ │ ├── linux.mk │ │ │ ├── public.mk │ │ │ ├── pylintrc │ │ │ ├── source │ │ │ ├── compare.cc │ │ │ ├── compare_common.cc │ │ │ ├── compare_gcc.cc │ │ │ ├── compare_neon.cc │ │ │ ├── compare_neon64.cc │ │ │ ├── compare_win.cc │ │ │ ├── convert.cc │ │ │ ├── convert_argb.cc │ │ │ ├── convert_from.cc │ │ │ ├── convert_from_argb.cc │ │ │ ├── convert_jpeg.cc │ │ │ ├── convert_to_argb.cc │ │ │ ├── convert_to_i420.cc │ │ │ ├── cpu_id.cc │ │ │ ├── mjpeg_decoder.cc │ │ │ ├── mjpeg_validate.cc │ │ │ ├── planar_functions.cc │ │ │ ├── rotate.cc │ │ │ ├── rotate_any.cc │ │ │ ├── rotate_argb.cc │ │ │ ├── rotate_common.cc │ │ │ ├── rotate_dspr2.cc │ │ │ ├── rotate_gcc.cc │ │ │ ├── rotate_msa.cc │ │ │ ├── rotate_neon.cc │ │ │ ├── rotate_neon64.cc │ │ │ ├── rotate_win.cc │ │ │ ├── row_any.cc │ │ │ ├── row_common.cc │ │ │ ├── row_dspr2.cc │ │ │ ├── row_gcc.cc │ │ │ ├── row_msa.cc │ │ │ ├── row_neon.cc │ │ │ ├── row_neon64.cc │ │ │ ├── row_win.cc │ │ │ ├── scale.cc │ │ │ ├── scale_any.cc │ │ │ ├── scale_argb.cc │ │ │ ├── scale_common.cc │ │ │ ├── scale_dspr2.cc │ │ │ ├── scale_gcc.cc │ │ │ ├── scale_msa.cc │ │ │ ├── scale_neon.cc │ │ │ ├── scale_neon64.cc │ │ │ ├── scale_win.cc │ │ │ └── video_common.cc │ │ │ ├── tools_libyuv │ │ │ ├── OWNERS │ │ │ ├── autoroller │ │ │ │ ├── roll_deps.py │ │ │ │ └── unittests │ │ │ │ │ ├── roll_deps_test.py │ │ │ │ │ └── testdata │ │ │ │ │ ├── DEPS │ │ │ │ │ ├── DEPS.chromium.new │ │ │ │ │ └── DEPS.chromium.old │ │ │ ├── get_landmines.py │ │ │ ├── msan │ │ │ │ ├── OWNERS │ │ │ │ └── blacklist.txt │ │ │ ├── ubsan │ │ │ │ ├── OWNERS │ │ │ │ ├── blacklist.txt │ │ │ │ └── vptr_blacklist.txt │ │ │ └── valgrind │ │ │ │ ├── libyuv_tests.bat │ │ │ │ ├── libyuv_tests.py │ │ │ │ ├── libyuv_tests.sh │ │ │ │ └── memcheck │ │ │ │ ├── OWNERS │ │ │ │ ├── PRESUBMIT.py │ │ │ │ ├── suppressions.txt │ │ │ │ ├── suppressions_mac.txt │ │ │ │ └── suppressions_win32.txt │ │ │ ├── unit_test │ │ │ ├── basictypes_test.cc │ │ │ ├── color_test.cc │ │ │ ├── compare_test.cc │ │ │ ├── convert_test.cc │ │ │ ├── cpu_test.cc │ │ │ ├── cpu_thread_test.cc │ │ │ ├── math_test.cc │ │ │ ├── planar_test.cc │ │ │ ├── rotate_argb_test.cc │ │ │ ├── rotate_test.cc │ │ │ ├── scale_argb_test.cc │ │ │ ├── scale_test.cc │ │ │ ├── testdata │ │ │ │ ├── arm_v7.txt │ │ │ │ ├── juno.txt │ │ │ │ └── tegra3.txt │ │ │ ├── unit_test.cc │ │ │ ├── unit_test.h │ │ │ └── video_common_test.cc │ │ │ ├── util │ │ │ ├── Makefile │ │ │ ├── compare.cc │ │ │ ├── cpuid.c │ │ │ ├── psnr.cc │ │ │ ├── psnr.h │ │ │ ├── psnr_main.cc │ │ │ ├── ssim.cc │ │ │ ├── ssim.h │ │ │ └── yuvconvert.cc │ │ │ ├── winarm.mk │ │ │ └── yuv_android.sh │ ├── java │ │ └── com │ │ │ └── libyuv │ │ │ └── util │ │ │ └── YuvUtil.java │ └── res │ │ ├── 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 │ └── test │ └── java │ └── com │ └── libyuv │ └── util │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | .idea 11 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LibyuvDemo 2 | 使用libyuv对yuv数据进行缩放,旋转,镜像,裁剪等操作 3 | 4 | 简书地址:http://www.jianshu.com/p/bd0feaf4c0f9 5 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "28.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.hzl.libyuvdemo" 9 | minSdkVersion 21 10 | targetSdkVersion 28 11 | } 12 | 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation project(':libyuv') 24 | implementation 'com.android.support:support-annotations:28.0.0' 25 | implementation 'com.android.support:support-compat:28.0.0' 26 | } 27 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/hzl/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/hzl/libyuvdemo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.hzl.libyuvdemo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.hzl.libyuvdemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/hzl/libyuvdemo/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.hzl.libyuvdemo; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | 6 | import java.io.File; 7 | import java.io.FileNotFoundException; 8 | import java.io.FileOutputStream; 9 | import java.io.IOException; 10 | import java.io.PrintStream; 11 | import java.text.SimpleDateFormat; 12 | import java.util.Date; 13 | import java.util.Locale; 14 | 15 | /** 16 | * 作者:请叫我百米冲刺 on 2017/11/20 上午10:53 17 | * 邮箱:mail@hezhilin.cc 18 | */ 19 | 20 | public class MainApplication extends Application { 21 | 22 | private static MainApplication INSTANCE; 23 | 24 | private static Activity CURRENT_ACTIVITY; 25 | 26 | public static MainApplication getInstance() { 27 | return INSTANCE; 28 | } 29 | 30 | public static void setCurrentActivity(Activity activity) { 31 | CURRENT_ACTIVITY = activity; 32 | } 33 | 34 | public static Activity getCurrentActivity() { 35 | return CURRENT_ACTIVITY; 36 | } 37 | 38 | @Override 39 | public void onCreate() { 40 | super.onCreate(); 41 | INSTANCE = this; 42 | initExceptionHandler(); 43 | } 44 | 45 | 46 | /** 47 | * 错误进行崩溃处理 48 | **/ 49 | private void initExceptionHandler() { 50 | final Thread.UncaughtExceptionHandler dueh = Thread.getDefaultUncaughtExceptionHandler(); 51 | /* 处理未捕捉异常 */ 52 | Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { 53 | 54 | @Override 55 | public void uncaughtException(Thread thread, Throwable ex) { 56 | FileOutputStream fos = null; 57 | PrintStream ps = null; 58 | try { 59 | File path = INSTANCE.getExternalCacheDir(); 60 | if (!path.isDirectory()) { 61 | path.mkdirs(); 62 | } 63 | fos = new FileOutputStream(path.getAbsolutePath() + File.separator + "crash_log.txt", true); 64 | ps = new PrintStream(fos); 65 | ps.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINESE).format(new Date(System.currentTimeMillis()))); 66 | ex.printStackTrace(ps); 67 | } catch (FileNotFoundException e) { 68 | } finally { 69 | if (fos != null) { 70 | try { 71 | fos.close(); 72 | } catch (IOException e) { 73 | } 74 | } 75 | if (ps != null) { 76 | ps.close(); 77 | } 78 | } 79 | dueh.uncaughtException(thread, ex); 80 | } 81 | }); 82 | } 83 | } -------------------------------------------------------------------------------- /app/src/main/java/com/hzl/libyuvdemo/contacts/Contacts.java: -------------------------------------------------------------------------------- 1 | package com.hzl.libyuvdemo.contacts; 2 | 3 | /** 4 | * 作者:请叫我百米冲刺 on 2017/11/20 下午3:05 5 | * 邮箱:mail@hezhilin.cc 6 | */ 7 | 8 | public class Contacts { 9 | 10 | public static final String CAMERA_WIDTH = "cameraWidth"; 11 | 12 | public static final String CAMERA_HEIGHT = "cameraHeight"; 13 | 14 | public static final String CAMERA_Morientation = "cameraMorientation"; 15 | 16 | public static final String SCALE_WIDTH = "scaleWidth"; 17 | 18 | public static final String SCALE_HEIGHT = "scaleHeight"; 19 | 20 | public static final String CROP_START_X = "cropStartX"; 21 | 22 | public static final String CROP_START_Y = "cropStartY"; 23 | 24 | public static final String CROP_WIDTH = "cropWidth"; 25 | 26 | public static final String CROP_HEIGHT = "cropHeight"; 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/hzl/libyuvdemo/listener/CameraPictureListener.java: -------------------------------------------------------------------------------- 1 | package com.hzl.libyuvdemo.listener; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | /** 6 | * 作者:请叫我百米冲刺 on 2017/11/13 上午8:57 7 | * 邮箱:mail@hezhilin.cc 8 | */ 9 | 10 | public interface CameraPictureListener { 11 | 12 | void onPictureBitmap(Bitmap btmp); 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/hzl/libyuvdemo/listener/CameraSurfaceListener.java: -------------------------------------------------------------------------------- 1 | package com.hzl.libyuvdemo.listener; 2 | 3 | 4 | /** 5 | * 作者:请叫我百米冲刺 on 2017/11/7 上午10:38 6 | * 邮箱:mail@hezhilin.cc 7 | */ 8 | public interface CameraSurfaceListener { 9 | 10 | void startAutoFocus(float x, float y); 11 | 12 | void openCamera(); 13 | 14 | void releaseCamera(); 15 | 16 | int changeCamera(); 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/hzl/libyuvdemo/listener/CameraYUVDataListener.java: -------------------------------------------------------------------------------- 1 | package com.hzl.libyuvdemo.listener; 2 | 3 | /** 4 | * 作者:请叫我百米冲刺 on 2017/11/7 上午11:05 5 | * 邮箱:mail@hezhilin.cc 6 | */ 7 | 8 | public interface CameraYUVDataListener { 9 | 10 | void onCallback(byte[] data); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/hzl/libyuvdemo/util/SPUtil.java: -------------------------------------------------------------------------------- 1 | package com.hzl.libyuvdemo.util; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | import com.hzl.libyuvdemo.MainApplication; 7 | 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.lang.reflect.Method; 10 | import java.util.Map; 11 | 12 | /** 13 | * 作者:请叫我百米冲刺 on 2017/11/20 下午3:03 14 | * 邮箱:mail@hezhilin.cc 15 | */ 16 | 17 | public class SPUtil { 18 | /** 19 | * 保存在手机里面的文件名 20 | */ 21 | public static final String FILE_NAME = "share_data"; 22 | 23 | 24 | /** 25 | * 保存数据的方法,我们需要拿到保存数据的具体类型,然后根据类型调用不同的保存方法 26 | */ 27 | public static void put(String key, Object object) { 28 | put(MainApplication.getInstance(), FILE_NAME, key, object); 29 | } 30 | 31 | private static void put(Context context, String spName, String key, Object object) { 32 | SharedPreferences sp = context.getSharedPreferences(spName, 33 | Context.MODE_PRIVATE); 34 | SharedPreferences.Editor editor = sp.edit(); 35 | 36 | if (object instanceof String) { 37 | editor.putString(key, (String) object); 38 | } else if (object instanceof Integer) { 39 | editor.putInt(key, (Integer) object); 40 | } else if (object instanceof Boolean) { 41 | editor.putBoolean(key, (Boolean) object); 42 | } else if (object instanceof Float) { 43 | editor.putFloat(key, (Float) object); 44 | } else if (object instanceof Long) { 45 | editor.putLong(key, (Long) object); 46 | } else { 47 | editor.putString(key, object.toString()); 48 | } 49 | 50 | SharedPreferencesCompat.apply(editor); 51 | } 52 | 53 | /** 54 | * 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值 55 | */ 56 | public static Object get(String key, Object defaultObject) { 57 | return get(MainApplication.getInstance(), FILE_NAME, key, defaultObject); 58 | } 59 | 60 | private static Object get(Context context, String spName, String key, Object defaultObject) { 61 | SharedPreferences sp = context.getSharedPreferences(spName, 62 | Context.MODE_PRIVATE); 63 | 64 | if (defaultObject instanceof String) { 65 | return sp.getString(key, (String) defaultObject); 66 | } else if (defaultObject instanceof Integer) { 67 | return sp.getInt(key, (Integer) defaultObject); 68 | } else if (defaultObject instanceof Boolean) { 69 | return sp.getBoolean(key, (Boolean) defaultObject); 70 | } else if (defaultObject instanceof Float) { 71 | return sp.getFloat(key, (Float) defaultObject); 72 | } else if (defaultObject instanceof Long) { 73 | return sp.getLong(key, (Long) defaultObject); 74 | } 75 | 76 | return null; 77 | } 78 | 79 | /** 80 | * 移除某个key值已经对应的值 81 | */ 82 | public static void remove(String key) { 83 | remove(MainApplication.getInstance(), FILE_NAME, key); 84 | } 85 | 86 | private static void remove(Context context, String spName, String key) { 87 | SharedPreferences sp = context.getSharedPreferences(spName, 88 | Context.MODE_PRIVATE); 89 | SharedPreferences.Editor editor = sp.edit(); 90 | editor.remove(key); 91 | SharedPreferencesCompat.apply(editor); 92 | } 93 | 94 | /** 95 | * 清除所有数据 96 | */ 97 | public static void clear() { 98 | clear(MainApplication.getInstance(), FILE_NAME); 99 | } 100 | 101 | private static void clear(Context context, String spName) { 102 | SharedPreferences sp = context.getSharedPreferences(spName, Context.MODE_PRIVATE); 103 | SharedPreferences.Editor editor = sp.edit(); 104 | editor.clear(); 105 | SharedPreferencesCompat.apply(editor); 106 | } 107 | 108 | /** 109 | * 查询某个key是否已经存在 110 | */ 111 | public static boolean contains(String key) { 112 | return contains(MainApplication.getInstance(), FILE_NAME, key); 113 | } 114 | 115 | private static boolean contains(Context context, String spName, String key) { 116 | SharedPreferences sp = context.getSharedPreferences(spName, Context.MODE_PRIVATE); 117 | return sp.contains(key); 118 | } 119 | 120 | /** 121 | * 返回所有的键值对 122 | */ 123 | public static Map getAll() { 124 | return getAll(MainApplication.getInstance(), FILE_NAME); 125 | } 126 | 127 | private static Map getAll(Context context, String spName) { 128 | SharedPreferences sp = context.getSharedPreferences(spName, 129 | Context.MODE_PRIVATE); 130 | return sp.getAll(); 131 | } 132 | 133 | /** 134 | * 创建一个解决SharedPreferencesCompat.apply方法的一个兼容类 135 | */ 136 | private static class SharedPreferencesCompat { 137 | private static final Method sApplyMethod = findApplyMethod(); 138 | 139 | /** 140 | * 反射查找apply的方法 141 | */ 142 | @SuppressWarnings({"unchecked", "rawtypes"}) 143 | private static Method findApplyMethod() { 144 | try { 145 | Class clz = SharedPreferences.Editor.class; 146 | return clz.getMethod("apply"); 147 | } catch (NoSuchMethodException e) { 148 | } 149 | 150 | return null; 151 | } 152 | 153 | /** 154 | * 如果找到则使用apply执行,否则使用commit 155 | */ 156 | public static void apply(SharedPreferences.Editor editor) { 157 | try { 158 | if (sApplyMethod != null) { 159 | sApplyMethod.invoke(editor); 160 | return; 161 | } 162 | } catch (IllegalArgumentException e) { 163 | } catch (IllegalAccessException e) { 164 | } catch (InvocationTargetException e) { 165 | } 166 | editor.commit(); 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_camera.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/camera_change.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-xxhdpi/camera_change.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/image_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-xxhdpi/image_close.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/image_focus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-xxhdpi/image_focus.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/take_picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-xxhdpi/take_picture.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LibyuvDemo 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/hzl/libyuvdemo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.hzl.libyuvdemo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.2' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Nov 20 10:46:10 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 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 Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /libyuv/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /libyuv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | include_directories(src/main/cpp/libyuv/include) 3 | add_subdirectory(src/main/cpp/libyuv ./build) 4 | aux_source_directory(src/main/cpp SRC_FILE) 5 | add_library(yuvutil SHARED ${SRC_FILE}) 6 | find_library(log-lib log) 7 | target_link_libraries(yuvutil ${log-lib} yuv) -------------------------------------------------------------------------------- /libyuv/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "28.0.2" 6 | defaultConfig { 7 | minSdkVersion 21 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | externalNativeBuild { 12 | cmake { 13 | cppFlags "" 14 | } 15 | } 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | externalNativeBuild { 24 | cmake { 25 | path 'CMakeLists.txt' 26 | } 27 | } 28 | } 29 | 30 | dependencies { 31 | implementation fileTree(dir: 'libs', include: ['*.jar']) 32 | implementation 'com.android.support:appcompat-v7:28.0.0' 33 | } 34 | -------------------------------------------------------------------------------- /libyuv/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/hzl/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /libyuv/src/androidTest/java/com/libyuv/util/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.libyuv.util; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.libyuv.util", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /libyuv/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/.clang-format: -------------------------------------------------------------------------------- 1 | # Defines the Chromium style for automatic reformatting. 2 | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html 3 | BasedOnStyle: Chromium 4 | --- 5 | Language: Java 6 | BasedOnStyle: Google 7 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .landmines 3 | pin-log.txt 4 | /base 5 | /build 6 | /buildtools 7 | /google_apis 8 | /links 9 | /links.db 10 | /ios 11 | /mojo 12 | /native_client 13 | /net 14 | /out 15 | /sde-avx-sse-transition-out.txt 16 | /testing 17 | /third_party 18 | /tools 19 | 20 | # Files generated by CMake build 21 | cmake_install.cmake 22 | CMakeCache.txt 23 | CMakeFiles/ 24 | yuvconvert 25 | libgtest.a 26 | libyuv.a 27 | libyuv_unittest 28 | 29 | # Files generated by winarm.mk build 30 | libyuv_arm.lib 31 | source/*.o 32 | 33 | # Files generated by perf 34 | perf.data 35 | perf.data.old 36 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | # The location of the build configuration file. 10 | buildconfig = "//build/config/BUILDCONFIG.gn" 11 | 12 | # The secondary source root is a parallel directory tree where 13 | # GN build files are placed when they can not be placed directly 14 | # in the source tree, e.g. for third party source trees. 15 | secondary_source = "//build/secondary/" 16 | 17 | # These are the targets to check headers for by default. The files in targets 18 | # matching these patterns (see "gn help label_pattern" for format) will have 19 | # their includes checked for proper dependencies when you run either 20 | # "gn check" or "gn gen --check". 21 | check_targets = [ "//libyuv/*" ] 22 | 23 | # These are the list of GN files that run exec_script. This whitelist exists 24 | # to force additional review for new uses of exec_script, which is strongly 25 | # discouraged except for gypi_to_gn calls. 26 | exec_script_whitelist = [ 27 | "//build/config/android/BUILD.gn", 28 | "//build/config/android/config.gni", 29 | "//build/config/android/internal_rules.gni", 30 | "//build/config/android/rules.gni", 31 | "//build/config/BUILD.gn", 32 | "//build/config/compiler/BUILD.gn", 33 | "//build/config/gcc/gcc_version.gni", 34 | "//build/config/ios/ios_sdk.gni", 35 | "//build/config/linux/BUILD.gn", 36 | "//build/config/linux/pkg_config.gni", 37 | "//build/config/mac/mac_sdk.gni", 38 | "//build/config/posix/BUILD.gn", 39 | "//build/config/sysroot.gni", 40 | "//build/config/win/BUILD.gn", 41 | "//build/config/win/visual_studio_version.gni", 42 | "//build/gn_helpers.py", 43 | "//build/gypi_to_gn.py", 44 | "//build/toolchain/concurrent_links.gni", 45 | "//build/toolchain/gcc_toolchain.gni", 46 | "//build/toolchain/mac/BUILD.gn", 47 | "//build/toolchain/win/BUILD.gn", 48 | ] 49 | 50 | default_args = { 51 | mac_sdk_min = "10.11" 52 | } 53 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file like so: 2 | # Name or Organization 3 | 4 | Google Inc. 5 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/Android.mk: -------------------------------------------------------------------------------- 1 | # This is the Android makefile for libyuv for NDK. 2 | LOCAL_PATH:= $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_CPP_EXTENSION := .cc 7 | 8 | LOCAL_SRC_FILES := \ 9 | source/compare.cc \ 10 | source/compare_common.cc \ 11 | source/compare_gcc.cc \ 12 | source/compare_neon.cc \ 13 | source/compare_neon64.cc \ 14 | source/convert.cc \ 15 | source/convert_argb.cc \ 16 | source/convert_from.cc \ 17 | source/convert_from_argb.cc \ 18 | source/convert_to_argb.cc \ 19 | source/convert_to_i420.cc \ 20 | source/cpu_id.cc \ 21 | source/planar_functions.cc \ 22 | source/rotate.cc \ 23 | source/rotate_any.cc \ 24 | source/rotate_argb.cc \ 25 | source/rotate_common.cc \ 26 | source/rotate_dspr2.cc \ 27 | source/rotate_gcc.cc \ 28 | source/rotate_msa.cc \ 29 | source/rotate_neon.cc \ 30 | source/rotate_neon64.cc \ 31 | source/row_any.cc \ 32 | source/row_common.cc \ 33 | source/row_dspr2.cc \ 34 | source/row_gcc.cc \ 35 | source/row_msa.cc \ 36 | source/row_neon.cc \ 37 | source/row_neon64.cc \ 38 | source/scale.cc \ 39 | source/scale_any.cc \ 40 | source/scale_argb.cc \ 41 | source/scale_common.cc \ 42 | source/scale_dspr2.cc \ 43 | source/scale_gcc.cc \ 44 | source/scale_msa.cc \ 45 | source/scale_neon.cc \ 46 | source/scale_neon64.cc \ 47 | source/video_common.cc 48 | 49 | common_CFLAGS := -Wall -fexceptions 50 | ifneq ($(LIBYUV_DISABLE_JPEG), "yes") 51 | LOCAL_SRC_FILES += \ 52 | source/convert_jpeg.cc \ 53 | source/mjpeg_decoder.cc \ 54 | source/mjpeg_validate.cc 55 | common_CFLAGS += -DHAVE_JPEG 56 | LOCAL_SHARED_LIBRARIES := libjpeg 57 | endif 58 | 59 | LOCAL_CFLAGS += $(common_CFLAGS) 60 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include 61 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/include 62 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include 63 | 64 | LOCAL_MODULE := libyuv_static 65 | LOCAL_MODULE_TAGS := optional 66 | 67 | include $(BUILD_STATIC_LIBRARY) 68 | 69 | include $(CLEAR_VARS) 70 | 71 | LOCAL_WHOLE_STATIC_LIBRARIES := libyuv_static 72 | LOCAL_MODULE := libyuv 73 | ifneq ($(LIBYUV_DISABLE_JPEG), "yes") 74 | LOCAL_SHARED_LIBRARIES := libjpeg 75 | endif 76 | 77 | include $(BUILD_SHARED_LIBRARY) 78 | 79 | include $(CLEAR_VARS) 80 | LOCAL_STATIC_LIBRARIES := libyuv_static 81 | LOCAL_SHARED_LIBRARIES := libjpeg 82 | LOCAL_MODULE_TAGS := tests 83 | LOCAL_CPP_EXTENSION := .cc 84 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/include 85 | LOCAL_SRC_FILES := \ 86 | unit_test/unit_test.cc \ 87 | unit_test/basictypes_test.cc \ 88 | unit_test/color_test.cc \ 89 | unit_test/compare_test.cc \ 90 | unit_test/convert_test.cc \ 91 | unit_test/cpu_test.cc \ 92 | unit_test/cpu_thread_test.cc \ 93 | unit_test/math_test.cc \ 94 | unit_test/planar_test.cc \ 95 | unit_test/rotate_argb_test.cc \ 96 | unit_test/rotate_test.cc \ 97 | unit_test/scale_argb_test.cc \ 98 | unit_test/scale_test.cc \ 99 | unit_test/video_common_test.cc 100 | 101 | LOCAL_MODULE := libyuv_unittest 102 | include $(BUILD_NATIVE_TEST) 103 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/CM_linux_packages.cmake: -------------------------------------------------------------------------------- 1 | # determine the version number from the #define in libyuv/version.h 2 | EXECUTE_PROCESS ( 3 | COMMAND grep --perl-regex --only-matching "(?<=LIBYUV_VERSION )[0-9]+" include/libyuv/version.h 4 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 5 | OUTPUT_VARIABLE YUV_VERSION_NUMBER 6 | OUTPUT_STRIP_TRAILING_WHITESPACE ) 7 | SET ( YUV_VER_MAJOR 0 ) 8 | SET ( YUV_VER_MINOR 0 ) 9 | SET ( YUV_VER_PATCH ${YUV_VERSION_NUMBER} ) 10 | SET ( YUV_VERSION ${YUV_VER_MAJOR}.${YUV_VER_MINOR}.${YUV_VER_PATCH} ) 11 | MESSAGE ( "Building ver.: ${YUV_VERSION}" ) 12 | 13 | # is this a 32-bit or 64-bit build? 14 | IF ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) 15 | SET ( YUV_BIT_SIZE 64 ) 16 | ELSEIF ( CMAKE_SIZEOF_VOID_P EQUAL 4 ) 17 | SET ( YUV_BIT_SIZE 32 ) 18 | ELSE () 19 | MESSAGE ( FATAL_ERROR "CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}" ) 20 | ENDIF () 21 | 22 | # detect if this is a ARM build 23 | STRING (FIND "${CMAKE_CXX_COMPILER}" "arm-linux-gnueabihf-g++" pos) 24 | IF ( ${pos} EQUAL -1 ) 25 | SET ( YUV_CROSS_COMPILE_FOR_ARM7 FALSE ) 26 | ELSE () 27 | MESSAGE ( "Cross compiling for ARM7" ) 28 | SET ( YUV_CROSS_COMPILE_FOR_ARM7 TRUE ) 29 | ENDIF () 30 | STRING (FIND "${CMAKE_SYSTEM_PROCESSOR}" "arm" pos) 31 | IF ( ${pos} EQUAL -1 ) 32 | SET ( YUV_COMPILE_FOR_ARM7 FALSE ) 33 | ELSE () 34 | MESSAGE ( "Compiling for ARM" ) 35 | SET ( YUV_COMPILE_FOR_ARM7 TRUE ) 36 | ENDIF () 37 | 38 | # setup the sytem name, such as "x86-32", "amd-64", and "arm-32 39 | IF ( ${YUV_CROSS_COMPILE_FOR_ARM7} OR ${YUV_COMPILE_FOR_ARM7} ) 40 | SET ( YUV_SYSTEM_NAME "armhf-${YUV_BIT_SIZE}" ) 41 | ELSE () 42 | IF ( YUV_BIT_SIZE EQUAL 32 ) 43 | SET ( YUV_SYSTEM_NAME "x86-${YUV_BIT_SIZE}" ) 44 | ELSE () 45 | SET ( YUV_SYSTEM_NAME "amd-${YUV_BIT_SIZE}" ) 46 | ENDIF () 47 | ENDIF () 48 | MESSAGE ( "Packaging for: ${YUV_SYSTEM_NAME}" ) 49 | 50 | # define all the variables needed by CPack to create .deb and .rpm packages 51 | SET ( CPACK_PACKAGE_VENDOR "Frank Barchard" ) 52 | SET ( CPACK_PACKAGE_CONTACT "fbarchard@chromium.org" ) 53 | SET ( CPACK_PACKAGE_VERSION ${YUV_VERSION} ) 54 | SET ( CPACK_PACKAGE_VERSION_MAJOR ${YUV_VER_MAJOR} ) 55 | SET ( CPACK_PACKAGE_VERSION_MINOR ${YUV_VER_MINOR} ) 56 | SET ( CPACK_PACKAGE_VERSION_PATCH ${YUV_VER_PATCH} ) 57 | SET ( CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE ) 58 | SET ( CPACK_SYSTEM_NAME "linux-${YUV_SYSTEM_NAME}" ) 59 | SET ( CPACK_PACKAGE_NAME "libyuv" ) 60 | SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "YUV library" ) 61 | SET ( CPACK_PACKAGE_DESCRIPTION "YUV library and YUV conversion tool" ) 62 | SET ( CPACK_DEBIAN_PACKAGE_SECTION "other" ) 63 | SET ( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" ) 64 | SET ( CPACK_DEBIAN_PACKAGE_MAINTAINER "Frank Barchard " ) 65 | SET ( CPACK_GENERATOR "DEB;RPM" ) 66 | 67 | # create the .deb and .rpm files (you'll need build-essential and rpm tools) 68 | INCLUDE( CPack ) 69 | 70 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMakeLists for libyuv 2 | # Originally created for "roxlu build system" to compile libyuv on windows 3 | # Run with -DTEST=ON to build unit tests 4 | 5 | PROJECT ( YUV C CXX ) # "C" is required even for C++ projects 6 | CMAKE_MINIMUM_REQUIRED( VERSION 2.8 ) 7 | OPTION( TEST "Built unit tests" OFF ) 8 | 9 | SET ( ly_base_dir ${PROJECT_SOURCE_DIR} ) 10 | SET ( ly_src_dir ${ly_base_dir}/source ) 11 | SET ( ly_inc_dir ${ly_base_dir}/include ) 12 | SET ( ly_tst_dir ${ly_base_dir}/unit_test ) 13 | SET ( ly_lib_name yuv ) 14 | SET ( ly_lib_static ${ly_lib_name} ) 15 | SET ( ly_lib_shared ${ly_lib_name}_shared ) 16 | 17 | FILE ( GLOB_RECURSE ly_source_files ${ly_src_dir}/*.cc ) 18 | LIST ( SORT ly_source_files ) 19 | 20 | FILE ( GLOB_RECURSE ly_unittest_sources ${ly_tst_dir}/*.cc ) 21 | LIST ( SORT ly_unittest_sources ) 22 | 23 | INCLUDE_DIRECTORIES( BEFORE ${ly_inc_dir} ) 24 | 25 | # this creates the static library (.a) 26 | ADD_LIBRARY ( ${ly_lib_static} STATIC ${ly_source_files} ) 27 | 28 | # this creates the shared library (.so) 29 | ADD_LIBRARY ( ${ly_lib_shared} SHARED ${ly_source_files} ) 30 | SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES OUTPUT_NAME "${ly_lib_name}" ) 31 | SET_TARGET_PROPERTIES ( ${ly_lib_shared} PROPERTIES PREFIX "lib" ) 32 | 33 | # this creates the conversion tool 34 | ADD_EXECUTABLE ( yuvconvert ${ly_base_dir}/util/yuvconvert.cc ) 35 | TARGET_LINK_LIBRARIES ( yuvconvert ${ly_lib_static} ) 36 | 37 | 38 | INCLUDE ( FindJPEG ) 39 | if (JPEG_FOUND) 40 | include_directories( ${JPEG_INCLUDE_DIR} ) 41 | target_link_libraries( yuvconvert ${JPEG_LIBRARY} ) 42 | add_definitions( -DHAVE_JPEG ) 43 | endif() 44 | 45 | if(TEST) 46 | find_library(GTEST_LIBRARY gtest) 47 | if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND") 48 | set(GTEST_SRC_DIR /usr/src/gtest CACHE STRING "Location of gtest sources") 49 | if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc) 50 | message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}") 51 | set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc) 52 | add_library(gtest STATIC ${gtest_sources}) 53 | include_directories(${GTEST_SRC_DIR}) 54 | include_directories(${GTEST_SRC_DIR}/include) 55 | set(GTEST_LIBRARY gtest) 56 | else() 57 | message(FATAL_ERROR "TEST is set but unable to find gtest library") 58 | endif() 59 | endif() 60 | 61 | add_executable(libyuv_unittest ${ly_unittest_sources}) 62 | target_link_libraries(libyuv_unittest ${ly_lib_name} ${GTEST_LIBRARY} pthread) 63 | if (JPEG_FOUND) 64 | target_link_libraries(libyuv_unittest ${JPEG_LIBRARY}) 65 | endif() 66 | 67 | if(NACL AND NACL_LIBC STREQUAL "newlib") 68 | target_link_libraries(libyuv_unittest glibc-compat) 69 | endif() 70 | 71 | target_link_libraries(libyuv_unittest gflags) 72 | endif() 73 | 74 | 75 | # install the conversion tool, .so, .a, and all the header files 76 | INSTALL ( PROGRAMS ${CMAKE_BINARY_DIR}/yuvconvert DESTINATION bin ) 77 | INSTALL ( TARGETS ${ly_lib_static} DESTINATION lib ) 78 | INSTALL ( TARGETS ${ly_lib_shared} LIBRARY DESTINATION lib ) 79 | INSTALL ( DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include ) 80 | 81 | # create the .deb and .rpm packages using cpack 82 | INCLUDE ( CM_linux_packages.cmake ) 83 | 84 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | 15 | * Neither the name of Google nor the names of its contributors may 16 | be used to endorse or promote products derived from this software 17 | without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/LICENSE_THIRD_PARTY: -------------------------------------------------------------------------------- 1 | This source tree contains third party source code which is governed by third 2 | party licenses. This file contains references to files which are under other 3 | licenses than the one provided in the LICENSE file in the root of the source 4 | tree. 5 | 6 | Files governed by third party licenses: 7 | source/x86inc.asm 8 | 9 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/OWNERS: -------------------------------------------------------------------------------- 1 | fbarchard@chromium.org 2 | magjed@chromium.org 3 | torbjorng@chromium.org 4 | 5 | per-file *.gyp=kjellander@chromium.org 6 | per-file *.gn=kjellander@chromium.org 7 | per-file .gitignore=* 8 | per-file AUTHORS=* 9 | per-file DEPS=* 10 | per-file PRESUBMIT.py=kjellander@chromium.org 11 | per-file gyp_libyuv.py=kjellander@chromium.org 12 | per-file setup_links.py=* 13 | per-file sync_chromium.py=kjellander@chromium.org 14 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the LibYuv code package. 5 | 6 | Google hereby grants to you a perpetual, worldwide, non-exclusive, 7 | no-charge, irrevocable (except as stated in this section) patent 8 | license to make, have made, use, offer to sell, sell, import, 9 | transfer, and otherwise run, modify and propagate the contents of this 10 | implementation of the LibYuv code package, where such license applies 11 | only to those patent claims, both currently owned by Google and 12 | acquired in the future, licensable by Google that are necessarily 13 | infringed by this implementation of the LibYuv code package. This 14 | grant does not include claims that would be infringed only as a 15 | consequence of further modification of this implementation. If you or 16 | your agent or exclusive licensee institute or order or agree to the 17 | institution of patent litigation against any entity (including a 18 | cross-claim or counterclaim in a lawsuit) alleging that this 19 | implementation of the LibYuv code package or any code incorporated 20 | within this implementation of the LibYuv code package constitutes 21 | direct or contributory patent infringement, or inducement of patent 22 | infringement, then any patent rights granted to you under this License 23 | for this implementation of the LibYuv code package shall terminate as 24 | of the date such litigation is filed. -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/PRESUBMIT.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import os 10 | 11 | 12 | def _RunPythonTests(input_api, output_api): 13 | def join(*args): 14 | return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) 15 | 16 | test_directories = [ 17 | root for root, _, files in os.walk(join('tools_libyuv')) 18 | if any(f.endswith('_test.py') for f in files) 19 | ] 20 | 21 | tests = [] 22 | for directory in test_directories: 23 | tests.extend( 24 | input_api.canned_checks.GetUnitTestsInDirectory( 25 | input_api, 26 | output_api, 27 | directory, 28 | whitelist=[r'.+_test\.py$'])) 29 | return input_api.RunTests(tests, parallel=True) 30 | 31 | 32 | def _CommonChecks(input_api, output_api): 33 | """Checks common to both upload and commit.""" 34 | results = [] 35 | results.extend(input_api.canned_checks.RunPylint(input_api, output_api, 36 | black_list=(r'^base[\\\/].*\.py$', 37 | r'^build[\\\/].*\.py$', 38 | r'^buildtools[\\\/].*\.py$', 39 | r'^ios[\\\/].*\.py$', 40 | r'^out.*[\\\/].*\.py$', 41 | r'^testing[\\\/].*\.py$', 42 | r'^third_party[\\\/].*\.py$', 43 | r'^tools[\\\/].*\.py$', 44 | # TODO(kjellander): should arguably be checked. 45 | r'^tools_libyuv[\\\/]valgrind[\\\/].*\.py$', 46 | r'^xcodebuild.*[\\\/].*\.py$',), 47 | disabled_warnings=['F0401', # Failed to import x 48 | 'E0611', # No package y in x 49 | 'W0232', # Class has no __init__ method 50 | ], 51 | pylintrc='pylintrc')) 52 | results.extend(_RunPythonTests(input_api, output_api)) 53 | return results 54 | 55 | 56 | def CheckChangeOnUpload(input_api, output_api): 57 | results = [] 58 | results.extend(_CommonChecks(input_api, output_api)) 59 | results.extend( 60 | input_api.canned_checks.CheckGNFormatted(input_api, output_api)) 61 | return results 62 | 63 | 64 | def CheckChangeOnCommit(input_api, output_api): 65 | results = [] 66 | results.extend(_CommonChecks(input_api, output_api)) 67 | results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) 68 | results.extend(input_api.canned_checks.CheckChangeWasUploaded( 69 | input_api, output_api)) 70 | results.extend(input_api.canned_checks.CheckChangeHasDescription( 71 | input_api, output_api)) 72 | return results 73 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/README.chromium: -------------------------------------------------------------------------------- 1 | Name: libyuv 2 | URL: http://code.google.com/p/libyuv/ 3 | Version: 1662 4 | License: BSD 5 | License File: LICENSE 6 | 7 | Description: 8 | libyuv is an open source project that includes YUV conversion and scaling functionality. 9 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/README.md: -------------------------------------------------------------------------------- 1 | **libyuv** is an open source project that includes YUV scaling and conversion functionality. 2 | 3 | * Scale YUV to prepare content for compression, with point, bilinear or box filter. 4 | * Convert to YUV from webcam formats. 5 | * Convert from YUV to formats for rendering/effects. 6 | * Rotate by 90/180/270 degrees to adjust for mobile devices in portrait mode. 7 | * Optimized for SSE2/SSSE3/AVX2 on x86/x64. 8 | * Optimized for Neon on Arm. 9 | * Optimized for DSP R2 on Mips. 10 | 11 | ### Development 12 | 13 | See [Getting started] [1] for instructions on how to get started developing. 14 | 15 | You can also browse the [docs directory] [2] for more documentation. 16 | 17 | [1]: https://chromium.googlesource.com/libyuv/libyuv/+/master/docs/getting_started.md 18 | [2]: https://chromium.googlesource.com/libyuv/libyuv/+/master/docs/ 19 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/all.gyp: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | # all.gyp and All target are for benefit of android gyp build. 10 | { 11 | 'targets': [ 12 | { 13 | 'target_name': 'All', 14 | 'type': 'none', 15 | 'dependencies': [ 16 | 'libyuv.gyp:*', 17 | 'libyuv_test.gyp:*', 18 | ], 19 | }, 20 | ], 21 | } 22 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/build_overrides/build.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | # Some non-Chromium builds don't use Chromium's third_party/binutils. 10 | linux_use_bundled_binutils_override = true 11 | 12 | # Variable that can be used to support multiple build scenarios, like having 13 | # Chromium specific targets in a client project's GN file etc. 14 | build_with_chromium = false 15 | 16 | # Some non-Chromium builds don't support building java targets. 17 | enable_java_templates = true 18 | 19 | # Allow using custom suppressions files (currently not used by libyuv). 20 | asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc" 21 | lsan_suppressions_file = "//build/sanitizers/lsan_suppressions.cc" 22 | tsan_suppressions_file = "//build/sanitizers/tsan_suppressions.cc" 23 | 24 | msan_blacklist_path = 25 | rebase_path("//tools_libyuv/msan/blacklist.txt", root_build_dir) 26 | ubsan_blacklist_path = 27 | rebase_path("//tools_libyuv/ubsan/blacklist.txt", root_build_dir) 28 | ubsan_vptr_blacklist_path = 29 | rebase_path("//tools_libyuv/ubsan/vptr_blacklist.txt", root_build_dir) 30 | 31 | # For Chromium, Android 32-bit non-component, non-clang builds hit a 4GiB size 32 | # limit, making them requiring symbol_level=2. WebRTC doesn't hit that problem 33 | # so we just ignore that assert. See https://crbug.com/648948 for more info. 34 | ignore_elf32_limitations = true 35 | 36 | # Use system Xcode installation instead of the Chromium bundled Mac toolchain, 37 | # since it contains only SDK 10.11, not 10.12 which WebRTC needs. 38 | use_system_xcode = true 39 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/build_overrides/gtest.gni: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 The LibYuv project authors. All Rights Reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | # Include support for registering main function in multi-process tests. 10 | gtest_include_multiprocess = true 11 | 12 | # Include support for platform-specific operations across unit tests. 13 | gtest_include_platform_test = true 14 | 15 | # Exclude support for testing Objective C code on OS X and iOS. 16 | gtest_include_objc_support = true 17 | 18 | # Exclude support for flushing coverage files on iOS. 19 | gtest_include_ios_coverage = true 20 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/cleanup_links.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright 2017 The LibYuv Project Authors. All rights reserved. 3 | # 4 | # Use of this source code is governed by a BSD-style license 5 | # that can be found in the LICENSE file in the root of the source 6 | # tree. An additional intellectual property rights grant can be found 7 | # in the file PATENTS. All contributing project authors may 8 | # be found in the AUTHORS file in the root of the source tree. 9 | 10 | # This is a copy of the file from WebRTC in: 11 | # https://chromium.googlesource.com/external/webrtc/+/master/cleanup_links.py 12 | 13 | """Script to cleanup symlinks created from setup_links.py. 14 | 15 | Before 177567c518b121731e507e9b9c4049c4dc96e4c8 (#15754) we had a Chromium 16 | checkout which we created symlinks into. In order to do clean syncs after 17 | landing that change, this script cleans up any old symlinks, avoiding annoying 18 | manual cleanup needed in order to complete gclient sync. 19 | """ 20 | 21 | import logging 22 | import optparse 23 | import os 24 | import shelve 25 | import subprocess 26 | import sys 27 | 28 | 29 | ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) 30 | LINKS_DB = 'links' 31 | 32 | # Version management to make future upgrades/downgrades easier to support. 33 | SCHEMA_VERSION = 1 34 | 35 | class WebRTCLinkSetup(object): 36 | def __init__(self, links_db, dry_run=False): 37 | self._dry_run = dry_run 38 | self._links_db = links_db 39 | 40 | def CleanupLinks(self): 41 | logging.debug('CleanupLinks') 42 | for source, link_path in self._links_db.iteritems(): 43 | if source == 'SCHEMA_VERSION': 44 | continue 45 | if os.path.islink(link_path) or sys.platform.startswith('win'): 46 | # os.path.islink() always returns false on Windows 47 | # See http://bugs.python.org/issue13143. 48 | logging.debug('Removing link to %s at %s', source, link_path) 49 | if not self._dry_run: 50 | if os.path.exists(link_path): 51 | if sys.platform.startswith('win') and os.path.isdir(link_path): 52 | subprocess.check_call(['rmdir', '/q', '/s', link_path], 53 | shell=True) 54 | else: 55 | os.remove(link_path) 56 | del self._links_db[source] 57 | 58 | 59 | def _initialize_database(filename): 60 | links_database = shelve.open(filename) 61 | # Wipe the database if this version of the script ends up looking at a 62 | # newer (future) version of the links db, just to be sure. 63 | version = links_database.get('SCHEMA_VERSION') 64 | if version and version != SCHEMA_VERSION: 65 | logging.info('Found database with schema version %s while this script only ' 66 | 'supports %s. Wiping previous database contents.', version, 67 | SCHEMA_VERSION) 68 | links_database.clear() 69 | links_database['SCHEMA_VERSION'] = SCHEMA_VERSION 70 | return links_database 71 | 72 | 73 | def main(): 74 | parser = optparse.OptionParser() 75 | parser.add_option('-d', '--dry-run', action='store_true', default=False, 76 | help='Print what would be done, but don\'t perform any ' 77 | 'operations. This will automatically set logging to ' 78 | 'verbose.') 79 | parser.add_option('-v', '--verbose', action='store_const', 80 | const=logging.DEBUG, default=logging.INFO, 81 | help='Print verbose output for debugging.') 82 | options, _ = parser.parse_args() 83 | 84 | if options.dry_run: 85 | options.verbose = logging.DEBUG 86 | logging.basicConfig(format='%(message)s', level=options.verbose) 87 | 88 | # Work from the root directory of the checkout. 89 | script_dir = os.path.dirname(os.path.abspath(__file__)) 90 | os.chdir(script_dir) 91 | 92 | # The database file gets .db appended on some platforms. 93 | db_filenames = [LINKS_DB, LINKS_DB + '.db'] 94 | if any(os.path.isfile(f) for f in db_filenames): 95 | links_database = _initialize_database(LINKS_DB) 96 | try: 97 | symlink_creator = WebRTCLinkSetup(links_database, options.dry_run) 98 | symlink_creator.CleanupLinks() 99 | finally: 100 | for f in db_filenames: 101 | if os.path.isfile(f): 102 | os.remove(f) 103 | return 0 104 | 105 | 106 | if __name__ == '__main__': 107 | sys.exit(main()) 108 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/codereview.settings: -------------------------------------------------------------------------------- 1 | # This file is used by git cl to get repository specific information. 2 | CODE_REVIEW_SERVER: codereview.chromium.org 3 | GERRIT_HOST: True 4 | PROJECT: libyuv 5 | TRY_ON_UPLOAD: False 6 | VIEW_VC: https://chromium.googlesource.com/libyuv/libyuv/+/ 7 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/docs/environment_variables.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | For test purposes, environment variables can be set to control libyuv behavior. These should only be used for testing, to narrow down bugs or to test performance. 4 | 5 | # CPU 6 | 7 | By default the cpu is detected and the most advanced form of SIMD is used. But you can disable instruction sets selectively, or completely, falling back on C code. Set the variable to 1 to disable the specified instruction set. 8 | 9 | LIBYUV_DISABLE_ASM 10 | LIBYUV_DISABLE_X86 11 | LIBYUV_DISABLE_SSE2 12 | LIBYUV_DISABLE_SSSE3 13 | LIBYUV_DISABLE_SSE41 14 | LIBYUV_DISABLE_SSE42 15 | LIBYUV_DISABLE_AVX 16 | LIBYUV_DISABLE_AVX2 17 | LIBYUV_DISABLE_AVX3 18 | LIBYUV_DISABLE_ERMS 19 | LIBYUV_DISABLE_FMA3 20 | LIBYUV_DISABLE_DSPR2 21 | LIBYUV_DISABLE_NEON 22 | 23 | # Test Width/Height/Repeat 24 | 25 | The unittests default to a small image (128x72) to run fast. This can be set by environment variable to test a specific resolutions. 26 | You can also repeat the test a specified number of iterations, allowing benchmarking and profiling. 27 | 28 | set LIBYUV_WIDTH=1280 29 | set LIBYUV_HEIGHT=720 30 | set LIBYUV_REPEAT=999 31 | set LIBYUV_FLAGS=-1 32 | set LIBYUV_CPU_INFO=-1 33 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/docs/rotation.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | Rotation by multiplies of 90 degrees allows mobile devices to rotate webcams from landscape to portrait. The higher level functions ConvertToI420 and ConvertToARGB allow rotation of any format. Optimized functionality is supported for I420, ARGB, NV12 and NV21. 4 | 5 | # ConvertToI420 6 | 7 | int ConvertToI420(const uint8* src_frame, size_t src_size, 8 | uint8* dst_y, int dst_stride_y, 9 | uint8* dst_u, int dst_stride_u, 10 | uint8* dst_v, int dst_stride_v, 11 | int crop_x, int crop_y, 12 | int src_width, int src_height, 13 | int crop_width, int crop_height, 14 | enum RotationMode rotation, 15 | uint32 format); 16 | 17 | This function crops, converts, and rotates. You should think of it in that order. 18 | * Crops the original image, which is src_width x src_height, to crop_width x crop_height. At this point the image is still not rotated. 19 | * Converts the cropped region to I420. Supports inverted source for src_height negative. 20 | * Rotates by 90, 180 or 270 degrees. 21 | The buffer the caller provides should account for rotation. Be especially important to get stride of the destination correct. 22 | 23 | e.g. 24 | 640 x 480 NV12 captured
25 | Crop to 640 x 360
26 | Rotate by 90 degrees to 360 x 640.
27 | Caller passes stride of 360 for Y and 360 / 2 for U and V.
28 | Caller passes crop_width of 640, crop_height of 360.
29 | 30 | # ConvertToARGB 31 | 32 | int ConvertToARGB(const uint8* src_frame, size_t src_size, 33 | uint8* dst_argb, int dst_stride_argb, 34 | int crop_x, int crop_y, 35 | int src_width, int src_height, 36 | int crop_width, int crop_height, 37 | enum RotationMode rotation, 38 | uint32 format); 39 | 40 | Same as I420, but implementation is less optimized - reads columns and writes rows, 16 bytes at a time. 41 | 42 | # I420Rotate 43 | 44 | int I420Rotate(const uint8* src_y, int src_stride_y, 45 | const uint8* src_u, int src_stride_u, 46 | const uint8* src_v, int src_stride_v, 47 | uint8* dst_y, int dst_stride_y, 48 | uint8* dst_u, int dst_stride_u, 49 | uint8* dst_v, int dst_stride_v, 50 | int src_width, int src_height, enum RotationMode mode); 51 | 52 | Destination is rotated, so pass dst_stride_y etc that consider rotation.
53 | Rotate by 180 can be done in place, but 90 and 270 can not. 54 | 55 | Implementation (Neon/SSE2) uses 8 x 8 block transpose, so best efficiency is with sizes and pointers that are aligned to 8. 56 | 57 | Cropping can be achieved by adjusting the src_y/u/v pointers and src_width, src_height. 58 | 59 | Lower level plane functions are provided, allowing other planar formats to be rotated. (e.g. I444) 60 | 61 | For other planar YUV formats (I444, I422, I411, I400, NV16, NV24), the planar functions are exposed and can be called directly 62 | 63 | 64 | // Rotate a plane by 0, 90, 180, or 270. 65 | int RotatePlane(const uint8* src, int src_stride, 66 | uint8* dst, int dst_stride, 67 | int src_width, int src_height, enum RotationMode mode); 68 | 69 | # ARGBRotate 70 | 71 | LIBYUV_API 72 | int ARGBRotate(const uint8* src_argb, int src_stride_argb, 73 | uint8* dst_argb, int dst_stride_argb, 74 | int src_width, int src_height, enum RotationMode mode); 75 | 76 | Same as I420, but implementation is less optimized - reads columns and writes rows. 77 | 78 | Rotate by 90, or any angle, can be achieved using ARGBAffine. 79 | 80 | # Mirror - Horizontal Flip 81 | 82 | Mirror functions for horizontally flipping an image, which can be useful for 'self view' of a webcam. 83 | 84 | int I420Mirror(const uint8* src_y, int src_stride_y, 85 | const uint8* src_u, int src_stride_u, 86 | const uint8* src_v, int src_stride_v, 87 | uint8* dst_y, int dst_stride_y, 88 | uint8* dst_u, int dst_stride_u, 89 | uint8* dst_v, int dst_stride_v, 90 | int width, int height); 91 | int ARGBMirror(const uint8* src_argb, int src_stride_argb, 92 | uint8* dst_argb, int dst_stride_argb, 93 | int width, int height); 94 | 95 | Mirror functionality can also be achieved with the I420Scale and ARGBScale functions by passing negative width and/or height. 96 | 97 | # Invert - Vertical Flip 98 | 99 | Inverting can be achieved with almost any libyuv function by passing a negative source height. 100 | 101 | I420Mirror and ARGBMirror can also be used to rotate by 180 degrees by passing a negative height. 102 | 103 | 104 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/download_vs_toolchain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2014 The LibYuv Project Authors. All rights reserved. 4 | # 5 | # Use of this source code is governed by a BSD-style license 6 | # that can be found in the LICENSE file in the root of the source 7 | # tree. An additional intellectual property rights grant can be found 8 | # in the file PATENTS. All contributing project authors may 9 | # be found in the AUTHORS file in the root of the source tree. 10 | 11 | # This script is used to run the vs_toolchain.py script to download the 12 | # Visual Studio toolchain. It's just a temporary measure while waiting for the 13 | # Chrome team to move find_depot_tools into src/build to get rid of these 14 | # workarounds (similar one in gyp_libyuv). 15 | 16 | import os 17 | import sys 18 | 19 | 20 | checkout_root = os.path.dirname(os.path.realpath(__file__)) 21 | sys.path.insert(0, os.path.join(checkout_root, 'build')) 22 | sys.path.insert(0, os.path.join(checkout_root, 'tools', 'find_depot_tools')) 23 | 24 | 25 | import vs_toolchain 26 | 27 | 28 | if __name__ == '__main__': 29 | sys.exit(vs_toolchain.main()) 30 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/gyp_libyuv: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2014 The LibYuv Project Authors. All rights reserved. 4 | # 5 | # Use of this source code is governed by a BSD-style license 6 | # that can be found in the LICENSE file in the root of the source 7 | # tree. An additional intellectual property rights grant can be found 8 | # in the file PATENTS. All contributing project authors may 9 | # be found in the AUTHORS file in the root of the source tree. 10 | 11 | # This script is used to run GYP for libyuv. It contains selected parts of the 12 | # main function from the src/build/gyp_chromium file. 13 | 14 | import glob 15 | import os 16 | import shlex 17 | import sys 18 | 19 | checkout_root = os.path.dirname(os.path.realpath(__file__)) 20 | 21 | sys.path.insert(0, os.path.join(checkout_root, 'build')) 22 | import gyp_chromium 23 | import gyp_helper 24 | import vs_toolchain 25 | 26 | sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib')) 27 | import gyp 28 | 29 | def GetSupplementalFiles(): 30 | """Returns a list of the supplemental files that are included in all GYP 31 | sources.""" 32 | # Can't use the one in gyp_chromium since the directory location of the root 33 | # is different. 34 | return glob.glob(os.path.join(checkout_root, '*', 'supplement.gypi')) 35 | 36 | 37 | if __name__ == '__main__': 38 | args = sys.argv[1:] 39 | 40 | if int(os.environ.get('GYP_CHROMIUM_NO_ACTION', 0)): 41 | print 'Skipping gyp_libyuv due to GYP_CHROMIUM_NO_ACTION env var.' 42 | sys.exit(0) 43 | 44 | # This could give false positives since it doesn't actually do real option 45 | # parsing. Oh well. 46 | gyp_file_specified = False 47 | for arg in args: 48 | if arg.endswith('.gyp'): 49 | gyp_file_specified = True 50 | break 51 | 52 | # If we didn't get a file, assume 'all.gyp' in the root of the checkout. 53 | if not gyp_file_specified: 54 | # Because of a bug in gyp, simply adding the abspath to all.gyp doesn't 55 | # work, but chdir'ing and adding the relative path does. Spooky :/ 56 | os.chdir(checkout_root) 57 | args.append('all.gyp') 58 | 59 | # There shouldn't be a circular dependency relationship between .gyp files, 60 | args.append('--no-circular-check') 61 | 62 | # Default to ninja unless GYP_GENERATORS is set. 63 | if not os.environ.get('GYP_GENERATORS'): 64 | os.environ['GYP_GENERATORS'] = 'ninja' 65 | 66 | vs2013_runtime_dll_dirs = None 67 | if int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')): 68 | vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs() 69 | 70 | # Enforce gyp syntax checking. This adds about 20% execution time. 71 | args.append('--check') 72 | 73 | supplemental_includes = gyp_chromium.GetSupplementalFiles() 74 | gyp_vars_dict = gyp_chromium.GetGypVars(supplemental_includes) 75 | 76 | # Automatically turn on crosscompile support for platforms that need it. 77 | if all(('ninja' in os.environ.get('GYP_GENERATORS', ''), 78 | gyp_vars_dict.get('OS') in ['android', 'ios'], 79 | 'GYP_CROSSCOMPILE' not in os.environ)): 80 | os.environ['GYP_CROSSCOMPILE'] = '1' 81 | 82 | args.extend(['-I' + i for i in 83 | gyp_chromium.additional_include_files(supplemental_includes, 84 | args)]) 85 | 86 | # Set the gyp depth variable to the root of the checkout. 87 | args.append('--depth=' + os.path.relpath(checkout_root)) 88 | 89 | print 'Updating projects from gyp files...' 90 | sys.stdout.flush() 91 | 92 | # Off we go... 93 | gyp_rc = gyp.main(args) 94 | 95 | if vs2013_runtime_dll_dirs: 96 | x64_runtime, x86_runtime = vs2013_runtime_dll_dirs 97 | vs_toolchain.CopyVsRuntimeDlls( 98 | os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()), 99 | (x86_runtime, x64_runtime)) 100 | 101 | sys.exit(gyp_rc) 102 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/gyp_libyuv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2014 The LibYuv Project Authors. All rights reserved. 4 | # 5 | # Use of this source code is governed by a BSD-style license 6 | # that can be found in the LICENSE file in the root of the source 7 | # tree. An additional intellectual property rights grant can be found 8 | # in the file PATENTS. All contributing project authors may 9 | # be found in the AUTHORS file in the root of the source tree. 10 | 11 | 12 | # This script is a modified copy of the src/build/gyp_chromium.py file. 13 | # It is needed for parallel processing. 14 | 15 | # This file is (possibly, depending on python version) imported by 16 | # gyp_libyuv when GYP_PARALLEL=1 and it creates sub-processes 17 | # through the multiprocessing library. 18 | 19 | # Importing in Python 2.6 (fixed in 2.7) on Windows doesn't search for 20 | # imports that don't end in .py (and aren't directories with an 21 | # __init__.py). This wrapper makes "import gyp_libyuv" work with 22 | # those old versions and makes it possible to execute gyp_libyuv.py 23 | # directly on Windows where the extension is useful. 24 | 25 | import os 26 | 27 | path = os.path.abspath(os.path.split(__file__)[0]) 28 | execfile(os.path.join(path, 'gyp_libyuv')) 29 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/include/libyuv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_H_ 12 | #define INCLUDE_LIBYUV_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/compare.h" 16 | #include "libyuv/convert.h" 17 | #include "libyuv/convert_argb.h" 18 | #include "libyuv/convert_from.h" 19 | #include "libyuv/convert_from_argb.h" 20 | #include "libyuv/cpu_id.h" 21 | #include "libyuv/mjpeg_decoder.h" 22 | #include "libyuv/planar_functions.h" 23 | #include "libyuv/rotate.h" 24 | #include "libyuv/rotate_argb.h" 25 | #include "libyuv/row.h" 26 | #include "libyuv/scale.h" 27 | #include "libyuv/scale_argb.h" 28 | #include "libyuv/scale_row.h" 29 | #include "libyuv/version.h" 30 | #include "libyuv/video_common.h" 31 | 32 | #endif // INCLUDE_LIBYUV_H_ 33 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/include/libyuv/basic_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ 12 | #define INCLUDE_LIBYUV_BASIC_TYPES_H_ 13 | 14 | #include // for NULL, size_t 15 | 16 | #if defined(_MSC_VER) && (_MSC_VER < 1600) 17 | #include // for uintptr_t on x86 18 | #else 19 | #include // for uintptr_t 20 | #endif 21 | 22 | #ifndef GG_LONGLONG 23 | #ifndef INT_TYPES_DEFINED 24 | #define INT_TYPES_DEFINED 25 | #ifdef COMPILER_MSVC 26 | typedef unsigned __int64 uint64; 27 | typedef __int64 int64; 28 | #ifndef INT64_C 29 | #define INT64_C(x) x##I64 30 | #endif 31 | #ifndef UINT64_C 32 | #define UINT64_C(x) x##UI64 33 | #endif 34 | #define INT64_F "I64" 35 | #else // COMPILER_MSVC 36 | #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 37 | typedef unsigned long uint64; // NOLINT 38 | typedef long int64; // NOLINT 39 | #ifndef INT64_C 40 | #define INT64_C(x) x##L 41 | #endif 42 | #ifndef UINT64_C 43 | #define UINT64_C(x) x##UL 44 | #endif 45 | #define INT64_F "l" 46 | #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 47 | typedef unsigned long long uint64; // NOLINT 48 | typedef long long int64; // NOLINT 49 | #ifndef INT64_C 50 | #define INT64_C(x) x##LL 51 | #endif 52 | #ifndef UINT64_C 53 | #define UINT64_C(x) x##ULL 54 | #endif 55 | #define INT64_F "ll" 56 | #endif // __LP64__ 57 | #endif // COMPILER_MSVC 58 | typedef unsigned int uint32; 59 | typedef int int32; 60 | typedef unsigned short uint16; // NOLINT 61 | typedef short int16; // NOLINT 62 | typedef unsigned char uint8; 63 | typedef signed char int8; 64 | #endif // INT_TYPES_DEFINED 65 | #endif // GG_LONGLONG 66 | 67 | // Detect compiler is for x86 or x64. 68 | #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \ 69 | defined(_M_IX86) 70 | #define CPU_X86 1 71 | #endif 72 | // Detect compiler is for ARM. 73 | #if defined(__arm__) || defined(_M_ARM) 74 | #define CPU_ARM 1 75 | #endif 76 | 77 | #ifndef ALIGNP 78 | #ifdef __cplusplus 79 | #define ALIGNP(p, t) \ 80 | reinterpret_cast( \ 81 | ((reinterpret_cast(p) + ((t)-1)) & ~((t)-1))) 82 | #else 83 | #define ALIGNP(p, t) \ 84 | (uint8*)((((uintptr_t)(p) + ((t)-1)) & ~((t)-1))) /* NOLINT */ 85 | #endif 86 | #endif 87 | 88 | #if !defined(LIBYUV_API) 89 | #if defined(_WIN32) || defined(__CYGWIN__) 90 | #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) 91 | #define LIBYUV_API __declspec(dllexport) 92 | #elif defined(LIBYUV_USING_SHARED_LIBRARY) 93 | #define LIBYUV_API __declspec(dllimport) 94 | #else 95 | #define LIBYUV_API 96 | #endif // LIBYUV_BUILDING_SHARED_LIBRARY 97 | #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ 98 | (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ 99 | defined(LIBYUV_USING_SHARED_LIBRARY)) 100 | #define LIBYUV_API __attribute__((visibility("default"))) 101 | #else 102 | #define LIBYUV_API 103 | #endif // __GNUC__ 104 | #endif // LIBYUV_API 105 | 106 | #define LIBYUV_BOOL int 107 | #define LIBYUV_FALSE 0 108 | #define LIBYUV_TRUE 1 109 | 110 | // Visual C x86 or GCC little endian. 111 | #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \ 112 | defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) || \ 113 | (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 114 | #define LIBYUV_LITTLE_ENDIAN 115 | #endif 116 | 117 | #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ 118 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/include/libyuv/compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_COMPARE_H_ 12 | #define INCLUDE_LIBYUV_COMPARE_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | // Compute a hash for specified memory. Seed of 5381 recommended. 22 | LIBYUV_API 23 | uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed); 24 | 25 | // Hamming Distance 26 | LIBYUV_API 27 | uint64 ComputeHammingDistance(const uint8* src_a, 28 | const uint8* 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 ARGBDetect(const uint8* argb, int stride_argb, int width, int height); 35 | 36 | // Sum Square Error - used to compute Mean Square Error or PSNR. 37 | LIBYUV_API 38 | uint64 ComputeSumSquareError(const uint8* src_a, const uint8* src_b, int count); 39 | 40 | LIBYUV_API 41 | uint64 ComputeSumSquareErrorPlane(const uint8* src_a, 42 | int stride_a, 43 | const uint8* src_b, 44 | int stride_b, 45 | int width, 46 | int height); 47 | 48 | static const int kMaxPsnr = 128; 49 | 50 | LIBYUV_API 51 | double SumSquareErrorToPsnr(uint64 sse, uint64 count); 52 | 53 | LIBYUV_API 54 | double CalcFramePsnr(const uint8* src_a, 55 | int stride_a, 56 | const uint8* src_b, 57 | int stride_b, 58 | int width, 59 | int height); 60 | 61 | LIBYUV_API 62 | double I420Psnr(const uint8* src_y_a, 63 | int stride_y_a, 64 | const uint8* src_u_a, 65 | int stride_u_a, 66 | const uint8* src_v_a, 67 | int stride_v_a, 68 | const uint8* src_y_b, 69 | int stride_y_b, 70 | const uint8* src_u_b, 71 | int stride_u_b, 72 | const uint8* src_v_b, 73 | int stride_v_b, 74 | int width, 75 | int height); 76 | 77 | LIBYUV_API 78 | double CalcFrameSsim(const uint8* src_a, 79 | int stride_a, 80 | const uint8* src_b, 81 | int stride_b, 82 | int width, 83 | int height); 84 | 85 | LIBYUV_API 86 | double I420Ssim(const uint8* src_y_a, 87 | int stride_y_a, 88 | const uint8* src_u_a, 89 | int stride_u_a, 90 | const uint8* src_v_a, 91 | int stride_v_a, 92 | const uint8* src_y_b, 93 | int stride_y_b, 94 | const uint8* src_u_b, 95 | int stride_u_b, 96 | const uint8* src_v_b, 97 | int stride_v_b, 98 | int width, 99 | int height); 100 | 101 | #ifdef __cplusplus 102 | } // extern "C" 103 | } // namespace libyuv 104 | #endif 105 | 106 | #endif // INCLUDE_LIBYUV_COMPARE_H_ 107 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/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(__i386__) && !defined(__SSE2__)) 23 | #define LIBYUV_DISABLE_X86 24 | #endif 25 | // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 26 | #if defined(__has_feature) 27 | #if __has_feature(memory_sanitizer) 28 | #define LIBYUV_DISABLE_X86 29 | #endif 30 | #endif 31 | 32 | // Visual C 2012 required for AVX2. 33 | #if defined(_M_IX86) && !defined(__clang__) && defined(_MSC_VER) && \ 34 | _MSC_VER >= 1700 35 | #define VISUALC_HAS_AVX2 1 36 | #endif // VisualStudio >= 2012 37 | 38 | // clang >= 3.4.0 required for AVX2. 39 | #if defined(__clang__) && (defined(__x86_64__) || defined(__i386__)) 40 | #if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4)) 41 | #define CLANG_HAS_AVX2 1 42 | #endif // clang >= 3.4 43 | #endif // __clang__ 44 | 45 | #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && \ 46 | (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2)) 47 | #define HAS_HASHDJB2_AVX2 48 | #endif 49 | 50 | // The following are available for Visual C and GCC: 51 | #if !defined(LIBYUV_DISABLE_X86) && \ 52 | (defined(__x86_64__) || defined(__i386__) || defined(_M_IX86)) 53 | #define HAS_HASHDJB2_SSE41 54 | #define HAS_SUMSQUAREERROR_SSE2 55 | #define HAS_HAMMINGDISTANCE_X86 56 | #endif 57 | 58 | // The following are available for Visual C and clangcl 32 bit: 59 | #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && \ 60 | (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2)) 61 | #define HAS_HASHDJB2_AVX2 62 | #define HAS_SUMSQUAREERROR_AVX2 63 | #endif 64 | 65 | // The following are available for Neon: 66 | #if !defined(LIBYUV_DISABLE_NEON) && \ 67 | (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__)) 68 | #define HAS_SUMSQUAREERROR_NEON 69 | #define HAS_HAMMINGDISTANCE_NEON 70 | #endif 71 | 72 | uint32 HammingDistance_C(const uint8* src_a, const uint8* src_b, int count); 73 | uint32 HammingDistance_X86(const uint8* src_a, const uint8* src_b, int count); 74 | uint32 HammingDistance_NEON(const uint8* src_a, const uint8* src_b, int count); 75 | 76 | uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count); 77 | uint32 SumSquareError_SSE2(const uint8* src_a, const uint8* src_b, int count); 78 | uint32 SumSquareError_AVX2(const uint8* src_a, const uint8* src_b, int count); 79 | uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count); 80 | 81 | uint32 HashDjb2_C(const uint8* src, int count, uint32 seed); 82 | uint32 HashDjb2_SSE41(const uint8* src, int count, uint32 seed); 83 | uint32 HashDjb2_AVX2(const uint8* src, int count, uint32 seed); 84 | 85 | #ifdef __cplusplus 86 | } // extern "C" 87 | } // namespace libyuv 88 | #endif 89 | 90 | #endif // INCLUDE_LIBYUV_COMPARE_ROW_H_ 91 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/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 kCpuHasAVX3 = 0x2000; 40 | static const int kCpuHasF16C = 0x4000; 41 | 42 | // 0x8000 reserved for future X86 flags. 43 | 44 | // These flags are only valid on MIPS processors. 45 | static const int kCpuHasMIPS = 0x10000; 46 | static const int kCpuHasDSPR2 = 0x20000; 47 | static const int kCpuHasMSA = 0x40000; 48 | 49 | // Optional init function. TestCpuFlag does an auto-init. 50 | // Returns cpu_info flags. 51 | LIBYUV_API 52 | int InitCpuFlags(void); 53 | 54 | // Detect CPU has SSE2 etc. 55 | // Test_flag parameter should be one of kCpuHas constants above. 56 | // Returns non-zero if instruction set is detected 57 | static __inline int TestCpuFlag(int test_flag) { 58 | LIBYUV_API extern int cpu_info_; 59 | #ifdef __ATOMIC_RELAXED 60 | int cpu_info = __atomic_load_n(&cpu_info_, __ATOMIC_RELAXED); 61 | #else 62 | int cpu_info = cpu_info_; 63 | #endif 64 | return (!cpu_info ? InitCpuFlags() : cpu_info) & test_flag; 65 | } 66 | 67 | // Internal function for parsing /proc/cpuinfo. 68 | LIBYUV_API 69 | int ArmCpuCaps(const char* cpuinfo_name); 70 | 71 | // For testing, allow CPU flags to be disabled. 72 | // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. 73 | // MaskCpuFlags(-1) to enable all cpu specific optimizations. 74 | // MaskCpuFlags(1) to disable all cpu specific optimizations. 75 | // MaskCpuFlags(0) to reset state so next call will auto init. 76 | // Returns cpu_info flags. 77 | LIBYUV_API 78 | int MaskCpuFlags(int enable_flags); 79 | 80 | // Low level cpuid for X86. Returns zeros on other CPUs. 81 | // eax is the info type that you want. 82 | // ecx is typically the cpu number, and should normally be zero. 83 | LIBYUV_API 84 | void CpuId(int eax, int ecx, int* cpu_info); 85 | 86 | #ifdef __cplusplus 87 | } // extern "C" 88 | } // namespace libyuv 89 | #endif 90 | 91 | #endif // INCLUDE_LIBYUV_CPU_ID_H_ 92 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/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* src_y, 37 | int src_stride_y, 38 | const uint8* src_u, 39 | int src_stride_u, 40 | const uint8* src_v, 41 | int src_stride_v, 42 | uint8* dst_y, 43 | int dst_stride_y, 44 | uint8* dst_u, 45 | int dst_stride_u, 46 | uint8* dst_v, 47 | int dst_stride_v, 48 | int src_width, 49 | int src_height, 50 | enum RotationMode mode); 51 | 52 | // Rotate NV12 input and store in I420. 53 | LIBYUV_API 54 | int NV12ToI420Rotate(const uint8* src_y, 55 | int src_stride_y, 56 | const uint8* src_uv, 57 | int src_stride_uv, 58 | uint8* dst_y, 59 | int dst_stride_y, 60 | uint8* dst_u, 61 | int dst_stride_u, 62 | uint8* dst_v, 63 | int dst_stride_v, 64 | int src_width, 65 | int src_height, 66 | enum RotationMode mode); 67 | 68 | // Rotate a plane by 0, 90, 180, or 270. 69 | LIBYUV_API 70 | int RotatePlane(const uint8* src, 71 | int src_stride, 72 | uint8* dst, 73 | int dst_stride, 74 | int src_width, 75 | int src_height, 76 | enum RotationMode mode); 77 | 78 | // Rotate planes by 90, 180, 270. Deprecated. 79 | LIBYUV_API 80 | void RotatePlane90(const uint8* src, 81 | int src_stride, 82 | uint8* dst, 83 | int dst_stride, 84 | int width, 85 | int height); 86 | 87 | LIBYUV_API 88 | void RotatePlane180(const uint8* src, 89 | int src_stride, 90 | uint8* dst, 91 | int dst_stride, 92 | int width, 93 | int height); 94 | 95 | LIBYUV_API 96 | void RotatePlane270(const uint8* src, 97 | int src_stride, 98 | uint8* dst, 99 | int dst_stride, 100 | int width, 101 | int height); 102 | 103 | LIBYUV_API 104 | void RotateUV90(const uint8* src, 105 | int src_stride, 106 | uint8* dst_a, 107 | int dst_stride_a, 108 | uint8* dst_b, 109 | int dst_stride_b, 110 | int width, 111 | int height); 112 | 113 | // Rotations for when U and V are interleaved. 114 | // These functions take one input pointer and 115 | // split the data into two buffers while 116 | // rotating them. Deprecated. 117 | LIBYUV_API 118 | void RotateUV180(const uint8* src, 119 | int src_stride, 120 | uint8* dst_a, 121 | int dst_stride_a, 122 | uint8* dst_b, 123 | int dst_stride_b, 124 | int width, 125 | int height); 126 | 127 | LIBYUV_API 128 | void RotateUV270(const uint8* src, 129 | int src_stride, 130 | uint8* dst_a, 131 | int dst_stride_a, 132 | uint8* dst_b, 133 | int dst_stride_b, 134 | int width, 135 | int height); 136 | 137 | // The 90 and 270 functions are based on transposes. 138 | // Doing a transpose with reversing the read/write 139 | // order will result in a rotation by +- 90 degrees. 140 | // Deprecated. 141 | LIBYUV_API 142 | void TransposePlane(const uint8* src, 143 | int src_stride, 144 | uint8* dst, 145 | int dst_stride, 146 | int width, 147 | int height); 148 | 149 | LIBYUV_API 150 | void TransposeUV(const uint8* src, 151 | int src_stride, 152 | uint8* dst_a, 153 | int dst_stride_a, 154 | uint8* dst_b, 155 | int dst_stride_b, 156 | int width, 157 | int height); 158 | 159 | #ifdef __cplusplus 160 | } // extern "C" 161 | } // namespace libyuv 162 | #endif 163 | 164 | #endif // INCLUDE_LIBYUV_ROTATE_H_ 165 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/include/libyuv/rotate_argb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_ROTATE_ARGB_H_ 12 | #define INCLUDE_LIBYUV_ROTATE_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/rotate.h" // For RotationMode. 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | // Rotate ARGB frame 23 | LIBYUV_API 24 | int ARGBRotate(const uint8* src_argb, 25 | int src_stride_argb, 26 | uint8* 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 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/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* src, 32 | int src_stride, 33 | int src_width, 34 | int src_height, 35 | uint8* 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* src, 43 | int src_stride, 44 | int src_width, 45 | int src_height, 46 | uint16* 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* src_y, 64 | int src_stride_y, 65 | const uint8* src_u, 66 | int src_stride_u, 67 | const uint8* src_v, 68 | int src_stride_v, 69 | int src_width, 70 | int src_height, 71 | uint8* dst_y, 72 | int dst_stride_y, 73 | uint8* dst_u, 74 | int dst_stride_u, 75 | uint8* 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* src_y, 83 | int src_stride_y, 84 | const uint16* src_u, 85 | int src_stride_u, 86 | const uint16* src_v, 87 | int src_stride_v, 88 | int src_width, 89 | int src_height, 90 | uint16* dst_y, 91 | int dst_stride_y, 92 | uint16* dst_u, 93 | int dst_stride_u, 94 | uint16* dst_v, 95 | int dst_stride_v, 96 | int dst_width, 97 | int dst_height, 98 | enum FilterMode filtering); 99 | 100 | #ifdef __cplusplus 101 | // Legacy API. Deprecated. 102 | LIBYUV_API 103 | int Scale(const uint8* src_y, 104 | const uint8* src_u, 105 | const uint8* src_v, 106 | int src_stride_y, 107 | int src_stride_u, 108 | int src_stride_v, 109 | int src_width, 110 | int src_height, 111 | uint8* dst_y, 112 | uint8* dst_u, 113 | uint8* dst_v, 114 | int dst_stride_y, 115 | int dst_stride_u, 116 | int dst_stride_v, 117 | int dst_width, 118 | int dst_height, 119 | LIBYUV_BOOL interpolate); 120 | 121 | // Legacy API. Deprecated. 122 | LIBYUV_API 123 | int ScaleOffset(const uint8* src_i420, 124 | int src_width, 125 | int src_height, 126 | uint8* dst_i420, 127 | int dst_width, 128 | int dst_height, 129 | int dst_yoffset, 130 | LIBYUV_BOOL interpolate); 131 | 132 | // For testing, allow disabling of specialized scalers. 133 | LIBYUV_API 134 | void SetUseReferenceImpl(LIBYUV_BOOL use); 135 | #endif // __cplusplus 136 | 137 | #ifdef __cplusplus 138 | } // extern "C" 139 | } // namespace libyuv 140 | #endif 141 | 142 | #endif // INCLUDE_LIBYUV_SCALE_H_ 143 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/include/libyuv/scale_argb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_SCALE_ARGB_H_ 12 | #define INCLUDE_LIBYUV_SCALE_ARGB_H_ 13 | 14 | #include "libyuv/basic_types.h" 15 | #include "libyuv/scale.h" // For FilterMode 16 | 17 | #ifdef __cplusplus 18 | namespace libyuv { 19 | extern "C" { 20 | #endif 21 | 22 | LIBYUV_API 23 | int ARGBScale(const uint8* src_argb, 24 | int src_stride_argb, 25 | int src_width, 26 | int src_height, 27 | uint8* dst_argb, 28 | int dst_stride_argb, 29 | int dst_width, 30 | int dst_height, 31 | enum FilterMode filtering); 32 | 33 | // Clipped scale takes destination rectangle coordinates for clip values. 34 | LIBYUV_API 35 | int ARGBScaleClip(const uint8* src_argb, 36 | int src_stride_argb, 37 | int src_width, 38 | int src_height, 39 | uint8* 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* src_y, 52 | int src_stride_y, 53 | const uint8* src_u, 54 | int src_stride_u, 55 | const uint8* src_v, 56 | int src_stride_v, 57 | uint32 src_fourcc, 58 | int src_width, 59 | int src_height, 60 | uint8* dst_argb, 61 | int dst_stride_argb, 62 | uint32 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 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/include/libyuv/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #ifndef INCLUDE_LIBYUV_VERSION_H_ 12 | #define INCLUDE_LIBYUV_VERSION_H_ 13 | 14 | #define LIBYUV_VERSION 1662 15 | 16 | #endif // INCLUDE_LIBYUV_VERSION_H_ 17 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/infra/config/OWNERS: -------------------------------------------------------------------------------- 1 | set noparent 2 | agable@chromium.org 3 | kjellander@chromium.org 4 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/infra/config/README.md: -------------------------------------------------------------------------------- 1 | This directory contains configuration files for infra services. 2 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/infra/config/cq.cfg: -------------------------------------------------------------------------------- 1 | # Commit Queue configuration file. The documentation of the format can be found 2 | # at http://luci-config.appspot.com/schemas/projects/refs:cq.cfg. 3 | 4 | version: 1 5 | cq_name: "libyuv" 6 | cq_status_url: "https://chromium-cq-status.appspot.com" 7 | git_repo_url: "https://chromium.googlesource.com/libyuv/libyuv.git" 8 | 9 | gerrit {} 10 | rietveld { 11 | url: "https://codereview.chromium.org" 12 | } 13 | 14 | 15 | verifiers { 16 | reviewer_lgtm { 17 | committer_list: "project-libyuv-committers" 18 | dry_run_access_list: "project-libyuv-tryjob-access" 19 | } 20 | gerrit_cq_ability { 21 | committer_list: "project-libyuv-committers" 22 | dry_run_access_list: "project-libyuv-tryjob-access" 23 | } 24 | 25 | try_job { 26 | buckets { 27 | name: "master.tryserver.libyuv" 28 | builders { name: "win" } 29 | builders { name: "win_rel" } 30 | builders { name: "win_x64_rel" } 31 | builders { name: "win_clang" } 32 | builders { name: "win_clang_rel" } 33 | builders { name: "win_x64_clang_rel" } 34 | builders { name: "mac" } 35 | builders { name: "mac_rel" } 36 | builders { name: "mac_asan" } 37 | builders { name: "ios" } 38 | builders { name: "ios_rel" } 39 | builders { name: "ios_arm64" } 40 | builders { name: "ios_arm64_rel" } 41 | builders { name: "linux" } 42 | builders { name: "linux_rel" } 43 | builders { 44 | name: "linux_gcc" 45 | experiment_percentage: 100 46 | } 47 | builders { name: "linux_memcheck" } 48 | builders { name: "linux_tsan2" } 49 | builders { name: "linux_asan" } 50 | builders { name: "linux_msan" } 51 | builders { name: "linux_ubsan" } 52 | builders { name: "linux_ubsan_vptr" } 53 | builders { name: "android" } 54 | builders { name: "android_rel" } 55 | builders { name: "android_clang" } 56 | builders { name: "android_arm64" } 57 | builders { name: "android_x86" } 58 | builders { name: "android_x64" } 59 | builders { 60 | name: "android_mips" 61 | experiment_percentage: 100 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/libyuv.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | import("//build_overrides/build.gni") 10 | import("//build/config/arm.gni") 11 | import("//build/config/mips.gni") 12 | 13 | declare_args() { 14 | libyuv_include_tests = !build_with_chromium 15 | libyuv_disable_jpeg = false 16 | libyuv_use_neon = (current_cpu == "arm64" || 17 | (current_cpu == "arm" && (arm_use_neon || arm_optionally_use_neon))) 18 | libyuv_use_msa = (current_cpu == "mips64el" || current_cpu == "mipsel") && 19 | mips_use_msa 20 | } 21 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/libyuv.gyp: -------------------------------------------------------------------------------- 1 | # Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'includes': [ 11 | 'libyuv.gypi', 12 | ], 13 | # Make sure that if we are being compiled to an xcodeproj, nothing tries to 14 | # include a .pch. 15 | 'xcode_settings': { 16 | 'GCC_PREFIX_HEADER': '', 17 | 'GCC_PRECOMPILE_PREFIX_HEADER': 'NO', 18 | }, 19 | 'variables': { 20 | 'use_system_libjpeg%': 0, 21 | # Can be enabled if your jpeg has GYP support. 22 | 'libyuv_disable_jpeg%': 1, 23 | # 'chromium_code' treats libyuv as internal and increases warning level. 24 | 'chromium_code': 1, 25 | # clang compiler default variable usable by other apps that include libyuv. 26 | 'clang%': 0, 27 | # Link-Time Optimizations. 28 | 'use_lto%': 0, 29 | 'mips_msa%': 0, # Default to msa off. 30 | 'build_neon': 0, 31 | 'build_msa': 0, 32 | 'conditions': [ 33 | ['(target_arch == "armv7" or target_arch == "armv7s" or \ 34 | (target_arch == "arm" and arm_version >= 7) or target_arch == "arm64")\ 35 | and (arm_neon == 1 or arm_neon_optional == 1)', { 36 | 'build_neon': 1, 37 | }], 38 | ['(target_arch == "mipsel" or target_arch == "mips64el")\ 39 | and (mips_msa == 1)', 40 | { 41 | 'build_msa': 1, 42 | }], 43 | ], 44 | }, 45 | 46 | 'targets': [ 47 | { 48 | 'target_name': 'libyuv', 49 | # Change type to 'shared_library' to build .so or .dll files. 50 | 'type': 'static_library', 51 | 'variables': { 52 | 'optimize': 'max', # enable O2 and ltcg. 53 | }, 54 | # Allows libyuv.a redistributable library without external dependencies. 55 | 'standalone_static_library': 1, 56 | 'conditions': [ 57 | # Disable -Wunused-parameter 58 | ['clang == 1', { 59 | 'cflags': [ 60 | '-Wno-unused-parameter', 61 | ], 62 | }], 63 | ['build_neon != 0', { 64 | 'defines': [ 65 | 'LIBYUV_NEON', 66 | ], 67 | 'cflags!': [ 68 | '-mfpu=vfp', 69 | '-mfpu=vfpv3', 70 | '-mfpu=vfpv3-d16', 71 | # '-mthumb', # arm32 not thumb 72 | ], 73 | 'conditions': [ 74 | # Disable LTO in libyuv_neon target due to gcc 4.9 compiler bug. 75 | ['clang == 0 and use_lto == 1', { 76 | 'cflags!': [ 77 | '-flto', 78 | '-ffat-lto-objects', 79 | ], 80 | }], 81 | # arm64 does not need -mfpu=neon option as neon is not optional 82 | ['target_arch != "arm64"', { 83 | 'cflags': [ 84 | '-mfpu=neon', 85 | # '-marm', # arm32 not thumb 86 | ], 87 | }], 88 | ], 89 | }], 90 | ['build_msa != 0', { 91 | 'defines': [ 92 | 'LIBYUV_MSA', 93 | ], 94 | }], 95 | ['OS != "ios" and libyuv_disable_jpeg != 1', { 96 | 'defines': [ 97 | 'HAVE_JPEG' 98 | ], 99 | 'conditions': [ 100 | # Caveat system jpeg support may not support motion jpeg 101 | [ 'use_system_libjpeg == 1', { 102 | 'dependencies': [ 103 | '<(DEPTH)/third_party/libjpeg/libjpeg.gyp:libjpeg', 104 | ], 105 | }, { 106 | 'dependencies': [ 107 | '<(DEPTH)/third_party/libjpeg_turbo/libjpeg.gyp:libjpeg', 108 | ], 109 | }], 110 | [ 'use_system_libjpeg == 1', { 111 | 'link_settings': { 112 | 'libraries': [ 113 | '-ljpeg', 114 | ], 115 | } 116 | }], 117 | ], 118 | }], 119 | ], #conditions 120 | 'defines': [ 121 | # Enable the following 3 macros to turn off assembly for specified CPU. 122 | # 'LIBYUV_DISABLE_X86', 123 | # 'LIBYUV_DISABLE_NEON', 124 | # 'LIBYUV_DISABLE_DSPR2', 125 | # Enable the following macro to build libyuv as a shared library (dll). 126 | # 'LIBYUV_USING_SHARED_LIBRARY', 127 | # TODO(fbarchard): Make these into gyp defines. 128 | ], 129 | 'include_dirs': [ 130 | 'include', 131 | '.', 132 | ], 133 | 'direct_dependent_settings': { 134 | 'include_dirs': [ 135 | 'include', 136 | '.', 137 | ], 138 | 'conditions': [ 139 | ['OS == "android" and target_arch == "arm64"', { 140 | 'ldflags': [ 141 | '-Wl,--dynamic-linker,/system/bin/linker64', 142 | ], 143 | }], 144 | ['OS == "android" and target_arch != "arm64"', { 145 | 'ldflags': [ 146 | '-Wl,--dynamic-linker,/system/bin/linker', 147 | ], 148 | }], 149 | ], #conditions 150 | }, 151 | 'sources': [ 152 | '<@(libyuv_sources)', 153 | ], 154 | }, 155 | ], # targets. 156 | } 157 | 158 | # Local Variables: 159 | # tab-width:2 160 | # indent-tabs-mode:nil 161 | # End: 162 | # vim: set expandtab tabstop=2 shiftwidth=2: 163 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/libyuv.gypi: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'variables': { 11 | 'libyuv_sources': [ 12 | # includes. 13 | 'include/libyuv.h', 14 | 'include/libyuv/basic_types.h', 15 | 'include/libyuv/compare.h', 16 | 'include/libyuv/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/macros_msa.h', 22 | 'include/libyuv/mjpeg_decoder.h', 23 | 'include/libyuv/planar_functions.h', 24 | 'include/libyuv/rotate.h', 25 | 'include/libyuv/rotate_argb.h', 26 | 'include/libyuv/rotate_row.h', 27 | 'include/libyuv/row.h', 28 | 'include/libyuv/scale.h', 29 | 'include/libyuv/scale_argb.h', 30 | 'include/libyuv/scale_row.h', 31 | 'include/libyuv/version.h', 32 | 'include/libyuv/video_common.h', 33 | 34 | # sources. 35 | 'source/compare.cc', 36 | 'source/compare_common.cc', 37 | 'source/compare_gcc.cc', 38 | 'source/compare_neon.cc', 39 | 'source/compare_neon64.cc', 40 | 'source/compare_win.cc', 41 | 'source/convert.cc', 42 | 'source/convert_argb.cc', 43 | 'source/convert_from.cc', 44 | 'source/convert_from_argb.cc', 45 | 'source/convert_jpeg.cc', 46 | 'source/convert_to_argb.cc', 47 | 'source/convert_to_i420.cc', 48 | 'source/cpu_id.cc', 49 | 'source/mjpeg_decoder.cc', 50 | 'source/mjpeg_validate.cc', 51 | 'source/planar_functions.cc', 52 | 'source/rotate.cc', 53 | 'source/rotate_any.cc', 54 | 'source/rotate_argb.cc', 55 | 'source/rotate_common.cc', 56 | 'source/rotate_gcc.cc', 57 | 'source/rotate_dspr2.cc', 58 | 'source/rotate_msa.cc', 59 | 'source/rotate_neon.cc', 60 | 'source/rotate_neon64.cc', 61 | 'source/rotate_win.cc', 62 | 'source/row_any.cc', 63 | 'source/row_common.cc', 64 | 'source/row_gcc.cc', 65 | 'source/row_dspr2.cc', 66 | 'source/row_msa.cc', 67 | 'source/row_neon.cc', 68 | 'source/row_neon64.cc', 69 | 'source/row_win.cc', 70 | 'source/scale.cc', 71 | 'source/scale_any.cc', 72 | 'source/scale_argb.cc', 73 | 'source/scale_common.cc', 74 | 'source/scale_gcc.cc', 75 | 'source/scale_dspr2.cc', 76 | 'source/scale_msa.cc', 77 | 'source/scale_neon.cc', 78 | 'source/scale_neon64.cc', 79 | 'source/scale_win.cc', 80 | 'source/video_common.cc', 81 | ], 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/libyuv_nacl.gyp: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The LibYuv Project Authors. All rights reserved. 2 | # 3 | # Use of this source code is governed by a BSD-style license 4 | # that can be found in the LICENSE file in the root of the source 5 | # tree. An additional intellectual property rights grant can be found 6 | # in the file PATENTS. All contributing project authors may 7 | # be found in the AUTHORS file in the root of the source tree. 8 | 9 | { 10 | 'includes': [ 11 | 'libyuv.gypi', 12 | '../../native_client/build/untrusted.gypi', 13 | ], 14 | 'targets': [ 15 | { 16 | 'target_name': 'libyuv_nacl', 17 | 'type': 'none', 18 | 'variables': { 19 | 'nlib_target': 'libyuv_nacl.a', 20 | 'build_glibc': 0, 21 | 'build_newlib': 0, 22 | 'build_pnacl_newlib': 1, 23 | }, 24 | 'include_dirs': [ 25 | 'include', 26 | ], 27 | 'direct_dependent_settings': { 28 | 'include_dirs': [ 29 | 'include', 30 | ], 31 | }, 32 | 'sources': [ 33 | '<@(libyuv_sources)', 34 | ], 35 | }, # target libyuv_nacl 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/linux.mk: -------------------------------------------------------------------------------- 1 | # This is a generic makefile for libyuv for gcc. 2 | # make -f linux.mk CXX=clang++ 3 | 4 | CC?=gcc 5 | CFLAGS?=-O2 -fomit-frame-pointer 6 | CFLAGS+=-Iinclude/ 7 | 8 | CXX?=g++ 9 | CXXFLAGS?=-O2 -fomit-frame-pointer 10 | CXXFLAGS+=-Iinclude/ 11 | 12 | LOCAL_OBJ_FILES := \ 13 | source/compare.o \ 14 | source/compare_common.o \ 15 | source/compare_gcc.o \ 16 | source/compare_neon64.o \ 17 | source/compare_neon.o \ 18 | source/compare_win.o \ 19 | source/convert_argb.o \ 20 | source/convert.o \ 21 | source/convert_from_argb.o \ 22 | source/convert_from.o \ 23 | source/convert_jpeg.o \ 24 | source/convert_to_argb.o \ 25 | source/convert_to_i420.o \ 26 | source/cpu_id.o \ 27 | source/mjpeg_decoder.o \ 28 | source/mjpeg_validate.o \ 29 | source/planar_functions.o \ 30 | source/rotate_any.o \ 31 | source/rotate_argb.o \ 32 | source/rotate.o \ 33 | source/rotate_common.o \ 34 | source/rotate_gcc.o \ 35 | source/rotate_dspr2.o \ 36 | source/rotate_neon64.o \ 37 | source/rotate_neon.o \ 38 | source/rotate_win.o \ 39 | source/row_any.o \ 40 | source/row_common.o \ 41 | source/row_gcc.o \ 42 | source/row_dspr2.o \ 43 | source/row_neon64.o \ 44 | source/row_neon.o \ 45 | source/row_win.o \ 46 | source/scale_any.o \ 47 | source/scale_argb.o \ 48 | source/scale.o \ 49 | source/scale_common.o \ 50 | source/scale_gcc.o \ 51 | source/scale_dspr2.o \ 52 | source/scale_neon64.o \ 53 | source/scale_neon.o \ 54 | source/scale_win.o \ 55 | source/video_common.o 56 | 57 | .cc.o: 58 | $(CXX) -c $(CXXFLAGS) $*.cc -o $*.o 59 | 60 | .c.o: 61 | $(CC) -c $(CFLAGS) $*.c -o $*.o 62 | 63 | all: libyuv.a yuvconvert cpuid psnr 64 | 65 | libyuv.a: $(LOCAL_OBJ_FILES) 66 | $(AR) $(ARFLAGS) $@ $(LOCAL_OBJ_FILES) 67 | 68 | # A C++ test utility that uses libyuv conversion. 69 | yuvconvert: util/yuvconvert.cc libyuv.a 70 | $(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/yuvconvert.cc libyuv.a 71 | 72 | # A standalone test utility 73 | psnr: util/psnr.cc 74 | $(CXX) $(CXXFLAGS) -Iutil/ -o $@ util/psnr.cc util/psnr_main.cc util/ssim.cc 75 | 76 | # A C test utility that uses libyuv conversion from C. 77 | # gcc 4.4 and older require -fno-exceptions to avoid link error on __gxx_personality_v0 78 | # CC=gcc-4.4 CXXFLAGS=-fno-exceptions CXX=g++-4.4 make -f linux.mk 79 | cpuid: util/cpuid.c libyuv.a 80 | $(CC) $(CFLAGS) -o $@ util/cpuid.c libyuv.a 81 | 82 | clean: 83 | /bin/rm -f source/*.o *.ii *.s libyuv.a convert cpuid psnr 84 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/public.mk: -------------------------------------------------------------------------------- 1 | # This file contains all the common make variables which are useful for 2 | # anyone depending on this library. 3 | # Note that dependencies on NDK are not directly listed since NDK auto adds 4 | # them. 5 | 6 | LIBYUV_INCLUDES := $(LIBYUV_PATH)/include 7 | 8 | LIBYUV_C_FLAGS := 9 | 10 | LIBYUV_CPP_FLAGS := 11 | 12 | LIBYUV_LDLIBS := 13 | LIBYUV_DEP_MODULES := 14 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/pylintrc: -------------------------------------------------------------------------------- 1 | [MESSAGES CONTROL] 2 | 3 | # Disable the message, report, category or checker with the given id(s). 4 | # TODO(kjellander): Reduce this list to as small as possible. 5 | disable=I0010,I0011,bad-continuation,broad-except,duplicate-code,eval-used,exec-used,fixme,invalid-name,missing-docstring,no-init,no-member,too-few-public-methods,too-many-ancestors,too-many-arguments,too-many-branches,too-many-function-args,too-many-instance-attributes,too-many-lines,too-many-locals,too-many-public-methods,too-many-return-statements,too-many-statements 6 | 7 | 8 | [REPORTS] 9 | 10 | # Don't write out full reports, just messages. 11 | reports=no 12 | 13 | 14 | [FORMAT] 15 | 16 | # We use two spaces for indents, instead of the usual four spaces or tab. 17 | indent-string=' ' 18 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/source/compare_common.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/basic_types.h" 12 | 13 | #include "libyuv/compare_row.h" 14 | 15 | #ifdef __cplusplus 16 | namespace libyuv { 17 | extern "C" { 18 | #endif 19 | 20 | #if ORIGINAL_OPT 21 | uint32 HammingDistance_C(const uint8* src_a, const uint8* src_b, int count) { 22 | uint32 diff = 0u; 23 | 24 | int i; 25 | for (i = 0; i < count; ++i) { 26 | int x = src_a[i] ^ src_b[i]; 27 | if (x & 1) 28 | ++diff; 29 | if (x & 2) 30 | ++diff; 31 | if (x & 4) 32 | ++diff; 33 | if (x & 8) 34 | ++diff; 35 | if (x & 16) 36 | ++diff; 37 | if (x & 32) 38 | ++diff; 39 | if (x & 64) 40 | ++diff; 41 | if (x & 128) 42 | ++diff; 43 | } 44 | return diff; 45 | } 46 | #endif 47 | 48 | // Hakmem method for hamming distance. 49 | uint32 HammingDistance_C(const uint8* src_a, const uint8* src_b, int count) { 50 | uint32 diff = 0u; 51 | 52 | int i; 53 | for (i = 0; i < count - 3; i += 4) { 54 | uint32 x = *((uint32*)src_a) ^ *((uint32*)src_b); 55 | uint32 u = x - ((x >> 1) & 0x55555555); 56 | u = ((u >> 2) & 0x33333333) + (u & 0x33333333); 57 | diff += ((((u + (u >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24); 58 | src_a += 4; 59 | src_b += 4; 60 | } 61 | return diff; 62 | } 63 | 64 | uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count) { 65 | uint32 sse = 0u; 66 | int i; 67 | for (i = 0; i < count; ++i) { 68 | int diff = src_a[i] - src_b[i]; 69 | sse += (uint32)(diff * diff); 70 | } 71 | return sse; 72 | } 73 | 74 | // hash seed of 5381 recommended. 75 | // Internal C version of HashDjb2 with int sized count for efficiency. 76 | uint32 HashDjb2_C(const uint8* src, int count, uint32 seed) { 77 | uint32 hash = seed; 78 | int i; 79 | for (i = 0; i < count; ++i) { 80 | hash += (hash << 5) + src[i]; 81 | } 82 | return hash; 83 | } 84 | 85 | #ifdef __cplusplus 86 | } // extern "C" 87 | } // namespace libyuv 88 | #endif 89 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/source/compare_neon.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/basic_types.h" 12 | 13 | #include "libyuv/compare_row.h" 14 | #include "libyuv/row.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | #if !defined(LIBYUV_DISABLE_NEON) && defined(__ARM_NEON__) && \ 22 | !defined(__aarch64__) 23 | 24 | // 256 bits at a time 25 | // uses short accumulator which restricts count to 131 KB 26 | uint32 HammingDistance_NEON(const uint8* src_a, const uint8* src_b, int count) { 27 | uint32 diff; 28 | 29 | asm volatile ( 30 | "vmov.u16 q4, #0 \n" // accumulator 31 | 32 | "1: \n" 33 | "vld1.8 {q0, q1}, [%0]! \n" 34 | "vld1.8 {q2, q3}, [%1]! \n" 35 | "veor.32 q0, q0, q2 \n" 36 | "veor.32 q1, q1, q3 \n" 37 | "vcnt.i8 q0, q0 \n" 38 | "vcnt.i8 q1, q1 \n" 39 | "subs %2, %2, #32 \n" 40 | "vadd.u8 q0, q0, q1 \n" // 16 byte counts 41 | "vpadal.u8 q4, q0 \n" // 8 shorts 42 | "bgt 1b \n" 43 | 44 | "vpaddl.u16 q0, q4 \n" // 4 ints 45 | "vpadd.u32 d0, d0, d1 \n" 46 | "vpadd.u32 d0, d0, d0 \n" 47 | "vmov.32 %3, d0[0] \n" 48 | 49 | : "+r"(src_a), 50 | "+r"(src_b), 51 | "+r"(count), 52 | "=r"(diff) 53 | : 54 | : "cc", "q0", "q1", "q2", "q3", "q4"); 55 | return diff; 56 | } 57 | 58 | uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count) { 59 | uint32 sse; 60 | asm volatile ( 61 | "vmov.u8 q8, #0 \n" 62 | "vmov.u8 q10, #0 \n" 63 | "vmov.u8 q9, #0 \n" 64 | "vmov.u8 q11, #0 \n" 65 | 66 | "1: \n" 67 | "vld1.8 {q0}, [%0]! \n" 68 | "vld1.8 {q1}, [%1]! \n" 69 | "subs %2, %2, #16 \n" 70 | "vsubl.u8 q2, d0, d2 \n" 71 | "vsubl.u8 q3, d1, d3 \n" 72 | "vmlal.s16 q8, d4, d4 \n" 73 | "vmlal.s16 q9, d6, d6 \n" 74 | "vmlal.s16 q10, d5, d5 \n" 75 | "vmlal.s16 q11, d7, d7 \n" 76 | "bgt 1b \n" 77 | 78 | "vadd.u32 q8, q8, q9 \n" 79 | "vadd.u32 q10, q10, q11 \n" 80 | "vadd.u32 q11, q8, q10 \n" 81 | "vpaddl.u32 q1, q11 \n" 82 | "vadd.u64 d0, d2, d3 \n" 83 | "vmov.32 %3, d0[0] \n" 84 | : "+r"(src_a), 85 | "+r"(src_b), 86 | "+r"(count), 87 | "=r"(sse) 88 | : 89 | : "memory", "cc", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11"); 90 | return sse; 91 | } 92 | 93 | #endif // defined(__ARM_NEON__) && !defined(__aarch64__) 94 | 95 | #ifdef __cplusplus 96 | } // extern "C" 97 | } // namespace libyuv 98 | #endif 99 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/source/compare_neon64.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/basic_types.h" 12 | 13 | #include "libyuv/compare_row.h" 14 | #include "libyuv/row.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | #if !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__) 22 | 23 | // 256 bits at a time 24 | // uses short accumulator which restricts count to 131 KB 25 | uint32 HammingDistance_NEON(const uint8* src_a, const uint8* src_b, int count) { 26 | uint32 diff; 27 | asm volatile ( 28 | "movi v4.8h, #0 \n" 29 | 30 | "1: \n" 31 | "ld1 {v0.16b, v1.16b}, [%0], #32 \n" 32 | "ld1 {v2.16b, v3.16b}, [%1], #32 \n" 33 | "eor v0.16b, v0.16b, v2.16b \n" 34 | "eor v1.16b, v1.16b, v3.16b \n" 35 | "cnt v0.16b, v0.16b \n" 36 | "cnt v1.16b, v1.16b \n" 37 | "subs %w2, %w2, #32 \n" 38 | "add v0.16b, v0.16b, v1.16b \n" 39 | "uadalp v4.8h, v0.16b \n" 40 | "b.gt 1b \n" 41 | 42 | "uaddlv s4, v4.8h \n" 43 | "fmov %w3, s4 \n" 44 | : "+r"(src_a), 45 | "+r"(src_b), 46 | "+r"(count), 47 | "=r"(diff) 48 | : 49 | : "cc", "v0", "v1", "v2", "v3", "v4"); 50 | return diff; 51 | } 52 | 53 | uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count) { 54 | uint32 sse; 55 | asm volatile ( 56 | "eor v16.16b, v16.16b, v16.16b \n" 57 | "eor v18.16b, v18.16b, v18.16b \n" 58 | "eor v17.16b, v17.16b, v17.16b \n" 59 | "eor v19.16b, v19.16b, v19.16b \n" 60 | 61 | "1: \n" 62 | "ld1 {v0.16b}, [%0], #16 \n" 63 | "ld1 {v1.16b}, [%1], #16 \n" 64 | "subs %w2, %w2, #16 \n" 65 | "usubl v2.8h, v0.8b, v1.8b \n" 66 | "usubl2 v3.8h, v0.16b, v1.16b \n" 67 | "smlal v16.4s, v2.4h, v2.4h \n" 68 | "smlal v17.4s, v3.4h, v3.4h \n" 69 | "smlal2 v18.4s, v2.8h, v2.8h \n" 70 | "smlal2 v19.4s, v3.8h, v3.8h \n" 71 | "b.gt 1b \n" 72 | 73 | "add v16.4s, v16.4s, v17.4s \n" 74 | "add v18.4s, v18.4s, v19.4s \n" 75 | "add v19.4s, v16.4s, v18.4s \n" 76 | "addv s0, v19.4s \n" 77 | "fmov %w3, s0 \n" 78 | : "+r"(src_a), 79 | "+r"(src_b), 80 | "+r"(count), 81 | "=r"(sse) 82 | : 83 | : "cc", "v0", "v1", "v2", "v3", "v16", "v17", "v18", "v19"); 84 | return sse; 85 | } 86 | 87 | #endif // !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__) 88 | 89 | #ifdef __cplusplus 90 | } // extern "C" 91 | } // namespace libyuv 92 | #endif 93 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/source/mjpeg_validate.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/mjpeg_decoder.h" 12 | 13 | #include // For memchr. 14 | 15 | #ifdef __cplusplus 16 | namespace libyuv { 17 | extern "C" { 18 | #endif 19 | 20 | // Helper function to scan for EOI marker (0xff 0xd9). 21 | static LIBYUV_BOOL ScanEOI(const uint8* sample, size_t sample_size) { 22 | if (sample_size >= 2) { 23 | const uint8* end = sample + sample_size - 1; 24 | const uint8* it = sample; 25 | while (it < end) { 26 | // TODO(fbarchard): scan for 0xd9 instead. 27 | it = static_cast(memchr(it, 0xff, end - it)); 28 | if (it == NULL) { 29 | break; 30 | } 31 | if (it[1] == 0xd9) { 32 | return LIBYUV_TRUE; // Success: Valid jpeg. 33 | } 34 | ++it; // Skip over current 0xff. 35 | } 36 | } 37 | // ERROR: Invalid jpeg end code not found. Size sample_size 38 | return LIBYUV_FALSE; 39 | } 40 | 41 | // Helper function to validate the jpeg appears intact. 42 | LIBYUV_BOOL ValidateJpeg(const uint8* sample, size_t sample_size) { 43 | // Maximum size that ValidateJpeg will consider valid. 44 | const size_t kMaxJpegSize = 0x7fffffffull; 45 | const size_t kBackSearchSize = 1024; 46 | if (sample_size < 64 || sample_size > kMaxJpegSize || !sample) { 47 | // ERROR: Invalid jpeg size: sample_size 48 | return LIBYUV_FALSE; 49 | } 50 | if (sample[0] != 0xff || sample[1] != 0xd8) { // SOI marker 51 | // ERROR: Invalid jpeg initial start code 52 | return LIBYUV_FALSE; 53 | } 54 | 55 | // Look for the End Of Image (EOI) marker near the end of the buffer. 56 | if (sample_size > kBackSearchSize) { 57 | if (ScanEOI(sample + sample_size - kBackSearchSize, kBackSearchSize)) { 58 | return LIBYUV_TRUE; // Success: Valid jpeg. 59 | } 60 | // Reduce search size for forward search. 61 | sample_size = sample_size - kBackSearchSize + 1; 62 | } 63 | // Step over SOI marker and scan for EOI. 64 | return ScanEOI(sample + 2, sample_size - 2); 65 | } 66 | 67 | #ifdef __cplusplus 68 | } // extern "C" 69 | } // namespace libyuv 70 | #endif 71 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/source/rotate_any.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/rotate.h" 12 | #include "libyuv/rotate_row.h" 13 | 14 | #include "libyuv/basic_types.h" 15 | 16 | #ifdef __cplusplus 17 | namespace libyuv { 18 | extern "C" { 19 | #endif 20 | 21 | #define TANY(NAMEANY, TPOS_SIMD, MASK) \ 22 | void NAMEANY(const uint8* src, int src_stride, uint8* dst, int dst_stride, \ 23 | int width) { \ 24 | int r = width & MASK; \ 25 | int n = width - r; \ 26 | if (n > 0) { \ 27 | TPOS_SIMD(src, src_stride, dst, dst_stride, n); \ 28 | } \ 29 | TransposeWx8_C(src + n, src_stride, dst + n * dst_stride, dst_stride, r); \ 30 | } 31 | 32 | #ifdef HAS_TRANSPOSEWX8_NEON 33 | TANY(TransposeWx8_Any_NEON, TransposeWx8_NEON, 7) 34 | #endif 35 | #ifdef HAS_TRANSPOSEWX8_SSSE3 36 | TANY(TransposeWx8_Any_SSSE3, TransposeWx8_SSSE3, 7) 37 | #endif 38 | #ifdef HAS_TRANSPOSEWX8_FAST_SSSE3 39 | TANY(TransposeWx8_Fast_Any_SSSE3, TransposeWx8_Fast_SSSE3, 15) 40 | #endif 41 | #ifdef HAS_TRANSPOSEWX8_DSPR2 42 | TANY(TransposeWx8_Any_DSPR2, TransposeWx8_DSPR2, 7) 43 | #endif 44 | #ifdef HAS_TRANSPOSEWX16_MSA 45 | TANY(TransposeWx16_Any_MSA, TransposeWx16_MSA, 15) 46 | #endif 47 | #undef TANY 48 | 49 | #define TUVANY(NAMEANY, TPOS_SIMD, MASK) \ 50 | void NAMEANY(const uint8* src, int src_stride, uint8* dst_a, \ 51 | int dst_stride_a, uint8* dst_b, int dst_stride_b, int width) { \ 52 | int r = width & MASK; \ 53 | int n = width - r; \ 54 | if (n > 0) { \ 55 | TPOS_SIMD(src, src_stride, dst_a, dst_stride_a, dst_b, dst_stride_b, n); \ 56 | } \ 57 | TransposeUVWx8_C(src + n * 2, src_stride, dst_a + n * dst_stride_a, \ 58 | dst_stride_a, dst_b + n * dst_stride_b, dst_stride_b, r); \ 59 | } 60 | 61 | #ifdef HAS_TRANSPOSEUVWX8_NEON 62 | TUVANY(TransposeUVWx8_Any_NEON, TransposeUVWx8_NEON, 7) 63 | #endif 64 | #ifdef HAS_TRANSPOSEUVWX8_SSE2 65 | TUVANY(TransposeUVWx8_Any_SSE2, TransposeUVWx8_SSE2, 7) 66 | #endif 67 | #ifdef HAS_TRANSPOSEUVWX8_DSPR2 68 | TUVANY(TransposeUVWx8_Any_DSPR2, TransposeUVWx8_DSPR2, 7) 69 | #endif 70 | #ifdef HAS_TRANSPOSEUVWX16_MSA 71 | TUVANY(TransposeUVWx16_Any_MSA, TransposeUVWx16_MSA, 7) 72 | #endif 73 | #undef TUVANY 74 | 75 | #ifdef __cplusplus 76 | } // extern "C" 77 | } // namespace libyuv 78 | #endif 79 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/source/rotate_common.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/rotate_row.h" 12 | #include "libyuv/row.h" 13 | 14 | #ifdef __cplusplus 15 | namespace libyuv { 16 | extern "C" { 17 | #endif 18 | 19 | void TransposeWx8_C(const uint8* src, 20 | int src_stride, 21 | uint8* dst, 22 | int dst_stride, 23 | int width) { 24 | int i; 25 | for (i = 0; i < width; ++i) { 26 | dst[0] = src[0 * src_stride]; 27 | dst[1] = src[1 * src_stride]; 28 | dst[2] = src[2 * src_stride]; 29 | dst[3] = src[3 * src_stride]; 30 | dst[4] = src[4 * src_stride]; 31 | dst[5] = src[5 * src_stride]; 32 | dst[6] = src[6 * src_stride]; 33 | dst[7] = src[7 * src_stride]; 34 | ++src; 35 | dst += dst_stride; 36 | } 37 | } 38 | 39 | void TransposeUVWx8_C(const uint8* src, 40 | int src_stride, 41 | uint8* dst_a, 42 | int dst_stride_a, 43 | uint8* dst_b, 44 | int dst_stride_b, 45 | int width) { 46 | int i; 47 | for (i = 0; i < width; ++i) { 48 | dst_a[0] = src[0 * src_stride + 0]; 49 | dst_b[0] = src[0 * src_stride + 1]; 50 | dst_a[1] = src[1 * src_stride + 0]; 51 | dst_b[1] = src[1 * src_stride + 1]; 52 | dst_a[2] = src[2 * src_stride + 0]; 53 | dst_b[2] = src[2 * src_stride + 1]; 54 | dst_a[3] = src[3 * src_stride + 0]; 55 | dst_b[3] = src[3 * src_stride + 1]; 56 | dst_a[4] = src[4 * src_stride + 0]; 57 | dst_b[4] = src[4 * src_stride + 1]; 58 | dst_a[5] = src[5 * src_stride + 0]; 59 | dst_b[5] = src[5 * src_stride + 1]; 60 | dst_a[6] = src[6 * src_stride + 0]; 61 | dst_b[6] = src[6 * src_stride + 1]; 62 | dst_a[7] = src[7 * src_stride + 0]; 63 | dst_b[7] = src[7 * src_stride + 1]; 64 | src += 2; 65 | dst_a += dst_stride_a; 66 | dst_b += dst_stride_b; 67 | } 68 | } 69 | 70 | void TransposeWxH_C(const uint8* src, 71 | int src_stride, 72 | uint8* dst, 73 | int dst_stride, 74 | int width, 75 | int height) { 76 | int i; 77 | for (i = 0; i < width; ++i) { 78 | int j; 79 | for (j = 0; j < height; ++j) { 80 | dst[i * dst_stride + j] = src[j * src_stride + i]; 81 | } 82 | } 83 | } 84 | 85 | void TransposeUVWxH_C(const uint8* src, 86 | int src_stride, 87 | uint8* dst_a, 88 | int dst_stride_a, 89 | uint8* dst_b, 90 | int dst_stride_b, 91 | int width, 92 | int height) { 93 | int i; 94 | for (i = 0; i < width * 2; i += 2) { 95 | int j; 96 | for (j = 0; j < height; ++j) { 97 | dst_a[j + ((i >> 1) * dst_stride_a)] = src[i + (j * src_stride)]; 98 | dst_b[j + ((i >> 1) * dst_stride_b)] = src[i + (j * src_stride) + 1]; 99 | } 100 | } 101 | } 102 | 103 | #ifdef __cplusplus 104 | } // extern "C" 105 | } // namespace libyuv 106 | #endif 107 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/source/video_common.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "libyuv/video_common.h" 12 | 13 | #ifdef __cplusplus 14 | namespace libyuv { 15 | extern "C" { 16 | #endif 17 | 18 | #define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0])) 19 | 20 | struct FourCCAliasEntry { 21 | uint32 alias; 22 | uint32 canonical; 23 | }; 24 | 25 | static const struct FourCCAliasEntry kFourCCAliases[] = { 26 | {FOURCC_IYUV, FOURCC_I420}, 27 | {FOURCC_YU12, FOURCC_I420}, 28 | {FOURCC_YU16, FOURCC_I422}, 29 | {FOURCC_YU24, FOURCC_I444}, 30 | {FOURCC_YUYV, FOURCC_YUY2}, 31 | {FOURCC_YUVS, FOURCC_YUY2}, // kCMPixelFormat_422YpCbCr8_yuvs 32 | {FOURCC_HDYC, FOURCC_UYVY}, 33 | {FOURCC_2VUY, FOURCC_UYVY}, // kCMPixelFormat_422YpCbCr8 34 | {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not. 35 | {FOURCC_DMB1, FOURCC_MJPG}, 36 | {FOURCC_BA81, FOURCC_BGGR}, // deprecated. 37 | {FOURCC_RGB3, FOURCC_RAW}, 38 | {FOURCC_BGR3, FOURCC_24BG}, 39 | {FOURCC_CM32, FOURCC_BGRA}, // kCMPixelFormat_32ARGB 40 | {FOURCC_CM24, FOURCC_RAW}, // kCMPixelFormat_24RGB 41 | {FOURCC_L555, FOURCC_RGBO}, // kCMPixelFormat_16LE555 42 | {FOURCC_L565, FOURCC_RGBP}, // kCMPixelFormat_16LE565 43 | {FOURCC_5551, FOURCC_RGBO}, // kCMPixelFormat_16LE5551 44 | }; 45 | // TODO(fbarchard): Consider mapping kCMPixelFormat_32BGRA to FOURCC_ARGB. 46 | // {FOURCC_BGRA, FOURCC_ARGB}, // kCMPixelFormat_32BGRA 47 | 48 | LIBYUV_API 49 | uint32 CanonicalFourCC(uint32 fourcc) { 50 | int i; 51 | for (i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) { 52 | if (kFourCCAliases[i].alias == fourcc) { 53 | return kFourCCAliases[i].canonical; 54 | } 55 | } 56 | // Not an alias, so return it as-is. 57 | return fourcc; 58 | } 59 | 60 | #ifdef __cplusplus 61 | } // extern "C" 62 | } // namespace libyuv 63 | #endif 64 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/OWNERS: -------------------------------------------------------------------------------- 1 | kjellander@chromium.org 2 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/roll_deps_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright 2017 The LibYuv Project Authors. All rights reserved. 3 | # 4 | # Use of this source code is governed by a BSD-style license 5 | # that can be found in the LICENSE file in the root of the source 6 | # tree. An additional intellectual property rights grant can be found 7 | # in the file PATENTS. All contributing project authors may 8 | # be found in the AUTHORS file in the root of the source tree. 9 | 10 | import glob 11 | import os 12 | import shutil 13 | import sys 14 | import tempfile 15 | import unittest 16 | 17 | 18 | SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 19 | PARENT_DIR = os.path.join(SCRIPT_DIR, os.pardir) 20 | sys.path.append(PARENT_DIR) 21 | import roll_deps 22 | from roll_deps import CalculateChangedDeps, GetMatchingDepsEntries, \ 23 | ParseDepsDict, ParseLocalDepsFile, UpdateDepsFile 24 | 25 | 26 | TEST_DATA_VARS = { 27 | 'chromium_git': 'https://chromium.googlesource.com', 28 | 'chromium_revision': '1b9c098a08e40114e44b6c1ec33ddf95c40b901d', 29 | } 30 | 31 | DEPS_ENTRIES = { 32 | 'src/build': 'https://build.com', 33 | 'src/buildtools': 'https://buildtools.com', 34 | 'src/testing/gtest': 'https://gtest.com', 35 | 'src/testing/gmock': 'https://gmock.com', 36 | } 37 | 38 | BUILD_OLD_REV = '52f7afeca991d96d68cf0507e20dbdd5b845691f' 39 | BUILD_NEW_REV = 'HEAD' 40 | BUILDTOOLS_OLD_REV = '64e38f0cebdde27aa0cfb405f330063582f9ac76' 41 | BUILDTOOLS_NEW_REV = '55ad626b08ef971fd82a62b7abb325359542952b' 42 | 43 | 44 | class TestError(Exception): 45 | pass 46 | 47 | 48 | class FakeCmd(object): 49 | def __init__(self): 50 | self.expectations = [] 51 | 52 | def add_expectation(self, *args, **kwargs): 53 | returns = kwargs.pop('_returns', None) 54 | self.expectations.append((args, kwargs, returns)) 55 | 56 | def __call__(self, *args, **kwargs): 57 | if not self.expectations: 58 | raise TestError('Got unexpected\n%s\n%s' % (args, kwargs)) 59 | exp_args, exp_kwargs, exp_returns = self.expectations.pop(0) 60 | if args != exp_args or kwargs != exp_kwargs: 61 | message = 'Expected:\n args: %s\n kwargs: %s\n' % (exp_args, exp_kwargs) 62 | message += 'Got:\n args: %s\n kwargs: %s\n' % (args, kwargs) 63 | raise TestError(message) 64 | return exp_returns 65 | 66 | 67 | class TestRollChromiumRevision(unittest.TestCase): 68 | def setUp(self): 69 | self._output_dir = tempfile.mkdtemp() 70 | for test_file in glob.glob(os.path.join(SCRIPT_DIR, 'testdata', '*')): 71 | shutil.copy(test_file, self._output_dir) 72 | self._libyuv_depsfile = os.path.join(self._output_dir, 'DEPS') 73 | self._old_cr_depsfile = os.path.join(self._output_dir, 'DEPS.chromium.old') 74 | self._new_cr_depsfile = os.path.join(self._output_dir, 'DEPS.chromium.new') 75 | 76 | self.fake = FakeCmd() 77 | self.old_RunCommand = getattr(roll_deps, '_RunCommand') 78 | setattr(roll_deps, '_RunCommand', self.fake) 79 | 80 | def tearDown(self): 81 | shutil.rmtree(self._output_dir, ignore_errors=True) 82 | self.assertEqual(self.fake.expectations, []) 83 | setattr(roll_deps, '_RunCommand', self.old_RunCommand) 84 | 85 | def testUpdateDepsFile(self): 86 | new_rev = 'aaaaabbbbbcccccdddddeeeeefffff0000011111' 87 | 88 | current_rev = TEST_DATA_VARS['chromium_revision'] 89 | UpdateDepsFile(self._libyuv_depsfile, current_rev, new_rev, []) 90 | with open(self._libyuv_depsfile) as deps_file: 91 | deps_contents = deps_file.read() 92 | self.assertTrue(new_rev in deps_contents, 93 | 'Failed to find %s in\n%s' % (new_rev, deps_contents)) 94 | 95 | def testParseDepsDict(self): 96 | with open(self._libyuv_depsfile) as deps_file: 97 | deps_contents = deps_file.read() 98 | local_scope = ParseDepsDict(deps_contents) 99 | vars_dict = local_scope['vars'] 100 | 101 | def assertVar(variable_name): 102 | self.assertEquals(vars_dict[variable_name], TEST_DATA_VARS[variable_name]) 103 | assertVar('chromium_git') 104 | assertVar('chromium_revision') 105 | self.assertEquals(len(local_scope['deps']), 3) 106 | 107 | def testGetMatchingDepsEntriesReturnsPathInSimpleCase(self): 108 | entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing/gtest') 109 | self.assertEquals(len(entries), 1) 110 | self.assertEquals(entries[0], DEPS_ENTRIES['src/testing/gtest']) 111 | 112 | def testGetMatchingDepsEntriesHandlesSimilarStartingPaths(self): 113 | entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing') 114 | self.assertEquals(len(entries), 2) 115 | 116 | def testGetMatchingDepsEntriesHandlesTwoPathsWithIdenticalFirstParts(self): 117 | entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/build') 118 | self.assertEquals(len(entries), 1) 119 | self.assertEquals(entries[0], DEPS_ENTRIES['src/build']) 120 | 121 | def testCalculateChangedDeps(self): 122 | _SetupGitLsRemoteCall(self.fake, 123 | 'https://chromium.googlesource.com/chromium/src/build', BUILD_NEW_REV) 124 | libyuv_deps = ParseLocalDepsFile(self._libyuv_depsfile) 125 | new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile) 126 | changed_deps = CalculateChangedDeps(libyuv_deps, new_cr_deps) 127 | self.assertEquals(len(changed_deps), 2) 128 | self.assertEquals(changed_deps[0].path, 'src/build') 129 | self.assertEquals(changed_deps[0].current_rev, BUILD_OLD_REV) 130 | self.assertEquals(changed_deps[0].new_rev, BUILD_NEW_REV) 131 | 132 | self.assertEquals(changed_deps[1].path, 'src/buildtools') 133 | self.assertEquals(changed_deps[1].current_rev, BUILDTOOLS_OLD_REV) 134 | self.assertEquals(changed_deps[1].new_rev, BUILDTOOLS_NEW_REV) 135 | 136 | 137 | def _SetupGitLsRemoteCall(cmd_fake, url, revision): 138 | cmd = ['git', 'ls-remote', url, revision] 139 | cmd_fake.add_expectation(cmd, _returns=(revision, None)) 140 | 141 | 142 | if __name__ == '__main__': 143 | unittest.main() 144 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS: -------------------------------------------------------------------------------- 1 | # DEPS file for unit tests. 2 | 3 | vars = { 4 | 'chromium_git': 'https://chromium.googlesource.com', 5 | 'chromium_revision': '1b9c098a08e40114e44b6c1ec33ddf95c40b901d', 6 | } 7 | 8 | deps = { 9 | # Entry that is a directory in Chromium, so we're using a Git subtree mirror for it. 10 | 'src/build': 11 | Var('chromium_git') + '/chromium/src/build' + '@' + '52f7afeca991d96d68cf0507e20dbdd5b845691f', 12 | 13 | # Entry that's also a DEPS entry in the Chromium DEPS file. 14 | 'src/buildtools': 15 | Var('chromium_git') + '/chromium/buildtools.git' + '@' + '64e38f0cebdde27aa0cfb405f330063582f9ac76', 16 | 17 | # Entry only present in libyuv, not Chromium. 18 | 'src/third_party/gflags/src': 19 | Var('chromium_git') + '/external/github.com/gflags/gflags@03bebcb065c83beff83d50ae025a55a4bf94dfca', 20 | } 21 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new: -------------------------------------------------------------------------------- 1 | # DEPS file for unit tests. 2 | 3 | vars = { 4 | 'chromium_git': 'https://chromium.googlesource.com', 5 | 6 | # This is updated compared to the DEPS.chromium.old file. 7 | 'buildtools_revision': '55ad626b08ef971fd82a62b7abb325359542952b', 8 | } 9 | 10 | deps = { 11 | 'src/buildtools': 12 | Var('chromium_git') + '/chromium/buildtools.git' + '@' + Var('buildtools_revision'), 13 | } 14 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old: -------------------------------------------------------------------------------- 1 | # DEPS file for unit tests. 2 | 3 | vars = { 4 | 'chromium_git': 'https://chromium.googlesource.com', 5 | 6 | # This is and older revision than DEPS.chromium.new file. 7 | 'buildtools_revision': '64e38f0cebdde27aa0cfb405f330063582f9ac76', 8 | } 9 | 10 | deps = { 11 | 'src/buildtools': 12 | Var('chromium_git') + '/chromium/buildtools.git' + '@' + Var('buildtools_revision'), 13 | } 14 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/get_landmines.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 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 | This file emits the list of reasons why a particular build needs to be clobbered 12 | (or a list of 'landmines'). 13 | """ 14 | 15 | import os 16 | import sys 17 | 18 | script_dir = os.path.dirname(os.path.realpath(__file__)) 19 | checkout_root = os.path.abspath(os.path.join(script_dir, os.pardir)) 20 | sys.path.insert(0, os.path.join(checkout_root, 'build')) 21 | import landmine_utils 22 | 23 | 24 | distributor = landmine_utils.distributor 25 | gyp_defines = landmine_utils.gyp_defines 26 | gyp_msvs_version = landmine_utils.gyp_msvs_version 27 | platform = landmine_utils.platform 28 | 29 | 30 | def print_landmines(): 31 | """ 32 | ALL LANDMINES ARE EMITTED FROM HERE. 33 | """ 34 | # DO NOT add landmines as part of a regular CL. Landmines are a last-effort 35 | # bandaid fix if a CL that got landed has a build dependency bug and all bots 36 | # need to be cleaned up. If you're writing a new CL that causes build 37 | # dependency problems, fix the dependency problems instead of adding a 38 | # landmine. 39 | # See the Chromium version in src/build/get_landmines.py for usage examples. 40 | print 'Clobber to remove GYP artifacts after switching bots to GN.' 41 | print 'Another try to remove GYP artifacts after switching bots to GN.' 42 | 43 | 44 | def main(): 45 | print_landmines() 46 | return 0 47 | 48 | 49 | if __name__ == '__main__': 50 | sys.exit(main()) 51 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/msan/OWNERS: -------------------------------------------------------------------------------- 1 | pbos@chromium.org 2 | kjellander@chromium.org 3 | 4 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/msan/blacklist.txt: -------------------------------------------------------------------------------- 1 | # The rules in this file are only applied at compile time. 2 | # Because the Chrome buildsystem does not automatically touch the files 3 | # mentioned here, changing this file requires clobbering all MSan bots. 4 | # 5 | # Please think twice before you add or remove these rules. 6 | 7 | # This is a stripped down copy of Chromium's blacklist.txt, to enable 8 | # adding libyuv-specific blacklist entries. 9 | 10 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/ubsan/OWNERS: -------------------------------------------------------------------------------- 1 | pbos@webrtc.org 2 | kjellander@webrtc.org 3 | fbarchard@chromium.org 4 | 5 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/ubsan/blacklist.txt: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # UBSan blacklist. 3 | # Please think twice before you add or remove these rules. 4 | 5 | # This is a stripped down copy of Chromium's blacklist.txt, to enable 6 | # adding WebRTC-specific blacklist entries. 7 | 8 | ############################################################################# 9 | # YASM does some funny things that UBsan doesn't like. 10 | # https://crbug.com/489901 11 | src:*/third_party/yasm/* 12 | 13 | ############################################################################# 14 | # Ignore system libraries. 15 | src:*/usr/* 16 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/ubsan/vptr_blacklist.txt: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # UBSan vptr blacklist. 3 | # Function and type based blacklisting use a mangled name, and it is especially 4 | # tricky to represent C++ types. For now, any possible changes by name manglings 5 | # are simply represented as wildcard expressions of regexp, and thus it might be 6 | # over-blacklisted. 7 | # 8 | # Please think twice before you add or remove these rules. 9 | # 10 | # This is a stripped down copy of Chromium's vptr_blacklist.txt, to enable 11 | # adding libyuv-specific blacklist entries. 12 | 13 | ############################################################################# 14 | # Using raw pointer values. 15 | # 16 | # A raw pointer value (16) is used to infer the field offset by 17 | # GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET. 18 | 19 | # Example: 20 | # src:*/third_party/protobuf/src/google/protobuf/compiler/plugin.pb.cc 21 | 22 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/valgrind/libyuv_tests.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: Copyright (c) 2012 The LibYuv Project Authors. All rights reserved. 3 | :: 4 | :: Use of this source code is governed by a BSD-style license 5 | :: that can be found in the LICENSE file in the root of the source 6 | :: tree. An additional intellectual property rights grant can be found 7 | :: in the file PATENTS. All contributing project authors may 8 | :: be found in the AUTHORS file in the root of the source tree. 9 | 10 | :: This script is a copy of chrome_tests.bat with the following changes: 11 | :: - Invokes libyuv_tests.py instead of chrome_tests.py 12 | :: - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make 13 | :: it possible to execute the Python scripts properly. 14 | 15 | :: TODO(timurrrr): batch files 'export' all the variables to the parent shell 16 | set THISDIR=%~dp0 17 | set TOOL_NAME="unknown" 18 | 19 | :: Get the tool name and put it into TOOL_NAME {{{1 20 | :: NB: SHIFT command doesn't modify %* 21 | :PARSE_ARGS_LOOP 22 | if %1 == () GOTO:TOOLNAME_NOT_FOUND 23 | if %1 == --tool GOTO:TOOLNAME_FOUND 24 | SHIFT 25 | goto :PARSE_ARGS_LOOP 26 | 27 | :TOOLNAME_NOT_FOUND 28 | echo "Please specify a tool (tsan or drmemory) by using --tool flag" 29 | exit /B 1 30 | 31 | :TOOLNAME_FOUND 32 | SHIFT 33 | set TOOL_NAME=%1 34 | :: }}} 35 | if "%TOOL_NAME%" == "drmemory" GOTO :SETUP_DRMEMORY 36 | if "%TOOL_NAME%" == "drmemory_light" GOTO :SETUP_DRMEMORY 37 | if "%TOOL_NAME%" == "drmemory_full" GOTO :SETUP_DRMEMORY 38 | if "%TOOL_NAME%" == "drmemory_pattern" GOTO :SETUP_DRMEMORY 39 | if "%TOOL_NAME%" == "tsan" GOTO :SETUP_TSAN 40 | echo "Unknown tool: `%TOOL_NAME%`! Only tsan and drmemory are supported." 41 | exit /B 1 42 | 43 | :SETUP_DRMEMORY 44 | if NOT "%DRMEMORY_COMMAND%"=="" GOTO :RUN_TESTS 45 | :: Set up DRMEMORY_COMMAND to invoke Dr. Memory {{{1 46 | set DRMEMORY_PATH=%THISDIR%..\..\third_party\drmemory 47 | set DRMEMORY_SFX=%DRMEMORY_PATH%\drmemory-windows-sfx.exe 48 | if EXIST %DRMEMORY_SFX% GOTO DRMEMORY_BINARY_OK 49 | echo "Can't find Dr. Memory executables." 50 | echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory" 51 | echo "for the instructions on how to get them." 52 | exit /B 1 53 | 54 | :DRMEMORY_BINARY_OK 55 | %DRMEMORY_SFX% -o%DRMEMORY_PATH%\unpacked -y 56 | set DRMEMORY_COMMAND=%DRMEMORY_PATH%\unpacked\bin\drmemory.exe 57 | :: }}} 58 | goto :RUN_TESTS 59 | 60 | :SETUP_TSAN 61 | :: Set up PIN_COMMAND to invoke TSan {{{1 62 | set TSAN_PATH=%THISDIR%..\..\third_party\tsan 63 | set TSAN_SFX=%TSAN_PATH%\tsan-x86-windows-sfx.exe 64 | if EXIST %TSAN_SFX% GOTO TSAN_BINARY_OK 65 | echo "Can't find ThreadSanitizer executables." 66 | echo "See http://www.chromium.org/developers/how-tos/using-valgrind/threadsanitizer/threadsanitizer-on-windows" 67 | echo "for the instructions on how to get them." 68 | exit /B 1 69 | 70 | :TSAN_BINARY_OK 71 | %TSAN_SFX% -o%TSAN_PATH%\unpacked -y 72 | set PIN_COMMAND=%TSAN_PATH%\unpacked\tsan-x86-windows\tsan.bat 73 | :: }}} 74 | goto :RUN_TESTS 75 | 76 | :RUN_TESTS 77 | set PYTHONPATH=%THISDIR%..\python\google;%THISDIR%..\valgrind 78 | set RUNNING_ON_VALGRIND=yes 79 | python %THISDIR%libyuv_tests.py %* 80 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/valgrind/libyuv_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2012 The LibYuv Project Authors. All rights reserved. 3 | # 4 | # Use of this source code is governed by a BSD-style license 5 | # that can be found in the LICENSE file in the root of the source 6 | # tree. An additional intellectual property rights grant can be found 7 | # in the file PATENTS. All contributing project authors may 8 | # be found in the AUTHORS file in the root of the source tree. 9 | 10 | # Set up some paths and re-direct the arguments to libyuv_tests.py 11 | 12 | # This script is a copy of the chrome_tests.sh wrapper script with the following 13 | # changes: 14 | # - The locate_valgrind.sh of Chromium's Valgrind scripts dir is used to locate 15 | # the Valgrind framework install. If it fails a fallback path is used instead 16 | # (../../chromium/src/third_party/valgrind/linux_x64) and a warning message 17 | # is showed by |show_locate_valgrind_failed_warning|. 18 | # - libyuv_tests.py is invoked instead of chrome_tests.py. 19 | # - Chromium's Valgrind scripts directory is added to the PYTHONPATH to make it 20 | # possible to execute the Python scripts properly. 21 | 22 | export THISDIR=`dirname $0` 23 | ARGV_COPY="$@" 24 | 25 | # We need to set CHROME_VALGRIND iff using Memcheck: 26 | # tools_libyuv/valgrind/libyuv_tests.sh --tool memcheck 27 | # or 28 | # tools_libyuv/valgrind/libyuv_tests.sh --tool=memcheck 29 | tool="memcheck" # Default to memcheck. 30 | while (( "$#" )) 31 | do 32 | if [[ "$1" == "--tool" ]] 33 | then 34 | tool="$2" 35 | shift 36 | elif [[ "$1" =~ --tool=(.*) ]] 37 | then 38 | tool="${BASH_REMATCH[1]}" 39 | fi 40 | shift 41 | done 42 | 43 | NEEDS_VALGRIND=0 44 | 45 | case "$tool" in 46 | "memcheck") 47 | NEEDS_VALGRIND=1 48 | ;; 49 | esac 50 | 51 | # For libyuv, we'll use the locate_valgrind.sh script in Chromium's Valgrind 52 | # scripts dir to locate the Valgrind framework install 53 | CHROME_VALGRIND_SCRIPTS=$THISDIR/../../tools/valgrind 54 | 55 | if [ "$NEEDS_VALGRIND" == "1" ] 56 | then 57 | CHROME_VALGRIND=`sh $CHROME_VALGRIND_SCRIPTS/locate_valgrind.sh` 58 | if [ "$CHROME_VALGRIND" = "" ] 59 | then 60 | CHROME_VALGRIND=../../src/third_party/valgrind/linux_x64 61 | echo 62 | echo "-------------------- WARNING ------------------------" 63 | echo "locate_valgrind.sh failed." 64 | echo "Using $CHROME_VALGRIND as a fallback location." 65 | echo "This might be because:" 66 | echo "1) This is a swarming bot" 67 | echo "2) You haven't set up the valgrind binaries correctly." 68 | echo "In this case, please make sure you have followed the instructions at" 69 | echo "http://www.chromium.org/developers/how-tos/using-valgrind/get-valgrind" 70 | echo "Notice: In the .gclient file, you need to add this for the 'libyuv'" 71 | echo "solution since our directory structure is different from Chromium's:" 72 | echo "\"custom_deps\": {" 73 | echo " \"libyuv/third_party/valgrind\":" 74 | echo " \"https://chromium.googlesource.com/chromium/deps/valgrind/binaries\"," 75 | echo "}," 76 | echo "-----------------------------------------------------" 77 | echo 78 | fi 79 | echo "Using valgrind binaries from ${CHROME_VALGRIND}" 80 | 81 | PATH="${CHROME_VALGRIND}/bin:$PATH" 82 | # We need to set these variables to override default lib paths hard-coded into 83 | # Valgrind binary. 84 | export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind" 85 | export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind" 86 | 87 | # Clean up some /tmp directories that might be stale due to interrupted 88 | # chrome_tests.py execution. 89 | # FYI: 90 | # -mtime +1 <- only print files modified more than 24h ago, 91 | # -print0/-0 are needed to handle possible newlines in the filenames. 92 | echo "Cleanup /tmp from Valgrind stuff" 93 | find /tmp -maxdepth 1 \(\ 94 | -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \ 95 | \) -mtime +1 -print0 | xargs -0 rm -rf 96 | fi 97 | 98 | # Add Chrome's Valgrind scripts dir to the PYTHON_PATH since it contains 99 | # the scripts that are needed for this script to run 100 | PYTHONPATH=$THISDIR/../../tools/python/google:$CHROME_VALGRIND_SCRIPTS python \ 101 | "$THISDIR/libyuv_tests.py" $ARGV_COPY 102 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/valgrind/memcheck/OWNERS: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/valgrind/memcheck/PRESUBMIT.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) 2012 The LibYuv Project Authors. All rights reserved. 3 | # 4 | # Use of this source code is governed by a BSD-style license 5 | # that can be found in the LICENSE file in the root of the source 6 | # tree. An additional intellectual property rights grant can be found 7 | # in the file PATENTS. All contributing project authors may 8 | # be found in the AUTHORS file in the root of the source tree. 9 | 10 | """ 11 | Copied from Chrome's src/tools/valgrind/memcheck/PRESUBMIT.py 12 | 13 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 14 | for more details on the presubmit API built into gcl. 15 | """ 16 | 17 | import os 18 | import re 19 | import sys 20 | 21 | def CheckChange(input_api, output_api): 22 | """Checks the memcheck suppressions files for bad data.""" 23 | 24 | # Add the path to the Chrome valgrind dir to the import path: 25 | tools_vg_path = os.path.join(input_api.PresubmitLocalPath(), '..', '..', '..', 26 | 'tools', 'valgrind') 27 | sys.path.append(tools_vg_path) 28 | import suppressions 29 | 30 | sup_regex = re.compile('suppressions.*\.txt$') 31 | suppressions = {} 32 | errors = [] 33 | check_for_memcheck = False 34 | # skip_next_line has 3 possible values: 35 | # - False: don't skip the next line. 36 | # - 'skip_suppression_name': the next line is a suppression name, skip. 37 | # - 'skip_param': the next line is a system call parameter error, skip. 38 | skip_next_line = False 39 | for f in filter(lambda x: sup_regex.search(x.LocalPath()), 40 | input_api.AffectedFiles()): 41 | for line, line_num in zip(f.NewContents(), 42 | xrange(1, len(f.NewContents()) + 1)): 43 | line = line.lstrip() 44 | if line.startswith('#') or not line: 45 | continue 46 | 47 | if skip_next_line: 48 | if skip_next_line == 'skip_suppression_name': 49 | if 'insert_a_suppression_name_here' in line: 50 | errors.append('"insert_a_suppression_name_here" is not a valid ' 51 | 'suppression name') 52 | if suppressions.has_key(line): 53 | if f.LocalPath() == suppressions[line][1]: 54 | errors.append('suppression with name "%s" at %s line %s ' 55 | 'has already been defined at line %s' % 56 | (line, f.LocalPath(), line_num, 57 | suppressions[line][1])) 58 | else: 59 | errors.append('suppression with name "%s" at %s line %s ' 60 | 'has already been defined at %s line %s' % 61 | (line, f.LocalPath(), line_num, 62 | suppressions[line][0], suppressions[line][1])) 63 | else: 64 | suppressions[line] = (f, line_num) 65 | check_for_memcheck = True; 66 | skip_next_line = False 67 | continue 68 | if check_for_memcheck: 69 | if not line.startswith('Memcheck:'): 70 | errors.append('"%s" should be "Memcheck:..." in %s line %s' % 71 | (line, f.LocalPath(), line_num)) 72 | check_for_memcheck = False; 73 | if line == '{': 74 | skip_next_line = 'skip_suppression_name' 75 | continue 76 | if line == "Memcheck:Param": 77 | skip_next_line = 'skip_param' 78 | continue 79 | 80 | if (line.startswith('fun:') or line.startswith('obj:') or 81 | line.startswith('Memcheck:') or line == '}' or 82 | line == '...'): 83 | continue 84 | errors.append('"%s" is probably wrong: %s line %s' % (line, f.LocalPath(), 85 | line_num)) 86 | if errors: 87 | return [output_api.PresubmitError('\n'.join(errors))] 88 | return [] 89 | 90 | def CheckChangeOnUpload(input_api, output_api): 91 | return CheckChange(input_api, output_api) 92 | 93 | def CheckChangeOnCommit(input_api, output_api): 94 | return CheckChange(input_api, output_api) 95 | 96 | def GetPreferredTrySlaves(): 97 | # We don't have any memcheck slaves yet, so there's no use for this method. 98 | # When we have, the slave name(s) should be put into this list. 99 | return [] 100 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/valgrind/memcheck/suppressions.txt: -------------------------------------------------------------------------------- 1 | # This file is used in addition to the one already maintained in Chrome. 2 | # It acts as a place holder for future additions for this project. 3 | # It must exist for the Python wrapper script to work properly. 4 | 5 | 6 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/valgrind/memcheck/suppressions_mac.txt: -------------------------------------------------------------------------------- 1 | # This file is used in addition to the one already maintained in Chrome. 2 | # It acts as a place holder for future additions for this project. 3 | # It must exist for the Python wrapper script to work properly. 4 | 5 | 6 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/tools_libyuv/valgrind/memcheck/suppressions_win32.txt: -------------------------------------------------------------------------------- 1 | # This file is used in addition to the one already maintained in Chrome. 2 | # It acts as a place holder for future additions for this project. 3 | # It must exist for the Python wrapper script to work properly. 4 | 5 | 6 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/unit_test/basictypes_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include "../unit_test/unit_test.h" 12 | #include "libyuv/basic_types.h" 13 | 14 | namespace libyuv { 15 | 16 | TEST_F(LibYUVBaseTest, Endian) { 17 | uint16 v16 = 0x1234u; 18 | uint8 first_byte = *reinterpret_cast(&v16); 19 | #if defined(LIBYUV_LITTLE_ENDIAN) 20 | EXPECT_EQ(0x34u, first_byte); 21 | #else 22 | EXPECT_EQ(0x12u, first_byte); 23 | #endif 24 | } 25 | 26 | TEST_F(LibYUVBaseTest, SizeOfTypes) { 27 | int8 i8 = -1; 28 | uint8 u8 = 1u; 29 | int16 i16 = -1; 30 | uint16 u16 = 1u; 31 | int32 i32 = -1; 32 | uint32 u32 = 1u; 33 | int64 i64 = -1; 34 | uint64 u64 = 1u; 35 | EXPECT_EQ(1u, sizeof(i8)); 36 | EXPECT_EQ(1u, sizeof(u8)); 37 | EXPECT_EQ(2u, sizeof(i16)); 38 | EXPECT_EQ(2u, sizeof(u16)); 39 | EXPECT_EQ(4u, sizeof(i32)); 40 | EXPECT_EQ(4u, sizeof(u32)); 41 | EXPECT_EQ(8u, sizeof(i64)); 42 | EXPECT_EQ(8u, sizeof(u64)); 43 | EXPECT_GT(0, i8); 44 | EXPECT_LT(0u, u8); 45 | EXPECT_GT(0, i16); 46 | EXPECT_LT(0u, u16); 47 | EXPECT_GT(0, i32); 48 | EXPECT_LT(0u, u32); 49 | EXPECT_GT(0, i64); 50 | EXPECT_LT(0u, u64); 51 | } 52 | 53 | TEST_F(LibYUVBaseTest, SizeOfConstants) { 54 | EXPECT_EQ(8u, sizeof(INT64_C(0))); 55 | EXPECT_EQ(8u, sizeof(UINT64_C(0))); 56 | EXPECT_EQ(8u, sizeof(INT64_C(0x1234567887654321))); 57 | EXPECT_EQ(8u, sizeof(UINT64_C(0x8765432112345678))); 58 | } 59 | 60 | } // namespace libyuv 61 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/unit_test/cpu_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "../unit_test/unit_test.h" 15 | #include "libyuv/basic_types.h" 16 | #include "libyuv/cpu_id.h" 17 | #include "libyuv/version.h" 18 | 19 | namespace libyuv { 20 | 21 | TEST_F(LibYUVBaseTest, TestCpuHas) { 22 | int cpu_flags = TestCpuFlag(-1); 23 | printf("Cpu Flags %x\n", cpu_flags); 24 | int has_arm = TestCpuFlag(kCpuHasARM); 25 | printf("Has ARM %x\n", has_arm); 26 | int has_neon = TestCpuFlag(kCpuHasNEON); 27 | printf("Has NEON %x\n", has_neon); 28 | int has_x86 = TestCpuFlag(kCpuHasX86); 29 | printf("Has X86 %x\n", has_x86); 30 | int has_sse2 = TestCpuFlag(kCpuHasSSE2); 31 | printf("Has SSE2 %x\n", has_sse2); 32 | int has_ssse3 = TestCpuFlag(kCpuHasSSSE3); 33 | printf("Has SSSE3 %x\n", has_ssse3); 34 | int has_sse41 = TestCpuFlag(kCpuHasSSE41); 35 | printf("Has SSE4.1 %x\n", has_sse41); 36 | int has_sse42 = TestCpuFlag(kCpuHasSSE42); 37 | printf("Has SSE4.2 %x\n", has_sse42); 38 | int has_avx = TestCpuFlag(kCpuHasAVX); 39 | printf("Has AVX %x\n", has_avx); 40 | int has_avx2 = TestCpuFlag(kCpuHasAVX2); 41 | printf("Has AVX2 %x\n", has_avx2); 42 | int has_erms = TestCpuFlag(kCpuHasERMS); 43 | printf("Has ERMS %x\n", has_erms); 44 | int has_fma3 = TestCpuFlag(kCpuHasFMA3); 45 | printf("Has FMA3 %x\n", has_fma3); 46 | int has_avx3 = TestCpuFlag(kCpuHasAVX3); 47 | printf("Has AVX3 %x\n", has_avx3); 48 | int has_f16c = TestCpuFlag(kCpuHasF16C); 49 | printf("Has F16C %x\n", has_f16c); 50 | int has_mips = TestCpuFlag(kCpuHasMIPS); 51 | printf("Has MIPS %x\n", has_mips); 52 | int has_dspr2 = TestCpuFlag(kCpuHasDSPR2); 53 | printf("Has DSPR2 %x\n", has_dspr2); 54 | int has_msa = TestCpuFlag(kCpuHasMSA); 55 | printf("Has MSA %x\n", has_msa); 56 | } 57 | 58 | TEST_F(LibYUVBaseTest, TestCpuCompilerEnabled) { 59 | #if defined(__aarch64__) 60 | printf("Arm64 build\n"); 61 | #endif 62 | #if defined(__aarch64__) || defined(__ARM_NEON__) || defined(LIBYUV_NEON) 63 | printf("Neon build enabled\n"); 64 | #endif 65 | #if defined(__x86_64__) || defined(_M_X64) 66 | printf("x64 build\n"); 67 | #endif 68 | #ifdef _MSC_VER 69 | printf("_MSC_VER %d\n", _MSC_VER); 70 | #endif 71 | #if !defined(LIBYUV_DISABLE_X86) && \ 72 | (defined(GCC_HAS_AVX2) || defined(CLANG_HAS_AVX2) || \ 73 | defined(VISUALC_HAS_AVX2)) 74 | printf("Has AVX2 1\n"); 75 | #else 76 | printf("Has AVX2 0\n"); 77 | // If compiler does not support AVX2, the following function not expected: 78 | #endif 79 | } 80 | 81 | #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || \ 82 | defined(_M_X64) 83 | TEST_F(LibYUVBaseTest, TestCpuId) { 84 | int has_x86 = TestCpuFlag(kCpuHasX86); 85 | if (has_x86) { 86 | int cpu_info[4]; 87 | // Vendor ID: 88 | // AuthenticAMD AMD processor 89 | // CentaurHauls Centaur processor 90 | // CyrixInstead Cyrix processor 91 | // GenuineIntel Intel processor 92 | // GenuineTMx86 Transmeta processor 93 | // Geode by NSC National Semiconductor processor 94 | // NexGenDriven NexGen processor 95 | // RiseRiseRise Rise Technology processor 96 | // SiS SiS SiS SiS processor 97 | // UMC UMC UMC UMC processor 98 | CpuId(0, 0, cpu_info); 99 | cpu_info[0] = cpu_info[1]; // Reorder output 100 | cpu_info[1] = cpu_info[3]; 101 | cpu_info[3] = 0; 102 | printf("Cpu Vendor: %s %x %x %x\n", reinterpret_cast(&cpu_info[0]), 103 | cpu_info[0], cpu_info[1], cpu_info[2]); 104 | EXPECT_EQ(12u, strlen(reinterpret_cast(&cpu_info[0]))); 105 | 106 | // CPU Family and Model 107 | // 3:0 - Stepping 108 | // 7:4 - Model 109 | // 11:8 - Family 110 | // 13:12 - Processor Type 111 | // 19:16 - Extended Model 112 | // 27:20 - Extended Family 113 | CpuId(1, 0, cpu_info); 114 | int family = ((cpu_info[0] >> 8) & 0x0f) | ((cpu_info[0] >> 16) & 0xff0); 115 | int model = ((cpu_info[0] >> 4) & 0x0f) | ((cpu_info[0] >> 12) & 0xf0); 116 | printf("Cpu Family %d (0x%x), Model %d (0x%x)\n", family, family, model, 117 | model); 118 | } 119 | } 120 | #endif 121 | 122 | static int FileExists(const char* file_name) { 123 | FILE* f = fopen(file_name, "r"); 124 | if (!f) { 125 | return 0; 126 | } 127 | fclose(f); 128 | return 1; 129 | } 130 | 131 | TEST_F(LibYUVBaseTest, TestLinuxNeon) { 132 | if (FileExists("../../unit_test/testdata/arm_v7.txt")) { 133 | EXPECT_EQ(0, ArmCpuCaps("../../unit_test/testdata/arm_v7.txt")); 134 | EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/tegra3.txt")); 135 | EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("../../unit_test/testdata/juno.txt")); 136 | } else { 137 | printf("WARNING: unable to load \"../../unit_test/testdata/arm_v7.txt\"\n"); 138 | } 139 | #if defined(__linux__) && defined(__ARM_NEON__) 140 | EXPECT_EQ(kCpuHasNEON, ArmCpuCaps("/proc/cpuinfo")); 141 | #endif 142 | } 143 | 144 | } // namespace libyuv 145 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/unit_test/cpu_thread_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | 13 | #include "libyuv/cpu_id.h" 14 | 15 | #if defined(__clang__) 16 | #if __has_include() 17 | #define LIBYUV_HAVE_PTHREAD 1 18 | #endif 19 | #elif defined(__linux__) 20 | #define LIBYUV_HAVE_PTHREAD 1 21 | #endif 22 | 23 | #ifdef LIBYUV_HAVE_PTHREAD 24 | #include 25 | #endif 26 | 27 | namespace libyuv { 28 | 29 | #ifdef LIBYUV_HAVE_PTHREAD 30 | void* ThreadMain(void* arg) { 31 | int* flags = static_cast(arg); 32 | 33 | *flags = TestCpuFlag(kCpuHasSSSE3); 34 | return nullptr; 35 | } 36 | #endif // LIBYUV_HAVE_PTHREAD 37 | 38 | // Call TestCpuFlag() from two threads. ThreadSanitizer should not report any 39 | // data race. 40 | TEST(LibYUVCpuThreadTest, TestCpuFlagMultipleThreads) { 41 | #ifdef LIBYUV_HAVE_PTHREAD 42 | int cpu_flags1; 43 | int cpu_flags2; 44 | int ret; 45 | pthread_t thread1; 46 | pthread_t thread2; 47 | 48 | MaskCpuFlags(0); // Reset to 0 to allow auto detect. 49 | ret = pthread_create(&thread1, nullptr, ThreadMain, &cpu_flags1); 50 | ASSERT_EQ(ret, 0); 51 | ret = pthread_create(&thread2, nullptr, ThreadMain, &cpu_flags2); 52 | ASSERT_EQ(ret, 0); 53 | ret = pthread_join(thread1, nullptr); 54 | EXPECT_EQ(ret, 0); 55 | ret = pthread_join(thread2, nullptr); 56 | EXPECT_EQ(ret, 0); 57 | EXPECT_EQ(cpu_flags1, cpu_flags2); 58 | #else 59 | printf("pthread unavailable; Test skipped."); 60 | #endif // LIBYUV_HAVE_PTHREAD 61 | } 62 | 63 | } // namespace libyuv 64 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/unit_test/math_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "../unit_test/unit_test.h" 16 | #include "libyuv/basic_types.h" 17 | #include "libyuv/cpu_id.h" 18 | #include "libyuv/scale.h" 19 | #include "libyuv/scale_row.h" 20 | 21 | namespace libyuv { 22 | 23 | TEST_F(LibYUVBaseTest, TestFixedDiv) { 24 | int num[1280]; 25 | int div[1280]; 26 | int result_opt[1280]; 27 | int result_c[1280]; 28 | 29 | EXPECT_EQ(0x10000, libyuv::FixedDiv(1, 1)); 30 | EXPECT_EQ(0x7fff0000, libyuv::FixedDiv(0x7fff, 1)); 31 | // TODO(fbarchard): Avoid the following that throw exceptions. 32 | // EXPECT_EQ(0x100000000, libyuv::FixedDiv(0x10000, 1)); 33 | // EXPECT_EQ(0x80000000, libyuv::FixedDiv(0x8000, 1)); 34 | 35 | EXPECT_EQ(0x20000, libyuv::FixedDiv(640 * 2, 640)); 36 | EXPECT_EQ(0x30000, libyuv::FixedDiv(640 * 3, 640)); 37 | EXPECT_EQ(0x40000, libyuv::FixedDiv(640 * 4, 640)); 38 | EXPECT_EQ(0x50000, libyuv::FixedDiv(640 * 5, 640)); 39 | EXPECT_EQ(0x60000, libyuv::FixedDiv(640 * 6, 640)); 40 | EXPECT_EQ(0x70000, libyuv::FixedDiv(640 * 7, 640)); 41 | EXPECT_EQ(0x80000, libyuv::FixedDiv(640 * 8, 640)); 42 | EXPECT_EQ(0xa0000, libyuv::FixedDiv(640 * 10, 640)); 43 | EXPECT_EQ(0x20000, libyuv::FixedDiv(960 * 2, 960)); 44 | EXPECT_EQ(0x08000, libyuv::FixedDiv(640 / 2, 640)); 45 | EXPECT_EQ(0x04000, libyuv::FixedDiv(640 / 4, 640)); 46 | EXPECT_EQ(0x20000, libyuv::FixedDiv(1080 * 2, 1080)); 47 | EXPECT_EQ(0x20000, libyuv::FixedDiv(200000, 100000)); 48 | EXPECT_EQ(0x18000, libyuv::FixedDiv(150000, 100000)); 49 | EXPECT_EQ(0x20000, libyuv::FixedDiv(40000, 20000)); 50 | EXPECT_EQ(0x20000, libyuv::FixedDiv(-40000, -20000)); 51 | EXPECT_EQ(-0x20000, libyuv::FixedDiv(40000, -20000)); 52 | EXPECT_EQ(-0x20000, libyuv::FixedDiv(-40000, 20000)); 53 | EXPECT_EQ(0x10000, libyuv::FixedDiv(4095, 4095)); 54 | EXPECT_EQ(0x10000, libyuv::FixedDiv(4096, 4096)); 55 | EXPECT_EQ(0x10000, libyuv::FixedDiv(4097, 4097)); 56 | EXPECT_EQ(123 * 65536, libyuv::FixedDiv(123, 1)); 57 | 58 | for (int i = 1; i < 4100; ++i) { 59 | EXPECT_EQ(0x10000, libyuv::FixedDiv(i, i)); 60 | EXPECT_EQ(0x20000, libyuv::FixedDiv(i * 2, i)); 61 | EXPECT_EQ(0x30000, libyuv::FixedDiv(i * 3, i)); 62 | EXPECT_EQ(0x40000, libyuv::FixedDiv(i * 4, i)); 63 | EXPECT_EQ(0x08000, libyuv::FixedDiv(i, i * 2)); 64 | EXPECT_NEAR(16384 * 65536 / i, libyuv::FixedDiv(16384, i), 1); 65 | } 66 | EXPECT_EQ(123 * 65536, libyuv::FixedDiv(123, 1)); 67 | 68 | MemRandomize(reinterpret_cast(&num[0]), sizeof(num)); 69 | MemRandomize(reinterpret_cast(&div[0]), sizeof(div)); 70 | for (int j = 0; j < 1280; ++j) { 71 | if (div[j] == 0) { 72 | div[j] = 1280; 73 | } 74 | num[j] &= 0xffff; // Clamp to avoid divide overflow. 75 | } 76 | for (int i = 0; i < benchmark_pixels_div1280_; ++i) { 77 | for (int j = 0; j < 1280; ++j) { 78 | result_opt[j] = libyuv::FixedDiv(num[j], div[j]); 79 | } 80 | } 81 | for (int j = 0; j < 1280; ++j) { 82 | result_c[j] = libyuv::FixedDiv_C(num[j], div[j]); 83 | EXPECT_NEAR(result_c[j], result_opt[j], 1); 84 | } 85 | } 86 | 87 | TEST_F(LibYUVBaseTest, TestFixedDiv_Opt) { 88 | int num[1280]; 89 | int div[1280]; 90 | int result_opt[1280]; 91 | int result_c[1280]; 92 | 93 | MemRandomize(reinterpret_cast(&num[0]), sizeof(num)); 94 | MemRandomize(reinterpret_cast(&div[0]), sizeof(div)); 95 | for (int j = 0; j < 1280; ++j) { 96 | num[j] &= 4095; // Make numerator smaller. 97 | div[j] &= 4095; // Make divisor smaller. 98 | if (div[j] == 0) { 99 | div[j] = 1280; 100 | } 101 | } 102 | 103 | int has_x86 = TestCpuFlag(kCpuHasX86); 104 | for (int i = 0; i < benchmark_pixels_div1280_; ++i) { 105 | if (has_x86) { 106 | for (int j = 0; j < 1280; ++j) { 107 | result_opt[j] = libyuv::FixedDiv(num[j], div[j]); 108 | } 109 | } else { 110 | for (int j = 0; j < 1280; ++j) { 111 | result_opt[j] = libyuv::FixedDiv_C(num[j], div[j]); 112 | } 113 | } 114 | } 115 | for (int j = 0; j < 1280; ++j) { 116 | result_c[j] = libyuv::FixedDiv_C(num[j], div[j]); 117 | EXPECT_NEAR(result_c[j], result_opt[j], 1); 118 | } 119 | } 120 | 121 | TEST_F(LibYUVBaseTest, TestFixedDiv1_Opt) { 122 | int num[1280]; 123 | int div[1280]; 124 | int result_opt[1280]; 125 | int result_c[1280]; 126 | 127 | MemRandomize(reinterpret_cast(&num[0]), sizeof(num)); 128 | MemRandomize(reinterpret_cast(&div[0]), sizeof(div)); 129 | for (int j = 0; j < 1280; ++j) { 130 | num[j] &= 4095; // Make numerator smaller. 131 | div[j] &= 4095; // Make divisor smaller. 132 | if (div[j] <= 1) { 133 | div[j] = 1280; 134 | } 135 | } 136 | 137 | int has_x86 = TestCpuFlag(kCpuHasX86); 138 | for (int i = 0; i < benchmark_pixels_div1280_; ++i) { 139 | if (has_x86) { 140 | for (int j = 0; j < 1280; ++j) { 141 | result_opt[j] = libyuv::FixedDiv1(num[j], div[j]); 142 | } 143 | } else { 144 | for (int j = 0; j < 1280; ++j) { 145 | result_opt[j] = libyuv::FixedDiv1_C(num[j], div[j]); 146 | } 147 | } 148 | } 149 | for (int j = 0; j < 1280; ++j) { 150 | result_c[j] = libyuv::FixedDiv1_C(num[j], div[j]); 151 | EXPECT_NEAR(result_c[j], result_opt[j], 1); 152 | } 153 | } 154 | 155 | } // namespace libyuv 156 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/unit_test/testdata/arm_v7.txt: -------------------------------------------------------------------------------- 1 | Processor : ARMv7 Processor rev 5 (v7l) 2 | BogoMIPS : 795.44 3 | Features : swp half thumb fastmult vfp edsp iwmmxt thumbee vfpv3 vfpv3d16 4 | CPU implementer : 0x56 5 | CPU architecture: 7 6 | CPU variant : 0x0 7 | CPU part : 0x581 8 | CPU revision : 5 9 | 10 | Hardware : OLPC XO-1.75 11 | Revision : 0000 12 | Serial : 0000000000000000 13 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/unit_test/testdata/juno.txt: -------------------------------------------------------------------------------- 1 | Processor : AArch64 Processor rev 0 (aarch64) 2 | processor : 0 3 | processor : 1 4 | processor : 2 5 | processor : 3 6 | processor : 4 7 | processor : 5 8 | Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 9 | CPU implementer : 0x41 10 | CPU architecture: AArch64 11 | CPU variant : 0x0 12 | CPU part : 0xd07 13 | CPU revision : 0 14 | 15 | Hardware : Juno 16 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/unit_test/testdata/tegra3.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/cpp/libyuv/unit_test/testdata/tegra3.txt -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/unit_test/video_common_test.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "../unit_test/unit_test.h" 15 | #include "libyuv/video_common.h" 16 | 17 | namespace libyuv { 18 | 19 | // Tests FourCC codes in video common, which are used for ConvertToI420(). 20 | 21 | static bool TestValidChar(uint32 onecc) { 22 | if ((onecc >= '0' && onecc <= '9') || (onecc >= 'A' && onecc <= 'Z') || 23 | (onecc >= 'a' && onecc <= 'z') || (onecc == ' ') || (onecc == 0xff)) { 24 | return true; 25 | } 26 | return false; 27 | } 28 | 29 | static bool TestValidFourCC(uint32 fourcc, int bpp) { 30 | if (!TestValidChar(fourcc & 0xff) || !TestValidChar((fourcc >> 8) & 0xff) || 31 | !TestValidChar((fourcc >> 16) & 0xff) || 32 | !TestValidChar((fourcc >> 24) & 0xff)) { 33 | return false; 34 | } 35 | if (bpp < 0 || bpp > 32) { 36 | return false; 37 | } 38 | return true; 39 | } 40 | 41 | TEST_F(LibYUVBaseTest, TestCanonicalFourCC) { 42 | EXPECT_EQ(static_cast(FOURCC_I420), CanonicalFourCC(FOURCC_IYUV)); 43 | EXPECT_EQ(static_cast(FOURCC_I420), CanonicalFourCC(FOURCC_YU12)); 44 | EXPECT_EQ(static_cast(FOURCC_I422), CanonicalFourCC(FOURCC_YU16)); 45 | EXPECT_EQ(static_cast(FOURCC_I444), CanonicalFourCC(FOURCC_YU24)); 46 | EXPECT_EQ(static_cast(FOURCC_YUY2), CanonicalFourCC(FOURCC_YUYV)); 47 | EXPECT_EQ(static_cast(FOURCC_YUY2), CanonicalFourCC(FOURCC_YUVS)); 48 | EXPECT_EQ(static_cast(FOURCC_UYVY), CanonicalFourCC(FOURCC_HDYC)); 49 | EXPECT_EQ(static_cast(FOURCC_UYVY), CanonicalFourCC(FOURCC_2VUY)); 50 | EXPECT_EQ(static_cast(FOURCC_MJPG), CanonicalFourCC(FOURCC_JPEG)); 51 | EXPECT_EQ(static_cast(FOURCC_MJPG), CanonicalFourCC(FOURCC_DMB1)); 52 | EXPECT_EQ(static_cast(FOURCC_RAW), CanonicalFourCC(FOURCC_RGB3)); 53 | EXPECT_EQ(static_cast(FOURCC_24BG), CanonicalFourCC(FOURCC_BGR3)); 54 | EXPECT_EQ(static_cast(FOURCC_BGRA), CanonicalFourCC(FOURCC_CM32)); 55 | EXPECT_EQ(static_cast(FOURCC_RAW), CanonicalFourCC(FOURCC_CM24)); 56 | EXPECT_EQ(static_cast(FOURCC_RGBO), CanonicalFourCC(FOURCC_L555)); 57 | EXPECT_EQ(static_cast(FOURCC_RGBP), CanonicalFourCC(FOURCC_L565)); 58 | EXPECT_EQ(static_cast(FOURCC_RGBO), CanonicalFourCC(FOURCC_5551)); 59 | } 60 | 61 | TEST_F(LibYUVBaseTest, TestFourCC) { 62 | EXPECT_TRUE(TestValidFourCC(FOURCC_I420, FOURCC_BPP_I420)); 63 | EXPECT_TRUE(TestValidFourCC(FOURCC_I420, FOURCC_BPP_I420)); 64 | EXPECT_TRUE(TestValidFourCC(FOURCC_I422, FOURCC_BPP_I422)); 65 | EXPECT_TRUE(TestValidFourCC(FOURCC_I444, FOURCC_BPP_I444)); 66 | EXPECT_TRUE(TestValidFourCC(FOURCC_I400, FOURCC_BPP_I400)); 67 | EXPECT_TRUE(TestValidFourCC(FOURCC_NV21, FOURCC_BPP_NV21)); 68 | EXPECT_TRUE(TestValidFourCC(FOURCC_NV12, FOURCC_BPP_NV12)); 69 | EXPECT_TRUE(TestValidFourCC(FOURCC_YUY2, FOURCC_BPP_YUY2)); 70 | EXPECT_TRUE(TestValidFourCC(FOURCC_UYVY, FOURCC_BPP_UYVY)); 71 | EXPECT_TRUE(TestValidFourCC(FOURCC_M420, FOURCC_BPP_M420)); 72 | EXPECT_TRUE(TestValidFourCC(FOURCC_Q420, FOURCC_BPP_Q420)); // deprecated. 73 | EXPECT_TRUE(TestValidFourCC(FOURCC_ARGB, FOURCC_BPP_ARGB)); 74 | EXPECT_TRUE(TestValidFourCC(FOURCC_BGRA, FOURCC_BPP_BGRA)); 75 | EXPECT_TRUE(TestValidFourCC(FOURCC_ABGR, FOURCC_BPP_ABGR)); 76 | EXPECT_TRUE(TestValidFourCC(FOURCC_24BG, FOURCC_BPP_24BG)); 77 | EXPECT_TRUE(TestValidFourCC(FOURCC_RAW, FOURCC_BPP_RAW)); 78 | EXPECT_TRUE(TestValidFourCC(FOURCC_RGBA, FOURCC_BPP_RGBA)); 79 | EXPECT_TRUE(TestValidFourCC(FOURCC_RGBP, FOURCC_BPP_RGBP)); 80 | EXPECT_TRUE(TestValidFourCC(FOURCC_RGBO, FOURCC_BPP_RGBO)); 81 | EXPECT_TRUE(TestValidFourCC(FOURCC_R444, FOURCC_BPP_R444)); 82 | EXPECT_TRUE(TestValidFourCC(FOURCC_MJPG, FOURCC_BPP_MJPG)); 83 | EXPECT_TRUE(TestValidFourCC(FOURCC_YV12, FOURCC_BPP_YV12)); 84 | EXPECT_TRUE(TestValidFourCC(FOURCC_YV16, FOURCC_BPP_YV16)); 85 | EXPECT_TRUE(TestValidFourCC(FOURCC_YV24, FOURCC_BPP_YV24)); 86 | EXPECT_TRUE(TestValidFourCC(FOURCC_YU12, FOURCC_BPP_YU12)); 87 | EXPECT_TRUE(TestValidFourCC(FOURCC_IYUV, FOURCC_BPP_IYUV)); 88 | EXPECT_TRUE(TestValidFourCC(FOURCC_YU16, FOURCC_BPP_YU16)); 89 | EXPECT_TRUE(TestValidFourCC(FOURCC_YU24, FOURCC_BPP_YU24)); 90 | EXPECT_TRUE(TestValidFourCC(FOURCC_YUYV, FOURCC_BPP_YUYV)); 91 | EXPECT_TRUE(TestValidFourCC(FOURCC_YUVS, FOURCC_BPP_YUVS)); 92 | EXPECT_TRUE(TestValidFourCC(FOURCC_HDYC, FOURCC_BPP_HDYC)); 93 | EXPECT_TRUE(TestValidFourCC(FOURCC_2VUY, FOURCC_BPP_2VUY)); 94 | EXPECT_TRUE(TestValidFourCC(FOURCC_JPEG, FOURCC_BPP_JPEG)); 95 | EXPECT_TRUE(TestValidFourCC(FOURCC_DMB1, FOURCC_BPP_DMB1)); 96 | EXPECT_TRUE(TestValidFourCC(FOURCC_BA81, FOURCC_BPP_BA81)); 97 | EXPECT_TRUE(TestValidFourCC(FOURCC_RGB3, FOURCC_BPP_RGB3)); 98 | EXPECT_TRUE(TestValidFourCC(FOURCC_BGR3, FOURCC_BPP_BGR3)); 99 | EXPECT_TRUE(TestValidFourCC(FOURCC_H264, FOURCC_BPP_H264)); 100 | EXPECT_TRUE(TestValidFourCC(FOURCC_ANY, FOURCC_BPP_ANY)); 101 | } 102 | 103 | } // namespace libyuv 104 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/util/Makefile: -------------------------------------------------------------------------------- 1 | psnr: psnr.cc ssim.cc psnr_main.cc 2 | ifeq ($(CXX),icl) 3 | $(CXX) /arch:SSE2 /Ox /openmp psnr.cc ssim.cc psnr_main.cc 4 | else 5 | $(CXX) -msse2 -O3 -fopenmp -static -o psnr psnr.cc ssim.cc psnr_main.cc -Wl,--strip-all 6 | endif 7 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/util/compare.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "libyuv/basic_types.h" 17 | #include "libyuv/compare.h" 18 | #include "libyuv/version.h" 19 | 20 | int main(int argc, char** argv) { 21 | if (argc < 1) { 22 | printf("libyuv compare v%d\n", LIBYUV_VERSION); 23 | printf("compare file1.yuv file2.yuv\n"); 24 | return -1; 25 | } 26 | char* name1 = argv[1]; 27 | char* name2 = (argc > 2) ? argv[2] : NULL; 28 | FILE* fin1 = fopen(name1, "rb"); 29 | FILE* fin2 = name2 ? fopen(name2, "rb") : NULL; 30 | 31 | const int kBlockSize = 32768; 32 | uint8 buf1[kBlockSize]; 33 | uint8 buf2[kBlockSize]; 34 | uint32 hash1 = 5381; 35 | uint32 hash2 = 5381; 36 | uint64 sum_square_err = 0; 37 | uint64 size_min = 0; 38 | int amt1 = 0; 39 | int amt2 = 0; 40 | do { 41 | amt1 = static_cast(fread(buf1, 1, kBlockSize, fin1)); 42 | if (amt1 > 0) 43 | hash1 = libyuv::HashDjb2(buf1, amt1, hash1); 44 | if (fin2) { 45 | amt2 = static_cast(fread(buf2, 1, kBlockSize, fin2)); 46 | if (amt2 > 0) 47 | hash2 = libyuv::HashDjb2(buf2, amt2, hash2); 48 | int amt_min = (amt1 < amt2) ? amt1 : amt2; 49 | size_min += amt_min; 50 | sum_square_err += libyuv::ComputeSumSquareError(buf1, buf2, amt_min); 51 | } 52 | } while (amt1 > 0 || amt2 > 0); 53 | 54 | printf("hash1 %x", hash1); 55 | if (fin2) { 56 | printf(", hash2 %x", hash2); 57 | double mse = 58 | static_cast(sum_square_err) / static_cast(size_min); 59 | printf(", mse %.2f", mse); 60 | double psnr = libyuv::SumSquareErrorToPsnr(sum_square_err, size_min); 61 | printf(", psnr %.2f\n", psnr); 62 | fclose(fin2); 63 | } 64 | fclose(fin1); 65 | } 66 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/util/cpuid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #define INCLUDE_LIBYUV_COMPARE_H_ 16 | #include "libyuv.h" 17 | #include "./psnr.h" 18 | #include "./ssim.h" 19 | 20 | int main(int argc, const char* argv[]) { 21 | int cpu_flags = TestCpuFlag(-1); 22 | int has_arm = TestCpuFlag(kCpuHasARM); 23 | int has_mips = TestCpuFlag(kCpuHasMIPS); 24 | int has_x86 = TestCpuFlag(kCpuHasX86); 25 | #if defined(__i386__) || defined(__x86_64__) || \ 26 | defined(_M_IX86) || defined(_M_X64) 27 | if (has_x86) { 28 | int family, model, cpu_info[4]; 29 | // Vendor ID: 30 | // AuthenticAMD AMD processor 31 | // CentaurHauls Centaur processor 32 | // CyrixInstead Cyrix processor 33 | // GenuineIntel Intel processor 34 | // GenuineTMx86 Transmeta processor 35 | // Geode by NSC National Semiconductor processor 36 | // NexGenDriven NexGen processor 37 | // RiseRiseRise Rise Technology processor 38 | // SiS SiS SiS SiS processor 39 | // UMC UMC UMC UMC processor 40 | CpuId(0, 0, &cpu_info[0]); 41 | cpu_info[0] = cpu_info[1]; // Reorder output 42 | cpu_info[1] = cpu_info[3]; 43 | cpu_info[3] = 0; 44 | printf("Cpu Vendor: %s\n", (char*)(&cpu_info[0])); 45 | 46 | // CPU Family and Model 47 | // 3:0 - Stepping 48 | // 7:4 - Model 49 | // 11:8 - Family 50 | // 13:12 - Processor Type 51 | // 19:16 - Extended Model 52 | // 27:20 - Extended Family 53 | CpuId(1, 0, &cpu_info[0]); 54 | family = ((cpu_info[0] >> 8) & 0x0f) | ((cpu_info[0] >> 16) & 0xff0); 55 | model = ((cpu_info[0] >> 4) & 0x0f) | ((cpu_info[0] >> 12) & 0xf0); 56 | printf("Cpu Family %d (0x%x), Model %d (0x%x)\n", family, family, 57 | model, model); 58 | } 59 | #endif 60 | printf("Cpu Flags %x\n", cpu_flags); 61 | printf("Has ARM %x\n", has_arm); 62 | printf("Has MIPS %x\n", has_mips); 63 | printf("Has X86 %x\n", has_x86); 64 | if (has_arm) { 65 | int has_neon = TestCpuFlag(kCpuHasNEON); 66 | printf("Has NEON %x\n", has_neon); 67 | } 68 | if (has_mips) { 69 | int has_dspr2 = TestCpuFlag(kCpuHasDSPR2); 70 | printf("Has DSPR2 %x\n", has_dspr2); 71 | } 72 | if (has_x86) { 73 | int has_sse2 = TestCpuFlag(kCpuHasSSE2); 74 | int has_ssse3 = TestCpuFlag(kCpuHasSSSE3); 75 | int has_sse41 = TestCpuFlag(kCpuHasSSE41); 76 | int has_sse42 = TestCpuFlag(kCpuHasSSE42); 77 | int has_avx = TestCpuFlag(kCpuHasAVX); 78 | int has_avx2 = TestCpuFlag(kCpuHasAVX2); 79 | int has_avx3 = TestCpuFlag(kCpuHasAVX3); 80 | int has_erms = TestCpuFlag(kCpuHasERMS); 81 | int has_fma3 = TestCpuFlag(kCpuHasFMA3); 82 | int has_f16c = TestCpuFlag(kCpuHasF16C); 83 | printf("Has SSE2 %x\n", has_sse2); 84 | printf("Has SSSE3 %x\n", has_ssse3); 85 | printf("Has SSE4.1 %x\n", has_sse41); 86 | printf("Has SSE4.2 %x\n", has_sse42); 87 | printf("Has AVX %x\n", has_avx); 88 | printf("Has AVX2 %x\n", has_avx2); 89 | printf("Has AVX3 %x\n", has_avx3); 90 | printf("Has ERMS %x\n", has_erms); 91 | printf("Has FMA3 %x\n", has_fma3); 92 | printf("Has F16C %x\n", has_f16c); 93 | } 94 | return 0; 95 | } 96 | 97 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/util/psnr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Get PSNR for video sequence. Assuming RAW 4:2:0 Y:Cb:Cr format 12 | 13 | #ifndef UTIL_PSNR_H_ // NOLINT 14 | #define UTIL_PSNR_H_ 15 | 16 | #include // For log10() 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #if !defined(INT_TYPES_DEFINED) && !defined(UINT8_TYPE_DEFINED) 23 | typedef unsigned char uint8; 24 | #define UINT8_TYPE_DEFINED 25 | #endif 26 | 27 | static const double kMaxPSNR = 128.0; 28 | 29 | // libyuv provides this function when linking library for jpeg support. 30 | // TODO(fbarchard): make psnr lib compatible subset of libyuv. 31 | #if !defined(HAVE_JPEG) 32 | // Computer Sum of Squared Error (SSE). 33 | // Pass this to ComputePSNR for final result. 34 | double ComputeSumSquareError(const uint8* org, const uint8* rec, int size); 35 | #endif 36 | 37 | // PSNR formula: psnr = 10 * log10 (Peak Signal^2 * size / sse) 38 | // Returns 128.0 (kMaxPSNR) if sse is 0 (perfect match). 39 | double ComputePSNR(double sse, double size); 40 | 41 | #ifdef __cplusplus 42 | } // extern "C" 43 | #endif 44 | 45 | #endif // UTIL_PSNR_H_ // NOLINT 46 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/util/ssim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The LibYuv Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | // Get SSIM for video sequence. Assuming RAW 4:2:0 Y:Cb:Cr format 12 | 13 | #ifndef UTIL_SSIM_H_ 14 | #define UTIL_SSIM_H_ 15 | 16 | #include // For log10() 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #if !defined(INT_TYPES_DEFINED) && !defined(UINT8_TYPE_DEFINED) 23 | typedef unsigned char uint8; 24 | #define UINT8_TYPE_DEFINED 25 | #endif 26 | 27 | double CalcSSIM(const uint8* org, 28 | const uint8* rec, 29 | const int image_width, 30 | const int image_height); 31 | 32 | double CalcLSSIM(double ssim); 33 | 34 | #ifdef __cplusplus 35 | } // extern "C" 36 | #endif 37 | 38 | #endif // UTIL_SSIM_H_ 39 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/winarm.mk: -------------------------------------------------------------------------------- 1 | # This is a generic makefile for libyuv for Windows Arm. 2 | # call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_arm\vcvarsx86_arm.bat" 3 | # nmake /f winarm.mk 4 | # make -f winarm.mk 5 | # nmake /f winarm.mk clean 6 | # consider /arch:ARMv7VE 7 | CC=cl 8 | CCFLAGS=/Ox /nologo /Iinclude /DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP 9 | AR=lib 10 | ARFLAGS=/MACHINE:ARM /NOLOGO /SUBSYSTEM:NATIVE 11 | RM=cmd /c del 12 | 13 | LOCAL_OBJ_FILES = \ 14 | source/compare.o\ 15 | source/compare_common.o\ 16 | source/convert.o\ 17 | source/convert_argb.o\ 18 | source/convert_from.o\ 19 | source/convert_from_argb.o\ 20 | source/convert_to_argb.o\ 21 | source/convert_to_i420.o\ 22 | source/cpu_id.o\ 23 | source/planar_functions.o\ 24 | source/rotate.o\ 25 | source/rotate_any.o\ 26 | source/rotate_argb.o\ 27 | source/rotate_common.o\ 28 | source/row_any.o\ 29 | source/row_common.o\ 30 | source/scale.o\ 31 | source/scale_any.o\ 32 | source/scale_argb.o\ 33 | source/scale_common.o\ 34 | source/video_common.o 35 | 36 | .cc.o: 37 | $(CC) /c $(CCFLAGS) $*.cc /Fo$@ 38 | 39 | all: libyuv_arm.lib winarm.mk 40 | 41 | libyuv_arm.lib: $(LOCAL_OBJ_FILES) winarm.mk 42 | $(AR) $(ARFLAGS) /OUT:$@ $(LOCAL_OBJ_FILES) 43 | 44 | clean: 45 | $(RM) "source\*.o" libyuv_arm.lib 46 | 47 | -------------------------------------------------------------------------------- /libyuv/src/main/cpp/libyuv/yuv_android.sh: -------------------------------------------------------------------------------- 1 | cd build 2 | cmake -DCMAKE_TOOLCHAIN_FILE=android.toolchain.cmake \ 3 | -DANDROID_NDK=/mnt/f/cres/ndk \ 4 | -DCMAKE_BUILD_TYPE=Release \ 5 | -DANDROID_ABI="armeabi-v7a arm64-v8a x86" \ 6 | ../ 7 | -------------------------------------------------------------------------------- /libyuv/src/main/java/com/libyuv/util/YuvUtil.java: -------------------------------------------------------------------------------- 1 | package com.libyuv.util; 2 | 3 | /** 4 | * 作者:请叫我百米冲刺 on 2017/8/28 上午11:05 5 | * 邮箱:mail@hezhilin.cc 6 | */ 7 | 8 | public class YuvUtil { 9 | 10 | static { 11 | System.loadLibrary("yuvutil"); 12 | } 13 | 14 | /** 15 | * 初始化 16 | * 17 | * @param width 原始的宽 18 | * @param height 原始的高 19 | * @param dst_width 输出的宽 20 | * @param dst_height 输出的高 21 | **/ 22 | public static native void init(int width, int height, int dst_width, int dst_height); 23 | 24 | 25 | /** 26 | * YUV数据的基本的处理 27 | * 28 | * @param src 原始数据 29 | * @param width 原始的宽 30 | * @param height 原始的高 31 | * @param dst 输出数据 32 | * @param dst_width 输出的宽 33 | * @param dst_height 输出的高 34 | * @param mode 压缩模式。这里为0,1,2,3 速度由快到慢,质量由低到高,一般用0就好了,因为0的速度最快 35 | * @param degree 旋转的角度,90,180和270三种 36 | * @param isMirror 是否镜像,一般只有270的时候才需要镜像 37 | **/ 38 | public static native void compressYUV(byte[] src, int width, int height, byte[] dst, int dst_width, int dst_height, int mode, int degree, boolean isMirror); 39 | 40 | /** 41 | * yuv数据的裁剪操作 42 | * 43 | * @param src 原始数据 44 | * @param width 原始的宽 45 | * @param height 原始的高 46 | * @param dst 输出数据 47 | * @param dst_width 输出的宽 48 | * @param dst_height 输出的高 49 | * @param left 裁剪的x的开始位置,必须为偶数,否则显示会有问题 50 | * @param top 裁剪的y的开始位置,必须为偶数,否则显示会有问题 51 | **/ 52 | public static native void cropYUV(byte[] src, int width, int height, byte[] dst, int dst_width, int dst_height, int left, int top); 53 | 54 | /** 55 | * 将I420转化为NV21 56 | * 57 | * @param i420Src 原始I420数据 58 | * @param nv21Src 转化后的NV21数据 59 | * @param width 输出的宽 60 | * @param width 输出的高 61 | **/ 62 | public static native void yuvI420ToNV21(byte[] i420Src, byte[] nv21Src, int width, int height); 63 | } 64 | -------------------------------------------------------------------------------- /libyuv/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /libyuv/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /libyuv/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /libyuv/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /libyuv/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /libyuv/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /libyuv/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /libyuv/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /libyuv/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /libyuv/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hzl123456/LibyuvDemo/d02b6500d0cf111bdd8778c56983154e6d14bdb4/libyuv/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /libyuv/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /libyuv/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Libyuv 3 | 4 | -------------------------------------------------------------------------------- /libyuv/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /libyuv/src/test/java/com/libyuv/util/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.libyuv.util; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':libyuv' 2 | --------------------------------------------------------------------------------