├── .gitignore
├── .idea
├── compiler.xml
├── encodings.xml
├── gradle.xml
├── jarRepositories.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── pri
│ │ └── tool
│ │ └── anv4l2camera
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── pri
│ │ │ └── tool
│ │ │ └── anv4l2camera
│ │ │ ├── AutoFitSurfaceView.java
│ │ │ ├── MyExpandableListAdapter.java
│ │ │ └── V4L2CameraActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── arrow.png
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_camera.xml
│ │ ├── item_elv_child.xml
│ │ └── item_elv_group.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
│ └── pri
│ └── tool
│ └── anv4l2camera
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── v4l2camera
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
├── androidTest
└── java
│ └── pri
│ └── tool
│ └── v4l2camera
│ └── ExampleInstrumentedTest.java
├── main
├── AndroidManifest.xml
├── cpp
│ ├── CMakeLists.txt
│ ├── JavaCallHelper.cpp
│ ├── JavaCallHelper.h
│ ├── V4L2Camera.cpp
│ ├── V4L2Camera.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
│ │ │ ├── scale_uv.h
│ │ │ ├── version.h
│ │ │ └── video_common.h
│ ├── libjpeg
│ │ ├── cderror.h
│ │ ├── cdjpeg.h
│ │ ├── jconfig.h
│ │ ├── jerror.h
│ │ ├── jinclude.h
│ │ ├── jmorecfg.h
│ │ ├── jpeglib.h
│ │ └── jversion.h
│ ├── libyuv
│ │ └── source
│ │ │ ├── compare.cc
│ │ │ ├── compare_common.cc
│ │ │ ├── compare_gcc.cc
│ │ │ ├── compare_mmi.cc
│ │ │ ├── compare_msa.cc
│ │ │ ├── compare_neon.cc
│ │ │ ├── compare_neon64.cc
│ │ │ ├── compare_win.cc
│ │ │ ├── convert.cc
│ │ │ ├── convert_argb.cc
│ │ │ ├── convert_from.cc
│ │ │ ├── convert_from_argb.cc
│ │ │ ├── convert_jpeg.cc
│ │ │ ├── convert_to_argb.cc
│ │ │ ├── convert_to_i420.cc
│ │ │ ├── cpu_id.cc
│ │ │ ├── mjpeg_decoder.cc
│ │ │ ├── mjpeg_validate.cc
│ │ │ ├── planar_functions.cc
│ │ │ ├── rotate.cc
│ │ │ ├── rotate_any.cc
│ │ │ ├── rotate_argb.cc
│ │ │ ├── rotate_common.cc
│ │ │ ├── rotate_gcc.cc
│ │ │ ├── rotate_mmi.cc
│ │ │ ├── rotate_msa.cc
│ │ │ ├── rotate_neon.cc
│ │ │ ├── rotate_neon64.cc
│ │ │ ├── rotate_win.cc
│ │ │ ├── row_any.cc
│ │ │ ├── row_common.cc
│ │ │ ├── row_gcc.cc
│ │ │ ├── row_mmi.cc
│ │ │ ├── row_msa.cc
│ │ │ ├── row_neon.cc
│ │ │ ├── row_neon64.cc
│ │ │ ├── row_win.cc
│ │ │ ├── scale.cc
│ │ │ ├── scale_any.cc
│ │ │ ├── scale_argb.cc
│ │ │ ├── scale_common.cc
│ │ │ ├── scale_gcc.cc
│ │ │ ├── scale_mmi.cc
│ │ │ ├── scale_msa.cc
│ │ │ ├── scale_neon.cc
│ │ │ ├── scale_neon64.cc
│ │ │ ├── scale_uv.cc
│ │ │ ├── scale_win.cc
│ │ │ ├── test.sh
│ │ │ └── video_common.cc
│ └── native_camera.cpp
├── java
│ └── pri
│ │ └── tool
│ │ ├── bean
│ │ ├── Frame.java
│ │ ├── FrameRate.java
│ │ └── Parameter.java
│ │ └── v4l2camera
│ │ ├── IDataCallback.java
│ │ ├── IStateCallback.java
│ │ ├── ImageUtils.java
│ │ └── V4L2Camera.java
├── jniLibs
│ └── armeabi-v7a
│ │ └── libjpeg.so
└── res
│ └── values
│ └── strings.xml
└── test
└── java
└── pri
└── tool
└── v4l2camera
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AnV4L2Camera
2 | Android 通过V4L2接口调用camera
3 |
4 | 因为需要能够打开设备 "/dev/video0" 可能在手机或其他成品机器上没有权限运行
5 |
6 | 需要在local.properties添加
7 | ndk.dir=C\:\\Users\\Fiture\\AppData\\Local\\Android\\Sdk\\ndk\\21.1.6352462
8 |
9 |
10 | 工程介绍可以参考
11 | https://www.jianshu.com/p/1fdf2ec2b206
12 |
13 | https://www.jianshu.com/p/6933ab0f153d
14 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.0"
6 | defaultConfig {
7 | applicationId "pri.tool.anv4l2camera"
8 | minSdkVersion 21
9 | targetSdkVersion 29
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 |
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | implementation fileTree(dir: 'libs', include: ['*.jar'])
25 | implementation 'androidx.appcompat:appcompat:1.2.0'
26 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
27 | testImplementation 'junit:junit:4.12'
28 | androidTestImplementation 'androidx.test:runner:1.2.0'
29 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
30 |
31 | implementation project(":v4l2camera")
32 | }
33 |
--------------------------------------------------------------------------------
/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/pri/tool/anv4l2camera/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package pri.tool.anv4l2camera;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.InstrumentationRegistry;
6 | import androidx.test.runner.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.getTargetContext();
24 |
25 | assertEquals("pri.tool.anv4l2camera", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
11 |
12 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/pri/tool/anv4l2camera/AutoFitSurfaceView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 The TensorFlow Authors. All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package pri.tool.anv4l2camera;
18 |
19 | import android.content.Context;
20 | import android.util.AttributeSet;
21 | import android.util.Log;
22 | import android.view.SurfaceView;
23 | import android.view.TextureView;
24 |
25 | /**
26 | * A {@link TextureView} that can be adjusted to a specified aspect ratio.
27 | */
28 | public class AutoFitSurfaceView extends SurfaceView {
29 | private final static String TAG = "AutoFitSurfaceView";
30 | private int ratioWidth = 0;
31 | private int ratioHeight = 0;
32 |
33 | public AutoFitSurfaceView(final Context context) {
34 | this(context, null);
35 | }
36 |
37 | public AutoFitSurfaceView(final Context context, final AttributeSet attrs) {
38 | this(context, attrs, 0);
39 | }
40 |
41 | public AutoFitSurfaceView(final Context context, final AttributeSet attrs, final int defStyle) {
42 | super(context, attrs, defStyle);
43 | }
44 |
45 | /**
46 | * Sets the aspect ratio for this view. The size of the view will be measured based on the ratio
47 | * calculated from the parameters. Note that the actual sizes of parameters don't matter, that
48 | * is, calling setAspectRatio(2, 3) and setAspectRatio(4, 6) make the same result.
49 | *
50 | * @param width Relative horizontal size
51 | * @param height Relative vertical size
52 | */
53 | public void setAspectRatio(final int width, final int height) {
54 | if (width < 0 || height < 0) {
55 | throw new IllegalArgumentException("Size cannot be negative.");
56 | }
57 | ratioWidth = width;
58 | ratioHeight = height;
59 | requestLayout();
60 | }
61 |
62 | @Override
63 | protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
64 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
65 | final int width = MeasureSpec.getSize(widthMeasureSpec);
66 | final int height = MeasureSpec.getSize(heightMeasureSpec);
67 | Log.d(TAG, "onMeasure width:" + width + ", height:" + height);
68 | if (0 == ratioWidth || 0 == ratioHeight) {
69 | setMeasuredDimension(width, height);
70 | } else {
71 | if (width < height * ratioWidth / ratioHeight) {
72 | setMeasuredDimension(width, width * ratioHeight / ratioWidth);
73 | } else {
74 | setMeasuredDimension(height * ratioWidth / ratioHeight, height);
75 | }
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/pri/tool/anv4l2camera/MyExpandableListAdapter.java:
--------------------------------------------------------------------------------
1 | package pri.tool.anv4l2camera;
2 |
3 | import android.content.Context;
4 | import android.nfc.Tag;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.BaseExpandableListAdapter;
10 | import android.widget.CheckBox;
11 | import android.widget.CompoundButton;
12 | import android.widget.ImageView;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 |
19 | public class MyExpandableListAdapter extends BaseExpandableListAdapter {
20 | public final static String TAG = "MyExpandableListAdapter";
21 |
22 | private String[] pixformat;
23 | private String[][] resolution;
24 | private Context context;
25 | View.OnClickListener ivGoToChildClickListener;
26 |
27 | HashMap statusHashMap;
28 |
29 | CheckBox childBox;
30 |
31 | public MyExpandableListAdapter() {
32 |
33 | }
34 |
35 | public MyExpandableListAdapter(String[] pixformat, String[][] resolution, Context context,
36 | View.OnClickListener ivGoToChildClickListener) {
37 | this.pixformat = pixformat;
38 | this.resolution = resolution;
39 | this.context = context;
40 | this.ivGoToChildClickListener = ivGoToChildClickListener;
41 |
42 | statusHashMap = new HashMap();
43 | for (int i = 0; i < resolution.length; i++) {// 初始时,让所有的子选项均未被选中
44 | for (int a = 0; a < resolution[i].length; a++) {
45 | statusHashMap.put(pixformat[i] + resolution[i][a], false);
46 | }
47 | }
48 | }
49 |
50 | @Override
51 | public int getGroupCount() { //组的数量
52 | return pixformat.length;
53 | }
54 |
55 | @Override
56 | public int getChildrenCount(int groupPosition) { //某组中子项数量
57 | return resolution[groupPosition].length;
58 | }
59 |
60 | @Override
61 | public Object getGroup(int groupPosition) { //某组
62 | return pixformat[groupPosition];
63 | }
64 |
65 | @Override
66 | public Object getChild(int groupPosition, int childPosition) { //某子项
67 | return resolution[groupPosition][childPosition];
68 | }
69 |
70 | @Override
71 | public long getGroupId(int groupPosition) {
72 | return groupPosition;
73 | }
74 |
75 | @Override
76 | public long getChildId(int groupPosition, int childPosition) {
77 | return childPosition;
78 | }
79 |
80 |
81 | @Override
82 | public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
83 | GroupHold groupHold;
84 | if (convertView == null) {
85 | convertView = LayoutInflater.from(context).inflate(R.layout.item_elv_group, null);
86 | groupHold = new GroupHold();
87 | groupHold.tvGroupName = (TextView) convertView.findViewById(R.id.tv_groupName);
88 | groupHold.ivGoToChildLv = (ImageView) convertView.findViewById(R.id.iv_goToChildLV);
89 |
90 | convertView.setTag(groupHold);
91 |
92 | } else {
93 | groupHold = (GroupHold) convertView.getTag();
94 |
95 | }
96 |
97 | String groupName = pixformat[groupPosition];
98 | groupHold.tvGroupName.setText(groupName);
99 |
100 |
101 | //取消默认的groupIndicator后根据方法中传入的isExpand判断组是否展开并动态自定义指示器
102 | // if (isExpanded) { //如果组展开
103 | // groupHold.ivGoToChildLv.setImageResource(R.drawable.delete);
104 | // } else {
105 | // groupHold.ivGoToChildLv.setImageResource(R.drawable.send_btn_add);
106 | // }
107 |
108 | //setTag() 方法接收的类型是object ,所以可将position和converView先封装在Map中。Bundle中无法封装view,所以不用bundle
109 | Map tagMap = new HashMap<>();
110 | tagMap.put("groupPosition", groupPosition);
111 | tagMap.put("isExpanded", isExpanded);
112 | groupHold.ivGoToChildLv.setTag(tagMap);
113 |
114 | //图标的点击事件
115 | groupHold.ivGoToChildLv.setOnClickListener(ivGoToChildClickListener);
116 |
117 | return convertView;
118 | }
119 |
120 | @Override
121 | public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView,
122 | ViewGroup parent) {
123 | ChildHold childHold;
124 | if (convertView == null) {
125 | convertView = LayoutInflater.from(context).inflate(R.layout.item_elv_child, null);
126 | childHold = new ChildHold();
127 | childHold.tvChildName = (TextView) convertView.findViewById(R.id.tv_elv_childName);
128 | childHold.cbElvChild = (CheckBox) convertView.findViewById(R.id.cb_elvChild);
129 | convertView.setTag(childHold);
130 | } else {
131 | childHold = (ChildHold) convertView.getTag();
132 | }
133 |
134 | Log.e(TAG, "getChildView");
135 |
136 | String childName = resolution[groupPosition][childPosition];
137 | childHold.tvChildName.setText(childName);
138 |
139 | Boolean nowStatus = statusHashMap.get(pixformat[groupPosition] + resolution[groupPosition][childPosition]);//当前状态
140 | childHold.cbElvChild.setChecked(nowStatus);
141 |
142 | // childHold.cbElvChild.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
143 | // @Override
144 | // public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
145 | // if (isChecked) {
146 | // Toast.makeText(context, "条目选中:" + pixformat[groupPosition] + "的" +
147 | // resolution[groupPosition][childPosition] + "被选中了", Toast.LENGTH_SHORT).show();
148 | // } else {
149 | // Toast.makeText(context, "条目选中:" + pixformat[groupPosition] + "的" +
150 | // resolution[groupPosition][childPosition] + "被取消选中了", Toast.LENGTH_SHORT).show();
151 | // }
152 | // }
153 | // });
154 |
155 | return convertView;
156 | }
157 |
158 | @Override
159 | public boolean isChildSelectable(int groupPosition, int childPosition) {
160 | return true; //默认返回false,改成true表示组中的子条目可以被点击选中
161 | }
162 |
163 | @Override
164 | public boolean hasStableIds() {
165 | return true;
166 | }
167 |
168 | public void setChildSelectState(String tag, boolean itemSelect) {
169 | statusHashMap.put(tag, itemSelect);
170 | }
171 |
172 | class GroupHold {
173 | TextView tvGroupName;
174 | ImageView ivGoToChildLv;
175 | }
176 |
177 | class ChildHold {
178 | TextView tvChildName;
179 | CheckBox cbElvChild;
180 | }
181 | }
182 |
--------------------------------------------------------------------------------
/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/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/app/src/main/res/drawable/arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_camera.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_elv_child.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_elv_group.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
14 |
15 |
20 |
--------------------------------------------------------------------------------
/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/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/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 | AnV4L2Camera
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/pri/tool/anv4l2camera/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package pri.tool.anv4l2camera;
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 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.4.1'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 |
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/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/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Aug 21 14:25:03 CST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':v4l2camera'
2 |
--------------------------------------------------------------------------------
/v4l2camera/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/v4l2camera/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.0"
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion 21
10 | targetSdkVersion 29
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 |
16 | externalNativeBuild {
17 | cmake {
18 | cppFlags ""
19 | abiFilters 'armeabi-v7a'
20 | }
21 | }
22 | }
23 |
24 | buildTypes {
25 | release {
26 | minifyEnabled false
27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
28 | }
29 | }
30 |
31 | externalNativeBuild {
32 | cmake {
33 | path "src/main/cpp/CMakeLists.txt"
34 | version "3.10.2"
35 | }
36 | }
37 |
38 | }
39 |
40 | dependencies {
41 | implementation fileTree(dir: 'libs', include: ['*.jar'])
42 |
43 | implementation 'androidx.appcompat:appcompat:1.2.0'
44 | testImplementation 'junit:junit:4.12'
45 | androidTestImplementation 'androidx.test:runner:1.2.0'
46 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
47 | }
48 |
--------------------------------------------------------------------------------
/v4l2camera/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 |
--------------------------------------------------------------------------------
/v4l2camera/src/androidTest/java/pri/tool/v4l2camera/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package pri.tool.v4l2camera;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.InstrumentationRegistry;
6 | import androidx.test.runner.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.getTargetContext();
24 |
25 | assertEquals("pri.tool.v4l2camera.test", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/v4l2camera/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 | include_directories(include libjpeg)
9 | add_definitions(-DHAVE_JPEG -DSAVE_JPEG)
10 |
11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}")
12 |
13 | file(GLOB src_files *.cpp libyuv/source/*.cc)
14 |
15 |
16 | # 指定libjpeg动态库路径
17 | set(jpeglibs "${CMAKE_SOURCE_DIR}/../jniLibs")
18 |
19 | # 导入第三方库:libjpeg.so
20 | add_library(libjpeg SHARED IMPORTED)
21 | set_target_properties(libjpeg PROPERTIES
22 | IMPORTED_LOCATION "${jpeglibs}/${ANDROID_ABI}/libjpeg.so")
23 |
24 |
25 |
26 | # Creates and names a library, sets it as either STATIC
27 | # or SHARED, and provides the relative paths to its source code.
28 | # You can define multiple libraries, and CMake builds them for you.
29 | # Gradle automatically packages shared libraries with your APK.
30 |
31 | add_library( # Sets the name of the library.
32 | v4l-android
33 |
34 | # Sets the library as a shared library.
35 | SHARED
36 |
37 | # Provides a relative path to your source file(s).
38 | #native-lib.cpp
39 | ${src_files})
40 |
41 | # Searches for a specified prebuilt library and stores the path as a
42 | # variable. Because CMake includes system libraries in the search path by
43 | # default, you only need to specify the name of the public NDK library
44 | # you want to add. CMake verifies that the library exists before
45 | # completing its build.
46 |
47 | find_library( # Sets the name of the path variable.
48 | log-lib
49 |
50 | # Specifies the name of the NDK library that
51 | # you want CMake to locate.
52 | log )
53 |
54 | # Specifies libraries CMake should link to your target library. You
55 | # can link multiple libraries, such as libraries you define in this
56 | # build script, prebuilt third-party libraries, or system libraries.
57 |
58 | target_link_libraries( # Specifies the target library.
59 | v4l-android
60 | android
61 | libjpeg
62 |
63 | # Links the target library to the log library
64 | # included in the NDK.
65 | ${log-lib})
66 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/JavaCallHelper.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Administrator on 2019/8/9.
3 | //
4 |
5 | #include "JavaCallHelper.h"
6 | #include
7 |
8 | //定义日志打印宏函数
9 | #define LOG_TAG "JavaCallHelper"
10 | #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
11 | #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
12 | #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
13 | #define ALOGD(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
14 |
15 | JavaCallHelper::JavaCallHelper(JavaVM *javaVM_, JNIEnv *env_, jobject instance_) {
16 | ALOGE("enter : %s", __FUNCTION__);
17 | this->javaVM = javaVM_;
18 | this->env = env_;
19 | // this->instance = instance_;//不能直接赋值!
20 | //一旦涉及到 jobject 跨方法、跨线程,需要创建全局引用
21 | this->instance = env->NewGlobalRef(instance_);
22 | jclass clazz = env->GetObjectClass(instance);
23 | // cd 进入 class所在的目录 执行: javap -s 全限定名,查看输出的 descriptor
24 | // xx\app\build\intermediates\classes\debug>javap -s com.netease.jnitest.Helper
25 | jDataCallback = env->GetMethodID(clazz, "postDataFromNative", "([BIII)V");
26 |
27 | ALOGE("leave: %s", __FUNCTION__);
28 |
29 | }
30 |
31 | JavaCallHelper::~JavaCallHelper() {
32 | javaVM = 0;
33 | env->DeleteGlobalRef(instance);
34 | instance = 0;
35 | }
36 |
37 |
38 | void JavaCallHelper::onDataCallback(unsigned char* buf, int len, int width, int height, int pixFormat) {
39 | JNIEnv *env = NULL;
40 |
41 | int status = javaVM->GetEnv((void**)&env, JNI_VERSION_1_4);
42 | if (status < 0) {
43 | javaVM->AttachCurrentThread(&env, NULL);
44 | ALOGE("AttachCurrentThread");
45 | }
46 |
47 | jbyteArray array = env->NewByteArray(len);
48 | jbyte* pByte;
49 | if (array == NULL) {
50 | ALOGE("onDataCallback NewByteArray fail");
51 | return;
52 | }
53 |
54 | pByte = new jbyte[len];
55 | if (pByte == NULL) {
56 | ALOGE("onDataCallback creat jbyte memory fail");
57 | return;
58 | }
59 | for (int i = 0; i < len; i++) {
60 | *(pByte + i) = *(buf + i);
61 | }
62 |
63 | env->SetByteArrayRegion(array, 0, len, pByte);
64 |
65 | ALOGE("CallVoidMethod");
66 | env->CallVoidMethod(instance, jDataCallback, array, width, height, pixFormat);
67 |
68 | env->DeleteLocalRef(array);
69 | delete pByte;
70 | pByte = NULL;
71 |
72 | if (env->ExceptionCheck()) {
73 | ALOGW("An exception occurred while notifying an event.");
74 | env->ExceptionClear();
75 | }
76 |
77 | if (status < 0) {
78 | javaVM->DetachCurrentThread();
79 | ALOGE("DetachCurrentThread");
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/JavaCallHelper.h:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Administrator on 2019/8/9.
3 | //
4 |
5 | #ifndef NE_PLAYER_1_JAVACALLHELPER_H
6 | #define NE_PLAYER_1_JAVACALLHELPER_H
7 |
8 | #include
9 |
10 | class JavaCallHelper {
11 | public:
12 | JavaCallHelper(JavaVM *javaVM_, JNIEnv *env_, jobject instance_);
13 |
14 | ~JavaCallHelper();
15 |
16 | void onDataCallback(unsigned char* buf, int len, int width, int height, int pixFormat);
17 |
18 |
19 | private:
20 | JavaVM *javaVM;
21 | JNIEnv *env;
22 | jobject instance;
23 | jmethodID jDataCallback;
24 | };
25 |
26 |
27 | //extern "C"
28 | //JNIEXPORT void JNICALL
29 | //Java_com_netease_jnitest_MainActivity_invokeHelper(JNIEnv *env, jobject instance) {
30 | // jclass clazz = env->FindClass("com/netease/jnitest/Helper");
31 | // //获得具体的静态方法 参数3:签名(下方说明)
32 | // //如果不会填 可以使用javap
33 | // jmethodID staticMethod = env->GetStaticMethodID(clazz,"staticMethod","(Ljava/lang/String;IZ)V");
34 | // //调用静态方法
35 | // jstring staticStr= env->NewStringUTF("C++调用静态方法");
36 | // env->CallStaticVoidMethod(clazz,staticMethod,staticStr,1,1);
37 | //
38 | // //获得构造方法 :构造方法写法
39 | // jmethodID constructMethod = env->GetMethodID(clazz,"","()V");
40 | // //创建对象
41 | // jobject helper = env->NewObject(clazz,constructMethod);
42 | // jmethodID instanceMethod = env->GetMethodID(clazz,"instanceMethod","(Ljava/lang/String;IZ)V");
43 | // jstring instanceStr= env->NewStringUTF("C++调用实例方法");
44 | // env->CallVoidMethod(helper,instanceMethod,instanceStr,2,0);
45 | //
46 | // //释放
47 | // env->DeleteLocalRef(clazz);
48 | // env->DeleteLocalRef(staticStr);
49 | // env->DeleteLocalRef(instanceStr);
50 | // env->DeleteLocalRef(helper);
51 | //}
52 |
53 | #endif //NE_PLAYER_1_JAVACALLHELPER_H
54 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/V4L2Camera.h:
--------------------------------------------------------------------------------
1 | /*
2 | **
3 | ** Copyright (C) 2010 Moko365 Inc.
4 | ** Copyright 2008, The Android Open Source Project
5 | **
6 | ** Licensed under the Apache License, Version 2.0 (the "License");
7 | ** you may not use this file except in compliance with the License.
8 | ** You may obtain a copy of the License at
9 | **
10 | ** http://www.apache.org/licenses/LICENSE-2.0
11 | **
12 | ** Unless required by applicable law or agreed to in writing, software
13 | ** distributed under the License is distributed on an "AS IS" BASIS,
14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | ** See the License for the specific language governing permissions and
16 | ** limitations under the License.
17 | */
18 |
19 | #ifndef _CAMIF_H_
20 | #define _CAMIF_H_
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include "JavaCallHelper.h"
27 |
28 | //sync with com.iview.common.module.ImageUtils
29 | #define YV12 0
30 | #define NV21 1
31 | #define YUYV 2
32 | #define MJPEG 3
33 | #define H264 4
34 |
35 |
36 | typedef struct {
37 | int numerator;
38 | int denominator;
39 | }FrameRate;
40 |
41 | typedef struct {
42 | int width;
43 | int height;
44 | std::list frameRate;
45 | } Frame;
46 |
47 | typedef struct {
48 | int pixFormat;
49 | std::list frames;
50 | }Parameter;
51 |
52 | #define STATE_OK 0
53 | #define ERROR_INIT_FAIL -1
54 | #define ERROR_LOGIN_FAIL -2
55 | #define ERROR_STATE_ILLEGAL -3
56 | #define ERROR_CAPABILITY_UNSUPPORT -4
57 | #define ERROR_OPEN_FAIL -5
58 | #define ERROR_PREVIEW_FAIL -6
59 |
60 |
61 |
62 | class V4L2Camera {
63 |
64 | public:
65 | V4L2Camera();
66 | ~V4L2Camera();
67 |
68 | int Open(const char *device,
69 | unsigned int width,
70 | unsigned int height,
71 | unsigned int pixelformat);
72 | int Init();
73 | void Uninit();
74 | void Close();
75 |
76 | void StartStreaming();
77 | void StopStreaming();
78 |
79 | std::list getParameters();
80 | int setPreviewSize(int width, int height, int pixformat);
81 |
82 | int GrabRawFrame(void *raw_base);
83 | void Convert(void *raw_base,
84 | void *preview_base,
85 | unsigned int rawSize);
86 |
87 | void setSurface(ANativeWindow *window);
88 |
89 | void _start();
90 | void renderVideo(unsigned char *preview);
91 |
92 | void setListener(JavaCallHelper * listener);
93 | void sendDataToJava(unsigned char *raw, int dataSize);
94 |
95 | int bmp_write(unsigned char *image, int imageWidth, int imageHeight, const char *filename);
96 |
97 | private:
98 | int fd;
99 | int start;
100 | unsigned char *mem;
101 | struct v4l2_buffer buf;
102 |
103 | unsigned int width;
104 | unsigned int height;
105 | unsigned int pixelformat;
106 |
107 | std::list parameters;
108 |
109 | ANativeWindow *window = 0;
110 | std::mutex windowLock;
111 |
112 | pthread_t pid_start;
113 |
114 | JavaCallHelper* listener = 0;
115 | std::mutex listenerLock;
116 | };
117 |
118 |
119 | #endif
120 |
--------------------------------------------------------------------------------
/v4l2camera/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/scale_uv.h"
30 | #include "libyuv/version.h"
31 | #include "libyuv/video_common.h"
32 |
33 | #endif // INCLUDE_LIBYUV_H_
34 |
--------------------------------------------------------------------------------
/v4l2camera/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 |
--------------------------------------------------------------------------------
/v4l2camera/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 |
--------------------------------------------------------------------------------
/v4l2camera/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(__clang__) && \
59 | (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2))
60 | #define HAS_HASHDJB2_AVX2
61 | #define HAS_SUMSQUAREERROR_AVX2
62 | #endif
63 |
64 | // The following are available for GCC and clangcl:
65 | #if !defined(LIBYUV_DISABLE_X86) && (defined(__x86_64__) || defined(__i386__))
66 | #define HAS_HAMMINGDISTANCE_SSSE3
67 | #endif
68 |
69 | // The following are available for GCC and clangcl:
70 | #if !defined(LIBYUV_DISABLE_X86) && defined(CLANG_HAS_AVX2) && \
71 | (defined(__x86_64__) || defined(__i386__))
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 |
--------------------------------------------------------------------------------
/v4l2camera/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 | // Convert 8 bit YUV to 12 bit.
43 | #define H420ToH012 I420ToI012
44 | LIBYUV_API
45 | int I420ToI012(const uint8_t* src_y,
46 | int src_stride_y,
47 | const uint8_t* src_u,
48 | int src_stride_u,
49 | const uint8_t* src_v,
50 | int src_stride_v,
51 | uint16_t* dst_y,
52 | int dst_stride_y,
53 | uint16_t* dst_u,
54 | int dst_stride_u,
55 | uint16_t* dst_v,
56 | int dst_stride_v,
57 | int width,
58 | int height);
59 |
60 | LIBYUV_API
61 | int I420ToI422(const uint8_t* src_y,
62 | int src_stride_y,
63 | const uint8_t* src_u,
64 | int src_stride_u,
65 | const uint8_t* src_v,
66 | int src_stride_v,
67 | uint8_t* dst_y,
68 | int dst_stride_y,
69 | uint8_t* dst_u,
70 | int dst_stride_u,
71 | uint8_t* dst_v,
72 | int dst_stride_v,
73 | int width,
74 | int height);
75 |
76 | LIBYUV_API
77 | int I420ToI444(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 | // Copy to I400. Source can be I420, I422, I444, I400, NV12 or NV21.
93 | LIBYUV_API
94 | int I400Copy(const uint8_t* src_y,
95 | int src_stride_y,
96 | uint8_t* dst_y,
97 | int dst_stride_y,
98 | int width,
99 | int height);
100 |
101 | LIBYUV_API
102 | int I420ToNV12(const uint8_t* src_y,
103 | int src_stride_y,
104 | const uint8_t* src_u,
105 | int src_stride_u,
106 | const uint8_t* src_v,
107 | int src_stride_v,
108 | uint8_t* dst_y,
109 | int dst_stride_y,
110 | uint8_t* dst_uv,
111 | int dst_stride_uv,
112 | int width,
113 | int height);
114 |
115 | LIBYUV_API
116 | int I420ToNV21(const uint8_t* src_y,
117 | int src_stride_y,
118 | const uint8_t* src_u,
119 | int src_stride_u,
120 | const uint8_t* src_v,
121 | int src_stride_v,
122 | uint8_t* dst_y,
123 | int dst_stride_y,
124 | uint8_t* dst_vu,
125 | int dst_stride_vu,
126 | int width,
127 | int height);
128 |
129 | LIBYUV_API
130 | int I420ToYUY2(const uint8_t* src_y,
131 | int src_stride_y,
132 | const uint8_t* src_u,
133 | int src_stride_u,
134 | const uint8_t* src_v,
135 | int src_stride_v,
136 | uint8_t* dst_yuy2,
137 | int dst_stride_yuy2,
138 | int width,
139 | int height);
140 |
141 | LIBYUV_API
142 | int I420ToUYVY(const uint8_t* src_y,
143 | int src_stride_y,
144 | const uint8_t* src_u,
145 | int src_stride_u,
146 | const uint8_t* src_v,
147 | int src_stride_v,
148 | uint8_t* dst_uyvy,
149 | int dst_stride_uyvy,
150 | int width,
151 | int height);
152 |
153 | // The following are from convert_argb.h
154 | // DEPRECATED: The prototypes will be removed in future. Use convert_argb.h
155 |
156 | // Convert I420 to ARGB.
157 | LIBYUV_API
158 | int I420ToARGB(const uint8_t* src_y,
159 | int src_stride_y,
160 | const uint8_t* src_u,
161 | int src_stride_u,
162 | const uint8_t* src_v,
163 | int src_stride_v,
164 | uint8_t* dst_argb,
165 | int dst_stride_argb,
166 | int width,
167 | int height);
168 |
169 | // Convert I420 to ABGR.
170 | LIBYUV_API
171 | int I420ToABGR(const uint8_t* src_y,
172 | int src_stride_y,
173 | const uint8_t* src_u,
174 | int src_stride_u,
175 | const uint8_t* src_v,
176 | int src_stride_v,
177 | uint8_t* dst_abgr,
178 | int dst_stride_abgr,
179 | int width,
180 | int height);
181 |
182 | // Convert I420 to specified format.
183 | // "dst_sample_stride" is bytes in a row for the destination. Pass 0 if the
184 | // buffer has contiguous rows. Can be negative. A multiple of 16 is optimal.
185 | LIBYUV_API
186 | int ConvertFromI420(const uint8_t* y,
187 | int y_stride,
188 | const uint8_t* u,
189 | int u_stride,
190 | const uint8_t* v,
191 | int v_stride,
192 | uint8_t* dst_sample,
193 | int dst_sample_stride,
194 | int width,
195 | int height,
196 | uint32_t fourcc);
197 |
198 | #ifdef __cplusplus
199 | } // extern "C"
200 | } // namespace libyuv
201 | #endif
202 |
203 | #endif // INCLUDE_LIBYUV_CONVERT_FROM_H_
204 |
--------------------------------------------------------------------------------
/v4l2camera/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 |
--------------------------------------------------------------------------------
/v4l2camera/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 |
--------------------------------------------------------------------------------
/v4l2camera/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 |
--------------------------------------------------------------------------------
/v4l2camera/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 |
--------------------------------------------------------------------------------
/v4l2camera/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 32 bit:
36 | #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && defined(_MSC_VER) && \
37 | !defined(__clang__)
38 | #define HAS_TRANSPOSEWX8_SSSE3
39 | #define HAS_TRANSPOSEUVWX8_SSE2
40 | #endif
41 |
42 | // The following are available for GCC 32 or 64 bit:
43 | #if !defined(LIBYUV_DISABLE_X86) && (defined(__i386__) || defined(__x86_64__))
44 | #define HAS_TRANSPOSEWX8_SSSE3
45 | #endif
46 |
47 | // The following are available for 64 bit GCC:
48 | #if !defined(LIBYUV_DISABLE_X86) && defined(__x86_64__)
49 | #define HAS_TRANSPOSEWX8_FAST_SSSE3
50 | #define HAS_TRANSPOSEUVWX8_SSE2
51 | #endif
52 |
53 | #if !defined(LIBYUV_DISABLE_NEON) && \
54 | (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__))
55 | #define HAS_TRANSPOSEWX8_NEON
56 | #define HAS_TRANSPOSEUVWX8_NEON
57 | #endif
58 |
59 | #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
60 | #define HAS_TRANSPOSEWX16_MSA
61 | #define HAS_TRANSPOSEUVWX16_MSA
62 | #endif
63 |
64 | #if !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A)
65 | #define HAS_TRANSPOSEWX8_MMI
66 | #define HAS_TRANSPOSEUVWX8_MMI
67 | #endif
68 |
69 | void TransposeWxH_C(const uint8_t* src,
70 | int src_stride,
71 | uint8_t* dst,
72 | int dst_stride,
73 | int width,
74 | int height);
75 |
76 | void TransposeWx8_C(const uint8_t* src,
77 | int src_stride,
78 | uint8_t* dst,
79 | int dst_stride,
80 | int width);
81 | void TransposeWx16_C(const uint8_t* src,
82 | int src_stride,
83 | uint8_t* dst,
84 | int dst_stride,
85 | int width);
86 | void TransposeWx8_NEON(const uint8_t* src,
87 | int src_stride,
88 | uint8_t* dst,
89 | int dst_stride,
90 | int width);
91 | void TransposeWx8_SSSE3(const uint8_t* src,
92 | int src_stride,
93 | uint8_t* dst,
94 | int dst_stride,
95 | int width);
96 | void TransposeWx8_MMI(const uint8_t* src,
97 | int src_stride,
98 | uint8_t* dst,
99 | int dst_stride,
100 | int width);
101 | void TransposeWx8_Fast_SSSE3(const uint8_t* src,
102 | int src_stride,
103 | uint8_t* dst,
104 | int dst_stride,
105 | int width);
106 | void TransposeWx16_MSA(const uint8_t* src,
107 | int src_stride,
108 | uint8_t* dst,
109 | int dst_stride,
110 | int width);
111 |
112 | void TransposeWx8_Any_NEON(const uint8_t* src,
113 | int src_stride,
114 | uint8_t* dst,
115 | int dst_stride,
116 | int width);
117 | void TransposeWx8_Any_SSSE3(const uint8_t* src,
118 | int src_stride,
119 | uint8_t* dst,
120 | int dst_stride,
121 | int width);
122 | void TransposeWx8_Any_MMI(const uint8_t* src,
123 | int src_stride,
124 | uint8_t* dst,
125 | int dst_stride,
126 | int width);
127 | void TransposeWx8_Fast_Any_SSSE3(const uint8_t* src,
128 | int src_stride,
129 | uint8_t* dst,
130 | int dst_stride,
131 | int width);
132 | void TransposeWx16_Any_MSA(const uint8_t* src,
133 | int src_stride,
134 | uint8_t* dst,
135 | int dst_stride,
136 | int width);
137 |
138 | void TransposeUVWxH_C(const uint8_t* src,
139 | int src_stride,
140 | uint8_t* dst_a,
141 | int dst_stride_a,
142 | uint8_t* dst_b,
143 | int dst_stride_b,
144 | int width,
145 | int height);
146 |
147 | void TransposeUVWx8_C(const uint8_t* src,
148 | int src_stride,
149 | uint8_t* dst_a,
150 | int dst_stride_a,
151 | uint8_t* dst_b,
152 | int dst_stride_b,
153 | int width);
154 | void TransposeUVWx16_C(const uint8_t* src,
155 | int src_stride,
156 | uint8_t* dst_a,
157 | int dst_stride_a,
158 | uint8_t* dst_b,
159 | int dst_stride_b,
160 | int width);
161 | void TransposeUVWx8_SSE2(const uint8_t* src,
162 | int src_stride,
163 | uint8_t* dst_a,
164 | int dst_stride_a,
165 | uint8_t* dst_b,
166 | int dst_stride_b,
167 | int width);
168 | void TransposeUVWx8_NEON(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 | void TransposeUVWx8_MMI(const uint8_t* src,
176 | int src_stride,
177 | uint8_t* dst_a,
178 | int dst_stride_a,
179 | uint8_t* dst_b,
180 | int dst_stride_b,
181 | int width);
182 | void TransposeUVWx16_MSA(const uint8_t* src,
183 | int src_stride,
184 | uint8_t* dst_a,
185 | int dst_stride_a,
186 | uint8_t* dst_b,
187 | int dst_stride_b,
188 | int width);
189 |
190 | void TransposeUVWx8_Any_SSE2(const uint8_t* src,
191 | int src_stride,
192 | uint8_t* dst_a,
193 | int dst_stride_a,
194 | uint8_t* dst_b,
195 | int dst_stride_b,
196 | int width);
197 | void TransposeUVWx8_Any_NEON(const uint8_t* src,
198 | int src_stride,
199 | uint8_t* dst_a,
200 | int dst_stride_a,
201 | uint8_t* dst_b,
202 | int dst_stride_b,
203 | int width);
204 | void TransposeUVWx8_Any_MMI(const uint8_t* src,
205 | int src_stride,
206 | uint8_t* dst_a,
207 | int dst_stride_a,
208 | uint8_t* dst_b,
209 | int dst_stride_b,
210 | int width);
211 | void TransposeUVWx16_Any_MSA(const uint8_t* src,
212 | int src_stride,
213 | uint8_t* dst_a,
214 | int dst_stride_a,
215 | uint8_t* dst_b,
216 | int dst_stride_b,
217 | int width);
218 |
219 | #ifdef __cplusplus
220 | } // extern "C"
221 | } // namespace libyuv
222 | #endif
223 |
224 | #endif // INCLUDE_LIBYUV_ROTATE_ROW_H_
225 |
--------------------------------------------------------------------------------
/v4l2camera/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 | // Sample is expected to be in the low 12 bits.
53 | LIBYUV_API
54 | void ScalePlane_12(const uint16_t* src,
55 | int src_stride,
56 | int src_width,
57 | int src_height,
58 | uint16_t* dst,
59 | int dst_stride,
60 | int dst_width,
61 | int dst_height,
62 | enum FilterMode filtering);
63 |
64 | // Scales a YUV 4:2:0 image from the src width and height to the
65 | // dst width and height.
66 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
67 | // used. This produces basic (blocky) quality at the fastest speed.
68 | // If filtering is kFilterBilinear, interpolation is used to produce a better
69 | // quality image, at the expense of speed.
70 | // If filtering is kFilterBox, averaging is used to produce ever better
71 | // quality image, at further expense of speed.
72 | // Returns 0 if successful.
73 |
74 | LIBYUV_API
75 | int I420Scale(const uint8_t* src_y,
76 | int src_stride_y,
77 | const uint8_t* src_u,
78 | int src_stride_u,
79 | const uint8_t* src_v,
80 | int src_stride_v,
81 | int src_width,
82 | int src_height,
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 dst_width,
90 | int dst_height,
91 | enum FilterMode filtering);
92 |
93 | LIBYUV_API
94 | int I420Scale_16(const uint16_t* src_y,
95 | int src_stride_y,
96 | const uint16_t* src_u,
97 | int src_stride_u,
98 | const uint16_t* src_v,
99 | int src_stride_v,
100 | int src_width,
101 | int src_height,
102 | uint16_t* dst_y,
103 | int dst_stride_y,
104 | uint16_t* dst_u,
105 | int dst_stride_u,
106 | uint16_t* dst_v,
107 | int dst_stride_v,
108 | int dst_width,
109 | int dst_height,
110 | enum FilterMode filtering);
111 |
112 | LIBYUV_API
113 | int I420Scale_12(const uint16_t* src_y,
114 | int src_stride_y,
115 | const uint16_t* src_u,
116 | int src_stride_u,
117 | const uint16_t* src_v,
118 | int src_stride_v,
119 | int src_width,
120 | int src_height,
121 | uint16_t* dst_y,
122 | int dst_stride_y,
123 | uint16_t* dst_u,
124 | int dst_stride_u,
125 | uint16_t* dst_v,
126 | int dst_stride_v,
127 | int dst_width,
128 | int dst_height,
129 | enum FilterMode filtering);
130 |
131 | // Scales a YUV 4:4:4 image from the src width and height to the
132 | // dst width and height.
133 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
134 | // used. This produces basic (blocky) quality at the fastest speed.
135 | // If filtering is kFilterBilinear, interpolation is used to produce a better
136 | // quality image, at the expense of speed.
137 | // If filtering is kFilterBox, averaging is used to produce ever better
138 | // quality image, at further expense of speed.
139 | // Returns 0 if successful.
140 |
141 | LIBYUV_API
142 | int I444Scale(const uint8_t* src_y,
143 | int src_stride_y,
144 | const uint8_t* src_u,
145 | int src_stride_u,
146 | const uint8_t* src_v,
147 | int src_stride_v,
148 | int src_width,
149 | int src_height,
150 | uint8_t* dst_y,
151 | int dst_stride_y,
152 | uint8_t* dst_u,
153 | int dst_stride_u,
154 | uint8_t* dst_v,
155 | int dst_stride_v,
156 | int dst_width,
157 | int dst_height,
158 | enum FilterMode filtering);
159 |
160 | LIBYUV_API
161 | int I444Scale_16(const uint16_t* src_y,
162 | int src_stride_y,
163 | const uint16_t* src_u,
164 | int src_stride_u,
165 | const uint16_t* src_v,
166 | int src_stride_v,
167 | int src_width,
168 | int src_height,
169 | uint16_t* dst_y,
170 | int dst_stride_y,
171 | uint16_t* dst_u,
172 | int dst_stride_u,
173 | uint16_t* dst_v,
174 | int dst_stride_v,
175 | int dst_width,
176 | int dst_height,
177 | enum FilterMode filtering);
178 |
179 | LIBYUV_API
180 | int I444Scale_12(const uint16_t* src_y,
181 | int src_stride_y,
182 | const uint16_t* src_u,
183 | int src_stride_u,
184 | const uint16_t* src_v,
185 | int src_stride_v,
186 | int src_width,
187 | int src_height,
188 | uint16_t* dst_y,
189 | int dst_stride_y,
190 | uint16_t* dst_u,
191 | int dst_stride_u,
192 | uint16_t* dst_v,
193 | int dst_stride_v,
194 | int dst_width,
195 | int dst_height,
196 | enum FilterMode filtering);
197 |
198 | // Scales an NV12 image from the src width and height to the
199 | // dst width and height.
200 | // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
201 | // used. This produces basic (blocky) quality at the fastest speed.
202 | // If filtering is kFilterBilinear, interpolation is used to produce a better
203 | // quality image, at the expense of speed.
204 | // kFilterBox is not supported for the UV channel and will be treated as
205 | // bilinear.
206 | // Returns 0 if successful.
207 |
208 | LIBYUV_API
209 | int NV12Scale(const uint8_t* src_y,
210 | int src_stride_y,
211 | const uint8_t* src_uv,
212 | int src_stride_uv,
213 | int src_width,
214 | int src_height,
215 | uint8_t* dst_y,
216 | int dst_stride_y,
217 | uint8_t* dst_uv,
218 | int dst_stride_uv,
219 | int dst_width,
220 | int dst_height,
221 | enum FilterMode filtering);
222 |
223 | #ifdef __cplusplus
224 | // Legacy API. Deprecated.
225 | LIBYUV_API
226 | int Scale(const uint8_t* src_y,
227 | const uint8_t* src_u,
228 | const uint8_t* src_v,
229 | int src_stride_y,
230 | int src_stride_u,
231 | int src_stride_v,
232 | int src_width,
233 | int src_height,
234 | uint8_t* dst_y,
235 | uint8_t* dst_u,
236 | uint8_t* dst_v,
237 | int dst_stride_y,
238 | int dst_stride_u,
239 | int dst_stride_v,
240 | int dst_width,
241 | int dst_height,
242 | LIBYUV_BOOL interpolate);
243 |
244 | // For testing, allow disabling of specialized scalers.
245 | LIBYUV_API
246 | void SetUseReferenceImpl(LIBYUV_BOOL use);
247 | #endif // __cplusplus
248 |
249 | #ifdef __cplusplus
250 | } // extern "C"
251 | } // namespace libyuv
252 | #endif
253 |
254 | #endif // INCLUDE_LIBYUV_SCALE_H_
255 |
--------------------------------------------------------------------------------
/v4l2camera/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 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/include/libyuv/scale_uv.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #ifndef INCLUDE_LIBYUV_SCALE_UV_H_
12 | #define INCLUDE_LIBYUV_SCALE_UV_H_
13 |
14 | #include "libyuv/basic_types.h"
15 | #include "libyuv/scale.h" // For FilterMode
16 |
17 | #ifdef __cplusplus
18 | namespace libyuv {
19 | extern "C" {
20 | #endif
21 |
22 | LIBYUV_API
23 | int UVScale(const uint8_t* src_uv,
24 | int src_stride_uv,
25 | int src_width,
26 | int src_height,
27 | uint8_t* dst_uv,
28 | int dst_stride_uv,
29 | int dst_width,
30 | int dst_height,
31 | enum FilterMode filtering);
32 |
33 | // Scale a 16 bit UV image.
34 | // This function is currently incomplete, it can't handle all cases.
35 | LIBYUV_API
36 | int UVScale_16(const uint16_t* src_uv,
37 | int src_stride_uv,
38 | int src_width,
39 | int src_height,
40 | uint16_t* dst_uv,
41 | int dst_stride_uv,
42 | int dst_width,
43 | int dst_height,
44 | enum FilterMode filtering);
45 |
46 | #ifdef __cplusplus
47 | } // extern "C"
48 | } // namespace libyuv
49 | #endif
50 |
51 | #endif // INCLUDE_LIBYUV_SCALE_UV_H_
52 |
--------------------------------------------------------------------------------
/v4l2camera/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 1788
15 |
16 | #endif // INCLUDE_LIBYUV_VERSION_H_
17 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libjpeg/cderror.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cderror.h
3 | *
4 | * This file was part of the Independent JPEG Group's software:
5 | * Copyright (C) 1994-1997, Thomas G. Lane.
6 | * Modified 2009-2017 by Guido Vollbeding.
7 | * libjpeg-turbo Modifications:
8 | * Copyright (C) 2021, D. R. Commander.
9 | * For conditions of distribution and use, see the accompanying README.ijg
10 | * file.
11 | *
12 | * This file defines the error and message codes for the cjpeg/djpeg
13 | * applications. These strings are not needed as part of the JPEG library
14 | * proper.
15 | * Edit this file to add new codes, or to translate the message strings to
16 | * some other language.
17 | */
18 |
19 | /*
20 | * To define the enum list of message codes, include this file without
21 | * defining macro JMESSAGE. To create a message string table, include it
22 | * again with a suitable JMESSAGE definition (see jerror.c for an example).
23 | */
24 | #ifndef JMESSAGE
25 | #ifndef CDERROR_H
26 | #define CDERROR_H
27 | /* First time through, define the enum list */
28 | #define JMAKE_ENUM_LIST
29 | #else
30 | /* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
31 | #define JMESSAGE(code, string)
32 | #endif /* CDERROR_H */
33 | #endif /* JMESSAGE */
34 |
35 | #ifdef JMAKE_ENUM_LIST
36 |
37 | typedef enum {
38 |
39 | #define JMESSAGE(code, string) code,
40 |
41 | #endif /* JMAKE_ENUM_LIST */
42 |
43 | JMESSAGE(JMSG_FIRSTADDONCODE = 1000, NULL) /* Must be first entry! */
44 |
45 | #ifdef BMP_SUPPORTED
46 | JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format")
47 | JMESSAGE(JERR_BMP_BADDEPTH, "Only 8-, 24-, and 32-bit BMP files are supported")
48 | JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length")
49 | JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1")
50 | JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB")
51 | JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported")
52 | JMESSAGE(JERR_BMP_EMPTY, "Empty BMP image")
53 | JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM")
54 | JMESSAGE(JERR_BMP_OUTOFRANGE, "Numeric value out of range in BMP file")
55 | JMESSAGE(JTRC_BMP, "%ux%u %d-bit BMP image")
56 | JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")
57 | JMESSAGE(JTRC_BMP_OS2, "%ux%u %d-bit OS2 BMP image")
58 | JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image")
59 | #endif /* BMP_SUPPORTED */
60 |
61 | #ifdef GIF_SUPPORTED
62 | JMESSAGE(JERR_GIF_BUG, "GIF output got confused")
63 | JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d")
64 | JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB")
65 | JMESSAGE(JERR_GIF_EMPTY, "Empty GIF image")
66 | JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file")
67 | JMESSAGE(JERR_GIF_NOT, "Not a GIF file")
68 | JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image")
69 | JMESSAGE(JTRC_GIF_BADVERSION,
70 | "Warning: unexpected GIF version number '%c%c%c'")
71 | JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x")
72 | JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input")
73 | JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file")
74 | JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring")
75 | JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image")
76 | JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits")
77 | #endif /* GIF_SUPPORTED */
78 |
79 | #ifdef PPM_SUPPORTED
80 | JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
81 | JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
82 | JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
83 | JMESSAGE(JERR_PPM_OUTOFRANGE, "Numeric value out of range in PPM file")
84 | JMESSAGE(JTRC_PGM, "%ux%u PGM image")
85 | JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
86 | JMESSAGE(JTRC_PPM, "%ux%u PPM image")
87 | JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image")
88 | #endif /* PPM_SUPPORTED */
89 |
90 | #ifdef TARGA_SUPPORTED
91 | JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format")
92 | JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file")
93 | JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB")
94 | JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image")
95 | JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image")
96 | JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image")
97 | #else
98 | JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled")
99 | #endif /* TARGA_SUPPORTED */
100 |
101 | JMESSAGE(JERR_BAD_CMAP_FILE,
102 | "Color map file is invalid or of unsupported format")
103 | JMESSAGE(JERR_TOO_MANY_COLORS,
104 | "Output file format cannot handle %d colormap entries")
105 | JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed")
106 | #ifdef TARGA_SUPPORTED
107 | JMESSAGE(JERR_UNKNOWN_FORMAT,
108 | "Unrecognized input file format --- perhaps you need -targa")
109 | #else
110 | JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format")
111 | #endif
112 | JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format")
113 |
114 | #ifdef JMAKE_ENUM_LIST
115 |
116 | JMSG_LASTADDONCODE
117 | } ADDON_MESSAGE_CODE;
118 |
119 | #undef JMAKE_ENUM_LIST
120 | #endif /* JMAKE_ENUM_LIST */
121 |
122 | /* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
123 | #undef JMESSAGE
124 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libjpeg/cdjpeg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * cdjpeg.h
3 | *
4 | * This file was part of the Independent JPEG Group's software:
5 | * Copyright (C) 1994-1997, Thomas G. Lane.
6 | * Modified 2019 by Guido Vollbeding.
7 | * libjpeg-turbo Modifications:
8 | * Copyright (C) 2017, 2019, 2021, D. R. Commander.
9 | * For conditions of distribution and use, see the accompanying README.ijg
10 | * file.
11 | *
12 | * This file contains common declarations for the sample applications
13 | * cjpeg and djpeg. It is NOT used by the core JPEG library.
14 | */
15 |
16 | #define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
17 | #define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
18 | #include "jinclude.h"
19 | #include "jpeglib.h"
20 | #include "jerror.h" /* get library error codes too */
21 | #include "cderror.h" /* get application-specific error codes */
22 |
23 |
24 | /*
25 | * Object interface for cjpeg's source file decoding modules
26 | */
27 |
28 | typedef struct cjpeg_source_struct *cjpeg_source_ptr;
29 |
30 | struct cjpeg_source_struct {
31 | void (*start_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
32 | JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
33 | void (*finish_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
34 |
35 | FILE *input_file;
36 |
37 | JSAMPARRAY buffer;
38 | JDIMENSION buffer_height;
39 | #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
40 | JDIMENSION max_pixels;
41 | #endif
42 | };
43 |
44 |
45 | /*
46 | * Object interface for djpeg's output file encoding modules
47 | */
48 |
49 | typedef struct djpeg_dest_struct *djpeg_dest_ptr;
50 |
51 | struct djpeg_dest_struct {
52 | /* start_output is called after jpeg_start_decompress finishes.
53 | * The color map will be ready at this time, if one is needed.
54 | */
55 | void (*start_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
56 | /* Emit the specified number of pixel rows from the buffer. */
57 | void (*put_pixel_rows) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
58 | JDIMENSION rows_supplied);
59 | /* Finish up at the end of the image. */
60 | void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
61 | /* Re-calculate buffer dimensions based on output dimensions (for use with
62 | partial image decompression.) If this is NULL, then the output format
63 | does not support partial image decompression (BMP, in particular, cannot
64 | support partial decompression because it uses an inversion buffer to write
65 | the image in bottom-up order.) */
66 | void (*calc_buffer_dimensions) (j_decompress_ptr cinfo,
67 | djpeg_dest_ptr dinfo);
68 |
69 |
70 | /* Target file spec; filled in by djpeg.c after object is created. */
71 | FILE *output_file;
72 |
73 | /* Output pixel-row buffer. Created by module init or start_output.
74 | * Width is cinfo->output_width * cinfo->output_components;
75 | * height is buffer_height.
76 | */
77 | JSAMPARRAY buffer;
78 | JDIMENSION buffer_height;
79 | };
80 |
81 |
82 | /*
83 | * cjpeg/djpeg may need to perform extra passes to convert to or from
84 | * the source/destination file format. The JPEG library does not know
85 | * about these passes, but we'd like them to be counted by the progress
86 | * monitor. We use an expanded progress monitor object to hold the
87 | * additional pass count.
88 | */
89 |
90 | struct cdjpeg_progress_mgr {
91 | struct jpeg_progress_mgr pub; /* fields known to JPEG library */
92 | int completed_extra_passes; /* extra passes completed */
93 | int total_extra_passes; /* total extra */
94 | JDIMENSION max_scans; /* abort if the number of scans exceeds this
95 | value and the value is non-zero */
96 | boolean report; /* whether or not to report progress */
97 | /* last printed percentage stored here to avoid multiple printouts */
98 | int percent_done;
99 | };
100 |
101 | typedef struct cdjpeg_progress_mgr *cd_progress_ptr;
102 |
103 |
104 | /* Module selection routines for I/O modules. */
105 |
106 | EXTERN(cjpeg_source_ptr) jinit_read_bmp(j_compress_ptr cinfo,
107 | boolean use_inversion_array);
108 | EXTERN(djpeg_dest_ptr) jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
109 | boolean use_inversion_array);
110 | EXTERN(cjpeg_source_ptr) jinit_read_gif(j_compress_ptr cinfo);
111 | EXTERN(djpeg_dest_ptr) jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw);
112 | EXTERN(cjpeg_source_ptr) jinit_read_ppm(j_compress_ptr cinfo);
113 | EXTERN(djpeg_dest_ptr) jinit_write_ppm(j_decompress_ptr cinfo);
114 | EXTERN(cjpeg_source_ptr) jinit_read_targa(j_compress_ptr cinfo);
115 | EXTERN(djpeg_dest_ptr) jinit_write_targa(j_decompress_ptr cinfo);
116 |
117 | /* cjpeg support routines (in rdswitch.c) */
118 |
119 | EXTERN(boolean) read_quant_tables(j_compress_ptr cinfo, char *filename,
120 | boolean force_baseline);
121 | EXTERN(boolean) read_scan_script(j_compress_ptr cinfo, char *filename);
122 | EXTERN(boolean) set_quality_ratings(j_compress_ptr cinfo, char *arg,
123 | boolean force_baseline);
124 | EXTERN(boolean) set_quant_slots(j_compress_ptr cinfo, char *arg);
125 | EXTERN(boolean) set_sample_factors(j_compress_ptr cinfo, char *arg);
126 |
127 | /* djpeg support routines (in rdcolmap.c) */
128 |
129 | EXTERN(void) read_color_map(j_decompress_ptr cinfo, FILE *infile);
130 |
131 | /* common support routines (in cdjpeg.c) */
132 |
133 | EXTERN(void) start_progress_monitor(j_common_ptr cinfo,
134 | cd_progress_ptr progress);
135 | EXTERN(void) end_progress_monitor(j_common_ptr cinfo);
136 | EXTERN(boolean) keymatch(char *arg, const char *keyword, int minchars);
137 | EXTERN(FILE *) read_stdin(void);
138 | EXTERN(FILE *) write_stdout(void);
139 |
140 | /* miscellaneous useful macros */
141 |
142 | #ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
143 | #define READ_BINARY "r"
144 | #define WRITE_BINARY "w"
145 | #else
146 | #define READ_BINARY "rb"
147 | #define WRITE_BINARY "wb"
148 | #endif
149 |
150 | #ifndef EXIT_FAILURE /* define exit() codes if not provided */
151 | #define EXIT_FAILURE 1
152 | #endif
153 | #ifndef EXIT_SUCCESS
154 | #define EXIT_SUCCESS 0
155 | #endif
156 | #ifndef EXIT_WARNING
157 | #define EXIT_WARNING 2
158 | #endif
159 |
160 | #define IsExtRGB(cs) \
161 | (cs == JCS_RGB || (cs >= JCS_EXT_RGB && cs <= JCS_EXT_ARGB))
162 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libjpeg/jconfig.h:
--------------------------------------------------------------------------------
1 | /* Version ID for the JPEG library.
2 | * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60".
3 | */
4 | #define JPEG_LIB_VERSION 62
5 |
6 | /* libjpeg-turbo version */
7 | #define LIBJPEG_TURBO_VERSION 2.1.3
8 |
9 | /* libjpeg-turbo version in integer form */
10 | #define LIBJPEG_TURBO_VERSION_NUMBER 2001003
11 |
12 | /* Support arithmetic encoding */
13 | #define C_ARITH_CODING_SUPPORTED 1
14 |
15 | /* Support arithmetic decoding */
16 | #define D_ARITH_CODING_SUPPORTED 1
17 |
18 | /* Support in-memory source/destination managers */
19 | #define MEM_SRCDST_SUPPORTED 1
20 |
21 | /* Use accelerated SIMD routines. */
22 | #define WITH_SIMD 1
23 |
24 | /*
25 | * Define BITS_IN_JSAMPLE as either
26 | * 8 for 8-bit sample values (the usual setting)
27 | * 12 for 12-bit sample values
28 | * Only 8 and 12 are legal data precisions for lossy JPEG according to the
29 | * JPEG standard, and the IJG code does not support anything else!
30 | * We do not support run-time selection of data precision, sorry.
31 | */
32 |
33 | #define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
34 |
35 | /* Define to 1 if you have the header file. */
36 | #define HAVE_LOCALE_H 1
37 |
38 | /* Define to 1 if you have the header file. */
39 | #define HAVE_STDDEF_H 1
40 |
41 | /* Define to 1 if you have the header file. */
42 | #define HAVE_STDLIB_H 1
43 |
44 | /* Define if you need to include to get size_t. */
45 | #define NEED_SYS_TYPES_H 1
46 |
47 | /* Define if you have BSD-like bzero and bcopy in rather than
48 | memset/memcpy in . */
49 | /* #undef NEED_BSD_STRINGS */
50 |
51 | /* Define to 1 if the system has the type `unsigned char'. */
52 | #define HAVE_UNSIGNED_CHAR 1
53 |
54 | /* Define to 1 if the system has the type `unsigned short'. */
55 | #define HAVE_UNSIGNED_SHORT 1
56 |
57 | /* Compiler does not support pointers to undefined structures. */
58 | /* #undef INCOMPLETE_TYPES_BROKEN */
59 |
60 | /* Define if your (broken) compiler shifts signed values as if they were
61 | unsigned. */
62 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */
63 |
64 | /* Define to empty if `const' does not conform to ANSI C. */
65 | /* #undef const */
66 |
67 | /* Define to `unsigned int' if does not define. */
68 | /* #undef size_t */
69 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libjpeg/jinclude.h:
--------------------------------------------------------------------------------
1 | /*
2 | * jinclude.h
3 | *
4 | * This file was part of the Independent JPEG Group's software:
5 | * Copyright (C) 1991-1994, Thomas G. Lane.
6 | * It was modified by The libjpeg-turbo Project to include only code relevant
7 | * to libjpeg-turbo.
8 | * For conditions of distribution and use, see the accompanying README.ijg
9 | * file.
10 | *
11 | * This file exists to provide a single place to fix any problems with
12 | * including the wrong system include files. (Common problems are taken
13 | * care of by the standard jconfig symbols, but on really weird systems
14 | * you may have to edit this file.)
15 | *
16 | * NOTE: this file is NOT intended to be included by applications using the
17 | * JPEG library. Most applications need only include jpeglib.h.
18 | */
19 |
20 |
21 | /* Include auto-config file to find out which system include files we need. */
22 |
23 | #include "jconfig.h" /* auto configuration options */
24 | #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
25 |
26 | /*
27 | * We need the NULL macro and size_t typedef.
28 | * On an ANSI-conforming system it is sufficient to include .
29 | * Otherwise, we get them from or ; we may have to
30 | * pull in as well.
31 | * Note that the core JPEG library does not require ;
32 | * only the default error handler and data source/destination modules do.
33 | * But we must pull it in because of the references to FILE in jpeglib.h.
34 | * You can remove those references if you want to compile without .
35 | */
36 |
37 | #ifdef HAVE_STDDEF_H
38 | #include
39 | #endif
40 |
41 | #ifdef HAVE_STDLIB_H
42 | #include
43 | #endif
44 |
45 | #ifdef NEED_SYS_TYPES_H
46 | #include
47 | #endif
48 |
49 | #include
50 |
51 | /*
52 | * We need memory copying and zeroing functions, plus strncpy().
53 | * ANSI and System V implementations declare these in .
54 | * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
55 | * Some systems may declare memset and memcpy in .
56 | *
57 | * NOTE: we assume the size parameters to these functions are of type size_t.
58 | * Change the casts in these macros if not!
59 | */
60 |
61 | #ifdef NEED_BSD_STRINGS
62 |
63 | #include
64 | #define MEMZERO(target, size) \
65 | bzero((void *)(target), (size_t)(size))
66 | #define MEMCOPY(dest, src, size) \
67 | bcopy((const void *)(src), (void *)(dest), (size_t)(size))
68 |
69 | #else /* not BSD, assume ANSI/SysV string lib */
70 |
71 | #include
72 | #define MEMZERO(target, size) \
73 | memset((void *)(target), 0, (size_t)(size))
74 | #define MEMCOPY(dest, src, size) \
75 | memcpy((void *)(dest), (const void *)(src), (size_t)(size))
76 |
77 | #endif
78 |
79 | /*
80 | * The modules that use fread() and fwrite() always invoke them through
81 | * these macros. On some systems you may need to twiddle the argument casts.
82 | * CAUTION: argument order is different from underlying functions!
83 | */
84 |
85 | #define JFREAD(file, buf, sizeofbuf) \
86 | ((size_t)fread((void *)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))
87 | #define JFWRITE(file, buf, sizeofbuf) \
88 | ((size_t)fwrite((const void *)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))
89 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libjpeg/jversion.h:
--------------------------------------------------------------------------------
1 | /*
2 | * jversion.h
3 | *
4 | * This file was part of the Independent JPEG Group's software:
5 | * Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
6 | * libjpeg-turbo Modifications:
7 | * Copyright (C) 2010, 2012-2021, D. R. Commander.
8 | * For conditions of distribution and use, see the accompanying README.ijg
9 | * file.
10 | *
11 | * This file contains software version identification.
12 | */
13 |
14 |
15 | #if JPEG_LIB_VERSION >= 80
16 |
17 | #define JVERSION "8d 15-Jan-2012"
18 |
19 | #elif JPEG_LIB_VERSION >= 70
20 |
21 | #define JVERSION "7 27-Jun-2009"
22 |
23 | #else
24 |
25 | #define JVERSION "6b 27-Mar-1998"
26 |
27 | #endif
28 |
29 | /*
30 | * NOTE: It is our convention to place the authors in the following order:
31 | * - libjpeg-turbo authors (2009-) in descending order of the date of their
32 | * most recent contribution to the project, then in ascending order of the
33 | * date of their first contribution to the project, then in alphabetical
34 | * order
35 | * - Upstream authors in descending order of the date of the first inclusion of
36 | * their code
37 | */
38 |
39 | #define JCOPYRIGHT \
40 | "Copyright (C) 2009-2021 D. R. Commander\n" \
41 | "Copyright (C) 2015, 2020 Google, Inc.\n" \
42 | "Copyright (C) 2019-2020 Arm Limited\n" \
43 | "Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
44 | "Copyright (C) 2011-2016 Siarhei Siamashka\n" \
45 | "Copyright (C) 2015 Intel Corporation\n" \
46 | "Copyright (C) 2013-2014 Linaro Limited\n" \
47 | "Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
48 | "Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
49 | "Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
50 | "Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
51 | "Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
52 |
53 | #define JCOPYRIGHT_SHORT \
54 | "Copyright (C) 1991-2021 The libjpeg-turbo Project and many others"
55 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/compare_common.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/basic_types.h"
12 |
13 | #include "libyuv/compare_row.h"
14 |
15 | #ifdef __cplusplus
16 | namespace libyuv {
17 | extern "C" {
18 | #endif
19 |
20 | // Hakmem method for hamming distance.
21 | uint32_t HammingDistance_C(const uint8_t* src_a,
22 | const uint8_t* src_b,
23 | int count) {
24 | uint32_t diff = 0u;
25 |
26 | int i;
27 | for (i = 0; i < count - 3; i += 4) {
28 | uint32_t x = *((const uint32_t*)src_a) ^ *((const uint32_t*)src_b);
29 | uint32_t u = x - ((x >> 1) & 0x55555555);
30 | u = ((u >> 2) & 0x33333333) + (u & 0x33333333);
31 | diff += ((((u + (u >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24);
32 | src_a += 4;
33 | src_b += 4;
34 | }
35 |
36 | for (; i < count; ++i) {
37 | uint32_t x = *src_a ^ *src_b;
38 | uint32_t u = x - ((x >> 1) & 0x55);
39 | u = ((u >> 2) & 0x33) + (u & 0x33);
40 | diff += (u + (u >> 4)) & 0x0f;
41 | src_a += 1;
42 | src_b += 1;
43 | }
44 |
45 | return diff;
46 | }
47 |
48 | uint32_t SumSquareError_C(const uint8_t* src_a,
49 | const uint8_t* src_b,
50 | int count) {
51 | uint32_t sse = 0u;
52 | int i;
53 | for (i = 0; i < count; ++i) {
54 | int diff = src_a[i] - src_b[i];
55 | sse += (uint32_t)(diff * diff);
56 | }
57 | return sse;
58 | }
59 |
60 | // hash seed of 5381 recommended.
61 | // Internal C version of HashDjb2 with int sized count for efficiency.
62 | uint32_t HashDjb2_C(const uint8_t* src, int count, uint32_t seed) {
63 | uint32_t hash = seed;
64 | int i;
65 | for (i = 0; i < count; ++i) {
66 | hash += (hash << 5) + src[i];
67 | }
68 | return hash;
69 | }
70 |
71 | #ifdef __cplusplus
72 | } // extern "C"
73 | } // namespace libyuv
74 | #endif
75 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/compare_mmi.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/basic_types.h"
12 |
13 | #include "libyuv/compare_row.h"
14 |
15 | #ifdef __cplusplus
16 | namespace libyuv {
17 | extern "C" {
18 | #endif
19 |
20 | // This module is for Mips MMI.
21 | #if !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A)
22 |
23 | // Hakmem method for hamming distance.
24 | uint32_t HammingDistance_MMI(const uint8_t* src_a,
25 | const uint8_t* src_b,
26 | int count) {
27 | uint32_t diff = 0u;
28 |
29 | uint64_t temp = 0, temp1 = 0, ta = 0, tb = 0;
30 | uint64_t c1 = 0x5555555555555555;
31 | uint64_t c2 = 0x3333333333333333;
32 | uint64_t c3 = 0x0f0f0f0f0f0f0f0f;
33 | uint32_t c4 = 0x01010101;
34 | uint64_t s1 = 1, s2 = 2, s3 = 4;
35 | __asm__ volatile(
36 | "1: \n\t"
37 | "ldc1 %[ta], 0(%[src_a]) \n\t"
38 | "ldc1 %[tb], 0(%[src_b]) \n\t"
39 | "xor %[temp], %[ta], %[tb] \n\t"
40 | "psrlw %[temp1], %[temp], %[s1] \n\t" // temp1=x>>1
41 | "and %[temp1], %[temp1], %[c1] \n\t" // temp1&=c1
42 | "psubw %[temp1], %[temp], %[temp1] \n\t" // x-temp1
43 | "and %[temp], %[temp1], %[c2] \n\t" // t = (u&c2)
44 | "psrlw %[temp1], %[temp1], %[s2] \n\t" // u>>2
45 | "and %[temp1], %[temp1], %[c2] \n\t" // u>>2 & c2
46 | "paddw %[temp1], %[temp1], %[temp] \n\t" // t1 = t1+t
47 | "psrlw %[temp], %[temp1], %[s3] \n\t" // u>>4
48 | "paddw %[temp1], %[temp1], %[temp] \n\t" // u+(u>>4)
49 | "and %[temp1], %[temp1], %[c3] \n\t" //&c3
50 | "dmfc1 $t0, %[temp1] \n\t"
51 | "dsrl32 $t0, $t0, 0 \n\t "
52 | "mul $t0, $t0, %[c4] \n\t"
53 | "dsrl $t0, $t0, 24 \n\t"
54 | "dadd %[diff], %[diff], $t0 \n\t"
55 | "dmfc1 $t0, %[temp1] \n\t"
56 | "mul $t0, $t0, %[c4] \n\t"
57 | "dsrl $t0, $t0, 24 \n\t"
58 | "dadd %[diff], %[diff], $t0 \n\t"
59 | "daddiu %[src_a], %[src_a], 8 \n\t"
60 | "daddiu %[src_b], %[src_b], 8 \n\t"
61 | "addiu %[count], %[count], -8 \n\t"
62 | "bgtz %[count], 1b \n\t"
63 | "nop \n\t"
64 | : [diff] "+r"(diff), [src_a] "+r"(src_a), [src_b] "+r"(src_b),
65 | [count] "+r"(count), [ta] "+f"(ta), [tb] "+f"(tb), [temp] "+f"(temp),
66 | [temp1] "+f"(temp1)
67 | : [c1] "f"(c1), [c2] "f"(c2), [c3] "f"(c3), [c4] "r"(c4), [s1] "f"(s1),
68 | [s2] "f"(s2), [s3] "f"(s3)
69 | : "memory");
70 | return diff;
71 | }
72 |
73 | uint32_t SumSquareError_MMI(const uint8_t* src_a,
74 | const uint8_t* src_b,
75 | int count) {
76 | uint32_t sse = 0u;
77 | uint32_t sse_hi = 0u, sse_lo = 0u;
78 |
79 | uint64_t src1, src2;
80 | uint64_t diff, diff_hi, diff_lo;
81 | uint64_t sse_sum, sse_tmp;
82 |
83 | const uint64_t mask = 0x0ULL;
84 |
85 | __asm__ volatile(
86 | "xor %[sse_sum], %[sse_sum], %[sse_sum] \n\t"
87 |
88 | "1: \n\t"
89 | "ldc1 %[src1], 0x00(%[src_a]) \n\t"
90 | "ldc1 %[src2], 0x00(%[src_b]) \n\t"
91 | "pasubub %[diff], %[src1], %[src2] \n\t"
92 | "punpcklbh %[diff_lo], %[diff], %[mask] \n\t"
93 | "punpckhbh %[diff_hi], %[diff], %[mask] \n\t"
94 | "pmaddhw %[sse_tmp], %[diff_lo], %[diff_lo] \n\t"
95 | "paddw %[sse_sum], %[sse_sum], %[sse_tmp] \n\t"
96 | "pmaddhw %[sse_tmp], %[diff_hi], %[diff_hi] \n\t"
97 | "paddw %[sse_sum], %[sse_sum], %[sse_tmp] \n\t"
98 |
99 | "daddiu %[src_a], %[src_a], 0x08 \n\t"
100 | "daddiu %[src_b], %[src_b], 0x08 \n\t"
101 | "daddiu %[count], %[count], -0x08 \n\t"
102 | "bnez %[count], 1b \n\t"
103 |
104 | "mfc1 %[sse_lo], %[sse_sum] \n\t"
105 | "mfhc1 %[sse_hi], %[sse_sum] \n\t"
106 | "daddu %[sse], %[sse_hi], %[sse_lo] \n\t"
107 | : [sse] "+&r"(sse), [diff] "=&f"(diff), [src1] "=&f"(src1),
108 | [src2] "=&f"(src2), [diff_lo] "=&f"(diff_lo), [diff_hi] "=&f"(diff_hi),
109 | [sse_sum] "=&f"(sse_sum), [sse_tmp] "=&f"(sse_tmp),
110 | [sse_hi] "+&r"(sse_hi), [sse_lo] "+&r"(sse_lo)
111 | : [src_a] "r"(src_a), [src_b] "r"(src_b), [count] "r"(count),
112 | [mask] "f"(mask)
113 | : "memory");
114 |
115 | return sse;
116 | }
117 |
118 | #endif // !defined(LIBYUV_DISABLE_MMI) && defined(_MIPS_ARCH_LOONGSON3A)
119 |
120 | #ifdef __cplusplus
121 | } // extern "C"
122 | } // namespace libyuv
123 | #endif
124 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/compare_msa.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/basic_types.h"
12 |
13 | #include "libyuv/compare_row.h"
14 | #include "libyuv/row.h"
15 |
16 | // This module is for GCC MSA
17 | #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
18 | #include "libyuv/macros_msa.h"
19 |
20 | #ifdef __cplusplus
21 | namespace libyuv {
22 | extern "C" {
23 | #endif
24 |
25 | uint32_t HammingDistance_MSA(const uint8_t* src_a,
26 | const uint8_t* src_b,
27 | int count) {
28 | uint32_t diff = 0u;
29 | int i;
30 | v16u8 src0, src1, src2, src3;
31 | v2i64 vec0 = {0}, vec1 = {0};
32 |
33 | for (i = 0; i < count; i += 32) {
34 | src0 = (v16u8)__msa_ld_b((v16i8*)src_a, 0);
35 | src1 = (v16u8)__msa_ld_b((v16i8*)src_a, 16);
36 | src2 = (v16u8)__msa_ld_b((v16i8*)src_b, 0);
37 | src3 = (v16u8)__msa_ld_b((v16i8*)src_b, 16);
38 | src0 ^= src2;
39 | src1 ^= src3;
40 | vec0 += __msa_pcnt_d((v2i64)src0);
41 | vec1 += __msa_pcnt_d((v2i64)src1);
42 | src_a += 32;
43 | src_b += 32;
44 | }
45 |
46 | vec0 += vec1;
47 | diff = (uint32_t)__msa_copy_u_w((v4i32)vec0, 0);
48 | diff += (uint32_t)__msa_copy_u_w((v4i32)vec0, 2);
49 | return diff;
50 | }
51 |
52 | uint32_t SumSquareError_MSA(const uint8_t* src_a,
53 | const uint8_t* src_b,
54 | int count) {
55 | uint32_t sse = 0u;
56 | int i;
57 | v16u8 src0, src1, src2, src3;
58 | v8i16 vec0, vec1, vec2, vec3;
59 | v4i32 reg0 = {0}, reg1 = {0}, reg2 = {0}, reg3 = {0};
60 | v2i64 tmp0;
61 |
62 | for (i = 0; i < count; i += 32) {
63 | src0 = (v16u8)__msa_ld_b((v16i8*)src_a, 0);
64 | src1 = (v16u8)__msa_ld_b((v16i8*)src_a, 16);
65 | src2 = (v16u8)__msa_ld_b((v16i8*)src_b, 0);
66 | src3 = (v16u8)__msa_ld_b((v16i8*)src_b, 16);
67 | vec0 = (v8i16)__msa_ilvr_b((v16i8)src2, (v16i8)src0);
68 | vec1 = (v8i16)__msa_ilvl_b((v16i8)src2, (v16i8)src0);
69 | vec2 = (v8i16)__msa_ilvr_b((v16i8)src3, (v16i8)src1);
70 | vec3 = (v8i16)__msa_ilvl_b((v16i8)src3, (v16i8)src1);
71 | vec0 = __msa_hsub_u_h((v16u8)vec0, (v16u8)vec0);
72 | vec1 = __msa_hsub_u_h((v16u8)vec1, (v16u8)vec1);
73 | vec2 = __msa_hsub_u_h((v16u8)vec2, (v16u8)vec2);
74 | vec3 = __msa_hsub_u_h((v16u8)vec3, (v16u8)vec3);
75 | reg0 = __msa_dpadd_s_w(reg0, vec0, vec0);
76 | reg1 = __msa_dpadd_s_w(reg1, vec1, vec1);
77 | reg2 = __msa_dpadd_s_w(reg2, vec2, vec2);
78 | reg3 = __msa_dpadd_s_w(reg3, vec3, vec3);
79 | src_a += 32;
80 | src_b += 32;
81 | }
82 |
83 | reg0 += reg1;
84 | reg2 += reg3;
85 | reg0 += reg2;
86 | tmp0 = __msa_hadd_s_d(reg0, reg0);
87 | sse = (uint32_t)__msa_copy_u_w((v4i32)tmp0, 0);
88 | sse += (uint32_t)__msa_copy_u_w((v4i32)tmp0, 2);
89 | return sse;
90 | }
91 |
92 | #ifdef __cplusplus
93 | } // extern "C"
94 | } // namespace libyuv
95 | #endif
96 |
97 | #endif // !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa)
98 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/compare_neon.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/basic_types.h"
12 |
13 | #include "libyuv/compare_row.h"
14 | #include "libyuv/row.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | #if !defined(LIBYUV_DISABLE_NEON) && defined(__ARM_NEON__) && \
22 | !defined(__aarch64__)
23 |
24 | // 256 bits at a time
25 | // uses short accumulator which restricts count to 131 KB
26 | uint32_t HammingDistance_NEON(const uint8_t* src_a,
27 | const uint8_t* src_b,
28 | int count) {
29 | uint32_t diff;
30 |
31 | asm volatile(
32 | "vmov.u16 q4, #0 \n" // accumulator
33 |
34 | "1: \n"
35 | "vld1.8 {q0, q1}, [%0]! \n"
36 | "vld1.8 {q2, q3}, [%1]! \n"
37 | "veor.32 q0, q0, q2 \n"
38 | "veor.32 q1, q1, q3 \n"
39 | "vcnt.i8 q0, q0 \n"
40 | "vcnt.i8 q1, q1 \n"
41 | "subs %2, %2, #32 \n"
42 | "vadd.u8 q0, q0, q1 \n" // 16 byte counts
43 | "vpadal.u8 q4, q0 \n" // 8 shorts
44 | "bgt 1b \n"
45 |
46 | "vpaddl.u16 q0, q4 \n" // 4 ints
47 | "vpadd.u32 d0, d0, d1 \n"
48 | "vpadd.u32 d0, d0, d0 \n"
49 | "vmov.32 %3, d0[0] \n"
50 |
51 | : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(diff)
52 | :
53 | : "cc", "q0", "q1", "q2", "q3", "q4");
54 | return diff;
55 | }
56 |
57 | uint32_t SumSquareError_NEON(const uint8_t* src_a,
58 | const uint8_t* src_b,
59 | int count) {
60 | uint32_t sse;
61 | asm volatile(
62 | "vmov.u8 q8, #0 \n"
63 | "vmov.u8 q10, #0 \n"
64 | "vmov.u8 q9, #0 \n"
65 | "vmov.u8 q11, #0 \n"
66 |
67 | "1: \n"
68 | "vld1.8 {q0}, [%0]! \n"
69 | "vld1.8 {q1}, [%1]! \n"
70 | "subs %2, %2, #16 \n"
71 | "vsubl.u8 q2, d0, d2 \n"
72 | "vsubl.u8 q3, d1, d3 \n"
73 | "vmlal.s16 q8, d4, d4 \n"
74 | "vmlal.s16 q9, d6, d6 \n"
75 | "vmlal.s16 q10, d5, d5 \n"
76 | "vmlal.s16 q11, d7, d7 \n"
77 | "bgt 1b \n"
78 |
79 | "vadd.u32 q8, q8, q9 \n"
80 | "vadd.u32 q10, q10, q11 \n"
81 | "vadd.u32 q11, q8, q10 \n"
82 | "vpaddl.u32 q1, q11 \n"
83 | "vadd.u64 d0, d2, d3 \n"
84 | "vmov.32 %3, d0[0] \n"
85 | : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse)
86 | :
87 | : "memory", "cc", "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11");
88 | return sse;
89 | }
90 |
91 | #endif // defined(__ARM_NEON__) && !defined(__aarch64__)
92 |
93 | #ifdef __cplusplus
94 | } // extern "C"
95 | } // namespace libyuv
96 | #endif
97 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/compare_neon64.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/basic_types.h"
12 |
13 | #include "libyuv/compare_row.h"
14 | #include "libyuv/row.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | #if !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
22 |
23 | // 256 bits at a time
24 | // uses short accumulator which restricts count to 131 KB
25 | uint32_t HammingDistance_NEON(const uint8_t* src_a,
26 | const uint8_t* src_b,
27 | int count) {
28 | uint32_t diff;
29 | asm volatile(
30 | "movi v4.8h, #0 \n"
31 |
32 | "1: \n"
33 | "ld1 {v0.16b, v1.16b}, [%0], #32 \n"
34 | "ld1 {v2.16b, v3.16b}, [%1], #32 \n"
35 | "eor v0.16b, v0.16b, v2.16b \n"
36 | "prfm pldl1keep, [%0, 448] \n" // prefetch 7 lines ahead
37 | "eor v1.16b, v1.16b, v3.16b \n"
38 | "cnt v0.16b, v0.16b \n"
39 | "prfm pldl1keep, [%1, 448] \n"
40 | "cnt v1.16b, v1.16b \n"
41 | "subs %w2, %w2, #32 \n"
42 | "add v0.16b, v0.16b, v1.16b \n"
43 | "uadalp v4.8h, v0.16b \n"
44 | "b.gt 1b \n"
45 |
46 | "uaddlv s4, v4.8h \n"
47 | "fmov %w3, s4 \n"
48 | : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(diff)
49 | :
50 | : "cc", "v0", "v1", "v2", "v3", "v4");
51 | return diff;
52 | }
53 |
54 | uint32_t SumSquareError_NEON(const uint8_t* src_a,
55 | const uint8_t* src_b,
56 | int count) {
57 | uint32_t sse;
58 | asm volatile(
59 | "eor v16.16b, v16.16b, v16.16b \n"
60 | "eor v18.16b, v18.16b, v18.16b \n"
61 | "eor v17.16b, v17.16b, v17.16b \n"
62 | "eor v19.16b, v19.16b, v19.16b \n"
63 |
64 | "1: \n"
65 | "ld1 {v0.16b}, [%0], #16 \n"
66 | "ld1 {v1.16b}, [%1], #16 \n"
67 | "subs %w2, %w2, #16 \n"
68 | "usubl v2.8h, v0.8b, v1.8b \n"
69 | "usubl2 v3.8h, v0.16b, v1.16b \n"
70 | "prfm pldl1keep, [%0, 448] \n" // prefetch 7 lines ahead
71 | "smlal v16.4s, v2.4h, v2.4h \n"
72 | "smlal v17.4s, v3.4h, v3.4h \n"
73 | "prfm pldl1keep, [%1, 448] \n"
74 | "smlal2 v18.4s, v2.8h, v2.8h \n"
75 | "smlal2 v19.4s, v3.8h, v3.8h \n"
76 | "b.gt 1b \n"
77 |
78 | "add v16.4s, v16.4s, v17.4s \n"
79 | "add v18.4s, v18.4s, v19.4s \n"
80 | "add v19.4s, v16.4s, v18.4s \n"
81 | "addv s0, v19.4s \n"
82 | "fmov %w3, s0 \n"
83 | : "+r"(src_a), "+r"(src_b), "+r"(count), "=r"(sse)
84 | :
85 | : "cc", "v0", "v1", "v2", "v3", "v16", "v17", "v18", "v19");
86 | return sse;
87 | }
88 |
89 | #endif // !defined(LIBYUV_DISABLE_NEON) && defined(__aarch64__)
90 |
91 | #ifdef __cplusplus
92 | } // extern "C"
93 | } // namespace libyuv
94 | #endif
95 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/compare_win.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/basic_types.h"
12 |
13 | #include "libyuv/compare_row.h"
14 | #include "libyuv/row.h"
15 |
16 | #if defined(_MSC_VER)
17 | #include // For __popcnt
18 | #endif
19 |
20 | #ifdef __cplusplus
21 | namespace libyuv {
22 | extern "C" {
23 | #endif
24 |
25 | // This module is for 32 bit Visual C x86
26 | #if !defined(LIBYUV_DISABLE_X86) && defined(_MSC_VER) && \
27 | !defined(__clang__) && defined(_M_IX86)
28 |
29 | uint32_t HammingDistance_SSE42(const uint8_t* src_a,
30 | const uint8_t* src_b,
31 | int count) {
32 | uint32_t diff = 0u;
33 |
34 | int i;
35 | for (i = 0; i < count - 3; i += 4) {
36 | uint32_t x = *((uint32_t*)src_a) ^ *((uint32_t*)src_b); // NOLINT
37 | src_a += 4;
38 | src_b += 4;
39 | diff += __popcnt(x);
40 | }
41 | return diff;
42 | }
43 |
44 | __declspec(naked) uint32_t
45 | SumSquareError_SSE2(const uint8_t* src_a, const uint8_t* src_b, int count) {
46 | __asm {
47 | mov eax, [esp + 4] // src_a
48 | mov edx, [esp + 8] // src_b
49 | mov ecx, [esp + 12] // count
50 | pxor xmm0, xmm0
51 | pxor xmm5, xmm5
52 |
53 | wloop:
54 | movdqu xmm1, [eax]
55 | lea eax, [eax + 16]
56 | movdqu xmm2, [edx]
57 | lea edx, [edx + 16]
58 | movdqa xmm3, xmm1 // abs trick
59 | psubusb xmm1, xmm2
60 | psubusb xmm2, xmm3
61 | por xmm1, xmm2
62 | movdqa xmm2, xmm1
63 | punpcklbw xmm1, xmm5
64 | punpckhbw xmm2, xmm5
65 | pmaddwd xmm1, xmm1
66 | pmaddwd xmm2, xmm2
67 | paddd xmm0, xmm1
68 | paddd xmm0, xmm2
69 | sub ecx, 16
70 | jg wloop
71 |
72 | pshufd xmm1, xmm0, 0xee
73 | paddd xmm0, xmm1
74 | pshufd xmm1, xmm0, 0x01
75 | paddd xmm0, xmm1
76 | movd eax, xmm0
77 | ret
78 | }
79 | }
80 |
81 | #ifdef HAS_SUMSQUAREERROR_AVX2
82 | // C4752: found Intel(R) Advanced Vector Extensions; consider using /arch:AVX.
83 | #pragma warning(disable : 4752)
84 | __declspec(naked) uint32_t
85 | SumSquareError_AVX2(const uint8_t* src_a, const uint8_t* src_b, int count) {
86 | __asm {
87 | mov eax, [esp + 4] // src_a
88 | mov edx, [esp + 8] // src_b
89 | mov ecx, [esp + 12] // count
90 | vpxor ymm0, ymm0, ymm0 // sum
91 | vpxor ymm5, ymm5, ymm5 // constant 0 for unpck
92 | sub edx, eax
93 |
94 | wloop:
95 | vmovdqu ymm1, [eax]
96 | vmovdqu ymm2, [eax + edx]
97 | lea eax, [eax + 32]
98 | vpsubusb ymm3, ymm1, ymm2 // abs difference trick
99 | vpsubusb ymm2, ymm2, ymm1
100 | vpor ymm1, ymm2, ymm3
101 | vpunpcklbw ymm2, ymm1, ymm5 // u16. mutates order.
102 | vpunpckhbw ymm1, ymm1, ymm5
103 | vpmaddwd ymm2, ymm2, ymm2 // square + hadd to u32.
104 | vpmaddwd ymm1, ymm1, ymm1
105 | vpaddd ymm0, ymm0, ymm1
106 | vpaddd ymm0, ymm0, ymm2
107 | sub ecx, 32
108 | jg wloop
109 |
110 | vpshufd ymm1, ymm0, 0xee // 3, 2 + 1, 0 both lanes.
111 | vpaddd ymm0, ymm0, ymm1
112 | vpshufd ymm1, ymm0, 0x01 // 1 + 0 both lanes.
113 | vpaddd ymm0, ymm0, ymm1
114 | vpermq ymm1, ymm0, 0x02 // high + low lane.
115 | vpaddd ymm0, ymm0, ymm1
116 | vmovd eax, xmm0
117 | vzeroupper
118 | ret
119 | }
120 | }
121 | #endif // HAS_SUMSQUAREERROR_AVX2
122 |
123 | uvec32 kHash16x33 = {0x92d9e201, 0, 0, 0}; // 33 ^ 16
124 | uvec32 kHashMul0 = {
125 | 0x0c3525e1, // 33 ^ 15
126 | 0xa3476dc1, // 33 ^ 14
127 | 0x3b4039a1, // 33 ^ 13
128 | 0x4f5f0981, // 33 ^ 12
129 | };
130 | uvec32 kHashMul1 = {
131 | 0x30f35d61, // 33 ^ 11
132 | 0x855cb541, // 33 ^ 10
133 | 0x040a9121, // 33 ^ 9
134 | 0x747c7101, // 33 ^ 8
135 | };
136 | uvec32 kHashMul2 = {
137 | 0xec41d4e1, // 33 ^ 7
138 | 0x4cfa3cc1, // 33 ^ 6
139 | 0x025528a1, // 33 ^ 5
140 | 0x00121881, // 33 ^ 4
141 | };
142 | uvec32 kHashMul3 = {
143 | 0x00008c61, // 33 ^ 3
144 | 0x00000441, // 33 ^ 2
145 | 0x00000021, // 33 ^ 1
146 | 0x00000001, // 33 ^ 0
147 | };
148 |
149 | __declspec(naked) uint32_t
150 | HashDjb2_SSE41(const uint8_t* src, int count, uint32_t seed) {
151 | __asm {
152 | mov eax, [esp + 4] // src
153 | mov ecx, [esp + 8] // count
154 | movd xmm0, [esp + 12] // seed
155 |
156 | pxor xmm7, xmm7 // constant 0 for unpck
157 | movdqa xmm6, xmmword ptr kHash16x33
158 |
159 | wloop:
160 | movdqu xmm1, [eax] // src[0-15]
161 | lea eax, [eax + 16]
162 | pmulld xmm0, xmm6 // hash *= 33 ^ 16
163 | movdqa xmm5, xmmword ptr kHashMul0
164 | movdqa xmm2, xmm1
165 | punpcklbw xmm2, xmm7 // src[0-7]
166 | movdqa xmm3, xmm2
167 | punpcklwd xmm3, xmm7 // src[0-3]
168 | pmulld xmm3, xmm5
169 | movdqa xmm5, xmmword ptr kHashMul1
170 | movdqa xmm4, xmm2
171 | punpckhwd xmm4, xmm7 // src[4-7]
172 | pmulld xmm4, xmm5
173 | movdqa xmm5, xmmword ptr kHashMul2
174 | punpckhbw xmm1, xmm7 // src[8-15]
175 | movdqa xmm2, xmm1
176 | punpcklwd xmm2, xmm7 // src[8-11]
177 | pmulld xmm2, xmm5
178 | movdqa xmm5, xmmword ptr kHashMul3
179 | punpckhwd xmm1, xmm7 // src[12-15]
180 | pmulld xmm1, xmm5
181 | paddd xmm3, xmm4 // add 16 results
182 | paddd xmm1, xmm2
183 | paddd xmm1, xmm3
184 |
185 | pshufd xmm2, xmm1, 0x0e // upper 2 dwords
186 | paddd xmm1, xmm2
187 | pshufd xmm2, xmm1, 0x01
188 | paddd xmm1, xmm2
189 | paddd xmm0, xmm1
190 | sub ecx, 16
191 | jg wloop
192 |
193 | movd eax, xmm0 // return hash
194 | ret
195 | }
196 | }
197 |
198 | // Visual C 2012 required for AVX2.
199 | #ifdef HAS_HASHDJB2_AVX2
200 | __declspec(naked) uint32_t
201 | HashDjb2_AVX2(const uint8_t* src, int count, uint32_t seed) {
202 | __asm {
203 | mov eax, [esp + 4] // src
204 | mov ecx, [esp + 8] // count
205 | vmovd xmm0, [esp + 12] // seed
206 |
207 | wloop:
208 | vpmovzxbd xmm3, [eax] // src[0-3]
209 | vpmulld xmm0, xmm0, xmmword ptr kHash16x33 // hash *= 33 ^ 16
210 | vpmovzxbd xmm4, [eax + 4] // src[4-7]
211 | vpmulld xmm3, xmm3, xmmword ptr kHashMul0
212 | vpmovzxbd xmm2, [eax + 8] // src[8-11]
213 | vpmulld xmm4, xmm4, xmmword ptr kHashMul1
214 | vpmovzxbd xmm1, [eax + 12] // src[12-15]
215 | vpmulld xmm2, xmm2, xmmword ptr kHashMul2
216 | lea eax, [eax + 16]
217 | vpmulld xmm1, xmm1, xmmword ptr kHashMul3
218 | vpaddd xmm3, xmm3, xmm4 // add 16 results
219 | vpaddd xmm1, xmm1, xmm2
220 | vpaddd xmm1, xmm1, xmm3
221 | vpshufd xmm2, xmm1, 0x0e // upper 2 dwords
222 | vpaddd xmm1, xmm1,xmm2
223 | vpshufd xmm2, xmm1, 0x01
224 | vpaddd xmm1, xmm1, xmm2
225 | vpaddd xmm0, xmm0, xmm1
226 | sub ecx, 16
227 | jg wloop
228 |
229 | vmovd eax, xmm0 // return hash
230 | vzeroupper
231 | ret
232 | }
233 | }
234 | #endif // HAS_HASHDJB2_AVX2
235 |
236 | #endif // !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86)
237 |
238 | #ifdef __cplusplus
239 | } // extern "C"
240 | } // namespace libyuv
241 | #endif
242 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/mjpeg_validate.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/mjpeg_decoder.h"
12 |
13 | #include // For memchr.
14 |
15 | #ifdef __cplusplus
16 | namespace libyuv {
17 | extern "C" {
18 | #endif
19 |
20 | // Helper function to scan for EOI marker (0xff 0xd9).
21 | static LIBYUV_BOOL ScanEOI(const uint8_t* src_mjpg, size_t src_size_mjpg) {
22 | if (src_size_mjpg >= 2) {
23 | const uint8_t* end = src_mjpg + src_size_mjpg - 1;
24 | const uint8_t* it = src_mjpg;
25 | while (it < end) {
26 | // TODO(fbarchard): scan for 0xd9 instead.
27 | it = (const uint8_t*)(memchr(it, 0xff, end - it));
28 | if (it == NULL) {
29 | break;
30 | }
31 | if (it[1] == 0xd9) {
32 | return LIBYUV_TRUE; // Success: Valid jpeg.
33 | }
34 | ++it; // Skip over current 0xff.
35 | }
36 | }
37 | // ERROR: Invalid jpeg end code not found. Size src_size_mjpg
38 | return LIBYUV_FALSE;
39 | }
40 |
41 | // Helper function to validate the jpeg appears intact.
42 | LIBYUV_BOOL ValidateJpeg(const uint8_t* src_mjpg, size_t src_size_mjpg) {
43 | // Maximum size that ValidateJpeg will consider valid.
44 | const size_t kMaxJpegSize = 0x7fffffffull;
45 | const size_t kBackSearchSize = 1024;
46 | if (src_size_mjpg < 64 || src_size_mjpg > kMaxJpegSize || !src_mjpg) {
47 | // ERROR: Invalid jpeg size: src_size_mjpg
48 | return LIBYUV_FALSE;
49 | }
50 | // SOI marker
51 | if (src_mjpg[0] != 0xff || src_mjpg[1] != 0xd8 || src_mjpg[2] != 0xff) {
52 | // ERROR: Invalid jpeg initial start code
53 | return LIBYUV_FALSE;
54 | }
55 |
56 | // Look for the End Of Image (EOI) marker near the end of the buffer.
57 | if (src_size_mjpg > kBackSearchSize) {
58 | if (ScanEOI(src_mjpg + src_size_mjpg - kBackSearchSize, kBackSearchSize)) {
59 | return LIBYUV_TRUE; // Success: Valid jpeg.
60 | }
61 | // Reduce search size for forward search.
62 | src_size_mjpg = src_size_mjpg - kBackSearchSize + 1;
63 | }
64 | // Step over SOI marker and scan for EOI.
65 | return ScanEOI(src_mjpg + 2, src_size_mjpg - 2);
66 | }
67 |
68 | #ifdef __cplusplus
69 | } // extern "C"
70 | } // namespace libyuv
71 | #endif
72 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/rotate_any.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/rotate.h"
12 | #include "libyuv/rotate_row.h"
13 |
14 | #include "libyuv/basic_types.h"
15 |
16 | #ifdef __cplusplus
17 | namespace libyuv {
18 | extern "C" {
19 | #endif
20 |
21 | #define TANY(NAMEANY, TPOS_SIMD, MASK) \
22 | void NAMEANY(const uint8_t* src, int src_stride, uint8_t* dst, \
23 | int dst_stride, int width) { \
24 | int r = width & MASK; \
25 | int n = width - r; \
26 | if (n > 0) { \
27 | TPOS_SIMD(src, src_stride, dst, dst_stride, n); \
28 | } \
29 | TransposeWx8_C(src + n, src_stride, dst + n * dst_stride, dst_stride, r); \
30 | }
31 |
32 | #ifdef HAS_TRANSPOSEWX8_NEON
33 | TANY(TransposeWx8_Any_NEON, TransposeWx8_NEON, 7)
34 | #endif
35 | #ifdef HAS_TRANSPOSEWX8_SSSE3
36 | TANY(TransposeWx8_Any_SSSE3, TransposeWx8_SSSE3, 7)
37 | #endif
38 | #ifdef HAS_TRANSPOSEWX8_MMI
39 | TANY(TransposeWx8_Any_MMI, TransposeWx8_MMI, 7)
40 | #endif
41 | #ifdef HAS_TRANSPOSEWX8_FAST_SSSE3
42 | TANY(TransposeWx8_Fast_Any_SSSE3, TransposeWx8_Fast_SSSE3, 15)
43 | #endif
44 | #ifdef HAS_TRANSPOSEWX16_MSA
45 | TANY(TransposeWx16_Any_MSA, TransposeWx16_MSA, 15)
46 | #endif
47 | #undef TANY
48 |
49 | #define TUVANY(NAMEANY, TPOS_SIMD, MASK) \
50 | void NAMEANY(const uint8_t* src, int src_stride, uint8_t* dst_a, \
51 | int dst_stride_a, uint8_t* dst_b, int dst_stride_b, \
52 | int width) { \
53 | int r = width & MASK; \
54 | int n = width - r; \
55 | if (n > 0) { \
56 | TPOS_SIMD(src, src_stride, dst_a, dst_stride_a, dst_b, dst_stride_b, n); \
57 | } \
58 | TransposeUVWx8_C(src + n * 2, src_stride, dst_a + n * dst_stride_a, \
59 | dst_stride_a, dst_b + n * dst_stride_b, dst_stride_b, r); \
60 | }
61 |
62 | #ifdef HAS_TRANSPOSEUVWX8_NEON
63 | TUVANY(TransposeUVWx8_Any_NEON, TransposeUVWx8_NEON, 7)
64 | #endif
65 | #ifdef HAS_TRANSPOSEUVWX8_SSE2
66 | TUVANY(TransposeUVWx8_Any_SSE2, TransposeUVWx8_SSE2, 7)
67 | #endif
68 | #ifdef HAS_TRANSPOSEUVWX8_MMI
69 | TUVANY(TransposeUVWx8_Any_MMI, TransposeUVWx8_MMI, 7)
70 | #endif
71 | #ifdef HAS_TRANSPOSEUVWX16_MSA
72 | TUVANY(TransposeUVWx16_Any_MSA, TransposeUVWx16_MSA, 7)
73 | #endif
74 | #undef TUVANY
75 |
76 | #ifdef __cplusplus
77 | } // extern "C"
78 | } // namespace libyuv
79 | #endif
80 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/rotate_argb.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/rotate.h"
12 |
13 | #include "libyuv/convert.h"
14 | #include "libyuv/cpu_id.h"
15 | #include "libyuv/planar_functions.h"
16 | #include "libyuv/row.h"
17 | #include "libyuv/scale_row.h" /* for ScaleARGBRowDownEven_ */
18 |
19 | #ifdef __cplusplus
20 | namespace libyuv {
21 | extern "C" {
22 | #endif
23 |
24 | static int ARGBTranspose(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 | int i;
31 | int src_pixel_step = src_stride_argb >> 2;
32 | void (*ScaleARGBRowDownEven)(
33 | const uint8_t* src_argb, ptrdiff_t src_stride_argb, int src_step,
34 | uint8_t* dst_argb, int dst_width) = ScaleARGBRowDownEven_C;
35 | // Check stride is a multiple of 4.
36 | if (src_stride_argb & 3) {
37 | return -1;
38 | }
39 | #if defined(HAS_SCALEARGBROWDOWNEVEN_SSE2)
40 | if (TestCpuFlag(kCpuHasSSE2)) {
41 | ScaleARGBRowDownEven = ScaleARGBRowDownEven_Any_SSE2;
42 | if (IS_ALIGNED(height, 4)) { // Width of dest.
43 | ScaleARGBRowDownEven = ScaleARGBRowDownEven_SSE2;
44 | }
45 | }
46 | #endif
47 | #if defined(HAS_SCALEARGBROWDOWNEVEN_NEON)
48 | if (TestCpuFlag(kCpuHasNEON)) {
49 | ScaleARGBRowDownEven = ScaleARGBRowDownEven_Any_NEON;
50 | if (IS_ALIGNED(height, 4)) { // Width of dest.
51 | ScaleARGBRowDownEven = ScaleARGBRowDownEven_NEON;
52 | }
53 | }
54 | #endif
55 | #if defined(HAS_SCALEARGBROWDOWNEVEN_MMI)
56 | if (TestCpuFlag(kCpuHasMMI)) {
57 | ScaleARGBRowDownEven = ScaleARGBRowDownEven_Any_MMI;
58 | if (IS_ALIGNED(height, 4)) { // Width of dest.
59 | ScaleARGBRowDownEven = ScaleARGBRowDownEven_MMI;
60 | }
61 | }
62 | #endif
63 | #if defined(HAS_SCALEARGBROWDOWNEVEN_MSA)
64 | if (TestCpuFlag(kCpuHasMSA)) {
65 | ScaleARGBRowDownEven = ScaleARGBRowDownEven_Any_MSA;
66 | if (IS_ALIGNED(height, 4)) { // Width of dest.
67 | ScaleARGBRowDownEven = ScaleARGBRowDownEven_MSA;
68 | }
69 | }
70 | #endif
71 |
72 | for (i = 0; i < width; ++i) { // column of source to row of dest.
73 | ScaleARGBRowDownEven(src_argb, 0, src_pixel_step, dst_argb, height);
74 | dst_argb += dst_stride_argb;
75 | src_argb += 4;
76 | }
77 | return 0;
78 | }
79 |
80 | static int ARGBRotate90(const uint8_t* src_argb,
81 | int src_stride_argb,
82 | uint8_t* dst_argb,
83 | int dst_stride_argb,
84 | int width,
85 | int height) {
86 | // Rotate by 90 is a ARGBTranspose with the source read
87 | // from bottom to top. So set the source pointer to the end
88 | // of the buffer and flip the sign of the source stride.
89 | src_argb += src_stride_argb * (height - 1);
90 | src_stride_argb = -src_stride_argb;
91 | return ARGBTranspose(src_argb, src_stride_argb, dst_argb, dst_stride_argb,
92 | width, height);
93 | }
94 |
95 | static int ARGBRotate270(const uint8_t* src_argb,
96 | int src_stride_argb,
97 | uint8_t* dst_argb,
98 | int dst_stride_argb,
99 | int width,
100 | int height) {
101 | // Rotate by 270 is a ARGBTranspose with the destination written
102 | // from bottom to top. So set the destination pointer to the end
103 | // of the buffer and flip the sign of the destination stride.
104 | dst_argb += dst_stride_argb * (width - 1);
105 | dst_stride_argb = -dst_stride_argb;
106 | return ARGBTranspose(src_argb, src_stride_argb, dst_argb, dst_stride_argb,
107 | width, height);
108 | }
109 |
110 | static int ARGBRotate180(const uint8_t* src_argb,
111 | int src_stride_argb,
112 | uint8_t* dst_argb,
113 | int dst_stride_argb,
114 | int width,
115 | int height) {
116 | // Swap first and last row and mirror the content. Uses a temporary row.
117 | align_buffer_64(row, width * 4);
118 | const uint8_t* src_bot = src_argb + src_stride_argb * (height - 1);
119 | uint8_t* dst_bot = dst_argb + dst_stride_argb * (height - 1);
120 | int half_height = (height + 1) >> 1;
121 | int y;
122 | void (*ARGBMirrorRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width) =
123 | ARGBMirrorRow_C;
124 | void (*CopyRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width) =
125 | CopyRow_C;
126 | #if defined(HAS_ARGBMIRRORROW_NEON)
127 | if (TestCpuFlag(kCpuHasNEON)) {
128 | ARGBMirrorRow = ARGBMirrorRow_Any_NEON;
129 | if (IS_ALIGNED(width, 8)) {
130 | ARGBMirrorRow = ARGBMirrorRow_NEON;
131 | }
132 | }
133 | #endif
134 | #if defined(HAS_ARGBMIRRORROW_SSE2)
135 | if (TestCpuFlag(kCpuHasSSE2)) {
136 | ARGBMirrorRow = ARGBMirrorRow_Any_SSE2;
137 | if (IS_ALIGNED(width, 4)) {
138 | ARGBMirrorRow = ARGBMirrorRow_SSE2;
139 | }
140 | }
141 | #endif
142 | #if defined(HAS_ARGBMIRRORROW_AVX2)
143 | if (TestCpuFlag(kCpuHasAVX2)) {
144 | ARGBMirrorRow = ARGBMirrorRow_Any_AVX2;
145 | if (IS_ALIGNED(width, 8)) {
146 | ARGBMirrorRow = ARGBMirrorRow_AVX2;
147 | }
148 | }
149 | #endif
150 | #if defined(HAS_ARGBMIRRORROW_MMI)
151 | if (TestCpuFlag(kCpuHasMMI)) {
152 | ARGBMirrorRow = ARGBMirrorRow_Any_MMI;
153 | if (IS_ALIGNED(width, 2)) {
154 | ARGBMirrorRow = ARGBMirrorRow_MMI;
155 | }
156 | }
157 | #endif
158 | #if defined(HAS_ARGBMIRRORROW_MSA)
159 | if (TestCpuFlag(kCpuHasMSA)) {
160 | ARGBMirrorRow = ARGBMirrorRow_Any_MSA;
161 | if (IS_ALIGNED(width, 16)) {
162 | ARGBMirrorRow = ARGBMirrorRow_MSA;
163 | }
164 | }
165 | #endif
166 | #if defined(HAS_COPYROW_SSE2)
167 | if (TestCpuFlag(kCpuHasSSE2)) {
168 | CopyRow = IS_ALIGNED(width * 4, 32) ? CopyRow_SSE2 : CopyRow_Any_SSE2;
169 | }
170 | #endif
171 | #if defined(HAS_COPYROW_AVX)
172 | if (TestCpuFlag(kCpuHasAVX)) {
173 | CopyRow = IS_ALIGNED(width * 4, 64) ? CopyRow_AVX : CopyRow_Any_AVX;
174 | }
175 | #endif
176 | #if defined(HAS_COPYROW_ERMS)
177 | if (TestCpuFlag(kCpuHasERMS)) {
178 | CopyRow = CopyRow_ERMS;
179 | }
180 | #endif
181 | #if defined(HAS_COPYROW_NEON)
182 | if (TestCpuFlag(kCpuHasNEON)) {
183 | CopyRow = IS_ALIGNED(width * 4, 32) ? CopyRow_NEON : CopyRow_Any_NEON;
184 | }
185 | #endif
186 |
187 | // Odd height will harmlessly mirror the middle row twice.
188 | for (y = 0; y < half_height; ++y) {
189 | ARGBMirrorRow(src_argb, row, width); // Mirror first row into a buffer
190 | ARGBMirrorRow(src_bot, dst_argb, width); // Mirror last row into first row
191 | CopyRow(row, dst_bot, width * 4); // Copy first mirrored row into last
192 | src_argb += src_stride_argb;
193 | dst_argb += dst_stride_argb;
194 | src_bot -= src_stride_argb;
195 | dst_bot -= dst_stride_argb;
196 | }
197 | free_aligned_buffer_64(row);
198 | return 0;
199 | }
200 |
201 | LIBYUV_API
202 | int ARGBRotate(const uint8_t* src_argb,
203 | int src_stride_argb,
204 | uint8_t* dst_argb,
205 | int dst_stride_argb,
206 | int width,
207 | int height,
208 | enum RotationMode mode) {
209 | if (!src_argb || width <= 0 || height == 0 || !dst_argb) {
210 | return -1;
211 | }
212 |
213 | // Negative height means invert the image.
214 | if (height < 0) {
215 | height = -height;
216 | src_argb = src_argb + (height - 1) * src_stride_argb;
217 | src_stride_argb = -src_stride_argb;
218 | }
219 |
220 | switch (mode) {
221 | case kRotate0:
222 | // copy frame
223 | return ARGBCopy(src_argb, src_stride_argb, dst_argb, dst_stride_argb,
224 | width, height);
225 | case kRotate90:
226 | return ARGBRotate90(src_argb, src_stride_argb, dst_argb, dst_stride_argb,
227 | width, height);
228 | case kRotate270:
229 | return ARGBRotate270(src_argb, src_stride_argb, dst_argb, dst_stride_argb,
230 | width, height);
231 | case kRotate180:
232 | return ARGBRotate180(src_argb, src_stride_argb, dst_argb, dst_stride_argb,
233 | width, height);
234 | default:
235 | break;
236 | }
237 | return -1;
238 | }
239 |
240 | #ifdef __cplusplus
241 | } // extern "C"
242 | } // namespace libyuv
243 | #endif
244 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/rotate_common.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/rotate_row.h"
12 | #include "libyuv/row.h"
13 |
14 | #ifdef __cplusplus
15 | namespace libyuv {
16 | extern "C" {
17 | #endif
18 |
19 | void TransposeWx8_C(const uint8_t* src,
20 | int src_stride,
21 | uint8_t* dst,
22 | int dst_stride,
23 | int width) {
24 | int i;
25 | for (i = 0; i < width; ++i) {
26 | dst[0] = src[0 * src_stride];
27 | dst[1] = src[1 * src_stride];
28 | dst[2] = src[2 * src_stride];
29 | dst[3] = src[3 * src_stride];
30 | dst[4] = src[4 * src_stride];
31 | dst[5] = src[5 * src_stride];
32 | dst[6] = src[6 * src_stride];
33 | dst[7] = src[7 * src_stride];
34 | ++src;
35 | dst += dst_stride;
36 | }
37 | }
38 |
39 | void TransposeUVWx8_C(const uint8_t* src,
40 | int src_stride,
41 | uint8_t* dst_a,
42 | int dst_stride_a,
43 | uint8_t* dst_b,
44 | int dst_stride_b,
45 | int width) {
46 | int i;
47 | for (i = 0; i < width; ++i) {
48 | dst_a[0] = src[0 * src_stride + 0];
49 | dst_b[0] = src[0 * src_stride + 1];
50 | dst_a[1] = src[1 * src_stride + 0];
51 | dst_b[1] = src[1 * src_stride + 1];
52 | dst_a[2] = src[2 * src_stride + 0];
53 | dst_b[2] = src[2 * src_stride + 1];
54 | dst_a[3] = src[3 * src_stride + 0];
55 | dst_b[3] = src[3 * src_stride + 1];
56 | dst_a[4] = src[4 * src_stride + 0];
57 | dst_b[4] = src[4 * src_stride + 1];
58 | dst_a[5] = src[5 * src_stride + 0];
59 | dst_b[5] = src[5 * src_stride + 1];
60 | dst_a[6] = src[6 * src_stride + 0];
61 | dst_b[6] = src[6 * src_stride + 1];
62 | dst_a[7] = src[7 * src_stride + 0];
63 | dst_b[7] = src[7 * src_stride + 1];
64 | src += 2;
65 | dst_a += dst_stride_a;
66 | dst_b += dst_stride_b;
67 | }
68 | }
69 |
70 | void TransposeWxH_C(const uint8_t* src,
71 | int src_stride,
72 | uint8_t* dst,
73 | int dst_stride,
74 | int width,
75 | int height) {
76 | int i;
77 | for (i = 0; i < width; ++i) {
78 | int j;
79 | for (j = 0; j < height; ++j) {
80 | dst[i * dst_stride + j] = src[j * src_stride + i];
81 | }
82 | }
83 | }
84 |
85 | void TransposeUVWxH_C(const uint8_t* src,
86 | int src_stride,
87 | uint8_t* dst_a,
88 | int dst_stride_a,
89 | uint8_t* dst_b,
90 | int dst_stride_b,
91 | int width,
92 | int height) {
93 | int i;
94 | for (i = 0; i < width * 2; i += 2) {
95 | int j;
96 | for (j = 0; j < height; ++j) {
97 | dst_a[j + ((i >> 1) * dst_stride_a)] = src[i + (j * src_stride)];
98 | dst_b[j + ((i >> 1) * dst_stride_b)] = src[i + (j * src_stride) + 1];
99 | }
100 | }
101 | }
102 |
103 | #ifdef __cplusplus
104 | } // extern "C"
105 | } // namespace libyuv
106 | #endif
107 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/rotate_win.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/rotate_row.h"
12 | #include "libyuv/row.h"
13 |
14 | #ifdef __cplusplus
15 | namespace libyuv {
16 | extern "C" {
17 | #endif
18 |
19 | // This module is for 32 bit Visual C x86
20 | #if !defined(LIBYUV_DISABLE_X86) && defined(_MSC_VER) && \
21 | !defined(__clang__) && defined(_M_IX86)
22 |
23 | __declspec(naked) void TransposeWx8_SSSE3(const uint8_t* src,
24 | int src_stride,
25 | uint8_t* dst,
26 | int dst_stride,
27 | int width) {
28 | __asm {
29 | push edi
30 | push esi
31 | push ebp
32 | mov eax, [esp + 12 + 4] // src
33 | mov edi, [esp + 12 + 8] // src_stride
34 | mov edx, [esp + 12 + 12] // dst
35 | mov esi, [esp + 12 + 16] // dst_stride
36 | mov ecx, [esp + 12 + 20] // width
37 |
38 | // Read in the data from the source pointer.
39 | // First round of bit swap.
40 | align 4
41 | convertloop:
42 | movq xmm0, qword ptr [eax]
43 | lea ebp, [eax + 8]
44 | movq xmm1, qword ptr [eax + edi]
45 | lea eax, [eax + 2 * edi]
46 | punpcklbw xmm0, xmm1
47 | movq xmm2, qword ptr [eax]
48 | movdqa xmm1, xmm0
49 | palignr xmm1, xmm1, 8
50 | movq xmm3, qword ptr [eax + edi]
51 | lea eax, [eax + 2 * edi]
52 | punpcklbw xmm2, xmm3
53 | movdqa xmm3, xmm2
54 | movq xmm4, qword ptr [eax]
55 | palignr xmm3, xmm3, 8
56 | movq xmm5, qword ptr [eax + edi]
57 | punpcklbw xmm4, xmm5
58 | lea eax, [eax + 2 * edi]
59 | movdqa xmm5, xmm4
60 | movq xmm6, qword ptr [eax]
61 | palignr xmm5, xmm5, 8
62 | movq xmm7, qword ptr [eax + edi]
63 | punpcklbw xmm6, xmm7
64 | mov eax, ebp
65 | movdqa xmm7, xmm6
66 | palignr xmm7, xmm7, 8
67 | // Second round of bit swap.
68 | punpcklwd xmm0, xmm2
69 | punpcklwd xmm1, xmm3
70 | movdqa xmm2, xmm0
71 | movdqa xmm3, xmm1
72 | palignr xmm2, xmm2, 8
73 | palignr xmm3, xmm3, 8
74 | punpcklwd xmm4, xmm6
75 | punpcklwd xmm5, xmm7
76 | movdqa xmm6, xmm4
77 | movdqa xmm7, xmm5
78 | palignr xmm6, xmm6, 8
79 | palignr xmm7, xmm7, 8
80 | // Third round of bit swap.
81 | // Write to the destination pointer.
82 | punpckldq xmm0, xmm4
83 | movq qword ptr [edx], xmm0
84 | movdqa xmm4, xmm0
85 | palignr xmm4, xmm4, 8
86 | movq qword ptr [edx + esi], xmm4
87 | lea edx, [edx + 2 * esi]
88 | punpckldq xmm2, xmm6
89 | movdqa xmm6, xmm2
90 | palignr xmm6, xmm6, 8
91 | movq qword ptr [edx], xmm2
92 | punpckldq xmm1, xmm5
93 | movq qword ptr [edx + esi], xmm6
94 | lea edx, [edx + 2 * esi]
95 | movdqa xmm5, xmm1
96 | movq qword ptr [edx], xmm1
97 | palignr xmm5, xmm5, 8
98 | punpckldq xmm3, xmm7
99 | movq qword ptr [edx + esi], xmm5
100 | lea edx, [edx + 2 * esi]
101 | movq qword ptr [edx], xmm3
102 | movdqa xmm7, xmm3
103 | palignr xmm7, xmm7, 8
104 | sub ecx, 8
105 | movq qword ptr [edx + esi], xmm7
106 | lea edx, [edx + 2 * esi]
107 | jg convertloop
108 |
109 | pop ebp
110 | pop esi
111 | pop edi
112 | ret
113 | }
114 | }
115 |
116 | __declspec(naked) void TransposeUVWx8_SSE2(const uint8_t* src,
117 | int src_stride,
118 | uint8_t* dst_a,
119 | int dst_stride_a,
120 | uint8_t* dst_b,
121 | int dst_stride_b,
122 | int w) {
123 | __asm {
124 | push ebx
125 | push esi
126 | push edi
127 | push ebp
128 | mov eax, [esp + 16 + 4] // src
129 | mov edi, [esp + 16 + 8] // src_stride
130 | mov edx, [esp + 16 + 12] // dst_a
131 | mov esi, [esp + 16 + 16] // dst_stride_a
132 | mov ebx, [esp + 16 + 20] // dst_b
133 | mov ebp, [esp + 16 + 24] // dst_stride_b
134 | mov ecx, esp
135 | sub esp, 4 + 16
136 | and esp, ~15
137 | mov [esp + 16], ecx
138 | mov ecx, [ecx + 16 + 28] // w
139 |
140 | align 4
141 | // Read in the data from the source pointer.
142 | // First round of bit swap.
143 | convertloop:
144 | movdqu xmm0, [eax]
145 | movdqu xmm1, [eax + edi]
146 | lea eax, [eax + 2 * edi]
147 | movdqa xmm7, xmm0 // use xmm7 as temp register.
148 | punpcklbw xmm0, xmm1
149 | punpckhbw xmm7, xmm1
150 | movdqa xmm1, xmm7
151 | movdqu xmm2, [eax]
152 | movdqu xmm3, [eax + edi]
153 | lea eax, [eax + 2 * edi]
154 | movdqa xmm7, xmm2
155 | punpcklbw xmm2, xmm3
156 | punpckhbw xmm7, xmm3
157 | movdqa xmm3, xmm7
158 | movdqu xmm4, [eax]
159 | movdqu xmm5, [eax + edi]
160 | lea eax, [eax + 2 * edi]
161 | movdqa xmm7, xmm4
162 | punpcklbw xmm4, xmm5
163 | punpckhbw xmm7, xmm5
164 | movdqa xmm5, xmm7
165 | movdqu xmm6, [eax]
166 | movdqu xmm7, [eax + edi]
167 | lea eax, [eax + 2 * edi]
168 | movdqu [esp], xmm5 // backup xmm5
169 | neg edi
170 | movdqa xmm5, xmm6 // use xmm5 as temp register.
171 | punpcklbw xmm6, xmm7
172 | punpckhbw xmm5, xmm7
173 | movdqa xmm7, xmm5
174 | lea eax, [eax + 8 * edi + 16]
175 | neg edi
176 | // Second round of bit swap.
177 | movdqa xmm5, xmm0
178 | punpcklwd xmm0, xmm2
179 | punpckhwd xmm5, xmm2
180 | movdqa xmm2, xmm5
181 | movdqa xmm5, xmm1
182 | punpcklwd xmm1, xmm3
183 | punpckhwd xmm5, xmm3
184 | movdqa xmm3, xmm5
185 | movdqa xmm5, xmm4
186 | punpcklwd xmm4, xmm6
187 | punpckhwd xmm5, xmm6
188 | movdqa xmm6, xmm5
189 | movdqu xmm5, [esp] // restore xmm5
190 | movdqu [esp], xmm6 // backup xmm6
191 | movdqa xmm6, xmm5 // use xmm6 as temp register.
192 | punpcklwd xmm5, xmm7
193 | punpckhwd xmm6, xmm7
194 | movdqa xmm7, xmm6
195 |
196 | // Third round of bit swap.
197 | // Write to the destination pointer.
198 | movdqa xmm6, xmm0
199 | punpckldq xmm0, xmm4
200 | punpckhdq xmm6, xmm4
201 | movdqa xmm4, xmm6
202 | movdqu xmm6, [esp] // restore xmm6
203 | movlpd qword ptr [edx], xmm0
204 | movhpd qword ptr [ebx], xmm0
205 | movlpd qword ptr [edx + esi], xmm4
206 | lea edx, [edx + 2 * esi]
207 | movhpd qword ptr [ebx + ebp], xmm4
208 | lea ebx, [ebx + 2 * ebp]
209 | movdqa xmm0, xmm2 // use xmm0 as the temp register.
210 | punpckldq xmm2, xmm6
211 | movlpd qword ptr [edx], xmm2
212 | movhpd qword ptr [ebx], xmm2
213 | punpckhdq xmm0, xmm6
214 | movlpd qword ptr [edx + esi], xmm0
215 | lea edx, [edx + 2 * esi]
216 | movhpd qword ptr [ebx + ebp], xmm0
217 | lea ebx, [ebx + 2 * ebp]
218 | movdqa xmm0, xmm1 // use xmm0 as the temp register.
219 | punpckldq xmm1, xmm5
220 | movlpd qword ptr [edx], xmm1
221 | movhpd qword ptr [ebx], xmm1
222 | punpckhdq xmm0, xmm5
223 | movlpd qword ptr [edx + esi], xmm0
224 | lea edx, [edx + 2 * esi]
225 | movhpd qword ptr [ebx + ebp], xmm0
226 | lea ebx, [ebx + 2 * ebp]
227 | movdqa xmm0, xmm3 // use xmm0 as the temp register.
228 | punpckldq xmm3, xmm7
229 | movlpd qword ptr [edx], xmm3
230 | movhpd qword ptr [ebx], xmm3
231 | punpckhdq xmm0, xmm7
232 | sub ecx, 8
233 | movlpd qword ptr [edx + esi], xmm0
234 | lea edx, [edx + 2 * esi]
235 | movhpd qword ptr [ebx + ebp], xmm0
236 | lea ebx, [ebx + 2 * ebp]
237 | jg convertloop
238 |
239 | mov esp, [esp + 16]
240 | pop ebp
241 | pop edi
242 | pop esi
243 | pop ebx
244 | ret
245 | }
246 | }
247 |
248 | #endif // !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86)
249 |
250 | #ifdef __cplusplus
251 | } // extern "C"
252 | } // namespace libyuv
253 | #endif
254 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -x
3 |
4 | function runbenchmark1 {
5 | perf record /google/src/cloud/fbarchard/clean/google3/blaze-bin/third_party/libyuv/libyuv_test --gunit_filter=*$1 --libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=1000 --libyuv_flags=-1 --libyuv_cpu_info=-1
6 | perf report | grep AVX
7 | }
8 |
9 | runbenchmark1 ABGRToI420
10 | runbenchmark1 Android420ToI420
11 | runbenchmark1 ARGBToI420
12 | runbenchmark1 Convert16To8Plane
13 | runbenchmark1 ConvertToARGB
14 | runbenchmark1 ConvertToI420
15 | runbenchmark1 CopyPlane
16 | runbenchmark1 H010ToAB30
17 | runbenchmark1 H010ToAR30
18 | runbenchmark1 HalfFloatPlane
19 | runbenchmark1 I010ToAB30
20 | runbenchmark1 I010ToAR30
21 | runbenchmark1 I420Copy
22 | runbenchmark1 I420Psnr
23 | runbenchmark1 I420Scale
24 | runbenchmark1 I420Ssim
25 | runbenchmark1 I420ToARGB
26 | runbenchmark1 I420ToNV12
27 | runbenchmark1 I420ToUYVY
28 | runbenchmark1 I422ToI420
29 | runbenchmark1 InitCpuFlags
30 | runbenchmark1 J420ToARGB
31 | runbenchmark1 NV12ToARGB
32 | runbenchmark1 NV12ToI420
33 | runbenchmark1 NV12ToI420Rotate
34 | runbenchmark1 SetCpuFlags
35 | runbenchmark1 YUY2ToI420
36 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/libyuv/source/video_common.cc:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 | *
4 | * Use of this source code is governed by a BSD-style license
5 | * that can be found in the LICENSE file in the root of the source
6 | * tree. An additional intellectual property rights grant can be found
7 | * in the file PATENTS. All contributing project authors may
8 | * be found in the AUTHORS file in the root of the source tree.
9 | */
10 |
11 | #include "libyuv/video_common.h"
12 |
13 | #ifdef __cplusplus
14 | namespace libyuv {
15 | extern "C" {
16 | #endif
17 |
18 | struct FourCCAliasEntry {
19 | uint32_t alias;
20 | uint32_t canonical;
21 | };
22 |
23 | #define NUM_ALIASES 18
24 | static const struct FourCCAliasEntry kFourCCAliases[NUM_ALIASES] = {
25 | {FOURCC_IYUV, FOURCC_I420},
26 | {FOURCC_YU12, FOURCC_I420},
27 | {FOURCC_YU16, FOURCC_I422},
28 | {FOURCC_YU24, FOURCC_I444},
29 | {FOURCC_YUYV, FOURCC_YUY2},
30 | {FOURCC_YUVS, FOURCC_YUY2}, // kCMPixelFormat_422YpCbCr8_yuvs
31 | {FOURCC_HDYC, FOURCC_UYVY},
32 | {FOURCC_2VUY, FOURCC_UYVY}, // kCMPixelFormat_422YpCbCr8
33 | {FOURCC_JPEG, FOURCC_MJPG}, // Note: JPEG has DHT while MJPG does not.
34 | {FOURCC_DMB1, FOURCC_MJPG},
35 | {FOURCC_BA81, FOURCC_BGGR}, // deprecated.
36 | {FOURCC_RGB3, FOURCC_RAW},
37 | {FOURCC_BGR3, FOURCC_24BG},
38 | {FOURCC_CM32, FOURCC_BGRA}, // kCMPixelFormat_32ARGB
39 | {FOURCC_CM24, FOURCC_RAW}, // kCMPixelFormat_24RGB
40 | {FOURCC_L555, FOURCC_RGBO}, // kCMPixelFormat_16LE555
41 | {FOURCC_L565, FOURCC_RGBP}, // kCMPixelFormat_16LE565
42 | {FOURCC_5551, FOURCC_RGBO}, // kCMPixelFormat_16LE5551
43 | };
44 | // TODO(fbarchard): Consider mapping kCMPixelFormat_32BGRA to FOURCC_ARGB.
45 | // {FOURCC_BGRA, FOURCC_ARGB}, // kCMPixelFormat_32BGRA
46 |
47 | LIBYUV_API
48 | uint32_t CanonicalFourCC(uint32_t fourcc) {
49 | int i;
50 | for (i = 0; i < NUM_ALIASES; ++i) {
51 | if (kFourCCAliases[i].alias == fourcc) {
52 | return kFourCCAliases[i].canonical;
53 | }
54 | }
55 | // Not an alias, so return it as-is.
56 | return fourcc;
57 | }
58 |
59 | #ifdef __cplusplus
60 | } // extern "C"
61 | } // namespace libyuv
62 | #endif
63 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/cpp/native_camera.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by llm on 20-7-8.
3 | //
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include "V4L2Camera.h"
10 |
11 | //定义日志打印宏函数
12 | #define LOG_TAG "FFMediaPlayer"
13 | #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
14 | #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
15 | #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
16 | #define ALOGD(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
17 |
18 | #define VIDEO_FILE "/dev/video0"
19 |
20 | #define IMAGEWIDTH 640
21 | #define IMAGEHEIGHT 480
22 | #define PIX_FORMATE V4L2_PIX_FMT_YUYV
23 |
24 | V4L2Camera* v4l2Camera = 0;
25 | JavaVM *javaVM = 0;
26 |
27 | static void com_iview_camera_native_init(JNIEnv *env,jobject thiz) {
28 |
29 | v4l2Camera = new V4L2Camera();
30 | //由v4l2负责释放
31 | JavaCallHelper* javaCallHelper = new JavaCallHelper(javaVM, env, thiz);
32 | v4l2Camera->setListener(javaCallHelper);
33 | }
34 |
35 | static void com_iview_camera_native_release(JNIEnv *env) {;
36 |
37 | if (v4l2Camera != 0) {
38 | v4l2Camera->setListener(0);
39 | delete v4l2Camera;
40 | v4l2Camera = 0;
41 | }
42 | }
43 |
44 | static jint com_iview_camera_native_open(JNIEnv *env, jobject thiz) {
45 |
46 | int ret = ERROR_OPEN_FAIL;
47 | if (v4l2Camera != 0) {
48 | ret = v4l2Camera->Open(VIDEO_FILE, IMAGEWIDTH, IMAGEHEIGHT, PIX_FORMATE);
49 | }
50 |
51 | return ret;
52 | }
53 |
54 | static void com_iview_camera_native_close(JNIEnv *env, jobject thiz) {
55 | if (v4l2Camera != 0) {
56 | v4l2Camera->Close();
57 | }
58 | }
59 |
60 | static jobject com_iview_camera_native_getParameters(JNIEnv *env, jobject thiz) {
61 |
62 | if (v4l2Camera == 0) {
63 | return 0;
64 | }
65 | std::list parameters = v4l2Camera->getParameters();
66 |
67 | jclass list_class = env->FindClass("java/util/ArrayList");
68 | if (list_class == NULL) {
69 | return 0;
70 | }
71 |
72 | jmethodID list_costruct = env->GetMethodID(list_class , "","()V"); //获得得构造函数Id
73 | jmethodID list_add = env->GetMethodID(list_class, "add", "(Ljava/lang/Object;)Z");
74 | jobject list_obj = env->NewObject(list_class , list_costruct); //创建一个Arraylist集合对象
75 |
76 | jclass parameter_cls = env->FindClass("pri/tool/bean/Parameter");//获得类引用
77 | //获得该类型的构造函数 函数名为 返回类型必须为 void 即 V
78 | jmethodID parameter_costruct = env->GetMethodID(parameter_cls , "", "(ILjava/util/ArrayList;)V");
79 |
80 | jclass frame_cls = env->FindClass("pri/tool/bean/Frame");//获得类引用
81 | //获得该类型的构造函数 函数名为 返回类型必须为 void 即 V
82 | jmethodID frame_costruct = env->GetMethodID(frame_cls , "", "(IILjava/util/ArrayList;)V");
83 |
84 | jclass frameRate_cls = env->FindClass("pri/tool/bean/FrameRate");//获得类引用
85 | //获得该类型的构造函数 函数名为 返回类型必须为 void 即 V
86 | jmethodID frameRate_costruct = env->GetMethodID(frameRate_cls , "", "(II)V");
87 |
88 | for (Parameter parameter : parameters) {
89 |
90 | jobject listFrame_obj = env->NewObject(list_class , list_costruct); //创建一个Arraylist集合对象
91 | for (Frame frame : parameter.frames) {
92 |
93 | jobject listFrameRate_obj = env->NewObject(list_class , list_costruct); //创建一个Arraylist集合对象
94 | for (FrameRate frameRate : frame.frameRate) {
95 | jobject frameRate_obj = env->NewObject(frameRate_cls, frameRate_costruct, frameRate.numerator, frameRate.denominator);
96 | env->CallBooleanMethod(listFrameRate_obj , list_add , frameRate_obj);
97 | }
98 |
99 | jobject frame_obj = env->NewObject(frame_cls, frame_costruct, frame.width, frame.height, listFrameRate_obj);
100 | env->CallBooleanMethod(listFrame_obj , list_add , frame_obj);
101 | }
102 |
103 | //TODO:完善类型映射
104 | int format;
105 | switch(parameter.pixFormat) {
106 | case V4L2_PIX_FMT_YUYV:
107 | format = YUYV;
108 | break;
109 | case V4L2_PIX_FMT_MJPEG:
110 | format = MJPEG;
111 | break;
112 | case V4L2_PIX_FMT_H264:
113 | format = H264;
114 | break;
115 | default:
116 | format = parameter.pixFormat;
117 | break;
118 | }
119 | jobject parameter_obj = env->NewObject(parameter_cls, parameter_costruct, format, listFrame_obj);
120 | env->CallBooleanMethod(list_obj, list_add, parameter_obj);
121 | }
122 |
123 | return list_obj;
124 | }
125 |
126 | static jint com_iview_camera_native_setPreviewSize(JNIEnv *env, jobject thiz, jint width, jint height, jint pixformat) {
127 | if (v4l2Camera == 0) {
128 | return ERROR_CAPABILITY_UNSUPPORT;
129 | }
130 |
131 | int format;
132 | switch (pixformat) {
133 | case YUYV:
134 | format = V4L2_PIX_FMT_YUYV;
135 | break;
136 | case MJPEG:
137 | format = V4L2_PIX_FMT_MJPEG;
138 | break;
139 | default:
140 | format = -1;
141 | break;
142 | }
143 |
144 | if (format == -1) {
145 | return ERROR_CAPABILITY_UNSUPPORT;
146 | }
147 |
148 | return v4l2Camera->setPreviewSize(width, height, format);
149 | }
150 |
151 | static int com_iview_camera_native_setSurface(JNIEnv *env, jobject thiz, jobject surface) {
152 | if (v4l2Camera == 0) {
153 | return ERROR_CAPABILITY_UNSUPPORT;
154 | }
155 |
156 | ANativeWindow *window = ANativeWindow_fromSurface(env, surface);
157 |
158 | v4l2Camera->setSurface(window);
159 |
160 | return 0;
161 | }
162 |
163 | static int com_iview_camera_native_startPreview(JNIEnv *env, jobject thiz) {
164 | if (v4l2Camera == 0) {
165 | return ERROR_CAPABILITY_UNSUPPORT;
166 | }
167 | int ret = 0;
168 | ret = v4l2Camera->Init();
169 | if (ret != 0 ) {
170 | ALOGE("startPreview init fail");
171 | }
172 | v4l2Camera->StartStreaming();
173 |
174 | return 0;
175 | }
176 |
177 | static int com_iview_camera_native_stopPreview(JNIEnv *env, jobject thiz) {
178 | if (v4l2Camera == 0) {
179 | return ERROR_CAPABILITY_UNSUPPORT;
180 | }
181 |
182 | v4l2Camera->StopStreaming();
183 |
184 | return 0;
185 | }
186 |
187 |
188 | static JNINativeMethod gMethods[] = {
189 | {"native_init", "()V", (void *)com_iview_camera_native_init},
190 | {"native_release", "()V", (void *)com_iview_camera_native_release},
191 | {"native_open", "()I", (void *)com_iview_camera_native_open},
192 | {"native_close", "()V", (void *)com_iview_camera_native_close},
193 | {"native_getParameters", "()Ljava/util/ArrayList;", (void *)com_iview_camera_native_getParameters},
194 | {"native_setPreviewSize", "(III)I", (void *)com_iview_camera_native_setPreviewSize},
195 | {"native_setSurface", "(Ljava/lang/Object;)I", (void *)com_iview_camera_native_setSurface},
196 | {"native_startPreview", "()I", (void *)com_iview_camera_native_startPreview},
197 | {"native_stopPreview", "()I", (void *)com_iview_camera_native_stopPreview},
198 | };
199 |
200 | //Ljava/lang/Object;
201 | //Ljava/util/ArrayList;
202 | static int registerNativeMethods(JNIEnv* env, const char* className, JNINativeMethod* gMethods, int methodsNum) {
203 | jclass clazz;
204 | //找到声明native方法的类
205 | clazz = env->FindClass(className);
206 | if(clazz == NULL){
207 | return JNI_FALSE;
208 | }
209 | //注册函数 参数:java类 所要注册的函数数组 注册函数的个数
210 | if(env->RegisterNatives(clazz, gMethods, methodsNum) < 0){
211 | return JNI_FALSE;
212 | }
213 | return JNI_TRUE;
214 | }
215 |
216 | static int register_native_methods(JNIEnv* env){
217 | //指定类的路径,通过FindClass 方法来找到对应的类
218 | const char* className = "pri/tool/v4l2camera/V4L2Camera";
219 |
220 | return registerNativeMethods(env, className, gMethods, sizeof(gMethods)/ sizeof(gMethods[0]));
221 | }
222 |
223 | jint JNI_OnLoad(JavaVM* vm, void* /* reserved */)
224 | {
225 | JNIEnv* env = NULL;
226 | jint result = -1;
227 |
228 | javaVM = vm;
229 |
230 | if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
231 | ALOGE("ERROR: GetEnv failed\n");
232 | goto bail;
233 | }
234 | assert(env != NULL);
235 |
236 | if (register_native_methods(env) < 0) {
237 | ALOGE("ERROR: register_native_methods failed");
238 | goto bail;
239 | }
240 | /* success -- return valid version number */
241 | result = JNI_VERSION_1_4;
242 |
243 | bail:
244 | return result;
245 | }
246 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/java/pri/tool/bean/Frame.java:
--------------------------------------------------------------------------------
1 | package pri.tool.bean;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class Frame {
6 | public int width;
7 | public int height;
8 | public ArrayList frameRate;
9 |
10 | Frame(int width, int height, ArrayList frameRate) {
11 | this.width = width;
12 | this.height = height;
13 | this.frameRate = frameRate;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/java/pri/tool/bean/FrameRate.java:
--------------------------------------------------------------------------------
1 | package pri.tool.bean;
2 |
3 | public class FrameRate {
4 | public int numerator;
5 | public int denominator;
6 |
7 | FrameRate(int numerator, int denominator) {
8 | this.numerator = numerator;
9 | this.denominator = denominator;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/java/pri/tool/bean/Parameter.java:
--------------------------------------------------------------------------------
1 | package pri.tool.bean;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class Parameter {
6 | public int pixFormat;
7 | public ArrayList frames;
8 |
9 | Parameter(int pixFormat, ArrayList frames) {
10 | this.pixFormat = pixFormat;
11 | this.frames = frames;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/java/pri/tool/v4l2camera/IDataCallback.java:
--------------------------------------------------------------------------------
1 | package pri.tool.v4l2camera;
2 |
3 | public interface IDataCallback {
4 | void onDataCallback(byte[] data, int dataType, int width, int height);
5 | }
6 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/java/pri/tool/v4l2camera/IStateCallback.java:
--------------------------------------------------------------------------------
1 | package pri.tool.v4l2camera;
2 |
3 | public interface IStateCallback {
4 |
5 | public void onOpened();
6 |
7 | public void onError(int error);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/java/pri/tool/v4l2camera/ImageUtils.java:
--------------------------------------------------------------------------------
1 | package pri.tool.v4l2camera;
2 |
3 | import android.graphics.Matrix;
4 | import android.util.Log;
5 |
6 | public class ImageUtils {
7 | private final static String TAG = "ImageUtils";
8 |
9 | // YUV420 arranged in “Y0-Y1-......””V0-V1....””U0-U1-.....” format
10 | public final static int YV12 = 0;
11 |
12 | //YUV420sp arranged in "YYYY YYYY VU VU" format
13 | public final static int NV21 = 1;
14 |
15 | //YUV422 arranged in "YUYV" format
16 | public final static int YUYV = 2;
17 |
18 | public final static int MJPEG = 3;
19 | public final static int H264 = 4;
20 |
21 |
22 | /**
23 | * Returns a transformation matrix from one reference frame into another.
24 | * Handles cropping (if maintaining aspect ratio is desired) and rotation.
25 | *
26 | * @param srcWidth Width of source frame.
27 | * @param srcHeight Height of source frame.
28 | * @param dstWidth Width of destination frame.
29 | * @param dstHeight Height of destination frame.
30 | * @param applyRotation Amount of rotation to apply from one frame to another.
31 | * Must be a multiple of 90.
32 | * @param maintainAspectRatio If true, will ensure that scaling in x and y remains constant,
33 | * cropping the image if necessary.
34 | * @return The transformation fulfilling the desired requirements.
35 | */
36 | public static Matrix getTransformationMatrix(
37 | final int srcWidth,
38 | final int srcHeight,
39 | final int dstWidth,
40 | final int dstHeight,
41 | final int applyRotation,
42 | final boolean maintainAspectRatio) {
43 | final Matrix matrix = new Matrix();
44 |
45 | if (applyRotation != 0) {
46 | if (applyRotation % 90 != 0) {
47 | Log.w(TAG, "Rotation of " + applyRotation + " % 90 != 0");
48 | }
49 |
50 | // Translate so center of image is at origin.
51 | matrix.postTranslate(-srcWidth / 2.0f, -srcHeight / 2.0f);
52 |
53 | // Rotate around origin.
54 | matrix.postRotate(applyRotation);
55 | }
56 |
57 | // Account for the already applied rotation, if any, and then determine how
58 | // much scaling is needed for each axis.
59 | final boolean transpose = (Math.abs(applyRotation) + 90) % 180 == 0;
60 |
61 | final int inWidth = transpose ? srcHeight : srcWidth;
62 | final int inHeight = transpose ? srcWidth : srcHeight;
63 |
64 | // Apply scaling if necessary.
65 | if (inWidth != dstWidth || inHeight != dstHeight) {
66 | final float scaleFactorX = dstWidth / (float) inWidth;
67 | final float scaleFactorY = dstHeight / (float) inHeight;
68 |
69 | if (maintainAspectRatio) {
70 | // Scale by minimum factor so that dst is filled completely while
71 | // maintaining the aspect ratio. Some image may fall off the edge.
72 | final float scaleFactor = Math.max(scaleFactorX, scaleFactorY);
73 | matrix.postScale(scaleFactor, scaleFactor);
74 | } else {
75 | // Scale exactly to fill dst from src.
76 | matrix.postScale(scaleFactorX, scaleFactorY);
77 | }
78 | }
79 |
80 | if (applyRotation != 0) {
81 | // Translate back from origin centered reference to destination frame.
82 | matrix.postTranslate(dstWidth / 2.0f, dstHeight / 2.0f);
83 | }
84 |
85 | return matrix;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/java/pri/tool/v4l2camera/V4L2Camera.java:
--------------------------------------------------------------------------------
1 | package pri.tool.v4l2camera;
2 |
3 | import android.content.Context;
4 | import android.os.Build;
5 | import android.text.TextUtils;
6 | import android.util.Log;
7 | import android.util.Size;
8 | import android.view.Surface;
9 | import android.view.SurfaceHolder;
10 |
11 | import androidx.annotation.RequiresApi;
12 |
13 |
14 | import java.util.ArrayList;
15 | import java.util.Collections;
16 | import java.util.Comparator;
17 | import java.util.List;
18 |
19 | import pri.tool.bean.Frame;
20 | import pri.tool.bean.FrameRate;
21 | import pri.tool.bean.Parameter;
22 |
23 | import static pri.tool.v4l2camera.ImageUtils.YUYV;
24 |
25 |
26 | public class V4L2Camera{
27 | private final static String TAG ="V4LCamera";
28 |
29 | public static final int MINIMUM_PREVIEW_SIZE = 320;
30 |
31 | public final static int SUCCESS = 0;
32 | public final static int ERROR_INIT_FAIL = -1;
33 | public final static int ERROR_LOGIN_FAIL = -2;
34 | public final static int ERROR_STATE_ILLEGAL = -3;
35 | public final static int ERROR_CAPABILITY_UNSUPPORT = -4;
36 | public final static int ERROR_OPEN_FAIL = -5;
37 | public final static int ERROR_PREVIEW_FAIL = -6;
38 |
39 | IStateCallback stateCallback; //状态回调,如打开camera成功失败状态,其他异常
40 | IDataCallback dataCallback; //camera 数据回调
41 |
42 | Size mPreviewSize;
43 |
44 | static {
45 | System.loadLibrary("v4l-android");
46 | }
47 |
48 | public void init(IStateCallback callback, Context context) {
49 | stateCallback = callback;
50 | native_init();
51 | }
52 |
53 | /*
54 | * 释放SDK资源
55 | */
56 | public void release() {
57 | native_release();
58 | stateCallback = null;
59 | }
60 |
61 | public void open() {
62 | int ret = native_open();
63 |
64 | if (ret == SUCCESS) {
65 | stateCallback.onOpened();
66 | } else {
67 | stateCallback.onError(ERROR_OPEN_FAIL);
68 | }
69 | }
70 |
71 | public void close() {
72 | native_close();
73 | }
74 |
75 | /**
76 | * 设置预览 Surface。
77 | */
78 | public void setSurface(SurfaceHolder holder) {
79 | if (holder != null) {
80 | native_setSurface(holder.getSurface());
81 | } else {
82 | native_setSurface((Surface)null);
83 | }
84 |
85 | }
86 |
87 | /**
88 | * 开始预览。
89 | */
90 | public void startPreview(IDataCallback callback) {
91 | dataCallback = callback;
92 | native_startPreview();
93 |
94 | }
95 |
96 | /**
97 | * 停止预览。
98 | */
99 | public void stopPreview() {
100 | native_stopPreview();
101 | dataCallback = null;
102 | }
103 |
104 | public ArrayList getCameraParameters() {
105 | return native_getParameters();
106 | }
107 |
108 | public int setPreviewParameter(int width, int height, int pixFormat) {
109 | return native_setPreviewSize(width, height, pixFormat);
110 | }
111 |
112 | public Size chooseOptimalSize(int desireWidth, int desireHeight) {
113 |
114 | ArrayList parameters = native_getParameters();
115 | for(Parameter parameter:parameters) {
116 | Log.e(TAG, "support format: " + parameter.pixFormat);
117 | for (Frame frame : parameter.frames) {
118 | Log.e(TAG, "support frame: width:" + frame.width + ", height:" + frame.height);
119 | for (FrameRate frameRate:frame.frameRate) {
120 | Log.e(TAG, "support framerate: numerator:" + frameRate.numerator + ", denominator:" + frameRate.denominator);
121 | }
122 | }
123 | }
124 |
125 | List cameraSizes = getSupportedPreviewSizes(parameters, YUYV);
126 | Size[] sizes = new Size[cameraSizes.size()];
127 | int i = 0;
128 | for (Size size : cameraSizes) {
129 | sizes[i++] = new Size(size.getWidth(), size.getHeight());
130 | }
131 | mPreviewSize = chooseOptimalSize(sizes, desireWidth, desireHeight);
132 |
133 | native_setPreviewSize(mPreviewSize.getWidth(), mPreviewSize.getHeight(), YUYV);
134 |
135 | return mPreviewSize;
136 | }
137 |
138 | /**
139 | * Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose
140 | * width and height are at least as large as the minimum of both, or an exact match if possible.
141 | *
142 | * @param choices The list of sizes that the camera supports for the intended output class
143 | * @param width The minimum desired width
144 | * @param height The minimum desired height
145 | * @return The optimal {@code Size}, or an arbitrary one if none were big enough
146 | */
147 | protected static Size chooseOptimalSize(final Size[] choices, final int width, final int height) {
148 | final int minSize = Math.max(Math.min(width, height), MINIMUM_PREVIEW_SIZE);
149 | final Size desiredSize = new Size(width, height);
150 |
151 | // Collect the supported resolutions that are at least as big as the preview Surface
152 | boolean exactSizeFound = false;
153 | final List bigEnough = new ArrayList();
154 | final List tooSmall = new ArrayList();
155 | for (final Size option : choices) {
156 | if (option.equals(desiredSize)) {
157 | // Set the size but don't return yet so that remaining sizes will still be logged.
158 | exactSizeFound = true;
159 | }
160 |
161 | if (option.getHeight() >= minSize && option.getWidth() >= minSize) {
162 | bigEnough.add(option);
163 | } else {
164 | tooSmall.add(option);
165 | }
166 | }
167 |
168 | Log.i(TAG, "Desired size: " + desiredSize.toString() + ", min size: " + minSize + "x" + minSize);
169 | Log.i(TAG, "Valid preview sizes: [" + TextUtils.join(", ", bigEnough) + "]");
170 | Log.i(TAG, "Rejected preview sizes: [" + TextUtils.join(", ", tooSmall) + "]");
171 |
172 | if (exactSizeFound) {
173 | Log.i(TAG,"Exact size match found.");
174 | return desiredSize;
175 | }
176 |
177 | // Pick the smallest of those, assuming we found any
178 | if (bigEnough.size() > 0) {
179 | final Size chosenSize = Collections.min(bigEnough, new CompareSizesByArea());
180 | Log.i(TAG, "Chosen size: " + chosenSize.getWidth() + "x" + chosenSize.getHeight());
181 | return chosenSize;
182 | } else {
183 | Log.e(TAG, "Couldn't find any suitable preview size");
184 | return choices[0];
185 | }
186 | }
187 |
188 | /**
189 | * Compares two {@code Size}s based on their areas.
190 | */
191 | static class CompareSizesByArea implements Comparator {
192 |
193 | @Override
194 | public int compare(Size lhs, Size rhs) {
195 | // We cast here to ensure the multiplications won't overflow
196 | return Long.signum((long) lhs.getWidth() * lhs.getHeight() -
197 | (long) rhs.getWidth() * rhs.getHeight());
198 | }
199 | }
200 |
201 |
202 | List getSupportedPreviewSizes(ArrayList parameters, int format) {
203 | List sizeList = new ArrayList<>();
204 |
205 | for(Parameter parameter:parameters) {
206 | Log.e(TAG, "support format: " + parameter.pixFormat);
207 | if (parameter.pixFormat == format) {
208 | for (Frame frame : parameter.frames) {
209 | Size size = new Size(frame.width, frame.height);
210 | sizeList.add(size);
211 | }
212 | }
213 | }
214 |
215 | return sizeList;
216 | }
217 |
218 | //Jni 层回调的函数
219 | private void postDataFromNative(byte[] data, int width, int height, int pixformat) {
220 | //Log.e(TAG, "postDataFromNative");
221 | if (dataCallback != null) {
222 | dataCallback.onDataCallback(data, pixformat, width, height);
223 | }
224 | }
225 |
226 | private native final void native_init();
227 | private native final void native_release();
228 | private native final int native_open();
229 | private native final void native_close();
230 | private native final ArrayList native_getParameters();
231 | private native final int native_setPreviewSize(int width, int height, int pixFormat);
232 | private native final int native_setSurface(Object surface);
233 | private native final int native_startPreview();
234 | private native final int native_stopPreview();
235 |
236 | }
237 |
--------------------------------------------------------------------------------
/v4l2camera/src/main/jniLibs/armeabi-v7a/libjpeg.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yizhongliu/AnV4L2Camera/4c30daf10b8e687d5743c2b0cc2918bcd3e6f8d8/v4l2camera/src/main/jniLibs/armeabi-v7a/libjpeg.so
--------------------------------------------------------------------------------
/v4l2camera/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | V4L2Camera
3 |
4 |
--------------------------------------------------------------------------------
/v4l2camera/src/test/java/pri/tool/v4l2camera/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package pri.tool.v4l2camera;
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 | }
--------------------------------------------------------------------------------