From 3066c6d6684a448e693bad94631fc9b039cc51d4 Mon Sep 17 00:00:00 2001 From: Mansour Moufid Date: Wed, 15 Jun 2022 19:56:54 -0400 Subject: [PATCH] Get U/V planes instead of V/U, and encode RGBA instead of BGRA. --- camera/basic/src/main/cpp/image_reader.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/camera/basic/src/main/cpp/image_reader.cpp b/camera/basic/src/main/cpp/image_reader.cpp index 55eb459de..11da216e4 100644 --- a/camera/basic/src/main/cpp/image_reader.cpp +++ b/camera/basic/src/main/cpp/image_reader.cpp @@ -194,7 +194,7 @@ static inline uint32_t YUV2RGB(int nY, int nU, int nV) { nG = (nG >> 10) & 0xff; nB = (nB >> 10) & 0xff; - return 0xff000000 | (nR << 16) | (nG << 8) | nB; + return 0xff000000 | (nB << 16) | (nG << 8) | nR; } /** @@ -258,8 +258,8 @@ void ImageReader::PresentImage(ANativeWindow_Buffer *buf, AImage *image) { AImage_getPlaneRowStride(image, 0, &yStride); AImage_getPlaneRowStride(image, 1, &uvStride); AImage_getPlaneData(image, 0, &yPixel, &yLen); - AImage_getPlaneData(image, 1, &vPixel, &vLen); - AImage_getPlaneData(image, 2, &uPixel, &uLen); + AImage_getPlaneData(image, 1, &uPixel, &uLen); + AImage_getPlaneData(image, 2, &vPixel, &vLen); int32_t uvPixelStride; AImage_getPlanePixelStride(image, 1, &uvPixelStride); @@ -297,8 +297,8 @@ void ImageReader::PresentImage90(ANativeWindow_Buffer *buf, AImage *image) { AImage_getPlaneRowStride(image, 0, &yStride); AImage_getPlaneRowStride(image, 1, &uvStride); AImage_getPlaneData(image, 0, &yPixel, &yLen); - AImage_getPlaneData(image, 1, &vPixel, &vLen); - AImage_getPlaneData(image, 2, &uPixel, &uLen); + AImage_getPlaneData(image, 1, &uPixel, &uLen); + AImage_getPlaneData(image, 2, &vPixel, &vLen); int32_t uvPixelStride; AImage_getPlanePixelStride(image, 1, &uvPixelStride); @@ -338,8 +338,8 @@ void ImageReader::PresentImage180(ANativeWindow_Buffer *buf, AImage *image) { AImage_getPlaneRowStride(image, 0, &yStride); AImage_getPlaneRowStride(image, 1, &uvStride); AImage_getPlaneData(image, 0, &yPixel, &yLen); - AImage_getPlaneData(image, 1, &vPixel, &vLen); - AImage_getPlaneData(image, 2, &uPixel, &uLen); + AImage_getPlaneData(image, 1, &uPixel, &uLen); + AImage_getPlaneData(image, 2, &vPixel, &vLen); int32_t uvPixelStride; AImage_getPlanePixelStride(image, 1, &uvPixelStride); @@ -380,8 +380,8 @@ void ImageReader::PresentImage270(ANativeWindow_Buffer *buf, AImage *image) { AImage_getPlaneRowStride(image, 0, &yStride); AImage_getPlaneRowStride(image, 1, &uvStride); AImage_getPlaneData(image, 0, &yPixel, &yLen); - AImage_getPlaneData(image, 1, &vPixel, &vLen); - AImage_getPlaneData(image, 2, &uPixel, &uLen); + AImage_getPlaneData(image, 1, &uPixel, &uLen); + AImage_getPlaneData(image, 2, &vPixel, &vLen); int32_t uvPixelStride; AImage_getPlanePixelStride(image, 1, &uvPixelStride);