Skip to content

Commit

Permalink
Merge pull request #19 from birros/feat/av1
Browse files Browse the repository at this point in the history
feat: add av1 support
  • Loading branch information
birros authored Aug 30, 2023
2 parents 2dfe071 + 474275d commit 77caf9c
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
clang 14.0.3
cmake 3.27.0
golang 1.20.5
macos 13.5
cmake 3.27.4
golang 1.21.0
macos 13.5.1
make 3.81
meson 1.2.0
meson 1.2.1
ninja 1.11.1
xcode 14.3.1
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,46 @@ ${INTERMEDIATE_DIR}/pkg-config_%: \

rm -rf ${TARGET_TMP_DIR}

# dav1d_<os>-<arch>
${INTERMEDIATE_DIR}/dav1d_%: \
${DOWNLOADS_DIR} \
${PKGCONFIG_DIR}

@echo "\033[32mRULE\033[0m $@"

$(eval TARGET_DIR=$@)
$(eval TARGET_PATTERN=$*)
$(eval TARGET_NAME=$(notdir ${TARGET_DIR}))
$(eval TARGET_PKGNAME=$(firstword $(subst _${TARGET_PATTERN}, ,${TARGET_NAME})))
$(eval TARGET_TMP_DIR=${TMP_DIR}/${TARGET_NAME})
$(eval TARGET_SRC_DIR=${TARGET_TMP_DIR}/src/${TARGET_PKGNAME})
$(eval TARGET_OUTPUT_DIR=${PROJECT_DIR}/${TARGET_DIR})

$(eval ARCHIVE_FILE=$(firstword $(wildcard ${DOWNLOADS_DIR}/${TARGET_PKGNAME}-*.tar.*)))

$(eval TARGET_OS=$(word 1, $(subst -, ,${TARGET_PATTERN})))
$(eval TARGET_ARCH=$(word 2, $(subst -, ,${TARGET_PATTERN})))

rm -rf ${TARGET_TMP_DIR} ${TARGET_DIR}
mkdir -p ${TARGET_TMP_DIR}

env -i \
PATH=${SANDBOX_PATH} \
ARCHIVE_FILE=${ARCHIVE_FILE} \
TARGET_DIR=${TARGET_SRC_DIR} \
sh ${PROJECT_DIR}/scripts/extract/build.sh

env -i \
PATH=${SANDBOX_PATH} \
PROJECT_DIR=${PROJECT_DIR} \
OS=${TARGET_OS} \
ARCH=${TARGET_ARCH} \
SRC_DIR=${TARGET_SRC_DIR} \
OUTPUT_DIR=${TARGET_OUTPUT_DIR} \
sh ${PROJECT_DIR}/scripts/${TARGET_PKGNAME}/build.sh

rm -rf ${TARGET_TMP_DIR}

# libressl_<os>-<arch>
${INTERMEDIATE_DIR}/libressl_%: \
${DOWNLOADS_DIR} \
Expand Down Expand Up @@ -303,6 +343,7 @@ ${INTERMEDIATE_DIR}/ffmpeg_%: \
${PKGCONFIG_DIR} \
${INTERMEDIATE_DIR}/libressl_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \
$$(if $$(filter video, $$(word 3,$$(subst -, ,$$*))), \
${INTERMEDIATE_DIR}/dav1d_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \
${INTERMEDIATE_DIR}/libxml2_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \
)

Expand Down Expand Up @@ -646,6 +687,7 @@ ${INTERMEDIATE_DIR}/libs-arch_%: \
${INTERMEDIATE_DIR}/ffmpeg_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*))-$$(word 3,$$(subst -, ,$$*))-$$(word 4,$$(subst -, ,$$*)) \
${INTERMEDIATE_DIR}/libressl_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \
$$(if $$(filter video, $$(word 3,$$(subst -, ,$$*))), \
${INTERMEDIATE_DIR}/dav1d_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \
${INTERMEDIATE_DIR}/libxml2_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \
${INTERMEDIATE_DIR}/uchardet_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \
${INTERMEDIATE_DIR}/libass_$$(word 1,$$(subst -, ,$$*))-$$(word 2,$$(subst -, ,$$*)) \
Expand Down Expand Up @@ -852,6 +894,7 @@ update-downloads-lock:
ffmpeg \
libressl \
libxml2 \
dav1d \
)

go run cmd/update-downloads-lock/main.go ${DEPS} > downloads.lock
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ A(mpv) --> B(ffmpeg)
A(mpv) -.-> C(libass)
A(mpv) -.-> D(uchardet)
B -.-> H(libressl)
B -.-> I(libxml2)
B -.-> H(dav1d)
B -.-> I(libressl)
B -.-> J(libxml2)
C --> E(freetype)
C --> F(harfbuzz)
Expand Down Expand Up @@ -130,6 +131,9 @@ E -.-> F
and laying out text in multiple languages and scripts, with support for
advanced typography features such as ligatures and kerning

