| OLD | NEW |
| 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/common/gpu/media/vaapi_jpeg_decode_accelerator.h" | 5 #include "content/common/gpu/media/vaapi_jpeg_decode_accelerator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" |
| 9 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 11 #include "content/common/gpu/gpu_channel.h" | 12 #include "content/common/gpu/gpu_channel.h" |
| 12 #include "content/common/gpu/media/vaapi_picture.h" | 13 #include "content/common/gpu/media/vaapi_picture.h" |
| 13 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
| 14 #include "media/filters/jpeg_parser.h" | 15 #include "media/filters/jpeg_parser.h" |
| 15 #include "third_party/libyuv/include/libyuv.h" | 16 #include "third_party/libyuv/include/libyuv.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 static void ReportVaapiError() { | 21 // UMA errors that the VaapiJpegDecodeAccelerator class reports. |
| 21 // TODO(kcwu) report error to UMA | 22 enum VAJDADecoderFailure { |
| 23 VAAPI_ERROR = 0, |
| 24 VAJDA_DECODER_FAILURES_MAX, |
| 25 }; |
| 26 |
| 27 static void ReportToUMA(VAJDADecoderFailure failure) { |
| 28 UMA_HISTOGRAM_ENUMERATION("Media.VAJDA.DecoderFailure", failure, |
| 29 VAJDA_DECODER_FAILURES_MAX); |
| 22 } | 30 } |
| 23 } // namespace | 31 } // namespace |
| 24 | 32 |
| 25 VaapiJpegDecodeAccelerator::DecodeRequest::DecodeRequest( | 33 VaapiJpegDecodeAccelerator::DecodeRequest::DecodeRequest( |
| 26 const media::BitstreamBuffer& bitstream_buffer, | 34 const media::BitstreamBuffer& bitstream_buffer, |
| 27 scoped_ptr<base::SharedMemory> shm, | 35 scoped_ptr<base::SharedMemory> shm, |
| 28 const scoped_refptr<media::VideoFrame>& video_frame) | 36 const scoped_refptr<media::VideoFrame>& video_frame) |
| 29 : bitstream_buffer(bitstream_buffer), | 37 : bitstream_buffer(bitstream_buffer), |
| 30 shm(shm.Pass()), | 38 shm(shm.Pass()), |
| 31 video_frame(video_frame) { | 39 video_frame(video_frame) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 decoder_thread_.Stop(); | 82 decoder_thread_.Stop(); |
| 75 } | 83 } |
| 76 | 84 |
| 77 bool VaapiJpegDecodeAccelerator::Initialize(Client* client) { | 85 bool VaapiJpegDecodeAccelerator::Initialize(Client* client) { |
| 78 DCHECK(task_runner_->BelongsToCurrentThread()); | 86 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 79 | 87 |
| 80 client_ = client; | 88 client_ = client; |
| 81 | 89 |
| 82 vaapi_wrapper_ = | 90 vaapi_wrapper_ = |
| 83 VaapiWrapper::Create(VaapiWrapper::kDecode, VAProfileJPEGBaseline, | 91 VaapiWrapper::Create(VaapiWrapper::kDecode, VAProfileJPEGBaseline, |
| 84 base::Bind(&ReportVaapiError)); | 92 base::Bind(&ReportToUMA, VAAPI_ERROR)); |
| 85 | 93 |
| 86 if (!vaapi_wrapper_.get()) { | 94 if (!vaapi_wrapper_.get()) { |
| 87 DLOG(ERROR) << "Failed initializing VAAPI"; | 95 DLOG(ERROR) << "Failed initializing VAAPI"; |
| 88 return false; | 96 return false; |
| 89 } | 97 } |
| 90 | 98 |
| 91 if (!decoder_thread_.Start()) { | 99 if (!decoder_thread_.Start()) { |
| 92 DLOG(ERROR) << "Failed to start decoding thread."; | 100 DLOG(ERROR) << "Failed to start decoding thread."; |
| 93 return false; | 101 return false; |
| 94 } | 102 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 248 |
| 241 scoped_ptr<DecodeRequest> request( | 249 scoped_ptr<DecodeRequest> request( |
| 242 new DecodeRequest(bitstream_buffer, shm.Pass(), video_frame)); | 250 new DecodeRequest(bitstream_buffer, shm.Pass(), video_frame)); |
| 243 | 251 |
| 244 decoder_task_runner_->PostTask( | 252 decoder_task_runner_->PostTask( |
| 245 FROM_HERE, base::Bind(&VaapiJpegDecodeAccelerator::DecodeTask, | 253 FROM_HERE, base::Bind(&VaapiJpegDecodeAccelerator::DecodeTask, |
| 246 base::Unretained(this), base::Passed(&request))); | 254 base::Unretained(this), base::Passed(&request))); |
| 247 } | 255 } |
| 248 | 256 |
| 249 } // namespace content | 257 } // namespace content |
| OLD | NEW |