Skip to content

Commit

Permalink
Update benchmark after changes in implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Nov 23, 2024
1 parent bd6af8e commit fe70adc
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 12 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ stub library (build without FFmpeg back-end). See previous paragraph for the mea
Below is the result of a small benchmark test performed with various apt-X encoding libraries.
Test was done with the usage of `aptxenc` and `aptxhdenc` tools from this repository.
Elapsed user time was calculated with the usage of a standard UNIX `time` command line tool. All
libraries (except original Qualcomm libraries) were compiled with Clang version 8.0.7 with the
`O2` or `O3` optimization level.
libraries (except original Qualcomm libraries) were compiled with Clang version 9.0.0 with the
`O3` optimization level.

### Setup

Expand All @@ -52,15 +52,15 @@ libraries (except original Qualcomm libraries) were compiled with Clang version

### Results

| Library | apt-X | Mbit/s | apt-X HD | Mbit/s |
|----------------------------------------|-----------|---------|-----------|---------|
| [libaptX-1.0.16-rel-Android21][1] | 1m00.370s | 1.23673 | — | — |
| [libaptXHD-1.0.1-rel-Android21][1] | — | — | 1m07.030s | 1.11109 |
| openaptx-stub | 0m04.480s | 0.0 | 0m04.820s | 0.0 |
| openaptx-ffmpeg (libavcodec-58.54.100) | 1m58.100s | 0.60835 | 2m03.270s | 0.58354 |
| aptx422 | 1m19.840s | 0.91721 | — | — |
| aptxHD100 | — | — | 1m21.950s | 0.89616 |
| [libopenaptx-0.2.0][2] | 1m22.090s | 0.89062 | 1m25.730s | 0.85429 |
| Library | apt-X | Mbit/s | apt-X HD | Mbit/s |
|----------------------------------------|---------|---------|----------|---------|
| [libaptX-1.0.16-rel-Android21][1] | 1m01s | 23.8 | — | — |
| [libaptXHD-1.0.1-rel-Android21][1] | — | — | 1m04s | 22.7 |
| openaptx-stub | 0m11s | 0.0 | 0m11s | 0.0 |
| openaptx-ffmpeg (libavcodec-59.37.100) | 2m12s | 11.0 | 2m18s | 10.5 |
| aptx422 | 1m14s | 19.6 | — | — |
| aptxHD100 | — | — | 1m16s | 19.1 |
| [libopenaptx-0.2.0][2] | 1m17s | 18.8 | 1m19s | 18.4 |

[1]: archive/aarch64 "Archive with Qualcomm apt-X encoding libraries"
[2]: https://github.com/pali/libopenaptx "The apt-X encoder/decoder based on FFmpeg code"
Expand Down
2 changes: 1 addition & 1 deletion src/aptx-stub.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* [open]aptx - stub-aptx.c
* [open]aptx - aptx-stub.c
* Copyright (c) 2017-2024 Arkadiusz Bokowy
*
* This file is a part of [open]aptx.
Expand Down
105 changes: 105 additions & 0 deletions test/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/sh
# Copyright (c) 2017-2024 Arkadiusz Bokowy

if [ -z "$1" ]; then
echo "Usage: $0 <audio-file>"
exit 1
fi

if ! [ -f "input.wav" ]; then
# Convert audio to WAV in order to skip decoding when running benchmarks.
ffmpeg -i "$1" -ar 48000 -ac 2 -y input.wav
fi

if ! [ -d "FFmpeg" ]; then
# Compile FFmpeg with aptX and aptX HD support.
git clone --depth=1 --branch=n5.1.6 https://github.com/FFmpeg/FFmpeg.git
(cd FFmpeg || exit
./configure \
--disable-static --disable-autodetect --disable-programs --disable-doc \
--disable-avdevice --disable-avformat --disable-avfilter \
--disable-swresample --disable-swscale --disable-postproc \
--disable-everything \
--enable-encoder=aptx --enable-muxer=aptx \
--enable-encoder=aptx_hd --enable-muxer=aptx_hd \
--enable-shared --extra-cflags="-O3"
make
)
fi

if ! [ -d "libfreeaptx" ]; then
# Compile freeaptx (FFmpeg-based) to compare it with our implementation.
git clone https://github.com/iamthehorker/libfreeaptx
(cd libfreeaptx || exit
CC=clang make
)
fi

# Save the original LD_LIBRARY_PATH for later use.
LD_LIBRARY_PATH_SAVED=$LD_LIBRARY_PATH

# Compile stub libraries to get baseline timings.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_SNDFILE=ON \
-DENABLE_APTX422=OFF -DENABLE_APTXHD100=OFF -DWITH_FFMPEG=OFF -DWITH_FREEAPTX=OFF
cmake --build build

export LD_LIBRARY_PATH=$PWD/build/src:$LD_LIBRARY_PATH_SAVED

echo "openaptx-stub-aptX"
time build/utils/aptxenc input.wav >/dev/null
echo "openaptx-stub-aptX (HD)"
time build/utils/aptxhdenc input.wav >/dev/null

# Prepare reverse-engineered libraries.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_SNDFILE=ON \
-DENABLE_APTX422=ON -DENABLE_APTXHD100=ON -DWITH_FFMPEG=OFF -DWITH_FREEAPTX=OFF \
-DCMAKE_C_FLAGS_RELEASE="-O3"
cmake --build build

export LD_LIBRARY_PATH=$PWD/build:$LD_LIBRARY_PATH_SAVED

echo "libaptX-4.2.2"
ln -srf build/src/libaptx-4.2.2.so build/libaptx.so
time build/utils/aptxenc input.wav >/dev/null
echo "libaptXHD-1.0.0"
ln -srf build/src/libaptxHD-1.0.0.so build/libaptx.so
time build/utils/aptxhdenc input.wav >/dev/null

# Prepare FFmpeg backend.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_SNDFILE=ON \
-DWITH_FFMPEG=ON -DWITH_FREEAPTX=OFF \
-Dpkgcfg_lib_FFLibAVCodec_avcodec=FFmpeg/libavcodec/libavcodec.so \
-Dpkgcfg_lib_FFLibAVCodec_avutil=FFmpeg/libavutil/libavutil.so \
-DCMAKE_C_FLAGS_RELEASE="-O3 -I$PWD/FFmpeg"
cmake --build build

export LD_LIBRARY_PATH=$PWD/build/src:$PWD/FFmpeg/libavcodec:$PWD/FFmpeg/libavutil:$LD_LIBRARY_PATH_SAVED

echo "openaptx-ffmpeg-aptX"
time build/utils/aptxenc input.wav >/dev/null
echo "openaptx-ffmpeg-aptX (HD)"
time build/utils/aptxhdenc input.wav >/dev/null

# Prepare freeaptx backend.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_SNDFILE=ON \
-DWITH_FFMPEG=OFF -DWITH_FREEAPTX=ON \
-Dpkgcfg_lib_FreeAptX_freeaptx=libfreeaptx/libfreeaptx.so \
-DCMAKE_C_FLAGS_RELEASE="-O3 -I$PWD/libfreeaptx"
cmake --build build

export LD_LIBRARY_PATH=$PWD/build/src:$PWD/libfreeaptx:$LD_LIBRARY_PATH_SAVED

echo "openaptx-freeaptx-aptX"
time build/utils/aptxenc input.wav >/dev/null
echo "openaptx-freeaptx-aptX (HD)"
time build/utils/aptxhdenc input.wav >/dev/null

# Test the original libraries.
export LD_LIBRARY_PATH=$PWD/build:$LD_LIBRARY_PATH_SAVED

echo "libaptX-1.0.16-rel-Android21-arm64"
ln -srf archive/aarch64/libaptX-1.0.16-rel-Android21-arm64.so build/libaptx.so
time build/utils/aptxenc input.wav >/dev/null
echo "libaptXHD-1.0.1-rel-Android21-arm64"
ln -srf archive/aarch64/libaptXHD-1.0.1-rel-Android21-arm64.so build/libaptx.so
time build/utils/aptxhdenc input.wav >/dev/null

0 comments on commit fe70adc

Please sign in to comment.