| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
#ifndef __MFXVIDEOPLUSPLUS_H |
| 8 |
#define __MFXVIDEOPLUSPLUS_H |
| 9 |
|
| 10 |
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD |
| 11 |
#include "vpl/mfx.h" |
| 12 |
#define MFX_IMPL_ACCELMODE(x) (0xff00 & (x)) |
| 13 |
#else |
| 14 |
#include "mfxvideo.h" |
| 15 |
#endif |
| 16 |
|
| 17 |
class MFXVideoSessionBase { |
| 18 |
public: |
| 19 |
virtual ~MFXVideoSessionBase() {} |
| 20 |
|
| 21 |
virtual mfxStatus Init(mfxIMPL impl, mfxVersion* ver) = 0; |
| 22 |
virtual mfxStatus InitEx(mfxInitParam par) = 0; |
| 23 |
virtual mfxStatus Close(void) = 0; |
| 24 |
|
| 25 |
virtual mfxStatus QueryIMPL(mfxIMPL* impl) = 0; |
| 26 |
virtual mfxStatus QueryVersion(mfxVersion* version) = 0; |
| 27 |
|
| 28 |
virtual mfxStatus JoinSession(mfxSession child_session) = 0; |
| 29 |
virtual mfxStatus DisjoinSession() = 0; |
| 30 |
virtual mfxStatus CloneSession(mfxSession* clone) = 0; |
| 31 |
virtual mfxStatus SetPriority(mfxPriority priority) = 0; |
| 32 |
virtual mfxStatus GetPriority(mfxPriority* priority) = 0; |
| 33 |
|
| 34 |
virtual mfxStatus SetFrameAllocator(mfxFrameAllocator* allocator) = 0; |
| 35 |
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) = 0; |
| 36 |
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL* hdl) = 0; |
| 37 |
virtual mfxStatus QueryPlatform(mfxPlatform* platform) = 0; |
| 38 |
|
| 39 |
virtual mfxStatus SyncOperation(mfxSyncPoint syncp, mfxU32 wait) = 0; |
| 40 |
|
| 41 |
virtual mfxStatus GetSurfaceForEncode(mfxFrameSurface1** output_surf) = 0; |
| 42 |
virtual mfxStatus GetSurfaceForDecode(mfxFrameSurface1** output_surf) = 0; |
| 43 |
virtual mfxStatus GetSurfaceForVPP(mfxFrameSurface1** output_surf) = 0; |
| 44 |
virtual mfxStatus GetSurfaceForVPPOut(mfxFrameSurface1** output_surf) = 0; |
| 45 |
|
| 46 |
virtual operator mfxSession(void) = 0; |
| 47 |
}; |
| 48 |
|
| 49 |
class MFXVideoENCODEBase { |
| 50 |
public: |
| 51 |
virtual ~MFXVideoENCODEBase() {} |
| 52 |
|
| 53 |
virtual mfxStatus Query(mfxVideoParam* in, mfxVideoParam* out) = 0; |
| 54 |
virtual mfxStatus QueryIOSurf(mfxVideoParam* par, mfxFrameAllocRequest* request) = 0; |
| 55 |
virtual mfxStatus Init(mfxVideoParam* par) = 0; |
| 56 |
virtual mfxStatus Reset(mfxVideoParam* par) = 0; |
| 57 |
virtual mfxStatus Close(void) = 0; |
| 58 |
|
| 59 |
virtual mfxStatus GetVideoParam(mfxVideoParam* par) = 0; |
| 60 |
virtual mfxStatus GetEncodeStat(mfxEncodeStat* stat) = 0; |
| 61 |
|
| 62 |
virtual mfxStatus EncodeFrameAsync(mfxEncodeCtrl* ctrl, |
| 63 |
mfxFrameSurface1* surface, |
| 64 |
mfxBitstream* bs, |
| 65 |
mfxSyncPoint* syncp) = 0; |
| 66 |
|
| 67 |
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) = 0; |
| 68 |
}; |
| 69 |
|
| 70 |
class MFXVideoDECODEBase { |
| 71 |
public: |
| 72 |
virtual ~MFXVideoDECODEBase() {} |
| 73 |
|
| 74 |
virtual mfxStatus Query(mfxVideoParam* in, mfxVideoParam* out) = 0; |
| 75 |
virtual mfxStatus DecodeHeader(mfxBitstream* bs, mfxVideoParam* par) = 0; |
| 76 |
virtual mfxStatus QueryIOSurf(mfxVideoParam* par, mfxFrameAllocRequest* request) = 0; |
| 77 |
virtual mfxStatus Init(mfxVideoParam* par) = 0; |
| 78 |
virtual mfxStatus Reset(mfxVideoParam* par) = 0; |
| 79 |
virtual mfxStatus Close(void) = 0; |
| 80 |
|
| 81 |
virtual mfxStatus GetVideoParam(mfxVideoParam* par) = 0; |
| 82 |
|
| 83 |
virtual mfxStatus GetDecodeStat(mfxDecodeStat* stat) = 0; |
| 84 |
virtual mfxStatus GetPayload(mfxU64* ts, mfxPayload* payload) = 0; |
| 85 |
virtual mfxStatus SetSkipMode(mfxSkipMode mode) = 0; |
| 86 |
virtual mfxStatus DecodeFrameAsync(mfxBitstream* bs, |
| 87 |
mfxFrameSurface1* surface_work, |
| 88 |
mfxFrameSurface1** surface_out, |
| 89 |
mfxSyncPoint* syncp) = 0; |
| 90 |
|
| 91 |
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) = 0; |
| 92 |
}; |
| 93 |
|
| 94 |
class MFXVideoVPPBase { |
| 95 |
public: |
| 96 |
virtual ~MFXVideoVPPBase() {} |
| 97 |
|
| 98 |
virtual mfxStatus Query(mfxVideoParam* in, mfxVideoParam* out) = 0; |
| 99 |
virtual mfxStatus QueryIOSurf(mfxVideoParam* par, mfxFrameAllocRequest request[2]) = 0; |
| 100 |
virtual mfxStatus Init(mfxVideoParam* par) = 0; |
| 101 |
virtual mfxStatus Reset(mfxVideoParam* par) = 0; |
| 102 |
virtual mfxStatus Close(void) = 0; |
| 103 |
|
| 104 |
virtual mfxStatus GetVideoParam(mfxVideoParam* par) = 0; |
| 105 |
virtual mfxStatus GetVPPStat(mfxVPPStat* stat) = 0; |
| 106 |
virtual mfxStatus RunFrameVPPAsync(mfxFrameSurface1* in, |
| 107 |
mfxFrameSurface1* out, |
| 108 |
mfxExtVppAuxData* aux, |
| 109 |
mfxSyncPoint* syncp) = 0; |
| 110 |
|
| 111 |
virtual mfxStatus GetSurfaceIn(mfxFrameSurface1** output_surf) = 0; |
| 112 |
virtual mfxStatus GetSurfaceOut(mfxFrameSurface1** output_surf) = 0; |
| 113 |
virtual mfxStatus ProcessFrameAsync(mfxFrameSurface1* in, mfxFrameSurface1** out) = 0; |
| 114 |
}; |
| 115 |
|
| 116 |
class MFXVideoSession : public MFXVideoSessionBase { |
| 117 |
public: |
| 118 |
MFXVideoSession(void) { |
| 119 |
m_session = (mfxSession)0; |
| 120 |
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD |
| 121 |
m_loader = (mfxLoader)0; |
| 122 |
#endif |
| 123 |
} |
| 124 |
virtual ~MFXVideoSession(void) { |
| 125 |
Close(); |
| 126 |
} |
| 127 |
|
| 128 |
virtual mfxStatus Init(mfxIMPL impl, mfxVersion *ver) override { |
| 129 |
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD |
| 130 |
mfxInitParam par = {}; |
| 131 |
par.Implementation = impl; |
| 132 |
par.Version = *ver; |
| 133 |
return InitSession(par); |
| 134 |
#else |
| 135 |
return MFXInit(impl, ver, &m_session); |
| 136 |
#endif |
| 137 |
} |
| 138 |
virtual mfxStatus InitEx(mfxInitParam par) override { |
| 139 |
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD |
| 140 |
return InitSession(par); |
| 141 |
#else |
| 142 |
return MFXInitEx(par, &m_session); |
| 143 |
#endif |
| 144 |
} |
| 145 |
virtual mfxStatus Close(void) override { |
| 146 |
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD |
| 147 |
if (m_session) { |
| 148 |
mfxStatus mfxRes; |
| 149 |
mfxRes = MFXClose(m_session); |
| 150 |
m_session = (mfxSession)0; |
| 151 |
if (m_loader) { |
| 152 |
MFXUnload(m_loader); |
| 153 |
m_loader = (mfxLoader)0; |
| 154 |
} |
| 155 |
return mfxRes; |
| 156 |
} |
| 157 |
else { |
| 158 |
return MFX_ERR_NONE; |
| 159 |
} |
| 160 |
#else |
| 161 |
mfxStatus mfxRes; |
| 162 |
mfxRes = MFXClose(m_session); |
| 163 |
m_session = (mfxSession)0; |
| 164 |
return mfxRes; |
| 165 |
#endif |
| 166 |
} |
| 167 |
|
| 168 |
virtual mfxStatus QueryIMPL(mfxIMPL *impl) override { |
| 169 |
return MFXQueryIMPL(m_session, impl); |
| 170 |
} |
| 171 |
virtual mfxStatus QueryVersion(mfxVersion *version) override { |
| 172 |
return MFXQueryVersion(m_session, version); |
| 173 |
} |
| 174 |
|
| 175 |
virtual mfxStatus JoinSession(mfxSession child_session) override { |
| 176 |
return MFXJoinSession(m_session, child_session); |
| 177 |
} |
| 178 |
virtual mfxStatus DisjoinSession() override { |
| 179 |
return MFXDisjoinSession(m_session); |
| 180 |
} |
| 181 |
virtual mfxStatus CloneSession(mfxSession *clone) override { |
| 182 |
return MFXCloneSession(m_session, clone); |
| 183 |
} |
| 184 |
virtual mfxStatus SetPriority(mfxPriority priority) override { |
| 185 |
return MFXSetPriority(m_session, priority); |
| 186 |
} |
| 187 |
virtual mfxStatus GetPriority(mfxPriority *priority) override { |
| 188 |
return MFXGetPriority(m_session, priority); |
| 189 |
} |
| 190 |
|
| 191 |
virtual mfxStatus SetFrameAllocator(mfxFrameAllocator *allocator) override { |
| 192 |
return MFXVideoCORE_SetFrameAllocator(m_session, allocator); |
| 193 |
} |
| 194 |
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) override { |
| 195 |
return MFXVideoCORE_SetHandle(m_session, type, hdl); |
| 196 |
} |
| 197 |
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *hdl) override { |
| 198 |
return MFXVideoCORE_GetHandle(m_session, type, hdl); |
| 199 |
} |
| 200 |
virtual mfxStatus QueryPlatform(mfxPlatform *platform) override { |
| 201 |
return MFXVideoCORE_QueryPlatform(m_session, platform); |
| 202 |
} |
| 203 |
|
| 204 |
virtual mfxStatus SyncOperation(mfxSyncPoint syncp, mfxU32 wait) override { |
| 205 |
return MFXVideoCORE_SyncOperation(m_session, syncp, wait); |
| 206 |
} |
| 207 |
|
| 208 |
virtual mfxStatus GetSurfaceForEncode(mfxFrameSurface1** output_surf) override { |
| 209 |
return MFXMemory_GetSurfaceForEncode(m_session, output_surf); |
| 210 |
} |
| 211 |
virtual mfxStatus GetSurfaceForDecode(mfxFrameSurface1** output_surf) override { |
| 212 |
return MFXMemory_GetSurfaceForDecode(m_session, output_surf); |
| 213 |
} |
| 214 |
virtual mfxStatus GetSurfaceForVPP (mfxFrameSurface1** output_surf) override { |
| 215 |
return MFXMemory_GetSurfaceForVPP (m_session, output_surf); |
| 216 |
} |
| 217 |
virtual mfxStatus GetSurfaceForVPPOut(mfxFrameSurface1** output_surf) override { |
| 218 |
return MFXMemory_GetSurfaceForVPPOut(m_session, output_surf); |
| 219 |
} |
| 220 |
|
| 221 |
virtual operator mfxSession(void) override { |
| 222 |
return m_session; |
| 223 |
} |
| 224 |
|
| 225 |
protected: |
| 226 |
mfxSession m_session; |
| 227 |
|
| 228 |
#ifdef MFXVIDEO_CPP_ENABLE_MFXLOAD |
| 229 |
mfxLoader m_loader; |
| 230 |
|
| 231 |
inline void InitVariant(mfxVariant *var, mfxU32 data) { |
| 232 |
var->Version.Version = (mfxU16)MFX_VARIANT_VERSION; |
| 233 |
var->Type = MFX_VARIANT_TYPE_U32; |
| 234 |
var->Data.U32 = data; |
| 235 |
} |
| 236 |
|
| 237 |
inline void InitVariant(mfxVariant *var, mfxU16 data) { |
| 238 |
var->Version.Version = (mfxU16)MFX_VARIANT_VERSION; |
| 239 |
var->Type = MFX_VARIANT_TYPE_U16; |
| 240 |
var->Data.U16 = data; |
| 241 |
} |
| 242 |
|
| 243 |
inline void InitVariant(mfxVariant *var, mfxHDL data) { |
| 244 |
var->Version.Version = (mfxU16)MFX_VARIANT_VERSION; |
| 245 |
var->Type = MFX_VARIANT_TYPE_PTR; |
| 246 |
var->Data.Ptr = data; |
| 247 |
} |
| 248 |
|
| 249 |
template <typename varDataType> |
| 250 |
mfxStatus CreateConfig(varDataType data, const char *propertyName) { |
| 251 |
mfxConfig cfg = MFXCreateConfig(m_loader); |
| 252 |
if (cfg == nullptr) |
| 253 |
return MFX_ERR_NULL_PTR; |
| 254 |
|
| 255 |
mfxVariant variant; |
| 256 |
InitVariant(&variant, data); |
| 257 |
|
| 258 |
return MFXSetConfigFilterProperty(cfg, (mfxU8 *)propertyName, variant); |
| 259 |
} |
| 260 |
|
| 261 |
mfxStatus InitSession(mfxInitParam par) { |
| 262 |
|
| 263 |
if (m_session) |
| 264 |
return MFX_ERR_NONE; |
| 265 |
|
| 266 |
m_loader = MFXLoad(); |
| 267 |
if (!m_loader) |
| 268 |
return MFX_ERR_NOT_FOUND; |
| 269 |
|
| 270 |
mfxStatus mfxRes = MFX_ERR_NONE; |
| 271 |
|
| 272 |
mfxU32 implBaseType = MFX_IMPL_BASETYPE(par.Implementation); |
| 273 |
|
| 274 |
|
| 275 |
switch (implBaseType) { |
| 276 |
case MFX_IMPL_AUTO: |
| 277 |
case MFX_IMPL_AUTO_ANY: |
| 278 |
break; |
| 279 |
|
| 280 |
case MFX_IMPL_SOFTWARE: |
| 281 |
mfxRes = CreateConfig<mfxU32>(MFX_IMPL_TYPE_SOFTWARE, "mfxImplDescription.Impl"); |
| 282 |
break; |
| 283 |
|
| 284 |
case MFX_IMPL_HARDWARE: |
| 285 |
case MFX_IMPL_HARDWARE_ANY: |
| 286 |
case MFX_IMPL_HARDWARE2: |
| 287 |
case MFX_IMPL_HARDWARE3: |
| 288 |
case MFX_IMPL_HARDWARE4: |
| 289 |
mfxRes = CreateConfig<mfxU32>(MFX_IMPL_TYPE_HARDWARE, "mfxImplDescription.Impl"); |
| 290 |
break; |
| 291 |
|
| 292 |
default: |
| 293 |
mfxRes = MFX_ERR_UNSUPPORTED; |
| 294 |
break; |
| 295 |
} |
| 296 |
|
| 297 |
if (MFX_ERR_NONE != mfxRes) |
| 298 |
return MFX_ERR_UNSUPPORTED; |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
switch (implBaseType) { |
| 303 |
case MFX_IMPL_HARDWARE: |
| 304 |
mfxRes = CreateConfig<mfxU32>(0, "mfxImplDescription.VendorImplID"); |
| 305 |
break; |
| 306 |
case MFX_IMPL_HARDWARE2: |
| 307 |
mfxRes = CreateConfig<mfxU32>(1, "mfxImplDescription.VendorImplID"); |
| 308 |
break; |
| 309 |
case MFX_IMPL_HARDWARE3: |
| 310 |
mfxRes = CreateConfig<mfxU32>(2, "mfxImplDescription.VendorImplID"); |
| 311 |
break; |
| 312 |
case MFX_IMPL_HARDWARE4: |
| 313 |
mfxRes = CreateConfig<mfxU32>(3, "mfxImplDescription.VendorImplID"); |
| 314 |
break; |
| 315 |
} |
| 316 |
|
| 317 |
if (MFX_ERR_NONE != mfxRes) |
| 318 |
return MFX_ERR_UNSUPPORTED; |
| 319 |
|
| 320 |
mfxU32 implAccelMode = MFX_IMPL_ACCELMODE(par.Implementation); |
| 321 |
if (implAccelMode == MFX_IMPL_VIA_D3D9) { |
| 322 |
|
| 323 |
|
| 324 |
mfxRes = CreateConfig<mfxU32>(MFX_ACCEL_MODE_VIA_D3D9, |
| 325 |
"mfxImplDescription.AccelerationMode"); |
| 326 |
} |
| 327 |
else if (implAccelMode == MFX_IMPL_VIA_D3D11) { |
| 328 |
|
| 329 |
mfxRes = CreateConfig<mfxU32>(MFX_ACCEL_MODE_VIA_D3D11, |
| 330 |
"mfxImplDescription.AccelerationMode"); |
| 331 |
} |
| 332 |
else if (implAccelMode == MFX_IMPL_VIA_VAAPI) { |
| 333 |
|
| 334 |
|
| 335 |
mfxRes = CreateConfig<mfxU32>(MFX_ACCEL_MODE_VIA_VAAPI, |
| 336 |
"mfxImplDescription.AccelerationMode"); |
| 337 |
} |
| 338 |
|
| 339 |
if (MFX_ERR_NONE != mfxRes) |
| 340 |
return MFX_ERR_UNSUPPORTED; |
| 341 |
|
| 342 |
|
| 343 |
mfxRes = |
| 344 |
CreateConfig<mfxU32>(par.Version.Version, "mfxImplDescription.ApiVersion.Version"); |
| 345 |
if (MFX_ERR_NONE != mfxRes) |
| 346 |
return MFX_ERR_UNSUPPORTED; |
| 347 |
|
| 348 |
|
| 349 |
if (par.GPUCopy) { |
| 350 |
mfxRes = CreateConfig<mfxU16>(par.GPUCopy, "DeviceCopy"); |
| 351 |
if (MFX_ERR_NONE != mfxRes) |
| 352 |
return MFX_ERR_UNSUPPORTED; |
| 353 |
} |
| 354 |
|
| 355 |
|
| 356 |
if (par.ExternalThreads) { |
| 357 |
return MFX_ERR_UNSUPPORTED; |
| 358 |
} |
| 359 |
|
| 360 |
|
| 361 |
if (par.NumExtParam) { |
| 362 |
for (mfxU32 idx = 0; idx < par.NumExtParam; idx++) { |
| 363 |
mfxRes = CreateConfig<mfxHDL>(par.ExtParam[idx], "ExtBuffer"); |
| 364 |
if (MFX_ERR_NONE != mfxRes) |
| 365 |
return MFX_ERR_UNSUPPORTED; |
| 366 |
} |
| 367 |
} |
| 368 |
|
| 369 |
|
| 370 |
mfxRes = MFXCreateSession(m_loader, 0, &m_session); |
| 371 |
|
| 372 |
return mfxRes; |
| 373 |
} |
| 374 |
#endif |
| 375 |
|
| 376 |
private: |
| 377 |
MFXVideoSession(const MFXVideoSession &); |
| 378 |
void operator=(MFXVideoSession &); |
| 379 |
}; |
| 380 |
|
| 381 |
class MFXVideoENCODE : public MFXVideoENCODEBase { |
| 382 |
public: |
| 383 |
explicit MFXVideoENCODE(mfxSession session) { |
| 384 |
m_session = session; |
| 385 |
} |
| 386 |
virtual ~MFXVideoENCODE(void) { |
| 387 |
Close(); |
| 388 |
} |
| 389 |
|
| 390 |
virtual mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out) override { |
| 391 |
return MFXVideoENCODE_Query(m_session, in, out); |
| 392 |
} |
| 393 |
virtual mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest *request) override { |
| 394 |
return MFXVideoENCODE_QueryIOSurf(m_session, par, request); |
| 395 |
} |
| 396 |
virtual mfxStatus Init(mfxVideoParam *par) override { |
| 397 |
return MFXVideoENCODE_Init(m_session, par); |
| 398 |
} |
| 399 |
virtual mfxStatus Reset(mfxVideoParam *par) override { |
| 400 |
return MFXVideoENCODE_Reset(m_session, par); |
| 401 |
} |
| 402 |
virtual mfxStatus Close(void) override { |
| 403 |
return MFXVideoENCODE_Close(m_session); |
| 404 |
} |
| 405 |
|
| 406 |
virtual mfxStatus GetVideoParam(mfxVideoParam *par) override { |
| 407 |
return MFXVideoENCODE_GetVideoParam(m_session, par); |
| 408 |
} |
| 409 |
virtual mfxStatus GetEncodeStat(mfxEncodeStat *stat) override { |
| 410 |
return MFXVideoENCODE_GetEncodeStat(m_session, stat); |
| 411 |
} |
| 412 |
|
| 413 |
virtual mfxStatus EncodeFrameAsync(mfxEncodeCtrl *ctrl, |
| 414 |
mfxFrameSurface1 *surface, |
| 415 |
mfxBitstream *bs, |
| 416 |
mfxSyncPoint *syncp) override { |
| 417 |
return MFXVideoENCODE_EncodeFrameAsync(m_session, ctrl, surface, bs, syncp); |
| 418 |
} |
| 419 |
|
| 420 |
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) override { |
| 421 |
return MFXMemory_GetSurfaceForEncode(m_session, output_surf); |
| 422 |
} |
| 423 |
|
| 424 |
protected: |
| 425 |
mfxSession m_session; |
| 426 |
}; |
| 427 |
|
| 428 |
class MFXVideoDECODE : public MFXVideoDECODEBase { |
| 429 |
public: |
| 430 |
explicit MFXVideoDECODE(mfxSession session) { |
| 431 |
m_session = session; |
| 432 |
} |
| 433 |
virtual ~MFXVideoDECODE(void) { |
| 434 |
Close(); |
| 435 |
} |
| 436 |
|
| 437 |
virtual mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out) override { |
| 438 |
return MFXVideoDECODE_Query(m_session, in, out); |
| 439 |
} |
| 440 |
virtual mfxStatus DecodeHeader(mfxBitstream *bs, mfxVideoParam *par) override { |
| 441 |
return MFXVideoDECODE_DecodeHeader(m_session, bs, par); |
| 442 |
} |
| 443 |
virtual mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest *request) override { |
| 444 |
return MFXVideoDECODE_QueryIOSurf(m_session, par, request); |
| 445 |
} |
| 446 |
virtual mfxStatus Init(mfxVideoParam *par) override { |
| 447 |
return MFXVideoDECODE_Init(m_session, par); |
| 448 |
} |
| 449 |
virtual mfxStatus Reset(mfxVideoParam *par) override { |
| 450 |
return MFXVideoDECODE_Reset(m_session, par); |
| 451 |
} |
| 452 |
virtual mfxStatus Close(void) override { |
| 453 |
return MFXVideoDECODE_Close(m_session); |
| 454 |
} |
| 455 |
|
| 456 |
virtual mfxStatus GetVideoParam(mfxVideoParam *par) override { |
| 457 |
return MFXVideoDECODE_GetVideoParam(m_session, par); |
| 458 |
} |
| 459 |
|
| 460 |
virtual mfxStatus GetDecodeStat(mfxDecodeStat *stat) override { |
| 461 |
return MFXVideoDECODE_GetDecodeStat(m_session, stat); |
| 462 |
} |
| 463 |
virtual mfxStatus GetPayload(mfxU64 *ts, mfxPayload *payload) override { |
| 464 |
return MFXVideoDECODE_GetPayload(m_session, ts, payload); |
| 465 |
} |
| 466 |
virtual mfxStatus SetSkipMode(mfxSkipMode mode) override { |
| 467 |
return MFXVideoDECODE_SetSkipMode(m_session, mode); |
| 468 |
} |
| 469 |
virtual mfxStatus DecodeFrameAsync(mfxBitstream *bs, |
| 470 |
mfxFrameSurface1 *surface_work, |
| 471 |
mfxFrameSurface1 **surface_out, |
| 472 |
mfxSyncPoint *syncp) override { |
| 473 |
return MFXVideoDECODE_DecodeFrameAsync(m_session, bs, surface_work, surface_out, syncp); |
| 474 |
} |
| 475 |
|
| 476 |
virtual mfxStatus GetSurface(mfxFrameSurface1** output_surf) override { |
| 477 |
return MFXMemory_GetSurfaceForDecode(m_session, output_surf); |
| 478 |
} |
| 479 |
|
| 480 |
protected: |
| 481 |
mfxSession m_session; |
| 482 |
}; |
| 483 |
|
| 484 |
class MFXVideoVPP : public MFXVideoVPPBase { |
| 485 |
public: |
| 486 |
explicit MFXVideoVPP(mfxSession session) { |
| 487 |
m_session = session; |
| 488 |
} |
| 489 |
virtual ~MFXVideoVPP(void) { |
| 490 |
Close(); |
| 491 |
} |
| 492 |
|
| 493 |
virtual mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out) override { |
| 494 |
return MFXVideoVPP_Query(m_session, in, out); |
| 495 |
} |
| 496 |
virtual mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest request[2]) override { |
| 497 |
return MFXVideoVPP_QueryIOSurf(m_session, par, request); |
| 498 |
} |
| 499 |
virtual mfxStatus Init(mfxVideoParam *par) override { |
| 500 |
return MFXVideoVPP_Init(m_session, par); |
| 501 |
} |
| 502 |
virtual mfxStatus Reset(mfxVideoParam *par) override { |
| 503 |
return MFXVideoVPP_Reset(m_session, par); |
| 504 |
} |
| 505 |
virtual mfxStatus Close(void) override { |
| 506 |
return MFXVideoVPP_Close(m_session); |
| 507 |
} |
| 508 |
|
| 509 |
virtual mfxStatus GetVideoParam(mfxVideoParam *par) override { |
| 510 |
return MFXVideoVPP_GetVideoParam(m_session, par); |
| 511 |
} |
| 512 |
virtual mfxStatus GetVPPStat(mfxVPPStat *stat) override { |
| 513 |
return MFXVideoVPP_GetVPPStat(m_session, stat); |
| 514 |
} |
| 515 |
virtual mfxStatus RunFrameVPPAsync(mfxFrameSurface1 *in, |
| 516 |
mfxFrameSurface1 *out, |
| 517 |
mfxExtVppAuxData *aux, |
| 518 |
mfxSyncPoint *syncp) override { |
| 519 |
return MFXVideoVPP_RunFrameVPPAsync(m_session, in, out, aux, syncp); |
| 520 |
} |
| 521 |
|
| 522 |
virtual mfxStatus GetSurfaceIn(mfxFrameSurface1** output_surf) override { |
| 523 |
return MFXMemory_GetSurfaceForVPP(m_session, output_surf); |
| 524 |
} |
| 525 |
virtual mfxStatus GetSurfaceOut(mfxFrameSurface1** output_surf) override { |
| 526 |
return MFXMemory_GetSurfaceForVPPOut(m_session, output_surf); |
| 527 |
} |
| 528 |
|
| 529 |
virtual mfxStatus ProcessFrameAsync(mfxFrameSurface1 *in, mfxFrameSurface1 **out) override { |
| 530 |
return MFXVideoVPP_ProcessFrameAsync(m_session, in, out); |
| 531 |
} |
| 532 |
|
| 533 |
protected: |
| 534 |
mfxSession m_session; |
| 535 |
}; |
| 536 |
|
| 537 |
class MFXVideoDECODE_VPP |
| 538 |
{ |
| 539 |
public: |
| 540 |
explicit MFXVideoDECODE_VPP(mfxSession session) { |
| 541 |
m_session = session; |
| 542 |
} |
| 543 |
virtual ~MFXVideoDECODE_VPP(void) { |
| 544 |
Close(); |
| 545 |
} |
| 546 |
|
| 547 |
virtual mfxStatus Init(mfxVideoParam* decode_par, mfxVideoChannelParam** vpp_par_array, mfxU32 num_channel_par) { |
| 548 |
return MFXVideoDECODE_VPP_Init(m_session, decode_par, vpp_par_array, num_channel_par); |
| 549 |
} |
| 550 |
virtual mfxStatus Reset(mfxVideoParam* decode_par, mfxVideoChannelParam** vpp_par_array, mfxU32 num_channel_par) { |
| 551 |
return MFXVideoDECODE_VPP_Reset(m_session, decode_par, vpp_par_array, num_channel_par); |
| 552 |
} |
| 553 |
virtual mfxStatus GetChannelParam(mfxVideoChannelParam *par, mfxU32 channel_id) { |
| 554 |
return MFXVideoDECODE_VPP_GetChannelParam(m_session, par, channel_id); |
| 555 |
} |
| 556 |
virtual mfxStatus DecodeFrameAsync(mfxBitstream *bs, mfxU32* skip_channels, mfxU32 num_skip_channels, mfxSurfaceArray **surf_array_out) { |
| 557 |
return MFXVideoDECODE_VPP_DecodeFrameAsync(m_session, bs, skip_channels, num_skip_channels, surf_array_out); |
| 558 |
} |
| 559 |
|
| 560 |
virtual mfxStatus DecodeHeader(mfxBitstream *bs, mfxVideoParam *par) { |
| 561 |
return MFXVideoDECODE_VPP_DecodeHeader(m_session, bs, par); |
| 562 |
} |
| 563 |
virtual mfxStatus Close(void) { |
| 564 |
return MFXVideoDECODE_VPP_Close(m_session); |
| 565 |
} |
| 566 |
virtual mfxStatus GetVideoParam(mfxVideoParam *par) { |
| 567 |
return MFXVideoDECODE_VPP_GetVideoParam(m_session, par); |
| 568 |
} |
| 569 |
virtual mfxStatus GetDecodeStat(mfxDecodeStat *stat) { |
| 570 |
return MFXVideoDECODE_VPP_GetDecodeStat(m_session, stat); |
| 571 |
} |
| 572 |
virtual mfxStatus GetPayload(mfxU64 *ts, mfxPayload *payload) { |
| 573 |
return MFXVideoDECODE_VPP_GetPayload(m_session, ts, payload); |
| 574 |
} |
| 575 |
virtual mfxStatus SetSkipMode(mfxSkipMode mode) { |
| 576 |
return MFXVideoDECODE_VPP_SetSkipMode(m_session, mode); |
| 577 |
} |
| 578 |
|
| 579 |
protected: |
| 580 |
mfxSession m_session; |
| 581 |
}; |
| 582 |
|
| 583 |
#endif |