-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add wasm build support #3577
base: master
Are you sure you want to change the base?
add wasm build support #3577
Changes from 1 commit
91b8324
79db3de
7fa9e03
24a19f8
a6cea85
ab46cd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
include $(SRC_PATH)build/arch.mk | ||
SHAREDLIBSUFFIX = so | ||
SHAREDLIBSUFFIXFULLVER=$(SHAREDLIBSUFFIX).$(FULL_VERSION) | ||
SHAREDLIBSUFFIXMAJORVER=$(SHAREDLIBSUFFIX).$(SHAREDLIB_MAJORVERSION) | ||
SHLDFLAGS = -Wl,-soname,$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXMAJORVER) | ||
CFLAGS += -Wall -fno-strict-aliasing -fPIC -MMD -MP | ||
# fix undifined symbol: __stack_chk_guard bug | ||
# flags needed to build wasm | ||
CFLAGS += -U_FORTIFY_SOURCE -pthread -DWASMSIMD -msimd128 | ||
CXXFLAGS += -U_FORTIFY_SOURCE -pthread -DWASMSIMD -msimd128 | ||
LDFLAGS += -U_FORTIFY_SOURCE -pthread -msimd128 | ||
ifeq ($(EMFS), nodefs) | ||
CFLAGS += -DNODEFS | ||
CXXFLAGS += -DNODEFS | ||
LDFLAGS += -lnodefs.js | ||
endif | ||
ifeq ($(EMFS), memfs) | ||
CFLAGS += -DMEMFS | ||
CXXFLAGS += -DMEMFS | ||
LDFLAGS += --preload-file ./testbin/workload | ||
endif | ||
ifeq ($(WASMDEBUG), True) | ||
CFLAGS += -g2 | ||
CXXFLAGS += -g2 | ||
LDFLAGS += -g2 | ||
endif | ||
|
||
STATIC_LDFLAGS += -lm | ||
AR_OPTS = crD $@ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,10 @@ | |
#if defined (ANDROID_NDK) | ||
#include <android/log.h> | ||
#endif | ||
#ifdef __EMSCRIPTEN__ | ||
#include <emscripten.h> | ||
#endif | ||
|
||
#include "codec_def.h" | ||
#include "codec_app_def.h" | ||
#include "codec_api.h" | ||
|
@@ -60,6 +64,13 @@ float g_fDecFPS = 0.0; | |
int g_iDecodedFrameNum = 0; | ||
#endif | ||
|
||
#if defined(NODEFS) | ||
#define CWD "/workload/" | ||
#endif | ||
#if defined(MEMFS) | ||
#define CWD "testbin/workload/" | ||
#endif | ||
|
||
#if defined(ANDROID_NDK) | ||
#define LOG_TAG "welsdec" | ||
#define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) | ||
|
@@ -256,7 +267,7 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons | |
if (kpH264FileName) { | ||
pH264File = fopen (kpH264FileName, "rb"); | ||
if (pH264File == NULL) { | ||
fprintf (stderr, "Can not open h264 source file, check its legal path related please..\n"); | ||
fprintf (stderr, "Can not open h264 source file: %s, check its legal path related please..\n", kpH264FileName); | ||
return; | ||
} | ||
fprintf (stderr, "H264 source file name: %s..\n", kpH264FileName); | ||
|
@@ -505,14 +516,27 @@ int32_t main (int32_t iArgC, char* pArgV[]) { | |
sDecParam.sVideoProperty.size = sizeof (sDecParam.sVideoProperty); | ||
sDecParam.eEcActiveIdc = ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE; | ||
|
||
#if defined(NODEFS) | ||
EM_ASM( | ||
FS.mkdir('/workload'); | ||
FS.mount(NODEFS, { root: '.' }, '/workload'); | ||
); | ||
#endif | ||
|
||
if (iArgC < 2) { | ||
printf ("usage 1: h264dec.exe welsdec.cfg\n"); | ||
printf ("usage 2: h264dec.exe welsdec.264 out.yuv\n"); | ||
printf ("usage 3: h264dec.exe welsdec.264\n"); | ||
return 1; | ||
} else if (iArgC == 2) { | ||
if (strstr (pArgV[1], ".cfg")) { // read config file //confirmed_safe_unsafe_usage | ||
CReadConfig cReadCfg (pArgV[1]); | ||
string cfgFilePath; | ||
#if defined(NODEFS) || defined(MEMFS) | ||
cfgFilePath = string(CWD) + string(pArgV[1]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for the Emscripten File System node.js environment for example, we map the main project dir to After the mount we can run h264enc.js like: The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why map the main project dir to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I tried to mount host dir In browser env, packaging all the main will lead to longer file reading time. |
||
#else | ||
cfgFilePath = string(pArgV[1]); | ||
#endif | ||
CReadConfig cReadCfg (cfgFilePath.c_str()); | ||
string strTag[4]; | ||
string strReconFile (""); | ||
|
||
|
@@ -554,14 +578,23 @@ int32_t main (int32_t iArgC, char* pArgV[]) { | |
} | ||
} else if (strstr (pArgV[1], | ||
".264")) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage | ||
#if defined(NODEFS) || defined(MEMFS) | ||
strInputFile = string(CWD) + string(pArgV[1]); | ||
#else | ||
strInputFile = pArgV[1]; | ||
#endif | ||
sDecParam.uiTargetDqLayer = (uint8_t) - 1; | ||
sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; | ||
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; | ||
} | ||
} else { //iArgC > 2 | ||
#if defined(NODEFS) || defined(MEMFS) | ||
strInputFile = string(CWD) + string(pArgV[1]); | ||
strOutputFile = string(CWD) + string(pArgV[2]); | ||
#else | ||
strInputFile = pArgV[1]; | ||
strOutputFile = pArgV[2]; | ||
#endif | ||
sDecParam.uiTargetDqLayer = (uint8_t) - 1; | ||
sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; | ||
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; | ||
|
@@ -571,7 +604,11 @@ int32_t main (int32_t iArgC, char* pArgV[]) { | |
|
||
if (!strcmp (cmd, "-options")) { | ||
if (i + 1 < iArgC) | ||
#if defined(NODEFS) || defined(MEMFS) | ||
strOptionFile = string(CWD) + string(pArgV[++i]); | ||
#else | ||
strOptionFile = pArgV[++i]; | ||
#endif | ||
else { | ||
printf ("options file not specified.\n"); | ||
return 1; | ||
|
@@ -585,7 +622,11 @@ int32_t main (int32_t iArgC, char* pArgV[]) { | |
} | ||
} else if (!strcmp (cmd, "-length")) { | ||
if (i + 1 < iArgC) | ||
#if defined(NODEFS) || defined(MEMFS) | ||
strLengthFile = string(CWD) + string(pArgV[++i]); | ||
#else | ||
strLengthFile = pArgV[++i]; | ||
#endif | ||
else { | ||
printf ("lenght file not specified.\n"); | ||
return 1; | ||
|
@@ -655,4 +696,4 @@ int32_t main (int32_t iArgC, char* pArgV[]) { | |
} | ||
|
||
return 0; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you avoid duplicating all this by just setting
EXEEXT = .html
?