Commit 3570facd authored by Rintaro Kuroiwa's avatar Rintaro Kuroiwa Committed by Commit Bot

Build D3D11VideoDecoder by default

- It keeps breaking and requires updating.
- So build it by default, the feature is still behind a runtime flag.
- GN files are cleaned up so that "mojo_media_host" is set with
  clearer logic.

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Ic78d4c949e0c8d57707f1d7f213c3b2fabd4b689
Reviewed-on: https://chromium-review.googlesource.com/959446
Commit-Queue: Rintaro Kuroiwa <rkuroiwa@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542840}
parent ff69e115
......@@ -16,7 +16,6 @@ buildflag_header("features") {
"USE_VAAPI=$use_vaapi",
"USE_V4L2_CODEC=$use_v4l2_codec",
"USE_LIBV4L2=$use_v4lplugin",
"ENABLE_D3D11_VIDEO_DECODER=$enable_d3d11_video_decoder",
]
}
......@@ -249,6 +248,14 @@ component("gpu") {
if (is_win) {
sources += [
"windows/d3d11_h264_accelerator.cc",
"windows/d3d11_h264_accelerator.h",
"windows/d3d11_picture_buffer.cc",
"windows/d3d11_picture_buffer.h",
"windows/d3d11_video_decoder.cc",
"windows/d3d11_video_decoder.h",
"windows/d3d11_video_decoder_impl.cc",
"windows/d3d11_video_decoder_impl.h",
"windows/dxva_picture_buffer_win.cc",
"windows/dxva_picture_buffer_win.h",
"windows/dxva_video_decode_accelerator_win.cc",
......@@ -284,18 +291,6 @@ component("gpu") {
"/DELAYLOAD:mf.dll",
"/DELAYLOAD:mfplat.dll",
]
if (enable_d3d11_video_decoder) {
sources += [
"windows/d3d11_h264_accelerator.cc",
"windows/d3d11_h264_accelerator.h",
"windows/d3d11_picture_buffer.cc",
"windows/d3d11_picture_buffer.h",
"windows/d3d11_video_decoder.cc",
"windows/d3d11_video_decoder.h",
"windows/d3d11_video_decoder_impl.cc",
"windows/d3d11_video_decoder_impl.h",
]
}
if (enable_library_cdms) {
sources += [
"windows/d3d11_cdm_proxy.cc",
......
......@@ -28,7 +28,7 @@ namespace media {
namespace {
static bool MakeContextCurrent(gpu::CommandBufferStub* stub) {
return stub && stub->decoder()->MakeCurrent();
return stub && stub->decoder_context()->MakeCurrent();
}
} // namespace
......@@ -100,8 +100,8 @@ bool D3D11PictureBuffer::GpuResources::Init(
// TODO(liberato): see GpuVideoFrameFactory.
// stub_->AddDestructionObserver(this);
auto decoder_helper = GLES2DecoderHelper::Create(stub->decoder());
gpu::gles2::ContextGroup* group = stub->decoder()->GetContextGroup();
auto decoder_helper = GLES2DecoderHelper::Create(stub->decoder_context());
gpu::gles2::ContextGroup* group = stub->decoder_context()->GetContextGroup();
gpu::MailboxManager* mailbox_manager = group->mailbox_manager();
gpu::gles2::TextureManager* texture_manager = group->texture_manager();
RETURN_ON_FAILURE(!!texture_manager, "No texture manager", false);
......
......@@ -73,8 +73,8 @@ void D3D11VideoDecoder::Initialize(
bool low_delay,
CdmContext* cdm_context,
const InitCB& init_cb,
const OutputCB& output_cb const
WaitingForDecryptionKeyCB& /* waiting_for_decryption_key_cb */) {
const OutputCB& output_cb,
const WaitingForDecryptionKeyCB& waiting_for_decryption_key_cb) {
bool is_h264 = config.profile() >= H264PROFILE_MIN &&
config.profile() <= H264PROFILE_MAX;
if (!is_h264) {
......@@ -90,7 +90,9 @@ void D3D11VideoDecoder::Initialize(
base::BindOnce(
&VideoDecoder::Initialize, impl_weak_, config, low_delay, cdm_context,
BindToCurrentThreadIfWeakPtr(weak_factory_.GetWeakPtr(), init_cb),
BindToCurrentThreadIfWeakPtr(weak_factory_.GetWeakPtr(), output_cb)));
BindToCurrentThreadIfWeakPtr(weak_factory_.GetWeakPtr(), output_cb),
BindToCurrentThreadIfWeakPtr(weak_factory_.GetWeakPtr(),
waiting_for_decryption_key_cb)));
}
void D3D11VideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
......
......@@ -22,7 +22,7 @@ namespace media {
namespace {
static bool MakeContextCurrent(gpu::CommandBufferStub* stub) {
return stub && stub->decoder()->MakeCurrent();
return stub && stub->decoder_context()->MakeCurrent();
}
} // namespace
......@@ -41,11 +41,13 @@ std::string D3D11VideoDecoderImpl::GetDisplayName() const {
return "D3D11VideoDecoderImpl";
}
void D3D11VideoDecoderImpl::Initialize(const VideoDecoderConfig& config,
bool low_delay,
CdmContext* cdm_context,
const InitCB& init_cb,
const OutputCB& output_cb) {
void D3D11VideoDecoderImpl::Initialize(
const VideoDecoderConfig& config,
bool low_delay,
CdmContext* cdm_context,
const InitCB& init_cb,
const OutputCB& output_cb,
const WaitingForDecryptionKeyCB& waiting_for_decryption_key_cb) {
init_cb_ = init_cb;
output_cb_ = output_cb;
......@@ -153,9 +155,9 @@ void D3D11VideoDecoderImpl::Initialize(const VideoDecoderConfig& config,
return;
}
h264_accelerator_.reset(new D3D11H264Accelerator(
this, video_decoder, video_device_, video_context_));
decoder_.reset(new media::H264Decoder(h264_accelerator_.get()));
accelerated_video_decoder_ =
std::make_unique<H264Decoder>(std::make_unique<D3D11H264Accelerator>(
this, video_decoder, video_device_, video_context_));
state_ = State::kRunning;
std::move(init_cb_).Run(true);
......@@ -192,7 +194,7 @@ void D3D11VideoDecoderImpl::DoDecode() {
if (current_buffer_->end_of_stream()) {
// Flush, then signal the decode cb once all pictures have been output.
current_buffer_ = nullptr;
if (!decoder_->Flush()) {
if (!accelerated_video_decoder_->Flush()) {
// This will also signal error |current_decode_cb_|.
NotifyError("Flush failed");
return;
......@@ -202,8 +204,8 @@ void D3D11VideoDecoderImpl::DoDecode() {
std::move(current_decode_cb_).Run(DecodeStatus::OK);
return;
}
decoder_->SetStream((const uint8_t*)current_buffer_->data(),
current_buffer_->data_size());
accelerated_video_decoder_->SetStream(
(const uint8_t*)current_buffer_->data(), current_buffer_->data_size());
}
while (true) {
......@@ -211,7 +213,8 @@ void D3D11VideoDecoderImpl::DoDecode() {
if (state_ == State::kError)
return;
media::AcceleratedVideoDecoder::DecodeResult result = decoder_->Decode();
media::AcceleratedVideoDecoder::DecodeResult result =
accelerated_video_decoder_->Decode();
// TODO(liberato): switch + class enum.
if (result == media::AcceleratedVideoDecoder::kRanOutOfStreamData) {
current_buffer_ = nullptr;
......@@ -248,7 +251,7 @@ void D3D11VideoDecoderImpl::Reset(const base::Closure& closure) {
input_buffer_queue_.clear();
// TODO(liberato): how do we signal an error?
decoder_->Reset();
accelerated_video_decoder_->Reset();
closure.Run();
}
......@@ -272,7 +275,7 @@ void D3D11VideoDecoderImpl::CreatePictureBuffers() {
// the VDA requests 20.
const int num_buffers = 20;
gfx::Size size = decoder_->GetPicSize();
gfx::Size size = accelerated_video_decoder_->GetPicSize();
// Create an array of |num_buffers| elements to back the PictureBuffers.
D3D11_TEXTURE2D_DESC texture_desc = {};
......
......@@ -33,11 +33,13 @@ class MEDIA_GPU_EXPORT D3D11VideoDecoderImpl : public VideoDecoder,
// VideoDecoder implementation:
std::string GetDisplayName() const override;
void Initialize(const VideoDecoderConfig& config,
bool low_delay,
CdmContext* cdm_context,
const InitCB& init_cb,
const OutputCB& output_cb) override;
void Initialize(
const VideoDecoderConfig& config,
bool low_delay,
CdmContext* cdm_context,
const InitCB& init_cb,
const OutputCB& output_cb,
const WaitingForDecryptionKeyCB& waiting_for_decryption_key_cb) override;
void Decode(const scoped_refptr<DecoderBuffer>& buffer,
const DecodeCB& decode_cb) override;
void Reset(const base::Closure& closure) override;
......@@ -82,8 +84,7 @@ class MEDIA_GPU_EXPORT D3D11VideoDecoderImpl : public VideoDecoder,
Microsoft::WRL::ComPtr<ID3D11VideoDevice> video_device_;
Microsoft::WRL::ComPtr<ID3D11VideoContext> video_context_;
std::unique_ptr<AcceleratedVideoDecoder> decoder_;
std::unique_ptr<D3D11H264Accelerator> h264_accelerator_;
std::unique_ptr<AcceleratedVideoDecoder> accelerated_video_decoder_;
GUID decoder_guid_;
......
......@@ -81,9 +81,6 @@ declare_args() {
# If true, use cast CMA backend instead of default chromium media pipeline.
is_cast_using_cma_backend = is_cast_audio_only || !is_android
# A temporary arg for enabling D3D11VideoDecoder
enable_d3d11_video_decoder = false
}
# enable_hls_sample_aes can only be true if enable_mse_mpeg2ts_stream_parser is.
......@@ -135,8 +132,8 @@ declare_args() {
# |mojo_media_services|). When enabled, selected mojo paths will be enabled in
# the media pipeline and corresponding services will hosted in the selected
# remote process (e.g. "utility" process, see |mojo_media_host|).
enable_mojo_media = is_android || is_chromecast || enable_library_cdms ||
enable_d3d11_video_decoder
enable_mojo_media =
is_android || is_chromecast || enable_library_cdms || is_win
# Enable the TestMojoMediaClient to be used in mojo MediaService. This is for
# testing only and will override the default platform MojoMediaClient, if any.
......@@ -203,41 +200,41 @@ declare_args() {
# - "gpu": Use mojo media service hosted in the gpu process.
# - "utility": Use mojo media service hosted in the utility process.
mojo_media_host = "none"
}
# Default mojo_media_services and mojo_media_host on various platforms.
# Can be overridden by gn build arguments from the --args command line flag
# for local testing.
if (enable_mojo_media) {
if (is_chromecast && is_cast_using_cma_backend) {
mojo_media_services = [
"cdm",
"renderer",
]
mojo_media_host = "browser"
} else if (is_android) {
# Both chrome for Android and cast for ATV belongs to this case
mojo_media_services = [
"cdm",
"audio_decoder",
]
mojo_media_services += [ "video_decoder" ]
mojo_media_host = "gpu"
} else if (enable_library_cdms) {
mojo_media_services = [ "cdm" ]
mojo_media_host = "gpu"
}
# Default mojo_media_services and mojo_media_host on various platforms.
# Can be overridden by gn build arguments from the --args command line flag
# for local testing.
if (enable_mojo_media) {
if (is_chromecast && is_cast_using_cma_backend) {
mojo_media_services = [
"cdm",
"renderer",
]
mojo_media_host = "browser"
} else if (is_android) {
# Both chrome for Android and cast for ATV belongs to this case
mojo_media_services = [
"cdm",
"audio_decoder",
"video_decoder",
]
mojo_media_host = "gpu"
} else if (is_win) {
mojo_media_services += [ "video_decoder" ]
mojo_media_host = "gpu"
}
if (is_win) {
if (enable_d3d11_video_decoder) {
mojo_media_services += [
"cdm",
"video_decoder",
]
if (enable_library_cdms) {
mojo_media_services += [ "cdm" ]
assert(
mojo_media_host == "none" || mojo_media_host == "gpu",
"For now, mojo_media_host should not overwrite it with a different " +
"value if it has been set.")
# TODO(liberato): This is temporary.
mojo_media_host = "gpu"
}
}
# Having a CDM running means it could require a CdmProxy running in the GPU
# process.
mojo_media_host = "gpu"
}
}
......
......@@ -31,9 +31,9 @@
#endif // defined(OS_ANDROID)
// OS_WIN guards are needed for cross-compiling on linux.
#if defined(OS_WIN) && BUILDFLAG(ENABLE_D3D11_VIDEO_DECODER)
#if defined(OS_WIN)
#include "media/gpu/windows/d3d11_video_decoder.h"
#endif // BUILDFLAG(ENABLE_D3D11_VIDEO_DECODER)
#endif // defined(OS_WIN)
namespace media {
......@@ -61,8 +61,7 @@ std::unique_ptr<MediaDrmStorage> CreateMediaDrmStorage(
}
#endif // defined(OS_ANDROID)
#if defined(OS_ANDROID) || \
(defined(OS_WIN) && BUILDFLAG(ENABLE_D3D11_VIDEO_DECODER))
#if defined(OS_ANDROID) || defined(OS_WIN)
gpu::CommandBufferStub* GetCommandBufferStub(
base::WeakPtr<MediaGpuChannelManager> media_gpu_channel_manager,
base::UnguessableToken channel_token,
......@@ -77,7 +76,7 @@ gpu::CommandBufferStub* GetCommandBufferStub(
return channel->LookupCommandBuffer(route_id);
}
#endif // OS_ANDROID || (OS_WIN && BUILDFLAG(ENABLE_D3D11_VIDEO_DECODER))
#endif // OS_ANDROID || OS_WIN
} // namespace
......@@ -123,7 +122,7 @@ std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder(
android_overlay_factory_cb_, std::move(request_overlay_info_cb),
std::make_unique<VideoFrameFactoryImpl>(gpu_task_runner_,
std::move(get_stub_cb)));
#elif defined(OS_WIN) && BUILDFLAG(ENABLE_D3D11_VIDEO_DECODER)
#elif defined(OS_WIN)
return std::make_unique<D3D11VideoDecoder>(
gpu_task_runner_,
base::BindRepeating(&GetCommandBufferStub, media_gpu_channel_manager_,
......
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