Skip to content

Commit

Permalink
Added tester scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Apr 13, 2020
1 parent 461a06c commit 52cccdf
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
artifacts/
stage/

references/
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,38 @@ It'll build both:
4. Install development tools.
* Execute `pacman -S mingw-w64-i686-gcc autoconf automake-wrapper make` if you wanna 32bit binary.
* Execute `pacman -S mingw-w64-x86_64-gcc autoconf automake-wrapper make` if you wanna 64bit binary.
5. Execute `./download.sh`, it'll download fdk-aac archive from [official opencore-amr project](https://sourceforge.net/projects/opencore-amr/) mirror.
6. Execute `./build.sh`.
5. Execute `./setup.sh`, it'll download fdk-aac archive from [official opencore-amr project](https://sourceforge.net/projects/opencore-amr/) mirror, and extract reference files for testing purpose.
6. You can choose GCC's optimization option. See `CFLAGS` symbols in the head of `build.sh` file.
7. Execute `./build.sh`.

Finally, stored binaries into artifacts directory.
* `artifacts/i686-w64-mingw32/` (32bit)
* `artifacts/x86_64-w64-mingw32/` (64bit)

If you have to get results for PCM bits equality, you can execute `./test.sh` after building was successful. It'll use `cmp` command, so will show nothing output if these PCM files are verified. For example:

```sh
$ ./test.sh
[100%] 01:35.852/01:35.852 (87x), ETA 00:00.000
4227066/4227066 samples processed in 00:01.106
[100%] 01:35.852/01:35.852 (71x), ETA 00:00.000
4227066/4227066 samples processed in 00:01.352
[100%] 01:35.852/01:35.852 (68x), ETA 00:00.000
4227066/4227066 samples processed in 00:01.403
[100%] 01:35.852/01:35.852 (113x), ETA 00:00.000
4227066/4227066 samples processed in 00:00.848
[100%] 01:35.852/01:35.852 (69x), ETA 00:00.000
4227066/4227066 samples processed in 00:01.384
[100%] 01:35.852/01:35.852 (82x), ETA 00:00.000
4227066/4227066 samples processed in 00:01.176
[100%] 01:35.852/01:35.852 (101x), ETA 00:00.000
4227066/4227066 samples processed in 00:00.950
[100%] 01:35.852/01:35.852 (80x), ETA 00:00.000
4227066/4227066 samples processed in 00:01.203

$
```

# Limitation

Unfortunately, 32bit binaries referenced MinGW32 gcc depending library named `libgcc_s_dw2-1.dll` and `libwinpthread-1.dll`. Because fdk-aac use dividing operator, it requires implicitly asynchronous exception handler contains into it.
Expand Down
20 changes: 17 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#! /bin/sh

###################################
# Compiler optimization flags:

# Platform native (not include AVX-512, it's standard options)
CFLAGS="-O3 -flto -march=native"

# AVX-512
#CFLAGS="-O3 -flto -march=native -mavx512f -mavx512dq -mavx512er -mavx512cd -mavx512bw -mavx512pf -mavx512vl -mavx512ifma -mavx512vbmi"

# For debugging/reference usage
#CFLAGS="-O0"

###################################

cd stage

rm -rf $MINGW_CHOST
Expand All @@ -11,20 +25,20 @@ tar -zxvf ../../artifacts/fdk-aac-2.0.1.tar.gz
tar -zxvf ../../artifacts/fdkaac-1.0.0.tar.gz

cd fdk-aac-0.1.6
./configure --prefix=$MINGW_PREFIX/$MINGW_CHOST/
./configure --prefix=$MINGW_PREFIX/$MINGW_CHOST/ CFLAGS="${CFLAGS}"
make -j40
make install
cd ..

cd fdk-aac-2.0.1
./configure --prefix=$MINGW_PREFIX/$MINGW_CHOST/
./configure --prefix=$MINGW_PREFIX/$MINGW_CHOST/ CFLAGS="${CFLAGS}"
make -j40
make install
cd ..

cd fdkaac-1.0.0
autoreconf -i
./configure --prefix=$MINGW_PREFIX/$MINGW_CHOST/
./configure --prefix=$MINGW_PREFIX/$MINGW_CHOST/ CFLAGS="${CFLAGS}"
make -j40
make install
cd ..
Expand Down
15 changes: 0 additions & 15 deletions download.sh

