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

Commit d32936fc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Transcoder: Detect input/output frame count mismatch due to codec error"

parents 8c3ac41f 47352415
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -396,6 +396,10 @@ void VideoTrackTranscoder::enqueueInputSample(int32_t bufferIndex) {
            mStatus = status;
            return;
        }

        if (mSampleInfo.size) {
            ++mInputFrameCount;
        }
    } else {
        LOG(DEBUG) << "EOS from source.";
        mEosFromSource = true;
@@ -445,6 +449,9 @@ void VideoTrackTranscoder::dequeueOutputSample(int32_t bufferIndex,
        sample->info.flags = bufferInfo.flags;
        sample->info.presentationTimeUs = bufferInfo.presentationTimeUs;

        if (bufferInfo.size > 0 && (bufferInfo.flags & SAMPLE_FLAG_CODEC_CONFIG) == 0) {
            ++mOutputFrameCount;
        }
        onOutputSampleAvailable(sample);

        mLastSampleWasSync = sample->info.flags & SAMPLE_FLAG_SYNC_SAMPLE;
@@ -456,6 +463,15 @@ void VideoTrackTranscoder::dequeueOutputSample(int32_t bufferIndex,
    if (bufferInfo.flags & AMEDIACODEC_BUFFER_FLAG_END_OF_STREAM) {
        LOG(DEBUG) << "EOS from encoder.";
        mEosFromEncoder = true;

        if (mInputFrameCount != mOutputFrameCount) {
            LOG(WARNING) << "Input / Output frame count mismatch: " << mInputFrameCount << " vs "
                         << mOutputFrameCount;
            if (mInputFrameCount > 0 && mOutputFrameCount == 0) {
                LOG(ERROR) << "Encoder did not produce any output frames.";
                mStatus = AMEDIA_ERROR_UNKNOWN;
            }
        }
    }
}

+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <binder/ProcessState.h>
#include <fcntl.h>
#include <media/MediaTranscoder.h>

#include <iostream>

using namespace android;
+2 −0
Original line number Diff line number Diff line
@@ -99,6 +99,8 @@ private:
    std::shared_ptr<AMediaFormat> mActualOutputFormat;
    pid_t mPid;
    uid_t mUid;
    uint64_t mInputFrameCount = 0;
    uint64_t mOutputFrameCount = 0;
};

}  // namespace android