Chromium Code Reviews| Index: content/browser/renderer_host/media/video_capture_controller.cc |
| =================================================================== |
| --- content/browser/renderer_host/media/video_capture_controller.cc (revision 151299) |
| +++ content/browser/renderer_host/media/video_capture_controller.cc (working copy) |
| @@ -67,7 +67,9 @@ |
| VideoCaptureController::VideoCaptureController( |
| media_stream::VideoCaptureManager* video_capture_manager) |
| - : frame_info_available_(false), |
| + : chopped_width_(0), |
| + chopped_height_(0), |
| + frame_info_available_(false), |
| video_capture_manager_(video_capture_manager), |
| device_in_use_(false), |
| state_(video_capture::kStopped) { |
| @@ -277,10 +279,12 @@ |
| case media::VideoCaptureCapability::kColorUnknown: // Color format not set. |
| break; |
| case media::VideoCaptureCapability::kI420: { |
| + DCHECK(!chopped_width_ && !chopped_height_); |
| memcpy(target, data, (frame_info_.width * frame_info_.height * 3) / 2); |
| break; |
| } |
| case media::VideoCaptureCapability::kYV12: { |
| + DCHECK(!chopped_width_ && !chopped_height_); |
| const uint8* ptr = data; |
| memcpy(yplane, ptr, (frame_info_.width * frame_info_.height)); |
| ptr += frame_info_.width * frame_info_.height; |
| @@ -290,11 +294,13 @@ |
| break; |
| } |
| case media::VideoCaptureCapability::kNV21: { |
| + DCHECK(!chopped_width_ && !chopped_height_); |
| media::ConvertNV21ToYUV(data, yplane, uplane, vplane, frame_info_.width, |
| frame_info_.height); |
| break; |
| } |
| case media::VideoCaptureCapability::kYUY2: { |
| + DCHECK(!chopped_width_ && !chopped_height_); |
| media::ConvertYUY2ToYUV(data, yplane, uplane, vplane, frame_info_.width, |
| frame_info_.height); |
| break; |
| @@ -303,11 +309,11 @@ |
| int ystride = frame_info_.width; |
| int uvstride = frame_info_.width / 2; |
| #if defined(OS_WIN) // RGB on Windows start at the bottom line. |
| - int rgb_stride = -3 * frame_info_.width; |
| - const uint8* rgb_src = data + 3 * frame_info_.width * |
| - (frame_info_.height -1); |
| + int rgb_stride = -3 * (frame_info_.width + chopped_width_); |
| + const uint8* rgb_src = data + 3 * (frame_info_.width + chopped_width_) * |
| + (frame_info_.height -1 + chopped_height_); |
| #else |
| - int rgb_stride = 3 * frame_info_.width; |
| + int rgb_stride = 3 * (frame_info_.width + chopped_width_); |
| const uint8* rgb_src = data; |
| #endif |
| media::ConvertRGB24ToYUV(rgb_src, yplane, uplane, vplane, |
| @@ -317,7 +323,8 @@ |
| } |
| case media::VideoCaptureCapability::kARGB: { |
| media::ConvertRGB32ToYUV(data, yplane, uplane, vplane, frame_info_.width, |
| - frame_info_.height, frame_info_.width * 4, |
| + frame_info_.height, |
| + (frame_info_.width + chopped_width_) * 4, |
| frame_info_.width, frame_info_.width / 2); |
| break; |
| } |
| @@ -341,6 +348,19 @@ |
| void VideoCaptureController::OnFrameInfo( |
| const media::VideoCaptureCapability& info) { |
| frame_info_= info; |
|
mflodman_chromium_OOO
2012/08/14 08:41:54
Do we know 'info' has odd number of pixels in this
wjia(left Chromium)
2012/08/14 16:07:01
Based on call stack in crbug.com/139004, in some c
|
| + // Handle cases when |info| has odd numbers for width/height. |
| + if (info.width & 1) { |
| + --frame_info_.width; |
| + chopped_width_ = 1; |
| + } else { |
| + chopped_width_ = 0; |
| + } |
| + if (info.height & 1) { |
| + --frame_info_.height; |
| + chopped_height_ = 1; |
| + } else { |
| + chopped_height_ = 0; |
| + } |
| BrowserThread::PostTask(BrowserThread::IO, |
| FROM_HERE, |
| base::Bind(&VideoCaptureController::DoFrameInfoOnIOThread, |