ref: 0c844c632c7f80ac66aaf23c2bb4f97e51cdad89
parent: bbf3fda5a0f1fed28c59a619cf858792a32d20a1
author: Jörn Heusipp <[email protected]>
date: Sat Feb 17 11:14:34 EST 2018
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;