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

Side by Side Diff: content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.cc

Issue 2735083002: [Mojo Video Capture] Add test coverage for accelerated jpeg decoding (Closed)
Patch Set: Rebase to March 15th, Remove #include jpeg_parser Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" 5 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 18 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
21 #include "media/base/media_switches.h"
21 #include "media/base/video_frame.h" 22 #include "media/base/video_frame.h"
22 #include "media/gpu/ipc/client/gpu_jpeg_decode_accelerator_host.h" 23 #include "media/gpu/ipc/client/gpu_jpeg_decode_accelerator_host.h"
23 #include "mojo/public/cpp/system/platform_handle.h" 24 #include "mojo/public/cpp/system/platform_handle.h"
24 25
25 namespace content { 26 namespace content {
26 27
27 VideoCaptureGpuJpegDecoder::VideoCaptureGpuJpegDecoder( 28 VideoCaptureGpuJpegDecoder::VideoCaptureGpuJpegDecoder(
28 const DecodeDoneCB& decode_done_cb) 29 const DecodeDoneCB& decode_done_cb)
29 : decode_done_cb_(decode_done_cb), 30 : decode_done_cb_(decode_done_cb),
30 next_bitstream_buffer_id_(0), 31 next_bitstream_buffer_id_(0),
31 in_buffer_id_(media::JpegDecodeAccelerator::kInvalidBitstreamBufferId), 32 in_buffer_id_(media::JpegDecodeAccelerator::kInvalidBitstreamBufferId),
32 decoder_status_(INIT_PENDING) {} 33 decoder_status_(INIT_PENDING) {}
33 34
34 VideoCaptureGpuJpegDecoder::~VideoCaptureGpuJpegDecoder() { 35 VideoCaptureGpuJpegDecoder::~VideoCaptureGpuJpegDecoder() {
35 DCHECK(CalledOnValidThread()); 36 DCHECK(CalledOnValidThread());
36 37
37 // |decoder_| guarantees no more JpegDecodeAccelerator::Client callbacks 38 // |decoder_| guarantees no more JpegDecodeAccelerator::Client callbacks
38 // on IO thread after deletion. 39 // on IO thread after deletion.
39 decoder_.reset(); 40 decoder_.reset();
40 41
41 // |gpu_channel_host_| should outlive |decoder_|, so |gpu_channel_host_| 42 // |gpu_channel_host_| should outlive |decoder_|, so |gpu_channel_host_|
42 // must be released after |decoder_| has been destroyed. 43 // must be released after |decoder_| has been destroyed.
43 gpu_channel_host_ = nullptr; 44 gpu_channel_host_ = nullptr;
44 } 45 }
45 46
46 void VideoCaptureGpuJpegDecoder::Initialize() { 47 void VideoCaptureGpuJpegDecoder::Initialize() {
47 DCHECK(CalledOnValidThread()); 48 DCHECK(CalledOnValidThread());
48 49
49 base::AutoLock lock(lock_); 50 base::AutoLock lock(lock_);
50 bool is_platform_supported = false; 51 bool is_platform_supported =
52 base::CommandLine::ForCurrentProcess()->HasSwitch(
53 switches::kUseFakeJpegDecodeAccelerator);
51 #if defined(OS_CHROMEOS) 54 #if defined(OS_CHROMEOS)
52 // Non-ChromeOS platforms do not support HW JPEG decode now. Do not establish 55 // Non-ChromeOS platforms do not support HW JPEG decode now. Do not establish
53 // gpu channel to avoid introducing overhead. 56 // gpu channel to avoid introducing overhead.
54 is_platform_supported = true; 57 is_platform_supported = true;
55 #endif 58 #endif
56 59
57 if (!is_platform_supported || 60 if (!is_platform_supported ||
58 base::CommandLine::ForCurrentProcess()->HasSwitch( 61 base::CommandLine::ForCurrentProcess()->HasSwitch(
59 switches::kDisableAcceleratedMjpegDecode)) { 62 switches::kDisableAcceleratedMjpegDecode)) {
60 decoder_status_ = FAILED; 63 decoder_status_ = FAILED;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 lock_.AssertAcquired(); 265 lock_.AssertAcquired();
263 return !decode_done_closure_.is_null(); 266 return !decode_done_closure_.is_null();
264 } 267 }
265 268
266 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() { 269 void VideoCaptureGpuJpegDecoder::RecordInitDecodeUMA_Locked() {
267 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess", 270 UMA_HISTOGRAM_BOOLEAN("Media.VideoCaptureGpuJpegDecoder.InitDecodeSuccess",
268 decoder_status_ == INIT_PASSED); 271 decoder_status_ == INIT_PASSED);
269 } 272 }
270 273
271 } // namespace content 274 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698