diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index 99bda507e2bf..acc3d93381e2 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -352,44 +352,23 @@ protected: uint8_t *y = data->mYChannel; uint8_t *cb = data->mCbChannel; uint8_t *cr = data->mCrChannel; + int32_t yStride = data->mYStride; + int32_t cbCrStride = data->mCbCrStride; uint32_t width = yuv->GetSize().width; uint32_t height = yuv->GetSize().height; - uint32_t length = yuv->GetDataSize(); - // NOTE: length may be rounded up or include 'other' data (see - // YCbCrImageDataDeserializerBase::ComputeMinBufferSize()) - // XXX Consider modifying these checks if we ever implement - // any subclasses of PlanarYCbCrImage that allow disjoint buffers such - // that y+3(width*height)/2 might go outside the allocation or there are - // pads between y, cr and cb. - // GrallocImage can have wider strides, and so in some cases - // would encode as garbage. If we need to encode it we'll either want to - // modify SendVideoFrame or copy/move the data in the buffer. - if (cb == (y + YSIZE(width, height)) && - cr == (cb + CRSIZE(width, height)) && - length >= I420SIZE(width, height)) { - MOZ_MTLOG(ML_DEBUG, "Sending an I420 video frame"); - VideoFrameConverted(y, I420SIZE(width, height), width, height, mozilla::kVideoI420, 0); + webrtc::I420VideoFrame i420_frame; + int rv = i420_frame.CreateFrame(y, cb, cr, width, height, + yStride, cbCrStride, cbCrStride, + webrtc::kVideoRotation_0); + if (rv != 0) { + NS_ERROR("Creating an I420 frame failed"); return; - } else { - MOZ_MTLOG(ML_ERROR, "Unsupported PlanarYCbCrImage format: " - "width=" << width << ", height=" << height << ", y=" << y - << "\n Expected: cb=y+" << YSIZE(width, height) - << ", cr=y+" << YSIZE(width, height) - + CRSIZE(width, height) - << "\n Observed: cb=y+" << cb - y - << ", cr=y+" << cr - y - << "\n ystride=" << data->mYStride - << ", yskip=" << data->mYSkip - << "\n cbcrstride=" << data->mCbCrStride - << ", cbskip=" << data->mCbSkip - << ", crskip=" << data->mCrSkip - << "\n ywidth=" << data->mYSize.width - << ", yheight=" << data->mYSize.height - << "\n cbcrwidth=" << data->mCbCrSize.width - << ", cbcrheight=" << data->mCbCrSize.height); - NS_ASSERTION(false, "Unsupported PlanarYCbCrImage format"); } + + MOZ_MTLOG(ML_DEBUG, "Sending an I420 video frame"); + VideoFrameConverted(i420_frame); + return; } }