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

Commit ba46fa93 authored by Harish Mahendrakar's avatar Harish Mahendrakar Committed by android-build-merger
Browse files

Merge "SoftAVCDec: Handle interlaced streams where two fields are sent in one input"

am: 460dcb75

Change-Id: I8dc483438793d73cbe2b403c085da5310740562f
parents 0f3445be 460dcb75
Loading
Loading
Loading
Loading
+24 −24
Original line number Diff line number Diff line
@@ -120,7 +120,8 @@ SoftAVC::SoftAVC(
      mIvColorFormat(IV_YUV_420P),
      mChangingResolution(false),
      mSignalledError(false),
      mStride(mWidth){
      mStride(mWidth),
      mInputOffset(0){
    initPorts(
            1 /* numMinInputBuffers */, kNumBuffers, INPUT_BUF_SIZE,
            1 /* numMinOutputBuffers */, kNumBuffers, CODEC_MIME_TYPE);
@@ -215,6 +216,7 @@ status_t SoftAVC::setParams(size_t stride) {
status_t SoftAVC::resetPlugin() {
    mIsInFlush = false;
    mReceivedEOS = false;
    mInputOffset = 0;
    memset(mTimeStamps, 0, sizeof(mTimeStamps));
    memset(mTimeStampsValid, 0, sizeof(mTimeStampsValid));

@@ -443,8 +445,8 @@ bool SoftAVC::setDecodeArgs(
    if (inHeader) {
        ps_dec_ip->u4_ts = timeStampIx;
        ps_dec_ip->pv_stream_buffer =
            inHeader->pBuffer + inHeader->nOffset;
        ps_dec_ip->u4_num_Bytes = inHeader->nFilledLen;
            inHeader->pBuffer + inHeader->nOffset + mInputOffset;
        ps_dec_ip->u4_num_Bytes = inHeader->nFilledLen - mInputOffset;
    } else {
        ps_dec_ip->u4_ts = 0;
        ps_dec_ip->pv_stream_buffer = NULL;
@@ -515,6 +517,8 @@ void SoftAVC::onPortFlushCompleted(OMX_U32 portIndex) {

void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
    UNUSED(portIndex);
    OMX_BUFFERHEADERTYPE *inHeader = NULL;
    BufferInfo *inInfo = NULL;

    if (mSignalledError) {
        return;
@@ -541,17 +545,11 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
    List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);

    while (!outQueue.empty()) {
        BufferInfo *inInfo;
        OMX_BUFFERHEADERTYPE *inHeader;

        BufferInfo *outInfo;
        OMX_BUFFERHEADERTYPE *outHeader;
        size_t timeStampIx;

        inInfo = NULL;
        inHeader = NULL;
        size_t timeStampIx = 0;

        if (!mIsInFlush) {
        if (!mIsInFlush && (NULL == inHeader)) {
            if (!inQueue.empty()) {
                inInfo = *inQueue.begin();
                inHeader = inInfo->mHeader;
@@ -618,7 +616,7 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
                return;
            }
            // If input dump is enabled, then write to file
            DUMP_TO_FILE(mInFile, s_dec_ip.pv_stream_buffer, s_dec_ip.u4_num_Bytes);
            DUMP_TO_FILE(mInFile, s_dec_ip.pv_stream_buffer, s_dec_ip.u4_num_Bytes, mInputOffset);

            GETTIME(&mTimeStart, NULL);
            /* Compute time elapsed between end of previous decode()
@@ -734,7 +732,16 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
                    resetPlugin();
                }
            }
            mInputOffset += s_dec_op.u4_num_bytes_consumed;
        }
        // If more than 4 bytes are remaining in input, then do not release it
        if (inHeader != NULL && ((inHeader->nFilledLen - mInputOffset) <= 4)) {
            inInfo->mOwnedByUs = false;
            inQueue.erase(inQueue.begin());
            inInfo = NULL;
            notifyEmptyBufferDone(inHeader);
            inHeader = NULL;
            mInputOffset = 0;

            /* If input EOS is seen and decoder is not in flush mode,
             * set the decoder in flush mode.
@@ -745,13 +752,6 @@ void SoftAVC::onQueueFilled(OMX_U32 portIndex) {
            if (mReceivedEOS && !mIsInFlush) {
                setFlushMode();
            }

        if (inHeader != NULL) {
            inInfo->mOwnedByUs = false;
            inQueue.erase(inQueue.begin());
            inInfo = NULL;
            notifyEmptyBufferDone(inHeader);
            inHeader = NULL;
        }
    }
}
+8 −5
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ private:
    bool mFlushNeeded;
    bool mSignalledError;
    size_t mStride;
    size_t mInputOffset;

    status_t initDecoder();
    status_t deInitDecoder();
@@ -143,10 +144,10 @@ private:
        ALOGD("Could not open file %s", m_filename);    \
    }                                                   \
}
#define DUMP_TO_FILE(m_filename, m_buf, m_size)         \
#define DUMP_TO_FILE(m_filename, m_buf, m_size, m_offset)\
{                                                       \
    FILE *fp = fopen(m_filename, "ab");                 \
    if (fp != NULL && m_buf != NULL) {                  \
    if (fp != NULL && m_buf != NULL && m_offset == 0) { \
        int i;                                          \
        i = fwrite(m_buf, 1, m_size, fp);               \
        ALOGD("fwrite ret %d to write %d", i, m_size);  \
@@ -154,10 +155,12 @@ private:
            ALOGD("Error in fwrite, returned %d", i);   \
            perror("Error in write to file");           \
        }                                               \
        fclose(fp);                                     \
    } else {                                            \
    } else if (fp == NULL) {                            \
        ALOGD("Could not write to file %s", m_filename);\
    }                                                   \
    if (fp) {                                           \
        fclose(fp);                                     \
    }                                                   \
}
#else /* FILE_DUMP_ENABLE */
#define INPUT_DUMP_PATH
@@ -166,7 +169,7 @@ private:
#define OUTPUT_DUMP_EXT
#define GENERATE_FILE_NAMES()
#define CREATE_DUMP_FILE(m_filename)
#define DUMP_TO_FILE(m_filename, m_buf, m_size)
#define DUMP_TO_FILE(m_filename, m_buf, m_size, m_offset)
#endif /* FILE_DUMP_ENABLE */

} // namespace android