| 1 |
/*############################################################################ |
| 2 |
# Copyright (C) 2021 Intel Corporation |
| 3 |
# |
| 4 |
# SPDX-License-Identifier: MIT |
| 5 |
############################################################################*/ |
| 6 |
|
| 7 |
#include <stdlib.h> |
| 8 |
#include <stdio.h> |
| 9 |
|
| 10 |
#include "mfx.h" |
| 11 |
|
| 12 |
/* These macro required for code compilation. */ |
| 13 |
#define INFINITE 0x7FFFFFFF |
| 14 |
#define UNUSED_PARAM(x) (void)(x) |
| 15 |
|
| 16 |
mfxSession session, sessionSW, sessionHW; |
| 17 |
|
| 18 |
void prg_dispatcher1 () { |
| 19 |
/*beg1*/ |
| 20 |
mfxLoader loader = MFXLoad(); |
| 21 |
MFXCreateSession(loader,0,&session); |
| 22 |
/*end1*/ |
| 23 |
} |
| 24 |
|
| 25 |
void prg_dispatcher2 () { |
| 26 |
/*beg2*/ |
| 27 |
mfxLoader loader = MFXLoad(); |
| 28 |
mfxConfig cfg = MFXCreateConfig(loader); |
| 29 |
mfxVariant ImplValue; |
| 30 |
ImplValue.Type = MFX_VARIANT_TYPE_U32; |
| 31 |
ImplValue.Data.U32 = MFX_IMPL_TYPE_HARDWARE; |
| 32 |
MFXSetConfigFilterProperty(cfg,(const mfxU8 *)"mfxImplDescription.Impl",ImplValue); |
| 33 |
MFXCreateSession(loader,0,&session); |
| 34 |
/*end2*/ |
| 35 |
} |
| 36 |
|
| 37 |
void prg_dispatcher3 () { |
| 38 |
/*beg3*/ |
| 39 |
// Create session with software based implementation |
| 40 |
mfxLoader loader1 = MFXLoad(); |
| 41 |
mfxConfig cfg1 = MFXCreateConfig(loader1); |
| 42 |
mfxVariant ImplValueSW; |
| 43 |
ImplValueSW.Type = MFX_VARIANT_TYPE_U32; |
| 44 |
ImplValueSW.Data.U32 = MFX_IMPL_TYPE_SOFTWARE; |
| 45 |
MFXSetConfigFilterProperty(cfg1,(const mfxU8 *)"mfxImplDescription.Impl",ImplValueSW); |
| 46 |
MFXCreateSession(loader1,0,&sessionSW); |
| 47 |
|
| 48 |
// Create session with hardware based implementation |
| 49 |
mfxLoader loader2 = MFXLoad(); |
| 50 |
mfxConfig cfg2 = MFXCreateConfig(loader2); |
| 51 |
mfxVariant ImplValueHW; |
| 52 |
ImplValueHW.Type = MFX_VARIANT_TYPE_U32; |
| 53 |
ImplValueHW.Data.U32 = MFX_IMPL_TYPE_HARDWARE; |
| 54 |
MFXSetConfigFilterProperty(cfg2,(const mfxU8 *)"mfxImplDescription.Impl",ImplValueHW); |
| 55 |
MFXCreateSession(loader2,0,&sessionHW); |
| 56 |
|
| 57 |
// use both sessionSW and sessionHW |
| 58 |
// ... |
| 59 |
// Close everything |
| 60 |
MFXClose(sessionSW); |
| 61 |
MFXClose(sessionHW); |
| 62 |
MFXUnload(loader1); // cfg1 will be destroyed here. |
| 63 |
MFXUnload(loader2); // cfg2 will be destroyed here. |
| 64 |
/*end3*/ |
| 65 |
} |
| 66 |
|
| 67 |
void prg_dispatcher4 () { |
| 68 |
/*beg4*/ |
| 69 |
mfxLoader loader = MFXLoad(); |
| 70 |
|
| 71 |
// We want to have AVC decoder supported. |
| 72 |
mfxConfig cfg1 = MFXCreateConfig(loader); |
| 73 |
mfxVariant ImplValue; |
| 74 |
ImplValue.Type = MFX_VARIANT_TYPE_U32; |
| 75 |
ImplValue.Data.U32 = MFX_CODEC_AVC; |
| 76 |
MFXSetConfigFilterProperty(cfg1, |
| 77 |
(const mfxU8 *)"mfxImplDescription.mfxDecoderDescription.decoder.CodecID",ImplValue); |
| 78 |
|
| 79 |
// And we want to have HEVC encoder supported by the same implementation. |
| 80 |
mfxConfig cfg2 = MFXCreateConfig(loader); |
| 81 |
ImplValue.Type = MFX_VARIANT_TYPE_U32; |
| 82 |
ImplValue.Data.U32 = MFX_CODEC_HEVC; |
| 83 |
MFXSetConfigFilterProperty(cfg2, |
| 84 |
(const mfxU8 *)"mfxImplDescription.mfxEncoderDescription.encoder.CodecID",ImplValue); |
| 85 |
|
| 86 |
// To create single session with both capabilities. |
| 87 |
MFXCreateSession(loader,0,&session); |
| 88 |
/*end4*/ |
| 89 |
} |