Skip to content

Commit

Permalink
Encoder working, decoder isnt
Browse files Browse the repository at this point in the history
  • Loading branch information
surma authored Oct 25, 2023
1 parent f27d524 commit 47cd47e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
9 changes: 2 additions & 7 deletions codecs/avif/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
CODEC_URL = https://github.com/AOMediaCodec/libavif/archive/refs/tags/v1.0.1.tar.gz
CODEC_PACKAGE = node_modules/libavif.tar.gz

# Take from libavif/ext/libsharpyuv.cmd
WEBP_URL = https://chromium.googlesource.com/webm/libwebp
WEBP_COMMIT = e2c85878f6a33f29948b43d3492d9cdaf801aa54

# using libaom from https://aomedia.googlesource.com/aom
LIBAOM_URL = https://aomedia.googlesource.com/aom/+archive/v3.7.0.tar.gz
LIBAOM_PACKAGE = node_modules/libaom.tar.gz

export CODEC_DIR = node_modules/libavif
export BUILD_DIR = node_modules/build
export LIBAOM_DIR = node_modules/libaom
export LIBSHARPYUV_DIR = node_modules/libavif/ext/libwebp

override CFLAGS += "-Wno-unused-macros"

Expand All @@ -30,7 +25,7 @@ ENVIRONMENT = worker

HELPER_MAKEFLAGS := -f helper.Makefile

.PHONY: buildsharp all clean
.PHONY: all clean

all: $(OUT_ENC_JS) $(OUT_DEC_JS) $(OUT_ENC_MT_JS)

Expand Down Expand Up @@ -70,7 +65,7 @@ $(OUT_DEC_JS): $(OUT_DEC_CPP) $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_DIR)/CMakeLis
-DCONFIG_MULTITHREAD=0 \
" \
ENVIRONMENT=$(ENVIRONMENT) \
LIBAVIF_FLAGS="-DAVIF_CODEC_AOM_ENCODE=0 -DAVIF_LOCAL_LIBSHARPYUV=ON"
LIBAVIF_FLAGS="-DAVIF_CODEC_AOM_ENCODE=0"

$(CODEC_PACKAGE):
mkdir -p $(@D)
Expand Down
2 changes: 1 addition & 1 deletion codecs/avif/enc/avif_enc_mt.js

Large diffs are not rendered by default.

Binary file modified codecs/avif/enc/avif_enc_mt.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion codecs/avif/enc/avif_enc_mt.worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions codecs/avif/helper.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
# $(LIBAVIF_FLAGS)
# $(ENVIRONMENT)

# Take from libavif/ext/libsharpyuv.cmd
WEBP_URL = https://chromium.googlesource.com/webm/libwebp
WEBP_COMMIT = e2c85878f6a33f29948b43d3492d9cdaf801aa54
LIBSHARPYUV_DIR = $(CODEC_DIR)/ext/libwebp

# $(OUT_JS) is something like "enc/avif_enc.js" or "enc/avif_enc_mt.js"
OUT_BUILD_DIR := $(BUILD_DIR)/$(basename $(OUT_JS))

CODEC_BUILD_DIR := $(OUT_BUILD_DIR)/libavif
Expand All @@ -28,7 +34,14 @@ OUT_WORKER=$(OUT_JS:.js=.worker.js)

all: $(OUT_JS)

$(OUT_JS): $(OUT_CPP) $(LIBAOM_OUT) $(CODEC_OUT) $(LIBSHARPYUV_OUT)
# Only add libsharpyuv as a dependency for encoders.
# Yes, that if statement is true for encoders.
ifneq (,$(findstring enc/, $(OUT_JS)))
$(OUT_JS): $(LIBSHARPYUV_OUT)
$(CODEC_OUT): $(LIBSHARPYUV_OUT)
endif

$(OUT_JS): $(OUT_CPP) $(LIBAOM_OUT) $(CODEC_OUT)
$(CXX) \
-I $(CODEC_DIR)/include \
$(CXXFLAGS) \
Expand All @@ -40,9 +53,9 @@ $(OUT_JS): $(OUT_CPP) $(LIBAOM_OUT) $(CODEC_OUT) $(LIBSHARPYUV_OUT)
-o $@ \
$+

$(CODEC_OUT): $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_OUT) $(LIBSHARPYUV_OUT)
$(CODEC_OUT): $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_OUT)
emcmake cmake \
-DCMAKE_LIBRARY_PATY=$(LIBSHARPYUV_BUILD_DIR) \
-DCMAKE_LIBRARY_PATH=$(LIBSHARPYUV_BUILD_DIR) \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=0 \
-DAVIF_CODEC_AOM=1 \
Expand Down

0 comments on commit 47cd47e

Please sign in to comment.