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

Commit 0faa814f authored by Harish Mahendrakar's avatar Harish Mahendrakar
Browse files

Codecs: Fix EOS handling in soft codecs

When EOS is sent along with non-zero length input buffer and if decoder
was still not producing output, due to initial latency, then decoder
would not produce any output. For eg. When only one input buffer with EOS
set is sent to the decoder, decoder was not producing any output.

Applies for SoftHEVC, SoftAVC and SoftMpeg2 decoders.

Bug: 28965335

Change-Id: Ic3a3bb479f9612042afcf02e6fda05c63ce84d70
parent 945da9bb
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -492,16 +492,6 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
    List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
    List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);

    /* If input EOS is seen and decoder is not in flush mode,
     * set the decoder in flush mode.
     * There can be a case where EOS is sent along with last picture data
     * In that case, only after decoding that input data, decoder has to be
     * put in flush. This case is handled here  */

    if (mReceivedEOS && !mIsInFlush) {
        setFlushMode();
    }

    while (!outQueue.empty()) {
        BufferInfo *inInfo;
        OMX_BUFFERHEADERTYPE *inHeader;
@@ -664,7 +654,7 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
                outInfo = NULL;
                notifyFillBufferDone(outHeader);
                outHeader = NULL;
            } else {
            } else if (mIsInFlush) {
                /* If in flush mode and no output is returned by the codec,
                 * then come out of flush mode */
                mIsInFlush = false;
@@ -685,6 +675,16 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
            }
        }

        /* If input EOS is seen and decoder is not in flush mode,
         * set the decoder in flush mode.
         * There can be a case where EOS is sent along with last picture data
         * In that case, only after decoding that input data, decoder has to be
         * put in flush. This case is handled here  */

        if (mReceivedEOS && !mIsInFlush) {
            setFlushMode();
        }

        if (inHeader != NULL) {
            inInfo->mOwnedByUs = false;
            inQueue.erase(inQueue.begin());
+11 −11
Original line number Diff line number Diff line
@@ -451,16 +451,6 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
    List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
    List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);

    /* If input EOS is seen and decoder is not in flush mode,
     * set the decoder in flush mode.
     * There can be a case where EOS is sent along with last picture data
     * In that case, only after decoding that input data, decoder has to be
     * put in flush. This case is handled here  */

    if (mReceivedEOS && !mIsInFlush) {
        setFlushMode();
    }

    while (!outQueue.empty()) {
        BufferInfo *inInfo;
        OMX_BUFFERHEADERTYPE *inHeader;
@@ -590,7 +580,7 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
                outInfo = NULL;
                notifyFillBufferDone(outHeader);
                outHeader = NULL;
            } else {
            } else if (mIsInFlush) {
                /* If in flush mode and no output is returned by the codec,
                 * then come out of flush mode */
                mIsInFlush = false;
@@ -611,6 +601,16 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
            }
        }

        /* If input EOS is seen and decoder is not in flush mode,
         * set the decoder in flush mode.
         * There can be a case where EOS is sent along with last picture data
         * In that case, only after decoding that input data, decoder has to be
         * put in flush. This case is handled here  */

        if (mReceivedEOS && !mIsInFlush) {
            setFlushMode();
        }

        // TODO: Handle more than one picture data
        if (inHeader != NULL) {
            inInfo->mOwnedByUs = false;
+11 −11
Original line number Diff line number Diff line
@@ -553,16 +553,6 @@ void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) {
        setParams(mStride);
    }

    /* If input EOS is seen and decoder is not in flush mode,
     * set the decoder in flush mode.
     * There can be a case where EOS is sent along with last picture data
     * In that case, only after decoding that input data, decoder has to be
     * put in flush. This case is handled here  */

    if (mReceivedEOS && !mIsInFlush) {
        setFlushMode();
    }

    while (!outQueue.empty()) {
        BufferInfo *inInfo;
        OMX_BUFFERHEADERTYPE *inHeader;
@@ -742,7 +732,7 @@ void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) {
                    notifyFillBufferDone(outHeader);
                    outHeader = NULL;
                }
            } else {
            } else if (mIsInFlush) {
                /* If in flush mode and no output is returned by the codec,
                 * then come out of flush mode */
                mIsInFlush = false;
@@ -763,6 +753,16 @@ void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) {
            }
        }

        /* If input EOS is seen and decoder is not in flush mode,
         * set the decoder in flush mode.
         * There can be a case where EOS is sent along with last picture data
         * In that case, only after decoding that input data, decoder has to be
         * put in flush. This case is handled here  */

        if (mReceivedEOS && !mIsInFlush) {
            setFlushMode();
        }

        // TODO: Handle more than one picture data
        if (inHeader != NULL) {
            inInfo->mOwnedByUs = false;