This file was deleted.

31 changes: 31 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /bin/sh

rm -rf artifacts
rm -rf stage

mkdir artifacts
mkdir stage

cd artifacts

wget https://jaist.dl.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-0.1.6.tar.gz
wget https://jaist.dl.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-2.0.1.tar.gz
wget https://github.com/nu774/fdkaac/archive/1.0.0.tar.gz

mv 1.0.0.tar.gz fdkaac-1.0.0.tar.gz

cd ..

rm -rf references
mkdir references

test-materials/ffmpeg.exe -i test-materials/battleThemeA.mp3 references/BattleThemeA.wav > /dev/null 2>&1

test-materials/ffmpeg.exe -i test-materials/BattleThemeA_p2_44_128.aac -f s16le references/battleThemeA_p2_44_128.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i test-materials/BattleThemeA_p5_44_128.aac -f s16le references/battleThemeA_p5_44_128.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i test-materials/BattleThemeA_p23_44_128.aac -f s16le references/battleThemeA_p23_44_128.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i test-materials/BattleThemeA_p29_44_128.aac -f s16le references/battleThemeA_p29_44_128.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i test-materials/BattleThemeA_p39_44_128.aac -f s16le references/battleThemeA_p39_44_128.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i test-materials/BattleThemeA_p2_44_256.aac -f s16le references/battleThemeA_p2_44_256.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i test-materials/BattleThemeA_p2_44_m1.aac -f s16le references/battleThemeA_p2_44_m1.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i test-materials/BattleThemeA_p2_44_m5.aac -f s16le references/battleThemeA_p2_44_m5.pcm > /dev/null 2>&1
Binary file added test-materials/BattleThemeA.mp3
Binary file not shown.
Binary file added test-materials/BattleThemeA_p23_44_128.aac
Binary file not shown.
Binary file added test-materials/BattleThemeA_p29_44_128.aac
Binary file not shown.
Binary file added test-materials/BattleThemeA_p2_44_128.aac
Binary file not shown.
Binary file added test-materials/BattleThemeA_p2_44_256.aac
Binary file not shown.
Binary file added test-materials/BattleThemeA_p2_44_m1.aac
Binary file not shown.
Binary file added test-materials/BattleThemeA_p2_44_m5.aac
Binary file not shown.
Binary file added test-materials/BattleThemeA_p39_44_128.aac
Binary file not shown.
Binary file added test-materials/BattleThemeA_p5_44_128.aac
Binary file not shown.
7 changes: 7 additions & 0 deletions test-materials/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BattleThemeA.wav imported from:

* [opengameart.org](https://opengameart.org/content/battle-theme-a)
* License: CC0

It was converted from mp3 format to wav format.
And spreaded mp4 formats by optimization disabled (64bit, -O0) fdkaac.exe.
Binary file added test-materials/ffmpeg.exe
Binary file not shown.
14 changes: 14 additions & 0 deletions test-materials/make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /bin/sh

./ffmpeg.exe -i BattleThemeA.mp3 BattleThemeA.wav > /dev/null 2>&1

../artifacts/x86_64-w64-mingw32/fdkaac.exe -p 2 -b 128 -o BattleThemeA_p2_44_128.aac BattleThemeA.wav
../artifacts/x86_64-w64-mingw32/fdkaac.exe -p 5 -b 128 -o BattleThemeA_p5_44_128.aac BattleThemeA.wav
../artifacts/x86_64-w64-mingw32/fdkaac.exe -p 23 -b 128 -o BattleThemeA_p23_44_128.aac BattleThemeA.wav
../artifacts/x86_64-w64-mingw32/fdkaac.exe -p 29 -b 128 -o BattleThemeA_p29_44_128.aac BattleThemeA.wav
../artifacts/x86_64-w64-mingw32/fdkaac.exe -p 39 -b 128 -o BattleThemeA_p39_44_128.aac BattleThemeA.wav
../artifacts/x86_64-w64-mingw32/fdkaac.exe -p 2 -b 256 -o BattleThemeA_p2_44_256.aac BattleThemeA.wav
../artifacts/x86_64-w64-mingw32/fdkaac.exe -p 2 -m 1 -o BattleThemeA_p2_44_m1.aac BattleThemeA.wav
../artifacts/x86_64-w64-mingw32/fdkaac.exe -p 2 -m 5 -o BattleThemeA_p2_44_m5.aac BattleThemeA.wav

rm BattleThemeA.wav
39 changes: 39 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#! /bin/sh

DEST=artifacts/$MINGW_CHOST"_test"

rm -rf $DEST
mkdir $DEST

# Execute using built binary.

artifacts/$MINGW_CHOST/fdkaac.exe -p 2 -b 128 -o $DEST/BattleThemeA_p2_44_128.aac references/BattleThemeA.wav
artifacts/$MINGW_CHOST/fdkaac.exe -p 5 -b 128 -o $DEST/BattleThemeA_p5_44_128.aac references/BattleThemeA.wav
artifacts/$MINGW_CHOST/fdkaac.exe -p 23 -b 128 -o $DEST/BattleThemeA_p23_44_128.aac references/BattleThemeA.wav
artifacts/$MINGW_CHOST/fdkaac.exe -p 29 -b 128 -o $DEST/BattleThemeA_p29_44_128.aac references/BattleThemeA.wav
artifacts/$MINGW_CHOST/fdkaac.exe -p 39 -b 128 -o $DEST/BattleThemeA_p39_44_128.aac references/BattleThemeA.wav
artifacts/$MINGW_CHOST/fdkaac.exe -p 2 -b 256 -o $DEST/BattleThemeA_p2_44_256.aac references/BattleThemeA.wav
artifacts/$MINGW_CHOST/fdkaac.exe -p 2 -m 1 -o $DEST/BattleThemeA_p2_44_m1.aac references/BattleThemeA.wav
artifacts/$MINGW_CHOST/fdkaac.exe -p 2 -m 5 -o $DEST/BattleThemeA_p2_44_m5.aac references/BattleThemeA.wav

# Make raw pcm from encoded files.

test-materials/ffmpeg.exe -i $DEST/BattleThemeA_p2_44_128.aac -f s16le $DEST/battleThemeA_p2_44_128.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i $DEST/BattleThemeA_p5_44_128.aac -f s16le $DEST/BattleThemeA_p5_44_128.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i $DEST/BattleThemeA_p23_44_128.aac -f s16le $DEST/BattleThemeA_p23_44_128.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i $DEST/BattleThemeA_p29_44_128.aac -f s16le $DEST/BattleThemeA_p29_44_128.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i $DEST/BattleThemeA_p39_44_128.aac -f s16le $DEST/BattleThemeA_p39_44_128.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i $DEST/BattleThemeA_p2_44_256.aac -f s16le $DEST/BattleThemeA_p2_44_256.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i $DEST/BattleThemeA_p2_44_m1.aac -f s16le $DEST/BattleThemeA_p2_44_m1.pcm > /dev/null 2>&1
test-materials/ffmpeg.exe -i $DEST/BattleThemeA_p2_44_m5.aac -f s16le $DEST/BattleThemeA_p2_44_m5.pcm > /dev/null 2>&1

# Compare raw pcm files.

cmp references/battleThemeA_p2_44_128.pcm $DEST/battleThemeA_p2_44_128.pcm
cmp references/BattleThemeA_p5_44_128.pcm $DEST/BattleThemeA_p5_44_128.pcm
cmp references/BattleThemeA_p23_44_128.pcm $DEST/BattleThemeA_p23_44_128.pcm
cmp references/BattleThemeA_p29_44_128.pcm $DEST/BattleThemeA_p29_44_128.pcm
cmp references/BattleThemeA_p39_44_128.pcm $DEST/BattleThemeA_p39_44_128.pcm
cmp references/BattleThemeA_p2_44_256.pcm $DEST/BattleThemeA_p2_44_256.pcm
cmp references/BattleThemeA_p2_44_m1.pcm $DEST/BattleThemeA_p2_44_m1.pcm
cmp references/BattleThemeA_p2_44_m5.pcm $DEST/BattleThemeA_p2_44_m5.pcm

0 comments on commit 52cccdf

Please sign in to comment.