mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 09:39:15 +00:00
Simplify and improve Basis makefile
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
CODEC_URL := https://github.com/BinomialLLC/basis_universal/archive/refs/tags/v1.15_rel2.tar.gz
|
CODEC_URL := https://github.com/BinomialLLC/basis_universal/archive/refs/tags/v1.15_rel2.tar.gz
|
||||||
CODEC_DIR := node_modules/basis
|
CODEC_DIR := node_modules/basis
|
||||||
|
CODEC_BUILD_DIR := $(CODEC_DIR)/build
|
||||||
|
CODEC_LIB := $(CODEC_BUILD_DIR)/basis.a
|
||||||
ENVIRONMENT = worker
|
ENVIRONMENT = worker
|
||||||
|
|
||||||
OUT_JS := enc/basis_enc.js dec/basis_dec.js
|
OUT_JS := enc/basis_enc.js dec/basis_dec.js
|
||||||
@@ -33,10 +35,8 @@ CODEC_C_SOURCE_FILES := \
|
|||||||
encoder/apg_bmp.c \
|
encoder/apg_bmp.c \
|
||||||
zstd/zstd.c
|
zstd/zstd.c
|
||||||
|
|
||||||
CODEC_CPP_OBJECT_FILES := $(CODEC_CPP_SOURCE_FILES:.cpp=.o)
|
CODEC_CPP_SOURCE_FILE_PATHS := $(addprefix $(CODEC_DIR)/, $(CODEC_CPP_SOURCE_FILES))
|
||||||
CODEC_C_OBJECT_FILES := $(CODEC_C_SOURCE_FILES:.c=.o)
|
CODEC_C_SOURCE_FILE_PATHS := $(addprefix $(CODEC_DIR)/, $(CODEC_C_SOURCE_FILES))
|
||||||
CODEC_CPP_OBJECT_FILE_PATHS := $(addprefix $(CODEC_DIR)/, $(CODEC_CPP_OBJECT_FILES))
|
|
||||||
CODEC_C_OBJECT_FILE_PATHS := $(addprefix $(CODEC_DIR)/, $(CODEC_C_OBJECT_FILES))
|
|
||||||
|
|
||||||
override CXXFLAGS += -DBASISU_FORCE_DEVEL_MESSAGES=1
|
override CXXFLAGS += -DBASISU_FORCE_DEVEL_MESSAGES=1
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ $(filter dec/%,$(OUT_JS)): dec/basis_dec.cpp
|
|||||||
|
|
||||||
# enc/mozjpeg_node_enc.js dec/mozjpeg_node_dec.js: ENVIRONMENT = node
|
# enc/mozjpeg_node_enc.js dec/mozjpeg_node_dec.js: ENVIRONMENT = node
|
||||||
|
|
||||||
%.js: $(CODEC_CPP_OBJECT_FILE_PATHS) $(CODEC_C_OBJECT_FILE_PATHS)
|
%.js: $(CODEC_LIB)
|
||||||
$(CXX) \
|
$(CXX) \
|
||||||
-I $(CODEC_DIR)/encoder \
|
-I $(CODEC_DIR)/encoder \
|
||||||
-I $(CODEC_DIR)/transcoder \
|
-I $(CODEC_DIR)/transcoder \
|
||||||
@@ -68,21 +68,21 @@ $(filter dec/%,$(OUT_JS)): dec/basis_dec.cpp
|
|||||||
-o $@ \
|
-o $@ \
|
||||||
$+
|
$+
|
||||||
|
|
||||||
$(CODEC_CPP_OBJECT_FILES): $(CODEC_DIR)
|
$(CODEC_LIB): $(CODEC_DIR)
|
||||||
|
mkdir -p $(CODEC_BUILD_DIR)
|
||||||
|
cd $(CODEC_BUILD_DIR) && \
|
||||||
$(CXX) \
|
$(CXX) \
|
||||||
${CXXFLAGS} \
|
${CXXFLAGS} \
|
||||||
-o $@ \
|
-c $(addprefix ../, $(CODEC_CPP_SOURCE_FILES))
|
||||||
-c $(@:.o=.cpp)
|
cd $(CODEC_BUILD_DIR) && \
|
||||||
|
|
||||||
$(CODEC_C_OBJECT_FILES): $(CODEC_DIR)
|
|
||||||
$(CC) \
|
$(CC) \
|
||||||
${CFLAGS} \
|
${CFLAGS} \
|
||||||
-o $@ \
|
-c $(addprefix ../, $(CODEC_C_SOURCE_FILES))
|
||||||
-c $(@:.o=.c)
|
$(AR) rc $(CODEC_LIB) $(CODEC_BUILD_DIR)/*.o
|
||||||
|
|
||||||
$(CODEC_DIR):
|
$(CODEC_DIR):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
|
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(OUT_JS) $(OUT_WASM)
|
$(RM) $(OUT_JS) $(OUT_WASM) $(CODEC_BUILD_DIR)
|
||||||
|
|||||||
104
codecs/basis/dec/basis_dec.js
generated
104
codecs/basis/dec/basis_dec.js
generated
@@ -971,9 +971,9 @@ function updateGlobalBufferAndViews(buf) {
|
|||||||
Module['HEAPF64'] = HEAPF64 = new Float64Array(buf);
|
Module['HEAPF64'] = HEAPF64 = new Float64Array(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
var STACK_BASE = 5776352,
|
var STACK_BASE = 5775920,
|
||||||
STACKTOP = STACK_BASE,
|
STACKTOP = STACK_BASE,
|
||||||
STACK_MAX = 533472;
|
STACK_MAX = 533040;
|
||||||
|
|
||||||
var TOTAL_STACK = 5242880;
|
var TOTAL_STACK = 5242880;
|
||||||
|
|
||||||
@@ -1418,12 +1418,6 @@ var ASM_CONSTS = {
|
|||||||
abort('Assertion failed: ' + UTF8ToString(condition) + ', at: ' + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
|
abort('Assertion failed: ' + UTF8ToString(condition) + ', at: ' + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ExceptionInfoAttrs={DESTRUCTOR_OFFSET:0,REFCOUNT_OFFSET:4,TYPE_OFFSET:8,CAUGHT_OFFSET:12,RETHROWN_OFFSET:13,SIZE:16};
|
|
||||||
function ___cxa_allocate_exception(size) {
|
|
||||||
// Thrown object is prepended by exception metadata block
|
|
||||||
return _malloc(size + ExceptionInfoAttrs.SIZE) + ExceptionInfoAttrs.SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _atexit(func, arg) {
|
function _atexit(func, arg) {
|
||||||
}
|
}
|
||||||
function ___cxa_thread_atexit(a0,a1
|
function ___cxa_thread_atexit(a0,a1
|
||||||
@@ -1431,88 +1425,6 @@ var ASM_CONSTS = {
|
|||||||
return _atexit(a0,a1);
|
return _atexit(a0,a1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ExceptionInfo(excPtr) {
|
|
||||||
this.excPtr = excPtr;
|
|
||||||
this.ptr = excPtr - ExceptionInfoAttrs.SIZE;
|
|
||||||
|
|
||||||
this.set_type = function(type) {
|
|
||||||
HEAP32[(((this.ptr)+(ExceptionInfoAttrs.TYPE_OFFSET))>>2)]=type;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.get_type = function() {
|
|
||||||
return HEAP32[(((this.ptr)+(ExceptionInfoAttrs.TYPE_OFFSET))>>2)];
|
|
||||||
};
|
|
||||||
|
|
||||||
this.set_destructor = function(destructor) {
|
|
||||||
HEAP32[(((this.ptr)+(ExceptionInfoAttrs.DESTRUCTOR_OFFSET))>>2)]=destructor;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.get_destructor = function() {
|
|
||||||
return HEAP32[(((this.ptr)+(ExceptionInfoAttrs.DESTRUCTOR_OFFSET))>>2)];
|
|
||||||
};
|
|
||||||
|
|
||||||
this.set_refcount = function(refcount) {
|
|
||||||
HEAP32[(((this.ptr)+(ExceptionInfoAttrs.REFCOUNT_OFFSET))>>2)]=refcount;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.set_caught = function (caught) {
|
|
||||||
caught = caught ? 1 : 0;
|
|
||||||
HEAP8[(((this.ptr)+(ExceptionInfoAttrs.CAUGHT_OFFSET))>>0)]=caught;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.get_caught = function () {
|
|
||||||
return HEAP8[(((this.ptr)+(ExceptionInfoAttrs.CAUGHT_OFFSET))>>0)] != 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.set_rethrown = function (rethrown) {
|
|
||||||
rethrown = rethrown ? 1 : 0;
|
|
||||||
HEAP8[(((this.ptr)+(ExceptionInfoAttrs.RETHROWN_OFFSET))>>0)]=rethrown;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.get_rethrown = function () {
|
|
||||||
return HEAP8[(((this.ptr)+(ExceptionInfoAttrs.RETHROWN_OFFSET))>>0)] != 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Initialize native structure fields. Should be called once after allocated.
|
|
||||||
this.init = function(type, destructor) {
|
|
||||||
this.set_type(type);
|
|
||||||
this.set_destructor(destructor);
|
|
||||||
this.set_refcount(0);
|
|
||||||
this.set_caught(false);
|
|
||||||
this.set_rethrown(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.add_ref = function() {
|
|
||||||
var value = HEAP32[(((this.ptr)+(ExceptionInfoAttrs.REFCOUNT_OFFSET))>>2)];
|
|
||||||
HEAP32[(((this.ptr)+(ExceptionInfoAttrs.REFCOUNT_OFFSET))>>2)]=value + 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Returns true if last reference released.
|
|
||||||
this.release_ref = function() {
|
|
||||||
var prev = HEAP32[(((this.ptr)+(ExceptionInfoAttrs.REFCOUNT_OFFSET))>>2)];
|
|
||||||
HEAP32[(((this.ptr)+(ExceptionInfoAttrs.REFCOUNT_OFFSET))>>2)]=prev - 1;
|
|
||||||
return prev === 1;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var exceptionLast=0;
|
|
||||||
|
|
||||||
function __ZSt18uncaught_exceptionv() { // std::uncaught_exception()
|
|
||||||
return __ZSt18uncaught_exceptionv.uncaught_exceptions > 0;
|
|
||||||
}
|
|
||||||
function ___cxa_throw(ptr, type, destructor) {
|
|
||||||
var info = new ExceptionInfo(ptr);
|
|
||||||
// Initialize ExceptionInfo content after it was allocated in __cxa_allocate_exception.
|
|
||||||
info.init(type, destructor);
|
|
||||||
exceptionLast = ptr;
|
|
||||||
if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) {
|
|
||||||
__ZSt18uncaught_exceptionv.uncaught_exceptions = 1;
|
|
||||||
} else {
|
|
||||||
__ZSt18uncaught_exceptionv.uncaught_exceptions++;
|
|
||||||
}
|
|
||||||
throw ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getShiftFromSize(size) {
|
function getShiftFromSize(size) {
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case 1: return 0;
|
case 1: return 0;
|
||||||
@@ -2619,9 +2531,7 @@ function intArrayToString(array) {
|
|||||||
__ATINIT__.push({ func: function() { ___wasm_call_ctors() } });
|
__ATINIT__.push({ func: function() { ___wasm_call_ctors() } });
|
||||||
var asmLibraryArg = {
|
var asmLibraryArg = {
|
||||||
"__assert_fail": ___assert_fail,
|
"__assert_fail": ___assert_fail,
|
||||||
"__cxa_allocate_exception": ___cxa_allocate_exception,
|
|
||||||
"__cxa_thread_atexit": ___cxa_thread_atexit,
|
"__cxa_thread_atexit": ___cxa_thread_atexit,
|
||||||
"__cxa_throw": ___cxa_throw,
|
|
||||||
"_embind_register_bool": __embind_register_bool,
|
"_embind_register_bool": __embind_register_bool,
|
||||||
"_embind_register_emval": __embind_register_emval,
|
"_embind_register_emval": __embind_register_emval,
|
||||||
"_embind_register_float": __embind_register_float,
|
"_embind_register_float": __embind_register_float,
|
||||||
@@ -2651,11 +2561,6 @@ var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() {
|
|||||||
return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments);
|
return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {function(...*):?} */
|
|
||||||
var _free = Module["_free"] = function() {
|
|
||||||
return (_free = Module["_free"] = Module["asm"]["free"]).apply(null, arguments);
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @type {function(...*):?} */
|
/** @type {function(...*):?} */
|
||||||
var _realloc = Module["_realloc"] = function() {
|
var _realloc = Module["_realloc"] = function() {
|
||||||
return (_realloc = Module["_realloc"] = Module["asm"]["realloc"]).apply(null, arguments);
|
return (_realloc = Module["_realloc"] = Module["asm"]["realloc"]).apply(null, arguments);
|
||||||
@@ -2666,6 +2571,11 @@ var _malloc = Module["_malloc"] = function() {
|
|||||||
return (_malloc = Module["_malloc"] = Module["asm"]["malloc"]).apply(null, arguments);
|
return (_malloc = Module["_malloc"] = Module["asm"]["malloc"]).apply(null, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @type {function(...*):?} */
|
||||||
|
var _free = Module["_free"] = function() {
|
||||||
|
return (_free = Module["_free"] = Module["asm"]["free"]).apply(null, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
/** @type {function(...*):?} */
|
/** @type {function(...*):?} */
|
||||||
var ___getTypeName = Module["___getTypeName"] = function() {
|
var ___getTypeName = Module["___getTypeName"] = function() {
|
||||||
return (___getTypeName = Module["___getTypeName"] = Module["asm"]["__getTypeName"]).apply(null, arguments);
|
return (___getTypeName = Module["___getTypeName"] = Module["asm"]["__getTypeName"]).apply(null, arguments);
|
||||||
|
|||||||
Binary file not shown.
@@ -21,7 +21,6 @@ val encode(std::string image_in, int image_width, int image_height, BasisOptions
|
|||||||
|
|
||||||
basist::etc1_global_selector_codebook sel_codebook(basist::g_global_selector_cb_size,
|
basist::etc1_global_selector_codebook sel_codebook(basist::g_global_selector_cb_size,
|
||||||
basist::g_global_selector_cb);
|
basist::g_global_selector_cb);
|
||||||
|
|
||||||
basis_compressor_params params;
|
basis_compressor_params params;
|
||||||
basis_compressor compressor;
|
basis_compressor compressor;
|
||||||
image img =
|
image img =
|
||||||
|
|||||||
14
codecs/basis/enc/basis_enc.js
generated
14
codecs/basis/enc/basis_enc.js
generated
@@ -971,9 +971,9 @@ function updateGlobalBufferAndViews(buf) {
|
|||||||
Module['HEAPF64'] = HEAPF64 = new Float64Array(buf);
|
Module['HEAPF64'] = HEAPF64 = new Float64Array(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
var STACK_BASE = 5878720,
|
var STACK_BASE = 5878144,
|
||||||
STACKTOP = STACK_BASE,
|
STACKTOP = STACK_BASE,
|
||||||
STACK_MAX = 635840;
|
STACK_MAX = 635264;
|
||||||
|
|
||||||
var TOTAL_STACK = 5242880;
|
var TOTAL_STACK = 5242880;
|
||||||
|
|
||||||
@@ -2971,11 +2971,6 @@ var ___wasm_call_ctors = Module["___wasm_call_ctors"] = function() {
|
|||||||
return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments);
|
return (___wasm_call_ctors = Module["___wasm_call_ctors"] = Module["asm"]["__wasm_call_ctors"]).apply(null, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @type {function(...*):?} */
|
|
||||||
var _free = Module["_free"] = function() {
|
|
||||||
return (_free = Module["_free"] = Module["asm"]["free"]).apply(null, arguments);
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @type {function(...*):?} */
|
/** @type {function(...*):?} */
|
||||||
var _realloc = Module["_realloc"] = function() {
|
var _realloc = Module["_realloc"] = function() {
|
||||||
return (_realloc = Module["_realloc"] = Module["asm"]["realloc"]).apply(null, arguments);
|
return (_realloc = Module["_realloc"] = Module["asm"]["realloc"]).apply(null, arguments);
|
||||||
@@ -2986,6 +2981,11 @@ var _malloc = Module["_malloc"] = function() {
|
|||||||
return (_malloc = Module["_malloc"] = Module["asm"]["malloc"]).apply(null, arguments);
|
return (_malloc = Module["_malloc"] = Module["asm"]["malloc"]).apply(null, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @type {function(...*):?} */
|
||||||
|
var _free = Module["_free"] = function() {
|
||||||
|
return (_free = Module["_free"] = Module["asm"]["free"]).apply(null, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
/** @type {function(...*):?} */
|
/** @type {function(...*):?} */
|
||||||
var ___getTypeName = Module["___getTypeName"] = function() {
|
var ___getTypeName = Module["___getTypeName"] = function() {
|
||||||
return (___getTypeName = Module["___getTypeName"] = Module["asm"]["__getTypeName"]).apply(null, arguments);
|
return (___getTypeName = Module["___getTypeName"] = Module["asm"]["__getTypeName"]).apply(null, arguments);
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user