Bug 1139132: Fix Chroma offset on WebRTC remote video when width is not even r=jesup a=lmandel
authorCesar Guirao <cesar@tokbox.com>
Tue, 03 Mar 2015 21:06:00 +0100
changeset 250359 19ac18d33c28
parent 250358 9e52698fd237
child 250360 18ecbc81b0e4
push id4558
push userrjesup@wgate.com
push date2015-03-12 04:04 +0000
treeherdermozilla-beta@19ac18d33c28 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, lmandel
bugs1139132
milestone37.0
Bug 1139132: Fix Chroma offset on WebRTC remote video when width is not even r=jesup a=lmandel Fixed chroma plane offset calculation when frame width/height is not even
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -1387,27 +1387,25 @@ void MediaPipelineReceiveVideo::Pipeline
 #ifdef MOZ_WIDGET_GONK
     ImageFormat format = ImageFormat::GRALLOC_PLANAR_YCBCR;
 #else
     ImageFormat format = ImageFormat::PLANAR_YCBCR;
 #endif
     nsRefPtr<layers::Image> image = image_container_->CreateImage(format);
     layers::PlanarYCbCrImage* yuvImage = static_cast<layers::PlanarYCbCrImage*>(image.get());
     uint8_t* frame = const_cast<uint8_t*>(static_cast<const uint8_t*> (buffer));
-    const uint8_t lumaBpp = 8;
-    const uint8_t chromaBpp = 4;
 
     layers::PlanarYCbCrData yuvData;
     yuvData.mYChannel = frame;
     yuvData.mYSize = IntSize(width_, height_);
-    yuvData.mYStride = width_ * lumaBpp/ 8;
-    yuvData.mCbCrStride = width_ * chromaBpp / 8;
+    yuvData.mYStride = width_;
+    yuvData.mCbCrStride = (width_ + 1) >> 1;
     yuvData.mCbChannel = frame + height_ * yuvData.mYStride;
-    yuvData.mCrChannel = yuvData.mCbChannel + height_ * yuvData.mCbCrStride / 2;
-    yuvData.mCbCrSize = IntSize(width_/ 2, height_/ 2);
+    yuvData.mCrChannel = yuvData.mCbChannel + ((height_ + 1) >> 1) * yuvData.mCbCrStride;
+    yuvData.mCbCrSize = IntSize((width_ + 1) >> 1, (height_ + 1) >> 1);
     yuvData.mPicX = 0;
     yuvData.mPicY = 0;
     yuvData.mPicSize = IntSize(width_, height_);
     yuvData.mStereoMode = StereoMode::MONO;
 
     yuvImage->SetData(yuvData);
 
     image_ = image.forget();