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

Commit e70044b7 authored by Riaz Rahaman's avatar Riaz Rahaman Committed by Steve Kondik
Browse files

libstagefright: In thumbnail mode set EOS on first frame

- Hardware decoder will only expect I frames, OMXCodec will
  set EOS on first ETB to stop more frames from being pulled
- Skip EOS check on FTB so that the first frame will be
  handled

Change-Id: I74638a56891bd484a7529349c3b8433dd2009a88
parent bc0500fd
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -1570,6 +1570,7 @@ OMXCodec::OMXCodec(
      mState(LOADED),
      mInitialBufferSubmit(true),
      mSignalledEOS(false),
      mFinalStatus(OK),
      mNoMoreOutputData(false),
      mOutputPortSettingsHaveChanged(false),
      mSeekTimeUs(-1),
@@ -3202,6 +3203,13 @@ void OMXCodec::fillOutputBuffers() {
    // end-of-output-stream. If we own all input buffers and also own
    // all output buffers and we already signalled end-of-input-stream,
    // the end-of-output-stream is implied.

    // NOTE: Thumbnail mode needs a call to fillOutputBuffer in order
    // to get the decoded frame from the component. Currently,
    // thumbnail mode calls emptyBuffer with an EOS flag on its first
    // frame and sets mSignalledEOS to true, so without the check for
    // !mThumbnailMode, fillOutputBuffer will never be called.
    if(!QCUtils::checkIsThumbNailMode(mFlags, mComponentName)) {
        if (mSignalledEOS
            && countBuffersWeOwn(mPortBuffers[kPortIndexInput])
                == mPortBuffers[kPortIndexInput].size()
@@ -3212,6 +3220,7 @@ void OMXCodec::fillOutputBuffers() {

            return;
        }
    }

    Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexOutput];
    for (size_t i = 0; i < buffers->size(); ++i) {
@@ -3557,6 +3566,18 @@ bool OMXCodec::drainInputBuffer(BufferInfo *info) {

    if (signalEOS) {
        flags |= OMX_BUFFERFLAG_EOS;
    } else if(QCUtils::checkIsThumbNailMode(mFlags, mComponentName)) {
        // Because we don't get an EOS after getting the first frame, we
        // need to notify the component with OMX_BUFFERFLAG_EOS, set
        // mNoMoreOutputData to false so fillOutputBuffer gets called on
        // the first output buffer (see comment in fillOutputBuffer), and
        // mSignalledEOS must be true so drainInputBuffer is not executed
        // on extra frames. Setting mFinalStatus to ERROR_END_OF_STREAM as
        // we dont want to return OK and NULL buffer in read.
        flags |= OMX_BUFFERFLAG_EOS;
        mNoMoreOutputData = false;
        mSignalledEOS = true;
        mFinalStatus = ERROR_END_OF_STREAM;
    } else {
        mNoMoreOutputData = false;
    }
+12 −0
Original line number Diff line number Diff line
@@ -399,6 +399,14 @@ void QCUtils::updateNativeWindowBufferGeometry(ANativeWindow* anw,
    }
}

bool QCUtils::checkIsThumbNailMode(const uint32_t flags, char* componentName) {
    bool isInThumbnailMode = false;
    if ((flags & OMXCodec::kClientNeedsFramebuffer) && !strncmp(componentName, "OMX.qcom.", 9)) {
        isInThumbnailMode = true;
    }
    return isInThumbnailMode;
}

}

#else //ENABLE_QC_AV_ENHANCEMENTS
@@ -466,5 +474,9 @@ void QCUtils::updateNativeWindowBufferGeometry(ANativeWindow* anw,
        OMX_U32 width, OMX_U32 height, OMX_COLOR_FORMATTYPE colorFormat) {
}

bool QCUtils::checkIsThumbNailMode(const uint32_t flags, char* componentName) {
    return false;
}

}
#endif //ENABLE_QC_AV_ENHANCEMENTS
+2 −0
Original line number Diff line number Diff line
@@ -118,6 +118,8 @@ struct QCUtils {
    //notify stride change to ANW
    static void updateNativeWindowBufferGeometry(ANativeWindow* anw,
            OMX_U32 width, OMX_U32 height, OMX_COLOR_FORMATTYPE colorFormat);

    static bool checkIsThumbNailMode(const uint32_t flags, char* componentName);
};

}