diff options
author | Scott Lobdell <slobdell@google.com> | 2021-06-04 18:02:44 +0000 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2021-06-04 18:02:44 +0000 |
commit | c85bde0398d2a185e66a61cdabd26e5435bb4807 (patch) | |
tree | 3d9efc2d95fccc971f519d1d323a19a4621683cd /camera/common | |
parent | a01a9128380dad45a28f4740a57136a058eb9d12 (diff) | |
parent | e013dd1a8b8f0df65b20c4de224effa1a7fcc61b (diff) |
Merge SP1A.210604.001
Change-Id: I78feee65e602d45bb0e3e90536729623b0f3d4f5
Diffstat (limited to 'camera/common')
-rw-r--r-- | camera/common/1.0/default/HandleImporter.cpp | 59 | ||||
-rw-r--r-- | camera/common/1.0/default/include/HandleImporter.h | 3 |
2 files changed, 49 insertions, 13 deletions
diff --git a/camera/common/1.0/default/HandleImporter.cpp b/camera/common/1.0/default/HandleImporter.cpp index 05a552cd95..7fcf52330c 100644 --- a/camera/common/1.0/default/HandleImporter.cpp +++ b/camera/common/1.0/default/HandleImporter.cpp @@ -123,6 +123,24 @@ YCbCrLayout HandleImporter::lockYCbCrInternal(const sp<M> mapper, buffer_handle_ return layout; } +std::vector<PlaneLayout> getPlaneLayouts(const sp<IMapperV4> mapper, buffer_handle_t& buf) { + auto buffer = const_cast<native_handle_t*>(buf); + std::vector<PlaneLayout> planeLayouts; + hidl_vec<uint8_t> encodedPlaneLayouts; + mapper->get(buffer, gralloc4::MetadataType_PlaneLayouts, + [&](const auto& tmpError, const auto& tmpEncodedPlaneLayouts) { + if (tmpError == MapperErrorV4::NONE) { + encodedPlaneLayouts = tmpEncodedPlaneLayouts; + } else { + ALOGE("%s: failed to get plane layouts %d!", __FUNCTION__, tmpError); + } + }); + + gralloc4::decodePlaneLayouts(encodedPlaneLayouts, &planeLayouts); + + return planeLayouts; +} + template <> YCbCrLayout HandleImporter::lockYCbCrInternal<IMapperV4, MapperErrorV4>( const sp<IMapperV4> mapper, buffer_handle_t& buf, uint64_t cpuUsage, @@ -147,19 +165,7 @@ YCbCrLayout HandleImporter::lockYCbCrInternal<IMapperV4, MapperErrorV4>( return layout; } - hidl_vec<uint8_t> encodedPlaneLayouts; - mapper->get(buffer, gralloc4::MetadataType_PlaneLayouts, - [&](const auto& tmpError, const auto& tmpEncodedPlaneLayouts) { - if (tmpError == MapperErrorV4::NONE) { - encodedPlaneLayouts = tmpEncodedPlaneLayouts; - } else { - ALOGE("%s: failed to get plane layouts %d!", __FUNCTION__, tmpError); - } - }); - - std::vector<PlaneLayout> planeLayouts; - gralloc4::decodePlaneLayouts(encodedPlaneLayouts, &planeLayouts); - + std::vector<PlaneLayout> planeLayouts = getPlaneLayouts(mapper, buf); for (const auto& planeLayout : planeLayouts) { for (const auto& planeLayoutComponent : planeLayout.components) { const auto& type = planeLayoutComponent.type; @@ -401,6 +407,33 @@ YCbCrLayout HandleImporter::lockYCbCr( return {}; } +status_t HandleImporter::getMonoPlanarStrideBytes(buffer_handle_t &buf, uint32_t *stride /*out*/) { + if (stride == nullptr) { + return BAD_VALUE; + } + + Mutex::Autolock lock(mLock); + + if (!mInitialized) { + initializeLocked(); + } + + if (mMapperV4 != nullptr) { + std::vector<PlaneLayout> planeLayouts = getPlaneLayouts(mMapperV4, buf); + if (planeLayouts.size() != 1) { + ALOGE("%s: Unexpected number of planes %zu!", __FUNCTION__, planeLayouts.size()); + return BAD_VALUE; + } + + *stride = planeLayouts[0].strideInBytes; + } else { + ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__); + return NO_INIT; + } + + return OK; +} + int HandleImporter::unlock(buffer_handle_t& buf) { if (mMapperV4 != nullptr) { return unlockInternal<IMapperV4, MapperErrorV4>(mMapperV4, buf); diff --git a/camera/common/1.0/default/include/HandleImporter.h b/camera/common/1.0/default/include/HandleImporter.h index edc97ad9a7..e404439cb6 100644 --- a/camera/common/1.0/default/include/HandleImporter.h +++ b/camera/common/1.0/default/include/HandleImporter.h @@ -56,6 +56,9 @@ public: YCbCrLayout lockYCbCr(buffer_handle_t& buf, uint64_t cpuUsage, const IMapper::Rect& accessRegion); + // Query the stride of the first plane in bytes. + status_t getMonoPlanarStrideBytes(buffer_handle_t& buf, uint32_t* stride /*out*/); + int unlock(buffer_handle_t& buf); // returns release fence private: |