Chromium Code Reviews| 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 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 using content_common_gpu_media::StubPathMap; | 26 using content_common_gpu_media::StubPathMap; |
| 27 | 27 |
| 28 #define NOTIFY_STATUS(name, status, session_failure) \ | 28 #define NOTIFY_STATUS(name, status, session_failure) \ |
| 29 do { \ | 29 do { \ |
| 30 OSSTATUS_DLOG(ERROR, status) << name; \ | 30 OSSTATUS_DLOG(ERROR, status) << name; \ |
| 31 NotifyError(PLATFORM_FAILURE, session_failure); \ | 31 NotifyError(PLATFORM_FAILURE, session_failure); \ |
| 32 } while (0) | 32 } while (0) |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 | 35 |
| 36 const media::VideoCodecProfile kSupportedProfiles[] = { | |
|
wuchengli
2015/03/23 14:42:06
static
henryhsu
2015/03/24 10:02:44
Done.
| |
| 37 H264PROFILE_BASELINE, | |
| 38 H264PROFILE_MAIN, | |
| 39 H264PROFILE_EXTENDED, | |
| 40 H264PROFILE_HIGH, | |
| 41 H264PROFILE_HIGH10PROFILE, | |
| 42 H264PROFILE_SCALABLEBASELINE, | |
| 43 H264PROFILE_SCALABLEHIGH, | |
| 44 H264PROFILE_STEREOHIGH, | |
| 45 H264PROFILE_MULTIVIEWHIGH, | |
| 46 }; | |
| 47 | |
| 36 // Size to use for NALU length headers in AVC format (can be 1, 2, or 4). | 48 // Size to use for NALU length headers in AVC format (can be 1, 2, or 4). |
| 37 static const int kNALUHeaderLength = 4; | 49 static const int kNALUHeaderLength = 4; |
| 38 | 50 |
| 39 // We request 5 picture buffers from the client, each of which has a texture ID | 51 // We request 5 picture buffers from the client, each of which has a texture ID |
| 40 // that we can bind decoded frames to. We need enough to satisfy preroll, and | 52 // that we can bind decoded frames to. We need enough to satisfy preroll, and |
| 41 // enough to avoid unnecessary stalling, but no more than that. The resource | 53 // enough to avoid unnecessary stalling, but no more than that. The resource |
| 42 // requirements are low, as we don't need the textures to be backed by storage. | 54 // requirements are low, as we don't need the textures to be backed by storage. |
| 43 static const int kNumPictureBuffers = media::limits::kMaxVideoFrames + 1; | 55 static const int kNumPictureBuffers = media::limits::kMaxVideoFrames + 1; |
| 44 | 56 |
| 45 // Maximum number of frames to queue for reordering before we stop asking for | 57 // Maximum number of frames to queue for reordering before we stop asking for |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 | 316 |
| 305 bool VTVideoDecodeAccelerator::Initialize( | 317 bool VTVideoDecodeAccelerator::Initialize( |
| 306 media::VideoCodecProfile profile, | 318 media::VideoCodecProfile profile, |
| 307 Client* client) { | 319 Client* client) { |
| 308 DCHECK(gpu_thread_checker_.CalledOnValidThread()); | 320 DCHECK(gpu_thread_checker_.CalledOnValidThread()); |
| 309 client_ = client; | 321 client_ = client; |
| 310 | 322 |
| 311 if (!InitializeVideoToolbox()) | 323 if (!InitializeVideoToolbox()) |
| 312 return false; | 324 return false; |
| 313 | 325 |
| 314 // Only H.264 with 4:2:0 chroma sampling is supported. | 326 // Only H.264 with 4:2:0 chroma sampling is supported. |
|
wuchengli
2015/03/23 14:42:06
Move the comment to where kSupportedProfiles is de
henryhsu
2015/03/24 10:02:44
Done.
| |
| 315 if (profile < media::H264PROFILE_MIN || | 327 bool profile_supported = false; |
| 316 profile > media::H264PROFILE_MAX || | 328 for (size_t i = 0; i < arraysize(kSupportedProfiles); ++i) { |
|
piman
2015/03/23 20:29:30
nit: same as other file, you can use range for loo
henryhsu
2015/03/24 10:02:44
Done.
| |
| 317 profile == media::H264PROFILE_HIGH422PROFILE || | 329 if (profile == kSupportedProfiles[i]) { |
| 318 profile == media::H264PROFILE_HIGH444PREDICTIVEPROFILE) { | 330 profile_supported = true; |
| 331 break; | |
| 332 } | |
| 333 } | |
| 334 if (!profile_supported) | |
| 319 return false; | 335 return false; |
| 320 } | |
| 321 | 336 |
| 322 // Spawn a thread to handle parsing and calling VideoToolbox. | 337 // Spawn a thread to handle parsing and calling VideoToolbox. |
| 323 if (!decoder_thread_.Start()) | 338 if (!decoder_thread_.Start()) |
| 324 return false; | 339 return false; |
| 325 | 340 |
| 326 // Count the session as successfully initialized. | 341 // Count the session as successfully initialized. |
| 327 UMA_HISTOGRAM_ENUMERATION("Media.VTVDA.SessionFailureReason", | 342 UMA_HISTOGRAM_ENUMERATION("Media.VTVDA.SessionFailureReason", |
| 328 SFT_SUCCESSFULLY_INITIALIZED, | 343 SFT_SUCCESSFULLY_INITIALIZED, |
| 329 SFT_MAX + 1); | 344 SFT_MAX + 1); |
| 330 return true; | 345 return true; |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1047 client_->NotifyEndOfBitstreamBuffer(bitstream_id); | 1062 client_->NotifyEndOfBitstreamBuffer(bitstream_id); |
| 1048 assigned_bitstream_ids_.clear(); | 1063 assigned_bitstream_ids_.clear(); |
| 1049 state_ = STATE_DESTROYING; | 1064 state_ = STATE_DESTROYING; |
| 1050 QueueFlush(TASK_DESTROY); | 1065 QueueFlush(TASK_DESTROY); |
| 1051 } | 1066 } |
| 1052 | 1067 |
| 1053 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() { | 1068 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() { |
| 1054 return false; | 1069 return false; |
| 1055 } | 1070 } |
| 1056 | 1071 |
| 1072 // static | |
| 1073 std::vector<media::VideoDecodeAccelerator::SupportedProfile> | |
| 1074 VTVideoDecodeAccelerator::GetSupportedProfiles() { | |
| 1075 std::vector<media::VideoDecodeAccelerator::SupportedProfile> profiles; | |
| 1076 for (size_t i = 0; i < arraysize(kSupportedProfiles); ++i) { | |
| 1077 media::VideoDecodeAccelerator::SupportedProfile profile; | |
| 1078 profile.profile = kSupportedProfiles[i]; | |
| 1079 profile.min_resolution.SetSize(480, 360); | |
| 1080 profile.max_resolution.SetSize(4096, 2160); | |
| 1081 profiles.push_back(profile); | |
| 1082 } | |
| 1083 return profiles; | |
| 1084 } | |
| 1085 | |
| 1057 } // namespace content | 1086 } // namespace content |
| OLD | NEW |