short -> int16_t

master
an 2019-11-25 17:15:33 -05:00
parent ab64303a7f
commit b4c25eb4d9
22 changed files with 80 additions and 83 deletions

View File

@ -166,9 +166,9 @@ typedef struct
typedef struct
{
int planenum;
short children[2]; // negative numbers are -(leafs+1), not nodes
short mins[3]; // for sphere culling
short maxs[3];
int16_t children[2]; // negative numbers are -(leafs+1), not nodes
int16_t mins[3]; // for sphere culling
int16_t maxs[3];
uint16_t firstface;
uint16_t numfaces; // counting both sides
} dsnode_t;
@ -177,8 +177,8 @@ typedef struct
{
int planenum;
int children[2]; // negative numbers are -(leafs+1), not nodes
short mins[3]; // for sphere culling
short maxs[3];
int16_t mins[3]; // for sphere culling
int16_t maxs[3];
uint32_t firstface;
uint32_t numfaces; // counting both sides
} dl1node_t;
@ -196,7 +196,7 @@ typedef struct
typedef struct
{
int planenum;
short children[2]; // negative numbers are contents
int16_t children[2]; // negative numbers are contents
} dsclipnode_t;
typedef struct
@ -230,12 +230,12 @@ typedef struct
#define MAXLIGHTMAPS 4
typedef struct
{
short planenum;
short side;
int16_t planenum;
int16_t side;
int firstedge; // we must support > 64k edges
short numedges;
short texinfo;
int16_t numedges;
int16_t texinfo;
// lighting info
byte styles[MAXLIGHTMAPS];
@ -270,8 +270,8 @@ typedef struct
int contents;
int visofs; // -1 = no visibility info
short mins[3]; // for frustum culling
short maxs[3];
int16_t mins[3]; // for frustum culling
int16_t maxs[3];
uint16_t firstmarksurface;
uint16_t nummarksurfaces;
@ -284,8 +284,8 @@ typedef struct
int contents;
int visofs; // -1 = no visibility info
short mins[3]; // for frustum culling
short maxs[3];
int16_t mins[3]; // for frustum culling
int16_t maxs[3];
uint32_t firstmarksurface;
uint32_t nummarksurfaces;

View File

@ -32,7 +32,7 @@ const char *svc_strings[] =
"svc_disconnect",
"svc_updatestat",
"svc_version", // [long] server version
"svc_setview", // [short] entity number
"svc_setview", // [int16_t] entity number
"svc_sound", // <see code>
"svc_time", // [float] server time
"svc_print", // [string] null terminated string
@ -46,7 +46,7 @@ const char *svc_strings[] =
// [string]..[0]item cache
"svc_lightstyle", // [byte] [string]
"svc_updatename", // [byte] [string]
"svc_updatefrags", // [byte] [short]
"svc_updatefrags", // [byte] [int16_t]
"svc_clientdata", // <shortbits + data>
"svc_stopsound", // <see code>
"svc_updatecolors", // [byte] [byte]
@ -79,7 +79,7 @@ const char *svc_strings[] =
"svc_fog", // 41 // [byte] density [byte] red [byte] green [byte] blue [float] time
"svc_spawnbaseline2", //42 // support for large modelindex, large framenum, alpha, using flags
"svc_spawnstatic2", // 43 // support for large modelindex, large framenum, alpha, using flags
"svc_spawnstaticsound2", // 44 // [coord3] [short] samp [byte] vol [byte] aten
"svc_spawnstaticsound2", // 44 // [coord3] [int16_t] samp [byte] vol [byte] aten
"", // 44
"", // 45
"", // 46

View File

@ -557,14 +557,14 @@ float Q_atof (const char *str)
qboolean host_bigendian;
short (*BigShort) (short l);
short (*LittleShort) (short l);
int16_t (*BigShort) (int16_t l);
int16_t (*LittleShort) (int16_t l);
int (*BigLong) (int l);
int (*LittleLong) (int l);
float (*BigFloat) (float l);
float (*LittleFloat) (float l);
short ShortSwap (short l)
int16_t ShortSwap (int16_t l)
{
byte b1, b2;
@ -574,7 +574,7 @@ short ShortSwap (short l)
return (b1<<8) + b2;
}
short ShortNoSwap (short l)
int16_t ShortNoSwap (int16_t l)
{
return l;
}
@ -662,7 +662,7 @@ void MSG_WriteShort (sizebuf_t *sb, int c)
byte *buf;
#ifdef PARANOID
if (c < ((short)0x8000) || c > (short)0x7fff)
if (c < ((int16_t)0x8000) || c > (int16_t)0x7fff)
Sys_Error ("MSG_WriteShort: range error");
#endif
@ -807,7 +807,7 @@ int MSG_ReadShort (void)
return -1;
}
c = (short)(net_message.data[msg_readcount]
c = (int16_t)(net_message.data[msg_readcount]
+ (net_message.data[msg_readcount+1]<<8));
msg_readcount += 2;

View File

@ -85,8 +85,8 @@ void InsertLinkAfter (link_t *l, link_t *after);
extern qboolean host_bigendian;
extern short (*BigShort) (short l);
extern short (*LittleShort) (short l);
extern int16_t (*BigShort) (int16_t l);
extern int16_t (*LittleShort) (int16_t l);
extern int (*BigLong) (int l);
extern int (*LittleLong) (int l);
extern float (*BigFloat) (float l);

View File

@ -458,7 +458,7 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
{
int totalvbosize = 0;
const aliasmesh_t *desc;
const short *indexes;
const int16_t *indexes;
const trivertx_t *trivertexes;
byte *vbodata;
int f;
@ -485,7 +485,7 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
// grab the pointers to data in the extradata
desc = (aliasmesh_t *) ((byte *) hdr + hdr->meshdesc);
indexes = (short *) ((byte *) hdr + hdr->indexes);
indexes = (int16_t *) ((byte *) hdr + hdr->indexes);
trivertexes = (trivertx_t *) ((byte *)hdr + hdr->vertexes);
// upload indices buffer

View File

@ -1781,7 +1781,7 @@ void Mod_LoadMarksurfaces (lump_t *l, int bsp2)
}
else
{
short *in = (short *)(mod_base + l->fileofs);
int16_t *in = (int16_t *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
Host_Error ("Mod_LoadMarksurfaces: funny lump size in %s",loadmodel->name);
@ -2221,7 +2221,7 @@ Fill background pixels so mipmapping doesn't have haloes - Ed
typedef struct
{
short x, y;
int16_t x, y;
} floodfill_t;
// must be a power of 2

View File

@ -151,8 +151,8 @@ typedef struct msurface_s
int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges
short texturemins[2];
short extents[2];
int16_t texturemins[2];
int16_t extents[2];
int light_s, light_t; // gl lightmap coordinates

View File

@ -120,7 +120,7 @@ int fgetLittleShort (FILE *f)
b1 = fgetc(f);
b2 = fgetc(f);
return (short)(b1 + b2*256);
return (int16_t)(b1 + b2*256);
}
int fgetLittleLong (FILE *f)

View File

@ -3820,14 +3820,14 @@ unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
/*
Paeth predicter, used by PNG filter type 4
The parameters are of type short, but should come from unsigned chars, the shorts
The parameters are of type int16_t, but should come from unsigned chars, the shorts
are only needed to make the paeth calculation correct.
*/
static unsigned char paethPredictor(short a, short b, short c)
static unsigned char paethPredictor(int16_t a, int16_t b, int16_t c)
{
short pa = abs(b - c);
short pb = abs(a - c);
short pc = abs(a + b - c - c);
int16_t pa = abs(b - c);
int16_t pb = abs(a - c);
int16_t pc = abs(a + b - c - c);
if(pc < pa && pc < pb) return (unsigned char)c;
else if(pb < pa) return (unsigned char)b;

View File

@ -30,7 +30,7 @@ struct qsockaddr
unsigned char qsa_len;
unsigned char qsa_family;
#else
short qsa_family;
int16_t qsa_family;
#endif /* BSD, sockaddr */
unsigned char qsa_data[14];
};

View File

@ -202,7 +202,7 @@ int Loop_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data)
bufferLength = &((qsocket_t *)sock->driverdata)->receiveMessageLength;
if ((*bufferLength + data->cursize + sizeof(byte) + sizeof(short)) > NET_MAXMESSAGE)
if ((*bufferLength + data->cursize + sizeof(byte) + sizeof(int16_t)) > NET_MAXMESSAGE)
return 0;
buffer = ((qsocket_t *)sock->driverdata)->receiveMessage + *bufferLength;

View File

@ -135,7 +135,7 @@ enum
typedef struct statement_s
{
uint16_t op;
short a, b, c;
int16_t a, b, c;
} dstatement_t;
typedef struct

View File

@ -117,13 +117,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
//johnfitz -- PROTOCOL_FITZQUAKE -- new bits
#define SND_LARGEENTITY (1<<3) // a short + byte (instead of just a short)
#define SND_LARGESOUND (1<<4) // a short soundindex (instead of a byte)
#define SND_LARGEENTITY (1<<3) // a int16_t + byte (instead of just a int16_t)
#define SND_LARGESOUND (1<<4) // a int16_t soundindex (instead of a byte)
//johnfitz
//johnfitz -- PROTOCOL_FITZQUAKE -- flags for entity baseline messages
#define B_LARGEMODEL (1<<0) // modelindex is short instead of byte
#define B_LARGEFRAME (1<<1) // frame is short instead of byte
#define B_LARGEMODEL (1<<0) // modelindex is int16_t instead of byte
#define B_LARGEFRAME (1<<1) // frame is int16_t instead of byte
#define B_ALPHA (1<<2) // 1 byte, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT
//johnfitz
@ -157,7 +157,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define svc_disconnect 2
#define svc_updatestat 3 // [byte] [long]
#define svc_version 4 // [long] server version
#define svc_setview 5 // [short] entity number
#define svc_setview 5 // [int16_t] entity number
#define svc_sound 6 // <see code>
#define svc_time 7 // [float] server time
#define svc_print 8 // [string] null terminated string
@ -170,7 +170,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// [string]...[0]sounds cache
#define svc_lightstyle 12 // [byte] [string]
#define svc_updatename 13 // [byte] [string]
#define svc_updatefrags 14 // [byte] [short]
#define svc_updatefrags 14 // [byte] [int16_t]
#define svc_clientdata 15 // <shortbits + data>
#define svc_stopsound 16 // <see code>
#define svc_updatecolors 17 // [byte] [byte]
@ -198,7 +198,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define svc_fog 41 // [byte] density [byte] red [byte] green [byte] blue [float] time
#define svc_spawnbaseline2 42 // support for large modelindex, large framenum, alpha, using flags
#define svc_spawnstatic2 43 // support for large modelindex, large framenum, alpha, using flags
#define svc_spawnstaticsound2 44 // [coord3] [short] samp [byte] vol [byte] aten
#define svc_spawnstaticsound2 44 // [coord3] [int16_t] samp [byte] vol [byte] aten
//johnfitz
//

View File

@ -68,13 +68,11 @@
/*==========================================================================*/
#define Q_MAXCHAR ((char)0x7f)
#define Q_MAXSHORT ((short)0x7fff)
#define Q_MAXINT ((int)0x7fffffff)
#define Q_MAXLONG ((int)0x7fffffff)
#define Q_MAXFLOAT ((int)0x7fffffff)
#define Q_MINCHAR ((char)0x80)
#define Q_MINSHORT ((short)0x8000)
#define Q_MININT ((int)0x80000000)
#define Q_MINLONG ((int)0x80000000)
#define Q_MINFLOAT ((int)0x7fffffff)
@ -86,7 +84,6 @@ _Static_assert(sizeof(char) == 1, "char not correct size");
_Static_assert(sizeof(float) == 4, "float not correct size");
_Static_assert(sizeof(long) >= 4, "long not correct size");
_Static_assert(sizeof(int) == 4, "int not correct size");
_Static_assert(sizeof(short) == 2, "short not correct size");
/* make sure enums are the size of ints for structure packing */
typedef enum {

View File

@ -58,8 +58,8 @@ qboolean shading = true; //johnfitz -- if false, disable vertex shading for vari
//johnfitz -- struct for passing lerp information to drawing functions
typedef struct {
short pose1;
short pose2;
int16_t pose1;
int16_t pose2;
float blend;
vec3_t origin;
vec3_t angles;

View File

@ -83,9 +83,9 @@ typedef struct entity_s
float lerpstart; //johnfitz -- animation lerping
float lerptime; //johnfitz -- animation lerping
float lerpfinish; //johnfitz -- lerping -- server sent us a more accurate interval, use it instead of 0.1
short previouspose; //johnfitz -- animation lerping
short currentpose; //johnfitz -- animation lerping
// short futurepose; //johnfitz -- animation lerping
int16_t previouspose; //johnfitz -- animation lerping
int16_t currentpose; //johnfitz -- animation lerping
// int16_t futurepose; //johnfitz -- animation lerping
float movelerpstart; //johnfitz -- transform lerping
vec3_t previousorigin; //johnfitz -- transform lerping
vec3_t currentorigin; //johnfitz -- transform lerping

View File

@ -712,8 +712,8 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f
break;
dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
s_rawsamples [dst].left = ((short *) data)[src * 2] * intVolume;
s_rawsamples [dst].right = ((short *) data)[src * 2 + 1] * intVolume;
s_rawsamples [dst].left = ((int16_t *) data)[src * 2] * intVolume;
s_rawsamples [dst].right = ((int16_t *) data)[src * 2 + 1] * intVolume;
}
}
else if (channels == 1 && width == 2)
@ -725,8 +725,8 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f
break;
dst = s_rawend & (MAX_RAW_SAMPLES - 1);
s_rawend++;
s_rawsamples [dst].left = ((short *) data)[src] * intVolume;
s_rawsamples [dst].right = ((short *) data)[src] * intVolume;
s_rawsamples [dst].left = ((int16_t *) data)[src] * intVolume;
s_rawsamples [dst].right = ((int16_t *) data)[src] * intVolume;
}
}
else if (channels == 2 && width == 1)

