Index: content/renderer/pepper/pepper_video_capture_host.cc |
diff --git a/content/renderer/pepper/pepper_video_capture_host.cc b/content/renderer/pepper/pepper_video_capture_host.cc |
index 5813a722902d84fdc12041f2d26baa8c34d515ac..abd9147966997d911e579f6972896f825ef6b91a 100644 |
--- a/content/renderer/pepper/pepper_video_capture_host.cc |
+++ b/content/renderer/pepper/pepper_video_capture_host.cc |
@@ -129,29 +129,39 @@ void PepperVideoCaptureHost::OnError(media::VideoCapture* capture, |
void PepperVideoCaptureHost::OnRemoved(media::VideoCapture* capture) { |
} |
-void PepperVideoCaptureHost::OnBufferReady( |
+void PepperVideoCaptureHost::OnFrameReady( |
media::VideoCapture* capture, |
- scoped_refptr<media::VideoCapture::VideoFrameBuffer> buffer) { |
- DCHECK(buffer.get()); |
+ const scoped_refptr<media::VideoFrame>& frame) { |
+ DCHECK(frame.get()); |
for (uint32_t i = 0; i < buffers_.size(); ++i) { |
if (!buffers_[i].in_use) { |
- // TODO(ihf): Switch to a size calculation based on stride. |
- // Stride is filled out now but not more meaningful than size |
- // until wjia unifies VideoFrameBuffer and media::VideoFrame. |
- size_t size = std::min(static_cast<size_t>(buffers_[i].buffer->size()), |
- buffer->buffer_size); |
- memcpy(buffers_[i].data, buffer->memory_pointer, size); |
+ DCHECK_EQ(frame->format(), media::VideoFrame::I420); |
+ if (buffers_[i].buffer->size() < media::VideoFrame::AllocationSize( |
+ frame->format(), frame->coded_size())) { |
+ // TODO(ihf): handle size mismatches gracefully here. |
+ return; |
+ } |
+ uint8* dst = reinterpret_cast<uint8*>(buffers_[i].data); |
+ COMPILE_ASSERT(media::VideoFrame::kYPlane == 0, y_plane_should_be_0); |
Ami GONE FROM CHROMIUM
2013/09/12 22:40:41
What's the point of these tests, beyond the I420 D
sheu
2013/09/13 00:15:19
'Cause ncarter@ wanted them?
We go through the pl
|
+ COMPILE_ASSERT(media::VideoFrame::kUPlane == 1, u_plane_should_be_1); |
+ COMPILE_ASSERT(media::VideoFrame::kVPlane == 2, v_plane_should_be_2); |
Ami GONE FROM CHROMIUM
2013/09/12 22:40:41
lol I've never wondered this before, but what does
sheu
2013/09/13 00:15:19
It means that the data pointers we get out of medi
|
+ for (size_t j = 0; j < media::VideoFrame::NumPlanes(frame->format()); |
Ami GONE FROM CHROMIUM
2013/09/12 22:40:41
I idly wonder if there value in a
void VideoFrame
sheu
2013/09/13 00:15:19
I looked already, and so far this is the only plac
Ami GONE FROM CHROMIUM
2013/09/13 00:26:34
!!
ncarter (slow)
2013/09/13 21:01:11
Another idea would be to wrap the target pointer i
sheu
2013/09/16 19:09:11
A little heavyweight there, I think.
|
+ ++j) { |
+ const uint8* src = frame->data(j); |
+ const size_t row_bytes = frame->row_bytes(j); |
+ const size_t src_stride = frame->stride(j); |
+ for (int k = 0; k < frame->rows(j); ++k) { |
+ memcpy(dst, src, row_bytes); |
+ dst += row_bytes; |
+ src += src_stride; |
+ } |
Ami GONE FROM CHROMIUM
2013/09/12 22:40:41
Is the sole difference between l.150-157 and:
siz
sheu
2013/09/13 00:15:19
Paranoia in case strides don't match up.
|
+ } |
buffers_[i].in_use = true; |
- platform_video_capture_->FeedBuffer(buffer); |
host()->SendUnsolicitedReply(pp_resource(), |
PpapiPluginMsg_VideoCapture_OnBufferReady(i)); |
return; |
} |
} |
- |
- // No free slot, just discard the frame and tell the media layer it can |
- // re-use the buffer. |
- platform_video_capture_->FeedBuffer(buffer); |
} |
void PepperVideoCaptureHost::OnDeviceInfoReceived( |
@@ -164,10 +174,8 @@ void PepperVideoCaptureHost::OnDeviceInfoReceived( |
}; |
ReleaseBuffers(); |
- // YUV 4:2:0 |
- int uv_width = info.width / 2; |
- int uv_height = info.height / 2; |
- size_t size = info.width * info.height + 2 * uv_width * uv_height; |
+ const size_t size = media::VideoFrame::AllocationSize( |
+ media::VideoFrame::I420, gfx::Size(info.width, info.height)); |
ppapi::proxy::ResourceMessageReplyParams params(pp_resource(), 0); |