OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include <CoreVideo/CoreVideo.h> | 7 #include <CoreVideo/CoreVideo.h> |
8 #include <OpenGL/CGLIOSurface.h> | 8 #include <OpenGL/CGLIOSurface.h> |
9 #include <OpenGL/gl.h> | 9 #include <OpenGL/gl.h> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/mac/mac_logging.h" | 14 #include "base/mac/mac_logging.h" |
15 #include "base/metrics/histogram_macros.h" | |
15 #include "base/sys_byteorder.h" | 16 #include "base/sys_byteorder.h" |
16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
17 #include "content/common/gpu/media/vt_video_decode_accelerator.h" | 18 #include "content/common/gpu/media/vt_video_decode_accelerator.h" |
18 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
19 #include "media/base/limits.h" | 20 #include "media/base/limits.h" |
20 #include "ui/gl/scoped_binders.h" | 21 #include "ui/gl/scoped_binders.h" |
21 | 22 |
22 using content_common_gpu_media::kModuleVt; | 23 using content_common_gpu_media::kModuleVt; |
23 using content_common_gpu_media::InitializeStubs; | 24 using content_common_gpu_media::InitializeStubs; |
24 using content_common_gpu_media::IsVtInitialized; | 25 using content_common_gpu_media::IsVtInitialized; |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 | 312 |
312 CFDictionarySetValue( | 313 CFDictionarySetValue( |
313 decoder_config, | 314 decoder_config, |
314 // kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder | 315 // kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder |
315 CFSTR("EnableHardwareAcceleratedVideoDecoder"), | 316 CFSTR("EnableHardwareAcceleratedVideoDecoder"), |
316 kCFBooleanTrue); | 317 kCFBooleanTrue); |
317 | 318 |
318 base::ScopedCFTypeRef<CFMutableDictionaryRef> image_config( | 319 base::ScopedCFTypeRef<CFMutableDictionaryRef> image_config( |
319 BuildImageConfig(coded_dimensions)); | 320 BuildImageConfig(coded_dimensions)); |
320 | 321 |
321 // TODO(sandersd): Does the old session need to be flushed first? | 322 if (!FinishDelayedFrames()) |
Pawel Osciak
2014/12/02 01:21:51
This is I think not related to this CL?
sandersd (OOO until July 31)
2014/12/02 01:25:31
Done.
| |
323 return false; | |
322 session_.reset(); | 324 session_.reset(); |
323 status = VTDecompressionSessionCreate( | 325 status = VTDecompressionSessionCreate( |
324 kCFAllocatorDefault, | 326 kCFAllocatorDefault, |
325 format_, // video_format_description | 327 format_, // video_format_description |
326 decoder_config, // video_decoder_specification | 328 decoder_config, // video_decoder_specification |
327 image_config, // destination_image_buffer_attributes | 329 image_config, // destination_image_buffer_attributes |
328 &callback_, // output_callback | 330 &callback_, // output_callback |
329 session_.InitializeInto()); | 331 session_.InitializeInto()); |
330 if (status) { | 332 if (status) { |
331 NOTIFY_STATUS("VTDecompressionSessionCreate()", status); | 333 NOTIFY_STATUS("VTDecompressionSessionCreate()", status); |
332 return false; | 334 return false; |
333 } | 335 } |
334 | 336 |
337 // Report whether hardware decode is being used. | |
338 base::ScopedCFTypeRef<CFBooleanRef> using_hardware; | |
339 if (VTSessionCopyProperty( | |
340 session_, | |
341 // kVTDecompressionPropertyKey_UsingHardwareAcceleratedVideoDecoder | |
342 CFSTR("UsingHardwareAcceleratedVideoDecoder"), | |
343 kCFAllocatorDefault, | |
344 using_hardware.InitializeInto()) == 0) { | |
345 UMA_HISTOGRAM_BOOLEAN("Media.VTVDA.UsingHardware", | |
346 CFBooleanGetValue(using_hardware)); | |
347 } | |
348 | |
335 return true; | 349 return true; |
336 } | 350 } |
337 | 351 |
338 void VTVideoDecodeAccelerator::DecodeTask( | 352 void VTVideoDecodeAccelerator::DecodeTask( |
339 const media::BitstreamBuffer& bitstream, | 353 const media::BitstreamBuffer& bitstream, |
340 Frame* frame) { | 354 Frame* frame) { |
341 DCHECK(decoder_thread_.message_loop_proxy()->BelongsToCurrentThread()); | 355 DCHECK(decoder_thread_.message_loop_proxy()->BelongsToCurrentThread()); |
342 | 356 |
343 // Map the bitstream buffer. | 357 // Map the bitstream buffer. |
344 base::SharedMemory memory(bitstream.handle(), true); | 358 base::SharedMemory memory(bitstream.handle(), true); |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 assigned_bitstream_ids_.clear(); | 899 assigned_bitstream_ids_.clear(); |
886 state_ = STATE_DESTROYING; | 900 state_ = STATE_DESTROYING; |
887 QueueFlush(TASK_DESTROY); | 901 QueueFlush(TASK_DESTROY); |
888 } | 902 } |
889 | 903 |
890 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() { | 904 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() { |
891 return false; | 905 return false; |
892 } | 906 } |
893 | 907 |
894 } // namespace content | 908 } // namespace content |
OLD | NEW |