View File

@ -176,7 +176,7 @@ flac_write_func (const FLAC__StreamDecoder *decoder,
}
else
{
short *out = (short *) ff->buffer;
int16_t *out = (int16_t *) ff->buffer;
for (i = 0; i < frame->header.blocksize; i++)
*out++ = *in++;
}
@ -199,8 +199,8 @@ flac_write_func (const FLAC__StreamDecoder *decoder,
}
else
{
short *lo = (short *) ff->buffer + 0;
short *ro = (short *) ff->buffer + 1;
int16_t *lo = (int16_t *) ff->buffer + 0;
int16_t *ro = (int16_t *) ff->buffer + 1;
for (i = 0; i < frame->header.blocksize; i++, lo++, ro++)
{
*lo++ = *li++;

View File

@ -72,11 +72,11 @@ static void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
srcsample = samplefrac >> 8;
samplefrac += fracstep;
if (inwidth == 2)
sample = LittleShort ( ((short *)data)[srcsample] );
sample = LittleShort ( ((int16_t *)data)[srcsample] );
else
sample = (int)( (unsigned char)(data[srcsample]) - 128) << 8;
if (sc->width == 2)
((short *)sc->data)[i] = sample;
((int16_t *)sc->data)[i] = sample;
else
((signed char *)sc->data)[i] = sample >> 8;
}
@ -176,9 +176,9 @@ static byte *last_chunk;
static byte *iff_data;
static int iff_chunk_len;
static short GetLittleShort (void)
static int16_t GetLittleShort (void)
{
short val = 0;
int16_t val = 0;
val = *data_p;
val = val + (*(data_p+1)<<8);
data_p += 2;

View File

@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];
int snd_scaletable[32][256];
int *snd_p, snd_linear_count;
short *snd_out;
int16_t *snd_out;
static int snd_vol;
@ -41,16 +41,16 @@ static void Snd_WriteLinearBlastStereo16 (void)
val = snd_p[i] / 256;
if (val > 0x7fff)
snd_out[i] = 0x7fff;
else if (val < (short)0x8000)
snd_out[i] = (short)0x8000;
else if (val < (int16_t)0x8000)
snd_out[i] = (int16_t)0x8000;
else
snd_out[i] = val;
val = snd_p[i+1] / 256;
if (val > 0x7fff)
snd_out[i+1] = 0x7fff;
else if (val < (short)0x8000)
snd_out[i+1] = (short)0x8000;
else if (val < (int16_t)0x8000)
snd_out[i+1] = (int16_t)0x8000;
else
snd_out[i+1] = val;
}
@ -69,7 +69,7 @@ static void S_TransferStereo16 (int endtime)
// handle recirculating buffer issues
lpos = lpaintedtime & ((shm->samples >> 1) - 1);
snd_out = (short *)shm->buffer + (lpos << 1);
snd_out = (int16_t *)shm->buffer + (lpos << 1);
snd_linear_count = (shm->samples >> 1) - lpos;
if (lpaintedtime + snd_linear_count > endtime)
@ -105,15 +105,15 @@ static void S_TransferPaintBuffer (int endtime)
if (shm->samplebits == 16)
{
short *out = (short *)shm->buffer;
int16_t *out = (int16_t *)shm->buffer;
while (count--)
{
val = *p / 256;
p+= step;
if (val > 0x7fff)
val = 0x7fff;
else if (val < (short)0x8000)
val = (short)0x8000;
else if (val < (int16_t)0x8000)
val = (int16_t)0x8000;
out[out_idx] = val;
out_idx = (out_idx + 1) & out_mask;
}
@ -127,8 +127,8 @@ static void S_TransferPaintBuffer (int endtime)
p+= step;
if (val > 0x7fff)
val = 0x7fff;
else if (val < (short)0x8000)
val = (short)0x8000;
else if (val < (int16_t)0x8000)
val = (int16_t)0x8000;
out[out_idx] = (val / 256) + 128;
out_idx = (out_idx + 1) & out_mask;
}
@ -142,8 +142,8 @@ static void S_TransferPaintBuffer (int endtime)
p+= step;
if (val > 0x7fff)
val = 0x7fff;
else if (val < (short)0x8000)
val = (short)0x8000;
else if (val < (int16_t)0x8000)
val = (int16_t)0x8000;
out[out_idx] = (val / 256);
out_idx = (out_idx + 1) & out_mask;
}
@ -500,14 +500,14 @@ static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count, in
int data;
int left, right;
int leftvol, rightvol;
signed short *sfx;
int16_t *sfx;
int i;
leftvol = ch->leftvol * snd_vol;
rightvol = ch->rightvol * snd_vol;
leftvol /= 256;
rightvol /= 256;
sfx = (signed short *)sc->data + ch->pos;
sfx = (int16_t *)sc->data + ch->pos;
for (i = 0; i < count; i++)
{

View File

@ -309,7 +309,7 @@ static int mp3_decode(snd_stream_t *stream, byte *buf, int len)
for (chan = 0; chan < stream->info.channels; chan++)
{
sample = p->Synth.pcm.samples[chan][p->cursamp];
/* convert from fixed to short,
/* convert from fixed to int16_t,
* write in host-endian format. */
if (sample <= -MAD_F_ONE)
sample = -0x7FFF;

View File

@ -38,7 +38,7 @@
#endif
/* Vorbis codec can return the samples in a number of different
* formats, we use the standard signed short format. */
* formats, we use the standard int16_t format. */
#define VORBIS_SAMPLEBITS 16
#define VORBIS_SAMPLEWIDTH 2
#define VORBIS_SIGNED_DATA 1