From ecd978360d79ba71df598f372be65cc1c0e34d80 Mon Sep 17 00:00:00 2001 From: OBATA Akio Date: Wed, 5 Jan 2022 16:36:10 +0900 Subject: noatun-plugins: change to use SDL feature to handle data for SDL With own imcompleted endianness checkes, systems might be mis-detected as big endian. Change to use SDL macros to determine endianness. Change to use SDL function to byte swap Change to use SDL tyepdef for appropriate size integer type Signed-off-by: OBATA Akio --- noatun-plugins/tippercanoe/core.cpp | 18 +++--------------- noatun-plugins/tippercanoe/sdlwrap.cpp | 6 +++--- noatun-plugins/tippercanoe/syna.h | 24 ------------------------ 3 files changed, 6 insertions(+), 42 deletions(-) (limited to 'noatun-plugins/tippercanoe') diff --git a/noatun-plugins/tippercanoe/core.cpp b/noatun-plugins/tippercanoe/core.cpp index 8d1f155..8181a81 100644 --- a/noatun-plugins/tippercanoe/core.cpp +++ b/noatun-plugins/tippercanoe/core.cpp @@ -23,6 +23,7 @@ #include #include "syna.h" #include +#include Core *core; #define outputs unsigned char *Dlo=(unsigned char*)lastOutputBmp.data; \ @@ -302,9 +303,6 @@ bool Core::calculate() double a[NumSamples], b[NumSamples]; int clarity[NumSamples]; //Surround sound int i,j,k; -#ifndef LITTLEENDIAN - sampleType temp; -#endif int brightFactor = int(Brightness * brightnessTwiddler /(starSize+0.01)); @@ -314,18 +312,8 @@ bool Core::calculate() for(i=0;i> 8) | (temp << 8); - x[i] = temp; - temp = data[i*2+1]; - temp = (temp << 8) | (temp >> 8); - y[i] = temp; -# endif + x[i] = SDL_SwapLE16(data[i*2]); + y[i] = SDL_SwapLE16(data[i*2+1]); } fft(x,y); diff --git a/noatun-plugins/tippercanoe/sdlwrap.cpp b/noatun-plugins/tippercanoe/sdlwrap.cpp index 0ca2f4e..5b6bc41 100644 --- a/noatun-plugins/tippercanoe/sdlwrap.cpp +++ b/noatun-plugins/tippercanoe/sdlwrap.cpp @@ -142,8 +142,8 @@ int SdlScreen::sizeUpdate(void) { return 0; } void SdlScreen::show(void) { SDL_LockSurface(surface); - unsigned long *ptr2 = (unsigned long*)core->output(); - unsigned long *ptr1 = (unsigned long*)( surface->pixels ); + Uint32 *ptr2 = (Uint32*)core->output(); + Uint32 *ptr1 = (Uint32*)( surface->pixels ); int i = core->outWidth*core->outHeight/4; do { @@ -153,7 +153,7 @@ void SdlScreen::show(void) { unsigned int const r2 = *(ptr2++); //if (r1 || r2) { -#ifdef LITTLEENDIAN +#if SDL_BYTEORDER == SDL_LIT_ENDIAN unsigned int const v = ((r1 & 0x000000f0ul) >> 4) | ((r1 & 0x0000f000ul) >> 8) diff --git a/noatun-plugins/tippercanoe/syna.h b/noatun-plugins/tippercanoe/syna.h index 0d36e1b..8b76710 100644 --- a/noatun-plugins/tippercanoe/syna.h +++ b/noatun-plugins/tippercanoe/syna.h @@ -47,31 +47,7 @@ #define NumSamples (1< typedef unsigned short sampleType; -#else -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_ENDIAN_H -#include -#elif defined(_BIG_ENDIAN) -#define BIG_ENDIAN 1 -#define BYTE_ORDER BIG_ENDIAN -#endif -typedef short sampleType; -#endif - -#if BYTE_ORDER == BIG_ENDIAN -#define BIGENDIAN -#else -#define LITTLEENDIAN -#endif void error(const char *str, bool syscall=false); void warning(const char *str, bool syscall=false); -- cgit v1.2.1