| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "media/gpu/ipc/common/gpu_video_accelerator_util.h" | |
| 6 | |
| 7 namespace media { | |
| 8 | |
| 9 // Make sure the enum values of VideoCodecProfile and | |
| 10 // gpu::VideoCodecProfile match. | |
| 11 #define STATIC_ASSERT_ENUM_MATCH(name) \ | |
| 12 static_assert(name == static_cast<VideoCodecProfile>(gpu::name), \ | |
| 13 #name " value must match in media and gpu.") | |
| 14 | |
| 15 STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_UNKNOWN); | |
| 16 STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_MIN); | |
| 17 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_BASELINE); | |
| 18 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_MAIN); | |
| 19 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_EXTENDED); | |
| 20 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH); | |
| 21 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH10PROFILE); | |
| 22 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH422PROFILE); | |
| 23 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH444PREDICTIVEPROFILE); | |
| 24 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_SCALABLEBASELINE); | |
| 25 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_SCALABLEHIGH); | |
| 26 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_STEREOHIGH); | |
| 27 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_MULTIVIEWHIGH); | |
| 28 STATIC_ASSERT_ENUM_MATCH(VP8PROFILE_ANY); | |
| 29 STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_PROFILE0); | |
| 30 STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_PROFILE1); | |
| 31 STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_PROFILE2); | |
| 32 STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_PROFILE3); | |
| 33 STATIC_ASSERT_ENUM_MATCH(HEVCPROFILE_MAIN); | |
| 34 STATIC_ASSERT_ENUM_MATCH(HEVCPROFILE_MAIN10); | |
| 35 STATIC_ASSERT_ENUM_MATCH(HEVCPROFILE_MAIN_STILL_PICTURE); | |
| 36 STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_MAX); | |
| 37 | |
| 38 // static | |
| 39 VideoDecodeAccelerator::Capabilities | |
| 40 GpuVideoAcceleratorUtil::ConvertGpuToMediaDecodeCapabilities( | |
| 41 const gpu::VideoDecodeAcceleratorCapabilities& gpu_capabilities) { | |
| 42 VideoDecodeAccelerator::Capabilities capabilities; | |
| 43 capabilities.supported_profiles = | |
| 44 ConvertGpuToMediaDecodeProfiles(gpu_capabilities.supported_profiles); | |
| 45 capabilities.flags = gpu_capabilities.flags; | |
| 46 return capabilities; | |
| 47 } | |
| 48 | |
| 49 // static | |
| 50 VideoDecodeAccelerator::SupportedProfiles | |
| 51 GpuVideoAcceleratorUtil::ConvertGpuToMediaDecodeProfiles( | |
| 52 const gpu::VideoDecodeAcceleratorSupportedProfiles& gpu_profiles) { | |
| 53 VideoDecodeAccelerator::SupportedProfiles profiles; | |
| 54 for (const auto& gpu_profile : gpu_profiles) { | |
| 55 VideoDecodeAccelerator::SupportedProfile profile; | |
| 56 profile.profile = static_cast<VideoCodecProfile>(gpu_profile.profile); | |
| 57 profile.max_resolution = gpu_profile.max_resolution; | |
| 58 profile.min_resolution = gpu_profile.min_resolution; | |
| 59 profile.encrypted_only = gpu_profile.encrypted_only; | |
| 60 profiles.push_back(profile); | |
| 61 } | |
| 62 return profiles; | |
| 63 } | |
| 64 | |
| 65 // static | |
| 66 gpu::VideoDecodeAcceleratorCapabilities | |
| 67 GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeCapabilities( | |
| 68 const VideoDecodeAccelerator::Capabilities& media_capabilities) { | |
| 69 gpu::VideoDecodeAcceleratorCapabilities capabilities; | |
| 70 capabilities.supported_profiles = | |
| 71 ConvertMediaToGpuDecodeProfiles(media_capabilities.supported_profiles); | |
| 72 capabilities.flags = media_capabilities.flags; | |
| 73 return capabilities; | |
| 74 } | |
| 75 | |
| 76 // static | |
| 77 gpu::VideoDecodeAcceleratorSupportedProfiles | |
| 78 GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeProfiles( | |
| 79 const VideoDecodeAccelerator::SupportedProfiles& media_profiles) { | |
| 80 gpu::VideoDecodeAcceleratorSupportedProfiles profiles; | |
| 81 for (const auto& media_profile : media_profiles) { | |
| 82 gpu::VideoDecodeAcceleratorSupportedProfile profile; | |
| 83 profile.profile = | |
| 84 static_cast<gpu::VideoCodecProfile>(media_profile.profile); | |
| 85 profile.max_resolution = media_profile.max_resolution; | |
| 86 profile.min_resolution = media_profile.min_resolution; | |
| 87 profile.encrypted_only = media_profile.encrypted_only; | |
| 88 profiles.push_back(profile); | |
| 89 } | |
| 90 return profiles; | |
| 91 } | |
| 92 | |
| 93 // static | |
| 94 VideoEncodeAccelerator::SupportedProfiles | |
| 95 GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles( | |
| 96 const gpu::VideoEncodeAcceleratorSupportedProfiles& gpu_profiles) { | |
| 97 VideoEncodeAccelerator::SupportedProfiles profiles; | |
| 98 for (const auto& gpu_profile : gpu_profiles) { | |
| 99 VideoEncodeAccelerator::SupportedProfile profile; | |
| 100 profile.profile = static_cast<VideoCodecProfile>(gpu_profile.profile); | |
| 101 profile.max_resolution = gpu_profile.max_resolution; | |
| 102 profile.max_framerate_numerator = gpu_profile.max_framerate_numerator; | |
| 103 profile.max_framerate_denominator = gpu_profile.max_framerate_denominator; | |
| 104 profiles.push_back(profile); | |
| 105 } | |
| 106 return profiles; | |
| 107 } | |
| 108 | |
| 109 // static | |
| 110 gpu::VideoEncodeAcceleratorSupportedProfiles | |
| 111 GpuVideoAcceleratorUtil::ConvertMediaToGpuEncodeProfiles( | |
| 112 const VideoEncodeAccelerator::SupportedProfiles& media_profiles) { | |
| 113 gpu::VideoEncodeAcceleratorSupportedProfiles profiles; | |
| 114 for (const auto& media_profile : media_profiles) { | |
| 115 gpu::VideoEncodeAcceleratorSupportedProfile profile; | |
| 116 profile.profile = | |
| 117 static_cast<gpu::VideoCodecProfile>(media_profile.profile); | |
| 118 profile.max_resolution = media_profile.max_resolution; | |
| 119 profile.max_framerate_numerator = media_profile.max_framerate_numerator; | |
| 120 profile.max_framerate_denominator = media_profile.max_framerate_denominator; | |
| 121 profiles.push_back(profile); | |
| 122 } | |
| 123 return profiles; | |
| 124 } | |
| 125 | |
| 126 // static | |
| 127 void GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( | |
| 128 const VideoDecodeAccelerator::SupportedProfiles& new_profiles, | |
| 129 VideoDecodeAccelerator::SupportedProfiles* media_profiles) { | |
| 130 for (const auto& profile : new_profiles) { | |
| 131 bool duplicate = false; | |
| 132 for (const auto& media_profile : *media_profiles) { | |
| 133 if (media_profile.profile == profile.profile) { | |
| 134 duplicate = true; | |
| 135 break; | |
| 136 } | |
| 137 } | |
| 138 if (!duplicate) | |
| 139 media_profiles->push_back(profile); | |
| 140 } | |
| 141 } | |
| 142 | |
| 143 // static | |
| 144 void GpuVideoAcceleratorUtil::InsertUniqueEncodeProfiles( | |
| 145 const VideoEncodeAccelerator::SupportedProfiles& new_profiles, | |
| 146 VideoEncodeAccelerator::SupportedProfiles* media_profiles) { | |
| 147 for (const auto& profile : new_profiles) { | |
| 148 bool duplicate = false; | |
| 149 for (const auto& media_profile : *media_profiles) { | |
| 150 if (media_profile.profile == profile.profile) { | |
| 151 duplicate = true; | |
| 152 break; | |
| 153 } | |
| 154 } | |
| 155 if (!duplicate) | |
| 156 media_profiles->push_back(profile); | |
| 157 } | |
| 158 } | |
| 159 | |
| 160 } // namespace media | |
| OLD | NEW |