Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DXVA2SurfaceAllocator.h « dxva2 « decoders « LAVVideo « decoder - github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1a3e1982c8c2c7f69d24d1002c563fbac4812eed (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
*      Copyright (C) 2010-2013 Hendrik Leppkes
*      http://www.1f0.de
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License along
*  with this program; if not, write to the Free Software Foundation, Inc.,
*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*  Initial Design and Concept taken from MPC-HC, licensed under GPLv2
*/

#pragma once

#include <Mfidl.h>

class CDecDXVA2;

interface __declspec(uuid("50A8A9A1-FF44-45C1-9DC2-79066ED1E576"))
ILAVDXVA2Sample :
public IUnknown {
  STDMETHOD_(int, GetDXSurfaceId()) = 0;
};

class CDXVA2Sample : public CMediaSample, public IMFGetService, public ILAVDXVA2Sample
{
  friend class CDXVA2SurfaceAllocator;

public:
  CDXVA2Sample(CDXVA2SurfaceAllocator *pAlloc, HRESULT *phr);
  virtual ~CDXVA2Sample();

  STDMETHODIMP          QueryInterface(REFIID riid, __deref_out void **ppv);
  STDMETHODIMP_(ULONG)  AddRef();
  STDMETHODIMP_(ULONG)  Release();

  // IMFGetService::GetService
  STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID *ppv);

  // ILAVDXVA2Sample
  STDMETHODIMP_(int) GetDXSurfaceId();

  // Override GetPointer because this class does not manage a system memory buffer.
  // The EVR uses the MR_BUFFER_SERVICE service to get the Direct3D surface.
  STDMETHODIMP GetPointer(BYTE ** ppBuffer);

private:

  // Sets the pointer to the Direct3D surface.
  void SetSurface(DWORD surfaceId, IDirect3DSurface9 *pSurf);

  IDirect3DSurface9 *m_pSurface   = nullptr;
  DWORD             m_dwSurfaceId = 0;
};

interface __declspec(uuid("23F80BD8-2654-4F74-B7CC-621868D0A850"))
ILAVDXVA2SurfaceAllocator :
public IUnknown {
  STDMETHOD_(void,DecoderDestruct)() = 0;
};

class CDXVA2SurfaceAllocator : public CBaseAllocator, public ILAVDXVA2SurfaceAllocator
{
public:
  CDXVA2SurfaceAllocator(CDecDXVA2 *m_pDXVA2Dec, HRESULT* phr);
  virtual ~CDXVA2SurfaceAllocator(void);

  DECLARE_IUNKNOWN;
  STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);

  HRESULT Alloc();
  void Free();
  STDMETHODIMP_(BOOL) DecommitInProgress() { CAutoLock cal(this); return m_bDecommitInProgress; }
  STDMETHODIMP_(BOOL) IsCommited() { CAutoLock cal(this); return m_bCommitted; }

  STDMETHODIMP_(void) DecoderDestruct() { m_pDec = nullptr; }

private:
  CDecDXVA2 *m_pDec = nullptr;

  IDirect3DSurface9 **m_ppRTSurfaceArray   = nullptr;
  UINT                m_nSurfaceArrayCount = 0;
};