shithub: mp3dec

Download patch

ref: ecd6d51e4706092af8ecc24015750cecd3c61b43
parent: aeec1573076484f7a7824cf9289f09b9be1011c1
author: lieff <lieff@users.noreply.github.com>
date: Tue Jan 16 09:23:47 EST 2018

add illegal/damaged vectors

--- a/minimp3_test.c
+++ b/minimp3_test.c
@@ -40,16 +40,19 @@
         samples = mp3dec_decode_frame(&mp3d, buf, nbuf, pcm, &info);
         if (samples)
         {
-            int readed = fread(pcm2, 1, 2*info.channels*samples, file_ref);
-            if (readed < 0)
-                exit(1);
-            total_samples += samples*info.channels;
-            for (i = 0; i < samples*info.channels; i++)
+            if (file_ref)
             {
-                int MSEtemp = abs((int)pcm[i] - (int)pcm2[i]);
-                if (MSEtemp > maxdiff)
-                    maxdiff = MSEtemp;
-                MSE += MSEtemp*MSEtemp;
+                int readed = fread(pcm2, 1, 2*info.channels*samples, file_ref);
+                if (readed < 0)
+                    exit(1);
+                total_samples += samples*info.channels;
+                for (i = 0; i < samples*info.channels; i++)
+                {
+                    int MSEtemp = abs((int)pcm[i] - (int)pcm2[i]);
+                    if (MSEtemp > maxdiff)
+                        maxdiff = MSEtemp;
+                    MSE += MSEtemp*MSEtemp;
+                }
             }
             if (file_out)
                 fwrite(pcm, samples, 2*info.channels, file_out);
@@ -57,7 +60,7 @@
         memmove(buf, buf + info.frame_bytes, nbuf -= info.frame_bytes);
     } while (info.frame_bytes);
 
-    MSE /= total_samples;
+    MSE /= total_samples ? total_samples : 1;
     if (0 == MSE)
         psnr = 99.0;
     else
@@ -73,7 +76,8 @@
     //rewind(file_wav);
     //fwrite(wav_header(info.hz, info.channels, 16, data_bytes), 1, 44, file_wav);
     fclose(file_mp3);
-    fclose(file_ref);
+    if (file_ref)
+        fclose(file_ref);
     if (file_out)
         fclose(file_out);
 }
@@ -83,7 +87,7 @@
     char *input_file_name  = (argc > 1) ? argv[1] : NULL;
     char *ref_file_name    = (argc > 2) ? argv[2] : NULL;
     char *output_file_name = (argc > 3) ? argv[3] : NULL;
-    if (!input_file_name || !ref_file_name)
+    if (!input_file_name)
     {
         printf("error: no file names given\n");
         return 1;
binary files /dev/null b/vectors/ILL2_center2.bit differ
binary files /dev/null b/vectors/ILL2_dual.bit differ
binary files /dev/null b/vectors/ILL2_dynx22.bit differ
binary files /dev/null b/vectors/ILL2_dynx31.bit differ
binary files /dev/null b/vectors/ILL2_dynx32.bit differ
binary files /dev/null b/vectors/ILL2_ext_switching.bit differ
binary files /dev/null b/vectors/ILL2_ext_switching.pcm differ
binary files /dev/null b/vectors/ILL2_layer1.bit differ
binary files /dev/null b/vectors/ILL2_layer1.pcm differ
binary files /dev/null b/vectors/ILL2_layer3.bit differ
binary files /dev/null b/vectors/ILL2_layer3.pcm differ
binary files /dev/null b/vectors/ILL2_mono.bit differ
binary files /dev/null b/vectors/ILL2_multilingual.bit differ
binary files /dev/null b/vectors/ILL2_overalloc1.bit differ
binary files /dev/null b/vectors/ILL2_overalloc2.bit differ
binary files /dev/null b/vectors/ILL2_prediction.bit differ
binary files /dev/null b/vectors/ILL2_samples.bit differ
binary files /dev/null b/vectors/ILL2_scf63.bit differ
binary files /dev/null b/vectors/ILL2_tca21.bit differ
binary files /dev/null b/vectors/ILL2_tca30.bit differ
binary files /dev/null b/vectors/ILL2_tca30_PC.bit differ
binary files /dev/null b/vectors/ILL2_tca31_PC.bit differ
binary files /dev/null b/vectors/ILL2_tca31_mtx0.bit differ
binary files /dev/null b/vectors/ILL2_tca31_mtx2.bit differ
binary files /dev/null b/vectors/ILL2_tca32_PC.bit differ
binary files /dev/null b/vectors/ILL2_wrongcrc.bit differ
binary files /dev/null b/vectors/ILL4_ext_id1.bit differ
binary files /dev/null b/vectors/ILL4_sync.bit differ
binary files /dev/null b/vectors/ILL4_wrong_length1.bit differ
binary files /dev/null b/vectors/ILL4_wrong_length2.bit differ
binary files /dev/null b/vectors/ILL4_wrongcrc.bit differ