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 "media/gpu/vaapi_jpeg_decode_accelerator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
16 #include "content/common/gpu/media/shared_memory_region.h" | |
17 #include "content/common/gpu/media/vaapi_picture.h" | |
18 #include "gpu/ipc/service/gpu_channel.h" | 16 #include "gpu/ipc/service/gpu_channel.h" |
19 #include "media/base/video_frame.h" | 17 #include "media/base/video_frame.h" |
20 #include "media/filters/jpeg_parser.h" | 18 #include "media/filters/jpeg_parser.h" |
19 #include "media/gpu/shared_memory_region.h" | |
20 #include "media/gpu/vaapi_picture.h" | |
21 #include "third_party/libyuv/include/libyuv.h" | 21 #include "third_party/libyuv/include/libyuv.h" |
22 | 22 |
23 namespace content { | 23 namespace media { |
24 | 24 |
25 namespace { | 25 namespace { |
26 // UMA errors that the VaapiJpegDecodeAccelerator class reports. | 26 // UMA errors that the VaapiJpegDecodeAccelerator class reports. |
27 enum VAJDADecoderFailure { | 27 enum VAJDADecoderFailure { |
28 VAAPI_ERROR = 0, | 28 VAAPI_ERROR = 0, |
29 // UMA requires that max must be greater than 1. | 29 VAJDA_DECODER_FAILURES_MAX, |
Pawel Osciak
2016/04/19 09:22:55
Could we please keep the comment to explain why +1
Mark Dittmer
2016/05/02 03:51:23
The max is no longer greater than 1. If left, the
| |
30 VAJDA_DECODER_FAILURES_MAX = 2, | |
31 }; | 30 }; |
32 | 31 |
33 static void ReportToUMA(VAJDADecoderFailure failure) { | 32 static void ReportToUMA(VAJDADecoderFailure failure) { |
34 UMA_HISTOGRAM_ENUMERATION("Media.VAJDA.DecoderFailure", failure, | 33 UMA_HISTOGRAM_ENUMERATION("Media.VAJDA.DecoderFailure", failure, |
35 VAJDA_DECODER_FAILURES_MAX); | 34 VAJDA_DECODER_FAILURES_MAX + 1); |
36 } | 35 } |
37 | 36 |
38 static unsigned int VaSurfaceFormatForJpeg( | 37 static unsigned int VaSurfaceFormatForJpeg( |
39 const media::JpegFrameHeader& frame_header) { | 38 const media::JpegFrameHeader& frame_header) { |
40 // The range of sampling factor is [1, 4]. Pack them into integer to make the | 39 // The range of sampling factor is [1, 4]. Pack them into integer to make the |
41 // matching code simpler. For example, 0x211 means the sampling factor are 2, | 40 // matching code simpler. For example, 0x211 means the sampling factor are 2, |
42 // 1, 1 for 3 components. | 41 // 1, 1 for 3 components. |
43 unsigned int h = 0, v = 0; | 42 unsigned int h = 0, v = 0; |
44 for (int i = 0; i < frame_header.num_components; i++) { | 43 for (int i = 0; i < frame_header.num_components; i++) { |
45 DCHECK_LE(frame_header.components[i].horizontal_sampling_factor, 4); | 44 DCHECK_LE(frame_header.components[i].horizontal_sampling_factor, 4); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 } // namespace | 76 } // namespace |
78 | 77 |
79 VaapiJpegDecodeAccelerator::DecodeRequest::DecodeRequest( | 78 VaapiJpegDecodeAccelerator::DecodeRequest::DecodeRequest( |
80 int32_t bitstream_buffer_id, | 79 int32_t bitstream_buffer_id, |
81 std::unique_ptr<SharedMemoryRegion> shm, | 80 std::unique_ptr<SharedMemoryRegion> shm, |
82 const scoped_refptr<media::VideoFrame>& video_frame) | 81 const scoped_refptr<media::VideoFrame>& video_frame) |
83 : bitstream_buffer_id(bitstream_buffer_id), | 82 : bitstream_buffer_id(bitstream_buffer_id), |
84 shm(std::move(shm)), | 83 shm(std::move(shm)), |
85 video_frame(video_frame) {} | 84 video_frame(video_frame) {} |
86 | 85 |
87 VaapiJpegDecodeAccelerator::DecodeRequest::~DecodeRequest() { | 86 VaapiJpegDecodeAccelerator::DecodeRequest::~DecodeRequest() {} |
88 } | |
89 | 87 |
90 void VaapiJpegDecodeAccelerator::NotifyError(int32_t bitstream_buffer_id, | 88 void VaapiJpegDecodeAccelerator::NotifyError(int32_t bitstream_buffer_id, |
91 Error error) { | 89 Error error) { |
92 DCHECK(task_runner_->BelongsToCurrentThread()); | 90 DCHECK(task_runner_->BelongsToCurrentThread()); |
93 DLOG(ERROR) << "Notifying of error " << error; | 91 DLOG(ERROR) << "Notifying of error " << error; |
94 DCHECK(client_); | 92 DCHECK(client_); |
95 client_->NotifyError(bitstream_buffer_id, error); | 93 client_->NotifyError(bitstream_buffer_id, error); |
96 } | 94 } |
97 | 95 |
98 void VaapiJpegDecodeAccelerator::NotifyErrorFromDecoderThread( | 96 void VaapiJpegDecodeAccelerator::NotifyErrorFromDecoderThread( |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 | 310 |
313 decoder_task_runner_->PostTask( | 311 decoder_task_runner_->PostTask( |
314 FROM_HERE, base::Bind(&VaapiJpegDecodeAccelerator::DecodeTask, | 312 FROM_HERE, base::Bind(&VaapiJpegDecodeAccelerator::DecodeTask, |
315 base::Unretained(this), base::Passed(&request))); | 313 base::Unretained(this), base::Passed(&request))); |
316 } | 314 } |
317 | 315 |
318 bool VaapiJpegDecodeAccelerator::IsSupported() { | 316 bool VaapiJpegDecodeAccelerator::IsSupported() { |
319 return VaapiWrapper::IsJpegDecodeSupported(); | 317 return VaapiWrapper::IsJpegDecodeSupported(); |
320 } | 318 } |
321 | 319 |
322 } // namespace content | 320 } // namespace media |
OLD | NEW |