Skip to content

Commit

Permalink
change the orientation of 90deg to 270 for preview
Browse files Browse the repository at this point in the history
  • Loading branch information
gkdeepa committed Nov 8, 2021
1 parent a5a2929 commit 775a3c4
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
From 750a6d205960e2edaaa3e5b7ff8400bbac2daac5 Mon Sep 17 00:00:00 2001
From: gkdeepa <[email protected]>
Date: Wed, 3 Nov 2021 14:11:10 +0530
Subject: [PATCH] check orientation in camera 90deg case

Tracked-On:
---
...ck-orientation-in-camera-180deg-case.patch | 50 +++++++++++++++++++
.../api1/client2/Parameters.cpp | 10 ++--
2 files changed, 56 insertions(+), 4 deletions(-)
create mode 100644 services/camera/libcameraservice/api1/0001-check-orientation-in-camera-180deg-case.patch

diff --git a/services/camera/libcameraservice/api1/0001-check-orientation-in-camera-180deg-case.patch b/services/camera/libcameraservice/api1/0001-check-orientation-in-camera-180deg-case.patch
new file mode 100644
index 0000000000..42b83e5fa1
--- /dev/null
+++ b/services/camera/libcameraservice/api1/0001-check-orientation-in-camera-180deg-case.patch
@@ -0,0 +1,50 @@
+From 9aa1a62d7206fdd32ea61eaecea46a58d5915686 Mon Sep 17 00:00:00 2001
+From: gkdeepa <[email protected]>
+Date: Wed, 3 Nov 2021 14:11:10 +0530
+Subject: [PATCH] check orientation in camera 180deg case
+
+Tracked-On:
+---
+ .../camera/libcameraservice/api1/client2/Parameters.cpp | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp
+index dbc863b3ad..9979610ca0 100644
+--- a/services/camera/libcameraservice/api1/client2/Parameters.cpp
++++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp
+@@ -16,7 +16,7 @@
+
+ #define LOG_TAG "Camera2-Parameters"
+ #define ATRACE_TAG ATRACE_TAG_CAMERA
+-// #define LOG_NDEBUG 0
++#define LOG_NDEBUG 0
+
+ #include <utils/Log.h>
+ #include <utils/Trace.h>
+@@ -2828,10 +2828,12 @@ bool Parameters::boolFromString(const char *boolStr) {
+ }
+
+ int Parameters::degToTransform(int degrees, bool mirror) {
++ ALOGE("degrees and mirror %d %d ",degrees, mirror);
+ if (!mirror) {
+ if (degrees == 0) return 0;
+ else if (degrees == 90) return HAL_TRANSFORM_ROT_90;
+- else if (degrees == 180) return HAL_TRANSFORM_ROT_180;
++ //else if (degrees == 180) return HAL_TRANSFORM_ROT_180;
++ else if (degrees == 180) return 0;
+ else if (degrees == 270) return HAL_TRANSFORM_ROT_270;
+ } else { // Do mirror (horizontal flip)
+ if (degrees == 0) { // FLIP_H and ROT_0
+@@ -2839,7 +2841,8 @@ int Parameters::degToTransform(int degrees, bool mirror) {
+ } else if (degrees == 90) { // FLIP_H and ROT_90
+ return HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90;
+ } else if (degrees == 180) { // FLIP_H and ROT_180
+- return HAL_TRANSFORM_FLIP_V;
++ return 0;
++ //return HAL_TRANSFORM_FLIP_V;
+ } else if (degrees == 270) { // FLIP_H and ROT_270
+ return HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90;
+ }
+--
+2.17.1
+
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp
index dbc863b3ad..487e7cd426 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.cpp
+++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp
@@ -16,7 +16,7 @@

#define LOG_TAG "Camera2-Parameters"
#define ATRACE_TAG ATRACE_TAG_CAMERA
-// #define LOG_NDEBUG 0
+#define LOG_NDEBUG 0

#include <utils/Log.h>
#include <utils/Trace.h>
@@ -2828,18 +2828,20 @@ bool Parameters::boolFromString(const char *boolStr) {
}

int Parameters::degToTransform(int degrees, bool mirror) {
+ ALOGE("degrees and mirror %d %d ",degrees, mirror);
if (!mirror) {
if (degrees == 0) return 0;
- else if (degrees == 90) return HAL_TRANSFORM_ROT_90;
+ else if (degrees == 90) return HAL_TRANSFORM_ROT_270;
else if (degrees == 180) return HAL_TRANSFORM_ROT_180;
else if (degrees == 270) return HAL_TRANSFORM_ROT_270;
} else { // Do mirror (horizontal flip)
if (degrees == 0) { // FLIP_H and ROT_0
return HAL_TRANSFORM_FLIP_H;
} else if (degrees == 90) { // FLIP_H and ROT_90
- return HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90;
+ return HAL_TRANSFORM_FLIP_H ;
} else if (degrees == 180) { // FLIP_H and ROT_180
- return HAL_TRANSFORM_FLIP_V;
+ return 0;
+ //return HAL_TRANSFORM_FLIP_V;
} else if (degrees == 270) { // FLIP_H and ROT_270
return HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90;
}
--
2.17.1

Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
From 656493d0162261289bdbeafb26b409ef6556d0f8 Mon Sep 17 00:00:00 2001
From 9d947676bd2a4ce49d5521a7d45664689c2a51ef Mon Sep 17 00:00:00 2001
From: gkdeepa <[email protected]>
Date: Tue, 2 Nov 2021 13:54:55 +0530
Subject: [PATCH] JPEG compressor lib inclusion

Tracked-On:
---
src/NV21JpegCompressor.cpp | 2 +-
src/jpeg-stub/Compressor.cpp | 2 +-
src/jpeg-stub/JpegStub.cpp | 5 ++---
3 files changed, 4 insertions(+), 5 deletions(-)
src/CameraSocketServerThread.cpp | 2 +-
src/NV21JpegCompressor.cpp | 2 +-
src/jpeg-stub/Compressor.cpp | 2 +-
src/jpeg-stub/JpegStub.cpp | 3 +--
4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/CameraSocketServerThread.cpp b/src/CameraSocketServerThread.cpp
index da97a8e..d10159a 100644
--- a/src/CameraSocketServerThread.cpp
+++ b/src/CameraSocketServerThread.cpp
@@ -384,7 +384,7 @@ bool CameraSocketServerThread::threadLoop() {
mClientFd = -1;
clearBuffer(fbuffer, 640, 480);
break;
- } else if ((event & POLLIN) || (trans_mode == VSOCK) || (trans_mode == TCP) ) { // preview / record
+ } else if ((event & POLLIN) ) { // preview / record
// data is available in socket => read data
if (gIsInFrameI420) {
ssize_t size = 0;
diff --git a/src/NV21JpegCompressor.cpp b/src/NV21JpegCompressor.cpp
index 3348959..a320886 100644
--- a/src/NV21JpegCompressor.cpp
Expand Down Expand Up @@ -37,7 +51,7 @@ index 385937c..4d67ac3 100644
#include <log/log.h>
#include <libexif/exif-data.h>
diff --git a/src/jpeg-stub/JpegStub.cpp b/src/jpeg-stub/JpegStub.cpp
index d421a87..5c88a5e 100644
index d421a87..a16dbc8 100644
--- a/src/jpeg-stub/JpegStub.cpp
+++ b/src/jpeg-stub/JpegStub.cpp
@@ -16,7 +16,7 @@
Expand All @@ -49,20 +63,14 @@ index d421a87..5c88a5e 100644
#define LOG_TAG "VirtualCamera_JPEGStub"
#include <errno.h>
#include <log/log.h>
@@ -36,12 +36,11 @@ extern "C" void JpegStub_cleanup(JpegStub *stub) {
@@ -36,7 +36,6 @@ extern "C" void JpegStub_cleanup(JpegStub *stub) {
extern "C" int JpegStub_compress(JpegStub *stub, const void *buffer, int width, int height,
int quality, ExifData *exifData) {
Compressor *compressor = reinterpret_cast<Compressor *>(stub->mCompressor);
-
if (compressor->compress(reinterpret_cast<const unsigned char *>(buffer), width, height,
quality, exifData)) {
ALOGV("%s: Compressed JPEG: %d[%dx%d] -> %zu bytes", __FUNCTION__,
(width * height * 12) / 8, width, height, compressor->getCompressedData().size());
- return 0;
+
}
ALOGE("%s: JPEG compression failed", __FUNCTION__);
return errno ? errno : EINVAL;
--
2.17.1

0 comments on commit 775a3c4

Please sign in to comment.