Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f1245b9 authored by Chien-Yu Chen's avatar Chien-Yu Chen
Browse files

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
parent a1e8ceb5
Loading
Loading
Loading
Loading
+11 −3
Original line number Original line Diff line number Diff line
@@ -1268,6 +1268,11 @@ public final class StreamConfigurationMap {


    private Size[] getInternalFormatSizes(int format, int dataspace,
    private Size[] getInternalFormatSizes(int format, int dataspace,
            boolean output, boolean highRes) {
            boolean output, boolean highRes) {
        // All depth formats are non-high-res.
        if (dataspace == HAL_DATASPACE_DEPTH && highRes) {
            return new Size[0];
        }

        SparseIntArray formatsMap =
        SparseIntArray formatsMap =
                !output ? mInputFormats :
                !output ? mInputFormats :
                dataspace == HAL_DATASPACE_DEPTH ? mDepthOutputFormats :
                dataspace == HAL_DATASPACE_DEPTH ? mDepthOutputFormats :
@@ -1286,6 +1291,8 @@ public final class StreamConfigurationMap {


        StreamConfiguration[] configurations =
        StreamConfiguration[] configurations =
                (dataspace == HAL_DATASPACE_DEPTH) ? mDepthConfigurations : mConfigurations;
                (dataspace == HAL_DATASPACE_DEPTH) ? mDepthConfigurations : mConfigurations;
        StreamConfigurationDuration[] minFrameDurations =
                (dataspace == HAL_DATASPACE_DEPTH) ? mDepthMinFrameDurations : mMinFrameDurations;


        for (StreamConfiguration config : configurations) {
        for (StreamConfiguration config : configurations) {
            int fmt = config.getFormat();
            int fmt = config.getFormat();
@@ -1294,8 +1301,8 @@ public final class StreamConfigurationMap {
                    // Filter slow high-res output formats; include for
                    // Filter slow high-res output formats; include for
                    // highRes, remove for !highRes
                    // highRes, remove for !highRes
                    long duration = 0;
                    long duration = 0;
                    for (int i = 0; i < mMinFrameDurations.length; i++) {
                    for (int i = 0; i < minFrameDurations.length; i++) {
                        StreamConfigurationDuration d = mMinFrameDurations[i];
                        StreamConfigurationDuration d = minFrameDurations[i];
                        if (d.getFormat() == fmt &&
                        if (d.getFormat() == fmt &&
                                d.getWidth() == config.getSize().getWidth() &&
                                d.getWidth() == config.getSize().getWidth() &&
                                d.getHeight() == config.getSize().getHeight()) {
                                d.getHeight() == config.getSize().getHeight()) {
@@ -1303,7 +1310,8 @@ public final class StreamConfigurationMap {
                            break;
                            break;
                        }
                        }
                    }
                    }
                    if (highRes != (duration > DURATION_20FPS_NS)) {
                    if (dataspace != HAL_DATASPACE_DEPTH &&
                            highRes != (duration > DURATION_20FPS_NS)) {
                        continue;
                        continue;
                    }
                    }
                }
                }