unsigned char -> uint8_t (ISO/IEC 2382-1:1993)

master
an 2019-11-25 17:23:46 -05:00
parent d77b584f45
commit f86e0719bb
22 changed files with 456 additions and 456 deletions

View File

@ -791,7 +791,7 @@ int MSG_ReadByte (void)
return -1;
}
c = (unsigned char)net_message.data[msg_readcount];
c = (uint8_t)net_message.data[msg_readcount];
msg_readcount++;
return c;

View File

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.h"
//extern unsigned char d_15to8table[65536]; //johnfitz -- never used
//extern uint8_t d_15to8table[65536]; //johnfitz -- never used
cvar_t scr_conalpha = {"scr_conalpha", "0.5", CVAR_ARCHIVE}; //johnfitz

View File

@ -516,7 +516,7 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
xyz[v].xyz[2] = trivert.v[2];
xyz[v].xyz[3] = 1; // need w 1 for 4 byte vertex compression
// map the normal coordinates in [-1..1] to [-127..127] and store in an unsigned char.
// map the normal coordinates in [-1..1] to [-127..127] and store in an uint8_t.
// this introduces some error (less than 0.004), but the normals were very coarse
// to begin with
xyz[v].normal[0] = 127 * r_avertexnormals[trivert.lightnormalindex][0];

View File

@ -38,7 +38,7 @@ static char loadfilename[MAX_OSPATH]; //file scope so that error messages can us
typedef struct stdio_buffer_s {
FILE *f;
unsigned char buffer[1024];
uint8_t buffer[1024];
int size;
int pos;
} stdio_buffer_t;
@ -102,11 +102,11 @@ byte *Image_LoadImage (const char *name, int *width, int *height)
//==============================================================================
typedef struct targaheader_s {
unsigned char id_length, colormap_type, image_type;
uint8_t id_length, colormap_type, image_type;
uint16_t colormap_index, colormap_length;
unsigned char colormap_size;
uint8_t colormap_size;
uint16_t x_origin, y_origin, width, height;
unsigned char pixel_size, attributes;
uint8_t pixel_size, attributes;
} targaheader_t;
#define TARGAHEADERSIZE 18 //size on disk
@ -240,7 +240,7 @@ byte *Image_LoadTGA (FILE *fin, int *width, int *height)
//johnfitz
for(column=0; column<columns; column++)
{
unsigned char red,green,blue,alphabyte;
uint8_t red,green,blue,alphabyte;
switch (targa_header.pixel_size)
{
case 24:
@ -268,7 +268,7 @@ byte *Image_LoadTGA (FILE *fin, int *width, int *height)
}
else if (targa_header.image_type==10) // Runlength encoded RGB images
{
unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;
uint8_t red,green,blue,alphabyte,packetHeader,packetSize,j;
for(row=rows-1; row>=0; row--)
{
//johnfitz -- fix for upside-down targas
@ -545,8 +545,8 @@ qboolean Image_WritePNG (const char *name, byte *data, int width, int height, in
unsigned error;
char pathname[MAX_OSPATH];
byte *flipped;
unsigned char *filters;
unsigned char *png;
uint8_t *filters;
uint8_t *png;
size_t pngsize;
LodePNGState state;
@ -557,7 +557,7 @@ qboolean Image_WritePNG (const char *name, byte *data, int width, int height, in
q_snprintf (pathname, sizeof(pathname), "%s/%s", com_gamedir, name);
flipped = (!upsidedown)? CopyFlipped (data, width, height, bpp) : data;
filters = (unsigned char *) malloc (height);
filters = (uint8_t *) malloc (height);
if (!filters || !flipped)
{
if (!upsidedown)

View File

@ -855,8 +855,8 @@ void IN_SendKeyEvents (void)
// SDL2 uses the local keyboard layout and handles modifiers
// (shift for uppercase, etc.) for us.
{
unsigned char *ch;
for (ch = (unsigned char *)event.text.text; *ch; ch++)
uint8_t *ch;
for (ch = (uint8_t *)event.text.text; *ch; ch++)
if ((*ch & ~0x7F) == 0)
Char_Event (*ch);
}

File diff suppressed because it is too large Load Diff

View File

@ -113,33 +113,33 @@ colortype: the desired color type for the raw output image. See explanation on P
bitdepth: the desired bit depth for the raw output image. See explanation on PNG color types.
Return value: LodePNG error code (0 means no error).
*/
unsigned lodepng_decode_memory(unsigned char** out, unsigned* w, unsigned* h,
const unsigned char* in, size_t insize,
unsigned lodepng_decode_memory(uint8_t** out, unsigned* w, unsigned* h,
const uint8_t* in, size_t insize,
LodePNGColorType colortype, unsigned bitdepth);
/*Same as lodepng_decode_memory, but always decodes to 32-bit RGBA raw image*/
unsigned lodepng_decode32(unsigned char** out, unsigned* w, unsigned* h,
const unsigned char* in, size_t insize);
unsigned lodepng_decode32(uint8_t** out, unsigned* w, unsigned* h,
const uint8_t* in, size_t insize);
/*Same as lodepng_decode_memory, but always decodes to 24-bit RGB raw image*/
unsigned lodepng_decode24(unsigned char** out, unsigned* w, unsigned* h,
const unsigned char* in, size_t insize);
unsigned lodepng_decode24(uint8_t** out, unsigned* w, unsigned* h,
const uint8_t* in, size_t insize);
#ifdef LODEPNG_COMPILE_DISK
/*
Load PNG from disk, from file with given name.
Same as the other decode functions, but instead takes a filename as input.
*/
unsigned lodepng_decode_file(unsigned char** out, unsigned* w, unsigned* h,
unsigned lodepng_decode_file(uint8_t** out, unsigned* w, unsigned* h,
const char* filename,
LodePNGColorType colortype, unsigned bitdepth);
/*Same as lodepng_decode_file, but always decodes to 32-bit RGBA raw image.*/
unsigned lodepng_decode32_file(unsigned char** out, unsigned* w, unsigned* h,
unsigned lodepng_decode32_file(uint8_t** out, unsigned* w, unsigned* h,
const char* filename);
/*Same as lodepng_decode_file, but always decodes to 24-bit RGB raw image.*/
unsigned lodepng_decode24_file(unsigned char** out, unsigned* w, unsigned* h,
unsigned lodepng_decode24_file(uint8_t** out, unsigned* w, unsigned* h,
const char* filename);
#endif /*LODEPNG_COMPILE_DISK*/
#endif /*LODEPNG_COMPILE_DECODER*/
@ -162,17 +162,17 @@ colortype: the color type of the raw input image. See explanation on PNG color t
bitdepth: the bit depth of the raw input image. See explanation on PNG color types.
Return value: LodePNG error code (0 means no error).
*/
unsigned lodepng_encode_memory(unsigned char** out, size_t* outsize,
const unsigned char* image, unsigned w, unsigned h,
unsigned lodepng_encode_memory(uint8_t** out, size_t* outsize,
const uint8_t* image, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth);
/*Same as lodepng_encode_memory, but always encodes from 32-bit RGBA raw image.*/
unsigned lodepng_encode32(unsigned char** out, size_t* outsize,
const unsigned char* image, unsigned w, unsigned h);
unsigned lodepng_encode32(uint8_t** out, size_t* outsize,
const uint8_t* image, unsigned w, unsigned h);
/*Same as lodepng_encode_memory, but always encodes from 24-bit RGB raw image.*/
unsigned lodepng_encode24(unsigned char** out, size_t* outsize,
const unsigned char* image, unsigned w, unsigned h);
unsigned lodepng_encode24(uint8_t** out, size_t* outsize,
const uint8_t* image, unsigned w, unsigned h);
#ifdef LODEPNG_COMPILE_DISK
/*
@ -181,16 +181,16 @@ Same as the other encode functions, but instead takes a filename as output.
NOTE: This overwrites existing files without warning!
*/
unsigned lodepng_encode_file(const char* filename,
const unsigned char* image, unsigned w, unsigned h,
const uint8_t* image, unsigned w, unsigned h,
LodePNGColorType colortype, unsigned bitdepth);
/*Same as lodepng_encode_file, but always encodes from 32-bit RGBA raw image.*/
unsigned lodepng_encode32_file(const char* filename,
const unsigned char* image, unsigned w, unsigned h);
const uint8_t* image, unsigned w, unsigned h);
/*Same as lodepng_encode_file, but always encodes from 24-bit RGB raw image.*/
unsigned lodepng_encode24_file(const char* filename,
const unsigned char* image, unsigned w, unsigned h);
const uint8_t* image, unsigned w, unsigned h);
#endif /*LODEPNG_COMPILE_DISK*/
#endif /*LODEPNG_COMPILE_ENCODER*/
@ -201,18 +201,18 @@ namespace lodepng
#ifdef LODEPNG_COMPILE_DECODER
/*Same as lodepng_decode_memory, but decodes to an std::vector. The colortype
is the format to output the pixels to. Default is RGBA 8-bit per channel.*/
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
const unsigned char* in, size_t insize,
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
const uint8_t* in, size_t insize,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
const std::vector<unsigned char>& in,
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
const std::vector<uint8_t>& in,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
#ifdef LODEPNG_COMPILE_DISK
/*
Converts PNG file from disk to raw pixel data in memory.
Same as the other decode functions, but instead takes a filename as input.
*/
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
const std::string& filename,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
#endif /* LODEPNG_COMPILE_DISK */
@ -221,11 +221,11 @@ unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
#ifdef LODEPNG_COMPILE_ENCODER
/*Same as lodepng_encode_memory, but encodes to an std::vector. colortype
is that of the raw input data. The output PNG color type will be auto chosen.*/
unsigned encode(std::vector<unsigned char>& out,
const unsigned char* in, unsigned w, unsigned h,
unsigned encode(std::vector<uint8_t>& out,
const uint8_t* in, unsigned w, unsigned h,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
unsigned encode(std::vector<unsigned char>& out,
const std::vector<unsigned char>& in, unsigned w, unsigned h,
unsigned encode(std::vector<uint8_t>& out,
const std::vector<uint8_t>& in, unsigned w, unsigned h,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
#ifdef LODEPNG_COMPILE_DISK
/*
@ -234,10 +234,10 @@ Same as the other encode functions, but instead takes a filename as output.
NOTE: This overwrites existing files without warning!
*/
unsigned encode(const std::string& filename,
const unsigned char* in, unsigned w, unsigned h,
const uint8_t* in, unsigned w, unsigned h,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
unsigned encode(const std::string& filename,
const std::vector<unsigned char>& in, unsigned w, unsigned h,
const std::vector<uint8_t>& in, unsigned w, unsigned h,
LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);
#endif /* LODEPNG_COMPILE_DISK */
#endif /* LODEPNG_COMPILE_ENCODER */
@ -259,14 +259,14 @@ struct LodePNGDecompressSettings
unsigned ignore_adler32; /*if 1, continue and don't give an error message if the Adler32 checksum is corrupted*/
/*use custom zlib decoder instead of built in one (default: null)*/
unsigned (*custom_zlib)(unsigned char**, size_t*,
const unsigned char*, size_t,
unsigned (*custom_zlib)(uint8_t**, size_t*,
const uint8_t*, size_t,
const LodePNGDecompressSettings*);
/*use custom deflate decoder instead of built in one (default: null)
if custom_zlib is used, custom_deflate is ignored since only the built in
zlib function will call custom_deflate*/
unsigned (*custom_inflate)(unsigned char**, size_t*,
const unsigned char*, size_t,
unsigned (*custom_inflate)(uint8_t**, size_t*,
const uint8_t*, size_t,
const LodePNGDecompressSettings*);
const void* custom_context; /*optional custom settings for custom functions*/
@ -293,14 +293,14 @@ struct LodePNGCompressSettings /*deflate = compress*/
unsigned lazymatching; /*use lazy matching: better compression but a bit slower. Default: true*/
/*use custom zlib encoder instead of built in one (default: null)*/
unsigned (*custom_zlib)(unsigned char**, size_t*,
const unsigned char*, size_t,
unsigned (*custom_zlib)(uint8_t**, size_t*,
const uint8_t*, size_t,
const LodePNGCompressSettings*);
/*use custom deflate encoder instead of built in one (default: null)
if custom_zlib is used, custom_deflate is ignored since only the built in
zlib function will call custom_deflate*/
unsigned (*custom_deflate)(unsigned char**, size_t*,
const unsigned char*, size_t,
unsigned (*custom_deflate)(uint8_t**, size_t*,
const uint8_t*, size_t,
const LodePNGCompressSettings*);
const void* custom_context; /*optional custom settings for custom functions*/
@ -335,7 +335,7 @@ typedef struct LodePNGColorMode
The palette is only supported for color type 3.
*/
unsigned char* palette; /*palette in RGBARGBA... order. When allocated, must be either 0, or have size 1024*/
uint8_t* palette; /*palette in RGBARGBA... order. When allocated, must be either 0, or have size 1024*/
size_t palettesize; /*palette size in number of colors (amount of bytes is 4 * palettesize)*/
/*
@ -364,7 +364,7 @@ unsigned lodepng_color_mode_copy(LodePNGColorMode* dest, const LodePNGColorMode*
void lodepng_palette_clear(LodePNGColorMode* info);
/*add 1 color to the palette*/
unsigned lodepng_palette_add(LodePNGColorMode* info,
unsigned char r, unsigned char g, unsigned char b, unsigned char a);
uint8_t r, uint8_t g, uint8_t b, uint8_t a);
/*get the total amount of bits per pixel, based on colortype and bitdepth in the struct*/
unsigned lodepng_get_bpp(const LodePNGColorMode* info);
@ -477,7 +477,7 @@ typedef struct LodePNGInfo
Do not allocate or traverse this data yourself. Use the chunk traversing functions declared
later, such as lodepng_chunk_next and lodepng_chunk_append, to read/write this struct.
*/
unsigned char* unknown_chunks_data[3];
uint8_t* unknown_chunks_data[3];
size_t unknown_chunks_size[3]; /*size in bytes of the unknown chunks, given for protection*/
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
} LodePNGInfo;
@ -508,7 +508,7 @@ For < 8 bpp images, there should not be padding bits at the end of scanlines.
For 16-bit per channel colors, uses big endian format like PNG does.
Return value is LodePNG error code
*/
unsigned lodepng_convert(unsigned char* out, const unsigned char* in,
unsigned lodepng_convert(uint8_t* out, const uint8_t* in,
const LodePNGColorMode* mode_out, const LodePNGColorMode* mode_in,
unsigned w, unsigned h);
@ -569,7 +569,7 @@ typedef struct LodePNGColorProfile
uint16_t key_b;
unsigned alpha; /*image is not opaque and alpha channel or alpha palette required*/
unsigned numcolors; /*amount of colors, up to 257. Not valid if bits == 16.*/
unsigned char palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order*/
uint8_t palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order*/
unsigned bits; /*bits per channel (not for palette). 1,2 or 4 for greyscale only. 16 if 16-bit per channel required.*/
} LodePNGColorProfile;
@ -577,12 +577,12 @@ void lodepng_color_profile_init(LodePNGColorProfile* profile);
/*Get a LodePNGColorProfile of the image.*/
unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
const unsigned char* image, unsigned w, unsigned h,
const uint8_t* image, unsigned w, unsigned h,
const LodePNGColorMode* mode_in);
/*The function LodePNG uses internally to decide the PNG color with auto_convert.
Chooses an optimal color model, e.g. grey if only grey pixels, palette if < 256 colors, ...*/
unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
const unsigned char* image, unsigned w, unsigned h,
const uint8_t* image, unsigned w, unsigned h,
const LodePNGColorMode* mode_in);
/*Settings for the encoder.*/
@ -604,7 +604,7 @@ typedef struct LodePNGEncoderSettings
the same length as the amount of scanlines in the image, and each value must <= 5. You
have to cleanup this buffer, LodePNG will never free it. Don't forget that filter_palette_zero
must be set to 0 to ensure this is also used on palette or low bitdepth images.*/
const unsigned char* predefined_filters;
const uint8_t* predefined_filters;
/*force creating a PLTE chunk if colortype is 2 or 6 (= a suggested palette).
If colortype is 3, PLTE is _always_ created.*/
@ -651,9 +651,9 @@ void lodepng_state_copy(LodePNGState* dest, const LodePNGState* source);
Same as lodepng_decode_memory, but uses a LodePNGState to allow custom settings and
getting much more information about the PNG image and color mode.
*/
unsigned lodepng_decode(unsigned char** out, unsigned* w, unsigned* h,
unsigned lodepng_decode(uint8_t** out, unsigned* w, unsigned* h,
LodePNGState* state,
const unsigned char* in, size_t insize);
const uint8_t* in, size_t insize);
/*
Read the PNG header, but not the actual data. This returns only the information
@ -662,14 +662,14 @@ information is placed in the info_png field of the LodePNGState.
*/
unsigned lodepng_inspect(unsigned* w, unsigned* h,
LodePNGState* state,
const unsigned char* in, size_t insize);
const uint8_t* in, size_t insize);
#endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER
/*This function allocates the out buffer with standard malloc and stores the size in *outsize.*/
unsigned lodepng_encode(unsigned char** out, size_t* outsize,
const unsigned char* image, unsigned w, unsigned h,
unsigned lodepng_encode(uint8_t** out, size_t* outsize,
const uint8_t* image, unsigned w, unsigned h,
LodePNGState* state);
#endif /*LODEPNG_COMPILE_ENCODER*/
@ -690,43 +690,43 @@ Gets the length of the data of the chunk. Total chunk length has 12 bytes more.
There must be at least 4 bytes to read from. If the result value is too large,
it may be corrupt data.
*/
unsigned lodepng_chunk_length(const unsigned char* chunk);
unsigned lodepng_chunk_length(const uint8_t* chunk);
/*puts the 4-byte type in null terminated string*/
void lodepng_chunk_type(char type[5], const unsigned char* chunk);
void lodepng_chunk_type(char type[5], const uint8_t* chunk);
/*check if the type is the given type*/
unsigned char lodepng_chunk_type_equals(const unsigned char* chunk, const char* type);
uint8_t lodepng_chunk_type_equals(const uint8_t* chunk, const char* type);
/*0: it's one of the critical chunk types, 1: it's an ancillary chunk (see PNG standard)*/
unsigned char lodepng_chunk_ancillary(const unsigned char* chunk);
uint8_t lodepng_chunk_ancillary(const uint8_t* chunk);
/*0: public, 1: private (see PNG standard)*/
unsigned char lodepng_chunk_private(const unsigned char* chunk);
uint8_t lodepng_chunk_private(const uint8_t* chunk);
/*0: the chunk is unsafe to copy, 1: the chunk is safe to copy (see PNG standard)*/
unsigned char lodepng_chunk_safetocopy(const unsigned char* chunk);
uint8_t lodepng_chunk_safetocopy(const uint8_t* chunk);
/*get pointer to the data of the chunk, where the input points to the header of the chunk*/
unsigned char* lodepng_chunk_data(unsigned char* chunk);
const unsigned char* lodepng_chunk_data_const(const unsigned char* chunk);
uint8_t* lodepng_chunk_data(uint8_t* chunk);
const uint8_t* lodepng_chunk_data_const(const uint8_t* chunk);
/*returns 0 if the crc is correct, 1 if it's incorrect (0 for OK as usual!)*/
unsigned lodepng_chunk_check_crc(const unsigned char* chunk);
unsigned lodepng_chunk_check_crc(const uint8_t* chunk);
/*generates the correct CRC from the data and puts it in the last 4 bytes of the chunk*/
void lodepng_chunk_generate_crc(unsigned char* chunk);
void lodepng_chunk_generate_crc(uint8_t* chunk);
/*iterate to next chunks. don't use on IEND chunk, as there is no next chunk then*/
unsigned char* lodepng_chunk_next(unsigned char* chunk);
const unsigned char* lodepng_chunk_next_const(const unsigned char* chunk);
uint8_t* lodepng_chunk_next(uint8_t* chunk);
const uint8_t* lodepng_chunk_next_const(const uint8_t* chunk);
/*
Appends chunk to the data in out. The given chunk should already have its chunk header.
The out variable and outlength are updated to reflect the new reallocated buffer.
Returns error code (0 if it went ok)
*/
unsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk);
unsigned lodepng_chunk_append(uint8_t** out, size_t* outlength, const uint8_t* chunk);
/*
Appends new chunk to out. The chunk to append is given by giving its length, type
@ -734,12 +734,12 @@ and data separately. The type is a 4-letter string.
The out variable and outlength are updated to reflect the new reallocated buffer.
Returne error code (0 if it went ok)
*/
unsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length,
const char* type, const unsigned char* data);
unsigned lodepng_chunk_create(uint8_t** out, size_t* outlength, unsigned length,
const char* type, const uint8_t* data);
/*Calculate CRC32 of buffer*/
unsigned lodepng_crc32(const unsigned char* buf, size_t len);
unsigned lodepng_crc32(const uint8_t* buf, size_t len);
#endif /*LODEPNG_COMPILE_PNG*/
@ -752,8 +752,8 @@ part of zlib that is required for PNG, it does not support dictionaries.
#ifdef LODEPNG_COMPILE_DECODER
/*Inflate a buffer. Inflate is the decompression step of deflate. Out buffer must be freed after use.*/
unsigned lodepng_inflate(unsigned char** out, size_t* outsize,
const unsigned char* in, size_t insize,
unsigned lodepng_inflate(uint8_t** out, size_t* outsize,
const uint8_t* in, size_t insize,
const LodePNGDecompressSettings* settings);
/*
@ -762,8 +762,8 @@ data must be according to the zlib specification.
Either, *out must be NULL and *outsize must be 0, or, *out must be a valid
buffer and *outsize its size in bytes. out must be freed by user after usage.
*/
unsigned lodepng_zlib_decompress(unsigned char** out, size_t* outsize,
const unsigned char* in, size_t insize,
unsigned lodepng_zlib_decompress(uint8_t** out, size_t* outsize,
const uint8_t* in, size_t insize,
const LodePNGDecompressSettings* settings);
#endif /*LODEPNG_COMPILE_DECODER*/
@ -775,8 +775,8 @@ The data is output in the format of the zlib specification.
Either, *out must be NULL and *outsize must be 0, or, *out must be a valid
buffer and *outsize its size in bytes. out must be freed by user after usage.
*/
unsigned lodepng_zlib_compress(unsigned char** out, size_t* outsize,
const unsigned char* in, size_t insize,
unsigned lodepng_zlib_compress(uint8_t** out, size_t* outsize,
const uint8_t* in, size_t insize,
const LodePNGCompressSettings* settings);
/*
@ -787,8 +787,8 @@ unsigned lodepng_huffman_code_lengths(unsigned* lengths, const unsigned* frequen
size_t numcodes, unsigned maxbitlen);
/*Compress a buffer with deflate. See RFC 1951. Out buffer must be freed after use.*/
unsigned lodepng_deflate(unsigned char** out, size_t* outsize,
const unsigned char* in, size_t insize,
unsigned lodepng_deflate(uint8_t** out, size_t* outsize,
const uint8_t* in, size_t insize,
const LodePNGCompressSettings* settings);
#endif /*LODEPNG_COMPILE_ENCODER*/
@ -803,7 +803,7 @@ outsize: output parameter, size of the allocated out buffer
filename: the path to the file to load
return value: error code (0 means ok)
*/
unsigned lodepng_load_file(unsigned char** out, size_t* outsize, const char* filename);
unsigned lodepng_load_file(uint8_t** out, size_t* outsize, const char* filename);
/*
Save a file from buffer to disk. Warning, if it exists, this function overwrites
@ -813,7 +813,7 @@ buffersize: size of the buffer to write
filename: the path to the file to save to
return value: error code (0 means ok)
*/
unsigned lodepng_save_file(const unsigned char* buffer, size_t buffersize, const char* filename);
unsigned lodepng_save_file(const uint8_t* buffer, size_t buffersize, const char* filename);
#endif /*LODEPNG_COMPILE_DISK*/
#ifdef LODEPNG_COMPILE_CPP
@ -832,21 +832,21 @@ class State : public LodePNGState
#ifdef LODEPNG_COMPILE_DECODER
/* Same as other lodepng::decode, but using a State for more settings and information. */
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
State& state,
const unsigned char* in, size_t insize);
unsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,
const uint8_t* in, size_t insize);
unsigned decode(std::vector<uint8_t>& out, unsigned& w, unsigned& h,
State& state,
const std::vector<unsigned char>& in);
const std::vector<uint8_t>& in);
#endif /*LODEPNG_COMPILE_DECODER*/
#ifdef LODEPNG_COMPILE_ENCODER
/* Same as other lodepng::encode, but using a State for more settings and information. */
unsigned encode(std::vector<unsigned char>& out,
const unsigned char* in, unsigned w, unsigned h,
unsigned encode(std::vector<uint8_t>& out,
const uint8_t* in, unsigned w, unsigned h,
State& state);
unsigned encode(std::vector<unsigned char>& out,
const std::vector<unsigned char>& in, unsigned w, unsigned h,
unsigned encode(std::vector<uint8_t>& out,
const std::vector<uint8_t>& in, unsigned w, unsigned h,
State& state);
#endif /*LODEPNG_COMPILE_ENCODER*/
@ -855,34 +855,34 @@ unsigned encode(std::vector<unsigned char>& out,
Load a file from disk into an std::vector.
return value: error code (0 means ok)
*/
unsigned load_file(std::vector<unsigned char>& buffer, const std::string& filename);
unsigned load_file(std::vector<uint8_t>& buffer, const std::string& filename);
/*
Save the binary data in an std::vector to a file on disk. The file is overwritten
without warning.
*/
unsigned save_file(const std::vector<unsigned char>& buffer, const std::string& filename);
unsigned save_file(const std::vector<uint8_t>& buffer, const std::string& filename);
#endif /* LODEPNG_COMPILE_DISK */
#endif /* LODEPNG_COMPILE_PNG */
#ifdef LODEPNG_COMPILE_ZLIB
#ifdef LODEPNG_COMPILE_DECODER
/* Zlib-decompress an unsigned char buffer */
unsigned decompress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,
/* Zlib-decompress an uint8_t buffer */
unsigned decompress(std::vector<uint8_t>& out, const uint8_t* in, size_t insize,
const LodePNGDecompressSettings& settings = lodepng_default_decompress_settings);
/* Zlib-decompress an std::vector */
unsigned decompress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,
unsigned decompress(std::vector<uint8_t>& out, const std::vector<uint8_t>& in,
const LodePNGDecompressSettings& settings = lodepng_default_decompress_settings);
#endif /* LODEPNG_COMPILE_DECODER */
#ifdef LODEPNG_COMPILE_ENCODER
/* Zlib-compress an unsigned char buffer */
unsigned compress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,
/* Zlib-compress an uint8_t buffer */
unsigned compress(std::vector<uint8_t>& out, const uint8_t* in, size_t insize,
const LodePNGCompressSettings& settings = lodepng_default_compress_settings);
/* Zlib-compress an std::vector */
unsigned compress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,
unsigned compress(std::vector<uint8_t>& out, const std::vector<uint8_t>& in,
const LodePNGCompressSettings& settings = lodepng_default_compress_settings);
#endif /* LODEPNG_COMPILE_ENCODER */
#endif /* LODEPNG_COMPILE_ZLIB */
@ -1315,7 +1315,7 @@ not the first bit of a new byte.
6.4. A note about 16-bits per channel and endianness
----------------------------------------------------
LodePNG uses unsigned char arrays for 16-bit per channel colors too, just like
LodePNG uses uint8_t arrays for 16-bit per channel colors too, just like
for any other color format. The 16-bit values are stored in big endian (most
significant byte first) in these arrays. This is the opposite order of the
little endian used by x86 CPU's.
@ -1329,7 +1329,7 @@ converting to/from all that is outside the scope of LodePNG.
This may mean that, depending on your use case, you may want to convert the big
endian output of LodePNG to little endian with a for loop. This is certainly not
always needed, many applications and libraries support big endian 16-bit colors
anyway, but it means you cannot simply cast the unsigned char* buffer to an
anyway, but it means you cannot simply cast the uint8_t* buffer to an
uint16_t* buffer on x86 CPUs.
@ -1374,18 +1374,18 @@ exploits, always make sure the buffer contains all the data of the chunks.
When using lodepng_chunk_next, make sure the returned value is within the
allocated memory.
unsigned lodepng_chunk_length(const unsigned char* chunk):
unsigned lodepng_chunk_length(const uint8_t* chunk):
Get the length of the chunk's data. The total chunk length is this length + 12.
void lodepng_chunk_type(char type[5], const unsigned char* chunk):
unsigned char lodepng_chunk_type_equals(const unsigned char* chunk, const char* type):
void lodepng_chunk_type(char type[5], const uint8_t* chunk):
uint8_t lodepng_chunk_type_equals(const uint8_t* chunk, const char* type):
Get the type of the chunk or compare if it's a certain type
unsigned char lodepng_chunk_critical(const unsigned char* chunk):
unsigned char lodepng_chunk_private(const unsigned char* chunk):
unsigned char lodepng_chunk_safetocopy(const unsigned char* chunk):
uint8_t lodepng_chunk_critical(const uint8_t* chunk):
uint8_t lodepng_chunk_private(const uint8_t* chunk):
uint8_t lodepng_chunk_safetocopy(const uint8_t* chunk):
Check if the chunk is critical in the PNG standard (only IHDR, PLTE, IDAT and IEND are).
Check if the chunk is private (public chunks are part of the standard, private ones not).
@ -1393,26 +1393,26 @@ Check if the chunk is safe to copy. If it's not, then, when modifying data in a
chunk, unsafe to copy chunks of the old image may NOT be saved in the new one if your
program doesn't handle that type of unknown chunk.
unsigned char* lodepng_chunk_data(unsigned char* chunk):
const unsigned char* lodepng_chunk_data_const(const unsigned char* chunk):
uint8_t* lodepng_chunk_data(uint8_t* chunk):
const uint8_t* lodepng_chunk_data_const(const uint8_t* chunk):
Get a pointer to the start of the data of the chunk.
unsigned lodepng_chunk_check_crc(const unsigned char* chunk):
void lodepng_chunk_generate_crc(unsigned char* chunk):
unsigned lodepng_chunk_check_crc(const uint8_t* chunk):
void lodepng_chunk_generate_crc(uint8_t* chunk):
Check if the crc is correct or generate a correct one.
unsigned char* lodepng_chunk_next(unsigned char* chunk):
const unsigned char* lodepng_chunk_next_const(const unsigned char* chunk):
uint8_t* lodepng_chunk_next(uint8_t* chunk):
const uint8_t* lodepng_chunk_next_const(const uint8_t* chunk):
Iterate to the next chunk. This works if you have a buffer with consecutive chunks. Note that these
functions do no boundary checking of the allocated data whatsoever, so make sure there is enough
data available in the buffer to be able to go to the next chunk.
unsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk):
unsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length,
const char* type, const unsigned char* data):
unsigned lodepng_chunk_append(uint8_t** out, size_t* outlength, const uint8_t* chunk):
unsigned lodepng_chunk_create(uint8_t** out, size_t* outlength, unsigned length,
const char* type, const uint8_t* data):
These functions are used to create new chunks that are appended to the data in *out that has
length *outlength. The append function appends an existing chunk to the new data. The create
@ -1529,7 +1529,7 @@ int main(int argc, char *argv[])
const char* filename = argc > 1 ? argv[1] : "test.png";
//load and decode
std::vector<unsigned char> image;
std::vector<uint8_t> image;
unsigned width, height;
unsigned error = lodepng::decode(image, width, height, filename);
@ -1547,7 +1547,7 @@ int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
unsigned error;
unsigned char* image;
uint8_t* image;
size_t width, height;
const char* filename = argc > 1 ? argv[1] : "test.png";

View File

@ -27,12 +27,12 @@
struct qsockaddr
{
#if defined(HAVE_SA_LEN)
unsigned char qsa_len;
unsigned char qsa_family;
uint8_t qsa_len;
uint8_t qsa_family;
#else
int16_t qsa_family;
#endif /* BSD, sockaddr */
unsigned char qsa_data[14];
uint8_t qsa_data[14];
};
#define NET_HEADERSIZE (2 * sizeof(uint32_t))

View File

@ -32,8 +32,8 @@
#if defined(PLATFORM_BSD) || defined(PLATFORM_OSX) || \
defined(PLATFORM_AMIGA) /* bsdsocket.library */ || \
defined(__GNU__) /* GNU/Hurd */ || defined(__riscos__)
/* struct sockaddr has unsigned char sa_len as the first member in BSD
* variants and the family member is also an unsigned char instead of an
/* struct sockaddr has uint8_t sa_len as the first member in BSD
* variants and the family member is also an uint8_t instead of an
* uint16_t. This should matter only when PLATFORM_UNIX is defined,
* however, checking for the offset of sa_family in every platform that
* provide a struct sockaddr doesn't hurt either (see down below for the

View File

@ -46,7 +46,7 @@ typedef struct edict_s
int leafnums[MAX_ENT_LEAFS];
entity_state_t baseline;
unsigned char alpha; /* johnfitz -- hack to support alpha since it's not part of entvars_t */
uint8_t alpha; /* johnfitz -- hack to support alpha since it's not part of entvars_t */
qboolean sendinterval; /* johnfitz -- send time until nextthink to client for better lerp timing */
float freetime; /* sv.time when the object was freed */

View File

@ -237,9 +237,9 @@ typedef struct
vec3_t angles;
uint16_t modelindex; //johnfitz -- was int
uint16_t frame; //johnfitz -- was int
unsigned char colormap; //johnfitz -- was int
unsigned char skin; //johnfitz -- was int
unsigned char alpha; //johnfitz -- added
uint8_t colormap; //johnfitz -- was int
uint8_t skin; //johnfitz -- was int
uint8_t alpha; //johnfitz -- added
int effects;
} entity_state_t;

View File

@ -58,7 +58,7 @@ typedef struct
int samplebits;
int signed8; /* device opened for S8 format? (e.g. Amiga AHI) */
int speed;
unsigned char *buffer;
uint8_t *buffer;
} dma_t;
/* !!! if this is changed, it must be changed in asm_i386.h too !!! */

View File

@ -83,7 +83,7 @@ _Static_assert(sizeof(THE_DUMMY_ENUM) == sizeof(int), "enum not sizeof(int)");
/*==========================================================================*/
typedef unsigned char byte;
typedef uint8_t byte;
typedef enum {
false = 0,

View File

@ -38,7 +38,7 @@ gltexture_t *lightmap_textures[MAX_LIGHTMAPS]; //johnfitz -- changed to an array
unsigned blocklights[BLOCK_WIDTH*BLOCK_HEIGHT*3]; //johnfitz -- was 18*18, added lit support (*3) and loosened surface extents maximum (BLOCK_WIDTH*BLOCK_HEIGHT)
typedef struct glRect_s {
unsigned char l,t,w,h;
uint8_t l,t,w,h;
} glRect_t;
glpoly_t *lightmap_polys[MAX_LIGHTMAPS];

View File

@ -60,7 +60,7 @@ static void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
{
// fast special case
for (i = 0; i < outcount; i++)
((signed char *)sc->data)[i] = (int)( (unsigned char)(data[i]) - 128);
((signed char *)sc->data)[i] = (int)( (uint8_t)(data[i]) - 128);
}
else
{
@ -74,7 +74,7 @@ static void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
if (inwidth == 2)
sample = LittleShort ( ((int16_t *)data)[srcsample] );
else
sample = (int)( (unsigned char)(data[srcsample]) - 128) << 8;
sample = (int)( (uint8_t)(data[srcsample]) - 128) << 8;
if (sc->width == 2)
((int16_t *)sc->data)[i] = sample;
else

View File

@ -120,7 +120,7 @@ static void S_TransferPaintBuffer (int endtime)
}
else if (shm->samplebits == 8 && !shm->signed8)
{
unsigned char *out = shm->buffer;
uint8_t *out = shm->buffer;
while (count--)
{
val = *p / 256;
@ -473,7 +473,7 @@ static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int
{
int data;
int *lscale, *rscale;
unsigned char *sfx;
uint8_t *sfx;
int i;
if (ch->leftvol > 255)
@ -483,7 +483,7 @@ static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int
lscale = snd_scaletable[ch->leftvol >> 3];
rscale = snd_scaletable[ch->rightvol >> 3];
sfx = (unsigned char *)sc->data + ch->pos;
sfx = (uint8_t *)sc->data + ch->pos;
for (i = 0; i < count; i++)
{

View File

@ -55,7 +55,7 @@ static mad_timer_t const mad_timer_zero_stub = {0, 0};
/* Private data */
typedef struct _mp3_priv_t
{
unsigned char mp3_buffer[MP3_BUFFER_SIZE];
uint8_t mp3_buffer[MP3_BUFFER_SIZE];
struct mad_stream Stream;
struct mad_frame Frame;
struct mad_synth Synth;
@ -67,7 +67,7 @@ typedef struct _mp3_priv_t
/* This function merges the functions tagtype() and id3_tag_query()
* from MAD's libid3tag, so we don't have to link to it
* Returns 0 if the frame is not an ID3 tag, tag length if it is */
static inline qboolean tag_is_id3v1(const unsigned char *data, size_t length)
static inline qboolean tag_is_id3v1(const uint8_t *data, size_t length)
{
if (length >= 3 &&
data[0] == 'T' && data[1] == 'A' && data[2] == 'G')
@ -77,7 +77,7 @@ static inline qboolean tag_is_id3v1(const unsigned char *data, size_t length)
return false;
}
static inline qboolean tag_is_id3v2(const unsigned char *data, size_t length)
static inline qboolean tag_is_id3v2(const uint8_t *data, size_t length)
{
if (length >= 10 &&
(data[0] == 'I' && data[1] == 'D' && data[2] == '3') &&
@ -93,7 +93,7 @@ static inline qboolean tag_is_id3v2(const unsigned char *data, size_t length)
* http://wiki.hydrogenaud.io/index.php?title=APEv2_specification
* Detect an APEv2 tag. (APEv1 has no header, so no luck.)
*/
static inline qboolean tag_is_apetag(const unsigned char *data, size_t length)
static inline qboolean tag_is_apetag(const uint8_t *data, size_t length)
{
uint32_t v;
@ -109,7 +109,7 @@ static inline qboolean tag_is_apetag(const unsigned char *data, size_t length)
return true;
}
static size_t mp3_tagsize(const unsigned char *data, size_t length)
static size_t mp3_tagsize(const uint8_t *data, size_t length)
{
size_t size;
@ -118,7 +118,7 @@ static size_t mp3_tagsize(const unsigned char *data, size_t length)
if (tag_is_id3v2(data, length))
{
unsigned char flags = data[5];
uint8_t flags = data[5];
size = 10 + (data[6]<<21) + (data[7]<<14) + (data[8]<<7) + data[9];
if (flags & ID3_TAG_FLAG_FOOTERPRESENT)
size += 10;

View File

@ -180,7 +180,7 @@ static int S_MP3_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer)
{
mp3_priv_t *priv = (mp3_priv_t *) stream->priv;
size_t bytes_read = 0;
int res = mpg123_read (priv->handle, (unsigned char *)buffer, (size_t)bytes, &bytes_read);
int res = mpg123_read (priv->handle, (uint8_t *)buffer, (size_t)bytes, &bytes_read);
switch (res)
{
case MPG123_DONE:

View File

@ -40,7 +40,7 @@ static int opc_fclose (void *f)
return 0; /* we fclose() elsewhere. */
}
static int opc_fread (void *f, unsigned char *buf, int size)
static int opc_fread (void *f, uint8_t *buf, int size)
{
int ret;
@ -69,7 +69,7 @@ static opus_int64 opc_ftell (void *f)
static const OpusFileCallbacks opc_qfs =
{
(int (*)(void *, unsigned char *, int)) opc_fread,
(int (*)(void *, uint8_t *, int)) opc_fread,
(int (*)(void *, opus_int64, int)) opc_fseek,
(opus_int64 (*)(void *)) opc_ftell,
(int (*)(void *)) opc_fclose

View File

@ -159,7 +159,7 @@ qboolean SNDDMA_Init (dma_t *dma)
buffersize = shm->samples * (shm->samplebits / 8);
Con_Printf ("SDL audio driver: %s, %d bytes buffer\n", drivername, buffersize);
shm->buffer = (unsigned char *) calloc (1, buffersize);
shm->buffer = (uint8_t *) calloc (1, buffersize);
if (!shm->buffer)
{
SDL_CloseAudio();

View File

@ -142,7 +142,7 @@ _retry:
return UMUSIC_XM;
}
if (type == UMUSIC_MP2) {
unsigned char *p = (unsigned char *)sig;
uint8_t *p = (uint8_t *)sig;
uint16_t u = ((p[0] << 8) | p[1]) & 0xFFFE;
if (u == 0xFFFC || u == 0xFFF4)
return UMUSIC_MP2;
@ -276,12 +276,12 @@ static int probe_umx (fshandle_t *f, const struct upkg_hdr *hdr,
static int32_t probe_header (void *header)
{
struct upkg_hdr *hdr;
unsigned char *p;
uint8_t *p;
uint32_t *swp;
int i;
/* byte swap the header - all members are 32 bit LE values */
p = (unsigned char *) header;
p = (uint8_t *) header;
swp = (uint32_t *) header;
for (i = 0; i < UPKG_HDR_SIZE/4; i++, p += 4) {
swp[i] = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);

View File

@ -201,7 +201,7 @@ STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x,
#define STBIW_ASSERT(x) assert(x)
#endif
#define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff)
#define STBIW_UCHAR(x) (uint8_t) ((x) & 0xff)
typedef struct
{
@ -240,7 +240,7 @@ static void stbi__end_write_file(stbi__write_context *s)
typedef uint32_t stbiw_uint32;
typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1];
static void stbiw__putc(stbi__write_context *s, unsigned char c)
static void stbiw__putc(stbi__write_context *s, uint8_t c)
{
s->func(s->context, &c, 1);
}
@ -253,7 +253,7 @@ static void stbiw__putc(stbi__write_context *s, unsigned char c)
* public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html
*/
static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,
static const uint8_t stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,
24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 };
static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const uint16_t *bs) {
@ -261,7 +261,7 @@ static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitC
bitCnt += bs[1];
bitBuf |= bs[0] << (24 - bitCnt);
while(bitCnt >= 8) {
unsigned char c = (bitBuf >> 16) & 255;
uint8_t c = (bitBuf >> 16) & 255;
stbiw__putc(s, c);
if(c == 255) {
stbiw__putc(s, 0);
@ -403,10 +403,10 @@ static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt
static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) {
// Constants that don't pollute global namespace
static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0};
static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};
static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d};
static const unsigned char std_ac_luminance_values[] = {
static const uint8_t std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0};
static const uint8_t std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};
static const uint8_t std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d};
static const uint8_t std_ac_luminance_values[] = {
0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08,
0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28,
0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,
@ -415,10 +415,10 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,
0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa
};
static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0};
static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};
static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77};
static const unsigned char std_ac_chrominance_values[] = {
static const uint8_t std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0};
static const uint8_t std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};
static const uint8_t std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77};
static const uint8_t std_ac_chrominance_values[] = {
0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91,
0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26,
0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,
@ -475,7 +475,7 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
int row, col, i, k;
float fdtbl_Y[64], fdtbl_UV[64];
unsigned char YTable[64], UVTable[64];
uint8_t YTable[64], UVTable[64];
if(!data || !width || !height || comp > 4 || comp < 1) {
return 0;
@ -487,9 +487,9 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
for(i = 0; i < 64; ++i) {
int uvti, yti = (YQT[i]*quality+50)/100;
YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti);
YTable[stbiw__jpg_ZigZag[i]] = (uint8_t) (yti < 1 ? 1 : yti > 255 ? 255 : yti);
uvti = (UVQT[i]*quality+50)/100;
UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti);
UVTable[stbiw__jpg_ZigZag[i]] = (uint8_t) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti);
}
for(row = 0, k = 0; row < 8; ++row) {
@ -501,13 +501,13 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
// Write Headers
{
static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 };
static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 };
unsigned char head1[] = { 0xFF,0xC0,0,0x11,8, /*[5]*/0,/*[6]*/0,/*[7]*/0,/*[8]*/0,
static const uint8_t head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 };
static const uint8_t head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 };
uint8_t head1[] = { 0xFF,0xC0,0,0x11,8, /*[5]*/0,/*[6]*/0,/*[7]*/0,/*[8]*/0,
3,1,0x11,0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 };
head1[5] = (unsigned char)(height>>8);
head1[5] = (uint8_t)(height>>8);
head1[6] = STBIW_UCHAR(height);
head1[7] = (unsigned char)(width>>8);
head1[7] = (uint8_t)(width>>8);
head1[8] = STBIW_UCHAR(width);
s->func(s->context, (void*)head0, sizeof(head0));
s->func(s->context, (void*)YTable, sizeof(YTable));
@ -531,7 +531,7 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
// Encode 8x8 macroblocks
{
static const uint16_t fillBits[] = {0x7F, 7};
const unsigned char *imageData = (const unsigned char *)data;
const uint8_t *imageData = (const uint8_t *)data;
int DCY=0, DCU=0, DCV=0;
int bitBuf=0, bitCnt=0;
// comp == 2 is grey+alpha (alpha is ignored)
@ -635,7 +635,7 @@ STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const
0.93 (2014-05-27)
warning fixes
0.92 (2010-08-01)
casts to unsigned char to fix warnings
casts to uint8_t to fix warnings
0.91 (2010-07-17)
first public release
0.90 first internal release