mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 09:15:35 +00:00
Bug 1482706 - Pre-roll seek by 2112 frames to account for encoder delay. r=kinetik
Differential Revision: https://phabricator.services.mozilla.com/D3485 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
a98680f98b
commit
92877ec9a4
@ -337,6 +337,10 @@ bool ADTSTrackDemuxer::Init() {
|
||||
mInfo->mRate, mInfo->mChannels, mInfo->mBitDepth,
|
||||
mInfo->mDuration.ToMicroseconds());
|
||||
|
||||
// AAC encoder delay is by default 2112 audio frames.
|
||||
// See https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
|
||||
// So we always seek 2112 frames prior the seeking point.
|
||||
mPreRoll = TimeUnit::FromMicroseconds(2112 * 1000000ULL / mSamplesPerSecond);
|
||||
return mSamplesPerSecond && mChannels;
|
||||
}
|
||||
|
||||
@ -347,9 +351,10 @@ UniquePtr<TrackInfo> ADTSTrackDemuxer::GetInfo() const {
|
||||
RefPtr<ADTSTrackDemuxer::SeekPromise> ADTSTrackDemuxer::Seek(
|
||||
const TimeUnit& aTime) {
|
||||
// Efficiently seek to the position.
|
||||
FastSeek(aTime);
|
||||
const TimeUnit time = aTime > mPreRoll ? aTime - mPreRoll : TimeUnit::Zero();
|
||||
FastSeek(time);
|
||||
// Correct seek position by scanning the next frames.
|
||||
const TimeUnit seekTime = ScanUntil(aTime);
|
||||
const TimeUnit seekTime = ScanUntil(time);
|
||||
|
||||
return SeekPromise::CreateAndResolve(seekTime, __func__);
|
||||
}
|
||||
|
@ -141,6 +141,11 @@ class ADTSTrackDemuxer : public MediaTrackDemuxer,
|
||||
|
||||
// Audio track config info.
|
||||
UniquePtr<AudioInfo> mInfo;
|
||||
|
||||
// Amount of pre-roll time when seeking.
|
||||
// AAC encoder delay is by default 2112 audio frames.
|
||||
media::TimeUnit mPreRoll;
|
||||
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user