├── .gitignore
├── README.md
├── README_cn.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── luoye
│ │ └── bzyuvlib
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── luoye
│ │ │ └── bzyuvlib
│ │ │ ├── Bitmap2YUVActivity.java
│ │ │ ├── Camera1YUVCropActivity.java
│ │ │ ├── Camera2Activity.java
│ │ │ ├── Camera2YUVCropActivity.java
│ │ │ ├── CameraActivity.java
│ │ │ ├── GreyImageTestActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── PermissionUtil.java
│ │ │ ├── RGBAHandleActivity.java
│ │ │ ├── YUV420ToNV21Activity.java
│ │ │ └── ZoomYUVActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── ic_launcher_background.xml
│ │ ├── timg.jpeg
│ │ └── timg_2.jpeg
│ │ ├── layout
│ │ ├── activity_bitmap2_y_u_v.xml
│ │ ├── activity_camera.xml
│ │ ├── activity_camera1_y_u_v_crop.xml
│ │ ├── activity_camera2.xml
│ │ ├── activity_camera2_y_u_v_crop.xml
│ │ ├── activity_grey_image_test.xml
│ │ ├── activity_main.xml
│ │ ├── activity_r_g_b_a_handle.xml
│ │ ├── activity_yuv420_to_nv_21.xml
│ │ └── activity_zoom_yuv.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── luoye
│ └── bzyuvlib
│ └── ExampleUnitTest.java
├── build.gradle
├── bzyuv
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── luoye
│ │ └── bzyuv
│ │ └── ExampleInstrumentedTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── cpp
│ ├── BZLogUtil.cpp
│ ├── BZLogUtil.h
│ ├── CMakeLists.txt
│ ├── bz_time.cpp
│ ├── bz_time.h
│ ├── 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
│ ├── lib
│ │ ├── arm64-v8a
│ │ │ └── libyuv_static.a
│ │ ├── armeabi-v7a
│ │ │ └── libyuv_static.a
│ │ ├── x86
│ │ │ └── libyuv_static.a
│ │ └── x86_64
│ │ │ └── libyuv_static.a
│ └── native-lib.cpp
│ └── java
│ └── com
│ └── luoye
│ └── bzyuvlib
│ ├── BZYUVSoLoadingUtil.java
│ └── BZYUVUtil.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | .cxx
10 | ### JetBrains template
11 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
12 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
13 |
14 |
15 |
16 | # Gradle and Maven with auto-import
17 | # When using Gradle or Maven with auto-import, you should exclude module files,
18 | # since they will be recreated, and may cause churn. Uncomment if using
19 | # auto-import.
20 | # .idea/modules.xml
21 | # .idea/*.iml
22 | # .idea/modules
23 | # *.iml
24 | # *.ipr
25 |
26 | # CMake
27 | cmake-build-*/
28 |
29 | # Mongo Explorer plugin
30 | .idea/**/mongoSettings.xml
31 |
32 | # File-based project format
33 | *.iws
34 |
35 | # IntelliJ
36 | out/
37 |
38 | # mpeltonen/sbt-idea plugin
39 | .idea_modules/
40 |
41 | # JIRA plugin
42 | atlassian-ide-plugin.xml
43 |
44 | # Cursive Clojure plugin
45 | .idea/replstate.xml
46 |
47 | # Crashlytics plugin (for Android Studio and IntelliJ)
48 | com_crashlytics_export_strings.xml
49 | crashlytics.properties
50 | crashlytics-build.properties
51 | fabric.properties
52 |
53 | # Editor-based Rest Client
54 | .idea/httpRequests
55 |
56 | # Android studio 3.1+ serialized cache file
57 | .idea/caches/build_file_checksums.ser
58 |
59 | ### Android template
60 | # Built application files
61 | *.apk
62 | *.ap_
63 | *.aab
64 |
65 | # Files for the ART/Dalvik VM
66 | *.dex
67 |
68 | # Java class files
69 | *.class
70 |
71 | # Generated files
72 | bin/
73 | gen/
74 | release/
75 |
76 | # Gradle files
77 | .gradle/
78 | build/
79 |
80 | # Local configuration file (sdk path, etc)
81 | local.properties
82 |
83 | # Proguard folder generated by Eclipse
84 | proguard/
85 |
86 | # Log Files
87 | *.log
88 |
89 | # Android Studio Navigation editor temp files
90 | .navigation/
91 |
92 | # Android Studio captures folder
93 | captures/
94 |
95 | # IntelliJ
96 | .idea/workspace.xml
97 | .idea/tasks.xml
98 | .idea/gradle.xml
99 | .idea/assetWizardSettings.xml
100 | .idea/dictionaries
101 | .idea/libraries
102 | # Android Studio 3 in .gitignore file.
103 | .idea/caches
104 | .idea/modules.xml
105 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you
106 | .idea/navEditor.xml
107 |
108 | # Keystore files
109 | # Uncomment the following lines if you do not want to check your keystore files in.
110 | #*.jks
111 | #*.keystore
112 |
113 | # External native build folder generated in Android Studio 2.2 and later
114 |
115 | # Google Services (e.g. APIs or Firebase)
116 | # google-services.json
117 |
118 | # Freeline
119 | freeline.py
120 | freeline/
121 | freeline_project_description.json
122 |
123 | # fastlane
124 | fastlane/report.xml
125 | fastlane/Preview.html
126 | fastlane/screenshots
127 | fastlane/test_output
128 | fastlane/readme.md
129 |
130 | # Version control
131 | vcs.xml
132 |
133 | # lint
134 | lint/intermediates/
135 | lint/generated/
136 | lint/outputs/
137 | lint/tmp/
138 | # lint/reports/
139 | Thumbs.db
140 | Thumbs.db:encryptable
141 | ehthumbs.db
142 | ehthumbs_vista.db
143 | *.stackdump
144 | [Dd]esktop.ini
145 | $RECYCLE.BIN/
146 | *.cab
147 | *.msi
148 | *.msix
149 | *.msm
150 | *.msp
151 | *.lnk
152 | .DS_Store
153 | .AppleDouble
154 | .LSOverride
155 | Icon
156 | ._*
157 | .DocumentRevisions-V100
158 | .fseventsd
159 | .Spotlight-V100
160 | .TemporaryItems
161 | .Trashes
162 | .VolumeIcon.icns
163 | .com.apple.timemachine.donotpresent
164 | .AppleDB
165 | .AppleDesktop
166 | Network Trash Folder
167 | Temporary Items
168 | .apdisk
169 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | I previously wrote a YUV to RGBA project based on RenderScript, address: https://www.raoyunsoft.com/wordpress/index.php/2020/01/19/yuvrenderscript/ If you like it, you can go here to find it, than Android native ScriptIntrinsicYuvToRGB is much more powerful, but recently found that RenderScript is much slower than Google ’s libyuv, so I wrote a YUV conversion project based on libyuv, and also supported the YUV conversion of Camera1 and Camera2 output, and the YUV mirror , Rotation, supported functions are as follows:
2 |
3 | 1. yuv420pToRGBA/yuv420pToBGRA
4 | 2. preHandleYUV
5 | 3. yv12ToRGBA/yv12ToBGRA
6 | 4. nv21ToRGBA/nv21ToBGRA
7 | 5. cropNV21/cropYUV420
8 | 6. zoomYUV420
9 | 7. bitmapToYUV420
10 | 8. yuvToGrey
11 | 9. greyToRGBA
12 | 10. translationSingleChannel
13 | 11. Support RGBA rotation and mirroring
14 | 12. yuvI420ToNV21
15 | 13. yuvI420ToNV12
16 |
17 |
18 |
19 | #### How to use:
20 |
21 | ##### 1.First add mavenCentral() as shown below
22 |
23 | ```
24 | allprojects {
25 | repositories {
26 | maven { url "https://nexus.raoyunsoft.com/repository/maven-releases/" }
27 | }
28 | }
29 | ```
30 |
31 | ##### 2. implementation 'com.guaishou.bzlib:bzyuv:1.1.19@aar'
32 |
33 |
34 |
35 | If it helps you, please give me a start
36 |
37 |
38 |
39 | [中文文档(Chinese DOC)](https://github.com/bookzhan/bzyuvlib/blob/master/README_cn.md)
40 |
41 |
--------------------------------------------------------------------------------
/README_cn.md:
--------------------------------------------------------------------------------
1 | 之前基于RenderScript写了一个YUV转RGBA的工程,地址:https://www.raoyunsoft.com/wordpress/index.php/2020/01/19/yuvrenderscript/ 喜欢的可以去看看,比Android原生的ScriptIntrinsicYuvToRGB要强大很多,但是近期在使用的过程中发现RenderScript比Google的libyuv速度要慢很多,于是我又基于libyuv写了一个YUV转换的工程,同时支持Camera1,Camera2输出的YUV转换,以及对YUV镜像,旋转,从YUV输出灰度图,灰度图转成RGBA, 单通道平移,具体支持的功能如下:
2 |
3 | 1. yuv420pToRGBA/yuv420pToBGRA
4 | 2. preHandleYUV
5 | 3. yv12ToRGBA/yv12ToBGRA
6 | 4. nv21ToRGBA/nv21ToBGRA
7 | 5. cropNV21/cropYUV420
8 | 6. zoomYUV420
9 | 7. bitmapToYUV420
10 | 8. yuvToGrey
11 | 9. greyToRGBA
12 | 10. translationSingleChannel
13 | 11. 支持RGBA的旋转,镜像
14 | 12. yuvI420ToNV21
15 | 13. yuvI420ToNV12
16 |
17 |
18 |
19 | #### 如何使用:
20 |
21 | ##### 1.先添加mavenCentral(),如下所示
22 |
23 | ```
24 | allprojects {
25 | repositories {
26 | maven { url "https://nexus.raoyunsoft.com/repository/maven-releases/" }
27 | }
28 | }
29 | ```
30 |
31 | ##### 2.然后implementation 'com.guaishou.bzlib:bzyuv:1.1.19@aar'
32 |
33 |
34 |
35 | 如果帮到了你,请给一个star
36 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 33
5 |
6 | defaultConfig {
7 | applicationId "com.luoye.bzyuvlib"
8 | minSdkVersion 21
9 | targetSdkVersion 33
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 |
21 | lintOptions {
22 | abortOnError false
23 | }
24 | namespace 'com.luoye.bzyuvlib'
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: 'libs', include: ['*.jar'])
29 | implementation 'androidx.appcompat:appcompat:1.4.1'
30 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
31 | testImplementation 'junit:junit:4.13.2'
32 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
33 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
34 |
35 | implementation 'com.guaishou.bzlib:bzcommon:1.1.24@aar'
36 | implementation 'com.guaishou.bzlib:bzcamera:1.0.24@aar'
37 | implementation project(path: ':bzyuv')
38 | }
39 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/luoye/bzyuvlib/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.luoye.bzyuvlib", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/Bitmap2YUVActivity.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.nfc.Tag;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.widget.ImageView;
11 |
12 | import androidx.appcompat.app.AppCompatActivity;
13 |
14 | import java.io.FileOutputStream;
15 | import java.nio.ByteBuffer;
16 |
17 | public class Bitmap2YUVActivity extends AppCompatActivity {
18 |
19 | private static final String TAG = "bz_Bitmap2YUVActivity";
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_bitmap2_y_u_v);
25 | ImageView ivImageSrc = findViewById(R.id.iv_image_src);
26 | ImageView ivImageDis = findViewById(R.id.iv_image_dis);
27 | Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.timg);
28 |
29 | // bitmap = convertRGB565(bitmap);
30 |
31 | ivImageSrc.setImageBitmap(bitmap);
32 | Log.d(TAG, "getWidth=" + bitmap.getWidth() + " getHeight=" + bitmap.getHeight());
33 |
34 | byte[] yuvBuffer = new byte[bitmap.getWidth() * bitmap.getHeight() * 3 / 2];
35 | BZYUVUtil.bitmapToYUV420(bitmap, yuvBuffer);
36 |
37 |
38 | byte[] rgbaBuffer = new byte[bitmap.getWidth() * bitmap.getHeight() * 4];
39 | BZYUVUtil.yuv420ToRGBA(yuvBuffer, rgbaBuffer, bitmap.getWidth(), bitmap.getHeight(), false, 0);
40 | Bitmap disBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
41 | disBitmap.copyPixelsFromBuffer(ByteBuffer.wrap(rgbaBuffer));
42 |
43 | ivImageDis.setImageBitmap(disBitmap);
44 | }
45 |
46 | private Bitmap convertRGB565(Bitmap bitmap) {
47 | Bitmap disBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.RGB_565);
48 | Canvas canvas = new Canvas(disBitmap);
49 | canvas.drawBitmap(bitmap, 0, 0, new Paint());
50 | return disBitmap;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/Camera1YUVCropActivity.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.ImageFormat;
5 | import android.hardware.Camera;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 | import android.widget.ImageView;
9 |
10 | import androidx.appcompat.app.AppCompatActivity;
11 |
12 | import com.luoye.bzcamera.BZCameraView;
13 | import com.luoye.bzcamera.listener.OnCameraStateListener;
14 |
15 | import java.nio.ByteBuffer;
16 |
17 | public class Camera1YUVCropActivity extends AppCompatActivity {
18 | private static final String TAG = "bz_Camera1YUVCrop";
19 |
20 | private BZCameraView bz_camera_view;
21 | private ImageView bz_image_view;
22 | private byte[] yuvBuffer = null;
23 | private byte[] argbByteBuffer = null;
24 | private byte[] cropYuvBuffer = null;
25 | private int index = 0;
26 | private Bitmap bitmap = null;
27 | private long totalTime = 0;
28 | private int cropStartX = 100;
29 | private int cropStartY = 100;
30 | private int cropWidth = 240;
31 | private int cropHeight = 320;
32 |
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_camera1_y_u_v_crop);
37 | bz_camera_view = findViewById(R.id.bz_camera_view);
38 | bz_camera_view.setPreviewTargetSize(480, 640);
39 | bz_image_view = findViewById(R.id.bz_image_view);
40 |
41 |
42 | // bz_image_view.setScaleX(-1);
43 | // bz_image_view.setScaleY(-1);
44 | bz_camera_view.setPreviewFormat(ImageFormat.NV21);
45 | bz_camera_view.setNeedCallBackData(true);
46 | bz_camera_view.setOnCameraStateListener(new OnCameraStateListener() {
47 | @Override
48 | public void onPreviewSuccess(Camera camera, int width, int height) {
49 |
50 | }
51 |
52 | @Override
53 | public void onPreviewFail(String message) {
54 |
55 | }
56 |
57 | @Override
58 | public void onPreviewDataUpdate(byte[] data, int width, int height, int displayOrientation, int cameraId) {
59 | if (width < cropWidth + cropStartX || height < cropHeight + cropStartY) {
60 | Log.e(TAG, "width < cropWidth + cropStartX || height < cropHeight + cropStartY");
61 | return;
62 | }
63 | long startTime = System.currentTimeMillis();
64 | if (null == yuvBuffer) {
65 | yuvBuffer = new byte[width * height * 3 / 2];
66 | }
67 | if (null == argbByteBuffer) {
68 | argbByteBuffer = new byte[cropWidth * cropHeight * 4];
69 | }
70 | if (null == cropYuvBuffer) {
71 | cropYuvBuffer = new byte[cropWidth * cropHeight * 3 / 2];
72 | }
73 | //Correct angle and mirror image to facilitate crop coordinate calculation
74 | BZYUVUtil.preHandleNV21(data, yuvBuffer, width, height, cameraId == Camera.CameraInfo.CAMERA_FACING_FRONT, displayOrientation);
75 | if (displayOrientation == 270 || displayOrientation == 90) {
76 | BZYUVUtil.cropYUV420(yuvBuffer, cropYuvBuffer, height, width, cropStartX, cropStartY, cropWidth, cropHeight);
77 | } else {
78 | BZYUVUtil.cropYUV420(yuvBuffer, cropYuvBuffer, width, height, cropStartX, cropStartY, cropWidth, cropHeight);
79 | }
80 | BZYUVUtil.yuv420ToRGBA(cropYuvBuffer, argbByteBuffer, cropWidth, cropHeight, false, 0);
81 | index++;
82 | totalTime += (System.currentTimeMillis() - startTime);
83 | Log.d(TAG, "time cost=" + (totalTime / index));
84 |
85 | if (null == bitmap) {
86 | bitmap = Bitmap.createBitmap(cropWidth, cropHeight, Bitmap.Config.ARGB_8888);
87 | }
88 | bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(argbByteBuffer));
89 | bz_image_view.post(new Runnable() {
90 | @Override
91 | public void run() {
92 | bz_image_view.setImageBitmap(bitmap);
93 | }
94 | });
95 | }
96 |
97 | @Override
98 | public void onCameraClose() {
99 |
100 | }
101 | });
102 | }
103 |
104 | @Override
105 | protected void onResume() {
106 | super.onResume();
107 | bz_camera_view.onResume();
108 | }
109 |
110 | @Override
111 | protected void onPause() {
112 | super.onPause();
113 | bz_camera_view.onPause();
114 | }
115 |
116 | @Override
117 | protected void onDestroy() {
118 | super.onDestroy();
119 | Log.d("onDestroy", "yuvFileOutputStream.close");
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/Camera2Activity.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.annotation.TargetApi;
4 | import android.graphics.Bitmap;
5 | import android.hardware.camera2.CameraCharacteristics;
6 | import android.hardware.camera2.CameraDevice;
7 | import android.media.Image;
8 | import android.os.Build;
9 | import android.os.Bundle;
10 | import android.util.Log;
11 | import android.widget.ImageView;
12 |
13 | import androidx.appcompat.app.AppCompatActivity;
14 |
15 | import com.luoye.bzcamera.BZCamera2View;
16 |
17 | import java.nio.ByteBuffer;
18 |
19 | @TargetApi(android.os.Build.VERSION_CODES.LOLLIPOP)
20 | public class Camera2Activity extends AppCompatActivity {
21 | private static final String TAG = "bz_Camera2Activity";
22 | private BZCamera2View bz_camera2_view;
23 | private ImageView iv_preview;
24 | private BZYUVUtil bzyuvUtil;
25 | private Bitmap bitmap;
26 | private long spaceTime;
27 | private int index;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_camera2);
33 | iv_preview = findViewById(R.id.iv_preview);
34 | bz_camera2_view = findViewById(R.id.bz_camera2_view);
35 | bz_camera2_view.setPreviewTargetSize(480,640);
36 | bz_camera2_view.setCheckCameraCapacity(false);
37 | bzyuvUtil = new BZYUVUtil();
38 | bz_camera2_view.setOnStatusChangeListener(new BZCamera2View.OnStatusChangeListener() {
39 | @Override
40 | public void onPreviewSuccess(CameraDevice mCameraDevice, int width, int height) {
41 |
42 | }
43 |
44 | @Override
45 | public void onImageAvailable(Image image, int displayOrientation, float fps) {
46 | int height = image.getHeight();
47 | int width = image.getWidth();
48 | if (displayOrientation == 270 || displayOrientation == 90) {
49 | width = image.getHeight();
50 | height = image.getWidth();
51 | }
52 | long startTime = System.currentTimeMillis();
53 | byte[] pixData = bzyuvUtil.yuv420pToRGBA(image, bz_camera2_view.getCurrentCameraLensFacing() == CameraCharacteristics.LENS_FACING_FRONT, displayOrientation);
54 |
55 | spaceTime += (System.currentTimeMillis() - startTime);
56 | index++;
57 | Log.d(TAG, "time cost=" + (spaceTime / index) + " bitmap.width=" + width + " height=" + height);
58 | if (null == bitmap) {
59 | bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
60 | }
61 | bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(pixData));
62 | iv_preview.post(new Runnable() {
63 | @Override
64 | public void run() {
65 | iv_preview.setImageBitmap(bitmap);
66 | }
67 | });
68 | }
69 | });
70 |
71 | }
72 |
73 | @Override
74 | protected void onResume() {
75 | super.onResume();
76 | bz_camera2_view.onResume();
77 | }
78 |
79 | @Override
80 | protected void onPause() {
81 | super.onPause();
82 | bz_camera2_view.onPause();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/Camera2YUVCropActivity.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.annotation.TargetApi;
4 | import android.graphics.Bitmap;
5 | import android.hardware.camera2.CameraCharacteristics;
6 | import android.hardware.camera2.CameraDevice;
7 | import android.media.Image;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.widget.ImageView;
11 |
12 | import androidx.appcompat.app.AppCompatActivity;
13 |
14 | import com.luoye.bzcamera.BZCamera2View;
15 |
16 | import java.io.FileOutputStream;
17 | import java.nio.ByteBuffer;
18 |
19 | @TargetApi(android.os.Build.VERSION_CODES.LOLLIPOP)
20 | public class Camera2YUVCropActivity extends AppCompatActivity {
21 | private static final String TAG = "bz_Camera2YUVCrop";
22 | private BZCamera2View bz_camera2_view;
23 | private ImageView iv_preview;
24 | private BZYUVUtil bzyuvUtil;
25 | private Bitmap bitmap;
26 | private long spaceTime;
27 | private int index;
28 | private int cropStartX = 100;
29 | private int cropStartY = 100;
30 | private int cropWidth = 240;
31 | private int cropHeight = 320;
32 | private byte[] argbByteBuffer = null;
33 | private byte[] cropYuvBuffer = null;
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 | setContentView(R.layout.activity_camera2_y_u_v_crop);
39 | iv_preview = findViewById(R.id.iv_preview);
40 | bz_camera2_view = findViewById(R.id.bz_camera2_view);
41 | bz_camera2_view.setCheckCameraCapacity(false);
42 | bzyuvUtil = new BZYUVUtil();
43 | bz_camera2_view.setOnStatusChangeListener(new BZCamera2View.OnStatusChangeListener() {
44 |
45 | private FileOutputStream fileOutputStream;
46 |
47 | @Override
48 | public void onPreviewSuccess(CameraDevice mCameraDevice, int width, int height) {
49 |
50 | }
51 |
52 | @Override
53 | public void onImageAvailable(Image image, int displayOrientation, float fps) {
54 | int height = image.getHeight();
55 | int width = image.getWidth();
56 | if (displayOrientation == 270 || displayOrientation == 90) {
57 | width = image.getHeight();
58 | height = image.getWidth();
59 | }
60 | if (width < cropWidth + cropStartX || height < cropHeight + cropStartY) {
61 | Log.e(TAG, "width < cropWidth + cropStartX || height < cropHeight + cropStartY");
62 | return;
63 | }
64 | if (null == argbByteBuffer) {
65 | argbByteBuffer = new byte[cropWidth * cropHeight * 4];
66 | }
67 | if (null == cropYuvBuffer) {
68 | cropYuvBuffer = new byte[cropWidth * cropHeight * 3 / 2];
69 | }
70 | long startTime = System.currentTimeMillis();
71 | byte[] yuv420 = bzyuvUtil.preHandleYUV420(image, bz_camera2_view.getCurrentCameraLensFacing() == CameraCharacteristics.LENS_FACING_FRONT, displayOrientation);
72 | if (null == fileOutputStream) {
73 | try {
74 | fileOutputStream = new FileOutputStream("/sdcard/bzmedia/kk.yuv");
75 | fileOutputStream.write(yuv420, 0, yuv420.length);
76 | fileOutputStream.flush();
77 | fileOutputStream.close();
78 | } catch (Exception e) {
79 | e.printStackTrace();
80 | }
81 | }
82 |
83 | BZYUVUtil.cropYUV420(yuv420, cropYuvBuffer, width, height, cropStartX, cropStartY, cropWidth, cropHeight);
84 |
85 | BZYUVUtil.yuv420ToRGBA(cropYuvBuffer, argbByteBuffer, cropWidth, cropHeight, false, 0);
86 |
87 | spaceTime += (System.currentTimeMillis() - startTime);
88 | index++;
89 | Log.d(TAG, "time cost=" + (spaceTime / index) + " bitmap.width=" + width + " height=" + height);
90 | if (null == bitmap) {
91 | bitmap = Bitmap.createBitmap(cropWidth, cropHeight, Bitmap.Config.ARGB_8888);
92 | }
93 | bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(argbByteBuffer));
94 | iv_preview.post(new Runnable() {
95 | @Override
96 | public void run() {
97 | iv_preview.setImageBitmap(bitmap);
98 | }
99 | });
100 | }
101 | });
102 | }
103 |
104 | @Override
105 | protected void onResume() {
106 | super.onResume();
107 | bz_camera2_view.onResume();
108 | }
109 |
110 | @Override
111 | protected void onPause() {
112 | super.onPause();
113 | bz_camera2_view.onPause();
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/CameraActivity.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.ImageFormat;
5 | import android.hardware.Camera;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 | import android.widget.ImageView;
9 |
10 | import androidx.appcompat.app.AppCompatActivity;
11 |
12 | import com.luoye.bzcamera.BZCameraView;
13 | import com.luoye.bzcamera.listener.OnCameraStateListener;
14 |
15 | import java.nio.ByteBuffer;
16 |
17 | public class CameraActivity extends AppCompatActivity {
18 | private static final String TAG = "bz_CameraActivity";
19 |
20 | private BZCameraView bz_camera_view;
21 | private ImageView bz_image_view;
22 | private byte[] argbByteBuffer = null;
23 | private int index = 0;
24 | private Bitmap bitmap = null;
25 | private long totalTime = 0;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_camera);
31 | bz_camera_view = findViewById(R.id.bz_camera_view);
32 | bz_camera_view.setPreviewTargetSize(480, 640);
33 | bz_image_view = findViewById(R.id.bz_image_view);
34 |
35 |
36 | // bz_image_view.setScaleX(-1);
37 | // bz_image_view.setScaleY(-1);
38 | bz_camera_view.setPreviewFormat(ImageFormat.NV21);
39 | bz_camera_view.setNeedCallBackData(true);
40 | bz_camera_view.setOnCameraStateListener(new OnCameraStateListener() {
41 | @Override
42 | public void onPreviewSuccess(Camera camera, int width, int height) {
43 |
44 | }
45 |
46 | @Override
47 | public void onPreviewFail(String message) {
48 |
49 | }
50 |
51 | @Override
52 | public void onPreviewDataUpdate(byte[] data, int width, int height, int displayOrientation, int cameraId) {
53 | if (null == argbByteBuffer) {
54 | argbByteBuffer = new byte[width * height * 4];
55 | }
56 | index++;
57 | long startTime = System.currentTimeMillis();
58 | BZYUVUtil.nv21ToRGBA(data, argbByteBuffer, width, height, cameraId == Camera.CameraInfo.CAMERA_FACING_FRONT, displayOrientation);
59 | totalTime += (System.currentTimeMillis() - startTime);
60 | Log.d(TAG, "time cost=" + (totalTime / index));
61 |
62 | if (null == bitmap) {
63 | if (displayOrientation == 270 || displayOrientation == 90) {
64 | bitmap = Bitmap.createBitmap(height, width, Bitmap.Config.ARGB_8888);
65 | } else {
66 | bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
67 | }
68 | }
69 | bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(argbByteBuffer));
70 | bz_image_view.post(new Runnable() {
71 | @Override
72 | public void run() {
73 | bz_image_view.setImageBitmap(bitmap);
74 | }
75 | });
76 | }
77 |
78 | @Override
79 | public void onCameraClose() {
80 |
81 | }
82 | });
83 | }
84 |
85 | @Override
86 | protected void onResume() {
87 | super.onResume();
88 | bz_camera_view.onResume();
89 | }
90 |
91 | @Override
92 | protected void onPause() {
93 | super.onPause();
94 | bz_camera_view.onPause();
95 | }
96 |
97 | @Override
98 | protected void onDestroy() {
99 | super.onDestroy();
100 | Log.d("onDestroy", "yuvFileOutputStream.close");
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/GreyImageTestActivity.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import androidx.annotation.RequiresApi;
4 | import androidx.appcompat.app.AppCompatActivity;
5 |
6 | import android.graphics.Bitmap;
7 | import android.hardware.camera2.CameraDevice;
8 | import android.media.Image;
9 | import android.os.Build;
10 | import android.os.Bundle;
11 | import android.util.Log;
12 | import android.view.View;
13 | import android.widget.ImageView;
14 |
15 | import com.luoye.bzcamera.BZCamera2View;
16 |
17 | import java.nio.ByteBuffer;
18 |
19 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
20 | public class GreyImageTestActivity extends AppCompatActivity {
21 |
22 | private BZCamera2View bz_camera2_view;
23 | private ImageView image_view;
24 | private BZYUVUtil bzyuvUtil;
25 | private byte[] outDataRGBA = null;
26 | private Bitmap bitmap = null;
27 | private byte[] greyBuffer = null;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_grey_image_test);
33 | bzyuvUtil = new BZYUVUtil();
34 | image_view = findViewById(R.id.image_view);
35 | bz_camera2_view = findViewById(R.id.bz_camera2_view);
36 | bz_camera2_view.setPreviewTargetSize(480, 640);
37 | bz_camera2_view.setDisplayOrientation(90);
38 | bz_camera2_view.switchCamera();
39 | bz_camera2_view.setOnStatusChangeListener(new BZCamera2View.OnStatusChangeListener() {
40 | @Override
41 | public void onPreviewSuccess(CameraDevice mCameraDevice, int width, int height) {
42 |
43 | }
44 |
45 | @Override
46 | public void onImageAvailable(Image image, int displayOrientation, float fps) {
47 | if (null == outDataRGBA) {
48 | outDataRGBA = new byte[image.getWidth() * image.getHeight() * 4];
49 | }
50 | if (null == greyBuffer) {
51 | greyBuffer = new byte[image.getWidth() * image.getHeight()];
52 | }
53 | int width = image.getWidth();
54 | int height = image.getHeight();
55 | if (displayOrientation == 90 || displayOrientation == 270) {
56 | width = image.getHeight();
57 | height = image.getWidth();
58 | }
59 | byte[] toGrey = bzyuvUtil.yuv420pToGrey(image, true, displayOrientation);
60 | BZYUVUtil.translationSingleChannel(toGrey, greyBuffer, width, height, -60,60);
61 |
62 | BZYUVUtil.greyToRGBA(greyBuffer, outDataRGBA, width, height);
63 | if (null == bitmap) {
64 | bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
65 | }
66 | bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(outDataRGBA));
67 | image_view.post(new Runnable() {
68 | @Override
69 | public void run() {
70 | image_view.setImageBitmap(bitmap);
71 | }
72 | });
73 | }
74 | });
75 | }
76 |
77 | @Override
78 | protected void onResume() {
79 | super.onResume();
80 | bz_camera2_view.onResume();
81 | }
82 |
83 | @Override
84 | protected void onPause() {
85 | super.onPause();
86 | bz_camera2_view.onPause();
87 | }
88 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.Manifest;
4 | import android.content.Intent;
5 | import android.os.Build;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.widget.Toast;
10 |
11 | import androidx.appcompat.app.AppCompatActivity;
12 |
13 | import com.bzcommon.utils.BZPermissionUtil;
14 |
15 | import java.util.ArrayList;
16 |
17 | public class MainActivity extends AppCompatActivity {
18 | private static final String TAG = "bz_MainActivity";
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_main);
24 | BZPermissionUtil.requestPermissionIfNot(this, Manifest.permission.CAMERA, BZPermissionUtil.CODE_REQ_PERMISSION);
25 | }
26 |
27 | @Override
28 | protected void onResume() {
29 | super.onResume();
30 | }
31 |
32 | private boolean noPermission() {
33 | if (!BZPermissionUtil.requestPermissionIfNot(this, Manifest.permission.CAMERA, BZPermissionUtil.CODE_REQ_PERMISSION)) {
34 | Toast.makeText(this, "Please give App sufficient permissions", Toast.LENGTH_LONG).show();
35 | return true;
36 | }
37 | return false;
38 | }
39 |
40 | public void Camera2Activity(View view) {
41 | if (noPermission()) {
42 | return;
43 | }
44 | startActivity(new Intent(this, Camera2Activity.class));
45 | }
46 |
47 | public void CameraActivity(View view) {
48 | if (noPermission()) {
49 | return;
50 | }
51 | startActivity(new Intent(this, CameraActivity.class));
52 | }
53 |
54 | public void Camera1YUVCropActivity(View view) {
55 | if (noPermission()) {
56 | return;
57 | }
58 | startActivity(new Intent(this, Camera1YUVCropActivity.class));
59 | }
60 |
61 | public void Camera2YUVCropActivity(View view) {
62 | if (noPermission()) {
63 | return;
64 | }
65 | startActivity(new Intent(this, Camera2YUVCropActivity.class));
66 | }
67 |
68 | public void zoomYUV(View view) {
69 | if (noPermission()) {
70 | return;
71 | }
72 | startActivity(new Intent(this, ZoomYUVActivity.class));
73 | }
74 |
75 | public void Bitmap2YUVActivity(View view) {
76 | if (noPermission()) {
77 | return;
78 | }
79 | startActivity(new Intent(this, Bitmap2YUVActivity.class));
80 | }
81 |
82 | public void GreyImageTestActivity(View view) {
83 | if (noPermission()) {
84 | return;
85 | }
86 | startActivity(new Intent(this, GreyImageTestActivity.class));
87 | }
88 |
89 | public void RGBAHandleActivity(View view) {
90 | if (noPermission()) {
91 | return;
92 | }
93 | startActivity(new Intent(this, RGBAHandleActivity.class));
94 | }
95 |
96 | public void YUV420ToNV21Activity(View view) {
97 | if (noPermission()) {
98 | return;
99 | }
100 | startActivity(new Intent(this, YUV420ToNV21Activity.class));
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/PermissionUtil.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.pm.PackageManager;
6 |
7 | import androidx.core.app.ActivityCompat;
8 | import androidx.core.content.ContextCompat;
9 |
10 |
11 | public class PermissionUtil {
12 | private static final String TAG = "PermissionUtil";
13 | public static final int CODE_REQ_PERMISSION = 1100;
14 | public static final int CODE_REQ_AUDIO_PERMISSION = 601;
15 | public static final int CODE_REQ_CAMERA_PERMISSION = 602;
16 |
17 |
18 | public static void requestPermission(Activity activity, String[] permissionArr, int requestCode) {
19 | if (permissionArr != null) {
20 | ActivityCompat.requestPermissions(activity, permissionArr, requestCode);
21 | }
22 |
23 | }
24 |
25 | public static void requestPermission(Activity activity, String permissionArr, int requestCode) {
26 | if (permissionArr != null) {
27 | ActivityCompat.requestPermissions(activity, new String[]{permissionArr}, requestCode);
28 | }
29 | }
30 |
31 | public static void requestPermissionIFNot(Activity activity, String permissionArr, int requestCode) {
32 | if (permissionArr != null && !isPermissionGranted(activity, permissionArr)) {
33 | requestPermission(activity, permissionArr, requestCode);
34 | }
35 | }
36 |
37 | public static boolean isPermissionGranted(Context context, String permission) {
38 | if (ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED) {
39 | return true;
40 | } else {
41 | return false;
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/RGBAHandleActivity.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 |
10 | import androidx.appcompat.app.AppCompatActivity;
11 |
12 | import java.nio.ByteBuffer;
13 |
14 | public class RGBAHandleActivity extends AppCompatActivity {
15 | private final static String TAG = "bz_RGBAHandle";
16 | private ImageView iv_rgba_dis;
17 | private Bitmap bitmapSrc;
18 |
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_r_g_b_a_handle);
24 | ImageView iv_rgba_src = findViewById(R.id.iv_rgba_src);
25 | iv_rgba_dis = findViewById(R.id.iv_rgba_dis);
26 |
27 | bitmapSrc = BitmapFactory.decodeResource(getResources(), R.drawable.timg_2);
28 | iv_rgba_src.setImageBitmap(bitmapSrc);
29 | }
30 |
31 | public void testRgba(View view) {
32 | Log.d(TAG,"Width="+bitmapSrc.getWidth()+" Height="+bitmapSrc.getHeight());
33 | byte[] srcBuffer = new byte[bitmapSrc.getWidth() * bitmapSrc.getHeight() * 4];
34 | bitmapSrc.copyPixelsToBuffer(ByteBuffer.wrap(srcBuffer));
35 |
36 | byte[] outBuffer = new byte[bitmapSrc.getWidth() * bitmapSrc.getHeight() * 4];
37 |
38 | int rotate = 90;
39 | long startTime = System.currentTimeMillis();
40 | BZYUVUtil.handleRGBA(srcBuffer, bitmapSrc.getWidth() * 4, outBuffer, bitmapSrc.getWidth(), bitmapSrc.getHeight(), true, rotate);
41 | Log.d(TAG, "time cost=" + (System.currentTimeMillis() - startTime));
42 | Bitmap bitmapDis;
43 | if (rotate == 90 || rotate == 270) {
44 | bitmapDis = Bitmap.createBitmap(bitmapSrc.getHeight(), bitmapSrc.getWidth(), Bitmap.Config.ARGB_8888);
45 | } else {
46 | bitmapDis = Bitmap.createBitmap(bitmapSrc.getWidth(), bitmapSrc.getHeight(), Bitmap.Config.ARGB_8888);
47 | }
48 | bitmapDis.copyPixelsFromBuffer(ByteBuffer.wrap(outBuffer));
49 | iv_rgba_dis.setImageBitmap(bitmapDis);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/YUV420ToNV21Activity.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.annotation.TargetApi;
4 | import android.graphics.Bitmap;
5 | import android.hardware.camera2.CameraCharacteristics;
6 | import android.hardware.camera2.CameraDevice;
7 | import android.media.Image;
8 | import android.os.Build;
9 | import android.os.Bundle;
10 | import android.util.Log;
11 | import android.widget.ImageView;
12 |
13 | import androidx.appcompat.app.AppCompatActivity;
14 |
15 | import com.luoye.bzcamera.BZCamera2View;
16 |
17 | import java.nio.ByteBuffer;
18 |
19 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
20 | public class YUV420ToNV21Activity extends AppCompatActivity {
21 | private static final String TAG = "bz_Camera2Activity";
22 | private BZCamera2View bz_camera2_view;
23 | private ImageView iv_preview;
24 | private BZYUVUtil bzyuvUtil;
25 | private Bitmap bitmap;
26 | private long spaceTime;
27 | private int index;
28 | private byte[] nv21Data;
29 | private byte[] rgbaData;
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_yuv420_to_nv_21);
35 | iv_preview = findViewById(R.id.iv_preview);
36 | bz_camera2_view = findViewById(R.id.bz_camera2_view);
37 | bz_camera2_view.setPreviewTargetSize(480, 640);
38 | bz_camera2_view.setCheckCameraCapacity(false);
39 | bzyuvUtil = new BZYUVUtil();
40 | bz_camera2_view.setOnStatusChangeListener(new BZCamera2View.OnStatusChangeListener() {
41 | @Override
42 | public void onPreviewSuccess(CameraDevice mCameraDevice, int width, int height) {
43 |
44 | }
45 |
46 | @Override
47 | public void onImageAvailable(Image image, int displayOrientation, float fps) {
48 | int height = image.getHeight();
49 | int width = image.getWidth();
50 | if (displayOrientation == 270 || displayOrientation == 90) {
51 | width = image.getHeight();
52 | height = image.getWidth();
53 | }
54 | long startTime = System.currentTimeMillis();
55 | byte[] yuv420 = bzyuvUtil.preHandleYUV420(image, bz_camera2_view.getCurrentCameraLensFacing() == CameraCharacteristics.LENS_FACING_FRONT, displayOrientation);
56 |
57 | if (null == nv21Data) {
58 | nv21Data = new byte[width * height * 3 / 2];
59 | }
60 | if (null == rgbaData) {
61 | rgbaData = new byte[width * height * 4];
62 | }
63 | BZYUVUtil.yuvI420ToNV21(yuv420, nv21Data, width, height);
64 | // BZYUVUtil.yuvI420ToNV12(yuv420, nv21Data, width, height);
65 |
66 | BZYUVUtil.nv21ToRGBA(nv21Data,rgbaData,width,height,false,0);
67 |
68 | spaceTime += (System.currentTimeMillis() - startTime);
69 | index++;
70 | Log.d(TAG, "time cost=" + (spaceTime / index) + " bitmap.width=" + width + " height=" + height);
71 | if (null == bitmap) {
72 | bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
73 | }
74 | bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(rgbaData));
75 | iv_preview.post(new Runnable() {
76 | @Override
77 | public void run() {
78 | iv_preview.setImageBitmap(bitmap);
79 | }
80 | });
81 | }
82 | });
83 |
84 | }
85 |
86 | @Override
87 | protected void onResume() {
88 | super.onResume();
89 | bz_camera2_view.onResume();
90 | }
91 |
92 | @Override
93 | protected void onPause() {
94 | super.onPause();
95 | bz_camera2_view.onPause();
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/src/main/java/com/luoye/bzyuvlib/ZoomYUVActivity.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.ImageFormat;
5 | import android.hardware.Camera;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 | import android.widget.ImageView;
9 |
10 | import androidx.appcompat.app.AppCompatActivity;
11 |
12 | import com.luoye.bzcamera.BZCameraView;
13 | import com.luoye.bzcamera.listener.OnCameraStateListener;
14 |
15 | import java.nio.ByteBuffer;
16 |
17 | public class ZoomYUVActivity extends AppCompatActivity {
18 | private static final String TAG = "bz_ZoomYUVActivity";
19 |
20 | private BZCameraView bz_camera_view;
21 | private ImageView bz_image_view;
22 | private byte[] argbByteBuffer = null;
23 | private int index = 0;
24 | private Bitmap bitmap = null;
25 | private long totalTime = 0;
26 | private byte[] yuvBuffer = null;
27 | private byte[] zoomYuvBuffer = null;
28 | private int zoomWidth = 240;
29 | private int zoomHeight = 320;
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_zoom_yuv);
35 | bz_camera_view = findViewById(R.id.bz_camera_view);
36 | bz_camera_view.setPreviewTargetSize(480, 640);
37 | bz_image_view = findViewById(R.id.bz_image_view);
38 |
39 |
40 | bz_camera_view.setPreviewFormat(ImageFormat.NV21);
41 | bz_camera_view.setNeedCallBackData(true);
42 | bz_camera_view.setOnCameraStateListener(new OnCameraStateListener() {
43 | @Override
44 | public void onPreviewSuccess(Camera camera, int width, int height) {
45 |
46 | }
47 |
48 | @Override
49 | public void onPreviewFail(String message) {
50 |
51 | }
52 |
53 | @Override
54 | public void onPreviewDataUpdate(byte[] data, int width, int height, int displayOrientation, int cameraId) {
55 | if (null == yuvBuffer) {
56 | yuvBuffer = new byte[width * height * 3 / 2];
57 | }
58 | if (null == zoomYuvBuffer) {
59 | zoomYuvBuffer = new byte[zoomWidth * zoomHeight * 3 / 2];
60 | }
61 | if (null == argbByteBuffer) {
62 | argbByteBuffer = new byte[zoomWidth * zoomHeight * 4];
63 | }
64 |
65 | index++;
66 | long startTime = System.currentTimeMillis();
67 | BZYUVUtil.preHandleNV21(data, yuvBuffer, width, height, cameraId == Camera.CameraInfo.CAMERA_FACING_FRONT, displayOrientation);
68 |
69 | int tempWidth = width;
70 | int tempHeight = height;
71 | if (displayOrientation == 270 || displayOrientation == 90) {
72 | tempWidth = height;
73 | tempHeight = width;
74 | }
75 | BZYUVUtil.zoomYUV420(yuvBuffer, zoomYuvBuffer, tempWidth, tempHeight, zoomWidth, zoomHeight);
76 |
77 |
78 | BZYUVUtil.yuv420ToRGBA(zoomYuvBuffer, argbByteBuffer, zoomWidth, zoomHeight, false, 0);
79 | totalTime += (System.currentTimeMillis() - startTime);
80 | Log.d(TAG, "time cost=" + (totalTime / index));
81 | if (null == bitmap) {
82 | bitmap = Bitmap.createBitmap(zoomWidth, zoomHeight, Bitmap.Config.ARGB_8888);
83 | }
84 | bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(argbByteBuffer));
85 | bz_image_view.post(new Runnable() {
86 | @Override
87 | public void run() {
88 | bz_image_view.setImageBitmap(bitmap);
89 | }
90 | });
91 | }
92 |
93 | @Override
94 | public void onCameraClose() {
95 |
96 | }
97 | });
98 | }
99 |
100 | @Override
101 | protected void onResume() {
102 | super.onResume();
103 | bz_camera_view.onResume();
104 | }
105 |
106 | @Override
107 | protected void onPause() {
108 | super.onPause();
109 | bz_camera_view.onPause();
110 | }
111 |
112 | @Override
113 | protected void onDestroy() {
114 | super.onDestroy();
115 | Log.d("onDestroy", "yuvFileOutputStream.close");
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/timg.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/drawable/timg.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/timg_2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/drawable/timg_2.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_bitmap2_y_u_v.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
20 |
21 |
26 |
27 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_camera.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
19 |
20 |
25 |
26 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_camera1_y_u_v_crop.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
19 |
20 |
25 |
26 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_camera2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
23 |
24 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_camera2_y_u_v_crop.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
23 |
24 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_grey_image_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
20 |
21 |
22 |
30 |
31 |
39 |
40 |
48 |
49 |
57 |
58 |
66 |
67 |
75 |
76 |
84 |
85 |
93 |
94 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_r_g_b_a_handle.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_yuv420_to_nv_21.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
23 |
24 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_zoom_yuv.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
19 |
20 |
25 |
26 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BZYUVLib
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/luoye/bzyuvlib/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
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() {
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 | google()
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.3.1'
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | google()
18 | mavenCentral()
19 | maven { url "https://nexus.raoyunsoft.com/repository/maven-releases/" }
20 | maven { url "https://nexus.raoyunsoft.com/repository/maven-snapshots/" }
21 | }
22 | tasks.withType(Javadoc) {
23 | options.addStringOption('Xdoclint:none', '-quiet')
24 | options.addStringOption('encoding', 'UTF-8')
25 | }
26 | }
27 |
28 | task clean(type: Delete) {
29 | delete rootProject.buildDir
30 | }
31 |
--------------------------------------------------------------------------------
/bzyuv/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/bzyuv/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'maven-publish'
3 |
4 |
5 | android {
6 | compileSdkVersion 33
7 |
8 | defaultConfig {
9 | minSdkVersion 21
10 | targetSdkVersion 33
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles 'consumer-rules.pro'
16 | externalNativeBuild {
17 | cmake {
18 | cppFlags "-std=c++11"
19 | version "3.18.1"
20 | }
21 | }
22 | ndk {
23 | abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
24 | }
25 | }
26 |
27 | buildTypes {
28 | release {
29 | minifyEnabled false
30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
31 | }
32 | }
33 | externalNativeBuild {
34 | cmake {
35 | path "src/main/cpp/CMakeLists.txt"
36 | }
37 | }
38 | lintOptions {
39 | abortOnError false
40 | }
41 | ndkVersion '22.1.7171670'
42 | }
43 |
44 | ext {
45 | NEXUS_USER = ''
46 | NEXUS_PASSWORD = ''
47 | RELEASE_SNAPSHOT = false
48 |
49 | POM_URL_SNAP = 'https://nexus.raoyunsoft.com/repository/maven-snapshots/'
50 | POM_URL = 'https://nexus.raoyunsoft.com/repository/maven-releases/'
51 |
52 | POM_GROUP_ID = 'com.guaishou.bzlib'
53 | POM_ATRIFACT_ID = 'bzyuv'
54 | POM_VERSION = '1.1.21'
55 | }
56 | if (System.getenv('NEXUS_USER')) {
57 | NEXUS_USER = System.getenv('NEXUS_USER')
58 | }
59 | if (System.getenv('NEXUS_PASSWORD')) {
60 | NEXUS_PASSWORD = System.getenv('NEXUS_PASSWORD')
61 | }
62 | println("NEXUS_USER=" + NEXUS_USER + " NEXUS_PASSWORD=" + NEXUS_PASSWORD)
63 |
64 | afterEvaluate {
65 | publishing {
66 | publications {
67 | release(MavenPublication) {
68 | from components.release
69 | groupId = POM_GROUP_ID
70 | artifactId = POM_ATRIFACT_ID
71 | artifact androidSourcesJar
72 | version = RELEASE_SNAPSHOT ? POM_VERSION + "-SNAPSHOT" : POM_VERSION
73 | }
74 | }
75 | repositories {
76 | maven {
77 | url RELEASE_SNAPSHOT ? POM_URL_SNAP : POM_URL
78 | credentials {
79 | username NEXUS_USER
80 | password NEXUS_PASSWORD
81 | }
82 | }
83 | }
84 | }
85 | }
86 |
87 | tasks.register('androidSourcesJar', Jar) {
88 | archiveClassifier.set('sources')
89 | from android.sourceSets.main.java.getSrcDirs()
90 | }
91 | artifacts {
92 | archives androidSourcesJar
93 | }
94 |
95 | dependencies {
96 | implementation fileTree(dir: 'libs', include: ['*.jar'])
97 | }
98 |
--------------------------------------------------------------------------------
/bzyuv/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/bzyuv/consumer-rules.pro
--------------------------------------------------------------------------------
/bzyuv/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/bzyuv/src/androidTest/java/com/luoye/bzyuv/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuv;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.luoye.bzyuv.test", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/bzyuv/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/BZLogUtil.cpp:
--------------------------------------------------------------------------------
1 | //
2 | /**
3 | * Created by zhandalin on 2018-09-10 11:26.
4 | * 说明:
5 | */
6 | //
7 |
8 | #include "BZLogUtil.h"
9 |
10 | bool BZLogUtil::enableLog = true;
11 |
12 | void BZLogUtil::logV(const char *fmt, ...) {
13 | if (enableLog) {
14 | va_list ap;
15 | char buf[LOG_BUF_SIZE];
16 | va_start(ap, fmt);
17 | vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
18 | va_end(ap);
19 | __android_log_write(ANDROID_LOG_VERBOSE, BZLOG_TAG, buf);
20 | }
21 | }
22 |
23 | void BZLogUtil::logD(const char *fmt, ...) {
24 | if (enableLog) {
25 | va_list ap;
26 | char buf[LOG_BUF_SIZE];
27 | va_start(ap, fmt);
28 | vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
29 | va_end(ap);
30 | __android_log_write(ANDROID_LOG_DEBUG, BZLOG_TAG, buf);
31 | }
32 | }
33 |
34 | void BZLogUtil::logE(const char *fmt, ...) {
35 | if (enableLog) {
36 | va_list ap;
37 | char buf[LOG_BUF_SIZE];
38 | va_start(ap, fmt);
39 | vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
40 | va_end(ap);
41 | __android_log_write(ANDROID_LOG_ERROR, BZLOG_TAG, buf);
42 | }
43 | }
44 |
45 | void BZLogUtil::logW(const char *fmt, ...) {
46 | if (enableLog) {
47 | va_list ap;
48 | char buf[LOG_BUF_SIZE];
49 | va_start(ap, fmt);
50 | vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
51 | va_end(ap);
52 | __android_log_write(ANDROID_LOG_WARN, BZLOG_TAG, buf);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/BZLogUtil.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by luoye on 2017/3/16.
3 | //
4 |
5 | #ifndef BZFFMPEG_BZLOG_H
6 | #define BZFFMPEG_BZLOG_H
7 |
8 | #include
9 | #include
10 |
11 | #define LOG_BUF_SIZE 1024
12 | #define BZLOG_TAG "bz_"
13 |
14 | class BZLogUtil {
15 | public:
16 | static bool enableLog;
17 |
18 | static void logV(const char *fmt, ...);
19 |
20 | static void logD(const char *fmt, ...);
21 |
22 | static void logW(const char *fmt, ...);
23 |
24 | static void logE(const char *fmt, ...);
25 | };
26 |
27 | #endif //BZFFMPEG_BZLOG_H
28 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 |
14 | add_library( # Sets the name of the library.
15 | bzyuvlib
16 |
17 | # Sets the library as a shared library.
18 | SHARED
19 |
20 | # Provides a relative path to your source file(s).
21 | native-lib.cpp
22 | bz_time.cpp
23 | BZLogUtil.cpp
24 | )
25 |
26 | # Searches for a specified prebuilt library and stores the path as a
27 | # variable. Because CMake includes system libraries in the search path by
28 | # default, you only need to specify the name of the public NDK library
29 | # you want to add. CMake verifies that the library exists before
30 | # completing its build.
31 |
32 |
33 | find_library( # Sets the name of the path variable.
34 | log-lib
35 |
36 | # Specifies the name of the NDK library that
37 | # you want CMake to locate.
38 | log)
39 | find_library(jnigraphics-lib jnigraphics)
40 |
41 | add_library(yuv-lib
42 | STATIC
43 | IMPORTED)
44 | set_target_properties(yuv-lib
45 | PROPERTIES IMPORTED_LOCATION
46 | ${Project_SOURCE_DIR}/lib/${ANDROID_ABI}/libyuv_static.a)
47 |
48 | include_directories(
49 | ./
50 | ./include/
51 | ./include/libyuv/
52 | )
53 | # Specifies libraries CMake should link to your target library. You
54 | # can link multiple libraries, such as libraries you define in this
55 | # build script, prebuilt third-party libraries, or system libraries.
56 |
57 | target_link_libraries( # Specifies the target library.
58 | bzyuvlib
59 |
60 | # Links the target library to the log library
61 | # included in the NDK.
62 | yuv-lib ${log-lib} ${jnigraphics-lib})
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/bz_time.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by zhandalin on 2017-04-21 11:26.
3 | * 说明:
4 | */
5 |
6 | #include "bz_time.h"
7 |
8 |
9 | int64_t getCurrentTime() {
10 | struct timeval tv;
11 | gettimeofday(&tv, NULL);
12 | return (int64_t) tv.tv_sec * 1000 + tv.tv_usec / 1000;
13 | }
14 |
15 | int64_t getMicrosecondTime() {
16 | struct timeval tv;
17 | gettimeofday(&tv, NULL);
18 | return (int64_t) tv.tv_sec * 1000000 + tv.tv_usec;
19 | }
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/bz_time.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by zhandalin on 2017-04-21 11:26.
3 | * 说明:获取时间
4 | */
5 |
6 | #ifndef BZFFMPEG_BZ_TIME_H
7 | #define BZFFMPEG_BZ_TIME_H
8 |
9 | #include
10 | #include
11 |
12 |
13 | //返回当前时间的微妙值
14 | int64_t getMicrosecondTime();
15 |
16 | //返回当前时间的毫秒值
17 | int64_t getCurrentTime();
18 |
19 | #endif //BZFFMPEG_BZ_TIME_H
20 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/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 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/basic_types.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_
12 | #define INCLUDE_LIBYUV_BASIC_TYPES_H_
13 |
14 | #include // For size_t and NULL
15 |
16 | #if !defined(INT_TYPES_DEFINED) && !defined(GG_LONGLONG)
17 | #define INT_TYPES_DEFINED
18 |
19 | #if defined(_MSC_VER) && (_MSC_VER < 1600)
20 | #include // for uintptr_t on x86
21 | typedef unsigned __int64 uint64_t;
22 | typedef __int64 int64_t;
23 | typedef unsigned int uint32_t;
24 | typedef int int32_t;
25 | typedef unsigned short uint16_t;
26 | typedef short int16_t;
27 | typedef unsigned char uint8_t;
28 | typedef signed char int8_t;
29 | #else
30 | #include // for uintptr_t and C99 types
31 | #endif // defined(_MSC_VER) && (_MSC_VER < 1600)
32 | // Types are deprecated. Enable this macro for legacy types.
33 | #ifdef LIBYUV_LEGACY_TYPES
34 | typedef uint64_t uint64;
35 | typedef int64_t int64;
36 | typedef uint32_t uint32;
37 | typedef int32_t int32;
38 | typedef uint16_t uint16;
39 | typedef int16_t int16;
40 | typedef uint8_t uint8;
41 | typedef int8_t int8;
42 | #endif // LIBYUV_LEGACY_TYPES
43 | #endif // INT_TYPES_DEFINED
44 |
45 | #if !defined(LIBYUV_API)
46 | #if defined(_WIN32) || defined(__CYGWIN__)
47 | #if defined(LIBYUV_BUILDING_SHARED_LIBRARY)
48 | #define LIBYUV_API __declspec(dllexport)
49 | #elif defined(LIBYUV_USING_SHARED_LIBRARY)
50 | #define LIBYUV_API __declspec(dllimport)
51 | #else
52 | #define LIBYUV_API
53 | #endif // LIBYUV_BUILDING_SHARED_LIBRARY
54 | #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \
55 | (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \
56 | defined(LIBYUV_USING_SHARED_LIBRARY))
57 | #define LIBYUV_API __attribute__((visibility("default")))
58 | #else
59 | #define LIBYUV_API
60 | #endif // __GNUC__
61 | #endif // LIBYUV_API
62 |
63 | // TODO(fbarchard): Remove bool macros.
64 | #define LIBYUV_BOOL int
65 | #define LIBYUV_FALSE 0
66 | #define LIBYUV_TRUE 1
67 |
68 | #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_
69 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/compare.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_COMPARE_H_
12 | #define INCLUDE_LIBYUV_COMPARE_H_
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | // Compute a hash for specified memory. Seed of 5381 recommended.
22 | LIBYUV_API
23 | uint32_t HashDjb2(const uint8_t* src, uint64_t count, uint32_t seed);
24 |
25 | // Hamming Distance
26 | LIBYUV_API
27 | uint64_t ComputeHammingDistance(const uint8_t* src_a,
28 | const uint8_t* src_b,
29 | int count);
30 |
31 | // Scan an opaque argb image and return fourcc based on alpha offset.
32 | // Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown.
33 | LIBYUV_API
34 | uint32_t ARGBDetect(const uint8_t* argb,
35 | int stride_argb,
36 | int width,
37 | int height);
38 |
39 | // Sum Square Error - used to compute Mean Square Error or PSNR.
40 | LIBYUV_API
41 | uint64_t ComputeSumSquareError(const uint8_t* src_a,
42 | const uint8_t* src_b,
43 | int count);
44 |
45 | LIBYUV_API
46 | uint64_t ComputeSumSquareErrorPlane(const uint8_t* src_a,
47 | int stride_a,
48 | const uint8_t* src_b,
49 | int stride_b,
50 | int width,
51 | int height);
52 |
53 | static const int kMaxPsnr = 128;
54 |
55 | LIBYUV_API
56 | double SumSquareErrorToPsnr(uint64_t sse, uint64_t count);
57 |
58 | LIBYUV_API
59 | double CalcFramePsnr(const uint8_t* src_a,
60 | int stride_a,
61 | const uint8_t* src_b,
62 | int stride_b,
63 | int width,
64 | int height);
65 |
66 | LIBYUV_API
67 | double I420Psnr(const uint8_t* src_y_a,
68 | int stride_y_a,
69 | const uint8_t* src_u_a,
70 | int stride_u_a,
71 | const uint8_t* src_v_a,
72 | int stride_v_a,
73 | const uint8_t* src_y_b,
74 | int stride_y_b,
75 | const uint8_t* src_u_b,
76 | int stride_u_b,
77 | const uint8_t* src_v_b,
78 | int stride_v_b,
79 | int width,
80 | int height);
81 |
82 | LIBYUV_API
83 | double CalcFrameSsim(const uint8_t* src_a,
84 | int stride_a,
85 | const uint8_t* src_b,
86 | int stride_b,
87 | int width,
88 | int height);
89 |
90 | LIBYUV_API
91 | double I420Ssim(const uint8_t* src_y_a,
92 | int stride_y_a,
93 | const uint8_t* src_u_a,
94 | int stride_u_a,
95 | const uint8_t* src_v_a,
96 | int stride_v_a,
97 | const uint8_t* src_y_b,
98 | int stride_y_b,
99 | const uint8_t* src_u_b,
100 | int stride_u_b,
101 | const uint8_t* src_v_b,
102 | int stride_v_b,
103 | int width,
104 | int height);
105 |
106 | #ifdef __cplusplus
107 | } // extern "C"
108 | } // namespace libyuv
109 | #endif
110 |
111 | #endif // INCLUDE_LIBYUV_COMPARE_H_
112 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/compare_row.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_COMPARE_ROW_H_
12 | #define INCLUDE_LIBYUV_COMPARE_ROW_H_
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | #if defined(__pnacl__) || defined(__CLR_VER) || \
22 | (defined(__native_client__) && defined(__x86_64__)) || \
23 | (defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
24 | #define LIBYUV_DISABLE_X86
25 | #endif
26 | #if defined(__native_client__)
27 | #define LIBYUV_DISABLE_NEON
28 | #endif
29 | // MemorySanitizer does not support assembly code yet. http://crbug.com/344505
30 | #if defined(__has_feature)
31 | #if __has_feature(memory_sanitizer)
32 | #define LIBYUV_DISABLE_X86
33 | #endif
34 | #endif
35 | // Visual C 2012 required for AVX2.
36 | #if defined(_M_IX86) && !defined(__clang__) && defined(_MSC_VER) && \
37 | _MSC_VER >= 1700
38 | #define VISUALC_HAS_AVX2 1
39 | #endif // VisualStudio >= 2012
40 |
41 | // clang >= 3.4.0 required for AVX2.
42 | #if defined(__clang__) && (defined(__x86_64__) || defined(__i386__))
43 | #if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4))
44 | #define CLANG_HAS_AVX2 1
45 | #endif // clang >= 3.4
46 | #endif // __clang__
47 |
48 | // The following are available for Visual C and GCC:
49 | #if !defined(LIBYUV_DISABLE_X86) && \
50 | (defined(__x86_64__) || defined(__i386__) || defined(_M_IX86))
51 | #define HAS_HASHDJB2_SSE41
52 | #define HAS_SUMSQUAREERROR_SSE2
53 | #define HAS_HAMMINGDISTANCE_SSE42
54 | #endif
55 |
56 | // The following are available for Visual C and clangcl 32 bit:
57 | #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER) && \
58 | (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
59 | #define HAS_HASHDJB2_AVX2
60 | #define HAS_SUMSQUAREERROR_AVX2
61 | #endif
62 |
63 | // The following are available for GCC and clangcl 64 bit:
64 | #if !defined(LIBYUV_DISABLE_X86) && \
65 | (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER)))
66 | #define HAS_HAMMINGDISTANCE_SSSE3
67 | #endif
68 |
69 | // The following are available for GCC and clangcl 64 bit:
70 | #if !defined(LIBYUV_DISABLE_X86) && defined(CLANG_HAS_AVX2) && \
71 | (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER)))
72 | #define HAS_HAMMINGDISTANCE_AVX2
73 | #endif
74 |
75 | // The following are available for Neon:
76 | #if !defined(LIBYUV_DISABLE_NEON) && \
77 | (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__))
78 | #define HAS_SUMSQUAREERROR_NEON
79 | #define HAS_HAMMINGDISTANCE_NEON
80 | #endif
81 |
82 | #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
83 | #define HAS_HAMMINGDISTANCE_MSA
84 | #define HAS_SUMSQUAREERROR_MSA
85 | #endif
86 |
87 | #if !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A)
88 | #define HAS_HAMMINGDISTANCE_MMI
89 | #define HAS_SUMSQUAREERROR_MMI
90 | #endif
91 |
92 | uint32_t HammingDistance_C(const uint8_t* src_a,
93 | const uint8_t* src_b,
94 | int count);
95 | uint32_t HammingDistance_SSE42(const uint8_t* src_a,
96 | const uint8_t* src_b,
97 | int count);
98 | uint32_t HammingDistance_SSSE3(const uint8_t* src_a,
99 | const uint8_t* src_b,
100 | int count);
101 | uint32_t HammingDistance_AVX2(const uint8_t* src_a,
102 | const uint8_t* src_b,
103 | int count);
104 | uint32_t HammingDistance_NEON(const uint8_t* src_a,
105 | const uint8_t* src_b,
106 | int count);
107 | uint32_t HammingDistance_MSA(const uint8_t* src_a,
108 | const uint8_t* src_b,
109 | int count);
110 | uint32_t HammingDistance_MMI(const uint8_t* src_a,
111 | const uint8_t* src_b,
112 | int count);
113 | uint32_t SumSquareError_C(const uint8_t* src_a,
114 | const uint8_t* src_b,
115 | int count);
116 | uint32_t SumSquareError_SSE2(const uint8_t* src_a,
117 | const uint8_t* src_b,
118 | int count);
119 | uint32_t SumSquareError_AVX2(const uint8_t* src_a,
120 | const uint8_t* src_b,
121 | int count);
122 | uint32_t SumSquareError_NEON(const uint8_t* src_a,
123 | const uint8_t* src_b,
124 | int count);
125 | uint32_t SumSquareError_MSA(const uint8_t* src_a,
126 | const uint8_t* src_b,
127 | int count);
128 | uint32_t SumSquareError_MMI(const uint8_t* src_a,
129 | const uint8_t* src_b,
130 | int count);
131 |
132 | uint32_t HashDjb2_C(const uint8_t* src, int count, uint32_t seed);
133 | uint32_t HashDjb2_SSE41(const uint8_t* src, int count, uint32_t seed);
134 | uint32_t HashDjb2_AVX2(const uint8_t* src, int count, uint32_t seed);
135 |
136 | #ifdef __cplusplus
137 | } // extern "C"
138 | } // namespace libyuv
139 | #endif
140 |
141 | #endif // INCLUDE_LIBYUV_COMPARE_ROW_H_
142 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/convert.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_CONVERT_H_
12 | #define INCLUDE_LIBYUV_CONVERT_H_
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #include "libyuv/rotate.h" // For enum RotationMode.
17 |
18 | // TODO(fbarchard): fix WebRTC source to include following libyuv headers:
19 | #include "libyuv/convert_argb.h" // For WebRTC I420ToARGB. b/620
20 | #include "libyuv/convert_from.h" // For WebRTC ConvertFromI420. b/620
21 | #include "libyuv/planar_functions.h" // For WebRTC I420Rect, CopyPlane. b/618
22 |
23 | #ifdef __cplusplus
24 | namespace libyuv {
25 | extern "C" {
26 | #endif
27 |
28 | // Convert I444 to I420.
29 | LIBYUV_API
30 | int I444ToI420(const uint8_t* src_y,
31 | int src_stride_y,
32 | const uint8_t* src_u,
33 | int src_stride_u,
34 | const uint8_t* src_v,
35 | int src_stride_v,
36 | uint8_t* dst_y,
37 | int dst_stride_y,
38 | uint8_t* dst_u,
39 | int dst_stride_u,
40 | uint8_t* dst_v,
41 | int dst_stride_v,
42 | int width,
43 | int height);
44 |
45 | // Convert I444 to NV12.
46 | LIBYUV_API
47 | int I444ToNV12(const uint8_t* src_y,
48 | int src_stride_y,
49 | const uint8_t* src_u,
50 | int src_stride_u,
51 | const uint8_t* src_v,
52 | int src_stride_v,
53 | uint8_t* dst_y,
54 | int dst_stride_y,
55 | uint8_t* dst_uv,
56 | int dst_stride_uv,
57 | int width,
58 | int height);
59 |
60 | // Convert I444 to NV21.
61 | LIBYUV_API
62 | int I444ToNV21(const uint8_t* src_y,
63 | int src_stride_y,
64 | const uint8_t* src_u,
65 | int src_stride_u,
66 | const uint8_t* src_v,
67 | int src_stride_v,
68 | uint8_t* dst_y,
69 | int dst_stride_y,
70 | uint8_t* dst_vu,
71 | int dst_stride_vu,
72 | int width,
73 | int height);
74 |
75 | // Convert I422 to I420.
76 | LIBYUV_API
77 | int I422ToI420(const uint8_t* src_y,
78 | int src_stride_y,
79 | const uint8_t* src_u,
80 | int src_stride_u,
81 | const uint8_t* src_v,
82 | int src_stride_v,
83 | uint8_t* dst_y,
84 | int dst_stride_y,
85 | uint8_t* dst_u,
86 | int dst_stride_u,
87 | uint8_t* dst_v,
88 | int dst_stride_v,
89 | int width,
90 | int height);
91 |
92 | // Convert I422 to NV21.
93 | LIBYUV_API
94 | int I422ToNV21(const uint8_t* src_y,
95 | int src_stride_y,
96 | const uint8_t* src_u,
97 | int src_stride_u,
98 | const uint8_t* src_v,
99 | int src_stride_v,
100 | uint8_t* dst_y,
101 | int dst_stride_y,
102 | uint8_t* dst_vu,
103 | int dst_stride_vu,
104 | int width,
105 | int height);
106 |
107 | // Copy I420 to I420.
108 | #define I420ToI420 I420Copy
109 | LIBYUV_API
110 | int I420Copy(const uint8_t* src_y,
111 | int src_stride_y,
112 | const uint8_t* src_u,
113 | int src_stride_u,
114 | const uint8_t* src_v,
115 | int src_stride_v,
116 | uint8_t* dst_y,
117 | int dst_stride_y,
118 | uint8_t* dst_u,
119 | int dst_stride_u,
120 | uint8_t* dst_v,
121 | int dst_stride_v,
122 | int width,
123 | int height);
124 |
125 | // Copy I010 to I010
126 | #define I010ToI010 I010Copy
127 | #define H010ToH010 I010Copy
128 | LIBYUV_API
129 | int I010Copy(const uint16_t* src_y,
130 | int src_stride_y,
131 | const uint16_t* src_u,
132 | int src_stride_u,
133 | const uint16_t* src_v,
134 | int src_stride_v,
135 | uint16_t* dst_y,
136 | int dst_stride_y,
137 | uint16_t* dst_u,
138 | int dst_stride_u,
139 | uint16_t* dst_v,
140 | int dst_stride_v,
141 | int width,
142 | int height);
143 |
144 | // Convert 10 bit YUV to 8 bit
145 | #define H010ToH420 I010ToI420
146 | LIBYUV_API
147 | int I010ToI420(const uint16_t* src_y,
148 | int src_stride_y,
149 | const uint16_t* src_u,
150 | int src_stride_u,
151 | const uint16_t* src_v,
152 | int src_stride_v,
153 | uint8_t* dst_y,
154 | int dst_stride_y,
155 | uint8_t* dst_u,
156 | int dst_stride_u,
157 | uint8_t* dst_v,
158 | int dst_stride_v,
159 | int width,
160 | int height);
161 |
162 | // Convert I400 (grey) to I420.
163 | LIBYUV_API
164 | int I400ToI420(const uint8_t* src_y,
165 | int src_stride_y,
166 | uint8_t* dst_y,
167 | int dst_stride_y,
168 | uint8_t* dst_u,
169 | int dst_stride_u,
170 | uint8_t* dst_v,
171 | int dst_stride_v,
172 | int width,
173 | int height);
174 |
175 | // Convert I400 (grey) to NV21.
176 | LIBYUV_API
177 | int I400ToNV21(const uint8_t* src_y,
178 | int src_stride_y,
179 | uint8_t* dst_y,
180 | int dst_stride_y,
181 | uint8_t* dst_vu,
182 | int dst_stride_vu,
183 | int width,
184 | int height);
185 |
186 | #define J400ToJ420 I400ToI420
187 |
188 | // Convert NV12 to I420.
189 | LIBYUV_API
190 | int NV12ToI420(const uint8_t* src_y,
191 | int src_stride_y,
192 | const uint8_t* src_uv,
193 | int src_stride_uv,
194 | uint8_t* dst_y,
195 | int dst_stride_y,
196 | uint8_t* dst_u,
197 | int dst_stride_u,
198 | uint8_t* dst_v,
199 | int dst_stride_v,
200 | int width,
201 | int height);
202 |
203 | // Convert NV21 to I420.
204 | LIBYUV_API
205 | int NV21ToI420(const uint8_t* src_y,
206 | int src_stride_y,
207 | const uint8_t* src_vu,
208 | int src_stride_vu,
209 | uint8_t* dst_y,
210 | int dst_stride_y,
211 | uint8_t* dst_u,
212 | int dst_stride_u,
213 | uint8_t* dst_v,
214 | int dst_stride_v,
215 | int width,
216 | int height);
217 |
218 | // Convert YUY2 to I420.
219 | LIBYUV_API
220 | int YUY2ToI420(const uint8_t* src_yuy2,
221 | int src_stride_yuy2,
222 | uint8_t* dst_y,
223 | int dst_stride_y,
224 | uint8_t* dst_u,
225 | int dst_stride_u,
226 | uint8_t* dst_v,
227 | int dst_stride_v,
228 | int width,
229 | int height);
230 |
231 | // Convert UYVY to I420.
232 | LIBYUV_API
233 | int UYVYToI420(const uint8_t* src_uyvy,
234 | int src_stride_uyvy,
235 | uint8_t* dst_y,
236 | int dst_stride_y,
237 | uint8_t* dst_u,
238 | int dst_stride_u,
239 | uint8_t* dst_v,
240 | int dst_stride_v,
241 | int width,
242 | int height);
243 |
244 | // Convert AYUV to NV12.
245 | LIBYUV_API
246 | int AYUVToNV12(const uint8_t* src_ayuv,
247 | int src_stride_ayuv,
248 | uint8_t* dst_y,
249 | int dst_stride_y,
250 | uint8_t* dst_uv,
251 | int dst_stride_uv,
252 | int width,
253 | int height);
254 |
255 | // Convert AYUV to NV21.
256 | LIBYUV_API
257 | int AYUVToNV21(const uint8_t* src_ayuv,
258 | int src_stride_ayuv,
259 | uint8_t* dst_y,
260 | int dst_stride_y,
261 | uint8_t* dst_vu,
262 | int dst_stride_vu,
263 | int width,
264 | int height);
265 |
266 | // Convert M420 to I420.
267 | LIBYUV_API
268 | int M420ToI420(const uint8_t* src_m420,
269 | int src_stride_m420,
270 | uint8_t* dst_y,
271 | int dst_stride_y,
272 | uint8_t* dst_u,
273 | int dst_stride_u,
274 | uint8_t* dst_v,
275 | int dst_stride_v,
276 | int width,
277 | int height);
278 |
279 | // Convert Android420 to I420.
280 | LIBYUV_API
281 | int Android420ToI420(const uint8_t* src_y,
282 | int src_stride_y,
283 | const uint8_t* src_u,
284 | int src_stride_u,
285 | const uint8_t* src_v,
286 | int src_stride_v,
287 | int src_pixel_stride_uv,
288 | uint8_t* dst_y,
289 | int dst_stride_y,
290 | uint8_t* dst_u,
291 | int dst_stride_u,
292 | uint8_t* dst_v,
293 | int dst_stride_v,
294 | int width,
295 | int height);
296 |
297 | // ARGB little endian (bgra in memory) to I420.
298 | LIBYUV_API
299 | int ARGBToI420(const uint8_t* src_argb,
300 | int src_stride_argb,
301 | uint8_t* dst_y,
302 | int dst_stride_y,
303 | uint8_t* dst_u,
304 | int dst_stride_u,
305 | uint8_t* dst_v,
306 | int dst_stride_v,
307 | int width,
308 | int height);
309 |
310 | // BGRA little endian (argb in memory) to I420.
311 | LIBYUV_API
312 | int BGRAToI420(const uint8_t* src_bgra,
313 | int src_stride_bgra,
314 | uint8_t* dst_y,
315 | int dst_stride_y,
316 | uint8_t* dst_u,
317 | int dst_stride_u,
318 | uint8_t* dst_v,
319 | int dst_stride_v,
320 | int width,
321 | int height);
322 |
323 | // ABGR little endian (rgba in memory) to I420.
324 | LIBYUV_API
325 | int ABGRToI420(const uint8_t* src_abgr,
326 | int src_stride_abgr,
327 | uint8_t* dst_y,
328 | int dst_stride_y,
329 | uint8_t* dst_u,
330 | int dst_stride_u,
331 | uint8_t* dst_v,
332 | int dst_stride_v,
333 | int width,
334 | int height);
335 |
336 | // RGBA little endian (abgr in memory) to I420.
337 | LIBYUV_API
338 | int RGBAToI420(const uint8_t* src_rgba,
339 | int src_stride_rgba,
340 | uint8_t* dst_y,
341 | int dst_stride_y,
342 | uint8_t* dst_u,
343 | int dst_stride_u,
344 | uint8_t* dst_v,
345 | int dst_stride_v,
346 | int width,
347 | int height);
348 |
349 | // RGB little endian (bgr in memory) to I420.
350 | LIBYUV_API
351 | int RGB24ToI420(const uint8_t* src_rgb24,
352 | int src_stride_rgb24,
353 | uint8_t* dst_y,
354 | int dst_stride_y,
355 | uint8_t* dst_u,
356 | int dst_stride_u,
357 | uint8_t* dst_v,
358 | int dst_stride_v,
359 | int width,
360 | int height);
361 |
362 | // RGB little endian (bgr in memory) to J420.
363 | LIBYUV_API
364 | int RGB24ToJ420(const uint8_t* src_rgb24,
365 | int src_stride_rgb24,
366 | uint8_t* dst_y,
367 | int dst_stride_y,
368 | uint8_t* dst_u,
369 | int dst_stride_u,
370 | uint8_t* dst_v,
371 | int dst_stride_v,
372 | int width,
373 | int height);
374 |
375 | // RGB big endian (rgb in memory) to I420.
376 | LIBYUV_API
377 | int RAWToI420(const uint8_t* src_raw,
378 | int src_stride_raw,
379 | uint8_t* dst_y,
380 | int dst_stride_y,
381 | uint8_t* dst_u,
382 | int dst_stride_u,
383 | uint8_t* dst_v,
384 | int dst_stride_v,
385 | int width,
386 | int height);
387 |
388 | // RGB16 (RGBP fourcc) little endian to I420.
389 | LIBYUV_API
390 | int RGB565ToI420(const uint8_t* src_rgb565,
391 | int src_stride_rgb565,
392 | uint8_t* dst_y,
393 | int dst_stride_y,
394 | uint8_t* dst_u,
395 | int dst_stride_u,
396 | uint8_t* dst_v,
397 | int dst_stride_v,
398 | int width,
399 | int height);
400 |
401 | // RGB15 (RGBO fourcc) little endian to I420.
402 | LIBYUV_API
403 | int ARGB1555ToI420(const uint8_t* src_argb1555,
404 | int src_stride_argb1555,
405 | uint8_t* dst_y,
406 | int dst_stride_y,
407 | uint8_t* dst_u,
408 | int dst_stride_u,
409 | uint8_t* dst_v,
410 | int dst_stride_v,
411 | int width,
412 | int height);
413 |
414 | // RGB12 (R444 fourcc) little endian to I420.
415 | LIBYUV_API
416 | int ARGB4444ToI420(const uint8_t* src_argb4444,
417 | int src_stride_argb4444,
418 | uint8_t* dst_y,
419 | int dst_stride_y,
420 | uint8_t* dst_u,
421 | int dst_stride_u,
422 | uint8_t* dst_v,
423 | int dst_stride_v,
424 | int width,
425 | int height);
426 |
427 | // RGB little endian (bgr in memory) to J400.
428 | LIBYUV_API
429 | int RGB24ToJ400(const uint8_t* src_rgb24,
430 | int src_stride_rgb24,
431 | uint8_t* dst_yj,
432 | int dst_stride_yj,
433 | int width,
434 | int height);
435 |
436 | // RGB big endian (rgb in memory) to J400.
437 | LIBYUV_API
438 | int RAWToJ400(const uint8_t* src_raw,
439 | int src_stride_raw,
440 | uint8_t* dst_yj,
441 | int dst_stride_yj,
442 | int width,
443 | int height);
444 |
445 | // src_width/height provided by capture.
446 | // dst_width/height for clipping determine final size.
447 | LIBYUV_API
448 | int MJPGToI420(const uint8_t* sample,
449 | size_t sample_size,
450 | uint8_t* dst_y,
451 | int dst_stride_y,
452 | uint8_t* dst_u,
453 | int dst_stride_u,
454 | uint8_t* dst_v,
455 | int dst_stride_v,
456 | int src_width,
457 | int src_height,
458 | int dst_width,
459 | int dst_height);
460 |
461 | // JPEG to NV21
462 | LIBYUV_API
463 | int MJPGToNV21(const uint8_t* sample,
464 | size_t sample_size,
465 | uint8_t* dst_y,
466 | int dst_stride_y,
467 | uint8_t* dst_vu,
468 | int dst_stride_vu,
469 | int src_width,
470 | int src_height,
471 | int dst_width,
472 | int dst_height);
473 |
474 | // Query size of MJPG in pixels.
475 | LIBYUV_API
476 | int MJPGSize(const uint8_t* sample,
477 | size_t sample_size,
478 | int* width,
479 | int* height);
480 |
481 | // Convert camera sample to I420 with cropping, rotation and vertical flip.
482 | // "src_size" is needed to parse MJPG.
483 | // "dst_stride_y" number of bytes in a row of the dst_y plane.
484 | // Normally this would be the same as dst_width, with recommended alignment
485 | // to 16 bytes for better efficiency.
486 | // If rotation of 90 or 270 is used, stride is affected. The caller should
487 | // allocate the I420 buffer according to rotation.
488 | // "dst_stride_u" number of bytes in a row of the dst_u plane.
489 | // Normally this would be the same as (dst_width + 1) / 2, with
490 | // recommended alignment to 16 bytes for better efficiency.
491 | // If rotation of 90 or 270 is used, stride is affected.
492 | // "crop_x" and "crop_y" are starting position for cropping.
493 | // To center, crop_x = (src_width - dst_width) / 2
494 | // crop_y = (src_height - dst_height) / 2
495 | // "src_width" / "src_height" is size of src_frame in pixels.
496 | // "src_height" can be negative indicating a vertically flipped image source.
497 | // "crop_width" / "crop_height" is the size to crop the src to.
498 | // Must be less than or equal to src_width/src_height
499 | // Cropping parameters are pre-rotation.
500 | // "rotation" can be 0, 90, 180 or 270.
501 | // "fourcc" is a fourcc. ie 'I420', 'YUY2'
502 | // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure.
503 | LIBYUV_API
504 | int ConvertToI420(const uint8_t* sample,
505 | size_t sample_size,
506 | uint8_t* dst_y,
507 | int dst_stride_y,
508 | uint8_t* dst_u,
509 | int dst_stride_u,
510 | uint8_t* dst_v,
511 | int dst_stride_v,
512 | int crop_x,
513 | int crop_y,
514 | int src_width,
515 | int src_height,
516 | int crop_width,
517 | int crop_height,
518 | enum RotationMode rotation,
519 | uint32_t fourcc);
520 |
521 | #ifdef __cplusplus
522 | } // extern "C"
523 | } // namespace libyuv
524 | #endif
525 |
526 | #endif // INCLUDE_LIBYUV_CONVERT_H_
527 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/convert_from.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_CONVERT_FROM_H_
12 | #define INCLUDE_LIBYUV_CONVERT_FROM_H_
13 |
14 | #include "libyuv/basic_types.h"
15 | #include "libyuv/rotate.h"
16 |
17 | #ifdef __cplusplus
18 | namespace libyuv {
19 | extern "C" {
20 | #endif
21 |
22 | // See Also convert.h for conversions from formats to I420.
23 |
24 | // Convert 8 bit YUV to 10 bit.
25 | #define H420ToH010 I420ToI010
26 | LIBYUV_API
27 | int I420ToI010(const uint8_t* src_y,
28 | int src_stride_y,
29 | const uint8_t* src_u,
30 | int src_stride_u,
31 | const uint8_t* src_v,
32 | int src_stride_v,
33 | uint16_t* dst_y,
34 | int dst_stride_y,
35 | uint16_t* dst_u,
36 | int dst_stride_u,
37 | uint16_t* dst_v,
38 | int dst_stride_v,
39 | int width,
40 | int height);
41 |
42 | LIBYUV_API
43 | int I420ToI422(const uint8_t* src_y,
44 | int src_stride_y,
45 | const uint8_t* src_u,
46 | int src_stride_u,
47 | const uint8_t* src_v,
48 | int src_stride_v,
49 | uint8_t* dst_y,
50 | int dst_stride_y,
51 | uint8_t* dst_u,
52 | int dst_stride_u,
53 | uint8_t* dst_v,
54 | int dst_stride_v,
55 | int width,
56 | int height);
57 |
58 | LIBYUV_API
59 | int I420ToI444(const uint8_t* src_y,
60 | int src_stride_y,
61 | const uint8_t* src_u,
62 | int src_stride_u,
63 | const uint8_t* src_v,
64 | int src_stride_v,
65 | uint8_t* dst_y,
66 | int dst_stride_y,
67 | uint8_t* dst_u,
68 | int dst_stride_u,
69 | uint8_t* dst_v,
70 | int dst_stride_v,
71 | int width,
72 | int height);
73 |
74 | // Copy to I400. Source can be I420, I422, I444, I400, NV12 or NV21.
75 | LIBYUV_API
76 | int I400Copy(const uint8_t* src_y,
77 | int src_stride_y,
78 | uint8_t* dst_y,
79 | int dst_stride_y,
80 | int width,
81 | int height);
82 |
83 | LIBYUV_API
84 | int I420ToNV12(const uint8_t* src_y,
85 | int src_stride_y,
86 | const uint8_t* src_u,
87 | int src_stride_u,
88 | const uint8_t* src_v,
89 | int src_stride_v,
90 | uint8_t* dst_y,
91 | int dst_stride_y,
92 | uint8_t* dst_uv,
93 | int dst_stride_uv,
94 | int width,
95 | int height);
96 |
97 | LIBYUV_API
98 | int I420ToNV21(const uint8_t* src_y,
99 | int src_stride_y,
100 | const uint8_t* src_u,
101 | int src_stride_u,
102 | const uint8_t* src_v,
103 | int src_stride_v,
104 | uint8_t* dst_y,
105 | int dst_stride_y,
106 | uint8_t* dst_vu,
107 | int dst_stride_vu,
108 | int width,
109 | int height);
110 |
111 | LIBYUV_API
112 | int I420ToYUY2(const uint8_t* src_y,
113 | int src_stride_y,
114 | const uint8_t* src_u,
115 | int src_stride_u,
116 | const uint8_t* src_v,
117 | int src_stride_v,
118 | uint8_t* dst_yuy2,
119 | int dst_stride_yuy2,
120 | int width,
121 | int height);
122 |
123 | LIBYUV_API
124 | int I420ToUYVY(const uint8_t* src_y,
125 | int src_stride_y,
126 | const uint8_t* src_u,
127 | int src_stride_u,
128 | const uint8_t* src_v,
129 | int src_stride_v,
130 | uint8_t* dst_uyvy,
131 | int dst_stride_uyvy,
132 | int width,
133 | int height);
134 |
135 | LIBYUV_API
136 | int I420ToARGB(const uint8_t* src_y,
137 | int src_stride_y,
138 | const uint8_t* src_u,
139 | int src_stride_u,
140 | const uint8_t* src_v,
141 | int src_stride_v,
142 | uint8_t* dst_argb,
143 | int dst_stride_argb,
144 | int width,
145 | int height);
146 |
147 | LIBYUV_API
148 | int I420ToBGRA(const uint8_t* src_y,
149 | int src_stride_y,
150 | const uint8_t* src_u,
151 | int src_stride_u,
152 | const uint8_t* src_v,
153 | int src_stride_v,
154 | uint8_t* dst_bgra,
155 | int dst_stride_bgra,
156 | int width,
157 | int height);
158 |
159 | LIBYUV_API
160 | int I420ToABGR(const uint8_t* src_y,
161 | int src_stride_y,
162 | const uint8_t* src_u,
163 | int src_stride_u,
164 | const uint8_t* src_v,
165 | int src_stride_v,
166 | uint8_t* dst_abgr,
167 | int dst_stride_abgr,
168 | int width,
169 | int height);
170 |
171 | LIBYUV_API
172 | int I420ToRGBA(const uint8_t* src_y,
173 | int src_stride_y,
174 | const uint8_t* src_u,
175 | int src_stride_u,
176 | const uint8_t* src_v,
177 | int src_stride_v,
178 | uint8_t* dst_rgba,
179 | int dst_stride_rgba,
180 | int width,
181 | int height);
182 |
183 | LIBYUV_API
184 | int I420ToRGB24(const uint8_t* src_y,
185 | int src_stride_y,
186 | const uint8_t* src_u,
187 | int src_stride_u,
188 | const uint8_t* src_v,
189 | int src_stride_v,
190 | uint8_t* dst_rgb24,
191 | int dst_stride_rgb24,
192 | int width,
193 | int height);
194 |
195 | LIBYUV_API
196 | int I420ToRAW(const uint8_t* src_y,
197 | int src_stride_y,
198 | const uint8_t* src_u,
199 | int src_stride_u,
200 | const uint8_t* src_v,
201 | int src_stride_v,
202 | uint8_t* dst_raw,
203 | int dst_stride_raw,
204 | int width,
205 | int height);
206 |
207 | LIBYUV_API
208 | int H420ToRGB24(const uint8_t* src_y,
209 | int src_stride_y,
210 | const uint8_t* src_u,
211 | int src_stride_u,
212 | const uint8_t* src_v,
213 | int src_stride_v,
214 | uint8_t* dst_rgb24,
215 | int dst_stride_rgb24,
216 | int width,
217 | int height);
218 |
219 | LIBYUV_API
220 | int H420ToRAW(const uint8_t* src_y,
221 | int src_stride_y,
222 | const uint8_t* src_u,
223 | int src_stride_u,
224 | const uint8_t* src_v,
225 | int src_stride_v,
226 | uint8_t* dst_raw,
227 | int dst_stride_raw,
228 | int width,
229 | int height);
230 |
231 | LIBYUV_API
232 | int J420ToRGB24(const uint8_t* src_y,
233 | int src_stride_y,
234 | const uint8_t* src_u,
235 | int src_stride_u,
236 | const uint8_t* src_v,
237 | int src_stride_v,
238 | uint8_t* dst_rgb24,
239 | int dst_stride_rgb24,
240 | int width,
241 | int height);
242 |
243 | LIBYUV_API
244 | int J420ToRAW(const uint8_t* src_y,
245 | int src_stride_y,
246 | const uint8_t* src_u,
247 | int src_stride_u,
248 | const uint8_t* src_v,
249 | int src_stride_v,
250 | uint8_t* dst_raw,
251 | int dst_stride_raw,
252 | int width,
253 | int height);
254 |
255 | LIBYUV_API
256 | int I420ToRGB565(const uint8_t* src_y,
257 | int src_stride_y,
258 | const uint8_t* src_u,
259 | int src_stride_u,
260 | const uint8_t* src_v,
261 | int src_stride_v,
262 | uint8_t* dst_rgb565,
263 | int dst_stride_rgb565,
264 | int width,
265 | int height);
266 |
267 | LIBYUV_API
268 | int J420ToRGB565(const uint8_t* src_y,
269 | int src_stride_y,
270 | const uint8_t* src_u,
271 | int src_stride_u,
272 | const uint8_t* src_v,
273 | int src_stride_v,
274 | uint8_t* dst_rgb565,
275 | int dst_stride_rgb565,
276 | int width,
277 | int height);
278 |
279 | LIBYUV_API
280 | int H420ToRGB565(const uint8_t* src_y,
281 | int src_stride_y,
282 | const uint8_t* src_u,
283 | int src_stride_u,
284 | const uint8_t* src_v,
285 | int src_stride_v,
286 | uint8_t* dst_rgb565,
287 | int dst_stride_rgb565,
288 | int width,
289 | int height);
290 |
291 | LIBYUV_API
292 | int I422ToRGB565(const uint8_t* src_y,
293 | int src_stride_y,
294 | const uint8_t* src_u,
295 | int src_stride_u,
296 | const uint8_t* src_v,
297 | int src_stride_v,
298 | uint8_t* dst_rgb565,
299 | int dst_stride_rgb565,
300 | int width,
301 | int height);
302 |
303 | // Convert I420 To RGB565 with 4x4 dither matrix (16 bytes).
304 | // Values in dither matrix from 0 to 7 recommended.
305 | // The order of the dither matrix is first byte is upper left.
306 |
307 | LIBYUV_API
308 | int I420ToRGB565Dither(const uint8_t* src_y,
309 | int src_stride_y,
310 | const uint8_t* src_u,
311 | int src_stride_u,
312 | const uint8_t* src_v,
313 | int src_stride_v,
314 | uint8_t* dst_rgb565,
315 | int dst_stride_rgb565,
316 | const uint8_t* dither4x4,
317 | int width,
318 | int height);
319 |
320 | LIBYUV_API
321 | int I420ToARGB1555(const uint8_t* src_y,
322 | int src_stride_y,
323 | const uint8_t* src_u,
324 | int src_stride_u,
325 | const uint8_t* src_v,
326 | int src_stride_v,
327 | uint8_t* dst_argb1555,
328 | int dst_stride_argb1555,
329 | int width,
330 | int height);
331 |
332 | LIBYUV_API
333 | int I420ToARGB4444(const uint8_t* src_y,
334 | int src_stride_y,
335 | const uint8_t* src_u,
336 | int src_stride_u,
337 | const uint8_t* src_v,
338 | int src_stride_v,
339 | uint8_t* dst_argb4444,
340 | int dst_stride_argb4444,
341 | int width,
342 | int height);
343 |
344 | // Convert I420 to AR30.
345 | LIBYUV_API
346 | int I420ToAR30(const uint8_t* src_y,
347 | int src_stride_y,
348 | const uint8_t* src_u,
349 | int src_stride_u,
350 | const uint8_t* src_v,
351 | int src_stride_v,
352 | uint8_t* dst_ar30,
353 | int dst_stride_ar30,
354 | int width,
355 | int height);
356 |
357 | // Convert H420 to AR30.
358 | LIBYUV_API
359 | int H420ToAR30(const uint8_t* src_y,
360 | int src_stride_y,
361 | const uint8_t* src_u,
362 | int src_stride_u,
363 | const uint8_t* src_v,
364 | int src_stride_v,
365 | uint8_t* dst_ar30,
366 | int dst_stride_ar30,
367 | int width,
368 | int height);
369 |
370 | // Convert I420 to specified format.
371 | // "dst_sample_stride" is bytes in a row for the destination. Pass 0 if the
372 | // buffer has contiguous rows. Can be negative. A multiple of 16 is optimal.
373 | LIBYUV_API
374 | int ConvertFromI420(const uint8_t* y,
375 | int y_stride,
376 | const uint8_t* u,
377 | int u_stride,
378 | const uint8_t* v,
379 | int v_stride,
380 | uint8_t* dst_sample,
381 | int dst_sample_stride,
382 | int width,
383 | int height,
384 | uint32_t fourcc);
385 |
386 | #ifdef __cplusplus
387 | } // extern "C"
388 | } // namespace libyuv
389 | #endif
390 |
391 | #endif // INCLUDE_LIBYUV_CONVERT_FROM_H_
392 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/convert_from_argb.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_
12 | #define INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | // Copy ARGB to ARGB.
22 | #define ARGBToARGB ARGBCopy
23 | LIBYUV_API
24 | int ARGBCopy(const uint8_t* src_argb,
25 | int src_stride_argb,
26 | uint8_t* dst_argb,
27 | int dst_stride_argb,
28 | int width,
29 | int height);
30 |
31 | // Convert ARGB To BGRA.
32 | LIBYUV_API
33 | int ARGBToBGRA(const uint8_t* src_argb,
34 | int src_stride_argb,
35 | uint8_t* dst_bgra,
36 | int dst_stride_bgra,
37 | int width,
38 | int height);
39 |
40 | // Convert ARGB To ABGR.
41 | LIBYUV_API
42 | int ARGBToABGR(const uint8_t* src_argb,
43 | int src_stride_argb,
44 | uint8_t* dst_abgr,
45 | int dst_stride_abgr,
46 | int width,
47 | int height);
48 |
49 | // Convert ARGB To RGBA.
50 | LIBYUV_API
51 | int ARGBToRGBA(const uint8_t* src_argb,
52 | int src_stride_argb,
53 | uint8_t* dst_rgba,
54 | int dst_stride_rgba,
55 | int width,
56 | int height);
57 |
58 | // Aliases
59 | #define ARGBToAB30 ABGRToAR30
60 | #define ABGRToAB30 ARGBToAR30
61 |
62 | // Convert ABGR To AR30.
63 | LIBYUV_API
64 | int ABGRToAR30(const uint8_t* src_abgr,
65 | int src_stride_abgr,
66 | uint8_t* dst_ar30,
67 | int dst_stride_ar30,
68 | int width,
69 | int height);
70 |
71 | // Convert ARGB To AR30.
72 | LIBYUV_API
73 | int ARGBToAR30(const uint8_t* src_argb,
74 | int src_stride_argb,
75 | uint8_t* dst_ar30,
76 | int dst_stride_ar30,
77 | int width,
78 | int height);
79 |
80 | // Convert ARGB To RGB24.
81 | LIBYUV_API
82 | int ARGBToRGB24(const uint8_t* src_argb,
83 | int src_stride_argb,
84 | uint8_t* dst_rgb24,
85 | int dst_stride_rgb24,
86 | int width,
87 | int height);
88 |
89 | // Convert ARGB To RAW.
90 | LIBYUV_API
91 | int ARGBToRAW(const uint8_t* src_argb,
92 | int src_stride_argb,
93 | uint8_t* dst_raw,
94 | int dst_stride_raw,
95 | int width,
96 | int height);
97 |
98 | // Convert ARGB To RGB565.
99 | LIBYUV_API
100 | int ARGBToRGB565(const uint8_t* src_argb,
101 | int src_stride_argb,
102 | uint8_t* dst_rgb565,
103 | int dst_stride_rgb565,
104 | int width,
105 | int height);
106 |
107 | // Convert ARGB To RGB565 with 4x4 dither matrix (16 bytes).
108 | // Values in dither matrix from 0 to 7 recommended.
109 | // The order of the dither matrix is first byte is upper left.
110 | // TODO(fbarchard): Consider pointer to 2d array for dither4x4.
111 | // const uint8_t(*dither)[4][4];
112 | LIBYUV_API
113 | int ARGBToRGB565Dither(const uint8_t* src_argb,
114 | int src_stride_argb,
115 | uint8_t* dst_rgb565,
116 | int dst_stride_rgb565,
117 | const uint8_t* dither4x4,
118 | int width,
119 | int height);
120 |
121 | // Convert ARGB To ARGB1555.
122 | LIBYUV_API
123 | int ARGBToARGB1555(const uint8_t* src_argb,
124 | int src_stride_argb,
125 | uint8_t* dst_argb1555,
126 | int dst_stride_argb1555,
127 | int width,
128 | int height);
129 |
130 | // Convert ARGB To ARGB4444.
131 | LIBYUV_API
132 | int ARGBToARGB4444(const uint8_t* src_argb,
133 | int src_stride_argb,
134 | uint8_t* dst_argb4444,
135 | int dst_stride_argb4444,
136 | int width,
137 | int height);
138 |
139 | // Convert ARGB To I444.
140 | LIBYUV_API
141 | int ARGBToI444(const uint8_t* src_argb,
142 | int src_stride_argb,
143 | uint8_t* dst_y,
144 | int dst_stride_y,
145 | uint8_t* dst_u,
146 | int dst_stride_u,
147 | uint8_t* dst_v,
148 | int dst_stride_v,
149 | int width,
150 | int height);
151 |
152 | // Convert ARGB To I422.
153 | LIBYUV_API
154 | int ARGBToI422(const uint8_t* src_argb,
155 | int src_stride_argb,
156 | uint8_t* dst_y,
157 | int dst_stride_y,
158 | uint8_t* dst_u,
159 | int dst_stride_u,
160 | uint8_t* dst_v,
161 | int dst_stride_v,
162 | int width,
163 | int height);
164 |
165 | // Convert ARGB To I420. (also in convert.h)
166 | LIBYUV_API
167 | int ARGBToI420(const uint8_t* src_argb,
168 | int src_stride_argb,
169 | uint8_t* dst_y,
170 | int dst_stride_y,
171 | uint8_t* dst_u,
172 | int dst_stride_u,
173 | uint8_t* dst_v,
174 | int dst_stride_v,
175 | int width,
176 | int height);
177 |
178 | // Convert ARGB to J420. (JPeg full range I420).
179 | LIBYUV_API
180 | int ARGBToJ420(const uint8_t* src_argb,
181 | int src_stride_argb,
182 | uint8_t* dst_yj,
183 | int dst_stride_yj,
184 | uint8_t* dst_u,
185 | int dst_stride_u,
186 | uint8_t* dst_v,
187 | int dst_stride_v,
188 | int width,
189 | int height);
190 |
191 | // Convert ARGB to J422.
192 | LIBYUV_API
193 | int ARGBToJ422(const uint8_t* src_argb,
194 | int src_stride_argb,
195 | uint8_t* dst_yj,
196 | int dst_stride_yj,
197 | uint8_t* dst_u,
198 | int dst_stride_u,
199 | uint8_t* dst_v,
200 | int dst_stride_v,
201 | int width,
202 | int height);
203 |
204 | // Convert ARGB to J400. (JPeg full range).
205 | LIBYUV_API
206 | int ARGBToJ400(const uint8_t* src_argb,
207 | int src_stride_argb,
208 | uint8_t* dst_yj,
209 | int dst_stride_yj,
210 | int width,
211 | int height);
212 |
213 | // Convert RGBA to J400. (JPeg full range).
214 | LIBYUV_API
215 | int RGBAToJ400(const uint8_t* src_rgba,
216 | int src_stride_rgba,
217 | uint8_t* dst_yj,
218 | int dst_stride_yj,
219 | int width,
220 | int height);
221 |
222 | // Convert ARGB to I400.
223 | LIBYUV_API
224 | int ARGBToI400(const uint8_t* src_argb,
225 | int src_stride_argb,
226 | uint8_t* dst_y,
227 | int dst_stride_y,
228 | int width,
229 | int height);
230 |
231 | // Convert ARGB to G. (Reverse of J400toARGB, which replicates G back to ARGB)
232 | LIBYUV_API
233 | int ARGBToG(const uint8_t* src_argb,
234 | int src_stride_argb,
235 | uint8_t* dst_g,
236 | int dst_stride_g,
237 | int width,
238 | int height);
239 |
240 | // Convert ARGB To NV12.
241 | LIBYUV_API
242 | int ARGBToNV12(const uint8_t* src_argb,
243 | int src_stride_argb,
244 | uint8_t* dst_y,
245 | int dst_stride_y,
246 | uint8_t* dst_uv,
247 | int dst_stride_uv,
248 | int width,
249 | int height);
250 |
251 | // Convert ARGB To NV21.
252 | LIBYUV_API
253 | int ARGBToNV21(const uint8_t* src_argb,
254 | int src_stride_argb,
255 | uint8_t* dst_y,
256 | int dst_stride_y,
257 | uint8_t* dst_vu,
258 | int dst_stride_vu,
259 | int width,
260 | int height);
261 |
262 | // Convert ABGR To NV12.
263 | LIBYUV_API
264 | int ABGRToNV12(const uint8_t* src_abgr,
265 | int src_stride_abgr,
266 | uint8_t* dst_y,
267 | int dst_stride_y,
268 | uint8_t* dst_uv,
269 | int dst_stride_uv,
270 | int width,
271 | int height);
272 |
273 | // Convert ABGR To NV21.
274 | LIBYUV_API
275 | int ABGRToNV21(const uint8_t* src_abgr,
276 | int src_stride_abgr,
277 | uint8_t* dst_y,
278 | int dst_stride_y,
279 | uint8_t* dst_vu,
280 | int dst_stride_vu,
281 | int width,
282 | int height);
283 |
284 | // Convert ARGB To YUY2.
285 | LIBYUV_API
286 | int ARGBToYUY2(const uint8_t* src_argb,
287 | int src_stride_argb,
288 | uint8_t* dst_yuy2,
289 | int dst_stride_yuy2,
290 | int width,
291 | int height);
292 |
293 | // Convert ARGB To UYVY.
294 | LIBYUV_API
295 | int ARGBToUYVY(const uint8_t* src_argb,
296 | int src_stride_argb,
297 | uint8_t* dst_uyvy,
298 | int dst_stride_uyvy,
299 | int width,
300 | int height);
301 |
302 | #ifdef __cplusplus
303 | } // extern "C"
304 | } // namespace libyuv
305 | #endif
306 |
307 | #endif // INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_
308 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/cpu_id.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_CPU_ID_H_
12 | #define INCLUDE_LIBYUV_CPU_ID_H_
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | // Internal flag to indicate cpuid requires initialization.
22 | static const int kCpuInitialized = 0x1;
23 |
24 | // These flags are only valid on ARM processors.
25 | static const int kCpuHasARM = 0x2;
26 | static const int kCpuHasNEON = 0x4;
27 | // 0x8 reserved for future ARM flag.
28 |
29 | // These flags are only valid on x86 processors.
30 | static const int kCpuHasX86 = 0x10;
31 | static const int kCpuHasSSE2 = 0x20;
32 | static const int kCpuHasSSSE3 = 0x40;
33 | static const int kCpuHasSSE41 = 0x80;
34 | static const int kCpuHasSSE42 = 0x100; // unused at this time.
35 | static const int kCpuHasAVX = 0x200;
36 | static const int kCpuHasAVX2 = 0x400;
37 | static const int kCpuHasERMS = 0x800;
38 | static const int kCpuHasFMA3 = 0x1000;
39 | static const int kCpuHasF16C = 0x2000;
40 | static const int kCpuHasGFNI = 0x4000;
41 | static const int kCpuHasAVX512BW = 0x8000;
42 | static const int kCpuHasAVX512VL = 0x10000;
43 | static const int kCpuHasAVX512VBMI = 0x20000;
44 | static const int kCpuHasAVX512VBMI2 = 0x40000;
45 | static const int kCpuHasAVX512VBITALG = 0x80000;
46 | static const int kCpuHasAVX512VPOPCNTDQ = 0x100000;
47 |
48 | // These flags are only valid on MIPS processors.
49 | static const int kCpuHasMIPS = 0x200000;
50 | static const int kCpuHasMSA = 0x400000;
51 | static const int kCpuHasMMI = 0x800000;
52 |
53 | // Optional init function. TestCpuFlag does an auto-init.
54 | // Returns cpu_info flags.
55 | LIBYUV_API
56 | int InitCpuFlags(void);
57 |
58 | // Detect CPU has SSE2 etc.
59 | // Test_flag parameter should be one of kCpuHas constants above.
60 | // Returns non-zero if instruction set is detected
61 | static __inline int TestCpuFlag(int test_flag) {
62 | LIBYUV_API extern int cpu_info_;
63 | #ifdef __ATOMIC_RELAXED
64 | int cpu_info = __atomic_load_n(&cpu_info_, __ATOMIC_RELAXED);
65 | #else
66 | int cpu_info = cpu_info_;
67 | #endif
68 | return (!cpu_info ? InitCpuFlags() : cpu_info) & test_flag;
69 | }
70 |
71 | // Internal function for parsing /proc/cpuinfo.
72 | LIBYUV_API
73 | int ArmCpuCaps(const char* cpuinfo_name);
74 | LIBYUV_API
75 | int MipsCpuCaps(const char* cpuinfo_name);
76 |
77 | // For testing, allow CPU flags to be disabled.
78 | // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3.
79 | // MaskCpuFlags(-1) to enable all cpu specific optimizations.
80 | // MaskCpuFlags(1) to disable all cpu specific optimizations.
81 | // MaskCpuFlags(0) to reset state so next call will auto init.
82 | // Returns cpu_info flags.
83 | LIBYUV_API
84 | int MaskCpuFlags(int enable_flags);
85 |
86 | // Sets the CPU flags to |cpu_flags|, bypassing the detection code. |cpu_flags|
87 | // should be a valid combination of the kCpuHas constants above and include
88 | // kCpuInitialized. Use this method when running in a sandboxed process where
89 | // the detection code might fail (as it might access /proc/cpuinfo). In such
90 | // cases the cpu_info can be obtained from a non sandboxed process by calling
91 | // InitCpuFlags() and passed to the sandboxed process (via command line
92 | // parameters, IPC...) which can then call this method to initialize the CPU
93 | // flags.
94 | // Notes:
95 | // - when specifying 0 for |cpu_flags|, the auto initialization is enabled
96 | // again.
97 | // - enabling CPU features that are not supported by the CPU will result in
98 | // undefined behavior.
99 | // TODO(fbarchard): consider writing a helper function that translates from
100 | // other library CPU info to libyuv CPU info and add a .md doc that explains
101 | // CPU detection.
102 | static __inline void SetCpuFlags(int cpu_flags) {
103 | LIBYUV_API extern int cpu_info_;
104 | #ifdef __ATOMIC_RELAXED
105 | __atomic_store_n(&cpu_info_, cpu_flags, __ATOMIC_RELAXED);
106 | #else
107 | cpu_info_ = cpu_flags;
108 | #endif
109 | }
110 |
111 | // Low level cpuid for X86. Returns zeros on other CPUs.
112 | // eax is the info type that you want.
113 | // ecx is typically the cpu number, and should normally be zero.
114 | LIBYUV_API
115 | void CpuId(int info_eax, int info_ecx, int* cpu_info);
116 |
117 | #ifdef __cplusplus
118 | } // extern "C"
119 | } // namespace libyuv
120 | #endif
121 |
122 | #endif // INCLUDE_LIBYUV_CPU_ID_H_
123 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/macros_msa.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_MACROS_MSA_H_
12 | #define INCLUDE_LIBYUV_MACROS_MSA_H_
13 |
14 | #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
15 | #include
16 | #include
17 |
18 | #if (__mips_isa_rev >= 6)
19 | #define LW(psrc) \
20 | ({ \
21 | const uint8_t* psrc_lw_m = (const uint8_t*)(psrc); \
22 | uint32_t val_m; \
23 | asm volatile("lw %[val_m], %[psrc_lw_m] \n" \
24 | : [val_m] "=r"(val_m) \
25 | : [psrc_lw_m] "m"(*psrc_lw_m)); \
26 | val_m; \
27 | })
28 |
29 | #if (__mips == 64)
30 | #define LD(psrc) \
31 | ({ \
32 | const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \
33 | uint64_t val_m = 0; \
34 | asm volatile("ld %[val_m], %[psrc_ld_m] \n" \
35 | : [val_m] "=r"(val_m) \
36 | : [psrc_ld_m] "m"(*psrc_ld_m)); \
37 | val_m; \
38 | })
39 | #else // !(__mips == 64)
40 | #define LD(psrc) \
41 | ({ \
42 | const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \
43 | uint32_t val0_m, val1_m; \
44 | uint64_t val_m = 0; \
45 | val0_m = LW(psrc_ld_m); \
46 | val1_m = LW(psrc_ld_m + 4); \
47 | val_m = (uint64_t)(val1_m); /* NOLINT */ \
48 | val_m = (uint64_t)((val_m << 32) & 0xFFFFFFFF00000000); /* NOLINT */ \
49 | val_m = (uint64_t)(val_m | (uint64_t)val0_m); /* NOLINT */ \
50 | val_m; \
51 | })
52 | #endif // (__mips == 64)
53 |
54 | #define SW(val, pdst) \
55 | ({ \
56 | uint8_t* pdst_sw_m = (uint8_t*)(pdst); /* NOLINT */ \
57 | uint32_t val_m = (val); \
58 | asm volatile("sw %[val_m], %[pdst_sw_m] \n" \
59 | : [pdst_sw_m] "=m"(*pdst_sw_m) \
60 | : [val_m] "r"(val_m)); \
61 | })
62 |
63 | #if (__mips == 64)
64 | #define SD(val, pdst) \
65 | ({ \
66 | uint8_t* pdst_sd_m = (uint8_t*)(pdst); /* NOLINT */ \
67 | uint64_t val_m = (val); \
68 | asm volatile("sd %[val_m], %[pdst_sd_m] \n" \
69 | : [pdst_sd_m] "=m"(*pdst_sd_m) \
70 | : [val_m] "r"(val_m)); \
71 | })
72 | #else // !(__mips == 64)
73 | #define SD(val, pdst) \
74 | ({ \
75 | uint8_t* pdst_sd_m = (uint8_t*)(pdst); /* NOLINT */ \
76 | uint32_t val0_m, val1_m; \
77 | val0_m = (uint32_t)((val)&0x00000000FFFFFFFF); \
78 | val1_m = (uint32_t)(((val) >> 32) & 0x00000000FFFFFFFF); \
79 | SW(val0_m, pdst_sd_m); \
80 | SW(val1_m, pdst_sd_m + 4); \
81 | })
82 | #endif // !(__mips == 64)
83 | #else // !(__mips_isa_rev >= 6)
84 | #define LW(psrc) \
85 | ({ \
86 | const uint8_t* psrc_lw_m = (const uint8_t*)(psrc); \
87 | uint32_t val_m; \
88 | asm volatile("ulw %[val_m], %[psrc_lw_m] \n" \
89 | : [val_m] "=r"(val_m) \
90 | : [psrc_lw_m] "m"(*psrc_lw_m)); \
91 | val_m; \
92 | })
93 |
94 | #if (__mips == 64)
95 | #define LD(psrc) \
96 | ({ \
97 | const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \
98 | uint64_t val_m = 0; \
99 | asm volatile("uld %[val_m], %[psrc_ld_m] \n" \
100 | : [val_m] "=r"(val_m) \
101 | : [psrc_ld_m] "m"(*psrc_ld_m)); \
102 | val_m; \
103 | })
104 | #else // !(__mips == 64)
105 | #define LD(psrc) \
106 | ({ \
107 | const uint8_t* psrc_ld_m = (const uint8_t*)(psrc); \
108 | uint32_t val0_m, val1_m; \
109 | uint64_t val_m = 0; \
110 | val0_m = LW(psrc_ld_m); \
111 | val1_m = LW(psrc_ld_m + 4); \
112 | val_m = (uint64_t)(val1_m); /* NOLINT */ \
113 | val_m = (uint64_t)((val_m << 32) & 0xFFFFFFFF00000000); /* NOLINT */ \
114 | val_m = (uint64_t)(val_m | (uint64_t)val0_m); /* NOLINT */ \
115 | val_m; \
116 | })
117 | #endif // (__mips == 64)
118 |
119 | #define SW(val, pdst) \
120 | ({ \
121 | uint8_t* pdst_sw_m = (uint8_t*)(pdst); /* NOLINT */ \
122 | uint32_t val_m = (val); \
123 | asm volatile("usw %[val_m], %[pdst_sw_m] \n" \
124 | : [pdst_sw_m] "=m"(*pdst_sw_m) \
125 | : [val_m] "r"(val_m)); \
126 | })
127 |
128 | #define SD(val, pdst) \
129 | ({ \
130 | uint8_t* pdst_sd_m = (uint8_t*)(pdst); /* NOLINT */ \
131 | uint32_t val0_m, val1_m; \
132 | val0_m = (uint32_t)((val)&0x00000000FFFFFFFF); \
133 | val1_m = (uint32_t)(((val) >> 32) & 0x00000000FFFFFFFF); \
134 | SW(val0_m, pdst_sd_m); \
135 | SW(val1_m, pdst_sd_m + 4); \
136 | })
137 | #endif // (__mips_isa_rev >= 6)
138 |
139 | // TODO(fbarchard): Consider removing __VAR_ARGS versions.
140 | #define LD_B(RTYPE, psrc) *((RTYPE*)(psrc)) /* NOLINT */
141 | #define LD_UB(...) LD_B(const v16u8, __VA_ARGS__)
142 |
143 | #define ST_B(RTYPE, in, pdst) *((RTYPE*)(pdst)) = (in) /* NOLINT */
144 | #define ST_UB(...) ST_B(v16u8, __VA_ARGS__)
145 |
146 | #define ST_H(RTYPE, in, pdst) *((RTYPE*)(pdst)) = (in) /* NOLINT */
147 | #define ST_UH(...) ST_H(v8u16, __VA_ARGS__)
148 |
149 | /* Description : Load two vectors with 16 'byte' sized elements
150 | Arguments : Inputs - psrc, stride
151 | Outputs - out0, out1
152 | Return Type - as per RTYPE
153 | Details : Load 16 byte elements in 'out0' from (psrc)
154 | Load 16 byte elements in 'out1' from (psrc + stride)
155 | */
156 | #define LD_B2(RTYPE, psrc, stride, out0, out1) \
157 | { \
158 | out0 = LD_B(RTYPE, (psrc)); \
159 | out1 = LD_B(RTYPE, (psrc) + stride); \
160 | }
161 | #define LD_UB2(...) LD_B2(const v16u8, __VA_ARGS__)
162 |
163 | #define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) \
164 | { \
165 | LD_B2(RTYPE, (psrc), stride, out0, out1); \
166 | LD_B2(RTYPE, (psrc) + 2 * stride, stride, out2, out3); \
167 | }
168 | #define LD_UB4(...) LD_B4(const v16u8, __VA_ARGS__)
169 |
170 | /* Description : Store two vectors with stride each having 16 'byte' sized
171 | elements
172 | Arguments : Inputs - in0, in1, pdst, stride
173 | Details : Store 16 byte elements from 'in0' to (pdst)
174 | Store 16 byte elements from 'in1' to (pdst + stride)
175 | */
176 | #define ST_B2(RTYPE, in0, in1, pdst, stride) \
177 | { \
178 | ST_B(RTYPE, in0, (pdst)); \
179 | ST_B(RTYPE, in1, (pdst) + stride); \
180 | }
181 | #define ST_UB2(...) ST_B2(v16u8, __VA_ARGS__)
182 |
183 | #define ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride) \
184 | { \
185 | ST_B2(RTYPE, in0, in1, (pdst), stride); \
186 | ST_B2(RTYPE, in2, in3, (pdst) + 2 * stride, stride); \
187 | }
188 | #define ST_UB4(...) ST_B4(v16u8, __VA_ARGS__)
189 |
190 | /* Description : Store vectors of 8 halfword elements with stride
191 | Arguments : Inputs - in0, in1, pdst, stride
192 | Details : Store 8 halfword elements from 'in0' to (pdst)
193 | Store 8 halfword elements from 'in1' to (pdst + stride)
194 | */
195 | #define ST_H2(RTYPE, in0, in1, pdst, stride) \
196 | { \
197 | ST_H(RTYPE, in0, (pdst)); \
198 | ST_H(RTYPE, in1, (pdst) + stride); \
199 | }
200 | #define ST_UH2(...) ST_H2(v8u16, __VA_ARGS__)
201 |
202 | // TODO(fbarchard): Consider using __msa_vshf_b and __msa_ilvr_b directly.
203 | /* Description : Shuffle byte vector elements as per mask vector
204 | Arguments : Inputs - in0, in1, in2, in3, mask0, mask1
205 | Outputs - out0, out1
206 | Return Type - as per RTYPE
207 | Details : Byte elements from 'in0' & 'in1' are copied selectively to
208 | 'out0' as per control vector 'mask0'
209 | */
210 | #define VSHF_B2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) \
211 | { \
212 | out0 = (RTYPE)__msa_vshf_b((v16i8)mask0, (v16i8)in1, (v16i8)in0); \
213 | out1 = (RTYPE)__msa_vshf_b((v16i8)mask1, (v16i8)in3, (v16i8)in2); \
214 | }
215 | #define VSHF_B2_UB(...) VSHF_B2(v16u8, __VA_ARGS__)
216 |
217 | /* Description : Interleave both left and right half of input vectors
218 | Arguments : Inputs - in0, in1
219 | Outputs - out0, out1
220 | Return Type - as per RTYPE
221 | Details : Right half of byte elements from 'in0' and 'in1' are
222 | interleaved and written to 'out0'
223 | */
224 | #define ILVRL_B2(RTYPE, in0, in1, out0, out1) \
225 | { \
226 | out0 = (RTYPE)__msa_ilvr_b((v16i8)in0, (v16i8)in1); \
227 | out1 = (RTYPE)__msa_ilvl_b((v16i8)in0, (v16i8)in1); \
228 | }
229 | #define ILVRL_B2_UB(...) ILVRL_B2(v16u8, __VA_ARGS__)
230 |
231 | #endif /* !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) */
232 |
233 | #endif // INCLUDE_LIBYUV_MACROS_MSA_H_
234 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/mjpeg_decoder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_MJPEG_DECODER_H_
12 | #define INCLUDE_LIBYUV_MJPEG_DECODER_H_
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #ifdef __cplusplus
17 | // NOTE: For a simplified public API use convert.h MJPGToI420().
18 |
19 | struct jpeg_common_struct;
20 | struct jpeg_decompress_struct;
21 | struct jpeg_source_mgr;
22 |
23 | namespace libyuv {
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | LIBYUV_BOOL ValidateJpeg(const uint8_t* sample, size_t sample_size);
30 |
31 | #ifdef __cplusplus
32 | } // extern "C"
33 | #endif
34 |
35 | static const uint32_t kUnknownDataSize = 0xFFFFFFFF;
36 |
37 | enum JpegSubsamplingType {
38 | kJpegYuv420,
39 | kJpegYuv422,
40 | kJpegYuv444,
41 | kJpegYuv400,
42 | kJpegUnknown
43 | };
44 |
45 | struct Buffer {
46 | const uint8_t* data;
47 | int len;
48 | };
49 |
50 | struct BufferVector {
51 | Buffer* buffers;
52 | int len;
53 | int pos;
54 | };
55 |
56 | struct SetJmpErrorMgr;
57 |
58 | // MJPEG ("Motion JPEG") is a pseudo-standard video codec where the frames are
59 | // simply independent JPEG images with a fixed huffman table (which is omitted).
60 | // It is rarely used in video transmission, but is common as a camera capture
61 | // format, especially in Logitech devices. This class implements a decoder for
62 | // MJPEG frames.
63 | //
64 | // See http://tools.ietf.org/html/rfc2435
65 | class LIBYUV_API MJpegDecoder {
66 | public:
67 | typedef void (*CallbackFunction)(void* opaque,
68 | const uint8_t* const* data,
69 | const int* strides,
70 | int rows);
71 |
72 | static const int kColorSpaceUnknown;
73 | static const int kColorSpaceGrayscale;
74 | static const int kColorSpaceRgb;
75 | static const int kColorSpaceYCbCr;
76 | static const int kColorSpaceCMYK;
77 | static const int kColorSpaceYCCK;
78 |
79 | MJpegDecoder();
80 | ~MJpegDecoder();
81 |
82 | // Loads a new frame, reads its headers, and determines the uncompressed
83 | // image format.
84 | // Returns LIBYUV_TRUE if image looks valid and format is supported.
85 | // If return value is LIBYUV_TRUE, then the values for all the following
86 | // getters are populated.
87 | // src_len is the size of the compressed mjpeg frame in bytes.
88 | LIBYUV_BOOL LoadFrame(const uint8_t* src, size_t src_len);
89 |
90 | // Returns width of the last loaded frame in pixels.
91 | int GetWidth();
92 |
93 | // Returns height of the last loaded frame in pixels.
94 | int GetHeight();
95 |
96 | // Returns format of the last loaded frame. The return value is one of the
97 | // kColorSpace* constants.
98 | int GetColorSpace();
99 |
100 | // Number of color components in the color space.
101 | int GetNumComponents();
102 |
103 | // Sample factors of the n-th component.
104 | int GetHorizSampFactor(int component);
105 |
106 | int GetVertSampFactor(int component);
107 |
108 | int GetHorizSubSampFactor(int component);
109 |
110 | int GetVertSubSampFactor(int component);
111 |
112 | // Public for testability.
113 | int GetImageScanlinesPerImcuRow();
114 |
115 | // Public for testability.
116 | int GetComponentScanlinesPerImcuRow(int component);
117 |
118 | // Width of a component in bytes.
119 | int GetComponentWidth(int component);
120 |
121 | // Height of a component.
122 | int GetComponentHeight(int component);
123 |
124 | // Width of a component in bytes with padding for DCTSIZE. Public for testing.
125 | int GetComponentStride(int component);
126 |
127 | // Size of a component in bytes.
128 | int GetComponentSize(int component);
129 |
130 | // Call this after LoadFrame() if you decide you don't want to decode it
131 | // after all.
132 | LIBYUV_BOOL UnloadFrame();
133 |
134 | // Decodes the entire image into a one-buffer-per-color-component format.
135 | // dst_width must match exactly. dst_height must be <= to image height; if
136 | // less, the image is cropped. "planes" must have size equal to at least
137 | // GetNumComponents() and they must point to non-overlapping buffers of size
138 | // at least GetComponentSize(i). The pointers in planes are incremented
139 | // to point to after the end of the written data.
140 | // TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded.
141 | LIBYUV_BOOL DecodeToBuffers(uint8_t** planes, int dst_width, int dst_height);
142 |
143 | // Decodes the entire image and passes the data via repeated calls to a
144 | // callback function. Each call will get the data for a whole number of
145 | // image scanlines.
146 | // TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded.
147 | LIBYUV_BOOL DecodeToCallback(CallbackFunction fn,
148 | void* opaque,
149 | int dst_width,
150 | int dst_height);
151 |
152 | // The helper function which recognizes the jpeg sub-sampling type.
153 | static JpegSubsamplingType JpegSubsamplingTypeHelper(
154 | int* subsample_x,
155 | int* subsample_y,
156 | int number_of_components);
157 |
158 | private:
159 | void AllocOutputBuffers(int num_outbufs);
160 | void DestroyOutputBuffers();
161 |
162 | LIBYUV_BOOL StartDecode();
163 | LIBYUV_BOOL FinishDecode();
164 |
165 | void SetScanlinePointers(uint8_t** data);
166 | LIBYUV_BOOL DecodeImcuRow();
167 |
168 | int GetComponentScanlinePadding(int component);
169 |
170 | // A buffer holding the input data for a frame.
171 | Buffer buf_;
172 | BufferVector buf_vec_;
173 |
174 | jpeg_decompress_struct* decompress_struct_;
175 | jpeg_source_mgr* source_mgr_;
176 | SetJmpErrorMgr* error_mgr_;
177 |
178 | // LIBYUV_TRUE iff at least one component has scanline padding. (i.e.,
179 | // GetComponentScanlinePadding() != 0.)
180 | LIBYUV_BOOL has_scanline_padding_;
181 |
182 | // Temporaries used to point to scanline outputs.
183 | int num_outbufs_; // Outermost size of all arrays below.
184 | uint8_t*** scanlines_;
185 | int* scanlines_sizes_;
186 | // Temporary buffer used for decoding when we can't decode directly to the
187 | // output buffers. Large enough for just one iMCU row.
188 | uint8_t** databuf_;
189 | int* databuf_strides_;
190 | };
191 |
192 | } // namespace libyuv
193 |
194 | #endif // __cplusplus
195 | #endif // INCLUDE_LIBYUV_MJPEG_DECODER_H_
196 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/rotate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_ROTATE_H_
12 | #define INCLUDE_LIBYUV_ROTATE_H_
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | // Supported rotation.
22 | typedef enum RotationMode {
23 | kRotate0 = 0, // No rotation.
24 | kRotate90 = 90, // Rotate 90 degrees clockwise.
25 | kRotate180 = 180, // Rotate 180 degrees.
26 | kRotate270 = 270, // Rotate 270 degrees clockwise.
27 |
28 | // Deprecated.
29 | kRotateNone = 0,
30 | kRotateClockwise = 90,
31 | kRotateCounterClockwise = 270,
32 | } RotationModeEnum;
33 |
34 | // Rotate I420 frame.
35 | LIBYUV_API
36 | int I420Rotate(const uint8_t* src_y,
37 | int src_stride_y,
38 | const uint8_t* src_u,
39 | int src_stride_u,
40 | const uint8_t* src_v,
41 | int src_stride_v,
42 | uint8_t* dst_y,
43 | int dst_stride_y,
44 | uint8_t* dst_u,
45 | int dst_stride_u,
46 | uint8_t* dst_v,
47 | int dst_stride_v,
48 | int width,
49 | int height,
50 | enum RotationMode mode);
51 |
52 | // Rotate I444 frame.
53 | LIBYUV_API
54 | int I444Rotate(const uint8_t* src_y,
55 | int src_stride_y,
56 | const uint8_t* src_u,
57 | int src_stride_u,
58 | const uint8_t* src_v,
59 | int src_stride_v,
60 | uint8_t* dst_y,
61 | int dst_stride_y,
62 | uint8_t* dst_u,
63 | int dst_stride_u,
64 | uint8_t* dst_v,
65 | int dst_stride_v,
66 | int width,
67 | int height,
68 | enum RotationMode mode);
69 |
70 | // Rotate NV12 input and store in I420.
71 | LIBYUV_API
72 | int NV12ToI420Rotate(const uint8_t* src_y,
73 | int src_stride_y,
74 | const uint8_t* src_uv,
75 | int src_stride_uv,
76 | uint8_t* dst_y,
77 | int dst_stride_y,
78 | uint8_t* dst_u,
79 | int dst_stride_u,
80 | uint8_t* dst_v,
81 | int dst_stride_v,
82 | int width,
83 | int height,
84 | enum RotationMode mode);
85 |
86 | // Rotate a plane by 0, 90, 180, or 270.
87 | LIBYUV_API
88 | int RotatePlane(const uint8_t* src,
89 | int src_stride,
90 | uint8_t* dst,
91 | int dst_stride,
92 | int width,
93 | int height,
94 | enum RotationMode mode);
95 |
96 | // Rotate planes by 90, 180, 270. Deprecated.
97 | LIBYUV_API
98 | void RotatePlane90(const uint8_t* src,
99 | int src_stride,
100 | uint8_t* dst,
101 | int dst_stride,
102 | int width,
103 | int height);
104 |
105 | LIBYUV_API
106 | void RotatePlane180(const uint8_t* src,
107 | int src_stride,
108 | uint8_t* dst,
109 | int dst_stride,
110 | int width,
111 | int height);
112 |
113 | LIBYUV_API
114 | void RotatePlane270(const uint8_t* src,
115 | int src_stride,
116 | uint8_t* dst,
117 | int dst_stride,
118 | int width,
119 | int height);
120 |
121 | // Rotations for when U and V are interleaved.
122 | // These functions take one input pointer and
123 | // split the data into two buffers while
124 | // rotating them. Deprecated.
125 | LIBYUV_API
126 | void RotateUV90(const uint8_t* src,
127 | int src_stride,
128 | uint8_t* dst_a,
129 | int dst_stride_a,
130 | uint8_t* dst_b,
131 | int dst_stride_b,
132 | int width,
133 | int height);
134 |
135 | LIBYUV_API
136 | void RotateUV180(const uint8_t* src,
137 | int src_stride,
138 | uint8_t* dst_a,
139 | int dst_stride_a,
140 | uint8_t* dst_b,
141 | int dst_stride_b,
142 | int width,
143 | int height);
144 |
145 | LIBYUV_API
146 | void RotateUV270(const uint8_t* src,
147 | int src_stride,
148 | uint8_t* dst_a,
149 | int dst_stride_a,
150 | uint8_t* dst_b,
151 | int dst_stride_b,
152 | int width,
153 | int height);
154 |
155 | // The 90 and 270 functions are based on transposes.
156 | // Doing a transpose with reversing the read/write
157 | // order will result in a rotation by +- 90 degrees.
158 | // Deprecated.
159 | LIBYUV_API
160 | void TransposePlane(const uint8_t* src,
161 | int src_stride,
162 | uint8_t* dst,
163 | int dst_stride,
164 | int width,
165 | int height);
166 |
167 | LIBYUV_API
168 | void TransposeUV(const uint8_t* src,
169 | int src_stride,
170 | uint8_t* dst_a,
171 | int dst_stride_a,
172 | uint8_t* dst_b,
173 | int dst_stride_b,
174 | int width,
175 | int height);
176 |
177 | #ifdef __cplusplus
178 | } // extern "C"
179 | } // namespace libyuv
180 | #endif
181 |
182 | #endif // INCLUDE_LIBYUV_ROTATE_H_
183 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/rotate_argb.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_ROTATE_ARGB_H_
12 | #define INCLUDE_LIBYUV_ROTATE_ARGB_H_
13 |
14 | #include "libyuv/basic_types.h"
15 | #include "libyuv/rotate.h" // For RotationMode.
16 |
17 | #ifdef __cplusplus
18 | namespace libyuv {
19 | extern "C" {
20 | #endif
21 |
22 | // Rotate ARGB frame
23 | LIBYUV_API
24 | int ARGBRotate(const uint8_t* src_argb,
25 | int src_stride_argb,
26 | uint8_t* dst_argb,
27 | int dst_stride_argb,
28 | int src_width,
29 | int src_height,
30 | enum RotationMode mode);
31 |
32 | #ifdef __cplusplus
33 | } // extern "C"
34 | } // namespace libyuv
35 | #endif
36 |
37 | #endif // INCLUDE_LIBYUV_ROTATE_ARGB_H_
38 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/rotate_row.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_ROTATE_ROW_H_
12 | #define INCLUDE_LIBYUV_ROTATE_ROW_H_
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | #if defined(__pnacl__) || defined(__CLR_VER) || \
22 | (defined(__native_client__) && defined(__x86_64__)) || \
23 | (defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
24 | #define LIBYUV_DISABLE_X86
25 | #endif
26 | #if defined(__native_client__)
27 | #define LIBYUV_DISABLE_NEON
28 | #endif
29 | // MemorySanitizer does not support assembly code yet. http://crbug.com/344505
30 | #if defined(__has_feature)
31 | #if __has_feature(memory_sanitizer)
32 | #define LIBYUV_DISABLE_X86
33 | #endif
34 | #endif
35 | // The following are available for Visual C and clangcl 32 bit:
36 | #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER)
37 | #define HAS_TRANSPOSEWX8_SSSE3
38 | #define HAS_TRANSPOSEUVWX8_SSE2
39 | #endif
40 |
41 | // The following are available for GCC 32 or 64 bit:
42 | #if !defined(LIBYUV_DISABLE_X86) && (defined(__i386__) || defined(__x86_64__))
43 | #define HAS_TRANSPOSEWX8_SSSE3
44 | #endif
45 |
46 | // The following are available for 64 bit GCC:
47 | #if !defined(LIBYUV_DISABLE_X86) && defined(__x86_64__)
48 | #define HAS_TRANSPOSEWX8_FAST_SSSE3
49 | #define HAS_TRANSPOSEUVWX8_SSE2
50 | #endif
51 |
52 | #if !defined(LIBYUV_DISABLE_NEON) && \
53 | (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__))
54 | #define HAS_TRANSPOSEWX8_NEON
55 | #define HAS_TRANSPOSEUVWX8_NEON
56 | #endif
57 |
58 | #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
59 | #define HAS_TRANSPOSEWX16_MSA
60 | #define HAS_TRANSPOSEUVWX16_MSA
61 | #endif
62 |
63 | #if !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A)
64 | #define HAS_TRANSPOSEWX8_MMI
65 | #define HAS_TRANSPOSEUVWX8_MMI
66 | #endif
67 |
68 | void TransposeWxH_C(const uint8_t* src,
69 | int src_stride,
70 | uint8_t* dst,
71 | int dst_stride,
72 | int width,
73 | int height);
74 |
75 | void TransposeWx8_C(const uint8_t* src,
76 | int src_stride,
77 | uint8_t* dst,
78 | int dst_stride,
79 | int width);
80 | void TransposeWx16_C(const uint8_t* src,
81 | int src_stride,
82 | uint8_t* dst,
83 | int dst_stride,
84 | int width);
85 | void TransposeWx8_NEON(const uint8_t* src,
86 | int src_stride,
87 | uint8_t* dst,
88 | int dst_stride,
89 | int width);
90 | void TransposeWx8_SSSE3(const uint8_t* src,
91 | int src_stride,
92 | uint8_t* dst,
93 | int dst_stride,
94 | int width);
95 | void TransposeWx8_MMI(const uint8_t* src,
96 | int src_stride,
97 | uint8_t* dst,
98 | int dst_stride,
99 | int width);
100 | void TransposeWx8_Fast_SSSE3(const uint8_t* src,
101 | int src_stride,
102 | uint8_t* dst,
103 | int dst_stride,
104 | int width);
105 | void TransposeWx16_MSA(const uint8_t* src,
106 | int src_stride,
107 | uint8_t* dst,
108 | int dst_stride,
109 | int width);
110 |
111 | void TransposeWx8_Any_NEON(const uint8_t* src,
112 | int src_stride,
113 | uint8_t* dst,
114 | int dst_stride,
115 | int width);
116 | void TransposeWx8_Any_SSSE3(const uint8_t* src,
117 | int src_stride,
118 | uint8_t* dst,
119 | int dst_stride,
120 | int width);
121 | void TransposeWx8_Any_MMI(const uint8_t* src,
122 | int src_stride,
123 | uint8_t* dst,
124 | int dst_stride,
125 | int width);
126 | void TransposeWx8_Fast_Any_SSSE3(const uint8_t* src,
127 | int src_stride,
128 | uint8_t* dst,
129 | int dst_stride,
130 | int width);
131 | void TransposeWx16_Any_MSA(const uint8_t* src,
132 | int src_stride,
133 | uint8_t* dst,
134 | int dst_stride,
135 | int width);
136 |
137 | void TransposeUVWxH_C(const uint8_t* src,
138 | int src_stride,
139 | uint8_t* dst_a,
140 | int dst_stride_a,
141 | uint8_t* dst_b,
142 | int dst_stride_b,
143 | int width,
144 | int height);
145 |
146 | void TransposeUVWx8_C(const uint8_t* src,
147 | int src_stride,
148 | uint8_t* dst_a,
149 | int dst_stride_a,
150 | uint8_t* dst_b,
151 | int dst_stride_b,
152 | int width);
153 | void TransposeUVWx16_C(const uint8_t* src,
154 | int src_stride,
155 | uint8_t* dst_a,
156 | int dst_stride_a,
157 | uint8_t* dst_b,
158 | int dst_stride_b,
159 | int width);
160 | void TransposeUVWx8_SSE2(const uint8_t* src,
161 | int src_stride,
162 | uint8_t* dst_a,
163 | int dst_stride_a,
164 | uint8_t* dst_b,
165 | int dst_stride_b,
166 | int width);
167 | void TransposeUVWx8_NEON(const uint8_t* src,
168 | int src_stride,
169 | uint8_t* dst_a,
170 | int dst_stride_a,
171 | uint8_t* dst_b,
172 | int dst_stride_b,
173 | int width);
174 | void TransposeUVWx8_MMI(const uint8_t* src,
175 | int src_stride,
176 | uint8_t* dst_a,
177 | int dst_stride_a,
178 | uint8_t* dst_b,
179 | int dst_stride_b,
180 | int width);
181 | void TransposeUVWx16_MSA(const uint8_t* src,
182 | int src_stride,
183 | uint8_t* dst_a,
184 | int dst_stride_a,
185 | uint8_t* dst_b,
186 | int dst_stride_b,
187 | int width);
188 |
189 | void TransposeUVWx8_Any_SSE2(const uint8_t* src,
190 | int src_stride,
191 | uint8_t* dst_a,
192 | int dst_stride_a,
193 | uint8_t* dst_b,
194 | int dst_stride_b,
195 | int width);
196 | void TransposeUVWx8_Any_NEON(const uint8_t* src,
197 | int src_stride,
198 | uint8_t* dst_a,
199 | int dst_stride_a,
200 | uint8_t* dst_b,
201 | int dst_stride_b,
202 | int width);
203 | void TransposeUVWx8_Any_MMI(const uint8_t* src,
204 | int src_stride,
205 | uint8_t* dst_a,
206 | int dst_stride_a,
207 | uint8_t* dst_b,
208 | int dst_stride_b,
209 | int width);
210 | void TransposeUVWx16_Any_MSA(const uint8_t* src,
211 | int src_stride,
212 | uint8_t* dst_a,
213 | int dst_stride_a,
214 | uint8_t* dst_b,
215 | int dst_stride_b,
216 | int width);
217 |
218 | #ifdef __cplusplus
219 | } // extern "C"
220 | } // namespace libyuv
221 | #endif
222 |
223 | #endif // INCLUDE_LIBYUV_ROTATE_ROW_H_
224 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/scale.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_SCALE_H_
12 | #define INCLUDE_LIBYUV_SCALE_H_
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | // Supported filtering.
22 | typedef enum FilterMode {
23 | kFilterNone = 0, // Point sample; Fastest.
24 | kFilterLinear = 1, // Filter horizontally only.
25 | kFilterBilinear = 2, // Faster than box, but lower quality scaling down.
26 | kFilterBox = 3 // Highest quality.
27 | } FilterModeEnum;
28 |
29 | // Scale a YUV plane.
30 | LIBYUV_API
31 | void ScalePlane(const uint8_t* src,
32 | int src_stride,
33 | int src_width,
34 | int src_height,
35 | uint8_t* dst,
36 | int dst_stride,
37 | int dst_width,
38 | int dst_height,
39 | enum FilterMode filtering);
40 |
41 | LIBYUV_API
42 | void ScalePlane_16(const uint16_t* src,
43 | int src_stride,
44 | int src_width,
45 | int src_height,
46 | uint16_t* dst,
47 | int dst_stride,
48 | int dst_width,
49 | int dst_height,
50 | enum FilterMode filtering);
51 |
52 | // Scales a YUV 4:2:0 image from the src width and height to the
53 | // dst width and height.
54 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
55 | // used. This produces basic (blocky) quality at the fastest speed.
56 | // If filtering is kFilterBilinear, interpolation is used to produce a better
57 | // quality image, at the expense of speed.
58 | // If filtering is kFilterBox, averaging is used to produce ever better
59 | // quality image, at further expense of speed.
60 | // Returns 0 if successful.
61 |
62 | LIBYUV_API
63 | int I420Scale(const uint8_t* src_y,
64 | int src_stride_y,
65 | const uint8_t* src_u,
66 | int src_stride_u,
67 | const uint8_t* src_v,
68 | int src_stride_v,
69 | int src_width,
70 | int src_height,
71 | uint8_t* dst_y,
72 | int dst_stride_y,
73 | uint8_t* dst_u,
74 | int dst_stride_u,
75 | uint8_t* dst_v,
76 | int dst_stride_v,
77 | int dst_width,
78 | int dst_height,
79 | enum FilterMode filtering);
80 |
81 | LIBYUV_API
82 | int I420Scale_16(const uint16_t* src_y,
83 | int src_stride_y,
84 | const uint16_t* src_u,
85 | int src_stride_u,
86 | const uint16_t* src_v,
87 | int src_stride_v,
88 | int src_width,
89 | int src_height,
90 | uint16_t* dst_y,
91 | int dst_stride_y,
92 | uint16_t* dst_u,
93 | int dst_stride_u,
94 | uint16_t* dst_v,
95 | int dst_stride_v,
96 | int dst_width,
97 | int dst_height,
98 | enum FilterMode filtering);
99 |
100 | // Scales a YUV 4:4:4 image from the src width and height to the
101 | // dst width and height.
102 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
103 | // used. This produces basic (blocky) quality at the fastest speed.
104 | // If filtering is kFilterBilinear, interpolation is used to produce a better
105 | // quality image, at the expense of speed.
106 | // If filtering is kFilterBox, averaging is used to produce ever better
107 | // quality image, at further expense of speed.
108 | // Returns 0 if successful.
109 |
110 | LIBYUV_API
111 | int I444Scale(const uint8_t* src_y,
112 | int src_stride_y,
113 | const uint8_t* src_u,
114 | int src_stride_u,
115 | const uint8_t* src_v,
116 | int src_stride_v,
117 | int src_width,
118 | int src_height,
119 | uint8_t* dst_y,
120 | int dst_stride_y,
121 | uint8_t* dst_u,
122 | int dst_stride_u,
123 | uint8_t* dst_v,
124 | int dst_stride_v,
125 | int dst_width,
126 | int dst_height,
127 | enum FilterMode filtering);
128 |
129 | LIBYUV_API
130 | int I444Scale_16(const uint16_t* src_y,
131 | int src_stride_y,
132 | const uint16_t* src_u,
133 | int src_stride_u,
134 | const uint16_t* src_v,
135 | int src_stride_v,
136 | int src_width,
137 | int src_height,
138 | uint16_t* dst_y,
139 | int dst_stride_y,
140 | uint16_t* dst_u,
141 | int dst_stride_u,
142 | uint16_t* dst_v,
143 | int dst_stride_v,
144 | int dst_width,
145 | int dst_height,
146 | enum FilterMode filtering);
147 |
148 | #ifdef __cplusplus
149 | // Legacy API. Deprecated.
150 | LIBYUV_API
151 | int Scale(const uint8_t* src_y,
152 | const uint8_t* src_u,
153 | const uint8_t* src_v,
154 | int src_stride_y,
155 | int src_stride_u,
156 | int src_stride_v,
157 | int src_width,
158 | int src_height,
159 | uint8_t* dst_y,
160 | uint8_t* dst_u,
161 | uint8_t* dst_v,
162 | int dst_stride_y,
163 | int dst_stride_u,
164 | int dst_stride_v,
165 | int dst_width,
166 | int dst_height,
167 | LIBYUV_BOOL interpolate);
168 |
169 | // For testing, allow disabling of specialized scalers.
170 | LIBYUV_API
171 | void SetUseReferenceImpl(LIBYUV_BOOL use);
172 | #endif // __cplusplus
173 |
174 | #ifdef __cplusplus
175 | } // extern "C"
176 | } // namespace libyuv
177 | #endif
178 |
179 | #endif // INCLUDE_LIBYUV_SCALE_H_
180 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/scale_argb.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_SCALE_ARGB_H_
12 | #define INCLUDE_LIBYUV_SCALE_ARGB_H_
13 |
14 | #include "libyuv/basic_types.h"
15 | #include "libyuv/scale.h" // For FilterMode
16 |
17 | #ifdef __cplusplus
18 | namespace libyuv {
19 | extern "C" {
20 | #endif
21 |
22 | LIBYUV_API
23 | int ARGBScale(const uint8_t* src_argb,
24 | int src_stride_argb,
25 | int src_width,
26 | int src_height,
27 | uint8_t* dst_argb,
28 | int dst_stride_argb,
29 | int dst_width,
30 | int dst_height,
31 | enum FilterMode filtering);
32 |
33 | // Clipped scale takes destination rectangle coordinates for clip values.
34 | LIBYUV_API
35 | int ARGBScaleClip(const uint8_t* src_argb,
36 | int src_stride_argb,
37 | int src_width,
38 | int src_height,
39 | uint8_t* dst_argb,
40 | int dst_stride_argb,
41 | int dst_width,
42 | int dst_height,
43 | int clip_x,
44 | int clip_y,
45 | int clip_width,
46 | int clip_height,
47 | enum FilterMode filtering);
48 |
49 | // Scale with YUV conversion to ARGB and clipping.
50 | LIBYUV_API
51 | int YUVToARGBScaleClip(const uint8_t* src_y,
52 | int src_stride_y,
53 | const uint8_t* src_u,
54 | int src_stride_u,
55 | const uint8_t* src_v,
56 | int src_stride_v,
57 | uint32_t src_fourcc,
58 | int src_width,
59 | int src_height,
60 | uint8_t* dst_argb,
61 | int dst_stride_argb,
62 | uint32_t dst_fourcc,
63 | int dst_width,
64 | int dst_height,
65 | int clip_x,
66 | int clip_y,
67 | int clip_width,
68 | int clip_height,
69 | enum FilterMode filtering);
70 |
71 | #ifdef __cplusplus
72 | } // extern "C"
73 | } // namespace libyuv
74 | #endif
75 |
76 | #endif // INCLUDE_LIBYUV_SCALE_ARGB_H_
77 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/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 1749
15 |
16 | #endif // INCLUDE_LIBYUV_VERSION_H_
17 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/include/libyuv/video_common.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | // Common definitions for video, including fourcc and VideoFormat.
12 |
13 | #ifndef INCLUDE_LIBYUV_VIDEO_COMMON_H_
14 | #define INCLUDE_LIBYUV_VIDEO_COMMON_H_
15 |
16 | #include "libyuv/basic_types.h"
17 |
18 | #ifdef __cplusplus
19 | namespace libyuv {
20 | extern "C" {
21 | #endif
22 |
23 | //////////////////////////////////////////////////////////////////////////////
24 | // Definition of FourCC codes
25 | //////////////////////////////////////////////////////////////////////////////
26 |
27 | // Convert four characters to a FourCC code.
28 | // Needs to be a macro otherwise the OS X compiler complains when the kFormat*
29 | // constants are used in a switch.
30 | #ifdef __cplusplus
31 | #define FOURCC(a, b, c, d) \
32 | ((static_cast(a)) | (static_cast(b) << 8) | \
33 | (static_cast(c) << 16) | /* NOLINT */ \
34 | (static_cast(d) << 24)) /* NOLINT */
35 | #else
36 | #define FOURCC(a, b, c, d) \
37 | (((uint32_t)(a)) | ((uint32_t)(b) << 8) | /* NOLINT */ \
38 | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) /* NOLINT */
39 | #endif
40 |
41 | // Some pages discussing FourCC codes:
42 | // http://www.fourcc.org/yuv.php
43 | // http://v4l2spec.bytesex.org/spec/book1.htm
44 | // http://developer.apple.com/quicktime/icefloe/dispatch020.html
45 | // http://msdn.microsoft.com/library/windows/desktop/dd206750.aspx#nv12
46 | // http://people.xiph.org/~xiphmont/containers/nut/nut4cc.txt
47 |
48 | // FourCC codes grouped according to implementation efficiency.
49 | // Primary formats should convert in 1 efficient step.
50 | // Secondary formats are converted in 2 steps.
51 | // Auxilliary formats call primary converters.
52 | enum FourCC {
53 | // 10 Primary YUV formats: 5 planar, 2 biplanar, 2 packed.
54 | FOURCC_I420 = FOURCC('I', '4', '2', '0'),
55 | FOURCC_I422 = FOURCC('I', '4', '2', '2'),
56 | FOURCC_I444 = FOURCC('I', '4', '4', '4'),
57 | FOURCC_I400 = FOURCC('I', '4', '0', '0'),
58 | FOURCC_NV21 = FOURCC('N', 'V', '2', '1'),
59 | FOURCC_NV12 = FOURCC('N', 'V', '1', '2'),
60 | FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'),
61 | FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'),
62 | FOURCC_I010 = FOURCC('I', '0', '1', '0'), // bt.601 10 bit 420
63 | FOURCC_I210 = FOURCC('I', '0', '1', '0'), // bt.601 10 bit 422
64 |
65 | // 1 Secondary YUV format: row biplanar.
66 | FOURCC_M420 = FOURCC('M', '4', '2', '0'),
67 |
68 | // 11 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp, 1 10 bpc
69 | FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'),
70 | FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'),
71 | FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'),
72 | FOURCC_AR30 = FOURCC('A', 'R', '3', '0'), // 10 bit per channel. 2101010.
73 | FOURCC_AB30 = FOURCC('A', 'B', '3', '0'), // ABGR version of 10 bit
74 | FOURCC_24BG = FOURCC('2', '4', 'B', 'G'),
75 | FOURCC_RAW = FOURCC('r', 'a', 'w', ' '),
76 | FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'),
77 | FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE.
78 | FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // argb1555 LE.
79 | FOURCC_R444 = FOURCC('R', '4', '4', '4'), // argb4444 LE.
80 |
81 | // 1 Primary Compressed YUV format.
82 | FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'),
83 |
84 | // 14 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias.
85 | FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'),
86 | FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'),
87 | FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'),
88 | FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'), // Linux version of I420.
89 | FOURCC_J420 =
90 | FOURCC('J', '4', '2', '0'), // jpeg (bt.601 full), unofficial fourcc
91 | FOURCC_J422 =
92 | FOURCC('J', '4', '2', '2'), // jpeg (bt.601 full), unofficial fourcc
93 | FOURCC_J444 =
94 | FOURCC('J', '4', '4', '4'), // jpeg (bt.601 full), unofficial fourcc
95 | FOURCC_J400 =
96 | FOURCC('J', '4', '0', '0'), // jpeg (bt.601 full), unofficial fourcc
97 | FOURCC_H420 = FOURCC('H', '4', '2', '0'), // bt.709, unofficial fourcc
98 | FOURCC_H422 = FOURCC('H', '4', '2', '2'), // bt.709, unofficial fourcc
99 | FOURCC_H444 = FOURCC('H', '4', '4', '4'), // bt.709, unofficial fourcc
100 | FOURCC_U420 = FOURCC('U', '4', '2', '0'), // bt.2020, unofficial fourcc
101 | FOURCC_U422 = FOURCC('U', '4', '2', '2'), // bt.2020, unofficial fourcc
102 | FOURCC_U444 = FOURCC('U', '4', '4', '4'), // bt.2020, unofficial fourcc
103 | FOURCC_H010 = FOURCC('H', '0', '1', '0'), // bt.709 10 bit 420
104 | FOURCC_U010 = FOURCC('U', '0', '1', '0'), // bt.2020 10 bit 420
105 | FOURCC_H210 = FOURCC('H', '0', '1', '0'), // bt.709 10 bit 422
106 | FOURCC_U210 = FOURCC('U', '0', '1', '0'), // bt.2020 10 bit 422
107 |
108 | // 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc.
109 | FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420.
110 | FOURCC_YU16 = FOURCC('Y', 'U', '1', '6'), // Alias for I422.
111 | FOURCC_YU24 = FOURCC('Y', 'U', '2', '4'), // Alias for I444.
112 | FOURCC_YUYV = FOURCC('Y', 'U', 'Y', 'V'), // Alias for YUY2.
113 | FOURCC_YUVS = FOURCC('y', 'u', 'v', 's'), // Alias for YUY2 on Mac.
114 | FOURCC_HDYC = FOURCC('H', 'D', 'Y', 'C'), // Alias for UYVY.
115 | FOURCC_2VUY = FOURCC('2', 'v', 'u', 'y'), // Alias for UYVY on Mac.
116 | FOURCC_JPEG = FOURCC('J', 'P', 'E', 'G'), // Alias for MJPG.
117 | FOURCC_DMB1 = FOURCC('d', 'm', 'b', '1'), // Alias for MJPG on Mac.
118 | FOURCC_BA81 = FOURCC('B', 'A', '8', '1'), // Alias for BGGR.
119 | FOURCC_RGB3 = FOURCC('R', 'G', 'B', '3'), // Alias for RAW.
120 | FOURCC_BGR3 = FOURCC('B', 'G', 'R', '3'), // Alias for 24BG.
121 | FOURCC_CM32 = FOURCC(0, 0, 0, 32), // Alias for BGRA kCMPixelFormat_32ARGB
122 | FOURCC_CM24 = FOURCC(0, 0, 0, 24), // Alias for RAW kCMPixelFormat_24RGB
123 | FOURCC_L555 = FOURCC('L', '5', '5', '5'), // Alias for RGBO.
124 | FOURCC_L565 = FOURCC('L', '5', '6', '5'), // Alias for RGBP.
125 | FOURCC_5551 = FOURCC('5', '5', '5', '1'), // Alias for RGBO.
126 |
127 | // deprecated formats. Not supported, but defined for backward compatibility.
128 | FOURCC_I411 = FOURCC('I', '4', '1', '1'),
129 | FOURCC_Q420 = FOURCC('Q', '4', '2', '0'),
130 | FOURCC_RGGB = FOURCC('R', 'G', 'G', 'B'),
131 | FOURCC_BGGR = FOURCC('B', 'G', 'G', 'R'),
132 | FOURCC_GRBG = FOURCC('G', 'R', 'B', 'G'),
133 | FOURCC_GBRG = FOURCC('G', 'B', 'R', 'G'),
134 | FOURCC_H264 = FOURCC('H', '2', '6', '4'),
135 |
136 | // Match any fourcc.
137 | FOURCC_ANY = -1,
138 | };
139 |
140 | enum FourCCBpp {
141 | // Canonical fourcc codes used in our code.
142 | FOURCC_BPP_I420 = 12,
143 | FOURCC_BPP_I422 = 16,
144 | FOURCC_BPP_I444 = 24,
145 | FOURCC_BPP_I411 = 12,
146 | FOURCC_BPP_I400 = 8,
147 | FOURCC_BPP_NV21 = 12,
148 | FOURCC_BPP_NV12 = 12,
149 | FOURCC_BPP_YUY2 = 16,
150 | FOURCC_BPP_UYVY = 16,
151 | FOURCC_BPP_M420 = 12,
152 | FOURCC_BPP_Q420 = 12,
153 | FOURCC_BPP_ARGB = 32,
154 | FOURCC_BPP_BGRA = 32,
155 | FOURCC_BPP_ABGR = 32,
156 | FOURCC_BPP_RGBA = 32,
157 | FOURCC_BPP_AR30 = 32,
158 | FOURCC_BPP_AB30 = 32,
159 | FOURCC_BPP_24BG = 24,
160 | FOURCC_BPP_RAW = 24,
161 | FOURCC_BPP_RGBP = 16,
162 | FOURCC_BPP_RGBO = 16,
163 | FOURCC_BPP_R444 = 16,
164 | FOURCC_BPP_RGGB = 8,
165 | FOURCC_BPP_BGGR = 8,
166 | FOURCC_BPP_GRBG = 8,
167 | FOURCC_BPP_GBRG = 8,
168 | FOURCC_BPP_YV12 = 12,
169 | FOURCC_BPP_YV16 = 16,
170 | FOURCC_BPP_YV24 = 24,
171 | FOURCC_BPP_YU12 = 12,
172 | FOURCC_BPP_J420 = 12,
173 | FOURCC_BPP_J400 = 8,
174 | FOURCC_BPP_H420 = 12,
175 | FOURCC_BPP_H422 = 16,
176 | FOURCC_BPP_H010 = 24,
177 | FOURCC_BPP_MJPG = 0, // 0 means unknown.
178 | FOURCC_BPP_H264 = 0,
179 | FOURCC_BPP_IYUV = 12,
180 | FOURCC_BPP_YU16 = 16,
181 | FOURCC_BPP_YU24 = 24,
182 | FOURCC_BPP_YUYV = 16,
183 | FOURCC_BPP_YUVS = 16,
184 | FOURCC_BPP_HDYC = 16,
185 | FOURCC_BPP_2VUY = 16,
186 | FOURCC_BPP_JPEG = 1,
187 | FOURCC_BPP_DMB1 = 1,
188 | FOURCC_BPP_BA81 = 8,
189 | FOURCC_BPP_RGB3 = 24,
190 | FOURCC_BPP_BGR3 = 24,
191 | FOURCC_BPP_CM32 = 32,
192 | FOURCC_BPP_CM24 = 24,
193 |
194 | // Match any fourcc.
195 | FOURCC_BPP_ANY = 0, // 0 means unknown.
196 | };
197 |
198 | // Converts fourcc aliases into canonical ones.
199 | LIBYUV_API uint32_t CanonicalFourCC(uint32_t fourcc);
200 |
201 | #ifdef __cplusplus
202 | } // extern "C"
203 | } // namespace libyuv
204 | #endif
205 |
206 | #endif // INCLUDE_LIBYUV_VIDEO_COMMON_H_
207 |
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/lib/arm64-v8a/libyuv_static.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/bzyuv/src/main/cpp/lib/arm64-v8a/libyuv_static.a
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/lib/armeabi-v7a/libyuv_static.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/bzyuv/src/main/cpp/lib/armeabi-v7a/libyuv_static.a
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/lib/x86/libyuv_static.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/bzyuv/src/main/cpp/lib/x86/libyuv_static.a
--------------------------------------------------------------------------------
/bzyuv/src/main/cpp/lib/x86_64/libyuv_static.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/bzyuv/src/main/cpp/lib/x86_64/libyuv_static.a
--------------------------------------------------------------------------------
/bzyuv/src/main/java/com/luoye/bzyuvlib/BZYUVSoLoadingUtil.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Created by bookzhan on 2024−03-11 22:43.
7 | * description:
8 | */
9 | public class BZYUVSoLoadingUtil {
10 | private static SoLoadingListener mSoLoadingListener;
11 |
12 | public static void setSoLoadingListener(SoLoadingListener soLoadingListener) {
13 | mSoLoadingListener = soLoadingListener;
14 | }
15 |
16 | public static void loadLibrary(String soName) {
17 | try {
18 | System.loadLibrary(soName);
19 | } catch (Throwable throwable) {
20 | Log.e(BZYUVSoLoadingUtil.class.getSimpleName(), "loadSo fail soName=" + soName, throwable);
21 | if (null != mSoLoadingListener) {
22 | mSoLoadingListener.onSoLoadingFail(soName);
23 | }
24 | }
25 | }
26 |
27 | public interface SoLoadingListener {
28 | void onSoLoadingFail(String soName);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/bzyuv/src/main/java/com/luoye/bzyuvlib/BZYUVUtil.java:
--------------------------------------------------------------------------------
1 | package com.luoye.bzyuvlib;
2 |
3 | import android.graphics.Bitmap;
4 | import android.media.Image;
5 | import android.os.Build;
6 |
7 |
8 | import java.nio.ByteBuffer;
9 |
10 | /**
11 | * Created by zhandalin on 2019-11-01 17:39.
12 | * description:
13 | */
14 | public class BZYUVUtil {
15 | static {
16 | BZYUVSoLoadingUtil.loadLibrary("bzyuvlib");
17 | }
18 |
19 | private byte[] outDataRGBA = null;
20 | private byte[] outDataBGRA = null;
21 | private byte[] outYUV420 = null;
22 | private byte[] outGrey = null;
23 | private byte[] outPreHandleRGBAData = null;
24 | private int lastWidth = 0;
25 | private int lastHeight = 0;
26 |
27 | public synchronized byte[] yuv420pToRGBA(Image image, boolean flipHorizontal, int rotate) {
28 | if (null == image || Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
29 | return null;
30 | }
31 | if (null == outDataRGBA || image.getWidth() != lastWidth || image.getHeight() != lastHeight) {
32 | outDataRGBA = new byte[image.getWidth() * image.getHeight() * 4];
33 | lastWidth = image.getWidth();
34 | lastHeight = image.getHeight();
35 | }
36 | Image.Plane[] planes = image.getPlanes();
37 | BZYUVUtil.yuv420pToRGBA(planes[0].getBuffer(), planes[0].getRowStride(), planes[1].getBuffer(), planes[1].getPixelStride(), planes[1].getRowStride(), planes[2].getBuffer(), planes[2].getPixelStride(), planes[2].getRowStride(), outDataRGBA, image.getWidth(), image.getHeight(), flipHorizontal, rotate);
38 | return outDataRGBA;
39 | }
40 |
41 | public synchronized byte[] yuv420pToBGRA(Image image, boolean flipHorizontal, int rotate) {
42 | if (null == image || Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
43 | return null;
44 | }
45 | if (null == outDataBGRA || image.getWidth() != lastWidth || image.getHeight() != lastHeight) {
46 | outDataBGRA = new byte[image.getWidth() * image.getHeight() * 4];
47 | lastWidth = image.getWidth();
48 | lastHeight = image.getHeight();
49 | }
50 | Image.Plane[] planes = image.getPlanes();
51 | BZYUVUtil.yuv420pToBGRA(planes[0].getBuffer(), planes[0].getRowStride(), planes[1].getBuffer(), planes[1].getPixelStride(), planes[1].getRowStride(), planes[2].getBuffer(), planes[2].getPixelStride(), planes[2].getRowStride(), outDataBGRA, image.getWidth(), image.getHeight(), flipHorizontal, rotate);
52 | return outDataBGRA;
53 | }
54 |
55 | public synchronized byte[] preHandleYUV420(Image image, boolean flipHorizontal, int rotate) {
56 | if (null == image || Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
57 | return null;
58 | }
59 | if (null == outYUV420 || image.getWidth() != lastWidth || image.getHeight() != lastHeight) {
60 | outYUV420 = new byte[image.getWidth() * image.getHeight() * 3 / 2];
61 | lastWidth = image.getWidth();
62 | lastHeight = image.getHeight();
63 | }
64 | Image.Plane[] planes = image.getPlanes();
65 | BZYUVUtil.preHandleYUV420(planes[0].getBuffer(), planes[0].getRowStride(), planes[1].getBuffer(), planes[1].getPixelStride(), planes[1].getRowStride(), planes[2].getBuffer(), planes[2].getPixelStride(), planes[2].getRowStride(), outYUV420, image.getWidth(), image.getHeight(), flipHorizontal, rotate);
66 | return outYUV420;
67 | }
68 |
69 | public synchronized byte[] yuv420pToGrey(Image image, boolean flipHorizontal, int rotate) {
70 | if (null == image || Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
71 | return null;
72 | }
73 | if (null == outGrey || image.getWidth() != lastWidth || image.getHeight() != lastHeight) {
74 | outGrey = new byte[image.getWidth() * image.getHeight()];
75 | lastWidth = image.getWidth();
76 | lastHeight = image.getHeight();
77 | }
78 | Image.Plane[] planes = image.getPlanes();
79 | BZYUVUtil.yuv420ToGray(planes[0].getBuffer(), planes[0].getRowStride(), planes[1].getBuffer(), planes[1].getPixelStride(), planes[1].getRowStride(), planes[2].getBuffer(), planes[2].getPixelStride(), planes[2].getRowStride(), outGrey, image.getWidth(), image.getHeight(), flipHorizontal, rotate);
80 | return outGrey;
81 | }
82 |
83 | public synchronized byte[] preHandleRGBA(Image image, boolean flipHorizontal, int rotate) {
84 | if (null == image || Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
85 | return null;
86 | }
87 | if (null == outPreHandleRGBAData || image.getWidth() != lastWidth || image.getHeight() != lastHeight) {
88 | outPreHandleRGBAData = new byte[image.getWidth() * image.getHeight() * 4];
89 | lastWidth = image.getWidth();
90 | lastHeight = image.getHeight();
91 | }
92 | Image.Plane[] planes = image.getPlanes();
93 | BZYUVUtil.handleRGBA4ByteBuffer(planes[0].getBuffer(), planes[0].getRowStride(),
94 | outPreHandleRGBAData, image.getWidth(), image.getHeight(), flipHorizontal, rotate);
95 | return outPreHandleRGBAData;
96 | }
97 |
98 | public static native int preHandleYUV420(ByteBuffer byteBufferY, int yRowStride, ByteBuffer byteBufferU, int uPixelStride, int uRowStride, ByteBuffer byteBufferV, int vPixelStride, int vRowStride, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
99 |
100 | public static native int yuv420pToRGBA(ByteBuffer byteBufferY, int yRowStride, ByteBuffer byteBufferU, int uPixelStride, int uRowStride, ByteBuffer byteBufferV, int vPixelStride, int vRowStride, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
101 |
102 | public static native int yuv420pToBGRA(ByteBuffer byteBufferY, int yRowStride, ByteBuffer byteBufferU, int uPixelStride, int uRowStride, ByteBuffer byteBufferV, int vPixelStride, int vRowStride, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
103 |
104 | public static native int yv12ToRGBA(byte[] yv12, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
105 |
106 | public static native int yv12ToBGRA(byte[] yv12, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
107 |
108 | public static native int nv21ToRGBA(byte[] nv21, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
109 |
110 | public static native int nv21ToBGRA(byte[] nv21, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
111 |
112 | public static native int yuv420ToRGBA(byte[] yuv420, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
113 |
114 | public static native int yuv420ToBGRA(byte[] yuv420, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
115 |
116 | public static native int yuv420ToGray(ByteBuffer byteBufferY, int yRowStride, ByteBuffer byteBufferU, int uPixelStride, int uRowStride, ByteBuffer byteBufferV, int vPixelStride, int vRowStride, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
117 |
118 | public static native int yv12ToGrey(byte[] yv12, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
119 |
120 | public static native int nv21ToGrey(byte[] nv21, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
121 |
122 | public static native int handleRGBA4ByteBuffer(ByteBuffer byteBuffer, int stride, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
123 |
124 | public static native int handleRGBA(byte[] buffer, int stride, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
125 |
126 | /**
127 | * @return Here RGBA and BGRA are the same.
128 | */
129 | public static native int greyToRGBA(byte[] grey, byte[] outData, int width, int height);
130 |
131 | /**
132 | * @param outData YUVI420
133 | */
134 | public static native int preHandleNV21(byte[] nv21, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
135 |
136 | /**
137 | * @param outData YUVI420
138 | */
139 | public static native int preHandleYV12(byte[] yv12, byte[] outData, int width, int height, boolean flipHorizontal, int rotate);
140 |
141 | public static native int yuvI420ToNV21(byte[] yuvI420, byte[] outData, int width, int height);
142 |
143 | public static native int yuvI420ToNV12(byte[] yuvI420, byte[] outData, int width, int height);
144 |
145 | public static native int yuvI420ToYV12(byte[] yuvI420, byte[] yv12, int width, int height);
146 |
147 | public static native int cropNV21(byte[] src, byte[] dis, int srcWidth, int srcHeight, int startX, int startY, int disWidth, int disHeight);
148 |
149 | public static native int cropYUV420(byte[] src, byte[] dis, int srcWidth, int srcHeight, int startX, int startY, int disWidth, int disHeight);
150 |
151 | public static native int zoomYUV420(byte[] src, byte[] dis, int srcWidth, int srcHeight, int disWidth, int disHeight);
152 |
153 | public static native int bitmapToYUV420(Bitmap bitmap, byte[] dis);
154 |
155 | public static native int translationSingleChannel(byte[] singleChannelData, byte[] outData, int width, int height, int translationX, int translationY);
156 | }
157 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bookzhan/bzyuvlib/e208742089ffd942a215ddae227408a5b3e8be69/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Apr 15 13:15:12 CST 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-7.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':bzyuv'
2 | rootProject.name='BZYUVLib'
3 |
--------------------------------------------------------------------------------