зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1262278 - Rename PlanarYCbCrImage::SetData and PlanarYCbCrImage::SetDataNoCopy r=nical
This commit is contained in:
Родитель
2792ab700c
Коммит
3b81e9dd7d
|
@ -2382,7 +2382,7 @@ nsGonkCameraControl::OnNewPreviewFrame(layers::TextureClient* aBuffer)
|
||||||
|
|
||||||
IntSize picSize(mCurrentConfiguration.mPreviewSize.width,
|
IntSize picSize(mCurrentConfiguration.mPreviewSize.width,
|
||||||
mCurrentConfiguration.mPreviewSize.height);
|
mCurrentConfiguration.mPreviewSize.height);
|
||||||
frame->SetData(aBuffer, picSize);
|
frame->AdoptData(aBuffer, picSize);
|
||||||
|
|
||||||
if (mCapturePoster.exchange(false)) {
|
if (mCapturePoster.exchange(false)) {
|
||||||
CreatePoster(frame,
|
CreatePoster(frame,
|
||||||
|
|
|
@ -247,9 +247,9 @@ bool VideoData::SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
|
||||||
|
|
||||||
aVideoImage->SetDelayedConversion(true);
|
aVideoImage->SetDelayedConversion(true);
|
||||||
if (aCopyData) {
|
if (aCopyData) {
|
||||||
return aVideoImage->SetData(data);
|
return aVideoImage->CopyData(data);
|
||||||
} else {
|
} else {
|
||||||
return aVideoImage->SetDataNoCopy(data);
|
return aVideoImage->AdoptData(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ VideoData::Create(const VideoInfo& aInfo,
|
||||||
0));
|
0));
|
||||||
|
|
||||||
RefPtr<layers::GrallocImage> image = new layers::GrallocImage();
|
RefPtr<layers::GrallocImage> image = new layers::GrallocImage();
|
||||||
image->SetData(aBuffer, aPicture.Size());
|
image->AdoptData(aBuffer, aPicture.Size());
|
||||||
v->mImage = image;
|
v->mImage = image;
|
||||||
|
|
||||||
return v.forget();
|
return v.forget();
|
||||||
|
|
|
@ -890,7 +890,7 @@ SetImageToBlackPixel(PlanarYCbCrImage* aImage)
|
||||||
data.mCrChannel = blackPixel + 2;
|
data.mCrChannel = blackPixel + 2;
|
||||||
data.mYStride = data.mCbCrStride = 1;
|
data.mYStride = data.mCbCrStride = 1;
|
||||||
data.mPicSize = data.mYSize = data.mCbCrSize = IntSize(1, 1);
|
data.mPicSize = data.mYSize = data.mCbCrSize = IntSize(1, 1);
|
||||||
aImage->SetData(data);
|
aImage->CopyData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
class VideoFrameContainerInvalidateRunnable : public nsRunnable {
|
class VideoFrameContainerInvalidateRunnable : public nsRunnable {
|
||||||
|
|
|
@ -79,8 +79,8 @@ VideoFrame::CreateBlackImage(const gfx::IntSize& aSize)
|
||||||
data.mPicSize = gfx::IntSize(aSize.width, aSize.height);
|
data.mPicSize = gfx::IntSize(aSize.width, aSize.height);
|
||||||
data.mStereoMode = StereoMode::MONO;
|
data.mStereoMode = StereoMode::MONO;
|
||||||
|
|
||||||
// SetData copies data, so we can free data.
|
// Copies data, so we can free data.
|
||||||
if (!image->SetData(data)) {
|
if (!image->CopyData(data)) {
|
||||||
MOZ_ASSERT(false);
|
MOZ_ASSERT(false);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,7 +421,7 @@ AndroidMediaReader::ImageBufferCallback::CreateI420Image(size_t aWidth,
|
||||||
frameDesc.mPicY = 0;
|
frameDesc.mPicY = 0;
|
||||||
frameDesc.mPicSize = IntSize(aWidth, aHeight);
|
frameDesc.mPicSize = IntSize(aWidth, aHeight);
|
||||||
|
|
||||||
yuvImage->SetDataNoCopy(frameDesc);
|
yuvImage->AdoptData(frameDesc);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ private:
|
||||||
data.mCbCrSize.width = halfWidth;
|
data.mCbCrSize.width = halfWidth;
|
||||||
data.mCbCrSize.height = halfHeight;
|
data.mCbCrSize.height = halfHeight;
|
||||||
|
|
||||||
image->SetData(data);
|
image->CopyData(data);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ private:
|
||||||
data.mCbCrSize.width = halfWidth;
|
data.mCbCrSize.width = halfWidth;
|
||||||
data.mCbCrSize.height = halfHeight;
|
data.mCbCrSize.height = halfHeight;
|
||||||
|
|
||||||
image->SetData(data);
|
image->CopyData(data);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ private:
|
||||||
data.mCbCrSize.width = halfWidth;
|
data.mCbCrSize.width = halfWidth;
|
||||||
data.mCbCrSize.height = halfHeight;
|
data.mCbCrSize.height = halfHeight;
|
||||||
|
|
||||||
image->SetData(data);
|
image->CopyData(data);
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -489,7 +489,7 @@ OMXVideoEncoder::Encode(const Image* aImage, int aWidth, int aHeight,
|
||||||
NS_ENSURE_TRUE(aWidth == size.width, NS_ERROR_INVALID_ARG);
|
NS_ENSURE_TRUE(aWidth == size.width, NS_ERROR_INVALID_ARG);
|
||||||
NS_ENSURE_TRUE(aHeight == size.height, NS_ERROR_INVALID_ARG);
|
NS_ENSURE_TRUE(aHeight == size.height, NS_ERROR_INVALID_ARG);
|
||||||
if (format == ImageFormat::PLANAR_YCBCR) {
|
if (format == ImageFormat::PLANAR_YCBCR) {
|
||||||
// Test for data, allowing SetDataNoCopy() on an image without an mBuffer
|
// Test for data, allowing AdoptData() on an image without an mBuffer
|
||||||
// (as used from WebrtcOMXH264VideoCodec, and a few other places) - bug 1067442
|
// (as used from WebrtcOMXH264VideoCodec, and a few other places) - bug 1067442
|
||||||
const PlanarYCbCrData* yuv = static_cast<PlanarYCbCrImage*>(img)->GetData();
|
const PlanarYCbCrData* yuv = static_cast<PlanarYCbCrImage*>(img)->GetData();
|
||||||
NS_ENSURE_TRUE(yuv->mYChannel, NS_ERROR_INVALID_ARG);
|
NS_ENSURE_TRUE(yuv->mYChannel, NS_ERROR_INVALID_ARG);
|
||||||
|
|
|
@ -251,7 +251,7 @@ MediaEngineDefaultVideoSource::Notify(nsITimer* aTimer)
|
||||||
0, 0);
|
0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool setData = ycbcr_image->SetData(data);
|
bool setData = ycbcr_image->CopyData(data);
|
||||||
MOZ_ASSERT(setData);
|
MOZ_ASSERT(setData);
|
||||||
|
|
||||||
// SetData copies data, so we can free the frame
|
// SetData copies data, so we can free the frame
|
||||||
|
|
|
@ -789,7 +789,7 @@ MediaEngineGonkVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth,
|
||||||
libyuv::FOURCC_NV21);
|
libyuv::FOURCC_NV21);
|
||||||
destBuffer->unlock();
|
destBuffer->unlock();
|
||||||
|
|
||||||
image->AsGrallocImage()->SetData(textureClient, gfx::IntSize(dstWidth, dstHeight));
|
image->AsGrallocImage()->AdoptData(textureClient, gfx::IntSize(dstWidth, dstHeight));
|
||||||
} else {
|
} else {
|
||||||
// Handle out of gralloc case.
|
// Handle out of gralloc case.
|
||||||
image = mImageContainer->CreatePlanarYCbCrImage();
|
image = mImageContainer->CreatePlanarYCbCrImage();
|
||||||
|
@ -821,7 +821,7 @@ MediaEngineGonkVideoSource::RotateImage(layers::Image* aImage, uint32_t aWidth,
|
||||||
data.mPicSize = IntSize(dstWidth, dstHeight);
|
data.mPicSize = IntSize(dstWidth, dstHeight);
|
||||||
data.mStereoMode = StereoMode::MONO;
|
data.mStereoMode = StereoMode::MONO;
|
||||||
|
|
||||||
image->AsPlanarYCbCrImage()->SetDataNoCopy(data);
|
image->AsPlanarYCbCrImage()->AdoptData(data);
|
||||||
}
|
}
|
||||||
graphicBuffer->unlock();
|
graphicBuffer->unlock();
|
||||||
|
|
||||||
|
|
|
@ -342,7 +342,7 @@ MediaEngineRemoteVideoSource::DeliverFrame(unsigned char* buffer,
|
||||||
data.mPicSize = IntSize(mWidth, mHeight);
|
data.mPicSize = IntSize(mWidth, mHeight);
|
||||||
data.mStereoMode = StereoMode::MONO;
|
data.mStereoMode = StereoMode::MONO;
|
||||||
|
|
||||||
if (!image->SetData(data)) {
|
if (!image->CopyData(data)) {
|
||||||
MOZ_ASSERT(false);
|
MOZ_ASSERT(false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ GrallocImage::SetData(const Data& aData)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GrallocImage::SetData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize)
|
GrallocImage::AdoptData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize)
|
||||||
{
|
{
|
||||||
mTextureClient = aGraphicBuffer;
|
mTextureClient = aGraphicBuffer;
|
||||||
mSize = aSize;
|
mSize = aSize;
|
||||||
|
|
|
@ -63,11 +63,12 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool SetData(const Data& aData);
|
virtual bool SetData(const Data& aData);
|
||||||
|
|
||||||
|
using RecyclingPlanarYCbCrImage::AdoptData;
|
||||||
/**
|
/**
|
||||||
* Share the SurfaceDescriptor without making the copy, in order
|
* Share the SurfaceDescriptor without making the copy, in order
|
||||||
* to support functioning in all different layer managers.
|
* to support functioning in all different layer managers.
|
||||||
*/
|
*/
|
||||||
void SetData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize);
|
void AdoptData(TextureClient* aGraphicBuffer, const gfx::IntSize& aSize);
|
||||||
|
|
||||||
// From [android 4.0.4]/hardware/msm7k/libgralloc-qsd8k/gralloc_priv.h
|
// From [android 4.0.4]/hardware/msm7k/libgralloc-qsd8k/gralloc_priv.h
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -534,12 +534,6 @@ RecyclingPlanarYCbCrImage::CopyData(const Data& aData)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
RecyclingPlanarYCbCrImage::SetData(const Data &aData)
|
|
||||||
{
|
|
||||||
return CopyData(aData);
|
|
||||||
}
|
|
||||||
|
|
||||||
gfxImageFormat
|
gfxImageFormat
|
||||||
PlanarYCbCrImage::GetOffscreenFormat()
|
PlanarYCbCrImage::GetOffscreenFormat()
|
||||||
{
|
{
|
||||||
|
@ -549,7 +543,7 @@ PlanarYCbCrImage::GetOffscreenFormat()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PlanarYCbCrImage::SetDataNoCopy(const Data &aData)
|
PlanarYCbCrImage::AdoptData(const Data &aData)
|
||||||
{
|
{
|
||||||
mData = aData;
|
mData = aData;
|
||||||
mSize = aData.mPicSize;
|
mSize = aData.mPicSize;
|
||||||
|
|
|
@ -727,16 +727,16 @@ public:
|
||||||
* This makes a copy of the data buffers, in order to support functioning
|
* This makes a copy of the data buffers, in order to support functioning
|
||||||
* in all different layer managers.
|
* in all different layer managers.
|
||||||
*/
|
*/
|
||||||
virtual bool SetData(const Data& aData) = 0;
|
virtual bool CopyData(const Data& aData) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This doesn't make a copy of the data buffers. Can be used when mBuffer is
|
* This doesn't make a copy of the data buffers. Can be used when mBuffer is
|
||||||
* pre allocated with AllocateAndGetNewBuffer(size) and then SetDataNoCopy is
|
* pre allocated with AllocateAndGetNewBuffer(size) and then AdoptData is
|
||||||
* called to only update the picture size, planes etc. fields in mData.
|
* called to only update the picture size, planes etc. fields in mData.
|
||||||
* The GStreamer media backend uses this to decode into PlanarYCbCrImage(s)
|
* The GStreamer media backend uses this to decode into PlanarYCbCrImage(s)
|
||||||
* directly.
|
* directly.
|
||||||
*/
|
*/
|
||||||
virtual bool SetDataNoCopy(const Data &aData);
|
virtual bool AdoptData(const Data &aData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This allocates and returns a new buffer
|
* This allocates and returns a new buffer
|
||||||
|
@ -793,16 +793,10 @@ class RecyclingPlanarYCbCrImage: public PlanarYCbCrImage {
|
||||||
public:
|
public:
|
||||||
explicit RecyclingPlanarYCbCrImage(BufferRecycleBin *aRecycleBin) : mRecycleBin(aRecycleBin) {}
|
explicit RecyclingPlanarYCbCrImage(BufferRecycleBin *aRecycleBin) : mRecycleBin(aRecycleBin) {}
|
||||||
virtual ~RecyclingPlanarYCbCrImage() override;
|
virtual ~RecyclingPlanarYCbCrImage() override;
|
||||||
virtual bool SetData(const Data& aData) override;
|
virtual bool CopyData(const Data& aData) override;
|
||||||
virtual uint8_t* AllocateAndGetNewBuffer(uint32_t aSize) override;
|
virtual uint8_t* AllocateAndGetNewBuffer(uint32_t aSize) override;
|
||||||
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
|
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
|
||||||
protected:
|
protected:
|
||||||
/**
|
|
||||||
* Make a copy of the YCbCr data into local storage.
|
|
||||||
*
|
|
||||||
* @param aData Input image data.
|
|
||||||
*/
|
|
||||||
bool CopyData(const Data& aData);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a buffer to store image data in.
|
* Return a buffer to store image data in.
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool SetData(const Data& aData) override;
|
virtual bool CopyData(const Data& aData) override;
|
||||||
virtual void SetDelayedConversion(bool aDelayed) override { mDelayedConversion = aDelayed; }
|
virtual void SetDelayedConversion(bool aDelayed) override { mDelayedConversion = aDelayed; }
|
||||||
|
|
||||||
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
|
already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
|
||||||
|
@ -86,9 +86,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BasicPlanarYCbCrImage::SetData(const Data& aData)
|
BasicPlanarYCbCrImage::CopyData(const Data& aData)
|
||||||
{
|
{
|
||||||
RecyclingPlanarYCbCrImage::SetData(aData);
|
RecyclingPlanarYCbCrImage::CopyData(aData);
|
||||||
|
|
||||||
if (mDelayedConversion) {
|
if (mDelayedConversion) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -82,7 +82,7 @@ SharedPlanarYCbCrImage::GetAsSourceSurface()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SharedPlanarYCbCrImage::SetData(const PlanarYCbCrData& aData)
|
SharedPlanarYCbCrImage::CopyData(const PlanarYCbCrData& aData)
|
||||||
{
|
{
|
||||||
// If mTextureClient has not already been allocated (through Allocate(aData))
|
// If mTextureClient has not already been allocated (through Allocate(aData))
|
||||||
// allocate it. This code path is slower than the one used when Allocate has
|
// allocate it. This code path is slower than the one used when Allocate has
|
||||||
|
@ -140,9 +140,9 @@ SharedPlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SharedPlanarYCbCrImage::SetDataNoCopy(const Data &aData)
|
SharedPlanarYCbCrImage::AdoptData(const Data &aData)
|
||||||
{
|
{
|
||||||
// SetDataNoCopy is used to update YUV plane offsets without (re)allocating
|
// AdoptData is used to update YUV plane offsets without (re)allocating
|
||||||
// memory previously allocated with AllocateAndGetNewBuffer().
|
// memory previously allocated with AllocateAndGetNewBuffer().
|
||||||
|
|
||||||
MOZ_ASSERT(mTextureClient, "This Image should have already allocated data");
|
MOZ_ASSERT(mTextureClient, "This Image should have already allocated data");
|
||||||
|
|
|
@ -34,8 +34,8 @@ public:
|
||||||
virtual uint8_t* GetBuffer() override;
|
virtual uint8_t* GetBuffer() override;
|
||||||
|
|
||||||
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
|
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
|
||||||
virtual bool SetData(const PlanarYCbCrData& aData) override;
|
virtual bool CopyData(const PlanarYCbCrData& aData) override;
|
||||||
virtual bool SetDataNoCopy(const Data &aData) override;
|
virtual bool AdoptData(const Data &aData) override;
|
||||||
|
|
||||||
virtual bool Allocate(PlanarYCbCrData& aData);
|
virtual bool Allocate(PlanarYCbCrData& aData);
|
||||||
virtual uint8_t* AllocateAndGetNewBuffer(uint32_t aSize) override;
|
virtual uint8_t* AllocateAndGetNewBuffer(uint32_t aSize) override;
|
||||||
|
|
|
@ -529,7 +529,7 @@ public:
|
||||||
|
|
||||||
gfx::IntSize picSize(buffer->GetSize());
|
gfx::IntSize picSize(buffer->GetSize());
|
||||||
nsAutoPtr<layers::GrallocImage> grallocImage(new layers::GrallocImage());
|
nsAutoPtr<layers::GrallocImage> grallocImage(new layers::GrallocImage());
|
||||||
grallocImage->SetData(buffer, picSize);
|
grallocImage->AdoptData(buffer, picSize);
|
||||||
|
|
||||||
// Get timestamp of the frame about to render.
|
// Get timestamp of the frame about to render.
|
||||||
int64_t timestamp = -1;
|
int64_t timestamp = -1;
|
||||||
|
@ -1004,8 +1004,8 @@ WebrtcOMXH264VideoEncoder::Encode(const webrtc::I420VideoFrame& aInputImage,
|
||||||
yuvData.mPicSize = yuvData.mYSize;
|
yuvData.mPicSize = yuvData.mYSize;
|
||||||
yuvData.mStereoMode = StereoMode::MONO;
|
yuvData.mStereoMode = StereoMode::MONO;
|
||||||
layers::RecyclingPlanarYCbCrImage img(nullptr);
|
layers::RecyclingPlanarYCbCrImage img(nullptr);
|
||||||
// SetDataNoCopy() doesn't need AllocateAndGetNewBuffer(); OMXVideoEncoder is ok with this
|
// AdoptData() doesn't need AllocateAndGetNewBuffer(); OMXVideoEncoder is ok with this
|
||||||
img.SetDataNoCopy(yuvData);
|
img.AdoptData(yuvData);
|
||||||
|
|
||||||
CODEC_LOGD("Encode frame: %dx%d, timestamp %u (%lld), renderTimeMs %" PRIu64,
|
CODEC_LOGD("Encode frame: %dx%d, timestamp %u (%lld), renderTimeMs %" PRIu64,
|
||||||
aInputImage.width(), aInputImage.height(),
|
aInputImage.width(), aInputImage.height(),
|
||||||
|
|
|
@ -2234,7 +2234,7 @@ public:
|
||||||
yuvData.mPicSize = IntSize(width_, height_);
|
yuvData.mPicSize = IntSize(width_, height_);
|
||||||
yuvData.mStereoMode = StereoMode::MONO;
|
yuvData.mStereoMode = StereoMode::MONO;
|
||||||
|
|
||||||
if (!yuvImage->SetData(yuvData)) {
|
if (!yuvImage->CopyData(yuvData)) {
|
||||||
MOZ_ASSERT(false);
|
MOZ_ASSERT(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче