Bug 1206708 - Allow YUV images with gaps between planes in MediaPipelineTransmit. r=jesup
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 12 Apr 2016 15:12:49 +0200
changeset 338346 13f36f3e31812f9c3787da944f4358c43b017160
parent 338345 08f50e080cdde2cc75b20d67e80a58ea50e68159
child 338347 e126886f6df8429b2b456d6f8fcfc1dc8f7d29da
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1206708
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1206708 - Allow YUV images with gaps between planes in MediaPipelineTransmit. r=jesup MozReview-Commit-ID: HZwQK8guBEr
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -347,54 +347,33 @@ protected:
       PlanarYCbCrImage* yuv = const_cast<PlanarYCbCrImage *>(
           static_cast<const PlanarYCbCrImage *>(aImage));
 
       const PlanarYCbCrData *data = yuv->GetData();
       if (data) {
         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;
       }
     }
 
     RefPtr<SourceSurface> surf = aImage->GetAsSourceSurface();
     if (!surf) {
       MOZ_MTLOG(ML_ERROR, "Getting surface from " << Stringify(format) << " image failed");
       return;
     }