Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: media/capture/video/fake_video_capture_device.cc

Issue 2398463003: 16 bit capture and GPU&CPU memory buffer support.
Patch Set: fixes. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/capture/video/fake_video_capture_device.cc
diff --git a/media/capture/video/fake_video_capture_device.cc b/media/capture/video/fake_video_capture_device.cc
index 0482f359db530006da6135e8b6e29ed50c58cb8b..97f18ec349c1b45c9d3c916754ba0b4dca7c0e61 100644
--- a/media/capture/video/fake_video_capture_device.cc
+++ b/media/capture/video/fake_video_capture_device.cc
@@ -113,9 +113,11 @@ void DoTakeFakePhoto(VideoCaptureDevice::TakePhotoCallback callback,
}
FakeVideoCaptureDevice::FakeVideoCaptureDevice(BufferOwnership buffer_ownership,
- float fake_capture_rate)
+ float fake_capture_rate,
+ VideoPixelFormat pixel_format)
: buffer_ownership_(buffer_ownership),
fake_capture_rate_(fake_capture_rate),
+ pixel_format_(pixel_format),
current_zoom_(kMinZoom),
weak_factory_(this) {}
@@ -143,19 +145,20 @@ void FakeVideoCaptureDevice::AllocateAndStart(
else
capture_format_.frame_size.SetSize(320, 240);
+ capture_format_.pixel_format = pixel_format_;
if (buffer_ownership_ == BufferOwnership::CLIENT_BUFFERS) {
capture_format_.pixel_storage = PIXEL_STORAGE_CPU;
capture_format_.pixel_format = PIXEL_FORMAT_ARGB;
DVLOG(1) << "starting with client argb buffers";
} else if (buffer_ownership_ == BufferOwnership::OWN_BUFFERS) {
capture_format_.pixel_storage = PIXEL_STORAGE_CPU;
- capture_format_.pixel_format = PIXEL_FORMAT_I420;
- DVLOG(1) << "starting with own I420 buffers";
+ DVLOG(1) << "starting with own" << VideoPixelFormatToString(pixel_format_)
+ << "buffers";
}
- if (capture_format_.pixel_format == PIXEL_FORMAT_I420) {
+ if (buffer_ownership_ != BufferOwnership::CLIENT_BUFFERS) {
fake_frame_.reset(new uint8_t[VideoFrame::AllocationSize(
- PIXEL_FORMAT_I420, capture_format_.frame_size)]);
+ pixel_format_, capture_format_.frame_size)]);
}
beep_time_ = base::TimeDelta();
@@ -261,8 +264,7 @@ void FakeVideoCaptureDevice::CaptureUsingClientBuffers(
DLOG_IF(ERROR, !capture_buffer) << "Couldn't allocate Capture Buffer";
DCHECK(capture_buffer->data()) << "Buffer has NO backing memory";
- if (capture_format_.pixel_storage == PIXEL_STORAGE_GPUMEMORYBUFFER &&
- capture_format_.pixel_format == media::PIXEL_FORMAT_I420) {
+ if (capture_format_.pixel_storage == PIXEL_STORAGE_GPUMEMORYBUFFER) {
// Since SkBitmap expects a packed&continuous memory region for I420, we
// need to use |fake_frame_| to draw onto.
memset(fake_frame_.get(), 0, capture_format_.ImageAllocationSize());
@@ -271,9 +273,10 @@ void FakeVideoCaptureDevice::CaptureUsingClientBuffers(
// Copy data from |fake_frame_| into the reserved planes of GpuMemoryBuffer.
size_t offset = 0;
- for (size_t i = 0; i < VideoFrame::NumPlanes(PIXEL_FORMAT_I420); ++i) {
+ for (size_t i = 0; i < VideoFrame::NumPlanes(capture_format_.pixel_format);
+ ++i) {
const size_t plane_size =
- VideoFrame::PlaneSize(PIXEL_FORMAT_I420, i,
+ VideoFrame::PlaneSize(capture_format_.pixel_format, i,
capture_format_.frame_size)
.GetArea();
memcpy(capture_buffer->data(i), fake_frame_.get() + offset, plane_size);
« no previous file with comments | « media/capture/video/fake_video_capture_device.h ('k') | media/capture/video/fake_video_capture_device_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698