| 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.
|
|
|