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

Unified Diff: content/common/gpu/client/gpu_video_encode_accelerator_host.cc

Issue 1128213005: Passing Native Texture backed Video Frame from Renderer to GPU process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Passing a Texture+SharedMemory video frame. Created 5 years, 6 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
« no previous file with comments | « content/common/gpu/client/gpu_video_encode_accelerator_host.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/client/gpu_video_encode_accelerator_host.cc
diff --git a/content/common/gpu/client/gpu_video_encode_accelerator_host.cc b/content/common/gpu/client/gpu_video_encode_accelerator_host.cc
index 1cbfeaa025a5a3c300068a36dba5e7d87b91a0db..42f0887bee19d965298769303e510d9ed516af2a 100644
--- a/content/common/gpu/client/gpu_video_encode_accelerator_host.cc
+++ b/content/common/gpu/client/gpu_video_encode_accelerator_host.cc
@@ -117,33 +117,41 @@ void GpuVideoEncodeAcceleratorHost::Encode(
if (!channel_)
return;
- if (!base::SharedMemory::IsHandleValid(frame->shared_memory_handle())) {
- NOTIFY_ERROR(kPlatformFailureError)
- << "Encode(): cannot encode frame not backed by shared memory";
- return;
- }
- base::SharedMemoryHandle handle =
- channel_->ShareToGpuProcess(frame->shared_memory_handle());
- if (!base::SharedMemory::IsHandleValid(handle)) {
- NOTIFY_ERROR(kPlatformFailureError)
- << "Encode(): failed to duplicate buffer handle for GPU process";
- return;
- }
-
- // We assume that planar frame data passed here is packed and contiguous.
- const size_t plane_count = media::VideoFrame::NumPlanes(frame->format());
- size_t frame_size = 0;
- for (size_t i = 0; i < plane_count; ++i) {
- // Cast DCHECK parameters to void* to avoid printing uint8* as a string.
- DCHECK_EQ(reinterpret_cast<void*>(frame->data(i)),
- reinterpret_cast<void*>((frame->data(0) + frame_size)))
- << "plane=" << i;
- frame_size += frame->stride(i) * frame->rows(i);
+ AcceleratedVideoEncoderMsg_Encode_Params params;
+ params.frame_id = next_frame_id_;
+ params.force_keyframe = force_keyframe;
+ params.storage_type = frame->storage_type();
+ params.pixel_format = frame->format();
+
+ if (frame->storage_type() == media::VideoFrame::STORAGE_SHMEM) {
+ if (!base::SharedMemory::IsHandleValid(frame->shared_memory_handle())) {
+ NOTIFY_ERROR(kPlatformFailureError) << "EncodeSharedMemory(): cannot "
+ "encode frame with invalid shared "
+ "memory handle";
+ return;
+ }
+ params.buffer_handle =
+ channel_->ShareToGpuProcess(frame->shared_memory_handle());
+ if (!base::SharedMemory::IsHandleValid(params.buffer_handle)) {
+ NOTIFY_ERROR(kPlatformFailureError) << "EncodeSharedMemory(): failed to "
+ "duplicate buffer handle for GPU "
+ "process";
+ return;
+ }
+ // We assume that planar frame data passed here is packed and contiguous.
+ params.buffer_size = 0;
+ const size_t plane_count = media::VideoFrame::NumPlanes(frame->format());
+ for (size_t i = 0; i < plane_count; ++i) {
+ // Cast DCHECK parameters to void* to avoid printing uint8* as a string.
+ DCHECK_EQ(reinterpret_cast<void*>(frame->data(i)),
+ reinterpret_cast<void*>((frame->data(0) + params.buffer_size)))
+ << "plane=" << i;
+ params.buffer_size += frame->stride(i) * frame->rows(i);
+ }
+ params.buffer_offset = frame->shared_memory_offset();
}
- Send(new AcceleratedVideoEncoderMsg_Encode(
- encoder_route_id_, next_frame_id_, handle, frame->shared_memory_offset(),
- frame_size, force_keyframe));
+ Send(new AcceleratedVideoEncoderMsg_Encode(encoder_route_id_, params));
frame_map_[next_frame_id_] = frame;
// Mask against 30 bits, to avoid (undefined) wraparound on signed integer.
« no previous file with comments | « content/common/gpu/client/gpu_video_encode_accelerator_host.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698