--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -805,19 +805,19 @@ MediaFormatReader::DemuxerProxy::NotifyD
}
return NotifyDataArrivedPromise::CreateAndResolve(true, __func__);
});
}
static const char*
TrackTypeToStr(TrackInfo::TrackType aTrack)
{
- MOZ_ASSERT(aTrack == TrackInfo::kAudioTrack ||
- aTrack == TrackInfo::kVideoTrack ||
- aTrack == TrackInfo::kTextTrack);
+ MOZ_ASSERT(aTrack == TrackInfo::kAudioTrack
+ || aTrack == TrackInfo::kVideoTrack
+ || aTrack == TrackInfo::kTextTrack);
switch (aTrack) {
case TrackInfo::kAudioTrack:
return "Audio";
case TrackInfo::kVideoTrack:
return "Video";
case TrackInfo::kTextTrack:
return "Text";
default:
@@ -1302,19 +1302,19 @@ MediaFormatReader::ShouldSkip(bool aSkip
media::TimeUnit aTimeThreshold)
{
MOZ_ASSERT(HasVideo());
media::TimeUnit nextKeyframe;
nsresult rv = mVideo.mTrackDemuxer->GetNextRandomAccessPoint(&nextKeyframe);
if (NS_FAILED(rv)) {
return aSkipToNextKeyframe;
}
- return (nextKeyframe < aTimeThreshold ||
- (mVideo.mTimeThreshold
- && mVideo.mTimeThreshold.ref().EndTime() < aTimeThreshold))
+ return (nextKeyframe < aTimeThreshold
+ || (mVideo.mTimeThreshold
+ && mVideo.mTimeThreshold.ref().EndTime() < aTimeThreshold))
&& nextKeyframe.ToMicroseconds() >= 0
&& !nextKeyframe.IsInfinite();
}
RefPtr<MediaDecoderReader::MediaDataPromise>
MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe,
int64_t aTimeThreshold)
{
@@ -1767,18 +1767,18 @@ MediaFormatReader::HandleDemuxedSamples(
// Decode all our demuxed frames.
while (decoder.mQueuedSamples.Length()) {
RefPtr<MediaRawData> sample = decoder.mQueuedSamples[0];
RefPtr<SharedTrackInfo> info = sample->mTrackInfo;
if (info && decoder.mLastStreamSourceID != info->GetID()) {
bool supportRecycling = MediaPrefs::MediaDecoderCheckRecycling()
&& decoder.mDecoder->SupportDecoderRecycling();
- if (decoder.mNextStreamSourceID.isNothing() ||
- decoder.mNextStreamSourceID.ref() != info->GetID()) {
+ if (decoder.mNextStreamSourceID.isNothing()
+ || decoder.mNextStreamSourceID.ref() != info->GetID()) {
if (!supportRecycling) {
LOG("%s stream id has changed from:%d to:%d, draining decoder.",
TrackTypeToStr(aTrack), decoder.mLastStreamSourceID,
info->GetID());
decoder.mNeedDraining = true;
decoder.mNextStreamSourceID = Some(info->GetID());
ScheduleUpdate(aTrack);
return;
@@ -1887,18 +1887,18 @@ MediaFormatReader::DrainDecoder(TrackTyp
MOZ_ASSERT(OnTaskQueue());
auto& decoder = GetDecoderData(aTrack);
if (!decoder.mNeedDraining || decoder.mDraining) {
return;
}
decoder.mNeedDraining = false;
decoder.mDraining = true;
- if (!decoder.mDecoder ||
- decoder.mNumSamplesInput == decoder.mNumSamplesOutput) {
+ if (!decoder.mDecoder
+ || decoder.mNumSamplesInput == decoder.mNumSamplesOutput) {
// No frames to drain.
LOGV("Draining %s with nothing to drain", TrackTypeToStr(aTrack));
NotifyDrainComplete(aTrack);
return;
}
RefPtr<MediaFormatReader> self = this;
decoder.mDecoder->Drain()
->Then(mTaskQueue, __func__,
@@ -2089,17 +2089,17 @@ MediaFormatReader::Update(TrackType aTra
return;
}
decoder.mError.reset();
LOG("%s decoded error count %d", TrackTypeToStr(aTrack),
decoder.mNumOfConsecutiveError);
media::TimeUnit nextKeyframe;
if (aTrack == TrackType::kVideoTrack && !decoder.HasInternalSeekPending()
&& NS_SUCCEEDED(
- decoder.mTrackDemuxer->GetNextRandomAccessPoint(&nextKeyframe))) {
+ decoder.mTrackDemuxer->GetNextRandomAccessPoint(&nextKeyframe))) {
if (needsNewDecoder) {
ShutdownDecoder(aTrack);
}
SkipVideoDemuxToNextKeyFrame(
decoder.mLastSampleTime.refOr(TimeInterval()).Length());
} else if (aTrack == TrackType::kAudioTrack) {
decoder.Flush();
}
@@ -2152,18 +2152,18 @@ MediaFormatReader::ReturnOutput(MediaDat
MOZ_ASSERT(GetDecoderData(aTrack).HasPromise());
MOZ_DIAGNOSTIC_ASSERT(aData->mType != MediaData::NULL_DATA);
LOG("Resolved data promise for %s [%lld, %lld]", TrackTypeToStr(aTrack),
aData->mTime, aData->GetEndTime());
if (aTrack == TrackInfo::kAudioTrack) {
AudioData* audioData = static_cast<AudioData*>(aData);
- if (audioData->mChannels != mInfo.mAudio.mChannels ||
- audioData->mRate != mInfo.mAudio.mRate) {
+ if (audioData->mChannels != mInfo.mAudio.mChannels
+ || audioData->mRate != mInfo.mAudio.mRate) {
LOG("change of audio format (rate:%d->%d). "
"This is an unsupported configuration",
mInfo.mAudio.mRate, audioData->mRate);
mInfo.mAudio.mRate = audioData->mRate;
mInfo.mAudio.mChannels = audioData->mChannels;
}
mAudio.ResolvePromise(aData, __func__);
} else if (aTrack == TrackInfo::kVideoTrack) {
@@ -2488,18 +2488,18 @@ MediaFormatReader::OnSeekFailed(TrackTyp
Maybe<media::TimeUnit> nextSeekTime;
// Find closest buffered time found after video seeked time.
for (const auto& timeRange : mAudio.mTimeRanges) {
if (timeRange.mStart >= mPendingSeekTime.ref()) {
nextSeekTime.emplace(timeRange.mStart);
break;
}
}
- if (nextSeekTime.isNothing() ||
- nextSeekTime.ref() > mFallbackSeekTime.ref()) {
+ if (nextSeekTime.isNothing()
+ || nextSeekTime.ref() > mFallbackSeekTime.ref()) {
nextSeekTime = Some(mFallbackSeekTime.ref());
LOG("Unable to seek audio to video seek time. A/V sync may be broken");
} else {
mFallbackSeekTime.reset();
}
mPendingSeekTime = nextSeekTime;
DoAudioSeek();
return;
@@ -2741,18 +2741,18 @@ MediaFormatReader::UpdateBuffered()
if (HasAudio() && HasVideo()) {
intervals = media::Intersection(mVideo.mTimeRanges, mAudio.mTimeRanges);
} else if (HasAudio()) {
intervals = mAudio.mTimeRanges;
} else if (HasVideo()) {
intervals = mVideo.mTimeRanges;
}
- if (!intervals.Length() ||
- intervals.GetStart() == media::TimeUnit::FromMicroseconds(0)) {
+ if (!intervals.Length()
+ || intervals.GetStart() == media::TimeUnit::FromMicroseconds(0)) {
// IntervalSet already starts at 0 or is empty, nothing to shift.
mBuffered = intervals;
} else {
mBuffered =
intervals.Shift(media::TimeUnit() - mInfo.mStartTime);
}
}
--- a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp
@@ -6,50 +6,53 @@
#include "mozilla/TaskQueue.h"
#include "FFmpegAudioDecoder.h"
#include "TimeUnits.h"
#define MAX_CHANNELS 16
-namespace mozilla
-{
+namespace mozilla {
FFmpegAudioDecoder<LIBAV_VER>::FFmpegAudioDecoder(FFmpegLibWrapper* aLib,
TaskQueue* aTaskQueue, const AudioInfo& aConfig)
: FFmpegDataDecoder(aLib, aTaskQueue, GetCodecId(aConfig.mMimeType))
{
MOZ_COUNT_CTOR(FFmpegAudioDecoder);
- // Use a new MediaByteBuffer as the object will be modified during initialization.
+ // Use a new MediaByteBuffer as the object will be modified during
+ // initialization.
if (aConfig.mCodecSpecificConfig && aConfig.mCodecSpecificConfig->Length()) {
mExtraData = new MediaByteBuffer;
mExtraData->AppendElements(*aConfig.mCodecSpecificConfig);
}
}
RefPtr<MediaDataDecoder::InitPromise>
FFmpegAudioDecoder<LIBAV_VER>::Init()
{
nsresult rv = InitDecoder();
- return rv == NS_OK ? InitPromise::CreateAndResolve(TrackInfo::kAudioTrack, __func__)
- : InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
+ return rv == NS_OK
+ ? InitPromise::CreateAndResolve(TrackInfo::kAudioTrack, __func__)
+ : InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
+ __func__);
}
void
FFmpegAudioDecoder<LIBAV_VER>::InitCodecContext()
{
MOZ_ASSERT(mCodecContext);
// We do not want to set this value to 0 as FFmpeg by default will
// use the number of cores, which with our mozlibavutil get_cpu_count
// isn't implemented.
mCodecContext->thread_count = 1;
// FFmpeg takes this as a suggestion for what format to use for audio samples.
- // LibAV 0.8 produces rubbish float interleaved samples, request 16 bits audio.
+ // LibAV 0.8 produces rubbish float interleaved samples, request 16 bits
+ // audio.
mCodecContext->request_sample_fmt =
(mLib->mVersion == 53) ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_FLT;
}
static AlignedAudioBuffer
CopyAndPackAudio(AVFrame* aFrame, uint32_t aNumChannels, uint32_t aNumAFrames)
{
MOZ_ASSERT(aNumChannels <= MAX_CHANNELS);
--- a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.h
+++ b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.h
@@ -2,21 +2,20 @@
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __FFmpegAACDecoder_h__
#define __FFmpegAACDecoder_h__
+#include "FFmpegDataDecoder.h"
#include "FFmpegLibWrapper.h"
-#include "FFmpegDataDecoder.h"
-namespace mozilla
-{
+namespace mozilla {
template <int V> class FFmpegAudioDecoder
{
};
template <>
class FFmpegAudioDecoder<LIBAV_VER> : public FFmpegDataDecoder<LIBAV_VER>
{
--- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp
@@ -1,28 +1,26 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "mozilla/SyncRunnable.h"
-#include "mozilla/TaskQueue.h"
#include <string.h>
#ifdef __GNUC__
#include <unistd.h>
#endif
#include "FFmpegLog.h"
#include "FFmpegDataDecoder.h"
+#include "mozilla/TaskQueue.h"
#include "prsystem.h"
-namespace mozilla
-{
+namespace mozilla {
StaticMutex FFmpegDataDecoder<LIBAV_VER>::sMonitor;
FFmpegDataDecoder<LIBAV_VER>::FFmpegDataDecoder(FFmpegLibWrapper* aLib,
TaskQueue* aTaskQueue,
AVCodecID aCodecID)
: mLib(aLib)
, mCodecContext(nullptr)
--- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h
+++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h
@@ -7,18 +7,17 @@
#ifndef __FFmpegDataDecoder_h__
#define __FFmpegDataDecoder_h__
#include "PlatformDecoderModule.h"
#include "FFmpegLibWrapper.h"
#include "mozilla/StaticMutex.h"
#include "FFmpegLibs.h"
-namespace mozilla
-{
+namespace mozilla {
template <int V>
class FFmpegDataDecoder : public MediaDataDecoder
{
};
template <>
class FFmpegDataDecoder<LIBAV_VER> : public MediaDataDecoder
@@ -37,17 +36,17 @@ public:
RefPtr<ShutdownPromise> Shutdown() override;
static AVCodec* FindAVCodec(FFmpegLibWrapper* aLib, AVCodecID aCodec);
protected:
// Flush and Drain operation, always run
virtual RefPtr<FlushPromise> ProcessFlush();
virtual void ProcessShutdown();
- virtual void InitCodecContext() {}
+ virtual void InitCodecContext() { }
AVFrame* PrepareFrame();
nsresult InitDecoder();
FFmpegLibWrapper* mLib;
AVCodecContext* mCodecContext;
AVFrame* mFrame;
RefPtr<MediaByteBuffer> mExtraData;
--- a/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
+++ b/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
@@ -7,33 +7,32 @@
#ifndef __FFmpegDecoderModule_h__
#define __FFmpegDecoderModule_h__
#include "PlatformDecoderModule.h"
#include "FFmpegLibWrapper.h"
#include "FFmpegAudioDecoder.h"
#include "FFmpegVideoDecoder.h"
-namespace mozilla
-{
+namespace mozilla {
template <int V>
class FFmpegDecoderModule : public PlatformDecoderModule
{
public:
static already_AddRefed<PlatformDecoderModule>
Create(FFmpegLibWrapper* aLib)
{
RefPtr<PlatformDecoderModule> pdm = new FFmpegDecoderModule(aLib);
return pdm.forget();
}
- explicit FFmpegDecoderModule(FFmpegLibWrapper* aLib) : mLib(aLib) {}
- virtual ~FFmpegDecoderModule() {}
+ explicit FFmpegDecoderModule(FFmpegLibWrapper* aLib) : mLib(aLib) { }
+ virtual ~FFmpegDecoderModule() { }
already_AddRefed<MediaDataDecoder>
CreateVideoDecoder(const CreateDecoderParams& aParams) override
{
// Temporary - forces use of VPXDecoder when alpha is present.
// Bug 1263836 will handle alpha scenario once implemented. It will shift
// the check for alpha to PDMFactory but not itself remove the need for a
// check.
@@ -68,19 +67,19 @@ public:
}
AVCodecID codec = audioCodec != AV_CODEC_ID_NONE ? audioCodec : videoCodec;
return !!FFmpegDataDecoder<V>::FindAVCodec(mLib, codec);
}
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override
{
- if (aConfig.IsVideo() &&
- (aConfig.mMimeType.EqualsLiteral("video/avc") ||
- aConfig.mMimeType.EqualsLiteral("video/mp4"))) {
+ if (aConfig.IsVideo()
+ && (aConfig.mMimeType.EqualsLiteral("video/avc")
+ || aConfig.mMimeType.EqualsLiteral("video/mp4"))) {
return ConversionRequired::kNeedAVCC;
} else {
return ConversionRequired::kNeedNone;
}
}
private:
FFmpegLibWrapper* mLib;
--- a/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp
@@ -5,18 +5,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FFmpegRuntimeLinker.h"
#include "FFmpegLibWrapper.h"
#include "mozilla/ArrayUtils.h"
#include "FFmpegLog.h"
#include "prlink.h"
-namespace mozilla
-{
+namespace mozilla {
FFmpegRuntimeLinker::LinkStatus FFmpegRuntimeLinker::sLinkStatus =
LinkStatus_INIT;
const char* FFmpegRuntimeLinker::sLinkStatusLibraryName = "";
template <int V> class FFmpegDecoderModule
{
public:
@@ -54,17 +53,18 @@ FFmpegRuntimeLinker::Init()
// more precise error if possible.
sLinkStatus = LinkStatus_NOT_FOUND;
for (size_t i = 0; i < ArrayLength(sLibs); i++) {
const char* lib = sLibs[i];
PRLibSpec lspec;
lspec.type = PR_LibSpec_Pathname;
lspec.value.pathname = lib;
- sLibAV.mAVCodecLib = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
+ sLibAV.mAVCodecLib =
+ PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
if (sLibAV.mAVCodecLib) {
sLibAV.mAVUtilLib = sLibAV.mAVCodecLib;
switch (sLibAV.Link()) {
case FFmpegLibWrapper::LinkResult::Success:
sLinkStatus = LinkStatus_SUCCEEDED;
sLinkStatusLibraryName = lib;
return true;
case FFmpegLibWrapper::LinkResult::NoProvidedLib:
--- a/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.h
+++ b/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.h
@@ -4,18 +4,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __FFmpegRuntimeLinker_h__
#define __FFmpegRuntimeLinker_h__
#include "PlatformDecoderModule.h"
-namespace mozilla
-{
+namespace mozilla {
class FFmpegRuntimeLinker
{
public:
static bool Init();
static already_AddRefed<PlatformDecoderModule> CreateDecoderModule();
enum LinkStatus
{
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -1,41 +1,38 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "mozilla/TaskQueue.h"
-
-#include "nsThreadUtils.h"
-#include "ImageContainer.h"
-
-#include "MediaInfo.h"
-#include "VPXDecoder.h"
-#include "MP4Decoder.h"
-
#include "FFmpegVideoDecoder.h"
#include "FFmpegLog.h"
-#include "mozilla/PodOperations.h"
+#include "ImageContainer.h"
+#include "MediaInfo.h"
+#include "MP4Decoder.h"
+#include "VPXDecoder.h"
#include "libavutil/pixfmt.h"
#if LIBAVCODEC_VERSION_MAJOR < 54
#define AVPixelFormat PixelFormat
#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
#define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P
#define AV_PIX_FMT_NONE PIX_FMT_NONE
#endif
+#include "mozilla/PodOperations.h"
+#include "mozilla/TaskQueue.h"
+#include "nsThreadUtils.h"
+
typedef mozilla::layers::Image Image;
typedef mozilla::layers::PlanarYCbCrImage PlanarYCbCrImage;
-namespace mozilla
-{
+namespace mozilla {
/**
* FFmpeg calls back to this function with a list of pixel formats it supports.
* We choose a pixel format that we support and return it.
* For now, we just look for YUV420P, YUVJ420P and YUV444 as those are the only
* only non-HW accelerated format supported by FFmpeg's H264 and VP9 decoder.
*/
static AVPixelFormat
@@ -66,56 +63,59 @@ FFmpegVideoDecoder<LIBAV_VER>::PtsCorrec
: mNumFaultyPts(0)
, mNumFaultyDts(0)
, mLastPts(INT64_MIN)
, mLastDts(INT64_MIN)
{
}
int64_t
-FFmpegVideoDecoder<LIBAV_VER>::PtsCorrectionContext::GuessCorrectPts(int64_t aPts, int64_t aDts)
+FFmpegVideoDecoder<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)) {
+ if ((mNumFaultyPts <= mNumFaultyDts || aDts == int64_t(AV_NOPTS_VALUE))
+ && aPts != int64_t(AV_NOPTS_VALUE)) {
pts = aPts;
} else {
pts = aDts;
}
return pts;
}
void
FFmpegVideoDecoder<LIBAV_VER>::PtsCorrectionContext::Reset()
{
mNumFaultyPts = 0;
mNumFaultyDts = 0;
mLastPts = INT64_MIN;
mLastDts = INT64_MIN;
}
-FFmpegVideoDecoder<LIBAV_VER>::FFmpegVideoDecoder(FFmpegLibWrapper* aLib,
- TaskQueue* aTaskQueue, const VideoInfo& aConfig, ImageContainer* aImageContainer)
+FFmpegVideoDecoder<LIBAV_VER>::FFmpegVideoDecoder(
+ FFmpegLibWrapper* aLib, TaskQueue* aTaskQueue, const VideoInfo& aConfig,
+ ImageContainer* aImageContainer)
: FFmpegDataDecoder(aLib, aTaskQueue, GetCodecId(aConfig.mMimeType))
, mImageContainer(aImageContainer)
, mInfo(aConfig)
, mCodecParser(nullptr)
, mLastInputDts(INT64_MIN)
{
MOZ_COUNT_CTOR(FFmpegVideoDecoder);
- // Use a new MediaByteBuffer as the object will be modified during initialization.
+ // Use a new MediaByteBuffer as the object will be modified during
+ // initialization.
mExtraData = new MediaByteBuffer;
mExtraData->AppendElements(*aConfig.mExtraData);
}
RefPtr<MediaDataDecoder::InitPromise>
FFmpegVideoDecoder<LIBAV_VER>::Init()
{
if (NS_FAILED(InitDecoder())) {
@@ -182,20 +182,19 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(
if (inputSize && mCodecParser && (mCodecID == AV_CODEC_ID_VP8
#if LIBAVCODEC_VERSION_MAJOR >= 55
|| mCodecID == AV_CODEC_ID_VP9
#endif
)) {
while (inputSize) {
uint8_t* data;
int size;
- int len = mLib->av_parser_parse2(mCodecParser, mCodecContext, &data, &size,
- inputData, inputSize,
- aSample->mTime, aSample->mTimecode,
- aSample->mOffset);
+ int len = mLib->av_parser_parse2(
+ mCodecParser, mCodecContext, &data, &size, inputData, inputSize,
+ aSample->mTime, aSample->mTimecode, aSample->mOffset);
if (size_t(len) > inputSize) {
return NS_ERROR_DOM_MEDIA_DECODE_ERR;
}
inputData += len;
inputSize -= len;
if (size) {
bool gotFrame = false;
MediaResult rv = DoDecode(aSample, data, size, &gotFrame, aResults);
@@ -276,18 +275,19 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(
if (!mDurationMap.Find(mFrame->pkt_dts, duration)) {
NS_WARNING("Unable to retrieve duration from map");
duration = aSample->mDuration;
// dts are probably incorrectly reported ; so clear the map as we're
// unlikely to find them in the future anyway. This also guards
// against the map becoming extremely big.
mDurationMap.Clear();
}
- FFMPEG_LOG("Got one frame output with pts=%lld dts=%lld duration=%lld opaque=%lld",
- pts, mFrame->pkt_dts, duration, mCodecContext->reordered_opaque);
+ FFMPEG_LOG(
+ "Got one frame output with pts=%lld dts=%lld duration=%lld opaque=%lld",
+ pts, mFrame->pkt_dts, duration, mCodecContext->reordered_opaque);
VideoData::YCbCrBuffer b;
b.mPlanes[0].mData = mFrame->data[0];
b.mPlanes[1].mData = mFrame->data[1];
b.mPlanes[2].mData = mFrame->data[2];
b.mPlanes[0].mStride = mFrame->linesize[0];
b.mPlanes[1].mStride = mFrame->linesize[1];
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h
@@ -43,18 +43,20 @@ public:
#endif
}
static AVCodecID GetCodecId(const nsACString& aMimeType);
private:
RefPtr<DecodePromise> ProcessDecode(MediaRawData* aSample) override;
RefPtr<DecodePromise> ProcessDrain() override;
RefPtr<FlushPromise> ProcessFlush() override;
- MediaResult DoDecode(MediaRawData* aSample, bool* aGotFrame, DecodedData& aResults);
- MediaResult DoDecode(MediaRawData* aSample, uint8_t* aData, int aSize, bool* aGotFrame, DecodedData& aResults);
+ MediaResult DoDecode(MediaRawData* aSample, bool* aGotFrame,
+ DecodedData& aResults);
+ MediaResult DoDecode(MediaRawData* aSample, uint8_t* aData, int aSize,
+ bool* aGotFrame, DecodedData& aResults);
void OutputDelayedFrames();
/**
* This method allocates a buffer for FFmpeg's decoder, wrapped in an Image.
* Currently it only supports Planar YUV420, which appears to be the only
* non-hardware accelerated image format that FFmpeg's H264 decoder is
* capable of outputting.
*/
@@ -62,34 +64,36 @@ private:
AVFrame* aFrame);
RefPtr<ImageContainer> mImageContainer;
VideoInfo mInfo;
// Parser used for VP8 and VP9 decoding.
AVCodecParserContext* mCodecParser;
- class PtsCorrectionContext {
+ class PtsCorrectionContext
+ {
public:
PtsCorrectionContext();
int64_t GuessCorrectPts(int64_t aPts, int64_t aDts);
void Reset();
int64_t LastDts() const { return mLastDts; }
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
+ int64_t mLastPts; /// PTS of the last frame
+ int64_t mLastDts; /// DTS of the last frame
};
PtsCorrectionContext mPtsContext;
int64_t mLastInputDts;
- class DurationMap {
+ class DurationMap
+ {
public:
typedef Pair<int64_t, int64_t> DurationElement;
// Insert Key and Duration pair at the end of our map.
void Insert(int64_t aKey, int64_t aDuration)
{
mMap.AppendElement(MakePair(aKey, aDuration));
}
--- a/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
+++ b/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
@@ -10,18 +10,17 @@
#include "nsIFile.h"
#include "prmem.h"
#include "prlink.h"
// We use a known symbol located in lgpllibs to determine its location.
// soundtouch happens to be always included in lgpllibs
#include "soundtouch/SoundTouch.h"
-namespace mozilla
-{
+namespace mozilla {
template <int V> class FFmpegDecoderModule
{
public:
static already_AddRefed<PlatformDecoderModule> Create(FFmpegLibWrapper*);
};
static FFmpegLibWrapper sFFVPXLib;