summaryrefslogtreecommitdiffstats
path: root/services/camera/libcameraservice/device2
diff options
context:
space:
mode:
authorZhijun He <zhijunhe@google.com>2014-08-08 12:00:47 -0700
committerZhijun He <zhijunhe@google.com>2014-08-11 04:32:14 +0000
commit28c9b6f298134624cb52b1af4ed8716dddb983d3 (patch)
tree4a9fb69c4b4f9783b8f1efe6369f5862633eddbb /services/camera/libcameraservice/device2
parent2dfe8ea7c131a045067c123efc934ef6ccdb8821 (diff)
downloadframeworks_av-28c9b6f298134624cb52b1af4ed8716dddb983d3.zip
frameworks_av-28c9b6f298134624cb52b1af4ed8716dddb983d3.tar.gz
frameworks_av-28c9b6f298134624cb52b1af4ed8716dddb983d3.tar.bz2
Camera2/3: Cleanup the jpeg buffer size calcaulation logic
- Only one place calculating the jpeg size-the device layer, Camera2Device and Camera3Device. - Remove size argument for CameraDeviceBase and cleanup related code. Bug: 14327010 Change-Id: I45d2ab4859ee0cc9273e579254f0569108c748f1
Diffstat (limited to 'services/camera/libcameraservice/device2')
-rw-r--r--services/camera/libcameraservice/device2/Camera2Device.cpp18
-rw-r--r--services/camera/libcameraservice/device2/Camera2Device.h4
2 files changed, 18 insertions, 4 deletions
diff --git a/services/camera/libcameraservice/device2/Camera2Device.cpp b/services/camera/libcameraservice/device2/Camera2Device.cpp
index 8c2520e..d473a76 100644
--- a/services/camera/libcameraservice/device2/Camera2Device.cpp
+++ b/services/camera/libcameraservice/device2/Camera2Device.cpp
@@ -242,13 +242,16 @@ status_t Camera2Device::waitUntilRequestReceived(int32_t requestId, nsecs_t time
}
status_t Camera2Device::createStream(sp<ANativeWindow> consumer,
- uint32_t width, uint32_t height, int format, size_t size, int *id) {
+ uint32_t width, uint32_t height, int format, int *id) {
ATRACE_CALL();
status_t res;
ALOGV("%s: E", __FUNCTION__);
sp<StreamAdapter> stream = new StreamAdapter(mHal2Device);
-
+ size_t size = 0;
+ if (format == HAL_PIXEL_FORMAT_BLOB) {
+ size = getJpegBufferSize(width, height);
+ }
res = stream->connectToDevice(consumer, width, height, format, size);
if (res != OK) {
ALOGE("%s: Camera %d: Unable to create stream (%d x %d, format %x):"
@@ -263,6 +266,17 @@ status_t Camera2Device::createStream(sp<ANativeWindow> consumer,
return OK;
}
+ssize_t Camera2Device::getJpegBufferSize(uint32_t width, uint32_t height) const {
+ // Always give the max jpeg buffer size regardless of the actual jpeg resolution.
+ camera_metadata_ro_entry jpegBufMaxSize = mDeviceInfo.find(ANDROID_JPEG_MAX_SIZE);
+ if (jpegBufMaxSize.count == 0) {
+ ALOGE("%s: Camera %d: Can't find maximum JPEG size in static metadata!", __FUNCTION__, mId);
+ return BAD_VALUE;
+ }
+
+ return jpegBufMaxSize.data.i32[0];
+}
+
status_t Camera2Device::createReprocessStreamFromStream(int outputId, int *id) {
ATRACE_CALL();
status_t res;
diff --git a/services/camera/libcameraservice/device2/Camera2Device.h b/services/camera/libcameraservice/device2/Camera2Device.h
index 46182f8..d0ca46e 100644
--- a/services/camera/libcameraservice/device2/Camera2Device.h
+++ b/services/camera/libcameraservice/device2/Camera2Device.h
@@ -57,8 +57,7 @@ class Camera2Device: public CameraDeviceBase {
virtual status_t clearStreamingRequest(int64_t *lastFrameNumber = NULL);
virtual status_t waitUntilRequestReceived(int32_t requestId, nsecs_t timeout);
virtual status_t createStream(sp<ANativeWindow> consumer,
- uint32_t width, uint32_t height, int format, size_t size,
- int *id);
+ uint32_t width, uint32_t height, int format, int *id);
virtual status_t createReprocessStreamFromStream(int outputId, int *id);
virtual status_t getStreamInfo(int id,
uint32_t *width, uint32_t *height, uint32_t *format);
@@ -79,6 +78,7 @@ class Camera2Device: public CameraDeviceBase {
// Flush implemented as just a wait
virtual status_t flush(int64_t *lastFrameNumber = NULL);
virtual uint32_t getDeviceVersion();
+ virtual ssize_t getJpegBufferSize(uint32_t width, uint32_t height) const;
private:
const int mId;