Merge pull request #647 from mstorsjo/remove-dynamic-vp
Remove code for loading the VP library dynamically
This commit is contained in:
commit
8690adf870
2
Makefile
2
Makefile
@ -38,7 +38,7 @@ endif
|
||||
include build/platform-$(OS).mk
|
||||
|
||||
|
||||
CFLAGS += -DNO_DYNAMIC_VP
|
||||
CFLAGS +=
|
||||
LDFLAGS +=
|
||||
|
||||
ifeq (Yes, $(GCOV))
|
||||
|
@ -93,7 +93,6 @@
|
||||
4CE446AA18BC605C0017DF25 /* as264_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = as264_common.h; sourceTree = "<group>"; };
|
||||
4CE446AB18BC605C0017DF25 /* au_set.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = au_set.h; sourceTree = "<group>"; };
|
||||
4CE446AC18BC605C0017DF25 /* bit_stream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bit_stream.h; sourceTree = "<group>"; };
|
||||
4CE446AD18BC605C0017DF25 /* bundleloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bundleloader.h; sourceTree = "<group>"; };
|
||||
4CE446AE18BC605C0017DF25 /* deblocking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deblocking.h; sourceTree = "<group>"; };
|
||||
4CE446AF18BC605C0017DF25 /* decode_mb_aux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = decode_mb_aux.h; sourceTree = "<group>"; };
|
||||
4CE446B018BC605C0017DF25 /* dq_map.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dq_map.h; sourceTree = "<group>"; };
|
||||
@ -286,7 +285,6 @@
|
||||
4CE446AA18BC605C0017DF25 /* as264_common.h */,
|
||||
4CE446AB18BC605C0017DF25 /* au_set.h */,
|
||||
4CE446AC18BC605C0017DF25 /* bit_stream.h */,
|
||||
4CE446AD18BC605C0017DF25 /* bundleloader.h */,
|
||||
4CE446AE18BC605C0017DF25 /* deblocking.h */,
|
||||
4CE446AF18BC605C0017DF25 /* decode_mb_aux.h */,
|
||||
4CE446B018BC605C0017DF25 /* dq_map.h */,
|
||||
@ -636,12 +634,10 @@
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "";
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[sdk=iphoneos*]" = (
|
||||
APPLE_IOS,
|
||||
NO_DYNAMIC_VP,
|
||||
HAVE_NEON,
|
||||
);
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[sdk=iphonesimulator*]" = (
|
||||
APPLE_IOS,
|
||||
NO_DYNAMIC_VP,
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/../../../../common/inc",
|
||||
@ -670,12 +666,10 @@
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "";
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[sdk=iphoneos*]" = (
|
||||
APPLE_IOS,
|
||||
NO_DYNAMIC_VP,
|
||||
HAVE_NEON,
|
||||
);
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[sdk=iphonesimulator*]" = (
|
||||
APPLE_IOS,
|
||||
NO_DYNAMIC_VP,
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/../../../../common/inc",
|
||||
|
@ -215,7 +215,7 @@
|
||||
FavorSizeOrSpeed="1"
|
||||
WholeProgramOptimization="true"
|
||||
AdditionalIncludeDirectories="..\..\..\common\inc;..\..\..\encoder\core\inc,..\..\..\api\svc;..\..\..\processing\interface"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;X86_ASM;"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;X86_ASM"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
|
@ -1,137 +0,0 @@
|
||||
/*!
|
||||
* \copy
|
||||
* Copyright (c) 2013, Cisco Systems
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef WELS_BOUNDLELOAD_H
|
||||
#define WELS_BOUNDLELOAD_H
|
||||
|
||||
#if defined(MACOS)
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <carbon/carbon.h>
|
||||
#include <coreFoundation/CFBundle.h>
|
||||
#include <string>
|
||||
|
||||
int GetCurrentModulePath (char* lpModulePath, const int iPathMax) {
|
||||
if (lpModulePath == NULL || iPathMax <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset (lpModulePath, 0, iPathMax);
|
||||
|
||||
char cCurrentPath[PATH_MAX];
|
||||
memset (cCurrentPath, 0, PATH_MAX);
|
||||
|
||||
Dl_info dlInfo;
|
||||
static int sDummy;
|
||||
dladdr ((void*)&sDummy, &dlInfo);
|
||||
|
||||
strlcpy (cCurrentPath, dlInfo.dli_fname, PATH_MAX);
|
||||
|
||||
// whether is self a framework ?
|
||||
int locateNumber = 1;
|
||||
struct FSRef currentPath;
|
||||
OSStatus iStatus = FSPathMakeRef ((unsigned char*)cCurrentPath, ¤tPath, NULL);
|
||||
if (noErr == iStatus) {
|
||||
LSItemInfoRecord info;
|
||||
iStatus = LSCopyItemInfoForRef (¤tPath, kLSRequestExtension, &info);
|
||||
if (noErr == iStatus && NULL == info.extension) {
|
||||
locateNumber = 4;
|
||||
}
|
||||
}
|
||||
std::string strPath (cCurrentPath);
|
||||
std::string::size_type pos = std::string::npos;
|
||||
for (int i = 0; i < locateNumber; i++) {
|
||||
pos = strPath.rfind ('/');
|
||||
if (std::string::npos == pos) {
|
||||
break;
|
||||
}
|
||||
strPath.erase (pos);
|
||||
}
|
||||
if (std::string::npos == pos) {
|
||||
return -2;
|
||||
}
|
||||
cCurrentPath[pos] = 0;
|
||||
|
||||
strlcpy (lpModulePath, cCurrentPath, iPathMax);
|
||||
strlcat (lpModulePath, "/", iPathMax);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
CFBundleRef LoadBundle (const char* lpBundlePath) {
|
||||
if (lpBundlePath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct FSRef bundlePath;
|
||||
OSStatus iStatus = FSPathMakeRef ((unsigned char*)lpBundlePath, &bundlePath, NULL);
|
||||
if (noErr != iStatus) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CFURLRef bundleURL = CFURLCreateFromFSRef (kCFAllocatorSystemDefault, &bundlePath);
|
||||
if (NULL == bundleURL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// 2.get bundle ref
|
||||
CFBundleRef bundleRef = CFBundleCreate (kCFAllocatorSystemDefault, bundleURL);
|
||||
CFRelease (bundleURL);
|
||||
|
||||
// Boolean bReturn = FALSE;
|
||||
if (NULL != bundleRef) {
|
||||
// bReturn = CFBundleLoadExecutable(bundleRef);
|
||||
}
|
||||
|
||||
return bundleRef;
|
||||
}
|
||||
|
||||
Boolean FreeBundle (CFBundleRef bundleRef) {
|
||||
if (NULL != bundleRef) {
|
||||
// CFBundleUnloadExecutable(bundleRef);
|
||||
CFRelease (bundleRef);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void* GetProcessAddress (CFBundleRef bundleRef, const char* lpProcName) {
|
||||
void* processAddress = NULL;
|
||||
if (NULL != bundleRef) {
|
||||
CFStringRef cfProcName = CFStringCreateWithCString (kCFAllocatorSystemDefault, lpProcName, CFStringGetSystemEncoding());
|
||||
processAddress = CFBundleGetFunctionPointerForName (bundleRef, cfProcName);
|
||||
CFRelease (cfProcName);
|
||||
}
|
||||
return processAddress;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -114,22 +114,6 @@ typedef struct SVAAFrameInfoExt_t: public SVAAFrameInfo
|
||||
uint8_t *pVaaBlockStaticIdc[16];//real memory,
|
||||
}SVAAFrameInfoExt;
|
||||
|
||||
class CWelsLib {
|
||||
public:
|
||||
CWelsLib (sWelsEncCtx* pEncCtx);
|
||||
virtual ~CWelsLib();
|
||||
|
||||
int32_t CreateIface (IWelsVP** ppInterfaceVp);
|
||||
int32_t DestroyIface (IWelsVP* pInterfaceVp);
|
||||
|
||||
protected:
|
||||
void* QueryFunction (const char* pName);
|
||||
|
||||
private:
|
||||
void* m_pVpLib;
|
||||
void* m_pInterface[2];
|
||||
};
|
||||
|
||||
class CWelsPreProcess {
|
||||
public:
|
||||
CWelsPreProcess (sWelsEncCtx* pEncCtx);
|
||||
@ -185,7 +169,6 @@ private:
|
||||
Scaled_Picture m_sScaledPicture;
|
||||
SPicture* m_pLastSpatialPicture[MAX_DEPENDENCY_LAYER][2];
|
||||
IWelsVP* m_pInterfaceVp;
|
||||
CWelsLib* m_pEncLib;
|
||||
sWelsEncCtx* m_pEncCtx;
|
||||
bool m_bInitDone;
|
||||
uint8_t m_uiSpatialLayersInTemporal[MAX_DEPENDENCY_LAYER];
|
||||
|
@ -30,16 +30,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NO_DYNAMIC_VP
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#elif defined(MACOS)
|
||||
#include "bundleloader.h"
|
||||
#elif defined(__GNUC__)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "wels_preprocess.h"
|
||||
#include "picture_handle.h"
|
||||
#include "encoder_context.h"
|
||||
@ -52,8 +42,6 @@ namespace WelsSVCEnc {
|
||||
|
||||
|
||||
//***** entry API declaration ************************************************************************//
|
||||
typedef EResult (* pfnCreateVpInterface) (void**, int);
|
||||
typedef EResult (* pfnDestroyVpInterface) (void*, int);
|
||||
|
||||
int32_t WelsInitScaledPic (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPic, CMemoryAlign* pMemoryAlign);
|
||||
bool JudgeNeedOfScaling (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPic);
|
||||
@ -76,125 +64,6 @@ inline void WelsUpdateSpatialIdxMap (sWelsEncCtx* pEncCtx, int32_t iPos, SPic
|
||||
}
|
||||
|
||||
|
||||
//***************************************************************************************************//
|
||||
CWelsLib::CWelsLib (sWelsEncCtx* pEncCtx) {
|
||||
m_pInterface[0] = m_pInterface[1] = NULL;
|
||||
|
||||
#ifndef NO_DYNAMIC_VP
|
||||
#if defined(_WIN32)
|
||||
const char WelsVPLib[] = "welsvp.dll";
|
||||
HMODULE shModule = LoadLibrary (WelsVPLib);
|
||||
if (!shModule)
|
||||
WelsLog (pEncCtx, WELS_LOG_ERROR, "welsvp load lib dynamic failed module=%x\n", shModule);
|
||||
|
||||
#elif defined(MACOS)
|
||||
const char WelsVPLib[] = "welsvp.bundle";
|
||||
char pCurPath[256];
|
||||
GetCurrentModulePath (pCurPath, 256);
|
||||
strlcat (pCurPath, WelsVPLib, 256);
|
||||
CFBundleRef shModule = LoadBundle (pCurPath);
|
||||
if (!shModule)
|
||||
WelsLog (pEncCtx, WELS_LOG_ERROR, "welsvp load lib dynamic failed module=%x\n", shModule);
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
const char WelsVPLib[] = "./libwelsvp.so";
|
||||
void* shModule = NULL;
|
||||
shModule = dlopen (WelsVPLib, RTLD_LAZY);
|
||||
if (shModule == NULL)
|
||||
printf ("dlopen %s iRet=%p, err=%s\n", WelsVPLib, shModule, dlerror());
|
||||
#endif
|
||||
|
||||
m_pVpLib = (void*)shModule;
|
||||
#endif
|
||||
}
|
||||
|
||||
CWelsLib::~CWelsLib() {
|
||||
#ifndef NO_DYNAMIC_VP
|
||||
if (m_pVpLib) {
|
||||
#if defined(_WIN32)
|
||||
HMODULE shModule = (HMODULE)m_pVpLib;
|
||||
FreeLibrary (shModule);
|
||||
|
||||
#elif defined(MACOS)
|
||||
CFBundleRef shModule = (CFBundleRef)m_pVpLib;
|
||||
FreeBundle (shModule);
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
void* shModule = m_pVpLib;
|
||||
dlclose (shModule);
|
||||
#endif
|
||||
m_pVpLib = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void* CWelsLib::QueryFunction (const char* pName) {
|
||||
void* pFunc = NULL;
|
||||
|
||||
#ifndef NO_DYNAMIC_VP
|
||||
if (m_pVpLib) {
|
||||
#if defined(_WIN32)
|
||||
HMODULE shModule = (HMODULE)m_pVpLib;
|
||||
pFunc = (void*)GetProcAddress (shModule, pName);
|
||||
|
||||
#elif defined(MACOS)
|
||||
CFBundleRef shModule = (CFBundleRef)m_pVpLib;
|
||||
pFunc = (void*)GetProcessAddress (shModule, pName);
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
void* shModule = m_pVpLib;
|
||||
pFunc = (void*)dlsym (shModule, pName);
|
||||
if (pFunc == NULL)
|
||||
printf ("dlsym %p iRet=%p, err=%s\n", shModule, pFunc, dlerror());
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return pFunc;
|
||||
}
|
||||
|
||||
int32_t CWelsLib::CreateIface (IWelsVP** ppInterfaceVp) {
|
||||
*ppInterfaceVp = NULL;
|
||||
#ifndef NO_DYNAMIC_VP
|
||||
if (m_pVpLib) {
|
||||
|
||||
#endif
|
||||
pfnCreateVpInterface pCreateVpInterface = NULL;
|
||||
pfnDestroyVpInterface pDestroyVpInterface = NULL;
|
||||
|
||||
#ifndef NO_DYNAMIC_VP
|
||||
pCreateVpInterface = (pfnCreateVpInterface) QueryFunction ("CreateVpInterface");
|
||||
pDestroyVpInterface = (pfnDestroyVpInterface) QueryFunction ("DestroyVpInterface");
|
||||
#else
|
||||
pCreateVpInterface = CreateVpInterface;
|
||||
// TODO(ekr@rtfm.com): This cast corrects a signature difference... This is a potential real problem
|
||||
pDestroyVpInterface = (pfnDestroyVpInterface)DestroyVpInterface;
|
||||
#endif
|
||||
|
||||
m_pInterface[0] = (void*)pCreateVpInterface;
|
||||
m_pInterface[1] = (void*)pDestroyVpInterface;
|
||||
|
||||
if (m_pInterface[0] && m_pInterface[1])
|
||||
pCreateVpInterface ((void**)ppInterfaceVp, WELSVP_INTERFACE_VERION);
|
||||
#ifndef NO_DYNAMIC_VP
|
||||
} else {
|
||||
}
|
||||
#endif
|
||||
|
||||
return (*ppInterfaceVp) ? 0 : 1;
|
||||
}
|
||||
|
||||
int32_t CWelsLib::DestroyIface (IWelsVP* pInterfaceVp) {
|
||||
if (pInterfaceVp) {
|
||||
pfnDestroyVpInterface pDestroyVpInterface = (pfnDestroyVpInterface) m_pInterface[1];
|
||||
if (pDestroyVpInterface) {
|
||||
pDestroyVpInterface (pInterfaceVp, WELSVP_INTERFACE_VERION);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* implement of the interface
|
||||
@ -203,7 +72,6 @@ int32_t CWelsLib::DestroyIface (IWelsVP* pInterfaceVp) {
|
||||
|
||||
CWelsPreProcess::CWelsPreProcess (sWelsEncCtx* pEncCtx) {
|
||||
m_pInterfaceVp = NULL;
|
||||
m_pEncLib = NULL;
|
||||
m_bInitDone = false;
|
||||
m_pEncCtx = pEncCtx;
|
||||
memset (&m_sScaledPicture, 0, sizeof (m_sScaledPicture));
|
||||
@ -218,12 +86,8 @@ CWelsPreProcess::~CWelsPreProcess() {
|
||||
}
|
||||
|
||||
int32_t CWelsPreProcess::WelsPreprocessCreate() {
|
||||
if (m_pEncLib == NULL && m_pInterfaceVp == NULL) {
|
||||
m_pEncLib = new CWelsLib (m_pEncCtx);
|
||||
if (!m_pEncLib)
|
||||
goto exit;
|
||||
|
||||
m_pEncLib->CreateIface (&m_pInterfaceVp);
|
||||
if (m_pInterfaceVp == NULL) {
|
||||
CreateVpInterface ((void**) &m_pInterfaceVp, WELSVP_INTERFACE_VERION);
|
||||
if (!m_pInterfaceVp)
|
||||
goto exit;
|
||||
} else
|
||||
@ -237,11 +101,8 @@ exit:
|
||||
}
|
||||
|
||||
int32_t CWelsPreProcess::WelsPreprocessDestroy() {
|
||||
if (m_pEncLib) {
|
||||
m_pEncLib->DestroyIface (m_pInterfaceVp);
|
||||
m_pInterfaceVp = NULL;
|
||||
WelsSafeDelete (m_pEncLib);
|
||||
}
|
||||
DestroyVpInterface (m_pInterfaceVp, WELSVP_INTERFACE_VERION);
|
||||
m_pInterfaceVp = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -32,5 +32,5 @@
|
||||
|
||||
LIBRARY welsvp.dll
|
||||
EXPORTS
|
||||
CreateVpInterface PRIVATE
|
||||
DestroyVpInterface PRIVATE
|
||||
CreateVpInterface
|
||||
DestroyVpInterface
|
Loading…
x
Reference in New Issue
Block a user