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

Commit 1381a707 authored by Paras Nagda's avatar Paras Nagda Committed by Michael Bestas
Browse files

stagefright: add changes related to high-framerates in CameraSource

Below changes are squashed with this change.

Stagefright: Allow setting high-framerates in CameraSource
ChangeId: If66211dd81b2a08d4df4c6f23e87304e9e7013f4

Stagefright: Allow setting of high-framerates in CameraSource for HSR
ChangeId: I30cb3b656570de1b615d55c20c0b4f98ae6e0c12

Stagefright: Create CameraSource for HSR
ChangeId: I7f420f5b15fb3c05bb7f918430ca9b7a630ed18e

Stagefright: Do not skip frames in time-lapse-source for high-speed
ChangeId: I8420e44ab96484f0d6301c366a24eefc8efeaf0f

media : Changing time stamp manipulation in HFR recording.
ChangeId: I98cdb14bb2b9c86013df9b2c8f2e558f184b633e

media: Modify timestamps for HFR use case
ChangeId: I3faf7294f743b1031ccc6624c3348f7e12b339b8

CRs-Fixed: 2226740

Change-Id: I079d880252992b94bd78ac43aed732f5000175d3
parent 7769ed5a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1617,7 +1617,7 @@ status_t StagefrightRecorder::setupCameraSource(
    Size videoSize;
    videoSize.width = mVideoWidth;
    videoSize.height = mVideoHeight;
    if (mCaptureFpsEnable) {
    if (mCaptureFpsEnable && mCaptureFps != mFrameRate) {
        if (!(mCaptureFps > 0.)) {
            ALOGE("Invalid mCaptureFps value: %lf", mCaptureFps);
            return BAD_VALUE;
@@ -1765,6 +1765,7 @@ status_t StagefrightRecorder::setupVideoEncoder(
            preferBFrames = false;
            tsLayers = 2; // use at least two layers as resulting video will likely be sped up
        } else if (mCaptureFps > maxPlaybackFps) { // slow-mo
            format->setInt32("high-frame-rate", 1);
            maxPlaybackFps = mCaptureFps; // assume video will be played back at full capture speed
            preferBFrames = false;
        }
+13 −1
Original line number Diff line number Diff line
@@ -342,6 +342,12 @@ status_t CameraSource::isCameraColorFormatSupported(
    return OK;
}

static int32_t getHighSpeedFrameRate(const CameraParameters& params) {
    const char* hsr = params.get("video-hsr");
    int32_t rate = (hsr != NULL && strncmp(hsr, "off", 3)) ? strtol(hsr, NULL, 10) : 0;
    return std::min(rate, 240);
}

/*
 * Configure the camera to use the requested video size
 * (width and height) and/or frame rate. If both width and
@@ -389,11 +395,15 @@ status_t CameraSource::configureCamera(
    }

    if (frameRate != -1) {
        CHECK(frameRate > 0 && frameRate <= 120);
        CHECK(frameRate > 0 && frameRate <= 240);
        const char* supportedFrameRates =
                params->get(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES);
        CHECK(supportedFrameRates != NULL);
        ALOGV("Supported frame rates: %s", supportedFrameRates);
        if (getHighSpeedFrameRate(*params)) {
            ALOGI("Use default 30fps for HighSpeed %dfps", frameRate);
            frameRate = 30;
        }
        char buf[4];
        snprintf(buf, 4, "%d", frameRate);
        if (strstr(supportedFrameRates, buf) == NULL) {
@@ -495,6 +505,8 @@ status_t CameraSource::checkFrameRate(
        ALOGE("Failed to retrieve preview frame rate (%d)", frameRateActual);
        return UNKNOWN_ERROR;
    }
    int32_t highSpeedRate = getHighSpeedFrameRate(params);
    frameRateActual = highSpeedRate ? highSpeedRate : frameRateActual;

    // Check the actual video frame rate against the target/requested
    // video frame rate.
+8 −1
Original line number Diff line number Diff line
@@ -298,7 +298,8 @@ bool CameraSourceTimeLapse::skipFrameAndModifyTimeStamp(int64_t *timestampUs) {
    // The first 2 output frames from the encoder are: decoder specific info and
    // the compressed video frame data for the first input video frame.
    if (mNumFramesEncoded >= 1 && *timestampUs <
        (mLastTimeLapseFrameRealTimestampUs + mTimeBetweenFrameCaptureUs)) {
        (mLastTimeLapseFrameRealTimestampUs + mTimeBetweenFrameCaptureUs) &&
        (mTimeBetweenFrameCaptureUs > mTimeBetweenTimeLapseVideoFramesUs + 1)) {
        // Skip all frames from last encoded frame until
        // sufficient time (mTimeBetweenFrameCaptureUs) has passed.
        // Tell the camera to release its recording frame and return.
@@ -313,6 +314,12 @@ bool CameraSourceTimeLapse::skipFrameAndModifyTimeStamp(int64_t *timestampUs) {

        mLastTimeLapseFrameRealTimestampUs = *timestampUs;
        *timestampUs = mLastFrameTimestampUs + mTimeBetweenTimeLapseVideoFramesUs;
        // Update start-time once the captured-time reaches the expected start-time.
        // Not doing so will result in CameraSource always dropping frames since
        // updated-timestamp will never intersect start-timestamp
        if ((mNumFramesReceived == 0 && mLastTimeLapseFrameRealTimestampUs >= mStartTimeUs)) {
            mStartTimeUs = *timestampUs;
        }
        return false;
    }
    return false;