Merge mozilla-central to inbound to fix bustage

This commit is contained in:
Carsten "Tomcat" Book 2016-08-02 17:48:32 +02:00
Родитель 80b93cef57 740bb4ed16
Коммит aca03c331f
17 изменённых файлов: 40 добавлений и 188 удалений

Просмотреть файл

@ -797,17 +797,6 @@ HTMLMediaElement::MozDumpDebugInfo()
}
}
void
HTMLMediaElement::SetVisible(bool aVisible)
{
if (!mDecoder) {
return;
}
mDecoder->NotifyOwnerActivityChanged(aVisible);
}
already_AddRefed<DOMMediaStream>
HTMLMediaElement::GetSrcObject() const
{

Просмотреть файл

@ -606,8 +606,6 @@ public:
void MozDumpDebugInfo();
void SetVisible(bool aVisible);
already_AddRefed<DOMMediaStream> GetSrcObject() const;
void SetSrcObject(DOMMediaStream& aValue);
void SetSrcObject(DOMMediaStream* aValue);

Просмотреть файл

@ -317,11 +317,6 @@ public:
return &mIsSuspended;
}
// Switch the video decoder to BlankDecoderModule. It might takes effective
// since a few samples later depends on how much demuxed samples are already
// queued in the original video decoder.
virtual void SetVideoBlankDecode(bool aIsBlankDecode) {}
protected:
virtual ~MediaDecoderReader();

Просмотреть файл

@ -410,14 +410,4 @@ MediaDecoderReaderWrapper::OnMetadataRead(MetadataHolder* aMetadata)
}
}
void
MediaDecoderReaderWrapper::SetVideoBlankDecode(bool aIsBlankDecode)
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
nsCOMPtr<nsIRunnable> r =
NewRunnableMethod<bool>(mReader, &MediaDecoderReader::SetVideoBlankDecode,
aIsBlankDecode);
mReader->OwnerThread()->Dispatch(r.forget());
}
} // namespace mozilla

Просмотреть файл

@ -121,8 +121,6 @@ public:
void SetCDMProxy(CDMProxy* aProxy) { mReader->SetCDMProxy(aProxy); }
#endif
void SetVideoBlankDecode(bool aIsBlankDecode);
private:
~MediaDecoderReaderWrapper();

Просмотреть файл

@ -1362,7 +1362,6 @@ void MediaDecoderStateMachine::VisibilityChanged()
if (mVideoDecodeSuspended) {
mVideoDecodeSuspended = false;
mReader->SetVideoBlankDecode(false);
if (mIsReaderSuspended) {
return;
@ -2641,7 +2640,7 @@ bool MediaDecoderStateMachine::IsStateMachineScheduled() const
bool MediaDecoderStateMachine::IsVideoDecodeSuspended() const
{
MOZ_ASSERT(OnTaskQueue());
return mIsReaderSuspended;
return mVideoDecodeSuspended || mIsReaderSuspended;
}
void
@ -2933,7 +2932,6 @@ MediaDecoderStateMachine::OnSuspendTimerResolved()
DECODER_LOG("OnSuspendTimerResolved");
mVideoDecodeSuspendTimer.CompleteRequest();
mVideoDecodeSuspended = true;
mReader->SetVideoBlankDecode(true);
}
void

Просмотреть файл

@ -418,8 +418,7 @@ MediaFormatReader::EnsureDecoderCreated(TrackType aTrack)
decoder.mInfo ? *decoder.mInfo->GetAsAudioInfo() : mInfo.mAudio,
decoder.mTaskQueue,
decoder.mCallback.get(),
mCrashHelper,
decoder.mIsBlankDecode
mCrashHelper
});
break;
}
@ -433,8 +432,7 @@ MediaFormatReader::EnsureDecoderCreated(TrackType aTrack)
decoder.mCallback.get(),
mLayersBackendType,
GetImageContainer(),
mCrashHelper,
decoder.mIsBlankDecode
mCrashHelper
});
break;
}
@ -2062,32 +2060,4 @@ MediaFormatReader::GetMozDebugReaderData(nsAString& aString)
aString += NS_ConvertUTF8toUTF16(result);
}
void
MediaFormatReader::SetVideoBlankDecode(bool aIsBlankDecode)
{
MOZ_ASSERT(OnTaskQueue());
return SetBlankDecode(TrackType::kVideoTrack, aIsBlankDecode);
}
void
MediaFormatReader::SetBlankDecode(TrackType aTrack, bool aIsBlankDecode)
{
MOZ_ASSERT(OnTaskQueue());
auto& decoder = GetDecoderData(aTrack);
LOG("%s, decoder.mIsBlankDecode = %d => aIsBlankDecode = %d",
TrackTypeToStr(aTrack), decoder.mIsBlankDecode, aIsBlankDecode);
if (decoder.mIsBlankDecode == aIsBlankDecode) {
return;
}
decoder.mIsBlankDecode = aIsBlankDecode;
decoder.Flush();
decoder.ShutdownDecoder();
NotifyDecodingRequested(TrackInfo::kVideoTrack); // Calls ScheduleUpdate().
return;
}
} // namespace mozilla

Просмотреть файл

@ -101,8 +101,6 @@ public:
// Used for debugging purposes.
void GetMozDebugReaderData(nsAString& aString);
void SetVideoBlankDecode(bool aIsBlankDecode) override;
private:
bool HasVideo() { return mVideo.mTrackDemuxer; }
@ -255,7 +253,6 @@ private:
, mSizeOfQueue(0)
, mIsHardwareAccelerated(false)
, mLastStreamSourceID(UINT32_MAX)
, mIsBlankDecode(false)
{}
MediaFormatReader* mOwner;
@ -430,9 +427,6 @@ private:
Maybe<media::TimeUnit> mLastTimeRangesEnd;
RefPtr<SharedTrackInfo> mInfo;
Maybe<media::TimeUnit> mFirstDemuxedSampleTime;
// Use BlankDecoderModule or not.
bool mIsBlankDecode;
};
class DecoderDataWithPromise : public DecoderData {
@ -577,8 +571,6 @@ private:
RefPtr<CDMProxy> mCDMProxy;
#endif
RefPtr<GMPCrashHelper> mCrashHelper;
void SetBlankDecode(TrackType aTrack, bool aIsBlankDecode);
};
} // namespace mozilla

Просмотреть файл

@ -81,7 +81,6 @@ PDMFactory::PDMFactory()
{
EnsureInit();
CreatePDMs();
CreateBlankPDM();
}
PDMFactory::~PDMFactory()
@ -121,11 +120,6 @@ PDMFactory::EnsureInit() const
already_AddRefed<MediaDataDecoder>
PDMFactory::CreateDecoder(const CreateDecoderParams& aParams)
{
if (aParams.mUseBlankDecoder) {
MOZ_ASSERT(mBlankPDM);
return CreateDecoderWithPDM(mBlankPDM, aParams);
}
const TrackInfo& config = aParams.mConfig;
bool isEncrypted = mEMEPDM && config.mCrypto.mValid;
@ -293,13 +287,6 @@ PDMFactory::CreatePDMs()
}
}
void
PDMFactory::CreateBlankPDM()
{
mBlankPDM = CreateBlankDecoderModule();
MOZ_ASSERT(mBlankPDM && NS_SUCCEEDED(mBlankPDM->Startup()));
}
bool
PDMFactory::StartupPDM(PlatformDecoderModule* aPDM)
{

Просмотреть файл

@ -47,7 +47,6 @@ public:
private:
virtual ~PDMFactory();
void CreatePDMs();
void CreateBlankPDM();
// Startup the provided PDM and add it to our list if successful.
bool StartupPDM(PlatformDecoderModule* aPDM);
// Returns the first PDM in our list supporting the mimetype.
@ -61,7 +60,6 @@ private:
nsTArray<RefPtr<PlatformDecoderModule>> mCurrentPDMs;
RefPtr<PlatformDecoderModule> mEMEPDM;
RefPtr<PlatformDecoderModule> mBlankPDM;
bool mWMFFailedToLoad = false;
bool mFFmpegFailedToLoad = false;

Просмотреть файл

@ -64,7 +64,6 @@ struct CreateDecoderParams {
layers::ImageContainer* mImageContainer = nullptr;
layers::LayersBackend mLayersBackend = layers::LayersBackend::LAYERS_NONE;
RefPtr<GMPCrashHelper> mCrashHelper;
bool mUseBlankDecoder = false;
private:
void Set(TaskQueue* aTaskQueue) { mTaskQueue = aTaskQueue; }
@ -73,7 +72,6 @@ private:
void Set(layers::ImageContainer* aImageContainer) { mImageContainer = aImageContainer; }
void Set(layers::LayersBackend aLayersBackend) { mLayersBackend = aLayersBackend; }
void Set(GMPCrashHelper* aCrashHelper) { mCrashHelper = aCrashHelper; }
void Set(bool aUseBlankDecoder) { mUseBlankDecoder = aUseBlankDecoder; }
template <typename T1, typename T2, typename... Ts>
void Set(T1&& a1, T2&& a2, Ts&&... args)
{

Просмотреть файл

@ -4,7 +4,6 @@
* 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 "H264Converter.h"
#include "ImageContainer.h"
#include "MediaDecoderReader.h"
#include "MediaInfo.h"
@ -12,11 +11,9 @@
#include "mozilla/mozalloc.h" // for operator new, and new (fallible)
#include "mozilla/RefPtr.h"
#include "mozilla/TaskQueue.h"
#include "mp4_demuxer/H264.h"
#include "nsAutoPtr.h"
#include "nsRect.h"
#include "PlatformDecoderModule.h"
#include "ReorderQueue.h"
#include "TimeUnits.h"
#include "VideoUtils.h"
@ -32,10 +29,6 @@ public:
const CreateDecoderParams& aParams)
: mCreator(aCreator)
, mCallback(aParams.mCallback)
, mMaxRefFrames(aParams.mConfig.GetType() == TrackInfo::kVideoTrack &&
H264Converter::IsH264(aParams.mConfig)
? mp4_demuxer::H264::ComputeMaxRefFrames(aParams.VideoConfig().mExtraData)
: 0)
, mType(aParams.mConfig.GetType())
{
}
@ -54,25 +47,19 @@ public:
mCreator->Create(media::TimeUnit::FromMicroseconds(aSample->mTime),
media::TimeUnit::FromMicroseconds(aSample->mDuration),
aSample->mOffset);
OutputFrame(data);
return NS_OK;
}
nsresult Flush() override
{
mReorderQueue.Clear();
return NS_OK;
}
nsresult Drain() override
{
while (!mReorderQueue.IsEmpty()) {
mCallback->Output(mReorderQueue.Pop().get());
if (!data) {
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
} else {
mCallback->Output(data);
}
return NS_OK;
}
nsresult Flush() override {
return NS_OK;
}
nsresult Drain() override {
mCallback->DrainComplete();
return NS_OK;
}
@ -82,32 +69,9 @@ public:
return "blank media data decoder";
}
private:
void OutputFrame(MediaData* aData)
{
if (!aData) {
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
return;
}
// Frames come out in DTS order but we need to output them in PTS order.
mReorderQueue.Push(aData);
while (mReorderQueue.Length() > mMaxRefFrames) {
mCallback->Output(mReorderQueue.Pop().get());
}
if (mReorderQueue.Length() <= mMaxRefFrames) {
mCallback->InputExhausted();
}
}
private:
nsAutoPtr<BlankMediaDataCreator> mCreator;
MediaDataDecoderCallback* mCallback;
const uint32_t mMaxRefFrames;
ReorderQueue mReorderQueue;
TrackInfo::TrackType mType;
};
@ -129,10 +93,10 @@ public:
{
// Create a fake YUV buffer in a 420 format. That is, an 8bpp Y plane,
// with a U and V plane that are half the size of the Y plane, i.e 8 bit,
// 2x2 subsampled.
const int sizeY = mFrameWidth * mFrameHeight;
const int sizeCbCr = ((mFrameWidth + 1) / 2) * ((mFrameHeight + 1) / 2);
auto frame = MakeUnique<uint8_t[]>(sizeY + sizeCbCr);
// 2x2 subsampled. Have the data pointers of each frame point to the
// first plane, they'll always be zero'd memory anyway.
auto frame = MakeUnique<uint8_t[]>(mFrameWidth * mFrameHeight);
memset(frame.get(), 0, mFrameWidth * mFrameHeight);
VideoData::YCbCrBuffer buffer;
// Y plane.
@ -144,7 +108,7 @@ public:
buffer.mPlanes[0].mSkip = 0;
// Cb plane.
buffer.mPlanes[1].mData = frame.get() + sizeY;
buffer.mPlanes[1].mData = frame.get();
buffer.mPlanes[1].mStride = mFrameWidth / 2;
buffer.mPlanes[1].mHeight = mFrameHeight / 2;
buffer.mPlanes[1].mWidth = mFrameWidth / 2;
@ -152,17 +116,13 @@ public:
buffer.mPlanes[1].mSkip = 0;
// Cr plane.
buffer.mPlanes[2].mData = frame.get() + sizeY;
buffer.mPlanes[2].mData = frame.get();
buffer.mPlanes[2].mStride = mFrameWidth / 2;
buffer.mPlanes[2].mHeight = mFrameHeight / 2;
buffer.mPlanes[2].mWidth = mFrameWidth / 2;
buffer.mPlanes[2].mOffset = 0;
buffer.mPlanes[2].mSkip = 0;
// Set to color white.
memset(buffer.mPlanes[0].mData, 255, sizeY);
memset(buffer.mPlanes[1].mData, 128, sizeCbCr);
return VideoData::Create(mInfo,
mImageContainer,
nullptr,
@ -174,7 +134,6 @@ public:
aDTS.ToMicroseconds(),
mPicture);
}
private:
VideoInfo mInfo;
gfx::IntRect mPicture;
@ -183,6 +142,7 @@ private:
RefPtr<layers::ImageContainer> mImageContainer;
};
class BlankAudioDataCreator {
public:
BlankAudioDataCreator(uint32_t aChannelCount, uint32_t aSampleRate)
@ -269,11 +229,7 @@ public:
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override
{
if (aConfig.IsVideo() && H264Converter::IsH264(aConfig)) {
return kNeedAVCC;
} else {
return kNeedNone;
}
return kNeedNone;
}
};

