Commit 6dd8cbfe authored by wuchengli's avatar wuchengli Committed by Commit bot

Duplicate VideoEncodeAccelerator::SupportedProfile in gpu_info.h.

gpu_info.h depended on media/video and media/ depended on gpu/.
gpu/ and media/ had a dependency cycle. Duplicate VEA::SupportedProfile
to gpu_info.h so gpu does not depend on media.

BUG=420801
TEST=Run apprtc loopback and ensure it uses HW encoder.

Review URL: https://codereview.chromium.org/668633002

Cr-Commit-Position: refs/heads/master@{#301048}
parent b9f5c40b
......@@ -74,7 +74,49 @@ GpuVideoEncodeAcceleratorHost::GetSupportedProfiles() {
DCHECK(CalledOnValidThread());
if (!channel_)
return std::vector<media::VideoEncodeAccelerator::SupportedProfile>();
return channel_->gpu_info().video_encode_accelerator_supported_profiles;
return ConvertGpuToMediaProfiles(
channel_->gpu_info().video_encode_accelerator_supported_profiles);
}
// 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);
std::vector<media::VideoEncodeAccelerator::SupportedProfile>
GpuVideoEncodeAcceleratorHost::ConvertGpuToMediaProfiles(const std::vector<
gpu::VideoEncodeAcceleratorSupportedProfile>& gpu_profiles) {
std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles;
for (size_t i = 0; i < gpu_profiles.size(); i++) {
media::VideoEncodeAccelerator::SupportedProfile profile;
profile.profile =
static_cast<media::VideoCodecProfile>(gpu_profiles[i].profile);
profile.max_resolution = gpu_profiles[i].max_resolution;
profile.max_framerate_numerator = gpu_profiles[i].max_framerate_numerator;
profile.max_framerate_denominator =
gpu_profiles[i].max_framerate_denominator;
profiles.push_back(profile);
}
return profiles;
}
bool GpuVideoEncodeAcceleratorHost::Initialize(
......
......@@ -12,6 +12,7 @@
#include "base/memory/weak_ptr.h"
#include "base/threading/non_thread_safe.h"
#include "content/common/gpu/client/command_buffer_proxy_impl.h"
#include "gpu/config/gpu_info.h"
#include "ipc/ipc_listener.h"
#include "media/video/video_encode_accelerator.h"
......@@ -44,6 +45,10 @@ class GpuVideoEncodeAcceleratorHost
GpuVideoEncodeAcceleratorHost(GpuChannelHost* channel,
CommandBufferProxyImpl* impl);
static std::vector<media::VideoEncodeAccelerator::SupportedProfile>
ConvertGpuToMediaProfiles(const std::vector<
gpu::VideoEncodeAcceleratorSupportedProfile>& gpu_profiles);
// IPC::Listener implementation.
bool OnMessageReceived(const IPC::Message& message) override;
void OnChannelError() override;
......
......@@ -64,6 +64,9 @@ IPC_ENUM_TRAITS_MIN_MAX_VALUE(media::VideoCodecProfile,
IPC_ENUM_TRAITS_MIN_MAX_VALUE(gpu::CollectInfoResult,
gpu::kCollectInfoNone,
gpu::kCollectInfoFatalFailure)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(gpu::VideoCodecProfile,
gpu::VIDEO_CODEC_PROFILE_MIN,
gpu::VIDEO_CODEC_PROFILE_MAX)
IPC_STRUCT_BEGIN(GPUCreateCommandBufferConfig)
IPC_STRUCT_MEMBER(int32, share_group_id)
......@@ -138,7 +141,7 @@ IPC_STRUCT_TRAITS_BEGIN(gpu::GPUInfo::GPUDevice)
IPC_STRUCT_TRAITS_MEMBER(device_string)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(media::VideoEncodeAccelerator::SupportedProfile)
IPC_STRUCT_TRAITS_BEGIN(gpu::VideoEncodeAcceleratorSupportedProfile)
IPC_STRUCT_TRAITS_MEMBER(profile)
IPC_STRUCT_TRAITS_MEMBER(max_resolution)
IPC_STRUCT_TRAITS_MEMBER(max_framerate_numerator)
......
......@@ -163,12 +163,29 @@ void GpuVideoEncodeAccelerator::OnWillDestroyStub() {
}
// static
std::vector<media::VideoEncodeAccelerator::SupportedProfile>
std::vector<gpu::VideoEncodeAcceleratorSupportedProfile>
GpuVideoEncodeAccelerator::GetSupportedProfiles() {
scoped_ptr<media::VideoEncodeAccelerator> encoder = CreateEncoder();
if (!encoder)
return std::vector<media::VideoEncodeAccelerator::SupportedProfile>();
return encoder->GetSupportedProfiles();
return std::vector<gpu::VideoEncodeAcceleratorSupportedProfile>();
return ConvertMediaToGpuProfiles(encoder->GetSupportedProfiles());
}
std::vector<gpu::VideoEncodeAcceleratorSupportedProfile>
GpuVideoEncodeAccelerator::ConvertMediaToGpuProfiles(const std::vector<
media::VideoEncodeAccelerator::SupportedProfile>& media_profiles) {
std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> profiles;
for (size_t i = 0; i < media_profiles.size(); i++) {
gpu::VideoEncodeAcceleratorSupportedProfile profile;
profile.profile =
static_cast<gpu::VideoCodecProfile>(media_profiles[i].profile);
profile.max_resolution = media_profiles[i].max_resolution;
profile.max_framerate_numerator = media_profiles[i].max_framerate_numerator;
profile.max_framerate_denominator =
media_profiles[i].max_framerate_denominator;
profiles.push_back(profile);
}
return profiles;
}
scoped_ptr<media::VideoEncodeAccelerator>
......
......@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "content/common/gpu/gpu_command_buffer_stub.h"
#include "gpu/config/gpu_info.h"
#include "ipc/ipc_listener.h"
#include "media/video/video_encode_accelerator.h"
#include "ui/gfx/size.h"
......@@ -58,8 +59,11 @@ class GpuVideoEncodeAccelerator
// Static query for supported profiles. This query calls the appropriate
// platform-specific version.
static std::vector<media::VideoEncodeAccelerator::SupportedProfile>
GetSupportedProfiles();
static std::vector<gpu::VideoEncodeAcceleratorSupportedProfile>
GetSupportedProfiles();
static std::vector<gpu::VideoEncodeAcceleratorSupportedProfile>
ConvertMediaToGpuProfiles(const std::vector<
media::VideoEncodeAccelerator::SupportedProfile>& media_profiles);
private:
// Create the appropriate platform-specific VEA.
......
......@@ -12,6 +12,7 @@
#include "content/common/gpu/client/context_provider_command_buffer.h"
#include "content/common/gpu/client/gl_helper.h"
#include "content/common/gpu/client/gpu_channel_host.h"
#include "content/common/gpu/client/gpu_video_encode_accelerator_host.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
#include "content/renderer/render_thread_impl.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
......@@ -248,8 +249,9 @@ RendererGpuVideoAcceleratorFactories::GetTaskRunner() {
std::vector<media::VideoEncodeAccelerator::SupportedProfile>
RendererGpuVideoAcceleratorFactories::
GetVideoEncodeAcceleratorSupportedProfiles() {
return gpu_channel_host_->gpu_info()
.video_encode_accelerator_supported_profiles;
return GpuVideoEncodeAcceleratorHost::ConvertGpuToMediaProfiles(
gpu_channel_host_->gpu_info()
.video_encode_accelerator_supported_profiles);
}
} // namespace content
include_rules = [
"+third_party/libxml", # For parsing WinSAT results files.
"+third_party/libXNVCtrl", # For NV driver version query.
"+media/video", # For VideoEncodeAccelerator::SupportedProfile.
]
......@@ -19,7 +19,7 @@ void EnumerateGPUDevice(gpu::GPUInfo::Enumerator* enumerator,
void EnumerateVideoEncodeAcceleratorSupportedProfile(
gpu::GPUInfo::Enumerator* enumerator,
const media::VideoEncodeAccelerator::SupportedProfile profile) {
const gpu::VideoEncodeAcceleratorSupportedProfile profile) {
enumerator->BeginVideoEncodeAcceleratorSupportedProfile();
enumerator->AddInt("profile", profile.profile);
enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width());
......@@ -101,7 +101,7 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
CollectInfoResult dx_diagnostics_info_state;
DxDiagNode dx_diagnostics;
#endif
std::vector<media::VideoEncodeAccelerator::SupportedProfile>
std::vector<VideoEncodeAcceleratorSupportedProfile>
video_encode_accelerator_supported_profiles;
};
......
......@@ -18,7 +18,7 @@
#include "gpu/config/dx_diag_node.h"
#include "gpu/config/gpu_performance_stats.h"
#include "gpu/gpu_export.h"
#include "media/video/video_encode_accelerator.h"
#include "ui/gfx/geometry/size.h"
namespace gpu {
......@@ -35,6 +35,34 @@ enum CollectInfoResult {
kCollectInfoFatalFailure = 3
};
// Video profile. This *must* match media::VideoCodecProfile.
enum VideoCodecProfile {
VIDEO_CODEC_PROFILE_UNKNOWN = -1,
VIDEO_CODEC_PROFILE_MIN = VIDEO_CODEC_PROFILE_UNKNOWN,
H264PROFILE_BASELINE = 0,
H264PROFILE_MAIN = 1,
H264PROFILE_EXTENDED = 2,
H264PROFILE_HIGH = 3,
H264PROFILE_HIGH10PROFILE = 4,
H264PROFILE_HIGH422PROFILE = 5,
H264PROFILE_HIGH444PREDICTIVEPROFILE = 6,
H264PROFILE_SCALABLEBASELINE = 7,
H264PROFILE_SCALABLEHIGH = 8,
H264PROFILE_STEREOHIGH = 9,
H264PROFILE_MULTIVIEWHIGH = 10,
VP8PROFILE_ANY = 11,
VP9PROFILE_ANY = 12,
VIDEO_CODEC_PROFILE_MAX = VP9PROFILE_ANY,
};
// Specification of an encoding profile supported by a hardware encoder.
struct GPU_EXPORT VideoEncodeAcceleratorSupportedProfile {
VideoCodecProfile profile;
gfx::Size max_resolution;
uint32 max_framerate_numerator;
uint32 max_framerate_denominator;
};
struct GPU_EXPORT GPUInfo {
struct GPU_EXPORT GPUDevice {
GPUDevice();
......@@ -178,7 +206,7 @@ struct GPU_EXPORT GPUInfo {
DxDiagNode dx_diagnostics;
#endif
std::vector<media::VideoEncodeAccelerator::SupportedProfile>
std::vector<VideoEncodeAcceleratorSupportedProfile>
video_encode_accelerator_supported_profiles;
// Note: when adding new members, please remember to update EnumerateFields
// in gpu_info.cc.
......@@ -204,7 +232,7 @@ struct GPU_EXPORT GPUInfo {
virtual void BeginGPUDevice() = 0;
virtual void EndGPUDevice() = 0;
// Markers indicating that a VideoEncodeAccelerator::SupportedProfile is
// Markers indicating that a VideoEncodeAcceleratorSupportedProfile is
// being described.
virtual void BeginVideoEncodeAcceleratorSupportedProfile() = 0;
virtual void EndVideoEncodeAcceleratorSupportedProfile() = 0;
......
......@@ -37,7 +37,8 @@ enum VideoCodec {
};
// Video stream profile. This *must* match PP_VideoDecoder_Profile.
// (enforced in webkit/plugins/ppapi/ppb_video_decoder_impl.cc)
// (enforced in webkit/plugins/ppapi/ppb_video_decoder_impl.cc) and
// gpu::VideoCodecProfile.
enum VideoCodecProfile {
// Keep the values in this enum unique, as they imply format (h.264 vs. VP8,
// for example), and keep the values for a particular format grouped
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment