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 "content/common/gpu/media/gpu_video_accelerator_util.h" |
| 6 |
| 7 namespace content { |
| 8 |
| 9 // Make sure the enum values of media::VideoCodecProfile and |
| 10 // gpu::VideoCodecProfile match. |
| 11 #define STATIC_ASSERT_ENUM_MATCH(name) \ |
| 12 static_assert( \ |
| 13 media::name == static_cast<media::VideoCodecProfile>(gpu::name), \ |
| 14 #name " value must match in media and gpu.") |
| 15 |
| 16 STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_UNKNOWN); |
| 17 STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_MIN); |
| 18 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_BASELINE); |
| 19 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_MAIN); |
| 20 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_EXTENDED); |
| 21 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH); |
| 22 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH10PROFILE); |
| 23 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH422PROFILE); |
| 24 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH444PREDICTIVEPROFILE); |
| 25 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_SCALABLEBASELINE); |
| 26 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_SCALABLEHIGH); |
| 27 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_STEREOHIGH); |
| 28 STATIC_ASSERT_ENUM_MATCH(H264PROFILE_MULTIVIEWHIGH); |
| 29 STATIC_ASSERT_ENUM_MATCH(VP8PROFILE_ANY); |
| 30 STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_ANY); |
| 31 STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_MAX); |
| 32 |
| 33 // static |
| 34 std::vector<media::VideoDecodeAccelerator::SupportedProfile> |
| 35 GpuVideoAcceleratorUtil::ConvertGpuToMediaDecodeProfiles(const std::vector< |
| 36 gpu::VideoDecodeAcceleratorSupportedProfile>& gpu_profiles) { |
| 37 std::vector<media::VideoDecodeAccelerator::SupportedProfile> profiles; |
| 38 for (const auto& gpu_profile : gpu_profiles) { |
| 39 media::VideoDecodeAccelerator::SupportedProfile profile; |
| 40 profile.profile = |
| 41 static_cast<media::VideoCodecProfile>(gpu_profile.profile); |
| 42 profile.max_resolution = gpu_profile.max_resolution; |
| 43 profile.min_resolution = gpu_profile.min_resolution; |
| 44 profiles.push_back(profile); |
| 45 } |
| 46 return profiles; |
| 47 } |
| 48 |
| 49 // static |
| 50 std::vector<gpu::VideoDecodeAcceleratorSupportedProfile> |
| 51 GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeProfiles(const std::vector< |
| 52 media::VideoDecodeAccelerator::SupportedProfile>& media_profiles) { |
| 53 std::vector<gpu::VideoDecodeAcceleratorSupportedProfile> profiles; |
| 54 for (const auto& media_profile : media_profiles) { |
| 55 gpu::VideoDecodeAcceleratorSupportedProfile profile; |
| 56 profile.profile = |
| 57 static_cast<gpu::VideoCodecProfile>(media_profile.profile); |
| 58 profile.max_resolution = media_profile.max_resolution; |
| 59 profile.min_resolution = media_profile.min_resolution; |
| 60 profiles.push_back(profile); |
| 61 } |
| 62 return profiles; |
| 63 } |
| 64 |
| 65 // static |
| 66 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
| 67 GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles(const std::vector< |
| 68 gpu::VideoEncodeAcceleratorSupportedProfile>& gpu_profiles) { |
| 69 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; |
| 70 for (const auto& gpu_profile : gpu_profiles) { |
| 71 media::VideoEncodeAccelerator::SupportedProfile profile; |
| 72 profile.profile = |
| 73 static_cast<media::VideoCodecProfile>(gpu_profile.profile); |
| 74 profile.max_resolution = gpu_profile.max_resolution; |
| 75 profile.max_framerate_numerator = gpu_profile.max_framerate_numerator; |
| 76 profile.max_framerate_denominator = gpu_profile.max_framerate_denominator; |
| 77 profiles.push_back(profile); |
| 78 } |
| 79 return profiles; |
| 80 } |
| 81 |
| 82 // static |
| 83 std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> |
| 84 GpuVideoAcceleratorUtil::ConvertMediaToGpuEncodeProfiles(const std::vector< |
| 85 media::VideoEncodeAccelerator::SupportedProfile>& media_profiles) { |
| 86 std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> profiles; |
| 87 for (const auto& media_profile : media_profiles) { |
| 88 gpu::VideoEncodeAcceleratorSupportedProfile profile; |
| 89 profile.profile = |
| 90 static_cast<gpu::VideoCodecProfile>(media_profile.profile); |
| 91 profile.max_resolution = media_profile.max_resolution; |
| 92 profile.max_framerate_numerator = media_profile.max_framerate_numerator; |
| 93 profile.max_framerate_denominator = media_profile.max_framerate_denominator; |
| 94 profiles.push_back(profile); |
| 95 } |
| 96 return profiles; |
| 97 } |
| 98 |
| 99 // static |
| 100 void GpuVideoAcceleratorUtil::UniqueInsertDecodeProfiles( |
| 101 std::vector<media::VideoDecodeAccelerator::SupportedProfile>* |
| 102 media_profiles, |
| 103 const std::vector<media::VideoDecodeAccelerator::SupportedProfile>& |
| 104 new_profiles) { |
| 105 for (const auto& profile : new_profiles) { |
| 106 bool duplicate = false; |
| 107 for (const auto& media_profile : *media_profiles) { |
| 108 if (media_profile.profile == profile.profile) { |
| 109 duplicate = true; |
| 110 break; |
| 111 } |
| 112 } |
| 113 if (!duplicate) |
| 114 media_profiles->push_back(profile); |
| 115 } |
| 116 } |
| 117 |
| 118 // static |
| 119 void GpuVideoAcceleratorUtil::UniqueInsertEncodeProfiles( |
| 120 std::vector<media::VideoEncodeAccelerator::SupportedProfile>* |
| 121 media_profiles, |
| 122 const std::vector<media::VideoEncodeAccelerator::SupportedProfile>& |
| 123 new_profiles) { |
| 124 for (const auto& profile : new_profiles) { |
| 125 bool duplicate = false; |
| 126 for (const auto& media_profile : *media_profiles) { |
| 127 if (media_profile.profile == profile.profile) { |
| 128 duplicate = true; |
| 129 break; |
| 130 } |
| 131 } |
| 132 if (!duplicate) |
| 133 media_profiles->push_back(profile); |
| 134 } |
| 135 } |
| 136 |
| 137 } // namespace content |
OLD | NEW |