зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1229963
- use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in dom/media/; r=cpearce
This commit is contained in:
Родитель
57ace7e27d
Коммит
ffeb7c7fe3
|
@ -88,7 +88,7 @@ public:
|
|||
void SetCapacity(uint32_t aCapacity) {
|
||||
MOZ_ASSERT(!mBuffer, "Buffer allocated.");
|
||||
mCapacity = aCapacity;
|
||||
mBuffer = new uint8_t[mCapacity];
|
||||
mBuffer = MakeUnique<uint8_t[]>(mCapacity);
|
||||
}
|
||||
|
||||
uint32_t Length() {
|
||||
|
@ -137,12 +137,12 @@ public:
|
|||
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
size_t amount = 0;
|
||||
amount += mBuffer.SizeOfExcludingThis(aMallocSizeOf);
|
||||
amount += aMallocSizeOf(mBuffer.get());
|
||||
return amount;
|
||||
}
|
||||
|
||||
private:
|
||||
nsAutoArrayPtr<uint8_t> mBuffer;
|
||||
UniquePtr<uint8_t[]> mBuffer;
|
||||
uint32_t mCapacity;
|
||||
uint32_t mStart;
|
||||
uint32_t mCount;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "MediaCache.h"
|
||||
#include "nsDeque.h"
|
||||
|
@ -96,7 +97,7 @@ public:
|
|||
explicit BlockChange(const uint8_t* aData)
|
||||
: mSourceBlockIndex(-1)
|
||||
{
|
||||
mData = new uint8_t[BLOCK_SIZE];
|
||||
mData = MakeUnique<uint8_t[]>(BLOCK_SIZE);
|
||||
memcpy(mData.get(), aData, BLOCK_SIZE);
|
||||
}
|
||||
|
||||
|
@ -105,7 +106,7 @@ public:
|
|||
explicit BlockChange(int32_t aSourceBlockIndex)
|
||||
: mSourceBlockIndex(aSourceBlockIndex) {}
|
||||
|
||||
nsAutoArrayPtr<uint8_t> mData;
|
||||
UniquePtr<uint8_t[]> mData;
|
||||
const int32_t mSourceBlockIndex;
|
||||
|
||||
bool IsMove() const {
|
||||
|
|
|
@ -379,7 +379,7 @@ MediaCacheStream::MediaCacheStream(ChannelMediaResource* aClient)
|
|||
mPinCount(0),
|
||||
mCurrentMode(MODE_PLAYBACK),
|
||||
mMetadataInPartialBlockBuffer(false),
|
||||
mPartialBlockBuffer(new int64_t[BLOCK_SIZE/sizeof(int64_t)])
|
||||
mPartialBlockBuffer(MakeUnique<int64_t[]>(BLOCK_SIZE/sizeof(int64_t)))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ size_t MediaCacheStream::SizeOfExcludingThis(
|
|||
size += mReadaheadBlocks.SizeOfExcludingThis(aMallocSizeOf);
|
||||
size += mMetadataBlocks.SizeOfExcludingThis(aMallocSizeOf);
|
||||
size += mPlayedBlocks.SizeOfExcludingThis(aMallocSizeOf);
|
||||
size += mPartialBlockBuffer.SizeOfExcludingThis(aMallocSizeOf);
|
||||
size += aMallocSizeOf(mPartialBlockBuffer.get());
|
||||
|
||||
return size;
|
||||
}
|
||||
|
@ -1842,7 +1842,7 @@ MediaCacheStream::FlushPartialBlockInternal(bool aNotifyAll,
|
|||
// Write back the partial block
|
||||
memset(reinterpret_cast<char*>(mPartialBlockBuffer.get()) + blockOffset, 0,
|
||||
BLOCK_SIZE - blockOffset);
|
||||
gMediaCache->AllocateAndWriteBlock(this, mPartialBlockBuffer,
|
||||
gMediaCache->AllocateAndWriteBlock(this, mPartialBlockBuffer.get(),
|
||||
mMetadataInPartialBlockBuffer ? MODE_METADATA : MODE_PLAYBACK);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "nsHashKeys.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "Intervals.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
class nsIPrincipal;
|
||||
|
||||
|
@ -510,7 +511,7 @@ private:
|
|||
// Use int64_t so that the data is well-aligned.
|
||||
// Heap allocate this buffer since the exact power-of-2 will cause allocation
|
||||
// slop when combined with the rest of the object members.
|
||||
nsAutoArrayPtr<int64_t> mPartialBlockBuffer;
|
||||
UniquePtr<int64_t[]> mPartialBlockBuffer;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#endif
|
||||
#include "VideoUtils.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include <cutils/properties.h>
|
||||
|
@ -533,8 +534,7 @@ MediaRawData::EnsureCapacity(size_t aSize)
|
|||
if (mData && mCapacity >= sizeNeeded) {
|
||||
return true;
|
||||
}
|
||||
nsAutoArrayPtr<uint8_t> newBuffer;
|
||||
newBuffer = new (fallible) uint8_t[sizeNeeded];
|
||||
auto newBuffer = MakeUniqueFallible<uint8_t[]>(sizeNeeded);
|
||||
if (!newBuffer) {
|
||||
return false;
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ MediaRawData::EnsureCapacity(size_t aSize)
|
|||
MOZ_ASSERT(uintptr_t(newData) % (RAW_DATA_ALIGNMENT+1) == 0);
|
||||
memcpy(newData, mData, mSize);
|
||||
|
||||
mBuffer = newBuffer.forget();
|
||||
mBuffer = Move(newBuffer);
|
||||
mCapacity = sizeNeeded;
|
||||
mData = newData;
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ private:
|
|||
bool EnsureCapacity(size_t aSize);
|
||||
uint8_t* mData;
|
||||
size_t mSize;
|
||||
nsAutoArrayPtr<uint8_t> mBuffer;
|
||||
UniquePtr<uint8_t[]> mBuffer;
|
||||
uint32_t mCapacity;
|
||||
CryptoSample mCryptoInternal;
|
||||
MediaRawData(const MediaRawData&); // Not implemented
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIStreamingProtocolService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
@ -72,7 +73,7 @@ public:
|
|||
MOZ_COUNT_CTOR(RtspTrackBuffer);
|
||||
mTrackIdx = aTrackIdx;
|
||||
MOZ_ASSERT(mSlotSize < UINT32_MAX / BUFFER_SLOT_NUM);
|
||||
mRingBuffer = new uint8_t[mTotalBufferSize];
|
||||
mRingBuffer = MakeUnique<uint8_t[]>(mTotalBufferSize);
|
||||
Reset();
|
||||
};
|
||||
~RtspTrackBuffer() {
|
||||
|
@ -85,7 +86,7 @@ public:
|
|||
size_t size = aMallocSizeOf(this);
|
||||
|
||||
// excluding this
|
||||
size += mRingBuffer.SizeOfExcludingThis(aMallocSizeOf);
|
||||
size += aMallocSizeOf(mRingBuffer.get());
|
||||
|
||||
return size;
|
||||
}
|
||||
|
@ -179,7 +180,7 @@ private:
|
|||
BufferSlotData mBufferSlotData[BUFFER_SLOT_NUM];
|
||||
|
||||
// The ring buffer pointer.
|
||||
nsAutoArrayPtr<uint8_t> mRingBuffer;
|
||||
UniquePtr<uint8_t[]> mRingBuffer;
|
||||
// Each slot's size.
|
||||
uint32_t mSlotSize;
|
||||
// Total mRingBuffer's total size.
|
||||
|
|
|
@ -68,7 +68,7 @@ VideoFrame::CreateBlackImage(const gfx::IntSize& aSize)
|
|||
data.mYSize = gfx::IntSize(aSize.width, aSize.height);
|
||||
data.mYStride = (int32_t) (aSize.width * lumaBpp / 8.0);
|
||||
data.mCbCrStride = (int32_t) (aSize.width * chromaBpp / 8.0);
|
||||
data.mCbChannel = frame.rwget() + aSize.height * data.mYStride;
|
||||
data.mCbChannel = frame.get() + aSize.height * data.mYStride;
|
||||
data.mCrChannel = data.mCbChannel + aSize.height * data.mCbCrStride / 2;
|
||||
data.mCbCrSize = gfx::IntSize(aSize.width / 2, aSize.height / 2);
|
||||
data.mPicX = 0;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Base64.h"
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISocketTransport.h"
|
||||
|
@ -263,7 +264,7 @@ ServeResourceEvent::Run() {
|
|||
// HTTP response headers sent below. A static_assert ensures
|
||||
// this where the buffer is used.
|
||||
const int buffer_size = 32768;
|
||||
nsAutoArrayPtr<char> b(new char[buffer_size]);
|
||||
auto b = MakeUnique<char[]>(buffer_size);
|
||||
|
||||
// If we know the length of the resource, send a Content-Length header.
|
||||
int64_t contentlength = resource->GetLength() - start;
|
||||
|
@ -271,8 +272,8 @@ ServeResourceEvent::Run() {
|
|||
static_assert (buffer_size > 1024,
|
||||
"buffer_size must be large enough "
|
||||
"to hold response headers");
|
||||
snprintf(b, buffer_size, "Content-Length: %" PRId64 "\r\n", contentlength);
|
||||
rv = WriteAll(b, strlen(b));
|
||||
snprintf(b.get(), buffer_size, "Content-Length: %" PRId64 "\r\n", contentlength);
|
||||
rv = WriteAll(b.get(), strlen(b.get()));
|
||||
if (NS_FAILED(rv)) { Shutdown(); return NS_OK; }
|
||||
}
|
||||
|
||||
|
@ -282,10 +283,10 @@ ServeResourceEvent::Run() {
|
|||
static_assert (buffer_size > 1024,
|
||||
"buffer_size must be large enough "
|
||||
"to hold response headers");
|
||||
snprintf(b, buffer_size, "Content-Range: "
|
||||
snprintf(b.get(), buffer_size, "Content-Range: "
|
||||
"bytes %" PRId64 "-%" PRId64 "/%" PRId64 "\r\n",
|
||||
start, resource->GetLength() - 1, resource->GetLength());
|
||||
rv = WriteAll(b, strlen(b));
|
||||
rv = WriteAll(b.get(), strlen(b.get()));
|
||||
if (NS_FAILED(rv)) { Shutdown(); return NS_OK; }
|
||||
}
|
||||
|
||||
|
@ -297,7 +298,7 @@ ServeResourceEvent::Run() {
|
|||
|
||||
// Read data from media resource
|
||||
uint32_t bytesRead = 0; // Number of bytes read/written to streams
|
||||
rv = resource->ReadAt(start, b, buffer_size, &bytesRead);
|
||||
rv = resource->ReadAt(start, b.get(), buffer_size, &bytesRead);
|
||||
while (NS_SUCCEEDED(rv) && bytesRead != 0) {
|
||||
// Keep track of what we think the starting position for the next read
|
||||
// is. This is used in subsequent ReadAt calls to ensure we are reading
|
||||
|
@ -306,10 +307,10 @@ ServeResourceEvent::Run() {
|
|||
start += bytesRead;
|
||||
|
||||
// Write data obtained from media resource to output stream
|
||||
rv = WriteAll(b, bytesRead);
|
||||
rv = WriteAll(b.get(), bytesRead);
|
||||
if (NS_FAILED (rv)) break;
|
||||
|
||||
rv = resource->ReadAt(start, b, 32768, &bytesRead);
|
||||
rv = resource->ReadAt(start, b.get(), 32768, &bytesRead);
|
||||
}
|
||||
|
||||
Shutdown();
|
||||
|
|
|
@ -127,7 +127,7 @@ TrackRunBox::fillSampleTable()
|
|||
return 0;
|
||||
}
|
||||
uint32_t len = frames.Length();
|
||||
sample_info_table = new tbl[len];
|
||||
sample_info_table = MakeUnique<tbl[]>(len);
|
||||
// Create sample table according to 14496-12 8.8.8.2.
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
// Sample size.
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsTArray.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "MuxerOperation.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#define WRITE_FULLBOX(_compositor, _size) \
|
||||
BoxSizeChecker checker(_compositor, _size); \
|
||||
|
@ -262,7 +263,7 @@ public:
|
|||
// the following are optional fields
|
||||
uint32_t data_offset; // data offset exists when audio/video are present in file.
|
||||
uint32_t first_sample_flags;
|
||||
nsAutoArrayPtr<tbl> sample_info_table;
|
||||
UniquePtr<tbl[]> sample_info_table;
|
||||
|
||||
// MuxerOperation methods
|
||||
nsresult Generate(uint32_t* aBoxSize) override;
|
||||
|
@ -404,7 +405,7 @@ public:
|
|||
} tbl;
|
||||
|
||||
uint32_t entry_count;
|
||||
nsAutoArrayPtr<tbl> sample_tbl;
|
||||
UniquePtr<tbl[]> sample_tbl;
|
||||
|
||||
// MuxerOperation methods
|
||||
nsresult Generate(uint32_t* aBoxSize) override;
|
||||
|
@ -430,7 +431,7 @@ public:
|
|||
} tbl;
|
||||
|
||||
uint32_t entry_count;
|
||||
nsAutoArrayPtr<tbl> sample_tbl;
|
||||
UniquePtr<tbl[]> sample_tbl;
|
||||
|
||||
// MuxerOperation methods
|
||||
nsresult Generate(uint32_t* aBoxSize) override;
|
||||
|
@ -455,7 +456,7 @@ public:
|
|||
} tbl;
|
||||
|
||||
uint32_t entry_count;
|
||||
nsAutoArrayPtr<tbl> sample_tbl;
|
||||
UniquePtr<tbl[]> sample_tbl;
|
||||
|
||||
// MuxerOperation methods
|
||||
nsresult Generate(uint32_t* aBoxSize) override;
|
||||
|
|
|
@ -44,7 +44,7 @@ MP4Stream::BlockingReadIntoCache(int64_t aOffset, size_t aCount, Monitor* aToUnl
|
|||
MOZ_ASSERT(block.mCount >= bytesRead);
|
||||
block.mCount = bytesRead;
|
||||
|
||||
mCache.AppendElement(block);
|
||||
mCache.AppendElement(Move(block));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -74,9 +75,15 @@ private:
|
|||
int64_t mOffset;
|
||||
size_t mCount;
|
||||
|
||||
CacheBlock(CacheBlock&& aOther)
|
||||
: mOffset(aOther.mOffset)
|
||||
, mCount(aOther.mCount)
|
||||
, mBuffer(Move(aOther.mBuffer))
|
||||
{}
|
||||
|
||||
bool Init()
|
||||
{
|
||||
mBuffer = new (fallible) char[mCount];
|
||||
mBuffer = MakeUniqueFallible<char[]>(mCount);
|
||||
return !!mBuffer;
|
||||
}
|
||||
|
||||
|
@ -87,7 +94,10 @@ private:
|
|||
}
|
||||
|
||||
private:
|
||||
nsAutoArrayPtr<char> mBuffer;
|
||||
CacheBlock(const CacheBlock&) = delete;
|
||||
CacheBlock& operator=(const CacheBlock&) = delete;
|
||||
|
||||
UniquePtr<char[]> mBuffer;
|
||||
};
|
||||
nsTArray<CacheBlock> mCache;
|
||||
};
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "GMPLoader.h"
|
||||
#include <stdio.h>
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "gmp-entrypoints.h"
|
||||
#include "prlink.h"
|
||||
#include "prenv.h"
|
||||
|
@ -247,12 +248,12 @@ GMPLoaderImpl::Load(const char* aUTF8LibPath,
|
|||
return false;
|
||||
}
|
||||
|
||||
nsAutoArrayPtr<wchar_t> widePath(new wchar_t[pathLen]);
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, aUTF8LibPath, -1, widePath, pathLen) == 0) {
|
||||
auto widePath = MakeUnique<wchar_t[]>(pathLen);
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, aUTF8LibPath, -1, widePath.get(), pathLen) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
libSpec.value.pathname_u = widePath;
|
||||
libSpec.value.pathname_u = widePath.get();
|
||||
libSpec.type = PR_LibSpec_PathnameU;
|
||||
#else
|
||||
libSpec.value.pathname = aUTF8LibPath;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/mozalloc.h" // for operator new, and new (fallible)
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/TaskQueue.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsRect.h"
|
||||
#include "PlatformDecoderModule.h"
|
||||
#include "TimeUnits.h"
|
||||
|
@ -118,12 +119,12 @@ public:
|
|||
// with a U and V plane that are half the size of the Y plane, i.e 8 bit,
|
||||
// 2x2 subsampled. Have the data pointers of each frame point to the
|
||||
// first plane, they'll always be zero'd memory anyway.
|
||||
nsAutoArrayPtr<uint8_t> frame(new uint8_t[mFrameWidth * mFrameHeight]);
|
||||
memset(frame, 0, mFrameWidth * mFrameHeight);
|
||||
auto frame = MakeUnique<uint8_t[]>(mFrameWidth * mFrameHeight);
|
||||
memset(frame.get(), 0, mFrameWidth * mFrameHeight);
|
||||
VideoData::YCbCrBuffer buffer;
|
||||
|
||||
// Y plane.
|
||||
buffer.mPlanes[0].mData = frame;
|
||||
buffer.mPlanes[0].mData = frame.get();
|
||||
buffer.mPlanes[0].mStride = mFrameWidth;
|
||||
buffer.mPlanes[0].mHeight = mFrameHeight;
|
||||
buffer.mPlanes[0].mWidth = mFrameWidth;
|
||||
|
@ -131,7 +132,7 @@ public:
|
|||
buffer.mPlanes[0].mSkip = 0;
|
||||
|
||||
// Cb plane.
|
||||
buffer.mPlanes[1].mData = frame;
|
||||
buffer.mPlanes[1].mData = frame.get();
|
||||
buffer.mPlanes[1].mStride = mFrameWidth / 2;
|
||||
buffer.mPlanes[1].mHeight = mFrameHeight / 2;
|
||||
buffer.mPlanes[1].mWidth = mFrameWidth / 2;
|
||||
|
@ -139,7 +140,7 @@ public:
|
|||
buffer.mPlanes[1].mSkip = 0;
|
||||
|
||||
// Cr plane.
|
||||
buffer.mPlanes[2].mData = frame;
|
||||
buffer.mPlanes[2].mData = frame.get();
|
||||
buffer.mPlanes[2].mStride = mFrameWidth / 2;
|
||||
buffer.mPlanes[2].mHeight = mFrameHeight / 2;
|
||||
buffer.mPlanes[2].mWidth = mFrameWidth / 2;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "MediaInfo.h"
|
||||
#include "AppleATDecoder.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
extern mozilla::LogModule* GetPDMLog();
|
||||
#define LOG(...) MOZ_LOG(GetPDMLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
|
||||
|
@ -211,8 +212,7 @@ AppleATDecoder::DecodeSample(MediaRawData* aSample)
|
|||
const uint32_t maxDecodedSamples = MAX_AUDIO_FRAMES * channels;
|
||||
|
||||
// Descriptions for _decompressed_ audio packets. ignored.
|
||||
nsAutoArrayPtr<AudioStreamPacketDescription>
|
||||
packets(new AudioStreamPacketDescription[MAX_AUDIO_FRAMES]);
|
||||
auto packets = MakeUnique<AudioStreamPacketDescription[]>(MAX_AUDIO_FRAMES);
|
||||
|
||||
// This API insists on having packets spoon-fed to it from a callback.
|
||||
// This structure exists only to pass our state.
|
||||
|
@ -220,7 +220,7 @@ AppleATDecoder::DecodeSample(MediaRawData* aSample)
|
|||
{ channels, (UInt32)aSample->Size(), aSample->Data() };
|
||||
|
||||
// Decompressed audio buffer
|
||||
nsAutoArrayPtr<AudioDataValue> decoded(new AudioDataValue[maxDecodedSamples]);
|
||||
auto decoded = MakeUnique<AudioDataValue[]>(maxDecodedSamples);
|
||||
|
||||
do {
|
||||
AudioBufferList decBuffer;
|
||||
|
@ -328,14 +328,13 @@ AppleATDecoder::GetInputAudioDescription(AudioStreamBasicDescription& aDesc,
|
|||
return NS_OK;
|
||||
}
|
||||
size_t listCount = formatListSize / sizeof(AudioFormatListItem);
|
||||
nsAutoArrayPtr<AudioFormatListItem> formatList(
|
||||
new AudioFormatListItem[listCount]);
|
||||
auto formatList = MakeUnique<AudioFormatListItem[]>(listCount);
|
||||
|
||||
rv = AudioFormatGetProperty(kAudioFormatProperty_FormatList,
|
||||
sizeof(formatInfo),
|
||||
&formatInfo,
|
||||
&formatListSize,
|
||||
formatList);
|
||||
formatList.get());
|
||||
if (rv) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -348,7 +347,7 @@ AppleATDecoder::GetInputAudioDescription(AudioStreamBasicDescription& aDesc,
|
|||
UInt32 indexSize = sizeof(itemIndex);
|
||||
rv = AudioFormatGetProperty(kAudioFormatProperty_FirstPlayableFormatFromList,
|
||||
formatListSize,
|
||||
formatList,
|
||||
formatList.get(),
|
||||
&indexSize,
|
||||
&itemIndex);
|
||||
if (rv) {
|
||||
|
@ -438,9 +437,9 @@ _MetadataCallback(void* aAppleATDecoder,
|
|||
decoder->mFileStreamError = true;
|
||||
return;
|
||||
}
|
||||
nsAutoArrayPtr<uint8_t> data(new uint8_t[size]);
|
||||
auto data = MakeUnique<uint8_t[]>(size);
|
||||
rv = AudioFileStreamGetProperty(aStream, aProperty,
|
||||
&size, data);
|
||||
&size, data.get());
|
||||
if (rv) {
|
||||
LOG("Couldn't get property '%s' (%s)",
|
||||
FourCC2Str(aProperty), FourCC2Str(rv));
|
||||
|
|
|
@ -669,8 +669,7 @@ GonkVideoDecoderManager::GetColorConverterBuffer(int32_t aWidth, int32_t aHeight
|
|||
size_t yuv420p_v_size = yuv420p_u_size;
|
||||
size_t yuv420p_size = yuv420p_y_size + yuv420p_u_size + yuv420p_v_size;
|
||||
if (mColorConverterBufferSize != yuv420p_size) {
|
||||
mColorConverterBuffer = nullptr; // release the previous buffer first
|
||||
mColorConverterBuffer = new uint8_t[yuv420p_size];
|
||||
mColorConverterBuffer = MakeUnique<uint8_t[]>(yuv420p_size);
|
||||
mColorConverterBufferSize = yuv420p_size;
|
||||
}
|
||||
return mColorConverterBuffer.get();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "GonkNativeWindow.h"
|
||||
#include "GonkNativeWindowClient.h"
|
||||
#include "mozilla/layers/FenceUtils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include <ui/Fence.h>
|
||||
|
||||
using namespace android;
|
||||
|
@ -112,7 +113,7 @@ private:
|
|||
|
||||
// color converter
|
||||
android::I420ColorConverterHelper mColorConverter;
|
||||
nsAutoArrayPtr<uint8_t> mColorConverterBuffer;
|
||||
UniquePtr<uint8_t[]> mColorConverterBuffer;
|
||||
size_t mColorConverterBufferSize;
|
||||
|
||||
android::sp<android::GonkNativeWindow> mNativeWindow;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "VideoUtils.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "gfx2DGlue.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::media;
|
||||
|
@ -138,7 +139,7 @@ bool RawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||
int64_t currentFrameTime = USECS_PER_S * mCurrentFrame / mFrameRate;
|
||||
uint32_t length = mFrameSize - sizeof(RawPacketHeader);
|
||||
|
||||
nsAutoArrayPtr<uint8_t> buffer(new uint8_t[length]);
|
||||
auto buffer = MakeUnique<uint8_t[]>(length);
|
||||
|
||||
// We're always decoding one frame when called
|
||||
while(true) {
|
||||
|
@ -151,7 +152,7 @@ bool RawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!ReadFromResource(buffer, length)) {
|
||||
if (!ReadFromResource(buffer.get(), length)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -165,7 +166,7 @@ bool RawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||
}
|
||||
|
||||
VideoData::YCbCrBuffer b;
|
||||
b.mPlanes[0].mData = buffer;
|
||||
b.mPlanes[0].mData = buffer.get();
|
||||
b.mPlanes[0].mStride = mMetadata.frameWidth * mMetadata.lumaChannelBpp / 8.0;
|
||||
b.mPlanes[0].mHeight = mMetadata.frameHeight;
|
||||
b.mPlanes[0].mWidth = mMetadata.frameWidth;
|
||||
|
@ -173,7 +174,7 @@ bool RawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||
|
||||
uint32_t cbcrStride = mMetadata.frameWidth * mMetadata.chromaChannelBpp / 8.0;
|
||||
|
||||
b.mPlanes[1].mData = buffer + mMetadata.frameHeight * b.mPlanes[0].mStride;
|
||||
b.mPlanes[1].mData = buffer.get() + mMetadata.frameHeight * b.mPlanes[0].mStride;
|
||||
b.mPlanes[1].mStride = cbcrStride;
|
||||
b.mPlanes[1].mHeight = mMetadata.frameHeight / 2;
|
||||
b.mPlanes[1].mWidth = mMetadata.frameWidth / 2;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Endian.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla::media;
|
||||
|
@ -191,9 +192,9 @@ bool WaveReader::DecodeAudioData()
|
|||
|
||||
static_assert(uint64_t(BLOCK_SIZE) < UINT_MAX / sizeof(char),
|
||||
"BLOCK_SIZE too large for enumerator.");
|
||||
nsAutoArrayPtr<char> dataBuffer(new char[static_cast<size_t>(readSize)]);
|
||||
auto dataBuffer = MakeUnique<char[]>(static_cast<size_t>(readSize));
|
||||
|
||||
if (!ReadAll(dataBuffer, readSize)) {
|
||||
if (!ReadAll(dataBuffer.get(), readSize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -406,7 +407,7 @@ WaveReader::LoadFormatChunk(uint32_t aChunkSize)
|
|||
if (extra > 0) {
|
||||
static_assert(UINT16_MAX + (UINT16_MAX % 2) < UINT_MAX / sizeof(char),
|
||||
"chunkExtension array too large for iterator.");
|
||||
nsAutoArrayPtr<char> chunkExtension(new char[extra]);
|
||||
auto chunkExtension = MakeUnique<char[]>(extra);
|
||||
if (!ReadAll(chunkExtension.get(), extra)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -528,7 +529,7 @@ WaveReader::LoadListChunk(uint32_t aChunkSize,
|
|||
return false;
|
||||
}
|
||||
|
||||
nsAutoArrayPtr<char> chunk(new char[aChunkSize]);
|
||||
auto chunk = MakeUnique<char[]>(aChunkSize);
|
||||
if (!ReadAll(chunk.get(), aChunkSize)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -652,7 +653,7 @@ WaveReader::LoadAllChunks(nsAutoPtr<dom::HTMLMediaElement::MetadataTags> &aTags)
|
|||
static const int64_t MAX_CHUNK_SIZE = 1 << 16;
|
||||
static_assert(uint64_t(MAX_CHUNK_SIZE) < UINT_MAX / sizeof(char),
|
||||
"MAX_CHUNK_SIZE too large for enumerator.");
|
||||
nsAutoArrayPtr<char> chunk(new char[MAX_CHUNK_SIZE]);
|
||||
auto chunk = MakeUnique<char[]>(MAX_CHUNK_SIZE);
|
||||
while (forward.value() > 0) {
|
||||
int64_t size = std::min(forward.value(), MAX_CHUNK_SIZE);
|
||||
if (!ReadAll(chunk.get(), size)) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "WebAudioUtils.h"
|
||||
#include "blink/Biquad.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "AudioParamTimeline.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -316,7 +317,7 @@ BiquadFilterNode::GetFrequencyResponse(const Float32Array& aFrequencyHz,
|
|||
return;
|
||||
}
|
||||
|
||||
nsAutoArrayPtr<float> frequencies(new float[length]);
|
||||
auto frequencies = MakeUnique<float[]>(length);
|
||||
float* frequencyHz = aFrequencyHz.Data();
|
||||
const double nyquist = Context()->SampleRate() * 0.5;
|
||||
|
||||
|
@ -338,7 +339,7 @@ BiquadFilterNode::GetFrequencyResponse(const Float32Array& aFrequencyHz,
|
|||
|
||||
WebCore::Biquad biquad;
|
||||
SetParamsOnBiquad(biquad, Context()->SampleRate(), mType, freq, q, gain, detune);
|
||||
biquad.getFrequencyResponse(int(length), frequencies, aMagResponse.Data(), aPhaseResponse.Data());
|
||||
biquad.getFrequencyResponse(int(length), frequencies.get(), aMagResponse.Data(), aPhaseResponse.Data());
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -69,8 +69,8 @@ size_t DynamicsCompressor::sizeOfIncludingThis(mozilla::MallocSizeOf aMallocSize
|
|||
}
|
||||
}
|
||||
|
||||
amount += m_sourceChannels.SizeOfExcludingThis(aMallocSizeOf);
|
||||
amount += m_destinationChannels.SizeOfExcludingThis(aMallocSizeOf);
|
||||
amount += aMallocSizeOf(m_sourceChannels.get());
|
||||
amount += aMallocSizeOf(m_destinationChannels.get());
|
||||
amount += m_compressor.sizeOfExcludingThis(aMallocSizeOf);
|
||||
return amount;
|
||||
}
|
||||
|
@ -308,8 +308,8 @@ void DynamicsCompressor::setNumberOfChannels(unsigned numberOfChannels)
|
|||
m_postFilterPacks.AppendElement(new ZeroPoleFilterPack4());
|
||||
}
|
||||
|
||||
m_sourceChannels = new const float* [numberOfChannels];
|
||||
m_destinationChannels = new float* [numberOfChannels];
|
||||
m_sourceChannels = mozilla::MakeUnique<const float* []>(numberOfChannels);
|
||||
m_destinationChannels = mozilla::MakeUnique<float* []>(numberOfChannels);
|
||||
|
||||
m_compressor.setNumberOfChannels(numberOfChannels);
|
||||
m_numberOfChannels = numberOfChannels;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "nsTArray.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
class AudioBlock;
|
||||
|
@ -115,8 +116,8 @@ protected:
|
|||
nsTArray<nsAutoPtr<ZeroPoleFilterPack4> > m_preFilterPacks;
|
||||
nsTArray<nsAutoPtr<ZeroPoleFilterPack4> > m_postFilterPacks;
|
||||
|
||||
nsAutoArrayPtr<const float*> m_sourceChannels;
|
||||
nsAutoArrayPtr<float*> m_destinationChannels;
|
||||
mozilla::UniquePtr<const float*[]> m_sourceChannels;
|
||||
mozilla::UniquePtr<float*[]> m_destinationChannels;
|
||||
|
||||
void setEmphasisStageParameters(unsigned stageIndex, float gain, float normalizedFrequency /* 0 -> 1 */);
|
||||
void setEmphasisParameters(float gain, float anchorFreq, float filterStageRatio);
|
||||
|
|
|
@ -40,6 +40,7 @@ using namespace std;
|
|||
using namespace mozilla::dom; // for WebAudioUtils
|
||||
using mozilla::IsInfinite;
|
||||
using mozilla::IsNaN;
|
||||
using mozilla::MakeUnique;
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
|
@ -78,7 +79,7 @@ size_t DynamicsCompressorKernel::sizeOfExcludingThis(mozilla::MallocSizeOf aMall
|
|||
size_t amount = 0;
|
||||
amount += m_preDelayBuffers.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
for (size_t i = 0; i < m_preDelayBuffers.Length(); i++) {
|
||||
amount += m_preDelayBuffers[i].SizeOfExcludingThis(aMallocSizeOf);
|
||||
amount += aMallocSizeOf(m_preDelayBuffers[i].get());
|
||||
}
|
||||
|
||||
return amount;
|
||||
|
@ -91,7 +92,7 @@ void DynamicsCompressorKernel::setNumberOfChannels(unsigned numberOfChannels)
|
|||
|
||||
m_preDelayBuffers.Clear();
|
||||
for (unsigned i = 0; i < numberOfChannels; ++i)
|
||||
m_preDelayBuffers.AppendElement(new float[MaxPreDelayFrames]);
|
||||
m_preDelayBuffers.AppendElement(MakeUnique<float[]>(MaxPreDelayFrames));
|
||||
}
|
||||
|
||||
void DynamicsCompressorKernel::setPreDelayTime(float preDelayTime)
|
||||
|
@ -104,7 +105,7 @@ void DynamicsCompressorKernel::setPreDelayTime(float preDelayTime)
|
|||
if (m_lastPreDelayFrames != preDelayFrames) {
|
||||
m_lastPreDelayFrames = preDelayFrames;
|
||||
for (unsigned i = 0; i < m_preDelayBuffers.Length(); ++i)
|
||||
memset(m_preDelayBuffers[i], 0, sizeof(float) * MaxPreDelayFrames);
|
||||
memset(m_preDelayBuffers[i].get(), 0, sizeof(float) * MaxPreDelayFrames);
|
||||
|
||||
m_preDelayReadIndex = 0;
|
||||
m_preDelayWriteIndex = preDelayFrames;
|
||||
|
@ -387,7 +388,7 @@ void DynamicsCompressorKernel::process(float* sourceChannels[],
|
|||
|
||||
// Predelay signal, computing compression amount from un-delayed version.
|
||||
for (unsigned i = 0; i < numberOfChannels; ++i) {
|
||||
float* delayBuffer = m_preDelayBuffers[i];
|
||||
float* delayBuffer = m_preDelayBuffers[i].get();
|
||||
float undelayedSource = sourceChannels[i][frameIndex];
|
||||
delayBuffer[preDelayWriteIndex] = undelayedSource;
|
||||
|
||||
|
@ -453,7 +454,7 @@ void DynamicsCompressorKernel::process(float* sourceChannels[],
|
|||
|
||||
// Apply final gain.
|
||||
for (unsigned i = 0; i < numberOfChannels; ++i) {
|
||||
float* delayBuffer = m_preDelayBuffers[i];
|
||||
float* delayBuffer = m_preDelayBuffers[i].get();
|
||||
destinationChannels[i][frameIndex] = delayBuffer[preDelayReadIndex] * totalGain;
|
||||
}
|
||||
|
||||
|
@ -479,7 +480,7 @@ void DynamicsCompressorKernel::reset()
|
|||
|
||||
// Predelay section.
|
||||
for (unsigned i = 0; i < m_preDelayBuffers.Length(); ++i)
|
||||
memset(m_preDelayBuffers[i], 0, sizeof(float) * MaxPreDelayFrames);
|
||||
memset(m_preDelayBuffers[i].get(), 0, sizeof(float) * MaxPreDelayFrames);
|
||||
|
||||
m_preDelayReadIndex = 0;
|
||||
m_preDelayWriteIndex = DefaultPreDelayFrames;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "nsTArray.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
|
@ -89,7 +90,7 @@ protected:
|
|||
unsigned m_lastPreDelayFrames;
|
||||
void setPreDelayTime(float);
|
||||
|
||||
nsTArray<nsAutoArrayPtr<float> > m_preDelayBuffers;
|
||||
nsTArray<mozilla::UniquePtr<float[]>> m_preDelayBuffers;
|
||||
int m_preDelayReadIndex;
|
||||
int m_preDelayWriteIndex;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ void EbmlComposer::GenerateHeader()
|
|||
// Write the EBML header.
|
||||
EbmlGlobal ebml;
|
||||
// The WEbM header default size usually smaller than 1k.
|
||||
nsAutoArrayPtr<uint8_t> buffer(new uint8_t[DEFAULT_HEADER_SIZE +
|
||||
mCodecPrivateData.Length()]);
|
||||
auto buffer = MakeUnique<uint8_t[]>(DEFAULT_HEADER_SIZE +
|
||||
mCodecPrivateData.Length());
|
||||
ebml.buf = buffer.get();
|
||||
ebml.offset = 0;
|
||||
writeHeader(&ebml);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "Layers.h"
|
||||
#include "ImageContainer.h"
|
||||
|
@ -314,7 +315,7 @@ public:
|
|||
// If we allow arbitrary frequencies, there's no guarantee we won't get rounded here
|
||||
// We could include an error term and adjust for it in generation; not worth the trouble
|
||||
//MOZ_ASSERT(mTotalLength * aFrequency == aSampleRate);
|
||||
mAudioBuffer = new int16_t[mTotalLength];
|
||||
mAudioBuffer = MakeUnique<int16_t[]>(mTotalLength);
|
||||
for (int i = 0; i < mTotalLength; i++) {
|
||||
// Set volume to -20db. It's from 32768.0 * 10^(-20/20) = 3276.8
|
||||
mAudioBuffer[i] = (3276.8f * sin(2 * M_PI * i / mTotalLength));
|
||||
|
@ -333,7 +334,7 @@ public:
|
|||
} else {
|
||||
processSamples = mTotalLength - mReadLength;
|
||||
}
|
||||
memcpy(aBuffer, mAudioBuffer + mReadLength, processSamples * bytesPerSample);
|
||||
memcpy(aBuffer, &mAudioBuffer[mReadLength], processSamples * bytesPerSample);
|
||||
aBuffer += processSamples;
|
||||
mReadLength += processSamples;
|
||||
remaining -= processSamples;
|
||||
|
@ -344,7 +345,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
nsAutoArrayPtr<int16_t> mAudioBuffer;
|
||||
UniquePtr<int16_t[]> mAudioBuffer;
|
||||
int16_t mTotalLength;
|
||||
int16_t mReadLength;
|
||||
};
|
||||
|
|
|
@ -152,8 +152,8 @@ FakeDirectAudioSynth::Speak(const nsAString& aText, const nsAString& aUri,
|
|||
// Just an arbitrary multiplier. Pretend that each character is
|
||||
// synthesized to 40 frames.
|
||||
uint32_t frames_length = 40 * mText.Length();
|
||||
nsAutoArrayPtr<int16_t> frames(new int16_t[frames_length]());
|
||||
mTask->SendAudioNative(frames, frames_length);
|
||||
auto frames = MakeUnique<int16_t[]>(frames_length);
|
||||
mTask->SendAudioNative(frames.get(), frames_length);
|
||||
|
||||
mTask->SendAudioNative(nullptr, 0);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче