diff --git a/.gitignore b/.gitignore index 9b4d159..86c0e1f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ artifacts/ stage/ - +references/ diff --git a/README.md b/README.md index b71717f..7fb67c1 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/build.sh b/build.sh index 55d5940..11f3860 100644 --- a/build.sh +++ b/build.sh @@ -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 @@ -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 .. diff --git a/download.sh b/download.sh deleted file mode 100644 index 6e1016d..0000000 --- a/download.sh +++ /dev/null @@ -1,15 +0,0 @@ -#! /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 diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..4c08593 --- /dev/null +++ b/setup.sh @@ -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 diff --git a/test-materials/BattleThemeA.mp3 b/test-materials/BattleThemeA.mp3 new file mode 100644 index 0000000..d22aa61 Binary files /dev/null and b/test-materials/BattleThemeA.mp3 differ diff --git a/test-materials/BattleThemeA_p23_44_128.aac b/test-materials/BattleThemeA_p23_44_128.aac new file mode 100644 index 0000000..e006950 Binary files /dev/null and b/test-materials/BattleThemeA_p23_44_128.aac differ diff --git a/test-materials/BattleThemeA_p29_44_128.aac b/test-materials/BattleThemeA_p29_44_128.aac new file mode 100644 index 0000000..fbd1a87 Binary files /dev/null and b/test-materials/BattleThemeA_p29_44_128.aac differ diff --git a/test-materials/BattleThemeA_p2_44_128.aac b/test-materials/BattleThemeA_p2_44_128.aac new file mode 100644 index 0000000..f4040ae Binary files /dev/null and b/test-materials/BattleThemeA_p2_44_128.aac differ diff --git a/test-materials/BattleThemeA_p2_44_256.aac b/test-materials/BattleThemeA_p2_44_256.aac new file mode 100644 index 0000000..a8cc854 Binary files /dev/null and b/test-materials/BattleThemeA_p2_44_256.aac differ diff --git a/test-materials/BattleThemeA_p2_44_m1.aac b/test-materials/BattleThemeA_p2_44_m1.aac new file mode 100644 index 0000000..efb2905 Binary files /dev/null and b/test-materials/BattleThemeA_p2_44_m1.aac differ diff --git a/test-materials/BattleThemeA_p2_44_m5.aac b/test-materials/BattleThemeA_p2_44_m5.aac new file mode 100644 index 0000000..9007bef Binary files /dev/null and b/test-materials/BattleThemeA_p2_44_m5.aac differ diff --git a/test-materials/BattleThemeA_p39_44_128.aac b/test-materials/BattleThemeA_p39_44_128.aac new file mode 100644 index 0000000..949fdac Binary files /dev/null and b/test-materials/BattleThemeA_p39_44_128.aac differ diff --git a/test-materials/BattleThemeA_p5_44_128.aac b/test-materials/BattleThemeA_p5_44_128.aac new file mode 100644 index 0000000..b972658 Binary files /dev/null and b/test-materials/BattleThemeA_p5_44_128.aac differ diff --git a/test-materials/README.md b/test-materials/README.md new file mode 100644 index 0000000..b770efa --- /dev/null +++ b/test-materials/README.md @@ -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. diff --git a/test-materials/ffmpeg.exe b/test-materials/ffmpeg.exe new file mode 100644 index 0000000..2351e76 Binary files /dev/null and b/test-materials/ffmpeg.exe differ diff --git a/test-materials/make.sh b/test-materials/make.sh new file mode 100644 index 0000000..c39d166 --- /dev/null +++ b/test-materials/make.sh @@ -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 diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..51f3221 --- /dev/null +++ b/test.sh @@ -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