diff options
Diffstat (limited to 'guest/hals/camera')
-rw-r--r-- | guest/hals/camera/Android.bp | 1 | ||||
-rw-r--r-- | guest/hals/camera/cached_stream_buffer.cpp | 19 | ||||
-rw-r--r-- | guest/hals/camera/cached_stream_buffer.h | 4 |
3 files changed, 22 insertions, 2 deletions
diff --git a/guest/hals/camera/Android.bp b/guest/hals/camera/Android.bp index ce4c46c1e..c6c87329f 100644 --- a/guest/hals/camera/Android.bp +++ b/guest/hals/camera/Android.bp @@ -77,6 +77,7 @@ cc_library_shared { "libhidlbase", "liblog", "libutils", + "libui", "libvsock_utils", "libcuttlefish_fs", "libjsoncpp", diff --git a/guest/hals/camera/cached_stream_buffer.cpp b/guest/hals/camera/cached_stream_buffer.cpp index ff692c7dc..7e99581aa 100644 --- a/guest/hals/camera/cached_stream_buffer.cpp +++ b/guest/hals/camera/cached_stream_buffer.cpp @@ -96,8 +96,23 @@ YCbCrLayout CachedStreamBuffer::acquireAsYUV(int32_t width, int32_t height, acquire_fence_ = -1; } } - IMapper::Rect region{0, 0, width, height}; - return g_importer.lockYCbCr(buffer_, GRALLOC_USAGE_SW_WRITE_OFTEN, region); + android::Rect region{0, 0, width, height}; + android_ycbcr result = + g_importer.lockYCbCr(buffer_, GRALLOC_USAGE_SW_WRITE_OFTEN, region); + if (result.ystride > UINT32_MAX || result.cstride > UINT32_MAX || + result.chroma_step > UINT32_MAX) { + ALOGE( + "%s: lockYCbCr failed. Unexpected values! ystride: %zu cstride: %zu " + "chroma_step: %zu", + __FUNCTION__, result.ystride, result.cstride, result.chroma_step); + return {}; + } + return {.y = result.y, + .cb = result.cb, + .cr = result.cr, + .yStride = static_cast<uint32_t>(result.ystride), + .cStride = static_cast<uint32_t>(result.cstride), + .chromaStep = static_cast<uint32_t>(result.chroma_step)}; } void* CachedStreamBuffer::acquireAsBlob(int32_t size, int timeout_ms) { diff --git a/guest/hals/camera/cached_stream_buffer.h b/guest/hals/camera/cached_stream_buffer.h index 09a404738..19d738d2b 100644 --- a/guest/hals/camera/cached_stream_buffer.h +++ b/guest/hals/camera/cached_stream_buffer.h @@ -15,12 +15,16 @@ */ #pragma once #include <android/hardware/camera/device/3.4/ICameraDeviceSession.h> +#include <android/hardware/graphics/mapper/2.0/IMapper.h> +#include <android/hardware/graphics/mapper/3.0/IMapper.h> +#include <android/hardware/graphics/mapper/4.0/IMapper.h> #include "HandleImporter.h" namespace android::hardware::camera::device::V3_4::implementation { using ::android::hardware::camera::common::V1_0::helper::HandleImporter; using ::android::hardware::camera::device::V3_2::StreamBuffer; +using ::android::hardware::graphics::mapper::V2_0::YCbCrLayout; // Small wrapper for allocating/freeing native handles class ReleaseFence { |