summaryrefslogtreecommitdiff
path: root/chromium/media/gpu/windows/d3d11_decoder_configurator.h
blob: beb99ecfb9701982c1e9d8ae0a655f21f1eb9cf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2020 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.

#ifndef MEDIA_GPU_WINDOWS_D3D11_DECODER_CONFIGURATOR_H_
#define MEDIA_GPU_WINDOWS_D3D11_DECODER_CONFIGURATOR_H_

#include <d3d11.h>
#include <wrl.h>
#include <memory>
#include <vector>

#include "media/base/status.h"
#include "media/gpu/media_gpu_export.h"
#include "media/gpu/windows/d3d11_picture_buffer.h"
#include "media/gpu/windows/d3d11_video_processor_proxy.h"
#include "ui/gfx/geometry/size.h"

namespace media {

class MediaLog;

// Stores different pixel formats and DGXI formats, and checks for decoder
// GUID support.  Generally provides a centralized place to figure out which
// decoder to use, and how its output texture should be configured.
class MEDIA_GPU_EXPORT D3D11DecoderConfigurator {
 public:
  D3D11DecoderConfigurator(DXGI_FORMAT decoder_output_dxgifmt,
                           GUID decoder_guid,
                           gfx::Size coded_size,
                           bool is_encrypted,
                           bool supports_swap_chain);
  virtual ~D3D11DecoderConfigurator() = default;

  static std::unique_ptr<D3D11DecoderConfigurator> Create(
      const gpu::GpuPreferences& gpu_preferences,
      const gpu::GpuDriverBugWorkarounds& workarounds,
      const VideoDecoderConfig& config,
      uint8_t bit_depth,
      MediaLog* media_log);

  bool SupportsDevice(ComD3D11VideoDevice video_device);

  // Create the decoder's output texture.
  StatusOr<ComD3D11Texture2D> CreateOutputTexture(ComD3D11Device device,
                                                  gfx::Size size,
                                                  uint32_t array_size);

  const D3D11_VIDEO_DECODER_DESC* DecoderDescriptor() const {
    return &decoder_desc_;
  }
  const GUID DecoderGuid() const { return decoder_guid_; }
  DXGI_FORMAT TextureFormat() const { return dxgi_format_; }

  static constexpr size_t BUFFER_COUNT = 20;

 private:
  // Set up instances of the parameter structs for D3D11 Functions
  void SetUpDecoderDescriptor(const gfx::Size& coded_size);
  void SetUpTextureDescriptor(bool supports_swap_chain, bool is_encrypted);

  D3D11_TEXTURE2D_DESC output_texture_desc_;
  D3D11_VIDEO_DECODER_DESC decoder_desc_;

  const DXGI_FORMAT dxgi_format_;
  const GUID decoder_guid_;
};

}  // namespace media

#endif  // MEDIA_GPU_WINDOWS_D3D11_DECODER_CONFIGURATOR_H_