kodi
RendererDXVA.h
1 /*
2  * Copyright (C) 2017-2019 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 #pragma once
9 
10 #include "RendererHQ.h"
11 #include "VideoRenderers/HwDecRender/DXVAHD.h"
12 
13 #include <map>
14 
15 #include <d3d11_4.h>
16 
17 extern "C"
18 {
19 #include <libavutil/pixfmt.h>
20 }
21 
22 enum RenderMethod;
23 
24 class CRendererDXVA : public CRendererHQ
25 {
26  class CRenderBufferImpl;
27 public:
28  ~CRendererDXVA() = default;
29 
30  CRenderInfo GetRenderInfo() override;
31  bool Supports(ESCALINGMETHOD method) const override;
32  bool Supports(ERENDERFEATURE feature) const override;
33  bool WantsDoublePass() override { return true; }
34  bool Configure(const VideoPicture& picture, float fps, unsigned orientation) override;
35  bool NeedBuffer(int idx) override;
36 
37  static CRendererBase* Create(CVideoSettings& videoSettings);
38  static void GetWeight(std::map<RenderMethod, int>& weights, const VideoPicture& picture);
39  static DXGI_FORMAT GetDXGIFormat(AVPixelFormat format, DXGI_FORMAT default_fmt);
40 
41 protected:
42  explicit CRendererDXVA(CVideoSettings& videoSettings);
43 
44  void CheckVideoParameters() override;
45  void RenderImpl(CD3DTexture& target, CRect& sourceRect, CPoint(&destPoints)[4], uint32_t flags) override;
46  CRenderBuffer* CreateBuffer() override;
47  virtual std::string GetRenderMethodDebugInfo() const;
48 
49 private:
50  void FillBuffersSet(CRenderBuffer* (&buffers)[8]);
51  CRect ApplyTransforms(const CRect& destRect) const;
57  DXVA::ProcessorConversion ChooseConversion(const DXVA::ProcessorConversions& conversions) const;
58 
59  std::unique_ptr<DXVA::CProcessorHD> m_processor;
60  std::shared_ptr<DXVA::CEnumeratorHD> m_enumerator;
61  DXVA::ProcessorConversion m_conversion;
62  DXVA::SupportedConversionsArgs m_conversionsArgs;
63  bool m_tryVSR{false};
64 };
65 
67 {
68 public:
69  explicit CRenderBufferImpl(AVPixelFormat av_pix_format, unsigned width, unsigned height);
71 
72  bool UploadBuffer() override;
73  HRESULT GetResource(ID3D11Resource** ppResource, unsigned* index) const override;
74 
75  static DXGI_FORMAT GetDXGIFormat(AVPixelFormat format, DXGI_FORMAT default_fmt = DXGI_FORMAT_UNKNOWN);
76 
77 private:
78  bool UploadToTexture();
79 
80  CD3DTexture m_texture;
81 };
Definition: D3DResource.h:90
Definition: RendererDXVA.h:24
Definition: RendererBase.h:57
Definition: RenderInfo.h:19
Definition: RendererDXVA.h:66
Definition: DXVAEnumeratorHD.h:85
Definition: RendererHQ.h:12
Definition: DVDVideoCodec.h:36
Definition: DXVAEnumeratorHD.h:116
Definition: VideoSettings.h:194
Definition: RendererBase.h:111