зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1292032 - Clean up VideoData static constructor methods. r=jya
--HG-- extra : rebase_source : e025c9a15ad00e970f9027f72c78b5d6effbc301
This commit is contained in:
Родитель
af772b40e6
Коммит
f323872778
|
@ -255,27 +255,26 @@ bool VideoData::SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
|
|||
|
||||
/* static */
|
||||
already_AddRefed<VideoData>
|
||||
VideoData::Create(const VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
Image* aImage,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
const YCbCrBuffer& aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture)
|
||||
VideoData::CreateAndCopyData(const VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
const YCbCrBuffer& aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture)
|
||||
{
|
||||
if (!aImage && !aContainer) {
|
||||
if (!aContainer) {
|
||||
// Create a dummy VideoData with no image. This gives us something to
|
||||
// send to media streams if necessary.
|
||||
RefPtr<VideoData> v(new VideoData(aOffset,
|
||||
aTime,
|
||||
aDuration,
|
||||
aKeyframe,
|
||||
aTimecode,
|
||||
aInfo.mDisplay,
|
||||
0));
|
||||
aTime,
|
||||
aDuration,
|
||||
aKeyframe,
|
||||
aTimecode,
|
||||
aInfo.mDisplay,
|
||||
0));
|
||||
return v.forget();
|
||||
}
|
||||
|
||||
|
@ -313,31 +312,27 @@ VideoData::Create(const VideoInfo& aInfo,
|
|||
}
|
||||
|
||||
RefPtr<VideoData> v(new VideoData(aOffset,
|
||||
aTime,
|
||||
aDuration,
|
||||
aKeyframe,
|
||||
aTimecode,
|
||||
aInfo.mDisplay,
|
||||
0));
|
||||
aTime,
|
||||
aDuration,
|
||||
aKeyframe,
|
||||
aTimecode,
|
||||
aInfo.mDisplay,
|
||||
0));
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
const YCbCrBuffer::Plane &Y = aBuffer.mPlanes[0];
|
||||
const YCbCrBuffer::Plane &Cb = aBuffer.mPlanes[1];
|
||||
const YCbCrBuffer::Plane &Cr = aBuffer.mPlanes[2];
|
||||
#endif
|
||||
|
||||
if (!aImage) {
|
||||
// Currently our decoder only knows how to output to ImageFormat::PLANAR_YCBCR
|
||||
// format.
|
||||
// Currently our decoder only knows how to output to ImageFormat::PLANAR_YCBCR
|
||||
// format.
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (IsYV12Format(Y, Cb, Cr) && !IsInEmulator()) {
|
||||
v->mImage = new layers::GrallocImage();
|
||||
}
|
||||
if (IsYV12Format(Y, Cb, Cr) && !IsInEmulator()) {
|
||||
v->mImage = new layers::GrallocImage();
|
||||
}
|
||||
#endif
|
||||
if (!v->mImage) {
|
||||
v->mImage = aContainer->CreatePlanarYCbCrImage();
|
||||
}
|
||||
} else {
|
||||
v->mImage = aImage;
|
||||
if (!v->mImage) {
|
||||
v->mImage = aContainer->CreatePlanarYCbCrImage();
|
||||
}
|
||||
|
||||
if (!v->mImage) {
|
||||
|
@ -349,9 +344,8 @@ VideoData::Create(const VideoInfo& aInfo,
|
|||
PlanarYCbCrImage* videoImage = v->mImage->AsPlanarYCbCrImage();
|
||||
MOZ_ASSERT(videoImage);
|
||||
|
||||
bool shouldCopyData = (aImage == nullptr);
|
||||
if (!VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
|
||||
shouldCopyData)) {
|
||||
true /* aCopyData */)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -363,8 +357,8 @@ VideoData::Create(const VideoInfo& aInfo,
|
|||
return nullptr;
|
||||
}
|
||||
videoImage = v->mImage->AsPlanarYCbCrImage();
|
||||
if(!VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
|
||||
true /* aCopyData */)) {
|
||||
if (!VideoData::SetVideoDataToImage(videoImage, aInfo, aBuffer, aPicture,
|
||||
true /* aCopyData */)) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -372,42 +366,9 @@ VideoData::Create(const VideoInfo& aInfo,
|
|||
return v.forget();
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<VideoData>
|
||||
VideoData::Create(const VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
const YCbCrBuffer& aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture)
|
||||
{
|
||||
return Create(aInfo, aContainer, nullptr, aOffset, aTime, aDuration, aBuffer,
|
||||
aKeyframe, aTimecode, aPicture);
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<VideoData>
|
||||
VideoData::Create(const VideoInfo& aInfo,
|
||||
Image* aImage,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
const YCbCrBuffer& aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture)
|
||||
{
|
||||
return Create(aInfo, nullptr, aImage, aOffset, aTime, aDuration, aBuffer,
|
||||
aKeyframe, aTimecode, aPicture);
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<VideoData>
|
||||
VideoData::CreateFromImage(const VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
|
@ -417,12 +378,12 @@ VideoData::CreateFromImage(const VideoInfo& aInfo,
|
|||
const IntRect& aPicture)
|
||||
{
|
||||
RefPtr<VideoData> v(new VideoData(aOffset,
|
||||
aTime,
|
||||
aDuration,
|
||||
aKeyframe,
|
||||
aTimecode,
|
||||
aInfo.mDisplay,
|
||||
0));
|
||||
aTime,
|
||||
aDuration,
|
||||
aKeyframe,
|
||||
aTimecode,
|
||||
aInfo.mDisplay,
|
||||
0));
|
||||
v->mImage = aImage;
|
||||
return v.forget();
|
||||
}
|
||||
|
@ -430,29 +391,15 @@ VideoData::CreateFromImage(const VideoInfo& aInfo,
|
|||
#ifdef MOZ_OMX_DECODER
|
||||
/* static */
|
||||
already_AddRefed<VideoData>
|
||||
VideoData::Create(const VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
mozilla::layers::TextureClient* aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture)
|
||||
VideoData::CreateAndCopyIntoTextureClient(const VideoInfo& aInfo,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
mozilla::layers::TextureClient* aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture)
|
||||
{
|
||||
if (!aContainer) {
|
||||
// Create a dummy VideoData with no image. This gives us something to
|
||||
// send to media streams if necessary.
|
||||
RefPtr<VideoData> v(new VideoData(aOffset,
|
||||
aTime,
|
||||
aDuration,
|
||||
aKeyframe,
|
||||
aTimecode,
|
||||
aInfo.mDisplay,
|
||||
0));
|
||||
return v.forget();
|
||||
}
|
||||
|
||||
// The following situations could be triggered by invalid input
|
||||
if (aPicture.width <= 0 || aPicture.height <= 0) {
|
||||
NS_WARNING("Empty picture rect");
|
||||
|
@ -472,12 +419,12 @@ VideoData::Create(const VideoInfo& aInfo,
|
|||
}
|
||||
|
||||
RefPtr<VideoData> v(new VideoData(aOffset,
|
||||
aTime,
|
||||
aDuration,
|
||||
aKeyframe,
|
||||
aTimecode,
|
||||
aInfo.mDisplay,
|
||||
0));
|
||||
aTime,
|
||||
aDuration,
|
||||
aKeyframe,
|
||||
aTimecode,
|
||||
aInfo.mDisplay,
|
||||
0));
|
||||
|
||||
RefPtr<layers::GrallocImage> image = new layers::GrallocImage();
|
||||
image->AdoptData(aBuffer, aPicture.Size());
|
||||
|
|
|
@ -459,51 +459,30 @@ public:
|
|||
// Returns nsnull if an error occurs. This may indicate that memory couldn't
|
||||
// be allocated to create the VideoData object, or it may indicate some
|
||||
// problem with the input data (e.g. negative stride).
|
||||
static already_AddRefed<VideoData> Create(const VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
Image* aImage,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
const YCbCrBuffer &aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture);
|
||||
|
||||
// Variant that always makes a copy of aBuffer
|
||||
static already_AddRefed<VideoData> Create(const VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
const YCbCrBuffer &aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture);
|
||||
|
||||
// Variant to create a VideoData instance given an existing aImage
|
||||
static already_AddRefed<VideoData> Create(const VideoInfo& aInfo,
|
||||
Image* aImage,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
const YCbCrBuffer &aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture);
|
||||
// Creates a new VideoData containing a deep copy of aBuffer. May use aContainer
|
||||
// to allocate an Image to hold the copied data.
|
||||
static already_AddRefed<VideoData> CreateAndCopyData(const VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
const YCbCrBuffer &aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture);
|
||||
|
||||
static already_AddRefed<VideoData> Create(const VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
layers::TextureClient* aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture);
|
||||
static already_AddRefed<VideoData> CreateAndCopyIntoTextureClient(const VideoInfo& aInfo,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
layers::TextureClient* aBuffer,
|
||||
bool aKeyframe,
|
||||
int64_t aTimecode,
|
||||
const IntRect& aPicture);
|
||||
|
||||
static already_AddRefed<VideoData> CreateFromImage(const VideoInfo& aInfo,
|
||||
ImageContainer* aContainer,
|
||||
int64_t aOffset,
|
||||
int64_t aTime,
|
||||
int64_t aDuration,
|
||||
|
|
|
@ -186,7 +186,6 @@ bool AndroidMediaReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||
}
|
||||
|
||||
v = VideoData::CreateFromImage(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
pos,
|
||||
frame.mTimeUs,
|
||||
1, // We don't know the duration yet.
|
||||
|
@ -231,15 +230,15 @@ bool AndroidMediaReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||
}
|
||||
|
||||
// This is the approximate byte position in the stream.
|
||||
v = VideoData::Create(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
pos,
|
||||
frame.mTimeUs,
|
||||
1, // We don't know the duration yet.
|
||||
b,
|
||||
frame.mKeyFrame,
|
||||
-1,
|
||||
picture);
|
||||
v = VideoData::CreateAndCopyData(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
pos,
|
||||
frame.mTimeUs,
|
||||
1, // We don't know the duration yet.
|
||||
b,
|
||||
frame.mKeyFrame,
|
||||
-1,
|
||||
picture);
|
||||
}
|
||||
|
||||
if (!v) {
|
||||
|
|
|
@ -881,15 +881,16 @@ nsresult OggReader::DecodeTheora(ogg_packet* aPacket, int64_t aTimeThreshold)
|
|||
b.mPlanes[i].mOffset = b.mPlanes[i].mSkip = 0;
|
||||
}
|
||||
|
||||
RefPtr<VideoData> v = VideoData::Create(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
mResource.Tell(),
|
||||
time,
|
||||
endTime - time,
|
||||
b,
|
||||
isKeyframe,
|
||||
aPacket->granulepos,
|
||||
mPicture);
|
||||
RefPtr<VideoData> v =
|
||||
VideoData::CreateAndCopyData(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
mResource.Tell(),
|
||||
time,
|
||||
endTime - time,
|
||||
b,
|
||||
isKeyframe,
|
||||
aPacket->granulepos,
|
||||
mPicture);
|
||||
if (!v) {
|
||||
// There may be other reasons for this error, but for
|
||||
// simplicity just assume the worst case: out of memory.
|
||||
|
|
|
@ -409,25 +409,25 @@ bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||
b.mPlanes[2].mOffset = frame.Cr.mOffset;
|
||||
b.mPlanes[2].mSkip = frame.Cr.mSkip;
|
||||
|
||||
v = VideoData::Create(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
pos,
|
||||
frame.mTimeUs,
|
||||
1, // We don't know the duration.
|
||||
b,
|
||||
frame.mKeyFrame,
|
||||
-1,
|
||||
picture);
|
||||
v = VideoData::CreateAndCopyData(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
pos,
|
||||
frame.mTimeUs,
|
||||
1, // We don't know the duration.
|
||||
b,
|
||||
frame.mKeyFrame,
|
||||
-1,
|
||||
picture);
|
||||
} else {
|
||||
v = VideoData::Create(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
pos,
|
||||
frame.mTimeUs,
|
||||
1, // We don't know the duration.
|
||||
frame.mGraphicBuffer,
|
||||
frame.mKeyFrame,
|
||||
-1,
|
||||
picture);
|
||||
v = VideoData::CreateAndCopyData(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
pos,
|
||||
frame.mTimeUs,
|
||||
1, // We don't know the duration.
|
||||
frame.mGraphicBuffer,
|
||||
frame.mKeyFrame,
|
||||
-1,
|
||||
picture);
|
||||
}
|
||||
|
||||
if (!v) {
|
||||
|
|
|
@ -163,16 +163,15 @@ public:
|
|||
memset(buffer.mPlanes[0].mData, 255, sizeY);
|
||||
memset(buffer.mPlanes[1].mData, 128, sizeCbCr);
|
||||
|
||||
return VideoData::Create(mInfo,
|
||||
mImageContainer,
|
||||
nullptr,
|
||||
aOffsetInStream,
|
||||
aDTS.ToMicroseconds(),
|
||||
aDuration.ToMicroseconds(),
|
||||
buffer,
|
||||
true,
|
||||
aDTS.ToMicroseconds(),
|
||||
mPicture);
|
||||
return VideoData::CreateAndCopyData(mInfo,
|
||||
mImageContainer,
|
||||
aOffsetInStream,
|
||||
aDTS.ToMicroseconds(),
|
||||
aDuration.ToMicroseconds(),
|
||||
buffer,
|
||||
true,
|
||||
aDTS.ToMicroseconds(),
|
||||
mPicture);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -168,16 +168,17 @@ TheoraDecoder::DoDecode(MediaRawData* aSample)
|
|||
|
||||
VideoInfo info;
|
||||
info.mDisplay = mInfo.mDisplay;
|
||||
RefPtr<VideoData> v = VideoData::Create(info,
|
||||
mImageContainer,
|
||||
aSample->mOffset,
|
||||
aSample->mTime,
|
||||
aSample->mDuration,
|
||||
b,
|
||||
aSample->mKeyframe,
|
||||
aSample->mTimecode,
|
||||
mInfo.ScaledImageRect(mTheoraInfo.frame_width,
|
||||
mTheoraInfo.frame_height));
|
||||
RefPtr<VideoData> v =
|
||||
VideoData::CreateAndCopyData(info,
|
||||
mImageContainer,
|
||||
aSample->mOffset,
|
||||
aSample->mTime,
|
||||
aSample->mDuration,
|
||||
b,
|
||||
aSample->mKeyframe,
|
||||
aSample->mTimecode,
|
||||
mInfo.ScaledImageRect(mTheoraInfo.frame_width,
|
||||
mTheoraInfo.frame_height));
|
||||
if (!v) {
|
||||
LOG("Image allocation error source %ldx%ld display %ldx%ld picture %ldx%ld",
|
||||
mTheoraInfo.frame_width, mTheoraInfo.frame_height, mInfo.mDisplay.width, mInfo.mDisplay.height,
|
||||
|
|
|
@ -160,16 +160,17 @@ VPXDecoder::DoDecode(MediaRawData* aSample)
|
|||
return -1;
|
||||
}
|
||||
|
||||
RefPtr<VideoData> v = VideoData::Create(mInfo,
|
||||
mImageContainer,
|
||||
aSample->mOffset,
|
||||
aSample->mTime,
|
||||
aSample->mDuration,
|
||||
b,
|
||||
aSample->mKeyframe,
|
||||
aSample->mTimecode,
|
||||
mInfo.ScaledImageRect(img->d_w,
|
||||
img->d_h));
|
||||
RefPtr<VideoData> v =
|
||||
VideoData::CreateAndCopyData(mInfo,
|
||||
mImageContainer,
|
||||
aSample->mOffset,
|
||||
aSample->mTime,
|
||||
aSample->mDuration,
|
||||
b,
|
||||
aSample->mKeyframe,
|
||||
aSample->mTimecode,
|
||||
mInfo.ScaledImageRect(img->d_w,
|
||||
img->d_h));
|
||||
|
||||
if (!v) {
|
||||
LOG("Image allocation error source %ldx%ld display %ldx%ld picture %ldx%ld",
|
||||
|
|
|
@ -41,15 +41,16 @@ VideoCallbackAdapter::Decoded(GMPVideoi420Frame* aDecodedFrame)
|
|||
}
|
||||
|
||||
gfx::IntRect pictureRegion(0, 0, decodedFrame->Width(), decodedFrame->Height());
|
||||
RefPtr<VideoData> v = VideoData::Create(mVideoInfo,
|
||||
mImageContainer,
|
||||
mLastStreamOffset,
|
||||
decodedFrame->Timestamp(),
|
||||
decodedFrame->Duration(),
|
||||
b,
|
||||
false,
|
||||
-1,
|
||||
pictureRegion);
|
||||
RefPtr<VideoData> v =
|
||||
VideoData::CreateAndCopyData(mVideoInfo,
|
||||
mImageContainer,
|
||||
mLastStreamOffset,
|
||||
decodedFrame->Timestamp(),
|
||||
decodedFrame->Duration(),
|
||||
b,
|
||||
false,
|
||||
-1,
|
||||
pictureRegion);
|
||||
if (v) {
|
||||
mCallback->Output(v);
|
||||
} else {
|
||||
|
|
|
@ -144,7 +144,6 @@ public:
|
|||
|
||||
RefPtr<VideoData> v =
|
||||
VideoData::CreateFromImage(mConfig,
|
||||
mImageContainer,
|
||||
offset,
|
||||
presentationTimeUs,
|
||||
aDuration.ToMicroseconds(),
|
||||
|
|
|
@ -366,16 +366,15 @@ AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage,
|
|||
|
||||
// Copy the image data into our own format.
|
||||
data =
|
||||
VideoData::Create(info,
|
||||
mImageContainer,
|
||||
nullptr,
|
||||
aFrameRef.byte_offset,
|
||||
aFrameRef.composition_timestamp.ToMicroseconds(),
|
||||
aFrameRef.duration.ToMicroseconds(),
|
||||
buffer,
|
||||
aFrameRef.is_sync_point,
|
||||
aFrameRef.decode_timestamp.ToMicroseconds(),
|
||||
visible);
|
||||
VideoData::CreateAndCopyData(info,
|
||||
mImageContainer,
|
||||
aFrameRef.byte_offset,
|
||||
aFrameRef.composition_timestamp.ToMicroseconds(),
|
||||
aFrameRef.duration.ToMicroseconds(),
|
||||
buffer,
|
||||
aFrameRef.is_sync_point,
|
||||
aFrameRef.decode_timestamp.ToMicroseconds(),
|
||||
visible);
|
||||
// Unlock the returned image data.
|
||||
CVPixelBufferUnlockBaseAddress(aImage, kCVPixelBufferLock_ReadOnly);
|
||||
} else {
|
||||
|
@ -389,7 +388,6 @@ AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage,
|
|||
|
||||
data =
|
||||
VideoData::CreateFromImage(info,
|
||||
mImageContainer,
|
||||
aFrameRef.byte_offset,
|
||||
aFrameRef.composition_timestamp.ToMicroseconds(),
|
||||
aFrameRef.duration.ToMicroseconds(),
|
||||
|
|
|
@ -289,16 +289,17 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecode(MediaRawData* aSample,
|
|||
b.mPlanes[1].mHeight = b.mPlanes[2].mHeight = (mFrame->height + 1) >> 1;
|
||||
}
|
||||
|
||||
RefPtr<VideoData> v = VideoData::Create(mInfo,
|
||||
mImageContainer,
|
||||
aSample->mOffset,
|
||||
pts,
|
||||
duration,
|
||||
b,
|
||||
!!mFrame->key_frame,
|
||||
-1,
|
||||
mInfo.ScaledImageRect(mFrame->width,
|
||||
mFrame->height));
|
||||
RefPtr<VideoData> v =
|
||||
VideoData::CreateAndCopyData(mInfo,
|
||||
mImageContainer,
|
||||
aSample->mOffset,
|
||||
pts,
|
||||
duration,
|
||||
b,
|
||||
!!mFrame->key_frame,
|
||||
-1,
|
||||
mInfo.ScaledImageRect(mFrame->width,
|
||||
mFrame->height));
|
||||
|
||||
if (!v) {
|
||||
NS_WARNING("image allocation error.");
|
||||
|
|
|
@ -425,16 +425,16 @@ GonkVideoDecoderManager::CreateVideoDataFromGraphicBuffer(MediaBuffer* aSource,
|
|||
static_cast<GrallocTextureData*>(textureClient->GetInternalData())->SetMediaBuffer(aSource);
|
||||
}
|
||||
|
||||
RefPtr<VideoData> data = VideoData::Create(mConfig,
|
||||
mImageContainer,
|
||||
0, // Filled later by caller.
|
||||
0, // Filled later by caller.
|
||||
1, // No way to pass sample duration from muxer to
|
||||
// OMX codec, so we hardcode the duration here.
|
||||
textureClient,
|
||||
false, // Filled later by caller.
|
||||
-1,
|
||||
aPicture);
|
||||
RefPtr<VideoData> data =
|
||||
VideoData::CreateAndCopyIntoTextureClient(mConfig,
|
||||
0, // Filled later by caller.
|
||||
0, // Filled later by caller.
|
||||
1, // No way to pass sample duration from muxer to
|
||||
// OMX codec, so we hardcode the duration here.
|
||||
textureClient,
|
||||
false, // Filled later by caller.
|
||||
-1,
|
||||
aPicture);
|
||||
return data.forget();
|
||||
}
|
||||
|
||||
|
@ -494,15 +494,16 @@ GonkVideoDecoderManager::CreateVideoDataFromDataBuffer(MediaBuffer* aSource, gfx
|
|||
b.mPlanes[2].mOffset = 0;
|
||||
b.mPlanes[2].mSkip = 0;
|
||||
|
||||
RefPtr<VideoData> data = VideoData::Create(mConfig,
|
||||
mImageContainer,
|
||||
0, // Filled later by caller.
|
||||
0, // Filled later by caller.
|
||||
1, // We don't know the duration.
|
||||
b,
|
||||
0, // Filled later by caller.
|
||||
-1,
|
||||
aPicture);
|
||||
RefPtr<VideoData> data =
|
||||
VideoData::CreateAndCopyData(mConfig,
|
||||
mImageContainer,
|
||||
0, // Filled later by caller.
|
||||
0, // Filled later by caller.
|
||||
1, // We don't know the duration.
|
||||
b,
|
||||
0, // Filled later by caller.
|
||||
-1,
|
||||
aPicture);
|
||||
|
||||
return data.forget();
|
||||
}
|
||||
|
|
|
@ -309,15 +309,15 @@ GonkBufferData::GetPlatformMediaData()
|
|||
}
|
||||
|
||||
VideoInfo info(*mGonkPlatformLayer->GetTrackInfo()->GetAsVideoInfo());
|
||||
RefPtr<VideoData> data = VideoData::Create(info,
|
||||
mGonkPlatformLayer->GetImageContainer(),
|
||||
0,
|
||||
mBuffer->nTimeStamp,
|
||||
1,
|
||||
mTextureClientRecycleHandler->GetTextureClient(),
|
||||
false,
|
||||
0,
|
||||
info.ImageRect());
|
||||
RefPtr<VideoData> data =
|
||||
VideoData::CreateAndCopyIntoTextureClient(info,
|
||||
0,
|
||||
mBuffer->nTimeStamp,
|
||||
1,
|
||||
mTextureClientRecycleHandler->GetTextureClient(),
|
||||
false,
|
||||
0,
|
||||
info.ImageRect());
|
||||
LOG("%p, disp width %d, height %d, pic width %d, height %d, time %ld",
|
||||
this, info.mDisplay.width, info.mDisplay.height,
|
||||
info.mImage.width, info.mImage.height, mBuffer->nTimeStamp);
|
||||
|
|
|
@ -1024,15 +1024,16 @@ MediaDataHelper::CreateYUV420VideoData(BufferData* aBufferData)
|
|||
b.mPlanes[2].mSkip = 0;
|
||||
|
||||
VideoInfo info(*mTrackInfo->GetAsVideoInfo());
|
||||
RefPtr<VideoData> data = VideoData::Create(info,
|
||||
mImageContainer,
|
||||
0, // Filled later by caller.
|
||||
0, // Filled later by caller.
|
||||
1, // We don't know the duration.
|
||||
b,
|
||||
0, // Filled later by caller.
|
||||
-1,
|
||||
info.ImageRect());
|
||||
RefPtr<VideoData> data =
|
||||
VideoData::CreateAndCopyData(info,
|
||||
mImageContainer,
|
||||
0, // Filled later by caller.
|
||||
0, // Filled later by caller.
|
||||
1, // We don't know the duration.
|
||||
b,
|
||||
0, // Filled later by caller.
|
||||
-1,
|
||||
info.ImageRect());
|
||||
|
||||
LOG("YUV420 VideoData: disp width %d, height %d, pic width %d, height %d, time %ld",
|
||||
info.mDisplay.width, info.mDisplay.height, info.mImage.width,
|
||||
|
|
|
@ -98,7 +98,6 @@ public:
|
|||
// into an image which is returned by aOutImage.
|
||||
HRESULT CopyToImage(IMFSample* aVideoSample,
|
||||
const nsIntRect& aRegion,
|
||||
ImageContainer* aContainer,
|
||||
Image** aOutImage) override;
|
||||
|
||||
bool SupportsConfig(IMFMediaType* aType, float aFramerate) override;
|
||||
|
@ -439,7 +438,6 @@ D3D9DXVA2Manager::Init(nsACString& aFailureReason)
|
|||
HRESULT
|
||||
D3D9DXVA2Manager::CopyToImage(IMFSample* aSample,
|
||||
const nsIntRect& aRegion,
|
||||
ImageContainer* aImageContainer,
|
||||
Image** aOutImage)
|
||||
{
|
||||
RefPtr<IMFMediaBuffer> buffer;
|
||||
|
@ -519,7 +517,6 @@ public:
|
|||
// into an image which is returned by aOutImage.
|
||||
HRESULT CopyToImage(IMFSample* aVideoSample,
|
||||
const nsIntRect& aRegion,
|
||||
ImageContainer* aContainer,
|
||||
Image** aOutImage) override;
|
||||
|
||||
HRESULT ConfigureForSize(uint32_t aWidth, uint32_t aHeight) override;
|
||||
|
@ -782,11 +779,9 @@ D3D11DXVA2Manager::CreateOutputSample(RefPtr<IMFSample>& aSample, ID3D11Texture2
|
|||
HRESULT
|
||||
D3D11DXVA2Manager::CopyToImage(IMFSample* aVideoSample,
|
||||
const nsIntRect& aRegion,
|
||||
ImageContainer* aContainer,
|
||||
Image** aOutImage)
|
||||
{
|
||||
NS_ENSURE_TRUE(aVideoSample, E_POINTER);
|
||||
NS_ENSURE_TRUE(aContainer, E_POINTER);
|
||||
NS_ENSURE_TRUE(aOutImage, E_POINTER);
|
||||
|
||||
// Our video frame is stored in a non-sharable ID3D11Texture2D. We need
|
||||
|
|
|
@ -35,7 +35,6 @@ public:
|
|||
// Creates an Image for the video frame stored in aVideoSample.
|
||||
virtual HRESULT CopyToImage(IMFSample* aVideoSample,
|
||||
const nsIntRect& aRegion,
|
||||
layers::ImageContainer* aContainer,
|
||||
layers::Image** aOutImage) = 0;
|
||||
|
||||
virtual HRESULT ConfigureForSize(uint32_t aWidth, uint32_t aHeight) { return S_OK; }
|
||||
|
|
|
@ -711,15 +711,16 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
|
|||
|
||||
if (mLayersBackend != LayersBackend::LAYERS_D3D9 &&
|
||||
mLayersBackend != LayersBackend::LAYERS_D3D11) {
|
||||
RefPtr<VideoData> v = VideoData::Create(mVideoInfo,
|
||||
mImageContainer,
|
||||
aStreamOffset,
|
||||
pts.ToMicroseconds(),
|
||||
duration.ToMicroseconds(),
|
||||
b,
|
||||
false,
|
||||
-1,
|
||||
pictureRegion);
|
||||
RefPtr<VideoData> v =
|
||||
VideoData::CreateAndCopyData(mVideoInfo,
|
||||
mImageContainer,
|
||||
aStreamOffset,
|
||||
pts.ToMicroseconds(),
|
||||
duration.ToMicroseconds(),
|
||||
b,
|
||||
false,
|
||||
-1,
|
||||
pictureRegion);
|
||||
if (twoDBuffer) {
|
||||
twoDBuffer->Unlock2D();
|
||||
} else {
|
||||
|
@ -740,7 +741,6 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
|
|||
|
||||
RefPtr<VideoData> v =
|
||||
VideoData::CreateFromImage(mVideoInfo,
|
||||
mImageContainer,
|
||||
aStreamOffset,
|
||||
pts.ToMicroseconds(),
|
||||
duration.ToMicroseconds(),
|
||||
|
@ -771,7 +771,6 @@ WMFVideoMFTManager::CreateD3DVideoFrame(IMFSample* aSample,
|
|||
RefPtr<Image> image;
|
||||
hr = mDXVA2Manager->CopyToImage(aSample,
|
||||
pictureRegion,
|
||||
mImageContainer,
|
||||
getter_AddRefs(image));
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
|
||||
NS_ENSURE_TRUE(image, E_FAIL);
|
||||
|
@ -781,7 +780,6 @@ WMFVideoMFTManager::CreateD3DVideoFrame(IMFSample* aSample,
|
|||
media::TimeUnit duration = GetSampleDuration(aSample);
|
||||
NS_ENSURE_TRUE(duration.IsValid(), E_FAIL);
|
||||
RefPtr<VideoData> v = VideoData::CreateFromImage(mVideoInfo,
|
||||
mImageContainer,
|
||||
aStreamOffset,
|
||||
pts.ToMicroseconds(),
|
||||
duration.ToMicroseconds(),
|
||||
|
|
|
@ -186,15 +186,16 @@ bool RawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
|||
b.mPlanes[2].mWidth = mMetadata.frameWidth / 2;
|
||||
b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0;
|
||||
|
||||
RefPtr<VideoData> v = VideoData::Create(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
-1,
|
||||
currentFrameTime,
|
||||
(USECS_PER_S / mFrameRate),
|
||||
b,
|
||||
1, // In raw video every frame is a keyframe
|
||||
-1,
|
||||
mPicture);
|
||||
RefPtr<VideoData> v =
|
||||
VideoData::CreateAndCopyData(mInfo.mVideo,
|
||||
mDecoder->GetImageContainer(),
|
||||
-1,
|
||||
currentFrameTime,
|
||||
(USECS_PER_S / mFrameRate),
|
||||
b,
|
||||
1, // In raw video every frame is a keyframe
|
||||
-1,
|
||||
mPicture);
|
||||
if (!v)
|
||||
return false;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче