File: d3d_allocator.h

package info (click to toggle)
libvpl-tools 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,652 kB
  • sloc: cpp: 107,469; python: 4,303; ansic: 3,202; sh: 159; lisp: 52; makefile: 13
file content (72 lines) | stat: -rw-r--r-- 2,328 bytes parent folder | download | duplicates (3)
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
/*############################################################################
  # Copyright (C) 2005 Intel Corporation
  #
  # SPDX-License-Identifier: MIT
  ############################################################################*/

#ifndef __D3D_ALLOCATOR_H__
#define __D3D_ALLOCATOR_H__

#if defined(_WIN32) || defined(_WIN64)

    #include <atlbase.h>
    #include <d3d9.h>
    #include <dxva2api.h>
    #include <vector>
    #include "base_allocator.h"

enum eTypeHandle { DXVA2_PROCESSOR = 0x00, DXVA2_DECODER = 0x01 };

struct D3DAllocatorParams : mfxAllocatorParams {
    IDirect3DDeviceManager9* pManager;
    DWORD surfaceUsage;

    D3DAllocatorParams() : pManager(), surfaceUsage() {}
};

class D3DFrameAllocator : public BaseFrameAllocator {
public:
    D3DFrameAllocator();
    virtual ~D3DFrameAllocator();

    virtual mfxStatus Init(mfxAllocatorParams* pParams);
    virtual mfxStatus Close();

    virtual IDirect3DDeviceManager9* GetDeviceManager() {
        return m_manager;
    };

    virtual mfxStatus LockFrame(mfxMemId mid, mfxFrameData* ptr);
    virtual mfxStatus UnlockFrame(mfxMemId mid, mfxFrameData* ptr);
    virtual mfxStatus GetFrameHDL(mfxMemId mid, mfxHDL* handle);

    virtual mfxStatus Create3DLutMemory(mfxMemId memId, mfxU8* lut3d, mfxU32 lut3d_size) {
        return MFX_ERR_NONE;
    }
    virtual mfxStatus Release3DLutMemory(mfxMemId memId) {
        return MFX_ERR_NONE;
    }

protected:
    virtual mfxStatus CheckRequestType(mfxFrameAllocRequest* request);
    virtual mfxStatus ReleaseResponse(mfxFrameAllocResponse* response);
    virtual mfxStatus AllocImpl(mfxFrameAllocRequest* request, mfxFrameAllocResponse* response);
    virtual mfxStatus ReallocImpl(mfxMemId midIn,
                                  const mfxFrameInfo* info,
                                  mfxU16 memType,
                                  mfxMemId* midOut);

    void DeallocateMids(mfxHDLPair** pairs, int n);

    std::vector<mfxHDLPair**> m_midsAllocated;

    CComPtr<IDirect3DDeviceManager9> m_manager;
    CComPtr<IDirectXVideoDecoderService> m_decoderService;
    CComPtr<IDirectXVideoProcessorService> m_processorService;
    HANDLE m_hDecoder;
    HANDLE m_hProcessor;
    DWORD m_surfaceUsage;
};

#endif // #if defined( _WIN32 ) || defined ( _WIN64 )
#endif // __D3D_ALLOCATOR_H__