Exemplo n.º 1
0
void
EMEH264Decoder::Decoded(GMPVideoi420Frame* aDecodedFrame)
{
  MOZ_ASSERT(IsOnGMPThread());

  VideoData::YCbCrBuffer b;

  auto height = aDecodedFrame->Height();
  auto width = aDecodedFrame->Width();

  // Y (Y') plane
  b.mPlanes[0].mData = aDecodedFrame->Buffer(kGMPYPlane);
  b.mPlanes[0].mStride = aDecodedFrame->Stride(kGMPYPlane);
  b.mPlanes[0].mHeight = height;
  b.mPlanes[0].mWidth = width;
  b.mPlanes[0].mOffset = 0;
  b.mPlanes[0].mSkip = 0;

  // U plane (Cb)
  b.mPlanes[1].mData = aDecodedFrame->Buffer(kGMPUPlane);
  b.mPlanes[1].mStride = aDecodedFrame->Stride(kGMPUPlane);
  b.mPlanes[1].mHeight = height / 2;
  b.mPlanes[1].mWidth = width / 2;
  b.mPlanes[1].mOffset = 0;
  b.mPlanes[1].mSkip = 0;

  // V plane (Cr)
  b.mPlanes[2].mData = aDecodedFrame->Buffer(kGMPVPlane);
  b.mPlanes[2].mStride = aDecodedFrame->Stride(kGMPVPlane);
  b.mPlanes[2].mHeight = height / 2;
  b.mPlanes[2].mWidth = width / 2;
  b.mPlanes[2].mOffset = 0;
  b.mPlanes[2].mSkip = 0;

  gfx::IntRect pictureRegion(0, 0, width, height);
  nsRefPtr<VideoData> v = VideoData::Create(mVideoInfo,
                                            mImageContainer,
                                            mLastStreamOffset,
                                            aDecodedFrame->Timestamp(),
                                            aDecodedFrame->Duration(),
                                            b,
                                            false,
                                            -1,
                                            pictureRegion);
  aDecodedFrame->Destroy();
  mCallback->Output(v);
}
Exemplo n.º 2
0
void
GMPVideoDecoder::Decoded(GMPVideoi420Frame* aDecodedFrame)
{
  GMPUniquePtr<GMPVideoi420Frame> decodedFrame(aDecodedFrame);

  MOZ_ASSERT(IsOnGMPThread());

  VideoData::YCbCrBuffer b;
  for (int i = 0; i < kGMPNumOfPlanes; ++i) {
    b.mPlanes[i].mData = decodedFrame->Buffer(GMPPlaneType(i));
    b.mPlanes[i].mStride = decodedFrame->Stride(GMPPlaneType(i));
    if (i == kGMPYPlane) {
      b.mPlanes[i].mWidth = decodedFrame->Width();
      b.mPlanes[i].mHeight = decodedFrame->Height();
    } else {
      b.mPlanes[i].mWidth = (decodedFrame->Width() + 1) / 2;
      b.mPlanes[i].mHeight = (decodedFrame->Height() + 1) / 2;
    }
    b.mPlanes[i].mOffset = 0;
    b.mPlanes[i].mSkip = 0;
  }

  gfx::IntRect pictureRegion(
    0, 0, decodedFrame->Width(), decodedFrame->Height());
  RefPtr<VideoData> v = VideoData::CreateAndCopyData(
    mConfig,
    mImageContainer,
    mLastStreamOffset,
    media::TimeUnit::FromMicroseconds(decodedFrame->Timestamp()),
    media::TimeUnit::FromMicroseconds(decodedFrame->Duration()),
    b,
    false,
    media::TimeUnit::FromMicroseconds(-1),
    pictureRegion);
  RefPtr<GMPVideoDecoder> self = this;
  if (v) {
    mDecodedData.AppendElement(std::move(v));
  } else {
    mDecodedData.Clear();
    mDecodePromise.RejectIfExists(
      MediaResult(NS_ERROR_OUT_OF_MEMORY,
                  RESULT_DETAIL("CallBack::CreateAndCopyData")),
      __func__);
  }
}
Exemplo n.º 3
0
void
VideoCallbackAdapter::Decoded(GMPVideoi420Frame* aDecodedFrame)
{
  GMPUniquePtr<GMPVideoi420Frame> decodedFrame(aDecodedFrame);

  MOZ_ASSERT(IsOnGMPThread());

  VideoData::YCbCrBuffer b;
  for (int i = 0; i < kGMPNumOfPlanes; ++i) {
    b.mPlanes[i].mData = decodedFrame->Buffer(GMPPlaneType(i));
    b.mPlanes[i].mStride = decodedFrame->Stride(GMPPlaneType(i));
    if (i == kGMPYPlane) {
      b.mPlanes[i].mWidth = decodedFrame->Width();
      b.mPlanes[i].mHeight = decodedFrame->Height();
    } else {
      b.mPlanes[i].mWidth = (decodedFrame->Width() + 1) / 2;
      b.mPlanes[i].mHeight = (decodedFrame->Height() + 1) / 2;
    }
    b.mPlanes[i].mOffset = 0;
    b.mPlanes[i].mSkip = 0;
  }

  gfx::IntRect pictureRegion(0, 0, decodedFrame->Width(), decodedFrame->Height());
  RefPtr<VideoData> v =
    VideoData::CreateAndCopyData(mVideoInfo,
                                 mImageContainer,
                                 mLastStreamOffset,
                                 decodedFrame->Timestamp(),
                                 decodedFrame->Duration(),
                                 b,
                                 false,
                                 -1,
                                 pictureRegion);
  if (v) {
    mCallback->Output(v);
  } else {
    mCallback->Error(MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__));
  }
}