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

Commit cbe1bfea authored by Pawin Vongmasa's avatar Pawin Vongmasa Committed by android-build-merger
Browse files

Merge "Make IGraphicBufferSource::setTimeLapseConfig take fps" into oc-dev am: 3498c386

am: e21c4053

Change-Id: I402d99085dea210c55a2ace5ec40b6e0f37de1a5
parents 701647f4 e21c4053
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -67,14 +67,11 @@ typedef ::android::hardware::media::omx::V1_0::IGraphicBufferSource
struct LWGraphicBufferSource : public BnGraphicBufferSource {
    sp<TGraphicBufferSource> mBase;
    LWGraphicBufferSource(sp<TGraphicBufferSource> const& base);
    BnStatus configure(
            const sp<IOMXNode>& omxNode, int32_t dataSpace) override;
    BnStatus configure(const sp<IOMXNode>& omxNode, int32_t dataSpace) override;
    BnStatus setSuspend(bool suspend, int64_t timeUs) override;
    BnStatus setRepeatPreviousFrameDelayUs(
            int64_t repeatAfterUs) override;
    BnStatus setRepeatPreviousFrameDelayUs(int64_t repeatAfterUs) override;
    BnStatus setMaxFps(float maxFps) override;
    BnStatus setTimeLapseConfig(
            int64_t timePerFrameUs, int64_t timePerCaptureUs) override;
    BnStatus setTimeLapseConfig(double fps, double captureFps) override;
    BnStatus setStartTimeUs(int64_t startTimeUs) override;
    BnStatus setStopTimeUs(int64_t stopTimeUs) override;
    BnStatus setColorAspects(int32_t aspects) override;
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ interface IGraphicBufferSource {
    void setSuspend(boolean suspend, long suspendTimeUs);
    void setRepeatPreviousFrameDelayUs(long repeatAfterUs);
    void setMaxFps(float maxFps);
    void setTimeLapseConfig(long timePerFrameUs, long timePerCaptureUs);
    void setTimeLapseConfig(double fps, double captureFps);
    void setStartTimeUs(long startTimeUs);
    void setStopTimeUs(long stopTimeUs);
    void setColorAspects(int aspects);
+2 −3
Original line number Diff line number Diff line
@@ -53,9 +53,8 @@ BnStatus LWGraphicBufferSource::setMaxFps(float maxFps) {
}

BnStatus LWGraphicBufferSource::setTimeLapseConfig(
        int64_t timePerFrameUs, int64_t timePerCaptureUs) {
    return toBinderStatus(mBase->setTimeLapseConfig(
            timePerFrameUs, timePerCaptureUs));
        double fps, double captureFps) {
    return toBinderStatus(mBase->setTimeLapseConfig(fps, captureFps));
}

BnStatus LWGraphicBufferSource::setStartTimeUs(
+10 −20
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ void StagefrightRecorder::updateMetrics() {
    // TBD mTrackEveryTimeDurationUs = 0;
    mAnalyticsItem->setInt32(kRecorderCaptureFpsEnable, mCaptureFpsEnable);
    mAnalyticsItem->setDouble(kRecorderCaptureFps, mCaptureFps);
    // TBD mTimeBetweenCaptureUs = -1;
    // TBD mCaptureFps = -1.0;
    // TBD mCameraSourceTimeLapse = NULL;
    // TBD mMetaDataStoredInVideoBuffers = kMetadataBufferTypeInvalid;
    // TBD mEncoderProfiles = MediaProfiles::getInstance();
@@ -709,18 +709,11 @@ status_t StagefrightRecorder::setParamCaptureFpsEnable(int32_t captureFpsEnable)
status_t StagefrightRecorder::setParamCaptureFps(double fps) {
    ALOGV("setParamCaptureFps: %.2f", fps);

    // FPS value is from Java layer where double follows IEEE-754, which is not
    // necessarily true for double here.
    constexpr double kIeee754Epsilon = 2.220446049250313e-16;
    constexpr double kEpsilon = std::max(std::numeric_limits<double>::epsilon(), kIeee754Epsilon);
    // Not allowing fps less than 1 frame / day minus epsilon.
    if (fps < 1.0 / 86400 - kEpsilon) {
        ALOGE("fps (%lf) is out of range (>= 1 frame / day)", fps);
    if (!(fps >= 1.0 / 86400)) {
        ALOGE("FPS is too small");
        return BAD_VALUE;
    }

    mCaptureFps = fps;
    mTimeBetweenCaptureUs = std::llround(1e6 / fps);
    return OK;
}

@@ -1574,16 +1567,15 @@ status_t StagefrightRecorder::setupCameraSource(
    videoSize.width = mVideoWidth;
    videoSize.height = mVideoHeight;
    if (mCaptureFpsEnable) {
        if (mTimeBetweenCaptureUs < 0) {
            ALOGE("Invalid mTimeBetweenTimeLapseFrameCaptureUs value: %lld",
                    (long long)mTimeBetweenCaptureUs);
        if (!(mCaptureFps > 0.)) {
            ALOGE("Invalid mCaptureFps value: %lf", mCaptureFps);
            return BAD_VALUE;
        }

        mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera(
                mCamera, mCameraProxy, mCameraId, mClientName, mClientUid, mClientPid,
                videoSize, mFrameRate, mPreviewSurface,
                mTimeBetweenCaptureUs);
                std::llround(1e6 / mCaptureFps));
        *cameraSource = mCameraSourceTimeLapse;
    } else {
        *cameraSource = CameraSource::CreateFromCamera(
@@ -1679,12 +1671,11 @@ status_t StagefrightRecorder::setupVideoEncoder(

        // set up time lapse/slow motion for surface source
        if (mCaptureFpsEnable) {
            if (mTimeBetweenCaptureUs <= 0) {
                ALOGE("Invalid mTimeBetweenCaptureUs value: %lld",
                        (long long)mTimeBetweenCaptureUs);
            if (!(mCaptureFps > 0.)) {
                ALOGE("Invalid mCaptureFps value: %lf", mCaptureFps);
                return BAD_VALUE;
            }
            format->setInt64("time-lapse", mTimeBetweenCaptureUs);
            format->setDouble("time-lapse-fps", mCaptureFps);
        }
    }

@@ -2077,8 +2068,7 @@ status_t StagefrightRecorder::reset() {
    mMaxFileSizeBytes = 0;
    mTrackEveryTimeDurationUs = 0;
    mCaptureFpsEnable = false;
    mCaptureFps = 0.0;
    mTimeBetweenCaptureUs = -1;
    mCaptureFps = -1.0;
    mCameraSourceTimeLapse = NULL;
    mMetaDataStoredInVideoBuffers = kMetadataBufferTypeInvalid;
    mEncoderProfiles = MediaProfiles::getInstance();
+12 −12
Original line number Diff line number Diff line
@@ -546,8 +546,8 @@ ACodec::ACodec()
      mRepeatFrameDelayUs(-1ll),
      mMaxPtsGapUs(-1ll),
      mMaxFps(-1),
      mTimePerFrameUs(-1ll),
      mTimePerCaptureUs(-1ll),
      mFps(-1.0),
      mCaptureFps(-1.0),
      mCreateInputBuffersSuspended(false),
      mLatency(0),
      mTunneled(false),
@@ -1802,8 +1802,8 @@ status_t ACodec::configureCodec(
            mMaxFps = -1;
        }

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

        if (!msg->findInt32(
@@ -3739,17 +3739,18 @@ status_t ACodec::setupVideoEncoder(

    def.nBufferSize = (video_def->nStride * video_def->nSliceHeight * 3) / 2;

    float frameRate;
    if (!msg->findFloat("frame-rate", &frameRate)) {
    float framerate;
    if (!msg->findFloat("frame-rate", &framerate)) {
        int32_t tmp;
        if (!msg->findInt32("frame-rate", &tmp)) {
            return INVALID_OPERATION;
        }
        frameRate = (float)tmp;
        mTimePerFrameUs = (int64_t) (1000000.0f / frameRate);
        mFps = (double)tmp;
    } else {
        mFps = (double)framerate;
    }

    video_def->xFramerate = (OMX_U32)(frameRate * 65536.0f);
    video_def->xFramerate = (OMX_U32)(mFps * 65536);
    video_def->eCompressionFormat = OMX_VIDEO_CodingUnused;
    // this is redundant as it was already set up in setVideoPortFormatType
    // FIXME for now skip this only for flexible YUV formats
@@ -6597,11 +6598,10 @@ status_t ACodec::LoadedState::setupInputSurface() {
        }
    }

    if (mCodec->mTimePerCaptureUs > 0ll
            && mCodec->mTimePerFrameUs > 0ll) {
    if (mCodec->mCaptureFps > 0. && mCodec->mFps > 0.) {
        err = statusFromBinderStatus(
                mCodec->mGraphicBufferSource->setTimeLapseConfig(
                        mCodec->mTimePerFrameUs, mCodec->mTimePerCaptureUs));
                        mCodec->mFps, mCodec->mCaptureFps));

        if (err != OK) {
            ALOGE("[%s] Unable to configure time lapse (err %d)",
Loading