Loading media/libstagefright/matroska/MatroskaExtractor.cpp +23 −1 Original line number Diff line number Diff line Loading @@ -369,8 +369,9 @@ status_t MatroskaSource::readBlock() { const mkvparser::Block *block = mBlockIter.block(); int64_t timeUs = mBlockIter.blockTimeUs(); int frameCount = block->GetFrameCount(); for (int i = 0; i < block->GetFrameCount(); ++i) { for (int i = 0; i < frameCount; ++i) { const mkvparser::Block::Frame &frame = block->GetFrame(i); MediaBuffer *mbuf = new MediaBuffer(frame.len); Loading @@ -390,6 +391,27 @@ status_t MatroskaSource::readBlock() { mBlockIter.advance(); if (!mBlockIter.eos() && frameCount > 1) { // For files with lacing enabled, we need to amend they kKeyTime of // each frame so that their kKeyTime are advanced accordingly (instead // of being set to the same value). To do this, we need to find out // the duration of the block using the start time of the next block. int64_t duration = mBlockIter.blockTimeUs() - timeUs; int64_t durationPerFrame = duration / frameCount; int64_t durationRemainder = duration % frameCount; // We split duration to each of the frame, distributing the remainder (if any) // to the later frames. The later frames are processed first due to the // use of the iterator for the doubly linked list List<MediaBuffer *>::iterator it = mPendingFrames.end(); for (int i = frameCount - 1; i >= 0; --i) { --it; int64_t frameRemainder = durationRemainder >= frameCount - i ? 1 : 0; int64_t frameTimeUs = timeUs + durationPerFrame * i + frameRemainder; (*it)->meta_data()->setInt64(kKeyTime, frameTimeUs); } } return OK; } Loading Loading
media/libstagefright/matroska/MatroskaExtractor.cpp +23 −1 Original line number Diff line number Diff line Loading @@ -369,8 +369,9 @@ status_t MatroskaSource::readBlock() { const mkvparser::Block *block = mBlockIter.block(); int64_t timeUs = mBlockIter.blockTimeUs(); int frameCount = block->GetFrameCount(); for (int i = 0; i < block->GetFrameCount(); ++i) { for (int i = 0; i < frameCount; ++i) { const mkvparser::Block::Frame &frame = block->GetFrame(i); MediaBuffer *mbuf = new MediaBuffer(frame.len); Loading @@ -390,6 +391,27 @@ status_t MatroskaSource::readBlock() { mBlockIter.advance(); if (!mBlockIter.eos() && frameCount > 1) { // For files with lacing enabled, we need to amend they kKeyTime of // each frame so that their kKeyTime are advanced accordingly (instead // of being set to the same value). To do this, we need to find out // the duration of the block using the start time of the next block. int64_t duration = mBlockIter.blockTimeUs() - timeUs; int64_t durationPerFrame = duration / frameCount; int64_t durationRemainder = duration % frameCount; // We split duration to each of the frame, distributing the remainder (if any) // to the later frames. The later frames are processed first due to the // use of the iterator for the doubly linked list List<MediaBuffer *>::iterator it = mPendingFrames.end(); for (int i = frameCount - 1; i >= 0; --i) { --it; int64_t frameRemainder = durationRemainder >= frameCount - i ? 1 : 0; int64_t frameTimeUs = timeUs + durationPerFrame * i + frameRemainder; (*it)->meta_data()->setInt64(kKeyTime, frameTimeUs); } } return OK; } Loading