Commit a4bf8348 authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Commit Bot

media/gpu: Query supported video decoder config of V4L2SVD and VaapiVD.

Before starting decoding, MojoVD asks which configs are supported by
GPU. Currently we still get the config via VDA implementations even we
enable new VD.

This CL adds new method "GetSupportedVideoDecoderConfigs" at V4L2SVD
and VaapiVD, and query the supported configs from them.

BUG=chromium:952730
TEST=Check the supported video decoder configs are the same
     on Kevin(V4L2) and Eve(Vaapi)

Change-Id: I12ad2662e2c5462878d7f74f9541906946b5d9c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1672852
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Reviewed-by: default avatarDavid Staessens <dstaessens@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672782}
parent 1fffa013
...@@ -241,6 +241,7 @@ source_set("common") { ...@@ -241,6 +241,7 @@ source_set("common") {
"codec_picture.h", "codec_picture.h",
"format_utils.cc", "format_utils.cc",
"format_utils.h", "format_utils.h",
"gpu_video_decode_accelerator_helpers.cc",
"gpu_video_decode_accelerator_helpers.h", "gpu_video_decode_accelerator_helpers.h",
"gpu_video_encode_accelerator_helpers.cc", "gpu_video_encode_accelerator_helpers.cc",
"gpu_video_encode_accelerator_helpers.h", "gpu_video_encode_accelerator_helpers.h",
......
...@@ -49,6 +49,27 @@ std::unique_ptr<VideoDecoder> CreateChromeosVideoDecoder( ...@@ -49,6 +49,27 @@ std::unique_ptr<VideoDecoder> CreateChromeosVideoDecoder(
} // namespace } // namespace
// static
SupportedVideoDecoderConfigs
ChromeosVideoDecoderFactory::GetSupportedConfigs() {
SupportedVideoDecoderConfigs supported_configs;
SupportedVideoDecoderConfigs configs;
#if BUILDFLAG(USE_VAAPI)
configs = VaapiVideoDecoder::GetSupportedConfigs();
supported_configs.insert(supported_configs.end(), configs.begin(),
configs.end());
#endif // BUILDFLAG(USE_VAAPI)
#if BUILDFLAG(USE_V4L2_CODEC)
configs = V4L2SliceVideoDecoder::GetSupportedConfigs();
supported_configs.insert(supported_configs.end(), configs.begin(),
configs.end());
#endif // BUILDFLAG(USE_V4L2_CODEC)
return supported_configs;
}
// static // static
std::unique_ptr<VideoDecoder> ChromeosVideoDecoderFactory::Create( std::unique_ptr<VideoDecoder> ChromeosVideoDecoderFactory::Create(
scoped_refptr<base::SequencedTaskRunner> client_task_runner, scoped_refptr<base::SequencedTaskRunner> client_task_runner,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "media/gpu/media_gpu_export.h" #include "media/gpu/media_gpu_export.h"
#include "media/video/supported_video_decoder_config.h"
namespace base { namespace base {
class SequencedTaskRunner; class SequencedTaskRunner;
...@@ -27,6 +28,8 @@ class MEDIA_GPU_EXPORT ChromeosVideoDecoderFactory { ...@@ -27,6 +28,8 @@ class MEDIA_GPU_EXPORT ChromeosVideoDecoderFactory {
public: public:
using GetCommandBufferStubCB = base::OnceCallback<gpu::CommandBufferStub*()>; using GetCommandBufferStubCB = base::OnceCallback<gpu::CommandBufferStub*()>;
static SupportedVideoDecoderConfigs GetSupportedConfigs();
// Create VideoDecoder instance that does convert the output VideoFrame // Create VideoDecoder instance that does convert the output VideoFrame
// to mailbox-backed VideoFrame by CommandBufferHelper. // to mailbox-backed VideoFrame by CommandBufferHelper.
// We convert the frame by MailboxVideoFrameConverter. See the description for // We convert the frame by MailboxVideoFrameConverter. See the description for
......
// Copyright 2019 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 "media/gpu/gpu_video_decode_accelerator_helpers.h"
namespace media {
SupportedVideoDecoderConfigs ConvertFromSupportedProfiles(
const VideoDecodeAccelerator::SupportedProfiles& profiles,
bool allow_encrypted) {
SupportedVideoDecoderConfigs configs;
for (const auto& profile : profiles) {
configs.push_back(SupportedVideoDecoderConfig(
profile.profile, // profile_min
profile.profile, // profile_max
profile.min_resolution, // coded_size_min
profile.max_resolution, // coded_size_max
allow_encrypted, // allow_encrypted
profile.encrypted_only)); // require_encrypted);
}
return configs;
}
} // namespace media
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "media/gpu/media_gpu_export.h"
#include "media/video/supported_video_decoder_config.h"
#include "media/video/video_decode_accelerator.h"
namespace gl { namespace gl {
class GLContext; class GLContext;
...@@ -64,6 +67,12 @@ using CreateAbstractTextureCallback = ...@@ -64,6 +67,12 @@ using CreateAbstractTextureCallback =
unsigned /* GLenum */ format, unsigned /* GLenum */ format,
unsigned /* GLenum */ type)>; unsigned /* GLenum */ type)>;
// Convert vector of VDA::SupportedProfile to vector of
// SupportedVideoDecoderConfig.
MEDIA_GPU_EXPORT SupportedVideoDecoderConfigs ConvertFromSupportedProfiles(
const VideoDecodeAccelerator::SupportedProfiles& profiles,
bool allow_encrypted);
} // namespace media } // namespace media
#endif // MEDIA_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HELPERS_H_ #endif // MEDIA_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HELPERS_H_
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "media/base/scopedfd_helper.h" #include "media/base/scopedfd_helper.h"
#include "media/gpu/accelerated_video_decoder.h" #include "media/gpu/accelerated_video_decoder.h"
#include "media/gpu/chromeos/dmabuf_video_frame_pool.h" #include "media/gpu/chromeos/dmabuf_video_frame_pool.h"
#include "media/gpu/gpu_video_decode_accelerator_helpers.h"
#include "media/gpu/macros.h" #include "media/gpu/macros.h"
#include "media/gpu/v4l2/v4l2_h264_accelerator.h" #include "media/gpu/v4l2/v4l2_h264_accelerator.h"
#include "media/gpu/v4l2/v4l2_vp8_accelerator.h" #include "media/gpu/v4l2/v4l2_vp8_accelerator.h"
...@@ -33,6 +34,13 @@ constexpr size_t kInputBufferMaxSizeFor4k = 4 * kInputBufferMaxSizeFor1080p; ...@@ -33,6 +34,13 @@ constexpr size_t kInputBufferMaxSizeFor4k = 4 * kInputBufferMaxSizeFor1080p;
constexpr size_t kNumInputBuffers = 16; constexpr size_t kNumInputBuffers = 16;
constexpr size_t kNumInputPlanes = 1; constexpr size_t kNumInputPlanes = 1;
// Input format V4L2 fourccs this class supports.
constexpr uint32_t kSupportedInputFourccs[] = {
V4L2_PIX_FMT_H264_SLICE,
V4L2_PIX_FMT_VP8_FRAME,
V4L2_PIX_FMT_VP9_FRAME,
};
// Checks an underlying video frame buffer of |frame| is valid for VIDIOC_DQBUF // Checks an underlying video frame buffer of |frame| is valid for VIDIOC_DQBUF
// that requires |target_num_fds| fds. // that requires |target_num_fds| fds.
bool IsValidFrameForQueueDMABuf(const VideoFrame* frame, bool IsValidFrameForQueueDMABuf(const VideoFrame* frame,
...@@ -120,6 +128,18 @@ std::unique_ptr<VideoDecoder> V4L2SliceVideoDecoder::Create( ...@@ -120,6 +128,18 @@ std::unique_ptr<VideoDecoder> V4L2SliceVideoDecoder::Create(
std::move(frame_converter))); std::move(frame_converter)));
} }
// static
SupportedVideoDecoderConfigs V4L2SliceVideoDecoder::GetSupportedConfigs() {
scoped_refptr<V4L2Device> device = V4L2Device::Create();
if (!device)
return SupportedVideoDecoderConfigs();
return ConvertFromSupportedProfiles(
device->GetSupportedDecodeProfiles(base::size(kSupportedInputFourccs),
kSupportedInputFourccs),
false);
}
V4L2SliceVideoDecoder::V4L2SliceVideoDecoder( V4L2SliceVideoDecoder::V4L2SliceVideoDecoder(
scoped_refptr<base::SequencedTaskRunner> client_task_runner, scoped_refptr<base::SequencedTaskRunner> client_task_runner,
scoped_refptr<V4L2Device> device, scoped_refptr<V4L2Device> device,
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "media/gpu/media_gpu_export.h" #include "media/gpu/media_gpu_export.h"
#include "media/gpu/v4l2/v4l2_decode_surface_handler.h" #include "media/gpu/v4l2/v4l2_decode_surface_handler.h"
#include "media/gpu/v4l2/v4l2_device.h" #include "media/gpu/v4l2/v4l2_device.h"
#include "media/video/supported_video_decoder_config.h"
namespace media { namespace media {
...@@ -42,6 +43,8 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder, ...@@ -42,6 +43,8 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecoder : public VideoDecoder,
std::unique_ptr<DmabufVideoFramePool> frame_pool, std::unique_ptr<DmabufVideoFramePool> frame_pool,
std::unique_ptr<VideoFrameConverter> frame_converter); std::unique_ptr<VideoFrameConverter> frame_converter);
static SupportedVideoDecoderConfigs GetSupportedConfigs();
// VideoDecoder implementation. // VideoDecoder implementation.
std::string GetDisplayName() const override; std::string GetDisplayName() const override;
bool IsPlatformDecoder() const override; bool IsPlatformDecoder() const override;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "media/gpu/chromeos/dmabuf_video_frame_pool.h" #include "media/gpu/chromeos/dmabuf_video_frame_pool.h"
#include "media/gpu/chromeos/platform_video_frame_utils.h" #include "media/gpu/chromeos/platform_video_frame_utils.h"
#include "media/gpu/format_utils.h" #include "media/gpu/format_utils.h"
#include "media/gpu/gpu_video_decode_accelerator_helpers.h"
#include "media/gpu/macros.h" #include "media/gpu/macros.h"
#include "media/gpu/vaapi/va_surface.h" #include "media/gpu/vaapi/va_surface.h"
#include "media/gpu/vaapi/vaapi_h264_accelerator.h" #include "media/gpu/vaapi/vaapi_h264_accelerator.h"
...@@ -66,6 +67,12 @@ std::unique_ptr<VideoDecoder> VaapiVideoDecoder::Create( ...@@ -66,6 +67,12 @@ std::unique_ptr<VideoDecoder> VaapiVideoDecoder::Create(
std::move(frame_pool), std::move(frame_converter))); std::move(frame_pool), std::move(frame_converter)));
} }
// static
SupportedVideoDecoderConfigs VaapiVideoDecoder::GetSupportedConfigs() {
return ConvertFromSupportedProfiles(
VaapiWrapper::GetSupportedDecodeProfiles(), false);
}
VaapiVideoDecoder::VaapiVideoDecoder( VaapiVideoDecoder::VaapiVideoDecoder(
scoped_refptr<base::SequencedTaskRunner> client_task_runner, scoped_refptr<base::SequencedTaskRunner> client_task_runner,
std::unique_ptr<DmabufVideoFramePool> frame_pool, std::unique_ptr<DmabufVideoFramePool> frame_pool,
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "media/base/video_codecs.h" #include "media/base/video_codecs.h"
#include "media/base/video_decoder.h" #include "media/base/video_decoder.h"
#include "media/gpu/decode_surface_handler.h" #include "media/gpu/decode_surface_handler.h"
#include "media/video/supported_video_decoder_config.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
...@@ -44,6 +45,8 @@ class VaapiVideoDecoder : public media::VideoDecoder, ...@@ -44,6 +45,8 @@ class VaapiVideoDecoder : public media::VideoDecoder,
std::unique_ptr<DmabufVideoFramePool> frame_pool, std::unique_ptr<DmabufVideoFramePool> frame_pool,
std::unique_ptr<VideoFrameConverter> frame_converter); std::unique_ptr<VideoFrameConverter> frame_converter);
static SupportedVideoDecoderConfigs GetSupportedConfigs();
// media::VideoDecoder implementation. // media::VideoDecoder implementation.
std::string GetDisplayName() const override; std::string GetDisplayName() const override;
bool IsPlatformDecoder() const override; bool IsPlatformDecoder() const override;
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
#include "media/gpu/buildflags.h" #include "media/gpu/buildflags.h"
#include "media/gpu/gpu_video_accelerator_util.h" #include "media/gpu/gpu_video_accelerator_util.h"
#include "media/gpu/gpu_video_decode_accelerator_factory.h" #include "media/gpu/gpu_video_decode_accelerator_factory.h"
#include "media/gpu/gpu_video_decode_accelerator_helpers.h"
#include "media/gpu/ipc/service/media_gpu_channel_manager.h" #include "media/gpu/ipc/service/media_gpu_channel_manager.h"
#include "media/gpu/ipc/service/vda_video_decoder.h" #include "media/gpu/ipc/service/vda_video_decoder.h"
#include "media/mojo/interfaces/video_decoder.mojom.h" #include "media/mojo/interfaces/video_decoder.mojom.h"
#include "media/video/supported_video_decoder_config.h"
#include "media/video/video_decode_accelerator.h" #include "media/video/video_decode_accelerator.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -149,7 +149,18 @@ GpuMojoMediaClient::GetSupportedVideoDecoderConfigs() { ...@@ -149,7 +149,18 @@ GpuMojoMediaClient::GetSupportedVideoDecoderConfigs() {
} }
supported_config_map[VideoDecoderImplementation::kAlternate] = supported_config_map[VideoDecoderImplementation::kAlternate] =
*d3d11_supported_configs_; *d3d11_supported_configs_;
#endif
#elif defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled(kChromeosVideoDecoder)) {
if (!chromeos_supported_configs_) {
chromeos_supported_configs_ =
ChromeosVideoDecoderFactory::GetSupportedConfigs();
}
supported_config_map[VideoDecoderImplementation::kDefault] =
*chromeos_supported_configs_;
return supported_config_map;
}
#endif // defined(OS_WIN)
auto& default_configs = auto& default_configs =
supported_config_map[VideoDecoderImplementation::kDefault]; supported_config_map[VideoDecoderImplementation::kDefault];
...@@ -164,15 +175,10 @@ GpuMojoMediaClient::GetSupportedVideoDecoderConfigs() { ...@@ -164,15 +175,10 @@ GpuMojoMediaClient::GetSupportedVideoDecoderConfigs() {
bool allow_encrypted = bool allow_encrypted =
capabilities.flags & capabilities.flags &
VideoDecodeAccelerator::Capabilities::SUPPORTS_ENCRYPTED_STREAMS; VideoDecodeAccelerator::Capabilities::SUPPORTS_ENCRYPTED_STREAMS;
for (const auto& supported_profile : capabilities.supported_profiles) { SupportedVideoDecoderConfigs supported_configs = ConvertFromSupportedProfiles(
default_configs.push_back(SupportedVideoDecoderConfig( capabilities.supported_profiles, allow_encrypted);
supported_profile.profile, // profile_min default_configs.insert(default_configs.end(), supported_configs.begin(),
supported_profile.profile, // profile_max supported_configs.end());
supported_profile.min_resolution, // coded_size_min
supported_profile.max_resolution, // coded_size_max
allow_encrypted, // allow_encrypted
supported_profile.encrypted_only)); // require_encrypted
}
return supported_config_map; return supported_config_map;
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "media/base/android_overlay_mojo_factory.h" #include "media/base/android_overlay_mojo_factory.h"
#include "media/cdm/cdm_proxy.h" #include "media/cdm/cdm_proxy.h"
#include "media/mojo/services/mojo_media_client.h" #include "media/mojo/services/mojo_media_client.h"
#include "media/video/supported_video_decoder_config.h"
namespace media { namespace media {
...@@ -67,10 +68,13 @@ class GpuMojoMediaClient : public MojoMediaClient { ...@@ -67,10 +68,13 @@ class GpuMojoMediaClient : public MojoMediaClient {
AndroidOverlayMojoFactoryCB android_overlay_factory_cb_; AndroidOverlayMojoFactoryCB android_overlay_factory_cb_;
CdmProxyFactoryCB cdm_proxy_factory_cb_; CdmProxyFactoryCB cdm_proxy_factory_cb_;
#if defined(OS_WIN) #if defined(OS_WIN)
base::Optional<std::vector<SupportedVideoDecoderConfig>> base::Optional<SupportedVideoDecoderConfigs> d3d11_supported_configs_;
d3d11_supported_configs_;
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
#if defined(OS_CHROMEOS)
base::Optional<SupportedVideoDecoderConfigs> chromeos_supported_configs_;
#endif // defined(OS_CHROMEOS)
DISALLOW_COPY_AND_ASSIGN(GpuMojoMediaClient); DISALLOW_COPY_AND_ASSIGN(GpuMojoMediaClient);
}; };
......
...@@ -52,7 +52,7 @@ bool SupportedVideoDecoderConfig::Matches( ...@@ -52,7 +52,7 @@ bool SupportedVideoDecoderConfig::Matches(
// static // static
bool IsVideoDecoderConfigSupported( bool IsVideoDecoderConfigSupported(
const std::vector<SupportedVideoDecoderConfig>& supported_configs, const SupportedVideoDecoderConfigs& supported_configs,
const VideoDecoderConfig& config) { const VideoDecoderConfig& config) {
for (const auto& c : supported_configs) { for (const auto& c : supported_configs) {
if (c.Matches(config)) if (c.Matches(config))
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef MEDIA_VIDEO_SUPPORTED_VIDEO_DECODER_CONFIG_H_ #ifndef MEDIA_VIDEO_SUPPORTED_VIDEO_DECODER_CONFIG_H_
#define MEDIA_VIDEO_SUPPORTED_VIDEO_DECODER_CONFIG_H_ #define MEDIA_VIDEO_SUPPORTED_VIDEO_DECODER_CONFIG_H_
#include <vector>
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/macros.h" #include "base/macros.h"
#include "media/base/media_export.h" #include "media/base/media_export.h"
...@@ -57,15 +59,16 @@ enum class VideoDecoderImplementation { ...@@ -57,15 +59,16 @@ enum class VideoDecoderImplementation {
kMaxValue = kAlternate kMaxValue = kAlternate
}; };
using SupportedVideoDecoderConfigs = std::vector<SupportedVideoDecoderConfig>;
// Map of mojo VideoDecoder implementations to the vector of configs that they // Map of mojo VideoDecoder implementations to the vector of configs that they
// (probably) support. // (probably) support.
using SupportedVideoDecoderConfigMap = using SupportedVideoDecoderConfigMap =
base::flat_map<VideoDecoderImplementation, base::flat_map<VideoDecoderImplementation, SupportedVideoDecoderConfigs>;
std::vector<SupportedVideoDecoderConfig>>;
// Helper method to determine if |config| is supported by |supported_configs|. // Helper method to determine if |config| is supported by |supported_configs|.
MEDIA_EXPORT bool IsVideoDecoderConfigSupported( MEDIA_EXPORT bool IsVideoDecoderConfigSupported(
const std::vector<SupportedVideoDecoderConfig>& supported_configs, const SupportedVideoDecoderConfigs& supported_configs,
const VideoDecoderConfig& config); const VideoDecoderConfig& config);
} // namespace media } // namespace media
......
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