shithub: mp3dec

Download patch

ref: 473c5fdea074e35a3135a0ca991070b877b374cd
parent: 9ac33df569adb8daecf8d556855b73bcb7765304
author: lieff <[email protected]>
date: Thu Jan 11 12:04:36 EST 2018

fix gcc warnings

--- a/minimp3.h
+++ b/minimp3.h
@@ -738,7 +738,7 @@
 #define CHECK_BITS      while (bs_sh >= 0) { bs_cache |= (uint32_t)*bs_next_ptr++ << bs_sh; bs_sh -= 8; }
 #define BSPOS           ((bs_next_ptr - bs->buf)*8 - 24 + bs_sh)
 
-    float one;
+    float one = 0.0f;
     int ireg = 0, big_val_cnt = gr_info->big_values;
     const uint8_t *sfb = gr_info->sfbtab;
     const uint8_t *bs_next_ptr = bs->buf + bs->pos/8;
@@ -806,7 +806,7 @@
             break;
         }
 #define RELOAD_SCALEFACTOR  if (!--np) {np = *sfb++/2; if (!np) break; one = *scf++;}
-#define DEQ_COUNT1(s) if (leaf & (128 >> s)) {dst[s] = ((int32_t)bs_cache < 0)?-one:one; FLUSH_BITS(1)}
+#define DEQ_COUNT1(s) if (leaf & (128 >> s)) {dst[s] = ((int32_t)bs_cache < 0) ? -one : one; FLUSH_BITS(1)}
         RELOAD_SCALEFACTOR;
         DEQ_COUNT1(0);
         DEQ_COUNT1(1);
--- a/minimp3_test.c
+++ b/minimp3_test.c
@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <math.h>
 
-static char *wav_header(int hz, int ch, int bips, int data_bytes)
+/*static char *wav_header(int hz, int ch, int bips, int data_bytes)
 {
     static char hdr[44] = "RIFFsizeWAVEfmt \x10\0\0\0\1\0ch_hz_abpsbabsdatasize";
     unsigned long nAvgBytesPerSec = bips*ch*hz >> 3;
@@ -18,13 +18,13 @@
     *(short *)(hdr + 0x22) = bips;
     *(int *  )(hdr + 0x28) = data_bytes;
     return hdr;
-}
+}*/
 
 static void decode_file(FILE *file_mp3, FILE *file_ref, FILE *file_out)
 {
     static mp3dec_t mp3d = { 0, };
     mp3dec_frame_info_t info;
-    int i, data_bytes, samples, total_samples = 0, nbuf = 0, maxdiff = 0;
+    int i, /*data_bytes, */samples, total_samples = 0, nbuf = 0, maxdiff = 0;
     double MSE = 0.0, psnr;
     unsigned char buf[4096];
 
@@ -39,7 +39,9 @@
         samples = mp3dec_decode_frame(&mp3d, buf, nbuf, pcm, &info);
         if (samples)
         {
-            fread(pcm2, 1, 2*info.channels*samples, file_ref);
+            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++)
             {
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -11,7 +11,7 @@
   cp vectors/l3-he_mode16.pcm fate-suite.ffmpeg.org/mp3-conformance/he_mode.pcm
 fi
 
-gcc -O2 -g -o minimp3 minimp3_test.c -lm
+gcc -O2 -g -Wall -Wextra -o minimp3 minimp3_test.c -lm
 
 APP=./minimp3