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

Commit dc6ac201 authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "support for time lapse/slow motion when using SURFACE source"

parents 323da101 2c9c8cba
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ public:
        INTERNAL_OPTION_REPEAT_PREVIOUS_FRAME_DELAY,  // data is an int64_t
        INTERNAL_OPTION_MAX_TIMESTAMP_GAP, // data is int64_t
        INTERNAL_OPTION_START_TIME, // data is an int64_t
        INTERNAL_OPTION_TIME_LAPSE, // data is an int64_t[2]
    };
    virtual status_t setInternalOption(
            node_id node,
+3 −0
Original line number Diff line number Diff line
@@ -207,6 +207,9 @@ private:
    int64_t mRepeatFrameDelayUs;
    int64_t mMaxPtsGapUs;

    int64_t mTimePerFrameUs;
    int64_t mTimePerCaptureUs;

    bool mCreateInputBuffersSuspended;

    status_t setCyclicIntraMacroblockRefresh(const sp<AMessage> &msg, int32_t mode);
+14 −3
Original line number Diff line number Diff line
@@ -690,10 +690,10 @@ status_t StagefrightRecorder::setParameter(
            return setParamTimeLapseEnable(timeLapseEnable);
        }
    } else if (key == "time-between-time-lapse-frame-capture") {
        int64_t timeBetweenTimeLapseFrameCaptureMs;
        if (safe_strtoi64(value.string(), &timeBetweenTimeLapseFrameCaptureMs)) {
        int64_t timeBetweenTimeLapseFrameCaptureUs;
        if (safe_strtoi64(value.string(), &timeBetweenTimeLapseFrameCaptureUs)) {
            return setParamTimeBetweenTimeLapseFrameCapture(
                    1000LL * timeBetweenTimeLapseFrameCaptureMs);
                    timeBetweenTimeLapseFrameCaptureUs);
        }
    } else {
        ALOGE("setParameter: failed to find key %s", key.string());
@@ -1436,6 +1436,17 @@ status_t StagefrightRecorder::setupVideoEncoder(
        format->setInt32("stride", mVideoWidth);
        format->setInt32("slice-height", mVideoWidth);
        format->setInt32("color-format", OMX_COLOR_FormatAndroidOpaque);

        // set up time lapse/slow motion for surface source
        if (mCaptureTimeLapse) {
            if (mTimeBetweenTimeLapseFrameCaptureUs <= 0) {
                ALOGE("Invalid mTimeBetweenTimeLapseFrameCaptureUs value: %lld",
                    mTimeBetweenTimeLapseFrameCaptureUs);
                return BAD_VALUE;
            }
            format->setInt64("time-lapse",
                    mTimeBetweenTimeLapseFrameCaptureUs);
        }
    }

    format->setInt32("bitrate", mVideoBitRate);
+31 −5
Original line number Diff line number Diff line
@@ -374,7 +374,9 @@ ACodec::ACodec()
      mStoreMetaDataInOutputBuffers(false),
      mMetaDataBuffersToSubmit(0),
      mRepeatFrameDelayUs(-1ll),
      mMaxPtsGapUs(-1l),
      mMaxPtsGapUs(-1ll),
      mTimePerCaptureUs(-1ll),
      mTimePerFrameUs(-1ll),
      mCreateInputBuffersSuspended(false) {
    mUninitializedState = new UninitializedState(this);
    mLoadedState = new LoadedState(this);
@@ -1119,7 +1121,11 @@ status_t ACodec::configureCodec(
        }

        if (!msg->findInt64("max-pts-gap-to-encoder", &mMaxPtsGapUs)) {
            mMaxPtsGapUs = -1l;
            mMaxPtsGapUs = -1ll;
        }

        if (!msg->findInt64("time-lapse", &mTimePerCaptureUs)) {
            mTimePerCaptureUs = -1ll;
        }

        if (!msg->findInt32(
@@ -1916,6 +1922,7 @@ status_t ACodec::setupVideoEncoder(const char *mime, const sp<AMessage> &msg) {
            return INVALID_OPERATION;
        }
        frameRate = (float)tmp;
        mTimePerFrameUs = (int64_t) (1000000.0f / frameRate);
    }

    video_def->xFramerate = (OMX_U32)(frameRate * 65536.0f);
@@ -3939,7 +3946,7 @@ void ACodec::LoadedState::onCreateInputSurface(
        }
    }

    if (err == OK && mCodec->mMaxPtsGapUs > 0l) {
    if (err == OK && mCodec->mMaxPtsGapUs > 0ll) {
        err = mCodec->mOMX->setInternalOption(
                mCodec->mNode,
                kPortIndexInput,
@@ -3954,6 +3961,25 @@ void ACodec::LoadedState::onCreateInputSurface(
        }
    }

    if (err == OK && mCodec->mTimePerCaptureUs > 0ll
            && mCodec->mTimePerFrameUs > 0ll) {
        int64_t timeLapse[2];
        timeLapse[0] = mCodec->mTimePerFrameUs;
        timeLapse[1] = mCodec->mTimePerCaptureUs;
        err = mCodec->mOMX->setInternalOption(
                mCodec->mNode,
                kPortIndexInput,
                IOMX::INTERNAL_OPTION_TIME_LAPSE,
                &timeLapse[0],
                sizeof(timeLapse));

        if (err != OK) {
            ALOGE("[%s] Unable to configure time lapse (err %d)",
                    mCodec->mComponentName.c_str(),
                    err);
        }
    }

    if (err == OK && mCodec->mCreateInputBuffersSuspended) {
        bool suspend = true;
        err = mCodec->mOMX->setInternalOption(
+5 −0
Original line number Diff line number Diff line
@@ -452,6 +452,11 @@ void convertMessageToMetaData(const sp<AMessage> &msg, sp<MetaData> &meta) {
        }
    }

    int32_t timeScale;
    if (msg->findInt32("time-scale", &timeScale)) {
        meta->setInt32(kKeyTimeScale, timeScale);
    }

    // XXX TODO add whatever other keys there are

#if 0
Loading