summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOBATA Akio <obache@wizdas.com>2022-01-05 16:36:10 +0900
committerSlávek Banko <slavek.banko@axis.cz>2022-01-05 13:21:13 +0100
commitfdab75afa31934a4f2d210020405311b2befdd3f (patch)
tree3c670821febc1742595d5b672fb5be4958900264
parent5363fd55b8fed6a22d63017ff110ddd7dc619c1a (diff)
downloadtdeaddons-fdab75afa31934a4f2d210020405311b2befdd3f.tar.gz
tdeaddons-fdab75afa31934a4f2d210020405311b2befdd3f.zip
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 <obache@wizdas.com> (cherry picked from commit ecd978360d79ba71df598f372be65cc1c0e34d80)
-rw-r--r--noatun-plugins/blurscope/scopedisplayer.cpp8
-rw-r--r--noatun-plugins/synaescope/core.cpp18
-rw-r--r--noatun-plugins/synaescope/sdlwrap.cpp6
-rw-r--r--noatun-plugins/synaescope/syna.h24
-rw-r--r--noatun-plugins/tippercanoe/core.cpp18
-rw-r--r--noatun-plugins/tippercanoe/sdlwrap.cpp6
-rw-r--r--noatun-plugins/tippercanoe/syna.h24
7 files changed, 16 insertions, 88 deletions
diff --git a/noatun-plugins/blurscope/scopedisplayer.cpp b/noatun-plugins/blurscope/scopedisplayer.cpp
index 4abc188..da31e5c 100644
--- a/noatun-plugins/blurscope/scopedisplayer.cpp
+++ b/noatun-plugins/blurscope/scopedisplayer.cpp
@@ -231,15 +231,15 @@ void SDLView::checkInput()
}
}
-#define output2 ((unsigned char*)outputBmp.data)
+#define output2 ((Uint8*)outputBmp.data)
void SDLView::repaint()
{
SDL_LockSurface(surface);
TEST();
- unsigned long *ptr2 = (unsigned long*)output2;
- unsigned long *ptr1 = (unsigned long*)( surface->pixels );
+ Uint32 *ptr2 = (Uint32*)output2;
+ Uint32 *ptr1 = (Uint32*)( surface->pixels );
int i = width*height/4;
TEST();
@@ -250,7 +250,7 @@ void SDLView::repaint()
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/synaescope/core.cpp b/noatun-plugins/synaescope/core.cpp
index e21c796..15c6730 100644
--- a/noatun-plugins/synaescope/core.cpp
+++ b/noatun-plugins/synaescope/core.cpp
@@ -24,6 +24,7 @@
#include "syna.h"
#include <unistd.h>
#include <noatun/conversion.h>
+#include <SDL_endian.h>
using namespace std;
@@ -305,9 +306,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));
@@ -322,18 +320,8 @@ bool Core::calculate()
for(i=0;i<NumSamples;i++)
{
-# ifdef LITTLEENDIAN
- x[i] = data[i*2];
- y[i] = data[i*2+1];
-# else
- // Need to convert to big-endian
- temp = data[i*2];
- temp = (temp >> 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/synaescope/sdlwrap.cpp b/noatun-plugins/synaescope/sdlwrap.cpp
index f40d384..920e150 100644
--- a/noatun-plugins/synaescope/sdlwrap.cpp
+++ b/noatun-plugins/synaescope/sdlwrap.cpp
@@ -150,8 +150,8 @@ void SdlScreen::show()
{
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 {
@@ -161,7 +161,7 @@ void SdlScreen::show()
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/synaescope/syna.h b/noatun-plugins/synaescope/syna.h
index 07c4e5e..0d3831b 100644
--- a/noatun-plugins/synaescope/syna.h
+++ b/noatun-plugins/synaescope/syna.h
@@ -48,31 +48,7 @@
#define NumSamples (1<<LogSize)
#define RecSize (1<<LogSize-Overlap)
-#ifndef __linux__
-#warning This target has not been tested!
-#endif
-
-#ifdef __FreeBSD__
-#include <machine/endian.h>
typedef unsigned short sampleType;
-#else
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_ENDIAN_H
-#include <endian.h>
-#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);
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 <string.h>
#include "syna.h"
#include <unistd.h>
+#include <SDL_endian.h>
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<NumSamples;i++)
{
-# ifdef LITTLEENDIAN
- x[i] = data[i*2];
- y[i] = data[i*2+1];
-# else
- // Need to convert to big-endian
- temp = data[i*2];
- temp = (temp >> 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<<LogSize)
#define RecSize (1<<LogSize-Overlap)
-#ifndef __linux__
-#warning This target has not been tested!
-#endif
-
-#ifdef __FreeBSD__
-#include <machine/endian.h>
typedef unsigned short sampleType;
-#else
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_ENDIAN_H
-#include <endian.h>
-#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);