From 5f1245b993ffa1edd84163298b1ba6298cf54242 Mon Sep 17 00:00:00 2001 From: Chien-Yu Chen Date: Tue, 16 Feb 2016 14:28:50 -0800 Subject: [PATCH] Camera2: Fix getInternalFormatSizes for depth All depth formats are considered as non-high-res. Also compare depth minimum frame durations instead of regular minimum frame durations for depth formats. Bug: 26687093 Change-Id: I65b691fe450077b0e3ace15f6ac0289b41caf42f --- .../camera2/params/StreamConfigurationMap.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/java/android/hardware/camera2/params/StreamConfigurationMap.java b/core/java/android/hardware/camera2/params/StreamConfigurationMap.java index b8d69601976eb..e7b7bee7bffa0 100644 --- a/core/java/android/hardware/camera2/params/StreamConfigurationMap.java +++ b/core/java/android/hardware/camera2/params/StreamConfigurationMap.java @@ -1268,6 +1268,11 @@ public final class StreamConfigurationMap { private Size[] getInternalFormatSizes(int format, int dataspace, boolean output, boolean highRes) { + // All depth formats are non-high-res. + if (dataspace == HAL_DATASPACE_DEPTH && highRes) { + return new Size[0]; + } + SparseIntArray formatsMap = !output ? mInputFormats : dataspace == HAL_DATASPACE_DEPTH ? mDepthOutputFormats : @@ -1286,6 +1291,8 @@ public final class StreamConfigurationMap { StreamConfiguration[] configurations = (dataspace == HAL_DATASPACE_DEPTH) ? mDepthConfigurations : mConfigurations; + StreamConfigurationDuration[] minFrameDurations = + (dataspace == HAL_DATASPACE_DEPTH) ? mDepthMinFrameDurations : mMinFrameDurations; for (StreamConfiguration config : configurations) { int fmt = config.getFormat(); @@ -1294,8 +1301,8 @@ public final class StreamConfigurationMap { // Filter slow high-res output formats; include for // highRes, remove for !highRes long duration = 0; - for (int i = 0; i < mMinFrameDurations.length; i++) { - StreamConfigurationDuration d = mMinFrameDurations[i]; + for (int i = 0; i < minFrameDurations.length; i++) { + StreamConfigurationDuration d = minFrameDurations[i]; if (d.getFormat() == fmt && d.getWidth() == config.getSize().getWidth() && d.getHeight() == config.getSize().getHeight()) { @@ -1303,7 +1310,8 @@ public final class StreamConfigurationMap { break; } } - if (highRes != (duration > DURATION_20FPS_NS)) { + if (dataspace != HAL_DATASPACE_DEPTH && + highRes != (duration > DURATION_20FPS_NS)) { continue; } }