зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1109431 - Apply TimestampsFuzzyEqual rounding to the buffered ranges returned from multiple decoders. r=ajones
--HG-- extra : rebase_source : 1ca8f7910db619b90fdc9478bb0dc52a5d16693b
This commit is contained in:
Родитель
c8cf5fc8d0
Коммит
7182f1554c
|
@ -98,7 +98,7 @@ TimeRanges::GetEndTime()
|
|||
}
|
||||
|
||||
void
|
||||
TimeRanges::Normalize()
|
||||
TimeRanges::Normalize(double aError)
|
||||
{
|
||||
if (mRanges.Length() >= 2) {
|
||||
nsAutoTArray<TimeRange,4> normalized;
|
||||
|
@ -112,7 +112,7 @@ TimeRanges::Normalize()
|
|||
current.mEnd >= mRanges[i].mEnd) {
|
||||
continue;
|
||||
}
|
||||
if (current.mEnd >= mRanges[i].mStart) {
|
||||
if (current.mEnd + aError >= mRanges[i].mStart) {
|
||||
current.mEnd = mRanges[i].mEnd;
|
||||
} else {
|
||||
normalized.AppendElement(current);
|
||||
|
@ -127,10 +127,10 @@ TimeRanges::Normalize()
|
|||
}
|
||||
|
||||
void
|
||||
TimeRanges::Union(const TimeRanges* aOtherRanges)
|
||||
TimeRanges::Union(const TimeRanges* aOtherRanges, double aError)
|
||||
{
|
||||
mRanges.AppendElements(aOtherRanges->mRanges);
|
||||
Normalize();
|
||||
Normalize(aError);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -42,10 +42,10 @@ public:
|
|||
double GetEndTime();
|
||||
|
||||
// See http://www.whatwg.org/html/#normalized-timeranges-object
|
||||
void Normalize();
|
||||
void Normalize(double aError = 0.0);
|
||||
|
||||
// Mutate this TimeRange to be the union of this and aOtherRanges.
|
||||
void Union(const TimeRanges* aOtherRanges);
|
||||
void Union(const TimeRanges* aOtherRanges, double aError);
|
||||
|
||||
// Mutate this TimeRange to be the intersection of this and aOtherRanges.
|
||||
void Intersection(const TimeRanges* aOtherRanges);
|
||||
|
|
|
@ -63,6 +63,14 @@ ContainerParser::TimestampsFuzzyEqual(int64_t aLhs, int64_t aRhs)
|
|||
{
|
||||
NS_WARNING("Using default ContainerParser::TimestampFuzzyEquals implementation");
|
||||
return aLhs == aRhs;
|
||||
return llabs(aLhs - aRhs) <= GetRoundingError();
|
||||
}
|
||||
|
||||
int64_t
|
||||
ContainerParser::GetRoundingError()
|
||||
{
|
||||
NS_WARNING("Using default ContainerParser::GetRoundingError implementation");
|
||||
return 0;
|
||||
}
|
||||
|
||||
const nsTArray<uint8_t>&
|
||||
|
@ -79,6 +87,7 @@ public:
|
|||
{}
|
||||
|
||||
static const unsigned NS_PER_USEC = 1000;
|
||||
static const unsigned USEC_PER_SEC = 1000000;
|
||||
|
||||
bool IsInitSegmentPresent(const uint8_t* aData, uint32_t aLength)
|
||||
{
|
||||
|
@ -182,10 +191,10 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TimestampsFuzzyEqual(int64_t aLhs, int64_t aRhs)
|
||||
int64_t GetRoundingError()
|
||||
{
|
||||
int64_t error = mParser.GetTimecodeScale() / NS_PER_USEC;
|
||||
return llabs(aLhs - aRhs) <= error * 2;
|
||||
return error * 2;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -276,9 +285,9 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TimestampsFuzzyEqual(int64_t aLhs, int64_t aRhs)
|
||||
int64_t GetRoundingError()
|
||||
{
|
||||
return llabs(aLhs - aRhs) <= 1000;
|
||||
return 1000;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -35,7 +35,9 @@ public:
|
|||
// Compare aLhs and rHs, considering any error that may exist in the
|
||||
// timestamps from the format's base representation. Return true if aLhs
|
||||
// == aRhs within the error epsilon.
|
||||
virtual bool TimestampsFuzzyEqual(int64_t aLhs, int64_t aRhs);
|
||||
bool TimestampsFuzzyEqual(int64_t aLhs, int64_t aRhs);
|
||||
|
||||
virtual int64_t GetRoundingError();
|
||||
|
||||
const nsTArray<uint8_t>& InitData();
|
||||
|
||||
|
|
|
@ -316,7 +316,7 @@ TrackBuffer::Buffered(dom::TimeRanges* aRanges)
|
|||
mDecoders[i]->GetBuffered(r);
|
||||
if (r->Length() > 0) {
|
||||
highestEndTime = std::max(highestEndTime, r->GetEndTime());
|
||||
aRanges->Union(r);
|
||||
aRanges->Union(r, double(mParser->GetRoundingError()) / USECS_PER_S);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче