mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
Backed out changeset 4953d5ffbacf (bug 1219134)
This commit is contained in:
parent
657bc370a2
commit
42a2e03f42
@ -21,45 +21,6 @@ namespace mozilla
|
||||
bool FFmpegDataDecoder<LIBAV_VER>::sFFmpegInitDone = false;
|
||||
StaticMutex FFmpegDataDecoder<LIBAV_VER>::sMonitor;
|
||||
|
||||
FFmpegDataDecoder<LIBAV_VER>::PtsCorrectionContext::PtsCorrectionContext()
|
||||
: mNumFaultyPts(0)
|
||||
, mNumFaultyDts(0)
|
||||
, mLastPts(INT64_MIN)
|
||||
, mLastDts(INT64_MIN)
|
||||
{
|
||||
}
|
||||
|
||||
int64_t
|
||||
FFmpegDataDecoder<LIBAV_VER>::PtsCorrectionContext::GuessCorrectPts(int64_t aPts, int64_t aDts)
|
||||
{
|
||||
int64_t pts = AV_NOPTS_VALUE;
|
||||
|
||||
if (aDts != int64_t(AV_NOPTS_VALUE)) {
|
||||
mNumFaultyDts += aDts <= mLastDts;
|
||||
mLastDts = aDts;
|
||||
}
|
||||
if (aPts != int64_t(AV_NOPTS_VALUE)) {
|
||||
mNumFaultyPts += aPts <= mLastPts;
|
||||
mLastPts = aPts;
|
||||
}
|
||||
if ((mNumFaultyPts <= mNumFaultyDts || aDts == int64_t(AV_NOPTS_VALUE)) &&
|
||||
aPts != int64_t(AV_NOPTS_VALUE)) {
|
||||
pts = aPts;
|
||||
} else {
|
||||
pts = aDts;
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
|
||||
void
|
||||
FFmpegDataDecoder<LIBAV_VER>::PtsCorrectionContext::Reset()
|
||||
{
|
||||
mNumFaultyPts = 0;
|
||||
mNumFaultyDts = 0;
|
||||
mLastPts = INT64_MIN;
|
||||
mLastDts = INT64_MIN;
|
||||
}
|
||||
|
||||
FFmpegDataDecoder<LIBAV_VER>::FFmpegDataDecoder(FlushableTaskQueue* aTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback,
|
||||
AVCodecID aCodecID)
|
||||
@ -223,7 +184,6 @@ FFmpegDataDecoder<LIBAV_VER>::ProcessFlush()
|
||||
if (mCodecContext) {
|
||||
avcodec_flush_buffers(mCodecContext);
|
||||
}
|
||||
mPtsContext.Reset();
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
mIsFlushing = false;
|
||||
mon.NotifyAll();
|
||||
|
@ -63,21 +63,6 @@ protected:
|
||||
Atomic<bool> mIsFlushing;
|
||||
AVCodecParserContext* mCodecParser;
|
||||
|
||||
class PtsCorrectionContext {
|
||||
public:
|
||||
PtsCorrectionContext();
|
||||
int64_t GuessCorrectPts(int64_t aPts, int64_t aDts);
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
int64_t mNumFaultyPts; /// Number of incorrect PTS values so far
|
||||
int64_t mNumFaultyDts; /// Number of incorrect DTS values so far
|
||||
int64_t mLastPts; /// PTS of the last frame
|
||||
int64_t mLastDts; /// DTS of the last frame
|
||||
};
|
||||
|
||||
PtsCorrectionContext mPtsContext;
|
||||
|
||||
private:
|
||||
static bool sFFmpegInitDone;
|
||||
static StaticMutex sMonitor;
|
||||
|
@ -54,6 +54,21 @@ FFmpegH264Decoder<LIBAV_VER>::Init()
|
||||
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
|
||||
}
|
||||
|
||||
int64_t
|
||||
FFmpegH264Decoder<LIBAV_VER>::GetPts(const AVPacket& packet)
|
||||
{
|
||||
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
||||
#if LIBAVCODEC_VERSION_MAJOR == 53
|
||||
if (mFrame->pkt_pts == 0) {
|
||||
return mFrame->pkt_dts;
|
||||
} else {
|
||||
return mFrame->pkt_pts;
|
||||
}
|
||||
#else
|
||||
return mFrame->pkt_pts;
|
||||
#endif
|
||||
}
|
||||
|
||||
FFmpegH264Decoder<LIBAV_VER>::DecodeResult
|
||||
FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample)
|
||||
{
|
||||
@ -143,7 +158,7 @@ FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample,
|
||||
|
||||
// If we've decoded a frame then we need to output it
|
||||
if (decoded) {
|
||||
int64_t pts = mPtsContext.GuessCorrectPts(mFrame->pkt_pts, mFrame->pkt_dts);
|
||||
int64_t pts = GetPts(packet);
|
||||
FFMPEG_LOG("Got one frame output with pts=%lld opaque=%lld",
|
||||
pts, mCodecContext->reordered_opaque);
|
||||
|
||||
|
@ -59,6 +59,7 @@ private:
|
||||
|
||||
static int AllocateBufferCb(AVCodecContext* aCodecContext, AVFrame* aFrame);
|
||||
static void ReleaseBufferCb(AVCodecContext* aCodecContext, AVFrame* aFrame);
|
||||
int64_t GetPts(const AVPacket& packet);
|
||||
|
||||
RefPtr<ImageContainer> mImageContainer;
|
||||
uint32_t mPictureWidth;
|
||||
|
Loading…
Reference in New Issue
Block a user