mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-12 06:51:09 +00:00
hopefully speed up byte swaps
This commit is contained in:
parent
6884f97694
commit
201f01b66c
4 changed files with 52 additions and 33 deletions
|
@ -76,12 +76,37 @@
|
||||||
|
|
||||||
extern qboolean bigendien;
|
extern qboolean bigendien;
|
||||||
|
|
||||||
short ShortSwap (short l);
|
short _ShortSwap (short l);
|
||||||
short ShortNoSwap (short l);
|
short _ShortNoSwap (short l);
|
||||||
int LongSwap (int l);
|
int _LongSwap (int l);
|
||||||
int LongNoSwap (int l);
|
int _LongNoSwap (int l);
|
||||||
float FloatSwap (float f);
|
float _FloatSwap (float f);
|
||||||
float FloatNoSwap (float f);
|
float _FloatNoSwap (float f);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define ShortSwap(l) ({ uint16_t x = (uint16_t) (l); \
|
||||||
|
x = ( ((x >> 8) & 0xff) \
|
||||||
|
| ((x << 8) & 0xff00)); \
|
||||||
|
x; })
|
||||||
|
|
||||||
|
#define LongSwap(l) ({ uint32_t z = (uint32_t) (l); \
|
||||||
|
z = (ShortSwap (z >> 16)) | (ShortSwap (z) << 16); \
|
||||||
|
z; })
|
||||||
|
|
||||||
|
#define FloatSwap(l) ({ union { uint32_t i; float f; } y; \
|
||||||
|
y.f = (l); \
|
||||||
|
y.i = LongSwap (y.i); \
|
||||||
|
y.f; })
|
||||||
|
#else
|
||||||
|
#define ShortSwap(l) _ShortSwap (l)
|
||||||
|
#define LongSwap(l) _LongSwap (l)
|
||||||
|
#define FloatSwap(l) _FloatSwap (l)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ShortNoSwap(l) (l)
|
||||||
|
#define LongNoSwap(l) (l)
|
||||||
|
#define FloatNoSwap(l) (l)
|
||||||
|
|
||||||
// NOTE: these /always/ read and write /little/ endian entities.
|
// NOTE: these /always/ read and write /little/ endian entities.
|
||||||
struct QFile_s;
|
struct QFile_s;
|
||||||
|
|
|
@ -61,6 +61,15 @@ typedef struct {
|
||||||
cvar_t *snd_loadas8bit;
|
cvar_t *snd_loadas8bit;
|
||||||
cvar_t *snd_interp;
|
cvar_t *snd_interp;
|
||||||
|
|
||||||
|
static void
|
||||||
|
check_buffer_integrity (sfxbuffer_t *sc, int width, const char *func)
|
||||||
|
{
|
||||||
|
byte *x = sc->data + sc->length * width;
|
||||||
|
if (memcmp (x, "\xde\xad\xbe\xef", 4))
|
||||||
|
Sys_Error ("%s screwed the pooch %02x%02x%02x%02x", func,
|
||||||
|
x[0], x[1], x[2], x[3]);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SND_ResampleMono (sfxbuffer_t *sc, byte *data, int length, void *prev)
|
SND_ResampleMono (sfxbuffer_t *sc, byte *data, int length, void *prev)
|
||||||
{
|
{
|
||||||
|
@ -195,12 +204,7 @@ general_Mono:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
check_buffer_integrity (sc, outwidth, __FUNCTION__);
|
||||||
byte *x = sc->data + sc->length * outwidth;
|
|
||||||
if (memcmp (x, "\xde\xad\xbe\xef", 4))
|
|
||||||
Sys_Error ("SND_ResampleMono screwed the pooch %02x%02x%02x%02x",
|
|
||||||
x[0], x[1], x[2], x[3]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -359,12 +363,7 @@ general_Stereo:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
check_buffer_integrity (sc, outwidth * 2, __FUNCTION__);
|
||||||
byte *x = sc->data + sc->length * outwidth * 2;
|
|
||||||
if (memcmp (x, "\xde\xad\xbe\xef", 4))
|
|
||||||
Sys_Error ("SND_ResampleStereo screwed the pooch %02x%02x%02x%02x",
|
|
||||||
x[0], x[1], x[2], x[3]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -429,10 +428,5 @@ SND_NoResampleStereo (sfxbuffer_t *sc, byte *data, int length, void *prev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
check_buffer_integrity (sc, outwidth * 2, __FUNCTION__);
|
||||||
byte *x = sc->data + sc->length * outwidth * 2;
|
|
||||||
if (memcmp (x, "\xde\xad\xbe\xef", 4))
|
|
||||||
Sys_Error ("SND_ResampleStereo screwed the pooch %02x%02x%02x%02x",
|
|
||||||
x[0], x[1], x[2], x[3]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ VISIBLE qboolean bigendien = true;;
|
||||||
|
|
||||||
|
|
||||||
VISIBLE short
|
VISIBLE short
|
||||||
ShortSwap (short l)
|
_ShortSwap (short l)
|
||||||
{
|
{
|
||||||
byte b1, b2;
|
byte b1, b2;
|
||||||
|
|
||||||
|
@ -62,13 +62,13 @@ ShortSwap (short l)
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE short
|
VISIBLE short
|
||||||
ShortNoSwap (short l)
|
_ShortNoSwap (short l)
|
||||||
{
|
{
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE int
|
VISIBLE int
|
||||||
LongSwap (int l)
|
_LongSwap (int l)
|
||||||
{
|
{
|
||||||
byte b1, b2, b3, b4;
|
byte b1, b2, b3, b4;
|
||||||
|
|
||||||
|
@ -81,13 +81,13 @@ LongSwap (int l)
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE int
|
VISIBLE int
|
||||||
LongNoSwap (int l)
|
_LongNoSwap (int l)
|
||||||
{
|
{
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE float
|
VISIBLE float
|
||||||
FloatSwap (float f)
|
_FloatSwap (float f)
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
float f;
|
float f;
|
||||||
|
@ -103,7 +103,7 @@ FloatSwap (float f)
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE float
|
VISIBLE float
|
||||||
FloatNoSwap (float f)
|
_FloatNoSwap (float f)
|
||||||
{
|
{
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,9 +499,9 @@ WriteLBMfile (char *filename, byte *data, int width, int height, byte *palette)
|
||||||
memset (&basebmhd, 0, sizeof (basebmhd));
|
memset (&basebmhd, 0, sizeof (basebmhd));
|
||||||
basebmhd.w = BigShort ((short) width);
|
basebmhd.w = BigShort ((short) width);
|
||||||
basebmhd.h = BigShort ((short) height);
|
basebmhd.h = BigShort ((short) height);
|
||||||
basebmhd.nPlanes = BigShort (8);
|
basebmhd.nPlanes = 8;
|
||||||
basebmhd.xAspect = BigShort (5);
|
basebmhd.xAspect = 5;
|
||||||
basebmhd.yAspect = BigShort (6);
|
basebmhd.yAspect = 6;
|
||||||
basebmhd.pageWidth = BigShort ((short) width);
|
basebmhd.pageWidth = BigShort ((short) width);
|
||||||
basebmhd.pageHeight = BigShort ((short) height);
|
basebmhd.pageHeight = BigShort ((short) height);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue