Bug 1044498 - WebMBufferedReader used mBlockOffset in some places where it was intended to use mBlockTimecode. r=cajbir

This commit is contained in:
Matthew Gregan 2014-08-25 16:09:44 +12:00
parent 5ac72698e0
commit 2a92e3ea20
3 changed files with 12 additions and 14 deletions

View File

@ -147,7 +147,7 @@ void WebMBufferedParser::Append(const unsigned char* aBuffer, uint32_t aLength,
uint32_t idx = aMapping.IndexOfFirstElementGt(mBlockOffset);
if (idx == 0 || !(aMapping[idx - 1] == mBlockOffset)) {
// Don't insert invalid negative timecodes.
if (mBlockOffset > 0 || mClusterTimecode > uint16_t(abs(mBlockOffset))) {
if (mBlockTimecode >= 0 || mClusterTimecode >= uint16_t(abs(mBlockTimecode))) {
MOZ_ASSERT(mGotTimecodeScale);
uint64_t absTimecode = mClusterTimecode + mBlockTimecode;
absTimecode *= mTimecodeScale;
@ -226,7 +226,7 @@ bool WebMBufferedState::CalculateBufferedForRange(int64_t aStartOffset, int64_t
return true;
}
bool WebMBufferedState::GetOffsetForTime(uint64_t aTime, int64_t* aOffset, enum OffsetType aType)
bool WebMBufferedState::GetOffsetForTime(uint64_t aTime, int64_t* aOffset)
{
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
WebMTimeDataOffset result(0, 0, 0);
@ -238,7 +238,7 @@ bool WebMBufferedState::GetOffsetForTime(uint64_t aTime, int64_t* aOffset, enum
}
}
*aOffset = aType == CLUSTER_START ? result.mSyncOffset : result.mOffset;
*aOffset = result.mSyncOffset;
return true;
}

View File

@ -209,11 +209,11 @@ public:
void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
bool CalculateBufferedForRange(int64_t aStartOffset, int64_t aEndOffset,
uint64_t* aStartTime, uint64_t* aEndTime);
enum OffsetType {
CLUSTER_START,
BLOCK_START
};
bool GetOffsetForTime(uint64_t aTime, int64_t* aOffset, enum OffsetType aType);
// Returns true if aTime is is present in mTimeMapping and sets aOffset to
// the latest offset for which decoding can resume without data
// dependencies to arrive at aTime.
bool GetOffsetForTime(uint64_t aTime, int64_t* aOffset);
private:
// Private destructor, to discourage deletion outside of Release():

View File

@ -944,13 +944,13 @@ bool WebMReader::DecodeVideoFrame(bool &aKeyframeSkip,
b.mPlanes[1].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
b.mPlanes[1].mWidth = (img->d_w + 1) >> img->x_chroma_shift;
b.mPlanes[1].mOffset = b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mData = img->planes[2];
b.mPlanes[2].mStride = img->stride[2];
b.mPlanes[2].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
b.mPlanes[2].mWidth = (img->d_w + 1) >> img->x_chroma_shift;
b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0;
IntRect picture = ToIntRect(mPicture);
if (img->d_w != static_cast<uint32_t>(mInitialFrame.width) ||
img->d_h != static_cast<uint32_t>(mInitialFrame.height)) {
@ -1011,8 +1011,7 @@ nsresult WebMReader::Seek(int64_t aTarget, int64_t aStartTime, int64_t aEndTime,
if (r != 0) {
// Try seeking directly based on cluster information in memory.
int64_t offset = 0;
bool rv = mBufferedState->GetOffsetForTime((aTarget - aStartTime)/NS_PER_USEC, &offset,
WebMBufferedState::CLUSTER_START);
bool rv = mBufferedState->GetOffsetForTime((aTarget - aStartTime)/NS_PER_USEC, &offset);
if (!rv) {
return NS_ERROR_FAILURE;
}
@ -1087,8 +1086,7 @@ void WebMReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_
int64_t WebMReader::GetEvictionOffset(double aTime)
{
int64_t offset;
if (!mBufferedState->GetOffsetForTime(aTime / NS_PER_USEC, &offset,
WebMBufferedState::CLUSTER_START)) {
if (!mBufferedState->GetOffsetForTime(aTime / NS_PER_USEC, &offset)) {
return -1;
}