diff --git a/services/camera/libcameraservice/Android.bp b/services/camera/libcameraservice/Android.bp index 981c56942c37b66119eef07dab2360449b5289af..e8aa921dc24a464eb2b986b165cb1daca1a630f0 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 eb45fbec26f1fdef19c54763801856541d4d7d50..e94935011f46a073f83711385883c7885eb476a5 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) {