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

Unified Diff: content/browser/renderer_host/media/video_capture_device_client.cc

Issue 1132683004: MJPEG acceleration for video capture, browser part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mjpeg-2-gpu
Patch Set: fix gpu channel establish 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
Index: content/browser/renderer_host/media/video_capture_device_client.cc
diff --git a/content/browser/renderer_host/media/video_capture_device_client.cc b/content/browser/renderer_host/media/video_capture_device_client.cc
index 33030ab6b621b4a418a618ef61273d08ef8e90e8..40bd94df737867d85bad5e890fc51d6ed8778b49 100644
--- a/content/browser/renderer_host/media/video_capture_device_client.cc
+++ b/content/browser/renderer_host/media/video_capture_device_client.cc
@@ -11,6 +11,7 @@
#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
+#include "content/browser/renderer_host/gpu_jpeg_decoder.h"
#include "content/browser/renderer_host/media/video_capture_buffer_pool.h"
#include "content/browser/renderer_host/media/video_capture_controller.h"
#include "content/common/gpu/client/context_provider_command_buffer.h"
@@ -200,13 +201,17 @@ VideoCaptureDeviceClient::VideoCaptureDeviceClient(
const scoped_refptr<VideoCaptureBufferPool>& buffer_pool,
const scoped_refptr<base::SingleThreadTaskRunner>& capture_task_runner)
: controller_(controller),
+ external_jpeg_decoder_initialized_(false),
buffer_pool_(buffer_pool),
capture_task_runner_(capture_task_runner),
last_captured_pixel_format_(media::PIXEL_FORMAT_UNKNOWN) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
}
-VideoCaptureDeviceClient::~VideoCaptureDeviceClient() {}
+VideoCaptureDeviceClient::~VideoCaptureDeviceClient() {
+ DCHECK(capture_task_runner_->BelongsToCurrentThread());
+ external_jpeg_decoder_.reset();
+}
void VideoCaptureDeviceClient::OnIncomingCapturedData(
const uint8* data,
@@ -220,6 +225,23 @@ void VideoCaptureDeviceClient::OnIncomingCapturedData(
OnLog("Pixel format: " + media::VideoCaptureFormat::PixelFormatToString(
frame_format.pixel_format));
last_captured_pixel_format_ = frame_format.pixel_format;
+
+ if (frame_format.pixel_format == media::PIXEL_FORMAT_MJPEG &&
+ !external_jpeg_decoder_initialized_) {
+ external_jpeg_decoder_initialized_ = true;
+ if (GpuJpegDecoder::Supported()) {
+ // base::Unretained is safe because |this| outlives
+ // |external_jpeg_decoder_|.
+ external_jpeg_decoder_.reset(new GpuJpegDecoder(
+ base::Bind(
+ &VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread,
+ controller_),
+ // TODO(kcwu): fallback to software decode if error.
+ base::Bind(&VideoCaptureDeviceClient::OnError,
+ base::Unretained(this))));
piman 2015/06/20 00:33:57 nit: can you add a comment about why Unretained is
kcwu 2015/06/20 00:47:08 line 233 does. Do you want me to explain it furthe
piman 2015/06/20 00:59:26 Oh, missed that. I guess that's fine... the main t
kcwu 2015/06/20 01:26:10 Done.
+ external_jpeg_decoder_->Initialize();
+ }
+ }
}
if (!frame_format.IsValid())
@@ -333,6 +355,14 @@ void VideoCaptureDeviceClient::OnIncomingCapturedData(
// paddings and/or alignments, but it cannot be smaller.
DCHECK_GE(static_cast<size_t>(length), frame_format.ImageAllocationSize());
+ if (external_jpeg_decoder_ &&
+ frame_format.pixel_format == media::PIXEL_FORMAT_MJPEG && rotation == 0 &&
+ !flip && external_jpeg_decoder_->ReadyToDecode()) {
+ external_jpeg_decoder_->DecodeCapturedData(data, length, frame_format,
+ timestamp, buffer.Pass());
+ return;
+ }
+
if (libyuv::ConvertToI420(data,
length,
yplane,
« no previous file with comments | « content/browser/renderer_host/media/video_capture_device_client.h ('k') | content/common/gpu/gpu_process_launch_causes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698