From b2210fc58cde10c281137e5e0c77319e218b4d45 Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Sat, 10 Feb 2024 09:30:19 -0500 Subject: [PATCH] Camera: Allow using camera modes declared in custom scaler maps Co-authored-by: Daniel Jacob Chittoor --- services/camera/libcameraservice/Android.bp | 4 +++ .../utils/SessionConfigurationUtils.cpp | 27 +++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/services/camera/libcameraservice/Android.bp b/services/camera/libcameraservice/Android.bp index 981c56942c..e8aa921dc2 100644 --- a/services/camera/libcameraservice/Android.bp +++ b/services/camera/libcameraservice/Android.bp @@ -38,6 +38,10 @@ license { cc_library_shared { name: "libcameraservice", + defaults: [ + "camera_custom_scaler_configuration_defaults", + ], + // Camera service source srcs: [ diff --git a/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp b/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp index eb45fbec26..e94935011f 100644 --- a/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp +++ b/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp @@ -159,15 +159,32 @@ bool roundBufferDimensionNearest(int32_t width, int32_t height, const int32_t heicSizesTag = getAppropriateModeTag(ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS, maxResolution); - camera_metadata_ro_entry streamConfigs = - (dataSpace == HAL_DATASPACE_DEPTH) ? info.find(depthSizesTag) : - (dataSpace == static_cast(HAL_DATASPACE_HEIF)) ? - info.find(heicSizesTag) : - info.find(scalerSizesTag); + + bool isDepth = dataSpace == HAL_DATASPACE_DEPTH; + bool isHeif = dataSpace == static_cast(HAL_DATASPACE_HEIF); + int32_t selectedTag = isDepth ? depthSizesTag : + isHeif ? heicSizesTag : scalerSizesTag; int32_t bestWidth = -1; int32_t bestHeight = -1; + camera_metadata_ro_entry streamConfigs = info.find(selectedTag); + + if (TARGET_CAMERA_CUSTOM_SCALER_CONFIGURATION != "" && selectedTag == scalerSizesTag) { + sp vTags; + sp cache = VendorTagDescriptorCache::getGlobalVendorTagCache(); + if (cache.get()) { + auto vendorId = const_cast(&info)->getVendorId(); + cache->getVendorTagDescriptor(vendorId, &vTags); + } + + uint32_t vendorTag; + status_t tagStatus = info.getTagFromName(TARGET_CAMERA_CUSTOM_SCALER_CONFIGURATION, vTags.get(), &vendorTag); + ALOGD("Tag by name %s %d %x", TARGET_CAMERA_CUSTOM_SCALER_CONFIGURATION, tagStatus, vendorTag); + if (tagStatus == OK) + streamConfigs = info.find(vendorTag); + } + // Iterate through listed stream configurations and find the one with the smallest euclidean // distance from the given dimensions for the given format. for (size_t i = 0; i < streamConfigs.count; i += 4) { -- GitLab