shithub: mp3dec

Download patch

ref: 2797d8a8b467dfad13eecd127495ef5d39f54cc0
parent: 5ce2e4d2210369009a6b988b56a37a56d561237d
author: lieff <lieff@users.noreply.github.com>
date: Wed Jan 10 09:54:07 EST 2018

add fate test

diff: cannot open b/scripts//null: file does not exist: 'b/scripts//null'
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,5 +6,8 @@
 compiler:
     - gcc
 
+before_install:
+    - if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -y wget; fi
+
 script:
-    - gcc -Dminimp3_test -O2 -g -o minimp3 minimp3.c 
\ No newline at end of file
+    - scripts/build.sh
\ No newline at end of file
--- a/minimp3.c
+++ b/minimp3.c
@@ -1639,7 +1639,7 @@
 
     mp3dec_init(&mp3d);
 
-    fwrite(wav_header(0, 0, 0, 0), 1, 44, file_wav);
+    //fwrite(wav_header(0, 0, 0, 0), 1, 44, file_wav);
 
     do
     {
@@ -1649,13 +1649,14 @@
         if (samples)
         {
             fwrite(pcm, samples, 2*info.channels, file_wav);
-        }
+        } else if (0 == info.frame_bytes) info.frame_bytes = nbuf;
+
         memmove(buf, buf + info.frame_bytes, nbuf -= info.frame_bytes);
     } while (nbuf);
 
     data_bytes = ftell(file_wav) - 44;
-    rewind(file_wav);
-    fwrite(wav_header(info.hz, info.channels, 16, data_bytes), 1, 44, file_wav);
+    //rewind(file_wav);
+    //fwrite(wav_header(info.hz, info.channels, 16, data_bytes), 1, 44, file_wav);
     fclose(file_wav);
     fclose(file_mp3);
 }
--- /dev/null
+++ b/scripts/build.sh
@@ -1,0 +1,21 @@
+set -e
+
+if [ ! -d "fate-suite.ffmpeg.org" ]; then
+  wget -np -r --level=1 http://fate-suite.ffmpeg.org/mp3-conformance/
+fi
+
+gcc -Dminimp3_test -O2 -g -o minimp3 minimp3.c
+
+APP=./minimp3
+
+set +e
+for i in fate-suite.ffmpeg.org/mp3-conformance/*.bit; do
+$($APP $i $i.out)
+retval=$?
+echo $i exited with code=$retval
+cmp -s $i $i.out > /dev/null
+if [ $? -eq 1 ]; then
+    echo test failed
+    exit 1
+fi
+done