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

Commit 9770ab51 authored by Rucha Katakwar's avatar Rucha Katakwar Committed by Android (Google) Code Review
Browse files

Merge "Camera: Support 60fps during constrained HFR."

parents 411c2f45 6e6505f7
Loading
Loading
Loading
Loading
+30 −4
Original line number Diff line number Diff line
@@ -30,9 +30,11 @@ import android.hardware.camera2.utils.SurfaceUtils;
import android.os.Handler;
import android.os.ConditionVariable;
import android.util.Range;
import android.util.Log;
import android.view.Surface;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -56,6 +58,7 @@ public class CameraConstrainedHighSpeedCaptureSessionImpl
    private final CameraCharacteristics mCharacteristics;
    private final CameraCaptureSessionImpl mSessionImpl;
    private final ConditionVariable mInitialized = new ConditionVariable();
    private final String TAG = "CameraConstrainedHighSpeedCaptureSessionImpl";

    /**
     * Create a new CameraCaptureSession.
@@ -95,10 +98,33 @@ public class CameraConstrainedHighSpeedCaptureSessionImpl
        StreamConfigurationMap config = mCharacteristics.get(ck);
        SurfaceUtils.checkConstrainedHighSpeedSurfaces(outputSurfaces, fpsRange, config);

        // Request list size: to limit the preview to 30fps, need use maxFps/30; to maximize
        // the preview frame rate, should use maxBatch size for that high speed stream
        // configuration. We choose the former for now.
        int requestListSize = fpsRange.getUpper() / 30;
        // Check the high speed video fps ranges for video size and find the min value from the list
        // and assign it to previewFps which will be used to calculate the requestList size.
        Range<Integer>[] highSpeedFpsRanges = config.getHighSpeedVideoFpsRangesFor(
                SurfaceUtils.getSurfaceSize(outputSurfaces.iterator().next()));
        Log.v(TAG, "High speed fps ranges: " + Arrays.toString(highSpeedFpsRanges));
        int previewFps = Integer.MAX_VALUE;
        for (Range<Integer> range : highSpeedFpsRanges) {
            int rangeMin = range.getLower();
            if (previewFps > rangeMin) {
                previewFps = rangeMin;
            }
        }
        // Since we only want to support 60fps apart from 30fps, if the min value is not 60,
        // then continue to calculate the requestList size using value 30.
        if (previewFps != 60 && previewFps != 30) {
            Log.w(TAG, "previewFps is neither 60 nor 30.");
            previewFps = 30;
        }
        Log.v(TAG, "previewFps: " + previewFps);

        int requestListSize = fpsRange.getUpper() / previewFps;
        // If it's a preview, keep requestList size fixed = 1.
        if (fpsRange.getUpper() > fpsRange.getLower()) {
            requestListSize = 1;
        }

        Log.v(TAG, "Request list size is: " + requestListSize);
        List<CaptureRequest> requestList = new ArrayList<CaptureRequest>();

        // Prepare the Request builders: need carry over the request controls.