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

Commit af6b79f9 authored by ApurupaPattapu's avatar ApurupaPattapu Committed by Steve Kondik
Browse files

libstagefright: Smooth Streaming in OMXCodec

This change is to address startup latency during playback.

Set smooth-streaming mode from OMXCodec by default
if mm.enable.smoothstreaming property is enabled

When crop change is detected, save the target crop/stride and apply
them just before the buffer is (potentially) rendered.
Applying the updates right away may cause artifacts as buffers with
previous resolution are not rendered yet.

This approach assumes that there will not be a crop change within
the detection and application of current crop

CRs-Fixed: 584629

Change-Id: Ia164309edf1c51ed28b929deabecc53fc56cbf33
parent da25dec2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ private:
        size_t mSize;
        void *mData;
        MediaBuffer *mMediaBuffer;
        bool mOutputCropChanged;
    };

    struct CodecSpecificData {
@@ -382,8 +383,9 @@ private:

#ifdef QCOM_HARDWARE
    int32_t mNumBFrames;
    bool mInSmoothStreamingMode;
#endif
    bool mInSmoothStreamingMode;
    bool mOutputCropChanged;
};

struct CodecCapabilities {
+0 −24
Original line number Diff line number Diff line
@@ -384,12 +384,7 @@ ACodec::ACodec()
      mDequeueCounter(0),
      mStoreMetaDataInOutputBuffers(false),
      mMetaDataBuffersToSubmit(0),
#ifdef QCOM_HARDWARE
      mRepeatFrameDelayUs(-1ll),
      mInSmoothStreamingMode(false) {
#else
      mRepeatFrameDelayUs(-1ll) {
#endif
    mUninitializedState = new UninitializedState(this);
    mLoadedState = new LoadedState(this);
    mLoadedToIdleState = new LoadedToIdleState(this);
@@ -1880,11 +1875,6 @@ status_t ACodec::setupVideoDecoder(
        return err;
    }

#ifdef QCOM_HARDWARE
    ExtendedCodec::enableSmoothStreaming(
            mOMX, mNode, &mInSmoothStreamingMode, mComponentName.c_str());
#endif

    return OK;
}

@@ -2666,11 +2656,6 @@ void ACodec::sendFormatChange(const sp<AMessage> &reply) {
                            rect.nTop,
                            rect.nLeft + rect.nWidth,
                            rect.nTop + rect.nHeight);
#ifdef QCOM_HARDWARE
                    reply->setInt32(
                            "color-format",
                            (int)(videoDef->eColorFormat));
#endif
                }
            }
            break;
@@ -3561,15 +3546,6 @@ void ACodec::BaseState::onOutputBufferDrained(const sp<AMessage> &msg) {
    android_native_rect_t crop;
    if (msg->findRect("crop",
            &crop.left, &crop.top, &crop.right, &crop.bottom)) {
#ifdef QCOM_HARDWARE
        if (mCodec->mInSmoothStreamingMode) {
            OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused;
            CHECK(msg->findInt32("color-format", (int32_t*)&eColorFormat));
            ExtendedUtils::updateNativeWindowBufferGeometry(
                    mCodec->mNativeWindow.get(), crop.right,
                    crop.bottom, eColorFormat);
        }
#endif
        CHECK_EQ(0, native_window_set_crop(
                mCodec->mNativeWindow.get(), &crop));
    }
+17 −12
Original line number Diff line number Diff line
@@ -1710,13 +1710,12 @@ OMXCodec::OMXCodec(
      mPaused(false),
      mNativeWindow(
              (!strncmp(componentName, "OMX.google.", 11))
#ifdef QCOM_HARDWARE
                        ? NULL : nativeWindow),
#ifdef QCOM_HARDWARE
      mNumBFrames(0),
      mInSmoothStreamingMode(false) {
#else
                        ? NULL : nativeWindow) {
#endif
      mInSmoothStreamingMode(false),
      mOutputCropChanged(false) {
    mPortStatus[kPortIndexInput] = ENABLED;
    mPortStatus[kPortIndexOutput] = ENABLED;

@@ -1999,6 +1998,7 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
        info.mStatus = OWNED_BY_US;
        info.mMem = mem;
        info.mMediaBuffer = NULL;
        info.mOutputCropChanged = false;

        if (portIndex == kPortIndexOutput) {
            if (!(mOMXLivesLocally
@@ -2719,6 +2719,10 @@ void OMXCodec::on_message(const omx_message &msg) {
                    mTargetTimeUs = -1;
                }

                if (mOutputCropChanged) {
                    mOutputCropChanged = false;
                    info->mOutputCropChanged = true;
                }
                mFilledBuffers.push_back(i);
                mBufferFilled.signal();
                if (mIsEncoder) {
@@ -4539,6 +4543,10 @@ status_t OMXCodec::read(
    }
    *buffer = info->mMediaBuffer;

    if (info->mOutputCropChanged) {
        initNativeWindowCrop();
        info->mOutputCropChanged = false;
    }
    return OK;
}

@@ -5166,15 +5174,12 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
                }

                if (mNativeWindow != NULL) {
#ifdef QCOM_HARDWARE
                     if (mInSmoothStreamingMode) {
                        ExtendedUtils::updateNativeWindowBufferGeometry(
                                mNativeWindow.get(), video_def->nFrameWidth,
                                video_def->nFrameHeight, video_def->eColorFormat);
                    }
#endif
                         mOutputCropChanged = true;
                     } else {
                         initNativeWindowCrop();
                     }
                }
#ifdef QCOM_HARDWARE
            } else {
                ExtendedUtils::HFR::copyHFRParams(inputFormat, mOutputFormat);