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/metrics/histogram.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 << frame_header.num_components << ", h=" << std::hex << h | 66 << frame_header.num_components << ", h=" << std::hex << h |
67 << ", v=" << v; | 67 << ", v=" << v; |
68 | 68 |
69 return 0; | 69 return 0; |
70 } | 70 } |
71 | 71 |
72 } // namespace | 72 } // namespace |
73 | 73 |
74 VaapiJpegDecodeAccelerator::DecodeRequest::DecodeRequest( | 74 VaapiJpegDecodeAccelerator::DecodeRequest::DecodeRequest( |
75 const media::BitstreamBuffer& bitstream_buffer, | 75 const media::BitstreamBuffer& bitstream_buffer, |
76 scoped_ptr<base::SharedMemory> shm, | 76 scoped_ptr<SharedMemoryRegion> shm, |
77 const scoped_refptr<media::VideoFrame>& video_frame) | 77 const scoped_refptr<media::VideoFrame>& video_frame) |
78 : bitstream_buffer(bitstream_buffer), | 78 : bitstream_buffer(bitstream_buffer), |
79 shm(shm.Pass()), | 79 shm(shm.Pass()), |
80 video_frame(video_frame) { | 80 video_frame(video_frame) {} |
81 } | |
82 | 81 |
83 VaapiJpegDecodeAccelerator::DecodeRequest::~DecodeRequest() { | 82 VaapiJpegDecodeAccelerator::DecodeRequest::~DecodeRequest() { |
84 } | 83 } |
85 | 84 |
86 void VaapiJpegDecodeAccelerator::NotifyError(int32_t bitstream_buffer_id, | 85 void VaapiJpegDecodeAccelerator::NotifyError(int32_t bitstream_buffer_id, |
87 Error error) { | 86 Error error) { |
88 DCHECK(task_runner_->BelongsToCurrentThread()); | 87 DCHECK(task_runner_->BelongsToCurrentThread()); |
89 DLOG(ERROR) << "Notifying of error " << error; | 88 DLOG(ERROR) << "Notifying of error " << error; |
90 DCHECK(client_); | 89 DCHECK(client_); |
91 client_->NotifyError(bitstream_buffer_id, error); | 90 client_->NotifyError(bitstream_buffer_id, error); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 278 |
280 void VaapiJpegDecodeAccelerator::Decode( | 279 void VaapiJpegDecodeAccelerator::Decode( |
281 const media::BitstreamBuffer& bitstream_buffer, | 280 const media::BitstreamBuffer& bitstream_buffer, |
282 const scoped_refptr<media::VideoFrame>& video_frame) { | 281 const scoped_refptr<media::VideoFrame>& video_frame) { |
283 DVLOG(3) << __func__; | 282 DVLOG(3) << __func__; |
284 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 283 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
285 TRACE_EVENT1("jpeg", "Decode", "input_id", bitstream_buffer.id()); | 284 TRACE_EVENT1("jpeg", "Decode", "input_id", bitstream_buffer.id()); |
286 | 285 |
287 DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id() | 286 DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id() |
288 << " size: " << bitstream_buffer.size(); | 287 << " size: " << bitstream_buffer.size(); |
289 scoped_ptr<base::SharedMemory> shm( | 288 scoped_ptr<SharedMemoryRegion> shm( |
290 new base::SharedMemory(bitstream_buffer.handle(), true)); | 289 new SharedMemoryRegion(bitstream_buffer, true)); |
291 | 290 |
292 if (!shm->Map(bitstream_buffer.size())) { | 291 if (!shm->Map()) { |
293 LOG(ERROR) << "Failed to map input buffer"; | 292 LOG(ERROR) << "Failed to map input buffer"; |
294 NotifyErrorFromDecoderThread(bitstream_buffer.id(), UNREADABLE_INPUT); | 293 NotifyErrorFromDecoderThread(bitstream_buffer.id(), UNREADABLE_INPUT); |
295 return; | 294 return; |
296 } | 295 } |
297 | 296 |
298 scoped_ptr<DecodeRequest> request( | 297 scoped_ptr<DecodeRequest> request( |
299 new DecodeRequest(bitstream_buffer, shm.Pass(), video_frame)); | 298 new DecodeRequest(bitstream_buffer, shm.Pass(), video_frame)); |
300 | 299 |
301 decoder_task_runner_->PostTask( | 300 decoder_task_runner_->PostTask( |
302 FROM_HERE, base::Bind(&VaapiJpegDecodeAccelerator::DecodeTask, | 301 FROM_HERE, base::Bind(&VaapiJpegDecodeAccelerator::DecodeTask, |
303 base::Unretained(this), base::Passed(&request))); | 302 base::Unretained(this), base::Passed(&request))); |
304 } | 303 } |
305 | 304 |
306 bool VaapiJpegDecodeAccelerator::IsSupported() { | 305 bool VaapiJpegDecodeAccelerator::IsSupported() { |
307 return VaapiWrapper::IsJpegDecodeSupported(); | 306 return VaapiWrapper::IsJpegDecodeSupported(); |
308 } | 307 } |
309 | 308 |
310 } // namespace content | 309 } // namespace content |
OLD | NEW |