shithub: mp3dec

Download patch

ref: f3de211d911e8cdd0ed105efb74b70d54628af13
parent: bbf3fda5a0f1fed28c59a619cf858792a32d20a1
parent: 0c844c632c7f80ac66aaf23c2bb4f97e51cdad89
author: Lion <lieff@users.noreply.github.com>
date: Sat Feb 17 13:25:09 EST 2018

Merge pull request #16 from manxorist/fix-testsuite-bigendian
Fix test suite MSE calculation on big-endian platforms.

--- a/minimp3_test.c
+++ b/minimp3_test.c
@@ -12,6 +12,12 @@
     #include <strings.h>
 #endif
 
+static unsigned short read16le(const void *p)
+{
+    const unsigned char *src = (const unsigned char *)p;
+    return ((src[0]) << 0) | ((src[1]) << 8);
+}
+
 #ifndef MINIMP3_NO_WAV
 static char *wav_header(int hz, int ch, int bips, int data_bytes)
 {
@@ -72,7 +78,7 @@
                 total_samples += samples*info.channels;
                 for (i = 0; i < samples*info.channels; i++)
                 {
-                    int MSEtemp = abs((int)pcm[i] - (int)(((short*)(void*)buf_ref)[i]));
+                    int MSEtemp = abs((int)pcm[i] - (int)(short)read16le(&buf_ref[i*sizeof(short)]));
                     if (MSEtemp > maxdiff)
                         maxdiff = MSEtemp;
                     MSE += (float)MSEtemp*(float)MSEtemp;