Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
39 Views

MFXInit returns -3 when called from a big transcoding application, returns 0 when called from a simple test program.

Our transcoding application supports MFX on Windows platforms. Now, we are trying to support it on Linux.

2018R1 on CentOS 7.4 Gold installation. Intel i5-6600 cpu.

When we write a simple C++ application like

main()
{
mfxStatus       sts;
mfxIMPL         impl;
mfxVersion      ver;
mfxSession      m_mfxSession;


impl            = MFX_IMPL_HARDWARE_ANY;
ver.Minor       = 25;
ver.Major       = 1;


sts = MFXInit( impl , &ver , &m_mfxSession );

if ( sts == MFX_ERR_NONE )
{
  printf( ....
}
else
{
  printf( ....
}

return( -1 );

}

 

MFXInit returns 0 (success) and we get the following output from mfx_dispatch.cpp

[user@localhost test]$ ./main.o 
INFO:    MFXInitEx (impl=MFX_IMPL_HARDWARE_ANY, pVer=1.25, ExternalThreads=0 session=0x7ffe6675d2b8
INFO:    invoking LoadLibrary(/opt/intel/mediasdk/lib64/libmfxhw64-p.so.1.25)
LoadSelectedDll loaded module /opt/intel/mediasdk/lib64/libmfxhw64-p.so.1.25. hModule=0x247d540
INFO:    MFXInitEx(MFX_IMPL_HARDWARE,ver=1.25,ExtThreads=0,session=0x247d0c0)
At last...
loadStatus=0
INFO:    invoking LoadLibrary(libmfxhw64.so)
LoadSelectedDll loaded module libmfxhw64.so. hModule=0x247d540
INFO:    MFXInitEx(MFX_IMPL_HARDWARE,ver=1.25,ExtThreads=0,session=0x2481fa0)
At last...
loadStatus=0
MFX_VIDEO_ENCODER::__Initialize() successful. Accelerator type: hardware/vaapi, Intel SDK version 1.25

 

When we put the same code to the very beginning of the main() of our big transcoding application and call MFXInit(), it returns -3:

INFO:    MFXInitEx (impl=MFX_IMPL_HARDWARE_ANY, pVer=1.25, ExternalThreads=0 session=0x7ffb44000e50
INFO:    invoking LoadLibrary(/opt/intel/mediasdk/lib64/libmfxhw64-p.so.1.25)
LoadSelectedDll loaded module /opt/intel/mediasdk/lib64/libmfxhw64-p.so.1.25. hModule=0x7ffb44025db0
INFO:    MFXInitEx(MFX_IMPL_HARDWARE,ver=1.25,ExtThreads=0,session=0x7ffb44025930)
library can't be load. MFXInitEx returned -3 
loadStatus=-3
INFO:    invoking LoadLibrary(libmfxhw64.so)
LoadSelectedDll loaded module libmfxhw64.so. hModule=0x7ffb440268e0
INFO:    MFXInitEx(MFX_IMPL_HARDWARE,ver=1.25,ExtThreads=0,session=0x7ffb44025930)
library can't be load. MFXInitEx returned -3 
loadStatus=-3

 

LD_LIBRARY_PATH is defined as

./:/opt/intel/mediasdk/lib64

 

As far as we traced the mfx_dispatch code, the SO is loaded, all function addresses are read but the actualTable[eMFXInitEx] function from the loaded SO happens to return -3.

mfxStatus MFX_DISP_HANDLE::LoadSelectedDLL(const msdk_disp_char *pPath, eMfxImplType reqImplType,
                                           mfxIMPL reqImpl, mfxIMPL reqImplInterface, mfxInitParam &par)
{

......

        // Call old-style MFXInit init for older libraries and audio library
        bool callOldInit = (impl & MFX_IMPL_AUDIO) || !actualTable[eMFXInitEx]; // if true call eMFXInit, if false - eMFXInitEx
        int tableIndex = (callOldInit) ? eMFXInit : eMFXInitEx;

        mfxFunctionPointer pFunc = actualTable[tableIndex];

        {
            if (callOldInit)
            {
                DISPATCHER_LOG_BLOCK(("Calling MFXInit(%s,ver=%u.%u,session=%p) from DLL\n"
                                     , DispatcherLog_GetMFXImplString(impl | implInterface).c_str()
                                     , apiVersion.Major
                                     , apiVersion.Minor
                                     , &session));

                mfxRes = (*(mfxStatus(MFX_CDECL *) (mfxIMPL, mfxVersion *, mfxSession *)) pFunc) (impl | implInterface, &version, &session);
            }
            else
            {
                DISPATCHER_LOG_BLOCK(("MFXInitEx(%s,ver=%u.%u,ExtThreads=%d,session=%p)\n"
                                     , DispatcherLog_GetMFXImplString(impl | implInterface).c_str()
                                     , apiVersion.Major
                                     , apiVersion.Minor
                                     , par.ExternalThreads
                                     , &session));

                mfxInitParam initPar = par;
                // adjusting user parameters
                initPar.Implementation = impl | implInterface;
                initPar.Version = version;
 ====>>         mfxRes = (*(mfxStatus(MFX_CDECL *) (mfxInitParam, mfxSession *)) pFunc) (initPar, &session);
            }
        }

......

}

 

Prebuilt sample transcoding application in the MediaSDK runs good.

Any ideas?

 

0 Kudos
2 Replies
Highlighted
Moderator
39 Views

Hi Altug,

This is more like a environment issue to me. For example, the big program might linked with different loader or parse library compare to your simple program.

Mark

0 Kudos
Highlighted
Beginner
39 Views

Our "big program" has a shared object (SO) component which is linked with libmfx.a from Intel Media SDK.

During the final linkage of our "big program", that SO component and libmfx.a is used again, to compile our proprietary use of Intel MFX functionality.

In other words, MFX API is used both in the SO component and the main executable which uses the SO component.

Although the same libmfx.a library was used, this was causing the problem I stated.

When the SO is compiled by enabling the MFX code in it, it links with libmfx.a and the MFXInit calls in our own code is failing. When MFX support is disabled in the SO component, MFXInit calls in our own code was working successfully.  Kind of a strange behaviour of the toolchain.

Disabled the MFX support in that SO component and the problem is solved.

0 Kudos