Просмотреть файл

@ -11,9 +11,9 @@
#include "AppleUtils.h"
#include "AppleVTDecoder.h"
#include "AppleVTLinker.h"
#include "mp4_demuxer/H264.h"
#include "MediaData.h"
#include "mozilla/ArrayUtils.h"
#include "mp4_demuxer/H264.h"
#include "nsAutoPtr.h"
#include "nsThreadUtils.h"
#include "mozilla/Logging.h"
@ -24,6 +24,22 @@
namespace mozilla {
static uint32_t ComputeMaxRefFrames(const MediaByteBuffer* aExtraData)
{
uint32_t maxRefFrames = 4;
// Retrieve video dimensions from H264 SPS NAL.
mp4_demuxer::SPSData spsdata;
if (mp4_demuxer::H264::DecodeSPSFromExtraData(aExtraData, spsdata)) {
// max_num_ref_frames determines the size of the sliding window
// we need to queue that many frames in order to guarantee proper
// pts frames ordering. Use a minimum of 4 to ensure proper playback of
// non compliant videos.
maxRefFrames =
std::min(std::max(maxRefFrames, spsdata.max_num_ref_frames + 1), 16u);
}
return maxRefFrames;
}
AppleVTDecoder::AppleVTDecoder(const VideoInfo& aConfig,
TaskQueue* aTaskQueue,
MediaDataDecoderCallback* aCallback,
@ -36,7 +52,7 @@ AppleVTDecoder::AppleVTDecoder(const VideoInfo& aConfig,
, mDisplayHeight(aConfig.mDisplay.height)
, mQueuedSamples(0)
, mTaskQueue(aTaskQueue)
, mMaxRefFrames(mp4_demuxer::H264::ComputeMaxRefFrames(aConfig.mExtraData))
, mMaxRefFrames(ComputeMaxRefFrames(aConfig.mExtraData))
, mImageContainer(aImageContainer)
, mInputIncoming(0)
, mIsShutDown(false)

Просмотреть файл

@ -214,12 +214,3 @@ partial interface HTMLMediaElement {
[Throws, Pref="media.seekToNextFrame.enabled"]
Promise<void> seekToNextFrame();
};
/*
* This is an API for simulating visibility changes to help debug and write
* tests about suspend-video-decoding.
*/
partial interface HTMLMediaElement {
[Pref="media.test.setVisible"]
void setVisible(boolean aVisible);
};

Просмотреть файл

@ -531,21 +531,4 @@ H264::EnsureSPSIsSane(SPSData& aSPS)
return valid;
}
/* static */ uint32_t
H264::ComputeMaxRefFrames(const mozilla::MediaByteBuffer* aExtraData)
{
uint32_t maxRefFrames = 4;
// Retrieve video dimensions from H264 SPS NAL.
SPSData spsdata;
if (DecodeSPSFromExtraData(aExtraData, spsdata)) {
// max_num_ref_frames determines the size of the sliding window
// we need to queue that many frames in order to guarantee proper
// pts frames ordering. Use a minimum of 4 to ensure proper playback of
// non compliant videos.
maxRefFrames =
std::min(std::max(maxRefFrames, spsdata.max_num_ref_frames + 1), 16u);
}
return maxRefFrames;
}
} // namespace mp4_demuxer

Просмотреть файл

@ -332,24 +332,17 @@ class H264
{
public:
static bool DecodeSPSFromExtraData(const mozilla::MediaByteBuffer* aExtraData, SPSData& aDest);
/* Extract RAW BYTE SEQUENCE PAYLOAD from NAL content.
Returns nullptr if invalid content.
This is compliant to ITU H.264 7.3.1 Syntax in tabular form NAL unit syntax
*/
static already_AddRefed<mozilla::MediaByteBuffer> DecodeNALUnit(const mozilla::MediaByteBuffer* aNAL);
/* Decode SPS NAL RBSP and fill SPSData structure */
static bool DecodeSPS(const mozilla::MediaByteBuffer* aSPS, SPSData& aDest);
// Ensure that SPS data makes sense, Return true if SPS data was, and false
// otherwise. If false, then content will be adjusted accordingly.
static bool EnsureSPSIsSane(SPSData& aSPS);
// If the given aExtraData is valid, return the aExtraData.max_num_ref_frames
// clamped to be in the range of [4, 16]; otherwise return 4.
static uint32_t ComputeMaxRefFrames(const mozilla::MediaByteBuffer* aExtraData);
private:
static void vui_parameters(BitReader& aBr, SPSData& aDest);
// Read HRD parameters, all data is ignored.