| Index: content/common/gpu/media/gpu_video_accelerator_util.cc
|
| diff --git a/content/common/gpu/media/gpu_video_accelerator_util.cc b/content/common/gpu/media/gpu_video_accelerator_util.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7f7d78c309b5e31b32b10b7183ef71f601eab830
|
| --- /dev/null
|
| +++ b/content/common/gpu/media/gpu_video_accelerator_util.cc
|
| @@ -0,0 +1,137 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/common/gpu/media/gpu_video_accelerator_util.h"
|
| +
|
| +namespace content {
|
| +
|
| +// Make sure the enum values of media::VideoCodecProfile and
|
| +// gpu::VideoCodecProfile match.
|
| +#define STATIC_ASSERT_ENUM_MATCH(name) \
|
| + static_assert( \
|
| + media::name == static_cast<media::VideoCodecProfile>(gpu::name), \
|
| + #name " value must match in media and gpu.")
|
| +
|
| +STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_UNKNOWN);
|
| +STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_MIN);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_BASELINE);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_MAIN);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_EXTENDED);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH10PROFILE);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH422PROFILE);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_HIGH444PREDICTIVEPROFILE);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_SCALABLEBASELINE);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_SCALABLEHIGH);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_STEREOHIGH);
|
| +STATIC_ASSERT_ENUM_MATCH(H264PROFILE_MULTIVIEWHIGH);
|
| +STATIC_ASSERT_ENUM_MATCH(VP8PROFILE_ANY);
|
| +STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_ANY);
|
| +STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_MAX);
|
| +
|
| +// static
|
| +std::vector<media::VideoDecodeAccelerator::SupportedProfile>
|
| +GpuVideoAcceleratorUtil::ConvertGpuToMediaDecodeProfiles(const std::vector<
|
| + gpu::VideoDecodeAcceleratorSupportedProfile>& gpu_profiles) {
|
| + std::vector<media::VideoDecodeAccelerator::SupportedProfile> profiles;
|
| + for (const auto& gpu_profile : gpu_profiles) {
|
| + media::VideoDecodeAccelerator::SupportedProfile profile;
|
| + profile.profile =
|
| + static_cast<media::VideoCodecProfile>(gpu_profile.profile);
|
| + profile.max_resolution = gpu_profile.max_resolution;
|
| + profile.min_resolution = gpu_profile.min_resolution;
|
| + profiles.push_back(profile);
|
| + }
|
| + return profiles;
|
| +}
|
| +
|
| +// static
|
| +std::vector<gpu::VideoDecodeAcceleratorSupportedProfile>
|
| +GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeProfiles(const std::vector<
|
| + media::VideoDecodeAccelerator::SupportedProfile>& media_profiles) {
|
| + std::vector<gpu::VideoDecodeAcceleratorSupportedProfile> profiles;
|
| + for (const auto& media_profile : media_profiles) {
|
| + gpu::VideoDecodeAcceleratorSupportedProfile profile;
|
| + profile.profile =
|
| + static_cast<gpu::VideoCodecProfile>(media_profile.profile);
|
| + profile.max_resolution = media_profile.max_resolution;
|
| + profile.min_resolution = media_profile.min_resolution;
|
| + profiles.push_back(profile);
|
| + }
|
| + return profiles;
|
| +}
|
| +
|
| +// static
|
| +std::vector<media::VideoEncodeAccelerator::SupportedProfile>
|
| +GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles(const std::vector<
|
| + gpu::VideoEncodeAcceleratorSupportedProfile>& gpu_profiles) {
|
| + std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles;
|
| + for (const auto& gpu_profile : gpu_profiles) {
|
| + media::VideoEncodeAccelerator::SupportedProfile profile;
|
| + profile.profile =
|
| + static_cast<media::VideoCodecProfile>(gpu_profile.profile);
|
| + profile.max_resolution = gpu_profile.max_resolution;
|
| + profile.max_framerate_numerator = gpu_profile.max_framerate_numerator;
|
| + profile.max_framerate_denominator = gpu_profile.max_framerate_denominator;
|
| + profiles.push_back(profile);
|
| + }
|
| + return profiles;
|
| +}
|
| +
|
| +// static
|
| +std::vector<gpu::VideoEncodeAcceleratorSupportedProfile>
|
| +GpuVideoAcceleratorUtil::ConvertMediaToGpuEncodeProfiles(const std::vector<
|
| + media::VideoEncodeAccelerator::SupportedProfile>& media_profiles) {
|
| + std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> profiles;
|
| + for (const auto& media_profile : media_profiles) {
|
| + gpu::VideoEncodeAcceleratorSupportedProfile profile;
|
| + profile.profile =
|
| + static_cast<gpu::VideoCodecProfile>(media_profile.profile);
|
| + profile.max_resolution = media_profile.max_resolution;
|
| + profile.max_framerate_numerator = media_profile.max_framerate_numerator;
|
| + profile.max_framerate_denominator = media_profile.max_framerate_denominator;
|
| + profiles.push_back(profile);
|
| + }
|
| + return profiles;
|
| +}
|
| +
|
| +// static
|
| +void GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(
|
| + const std::vector<media::VideoDecodeAccelerator::SupportedProfile>&
|
| + new_profiles,
|
| + std::vector<media::VideoDecodeAccelerator::SupportedProfile>*
|
| + media_profiles) {
|
| + for (const auto& profile : new_profiles) {
|
| + bool duplicate = false;
|
| + for (const auto& media_profile : *media_profiles) {
|
| + if (media_profile.profile == profile.profile) {
|
| + duplicate = true;
|
| + break;
|
| + }
|
| + }
|
| + if (!duplicate)
|
| + media_profiles->push_back(profile);
|
| + }
|
| +}
|
| +
|
| +// static
|
| +void GpuVideoAcceleratorUtil::InsertUniqueEncodeProfiles(
|
| + const std::vector<media::VideoEncodeAccelerator::SupportedProfile>&
|
| + new_profiles,
|
| + std::vector<media::VideoEncodeAccelerator::SupportedProfile>*
|
| + media_profiles) {
|
| + for (const auto& profile : new_profiles) {
|
| + bool duplicate = false;
|
| + for (const auto& media_profile : *media_profiles) {
|
| + if (media_profile.profile == profile.profile) {
|
| + duplicate = true;
|
| + break;
|
| + }
|
| + }
|
| + if (!duplicate)
|
| + media_profiles->push_back(profile);
|
| + }
|
| +}
|
| +
|
| +} // namespace content
|
|
|