Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmercerind committed Oct 13, 2024
1 parent 186205a commit 453ef51
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 67 deletions.
20 changes: 6 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,24 @@ on:
permissions:
contents: write

env:
NDK_VER: 25.1.8937393

jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3.3.0
uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/setup-java@v3.9.0
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Setup Flutter SDK
uses: subosito/flutter-action@v1
with:
channel: "stable"
- name: Gradle Build Action
uses: gradle/[email protected]
- name: Cache
uses: actions/[email protected]
with:
path: /usr/local/lib/android/sdk/ndk/${{ env.NDK_VER }}
key: ${{ runner.os }}-${{ env.NDK_VER }}
- name: Symlink SDK
working-directory: ./buildscripts
run: |
Expand All @@ -55,7 +47,7 @@ jobs:
run: |
sudo chmod +x bundle_encoders-gpl.sh
./bundle_encoders-gpl.sh
- uses: actions/upload-artifact@v3.1.2
- uses: actions/upload-artifact@v4
with:
name: artifact
path: ./output/*
Expand Down
8 changes: 5 additions & 3 deletions buildscripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ loadarch () {
export AS="nasm"
fi
export CXX=$cc_triple-clang++
export LDFLAGS="-Wl,-O1,--icf=safe -Wl,-z,max-page-size=16384"
export AR=llvm-ar
export RANLIB=llvm-ranlib
}
Expand Down Expand Up @@ -81,9 +82,10 @@ wrap_mode = 'nodownload'
[binaries]
c = '$CC'
cpp = '$CXX'
ar = '$AR'
strip = '$ndk_triple-strip'
pkgconfig = 'pkg-config'
ar = 'llvm-ar'
nm = 'llvm-nm'
strip = 'llvm-strip'
pkg-config = 'pkg-config'
[host_machine]
system = 'android'
cpu_family = '$cpu_family'
Expand Down
2 changes: 2 additions & 0 deletions buildscripts/bundle_default.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
set -e

# --------------------------------------------------

if [ ! -f "deps" ]; then
Expand Down
2 changes: 2 additions & 0 deletions buildscripts/bundle_encoders-gpl.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
set -e

# --------------------------------------------------
set -euxo pipefail

Expand Down
2 changes: 2 additions & 0 deletions buildscripts/bundle_full.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
set -e

# --------------------------------------------------

if [ ! -f "deps" ]; then
Expand Down
18 changes: 15 additions & 3 deletions buildscripts/flavors/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cpuflags=

../configure \
--target-os=android --enable-cross-compile --cross-prefix=$ndk_triple- --ar=$AR --cc=$CC --ranlib=$RANLIB \
--arch=${ndk_triple%%-*} --cpu=$cpu --pkg-config=pkg-config \
--arch=${ndk_triple%%-*} --cpu=$cpu --pkg-config=pkg-config --nm=llvm-nm \
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \
\
--disable-gpl \
Expand Down Expand Up @@ -144,6 +144,17 @@ cpuflags=
--enable-decoder=webvtt \
--enable-decoder=movtext \
\
--enable-decoder=mjpeg \
--enable-decoder=ljpeg \
--enable-decoder=jpegls \
--enable-decoder=jpeg2000 \
--enable-decoder=png \
--enable-decoder=gif \
--enable-decoder=bmp \
--enable-decoder=tiff \
--enable-decoder=webp \
--enable-decoder=jpegls \
\
--enable-demuxer=concat \
--enable-demuxer=data \
--enable-demuxer=flv \
Expand Down Expand Up @@ -191,8 +202,8 @@ cpuflags=
--enable-demuxer=xwma \
--enable-demuxer=dsf \
--enable-demuxer=truehd \
--enable-demuxer=dts \
--enable-demuxer=dtshd \
--enable-demuxer=dts \
--enable-demuxer=dtshd \
\
--enable-demuxer=ass \
--enable-demuxer=srt \
Expand Down Expand Up @@ -244,6 +255,7 @@ cpuflags=
--enable-protocol=tcp \
--enable-protocol=tls \
--enable-protocol=srt \
--enable-protocol=udp \
\
--enable-encoder=mjpeg \
--enable-encoder=ljpeg \
Expand Down
5 changes: 2 additions & 3 deletions buildscripts/flavors/encoders-gpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cpuflags=

../configure \
--target-os=android --enable-cross-compile --cross-prefix=$ndk_triple- --ar=$AR --cc=$CC --ranlib=$RANLIB \
--arch=${ndk_triple%%-*} --cpu=$cpu --pkg-config=pkg-config \
--arch=${ndk_triple%%-*} --cpu=$cpu --pkg-config=pkg-config --nm=llvm-nm \
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \
--pkg-config-flags="--static" \
\
Expand Down Expand Up @@ -87,8 +87,6 @@ cpuflags=
--enable-swscale \
--enable-swresample \
\
\
\
--enable-filters \
\
--enable-protocol=async \
Expand All @@ -112,6 +110,7 @@ cpuflags=
--enable-protocol=tcp \
--enable-protocol=tls \
--enable-protocol=srt \
--enable-protocol=udp \
\
--enable-network \

Expand Down
5 changes: 2 additions & 3 deletions buildscripts/flavors/full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cpuflags=

../configure \
--target-os=android --enable-cross-compile --cross-prefix=$ndk_triple- --ar=$AR --cc=$CC --ranlib=$RANLIB \
--arch=${ndk_triple%%-*} --cpu=$cpu --pkg-config=pkg-config \
--arch=${ndk_triple%%-*} --cpu=$cpu --pkg-config=pkg-config --nm=llvm-nm \
--extra-cflags="-I$prefix_dir/include $cpuflags" --extra-ldflags="-L$prefix_dir/lib" \
\
--disable-gpl \
Expand Down Expand Up @@ -84,8 +84,6 @@ cpuflags=
--enable-swscale \
--enable-swresample \
\
\
\
--enable-filter=overlay \
--enable-filter=equalizer \
\
Expand All @@ -110,6 +108,7 @@ cpuflags=
--enable-protocol=tcp \
--enable-protocol=tls \
--enable-protocol=srt \
--enable-protocol=udp \
\
--enable-encoder=mjpeg \
--enable-encoder=ljpeg \
Expand Down
28 changes: 15 additions & 13 deletions buildscripts/include/depinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

## Dependency versions

v_sdk=9123335_latest
v_ndk=25.2.9519653
v_sdk_build_tools=33.0.2
v_sdk=11076708_latest
v_ndk=27.1.12297006
v_sdk_build_tools=35.0.0

v_libass=0.17.1
v_harfbuzz=7.2.0
v_fribidi=1.0.12
v_freetype=2-13-0
v_mbedtls=3.4.0
v_dav1d=1.2.0
v_libass=0.17.3
v_harfbuzz=10.0.1
v_fribidi=1.0.16
v_freetype=2-13-3
v_mbedtls=3.6.1
v_libplacebo=7.349.0
v_dav1d=1.4.3
v_libxml2=2.10.3
v_ffmpeg=6.0
v_mpv=78d43740f52db817d98bcf24fb30a76ab6fa13ff
v_ffmpeg=7.1
v_mpv=0.39.0
v_libogg=1.3.5
v_libvorbis=1.3.7
v_libvpx=1.13
Expand All @@ -37,8 +38,9 @@ dep_harfbuzz=()
dep_libass=(freetype fribidi harfbuzz)
dep_lua=()
dep_shaderc=()
dep_libplacebo=()
if [ -n "$ENCODERS_GPL" ]; then
dep_mpv=(ffmpeg libass fftools_ffi)
dep_mpv=(ffmpeg libass libplacebo fftools_ffi)
else
dep_mpv=(ffmpeg libass)
dep_mpv=(ffmpeg libass libplacebo)
fi
7 changes: 5 additions & 2 deletions buildscripts/include/download-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mkdir -p deps && cd deps

# mbedtls
[ ! -d mbedtls ] && git clone --depth 1 --branch v$v_mbedtls https://github.com/Mbed-TLS/mbedtls.git mbedtls
[ ! -d mbedtls ] && git clone --depth 1 --branch v$v_mbedtls --recurse-submodules https://github.com/Mbed-TLS/mbedtls.git mbedtls

# dav1d
[ ! -d dav1d ] && git clone --depth 1 --branch $v_dav1d https://code.videolan.org/videolan/dav1d.git dav1d
Expand Down Expand Up @@ -49,14 +49,17 @@ Shaderc sources are provided by the NDK.
see <ndk>/sources/third_party/shaderc
HEREDOC

# libplacebo
[ ! -d libplacebo ] && git clone --depth 1 --branch v$v_libplacebo --recurse-submodules https://code.videolan.org/videolan/libplacebo.git libplacebo

# mpv
[ ! -d mpv ] && git clone https://github.com/mpv-player/mpv.git mpv && cd mpv && git reset --hard 78d43740f52db817d98bcf24fb30a76ab6fa13ff && cd ..

# fftools_ffi
[ ! -d fftools_ffi ] && git clone --depth 1 --branch main https://github.com/moffatman/fftools-ffi.git fftools_ffi

# media-kit-android-helper
[ ! -d media-kit-android-helper ] && git clone --depth 1 --branch fix/no-dup-fd https://github.com/media-kit/media-kit-android-helper.git
[ ! -d media-kit-android-helper ] && git clone --depth 1 --branch main https://github.com/media-kit/media-kit-android-helper.git

# media_kit
[ ! -d media_kit ] && git clone --depth 1 --single-branch --branch main https://github.com/alexmercerind/media_kit.git
Expand Down
8 changes: 4 additions & 4 deletions buildscripts/include/download-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ if [ "$os" == "linux" ]; then
hash yum &>/dev/null && {
sudo yum install autoconf pkgconfig libtool ninja-build unzip \
python3-pip python3-setuptools unzip wget;
sudo pip3 install meson; }
python3 -m pip install meson jsonschema jinja2; }
apt-get -v &>/dev/null && {
sudo apt-get update;
sudo apt-get install -y autoconf pkg-config libtool ninja-build nasm unzip \
python3-pip python3-setuptools unzip;
sudo pip3 install meson; }
python3 -m pip install meson jsonschema jinja2; }
fi

if ! javac -version &>/dev/null; then
Expand Down Expand Up @@ -61,10 +61,10 @@ sdkmanager () {
"$exe" --sdk_root="${ANDROID_HOME}" "$@"
}
echo y | sdkmanager \
"platforms;android-33" \
"platforms;android-35" \
"build-tools;${v_sdk_build_tools}" \
"ndk;${v_ndk}" \
"cmake;3.22.1"
"cmake;3.30.3"

# gas-preprocessor
mkdir -p bin
Expand Down
81 changes: 81 additions & 0 deletions buildscripts/patches/ffmpeg/av1_mediacodec.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
diff --git a/configure b/configure
index ba5793b..b73af74 100755
--- a/configure
+++ b/configure
@@ -3163,6 +3163,7 @@ nvenc_deps_any="libdl LoadLibrary"
aac_mf_encoder_deps="mediafoundation"
ac3_mf_encoder_deps="mediafoundation"
av1_cuvid_decoder_deps="cuvid CUVIDAV1PICPARAMS"
+av1_mediacodec_decoder_deps="mediacodec"
h263_v4l2m2m_decoder_deps="v4l2_m2m h263_v4l2_m2m"
h263_v4l2m2m_encoder_deps="v4l2_m2m h263_v4l2_m2m"
h264_amf_encoder_deps="amf"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 457ec58..0b95b65 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -241,6 +241,7 @@ OBJS-$(CONFIG_AURA_DECODER) += cyuv.o
OBJS-$(CONFIG_AURA2_DECODER) += aura.o
OBJS-$(CONFIG_AV1_DECODER) += av1dec.o
OBJS-$(CONFIG_AV1_CUVID_DECODER) += cuviddec.o
+OBJS-$(CONFIG_AV1_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_AVRN_DECODER) += avrndec.o
OBJS-$(CONFIG_AVRP_DECODER) += r210dec.o
OBJS-$(CONFIG_AVRP_ENCODER) += r210enc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index bdfc2f6..5c35444 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -815,6 +815,7 @@ extern const FFCodec ff_libaom_av1_decoder;
/* hwaccel hooks only, so prefer external decoders */
extern const FFCodec ff_av1_decoder;
extern const FFCodec ff_av1_cuvid_decoder;
+extern const FFCodec ff_av1_mediacodec_decoder;
extern const FFCodec ff_av1_qsv_decoder;
extern const FFCodec ff_libopenh264_encoder;
extern const FFCodec ff_libopenh264_decoder;
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index 6b4c39b..49f118e 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -1,5 +1,5 @@
/*
- * Android MediaCodec MPEG-2 / H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
+ * Android MediaCodec MPEG-2 / H.264 / H.265 / MPEG-4 / VP8 / VP9 / AV1 decoders
*
* Copyright (c) 2015-2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
*
@@ -287,7 +287,8 @@ done:
#if CONFIG_MPEG2_MEDIACODEC_DECODER || \
CONFIG_MPEG4_MEDIACODEC_DECODER || \
CONFIG_VP8_MEDIACODEC_DECODER || \
- CONFIG_VP9_MEDIACODEC_DECODER
+ CONFIG_VP9_MEDIACODEC_DECODER || \
+ CONFIG_AV1_MEDIACODEC_DECODER
static int common_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
{
int ret = 0;
@@ -372,6 +373,15 @@ static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
goto done;
break;
#endif
+#if CONFIG_AV1_MEDIACODEC_DECODER
+ case AV_CODEC_ID_AV1:
+ codec_mime = "video/av01";
+
+ ret = common_set_extradata(avctx, format);
+ if (ret < 0)
+ goto done;
+ break;
+#endif
default:
av_assert0(0);
}
@@ -573,3 +583,7 @@ DECLARE_MEDIACODEC_VDEC(vp8, "VP8", AV_CODEC_ID_VP8, NULL)
#if CONFIG_VP9_MEDIACODEC_DECODER
DECLARE_MEDIACODEC_VDEC(vp9, "VP9", AV_CODEC_ID_VP9, NULL)
#endif
+
+#if CONFIG_AV1_MEDIACODEC_DECODER
+DECLARE_MEDIACODEC_VDEC(av1, "AV1", AV_CODEC_ID_AV1, NULL)
+#endif
14 changes: 0 additions & 14 deletions buildscripts/patches/ffmpeg/hls_mp4_seek.patch

This file was deleted.

Loading

0 comments on commit 453ef51

Please sign in to comment.