diff options
author | Yin-Chia Yeh <yinchiayeh@google.com> | 2015-01-09 15:21:27 -0800 |
---|---|---|
committer | Yin-Chia Yeh <yinchiayeh@google.com> | 2015-01-20 13:40:53 -0800 |
commit | 0c4e56d0baaa19fcf17234b38d634b7281e2ae37 (patch) | |
tree | 54ee27c5dece90449af6924cc787af655346b201 /services/camera | |
parent | 7ccc6b9baf2f568a0a8c6e27dcd4195645a6361d (diff) | |
download | frameworks_av-0c4e56d0baaa19fcf17234b38d634b7281e2ae37.zip frameworks_av-0c4e56d0baaa19fcf17234b38d634b7281e2ae37.tar.gz frameworks_av-0c4e56d0baaa19fcf17234b38d634b7281e2ae37.tar.bz2 |
Camera: make sure jpeg buffer size isn't too small
Assuming the jpeg header can take up to 256KB, make sure we always
allocate enough size for the image data.
Bug: 18962703
Change-Id: I08eb3d198d12f71f3ab7266324e80fe7410bdc89
Diffstat (limited to 'services/camera')
-rw-r--r-- | services/camera/libcameraservice/device3/Camera3Device.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index bba3905..53e6fa9 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -361,16 +361,15 @@ ssize_t Camera3Device::getJpegBufferSize(uint32_t width, uint32_t height) const return BAD_VALUE; } maxJpegBufferSize = jpegBufMaxSize.data.i32[0]; + assert(kMinJpegBufferSize < maxJpegBufferSize); // Calculate final jpeg buffer size for the given resolution. float scaleFactor = ((float) (width * height)) / (maxJpegResolution.width * maxJpegResolution.height); - ssize_t jpegBufferSize = scaleFactor * maxJpegBufferSize; - // Bound the buffer size to [MIN_JPEG_BUFFER_SIZE, maxJpegBufferSize]. + ssize_t jpegBufferSize = scaleFactor * (maxJpegBufferSize - kMinJpegBufferSize) + + kMinJpegBufferSize; if (jpegBufferSize > maxJpegBufferSize) { jpegBufferSize = maxJpegBufferSize; - } else if (jpegBufferSize < kMinJpegBufferSize) { - jpegBufferSize = kMinJpegBufferSize; } return jpegBufferSize; |