- **[dav1d](https://code.videolan.org/videolan/dav1d) (optional)**: A library
for cross-platform AV1 decoding

- **[libressl](https://www.libressl.org/) (optional)**: A fork of OpenSSL that
aims to provide a more secure and auditable implementation of the SSL/TLS
protocols
Expand All @@ -154,6 +158,7 @@ E -.-> F
| libressl | Apache-1.0, BSD-4-Clause, ISC, public domain ||
| uchardet | MPL-1.1, GPL-2, LGPL-2.1 ||
| libxml2 | MIT ||
| dav1d | BSD-2-clause ||

## Notes

Expand Down
22 changes: 13 additions & 9 deletions downloads.lock
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
dav1d:
version: 1.2.1
url: https://code.videolan.org/videolan/dav1d/-/archive/1.2.1/dav1d-1.2.1.tar.bz2
sha256: a4003623cdc0109dec3aac8435520aa3fb12c4d69454fa227f2658cdb6dab5fa
ffmpeg:
version: "6.0"
url: https://ffmpeg.org/releases/ffmpeg-6.0.tar.xz
sha256: 57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
freetype:
version: 2.13.1
url: https://downloads.sourceforge.net/project/freetype/freetype2/2.13.1/freetype-2.13.1.tar.xz
sha256: ea67e3b019b1104d1667aa274f5dc307d8cbd606b399bc32df308a77f1a564bf
version: 2.13.2
url: https://downloads.sourceforge.net/project/freetype/freetype2/2.13.2/freetype-2.13.2.tar.xz
sha256: 12991c4e55c506dd7f9b765933e62fd2be2e06d421505d7950a132e4f1bb484d
fribidi:
version: 1.0.13
url: https://github.com/fribidi/fribidi/releases/download/v1.0.13/fribidi-1.0.13.tar.xz
sha256: 7fa16c80c81bd622f7b198d31356da139cc318a63fc7761217af4130903f54a2
harfbuzz:
version: 8.0.1
url: https://github.com/harfbuzz/harfbuzz/archive/8.0.1.tar.gz
sha256: d54ca67b6a0bf732b66a343566446d7f93df2bb850133f886c0082fb618a06b2
version: 8.1.1
url: https://github.com/harfbuzz/harfbuzz/archive/8.1.1.tar.gz
sha256: b16e6bc0fc7e6a218583f40c7d201771f2e3072f85ef6e9217b36c1dc6b2aa25
libass:
version: 0.17.1
url: https://github.com/libass/libass/releases/download/0.17.1/libass-0.17.1.tar.xz
Expand All @@ -23,9 +27,9 @@ libressl:
url: https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.7.3.tar.gz
sha256: 7948c856a90c825bd7268b6f85674a8dcd254bae42e221781b24e3f8dc335db3
libxml2:
version: 2.11.4
url: https://download.gnome.org/sources/libxml2/2.11/libxml2-2.11.4.tar.xz
sha256: 737e1d7f8ab3f139729ca13a2494fd17bf30ddb4b7a427cf336252cab57f57f7
version: 2.11.5
url: https://download.gnome.org/sources/libxml2/2.11/libxml2-2.11.5.tar.xz
sha256: 3727b078c360ec69fa869de14bd6f75d7ee8d36987b071e6928d4720a28df3a6
mpv:
version: 0.36.0
url: https://github.com/mpv-player/mpv/archive/refs/tags/v0.36.0.tar.gz
Expand Down
24 changes: 24 additions & 0 deletions scripts/dav1d/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -e # exit immediately if a command exits with a non-zero status
set -u # treat unset variables as an error

cd ${SRC_DIR}
meson setup build \
--cross-file ${PROJECT_DIR}/cross-files/${OS}-${ARCH}.ini \
--prefix="${OUTPUT_DIR}" \
-Dbitdepths="['8', '16']" \
-Denable_asm=false \
-Denable_tools=false \
-Denable_examples=false \
-Denable_tests=false \
-Denable_docs=false \
-Dlogging=true \
-Dtestdata_tests=false \
-Dfuzzing_engine=none \
-Dfuzzer_ldflags= \
-Dstack_alignment=0 \
-Dxxhash_muxer=auto \
-Dtrim_dsp=if-release
meson compile -C build
meson install -C build
3 changes: 2 additions & 1 deletion scripts/ffmpeg/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ video_common_options = [
'--enable-neon', # improve hevc (h265) support on arm
'--enable-libxml2', # dash support
'--enable-videotoolbox',
'--enable-libdav1d', # av1 support
]

# https://github.com/media-kit/libmpv-android-audio-build/blob/260666c0fef8c154971b5faf3f78da27c2bf2c40/buildscripts/flavors/default.sh
Expand Down Expand Up @@ -183,7 +184,7 @@ video_default_options = [
'--enable-decoder=vp9', # vp9*
'--enable-decoder=hevc', # hevc*
'--enable-decoder=av1', # av1*
# '--enable-decoder=libdav1d', # --enable-libdav1d required
'--enable-decoder=libdav1d',
'--enable-decoder=theora',
'--enable-decoder=msmpeg4v1', # msmpeg*
'--enable-decoder=msmpeg4v2', # msmpeg*
Expand Down

0 comments on commit 77caf9c

Please sign in to comment.