File: mfx_h264_encode_interface.h

package info (click to toggle)
intel-mediasdk 22.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 86,508 kB
  • sloc: cpp: 1,055,709; ansic: 25,847; asm: 17,754; python: 8,951; cs: 965; sh: 543; makefile: 528; lisp: 52
file content (181 lines) | stat: -rw-r--r-- 4,877 bytes parent folder | download | duplicates (2)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// Copyright (c) 2018-2019 Intel Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include "mfx_common.h"

#if defined (MFX_ENABLE_H264_VIDEO_ENCODE_HW)

#ifndef __MFX_H264_ENCODE_INTERFACE__H
#define __MFX_H264_ENCODE_INTERFACE__H

#include <vector>
#include <assert.h>
#include "mfxdefs.h"
#include "mfxvideo++int.h"

#include "mfx_h264_enc_common_hw.h"

// structures will be abstracted (ENCODE_CAPS, D3DDDIFORMAT)
#if defined(MFX_VA_LINUX)
    #include "mfx_h264_encode_struct_vaapi.h"
#endif

#ifdef MFX_ENABLE_MFE
#include "mfx_mfe_adapter.h"
#endif

namespace MfxHwH264Encode
{
    class PreAllocatedVector
    {
    public:
        PreAllocatedVector()
            : m_size(0)
        {
        }

        void Alloc(mfxU32 capacity)
        {
            m_storage.resize(capacity);
            m_size = 0;
        }

        void SetSize(mfxU32 size)
        {
            assert(size <= m_storage.size());
            m_size = size;
        }

        mfxU32 Size() const
        {
            return m_size;
        }

        mfxU32 Capacity() const
        {
            return (mfxU32)m_storage.size();
        }

        mfxU8 * Buffer()
        {
            assert(m_storage.size() > 0);
            return &m_storage[0];
        }

        mfxU8 const * Buffer() const
        {
            assert(m_storage.size() > 0);
            return &m_storage[0];
        }

    private:
        std::vector<mfxU8>  m_storage;
        mfxU32              m_size;
    };


    class DriverEncoder
    {
    public:

        virtual ~DriverEncoder(){}

        virtual
        mfxStatus CreateAuxilliaryDevice(
            VideoCORE * core,
            GUID        guid,
            mfxU32      width,
            mfxU32      height,
            bool        isTemporal = false) = 0;

        virtual
        mfxStatus CreateAccelerationService(
            MfxVideoParam const & par) = 0;

        virtual
        mfxStatus Reset(
            MfxVideoParam const & par) = 0;

        virtual 
        mfxStatus Register(
            mfxFrameAllocResponse & response,
            D3DDDIFORMAT            type) = 0;

        virtual 
        mfxStatus Execute(
            mfxHDLPair                 pair,
            DdiTask const &            task,
            mfxU32                     fieldId,
            PreAllocatedVector const & sei) = 0;

        virtual
        mfxStatus QueryCompBufferInfo(
            D3DDDIFORMAT           type,
            mfxFrameAllocRequest & request) = 0;

        virtual
        mfxStatus QueryEncodeCaps(
            MFX_ENCODE_CAPS & caps) = 0;

        virtual
        mfxStatus QueryMbPerSec(
            mfxVideoParam const & par,
            mfxU32              (&mbPerSec)[16]) = 0;

        virtual
        mfxStatus QueryStatus(
            DdiTask & task,
            mfxU32    fieldId) = 0;

        virtual
        mfxStatus Destroy() = 0;

        virtual
        void ForceCodingFunction (mfxU16 codingFunction) = 0;

        virtual
        mfxStatus QueryHWGUID(
            VideoCORE * core,
            GUID        guid,
            bool        isTemporal) = 0;

        virtual
        mfxStatus QueryEncCtrlCaps(
            ENCODE_ENC_CTRL_CAPS & /*caps*/) { return MFX_ERR_UNSUPPORTED; };

        virtual
        mfxStatus GetEncCtrlCaps(
            ENCODE_ENC_CTRL_CAPS & /*caps*/) { return MFX_ERR_UNSUPPORTED; };

        virtual
        mfxStatus SetEncCtrlCaps(
            ENCODE_ENC_CTRL_CAPS const & /*caps*/) { return MFX_ERR_UNSUPPORTED; };
    };

    DriverEncoder* CreatePlatformH264Encoder( VideoCORE* core ); 

#if defined(MFX_ENABLE_MFE)
    MFEVAAPIEncoder* CreatePlatformMFEEncoder( VideoCORE* core );
#endif

}; // namespace

#endif // __MFX_H264_ENCODE_INTERFACE__H
#endif // #if defined (MFX_ENABLE_H264_VIDEO_ENCODE_HW) && defined(MFX_VA_WIN)