发布v3.1.0
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.king.zxing">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.google.zxing.Result;
|
||||
import com.king.camera.scan.AnalyzeResult;
|
||||
import com.king.camera.scan.FrameMetadata;
|
||||
import com.king.camera.scan.analyze.Analyzer;
|
||||
import com.king.camera.scan.util.ImageUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -38,7 +38,7 @@ public abstract class ImageAnalyzer implements Analyzer<Result> {
|
||||
public abstract Result analyze(byte[] data, int width, int height);
|
||||
|
||||
@Override
|
||||
public void analyze(@NonNull ImageProxy imageProxy, @NonNull OnAnalyzeListener<AnalyzeResult<Result>> listener) {
|
||||
public void analyze(@NonNull ImageProxy imageProxy, @NonNull OnAnalyzeListener<Result> listener) {
|
||||
|
||||
if (!joinQueue.get()) {
|
||||
int imageSize = imageProxy.getWidth() * imageProxy.getHeight();
|
||||
@@ -56,7 +56,7 @@ public abstract class ImageAnalyzer implements Analyzer<Result> {
|
||||
int width = imageProxy.getWidth();
|
||||
int height = imageProxy.getHeight();
|
||||
|
||||
yuv_420_888toNv21(imageProxy, nv21Data);
|
||||
ImageUtils.yuv_420_888toNv21(imageProxy, nv21Data);
|
||||
|
||||
Result result;
|
||||
if (rotation == 90 || rotation == 270) {
|
||||
@@ -88,59 +88,4 @@ public abstract class ImageAnalyzer implements Analyzer<Result> {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* YUV420_888转NV21
|
||||
*
|
||||
* @param image
|
||||
* @param nv21
|
||||
*/
|
||||
private void yuv_420_888toNv21(@NonNull ImageProxy image, byte[] nv21) {
|
||||
ImageProxy.PlaneProxy yPlane = image.getPlanes()[0];
|
||||
ImageProxy.PlaneProxy uPlane = image.getPlanes()[1];
|
||||
ImageProxy.PlaneProxy vPlane = image.getPlanes()[2];
|
||||
|
||||
ByteBuffer yBuffer = yPlane.getBuffer();
|
||||
ByteBuffer uBuffer = uPlane.getBuffer();
|
||||
ByteBuffer vBuffer = vPlane.getBuffer();
|
||||
yBuffer.rewind();
|
||||
uBuffer.rewind();
|
||||
vBuffer.rewind();
|
||||
|
||||
int ySize = yBuffer.remaining();
|
||||
|
||||
int position = 0;
|
||||
|
||||
// Add the full y buffer to the array. If rowStride > 1, some padding may be skipped.
|
||||
for (int row = 0; row < image.getHeight(); row++) {
|
||||
yBuffer.get(nv21, position, image.getWidth());
|
||||
position += image.getWidth();
|
||||
yBuffer.position(Math.min(ySize, yBuffer.position() - image.getWidth() + yPlane.getRowStride()));
|
||||
}
|
||||
|
||||
int chromaHeight = image.getHeight() / 2;
|
||||
int chromaWidth = image.getWidth() / 2;
|
||||
int vRowStride = vPlane.getRowStride();
|
||||
int uRowStride = uPlane.getRowStride();
|
||||
int vPixelStride = vPlane.getPixelStride();
|
||||
int uPixelStride = uPlane.getPixelStride();
|
||||
|
||||
// Interleave the u and v frames, filling up the rest of the buffer. Use two line buffers to
|
||||
// perform faster bulk gets from the byte buffers.
|
||||
byte[] vLineBuffer = new byte[vRowStride];
|
||||
byte[] uLineBuffer = new byte[uRowStride];
|
||||
for (int row = 0; row < chromaHeight; row++) {
|
||||
vBuffer.get(vLineBuffer, 0, Math.min(vRowStride, vBuffer.remaining()));
|
||||
uBuffer.get(uLineBuffer, 0, Math.min(uRowStride, uBuffer.remaining()));
|
||||
int vLineBufferPosition = 0;
|
||||
int uLineBufferPosition = 0;
|
||||
for (int col = 0; col < chromaWidth; col++) {
|
||||
nv21[position++] = vLineBuffer[vLineBufferPosition];
|
||||
nv21[position++] = uLineBuffer[uLineBufferPosition];
|
||||
vLineBufferPosition += vPixelStride;
|
||||
uLineBufferPosition += uPixelStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user