whitespace + unsigned

SVN revision: 14917
This commit is contained in:
Carsten Haitzler 2005-05-23 04:32:04 +00:00
parent 56eb17e152
commit 2f81db8bb2
7 changed files with 466 additions and 448 deletions

View File

@ -1,3 +1,6 @@
/* strdup requires BSD source */
#define _BSD_SOURCE
#include "Eet.h"
#include <stdio.h>
#include <unistd.h>
@ -31,6 +34,9 @@ main(int argc, char **argv)
int i;
double t1, t2;
if (argc < 2)
exit(-1);
file = argv[1];
ef = eet_open(file, EET_FILE_MODE_READ);
if (ef)
@ -52,7 +58,8 @@ main(int argc, char **argv)
{
for (i = 0; i < items_num; i++)
{
int w, h, alpha, compress, quality, lossy;
int alpha, compress, quality, lossy;
unsigned int w, h;
void *data;
if (eet_data_image_header_read(ef, items[i], &w, &h, &alpha, &compress, &quality, &lossy))
@ -81,7 +88,8 @@ main(int argc, char **argv)
t1 = get_time();
for (i = 0; i < items_num; i++)
{
int w, h, alpha, compress, quality, lossy;
int alpha, compress, quality, lossy;
unsigned int w, h;
void *data;
ef = eet_open(file, EET_FILE_MODE_READ);

View File

@ -1,3 +1,6 @@
/* PATH_MAX requires POSIX source */
#define _POSIX_SOURCE
#include "Eet.h"
#include <stdio.h>
#include <unistd.h>

View File

@ -249,8 +249,8 @@ extern "C" {
* Read just the header data for an image and dont decode the pixels.
* @param ef A valid eet file handle opened for reading.
* @param name Name of the entry. eg: "/base/file_i_want".
* @param w A pointer to the int to hold the width in pixels.
* @param h A pointer to the int to hold the height in pixels.
* @param w A pointer to the unsigned int to hold the width in pixels.
* @param h A pointer to the unsigned int to hold the height in pixels.
* @param alpha A pointer to the int to hold the alpha flag.
* @param compress A pointer to the int to hold the compression amount.
* @param quality A pointer to the int to hold the quality amount.
@ -276,14 +276,14 @@ extern "C" {
* On success the function returns 1 indicating the header was read and
* decoded properly, or 0 on failure.
*/
EAPI int eet_data_image_header_read(Eet_File *ef, char *name, int *w, int *h, int *alpha, int *compress, int *quality, int *lossy);
EAPI int eet_data_image_header_read(Eet_File *ef, char *name, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
/**
* Read image data from the named key in the eet file.
* @param ef A valid eet file handle opened for reading.
* @param name Name of the entry. eg: "/base/file_i_want".
* @param w A pointer to the int to hold the width in pixels.
* @param h A pointer to the int to hold the height in pixels.
* @param w A pointer to the unsigned int to hold the width in pixels.
* @param h A pointer to the unsigned int to hold the height in pixels.
* @param alpha A pointer to the int to hold the alpha flag.
* @param compress A pointer to the int to hold the compression amount.
* @param quality A pointer to the int to hold the quality amount.
@ -311,7 +311,7 @@ extern "C" {
* when it is done with it. On failure NULL is returned and the parameter
* values may not contain any sensible data.
*/
EAPI void *eet_data_image_read(Eet_File *ef, char *name, int *w, int *h, int *alpha, int *compress, int *quality, int *lossy);
EAPI void *eet_data_image_read(Eet_File *ef, char *name, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
/**
* Write image data to the named key in an eet file.
@ -343,14 +343,14 @@ extern "C" {
* On success this function returns the number of bytes that were required
* to encode the image data, or on failure it returns 0.
*/
EAPI int eet_data_image_write(Eet_File *ef, char *name, void *data, int w, int h, int alpha, int compress, int quality, int lossy);
EAPI int eet_data_image_write(Eet_File *ef, char *name, void *data, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy);
/**
* Decode Image data header only to get information.
* @param data The encoded pixel data.
* @param size The size, in bytes, of the encoded pixel data.
* @param w A pointer to the int to hold the width in pixels.
* @param h A pointer to the int to hold the height in pixels.
* @param w A pointer to the unsigned int to hold the width in pixels.
* @param h A pointer to the unsigned int to hold the height in pixels.
* @param alpha A pointer to the int to hold the alpha flag.
* @param compress A pointer to the int to hold the compression amount.
* @param quality A pointer to the int to hold the quality amount.
@ -376,14 +376,14 @@ extern "C" {
* On success the function returns 1 indicating the header was read and
* decoded properly, or 0 on failure.
*/
EAPI int eet_data_image_header_decode(void *data, int size, int *w, int *h, int *alpha, int *compress, int *quality, int *lossy);
EAPI int eet_data_image_header_decode(void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
/**
* Decode Image data into pixel data.
* @param data The encoded pixel data.
* @param size The size, in bytes, of the encoded pixel data.
* @param w A pointer to the int to hold the width in pixels.
* @param h A pointer to the int to hold the height in pixels.
* @param w A pointer to the unsigned int to hold the width in pixels.
* @param h A pointer to the unsigned int to hold the height in pixels.
* @param alpha A pointer to the int to hold the alpha flag.
* @param compress A pointer to the int to hold the compression amount.
* @param quality A pointer to the int to hold the quality amount.
@ -411,7 +411,7 @@ extern "C" {
* when it is done with it. On failure NULL is returned and the parameter
* values may not contain any sensible data.
*/
EAPI void *eet_data_image_decode(void *data, int size, int *w, int *h, int *alpha, int *compress, int *quality, int *lossy);
EAPI void *eet_data_image_decode(void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
/**
* Encode image data for storage or transmission.
@ -442,7 +442,7 @@ extern "C" {
* On success this function returns a pointer to the encoded data that you
* can free with free() when no longer needed.
*/
EAPI void *eet_data_image_encode(void *data, int *size_ret, int w, int h, int alpha, int compress, int quality, int lossy);
EAPI void *eet_data_image_encode(void *data, int *size_ret, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy);
/***************************************************************************/

View File

@ -19,13 +19,13 @@ static void _JPEGFatalErrorHandler(j_common_ptr cinfo);
static void _JPEGErrorHandler(j_common_ptr cinfo);
static void _JPEGErrorHandler2(j_common_ptr cinfo, int msg_level);
static int eet_data_image_jpeg_header_decode(void *data, int size, int *w, int *h);
static void *eet_data_image_jpeg_rgb_decode(void *data, int size, int *w, int *h);
static void *eet_data_image_jpeg_alpha_decode(void *data, int size, unsigned int *d, int *w, int *h);
static void *eet_data_image_lossless_convert(int *size, void *data, int w, int h, int alpha);
static void *eet_data_image_lossless_compressed_convert(int *size, void *data, int w, int h, int alpha, int compression);
static void *eet_data_image_jpeg_convert(int *size, void *data, int w, int h, int alpha, int quality);
static void *eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha, int quality);
static int eet_data_image_jpeg_header_decode(void *data, int size, unsigned int *w, unsigned int *h);
static void *eet_data_image_jpeg_rgb_decode(void *data, int size, unsigned int *w, unsigned int *h);
static void *eet_data_image_jpeg_alpha_decode(void *data, int size, unsigned int *d, unsigned int *w, unsigned int *h);
static void *eet_data_image_lossless_convert(int *size, void *data, unsigned int w, unsigned int h, int alpha);
static void *eet_data_image_lossless_compressed_convert(int *size, void *data, unsigned int w, unsigned int h, int alpha, int compression);
static void *eet_data_image_jpeg_convert(int *size, void *data, unsigned int w, unsigned int h, int alpha, int quality);
static void *eet_data_image_jpeg_alpha_convert(int *size, void *data, unsigned int w, unsigned int h, int alpha, int quality);
/*---*/
@ -93,7 +93,7 @@ _JPEGErrorHandler2(j_common_ptr cinfo, int msg_level)
}
static int
eet_data_image_jpeg_header_decode(void *data, int size, int *w, int *h)
eet_data_image_jpeg_header_decode(void *data, int size, unsigned int *w, unsigned int *h)
{
struct jpeg_decompress_struct cinfo;
struct _JPEG_error_mgr jerr;
@ -128,14 +128,15 @@ eet_data_image_jpeg_header_decode(void *data, int size, int *w, int *h)
}
static void *
eet_data_image_jpeg_rgb_decode(void *data, int size, int *w, int *h)
eet_data_image_jpeg_rgb_decode(void *data, int size, unsigned int *w, unsigned int *h)
{
unsigned int *d;
struct jpeg_decompress_struct cinfo;
struct _JPEG_error_mgr jerr;
unsigned char *ptr, *line[16], *tdata = NULL;
unsigned int *ptr2;
int x, y, l, i, scans, count, prevy;
unsigned int x, y, l, scans;
int i, count, prevy;
FILE *f;
f = _eet_memfile_read_open(data, (size_t)size);
@ -241,13 +242,14 @@ eet_data_image_jpeg_rgb_decode(void *data, int size, int *w, int *h)
}
static void *
eet_data_image_jpeg_alpha_decode(void *data, int size, unsigned int *d, int *w, int *h)
eet_data_image_jpeg_alpha_decode(void *data, int size, unsigned int *d, unsigned int *w, unsigned int *h)
{
struct jpeg_decompress_struct cinfo;
struct _JPEG_error_mgr jerr;
unsigned char *ptr, *line[16], *tdata = NULL;
unsigned int *ptr2;
int x, y, l, i, scans, count, prevy;
unsigned int x, y, l, scans;
int i, count, prevy;
FILE *f;
f = _eet_memfile_read_open(data, (size_t)size);
@ -368,7 +370,7 @@ eet_data_image_jpeg_alpha_decode(void *data, int size, unsigned int *d, int *w,
}
static void *
eet_data_image_lossless_convert(int *size, void *data, int w, int h, int alpha)
eet_data_image_lossless_convert(int *size, void *data, unsigned int w, unsigned int h, int alpha)
{
if (words_bigendian == -1)
{
@ -397,7 +399,7 @@ eet_data_image_lossless_convert(int *size, void *data, int w, int h, int alpha)
if (words_bigendian)
{
int i;
unsigned int i;
for (i = 0; i < ((w * h) + 8); i++) SWAP32(header[i]);
}
@ -407,7 +409,7 @@ eet_data_image_lossless_convert(int *size, void *data, int w, int h, int alpha)
}
static void *
eet_data_image_lossless_compressed_convert(int *size, void *data, int w, int h, int alpha, int compression)
eet_data_image_lossless_compressed_convert(int *size, void *data, unsigned int w, unsigned int h, int alpha, int compression)
{
if (words_bigendian == -1)
{
@ -446,7 +448,7 @@ eet_data_image_lossless_compressed_convert(int *size, void *data, int w, int h,
if (words_bigendian)
{
int i;
unsigned int i;
for (i = 0; i < ((w * h) + 8); i++) SWAP32(header[i]);
}
@ -468,7 +470,7 @@ eet_data_image_lossless_compressed_convert(int *size, void *data, int w, int h,
}
static void *
eet_data_image_jpeg_convert(int *size, void *data, int w, int h, int alpha, int quality)
eet_data_image_jpeg_convert(int *size, void *data, unsigned int w, unsigned int h, int alpha, int quality)
{
int *ptr;
void *d = NULL;
@ -479,6 +481,8 @@ eet_data_image_jpeg_convert(int *size, void *data, int w, int h, int alpha, int
FILE *f;
unsigned char *buf;
(void) alpha; /* unused */
f =_eet_memfile_write_open(&d, &sz);
if (!f) return NULL;
@ -524,7 +528,7 @@ eet_data_image_jpeg_convert(int *size, void *data, int w, int h, int alpha, int
ptr = data;
while (cinfo.next_scanline < cinfo.image_height)
{
int i, j;
unsigned int i, j;
/* convert scaline from ARGB to RGB packed */
for (j = 0, i = 0; i < w; i++)
@ -548,13 +552,15 @@ eet_data_image_jpeg_convert(int *size, void *data, int w, int h, int alpha, int
}
static void *
eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha, int quality)
eet_data_image_jpeg_alpha_convert(int *size, void *data, unsigned int w, unsigned int h, int alpha, int quality)
{
unsigned char *d1, *d2;
unsigned char *d;
int *header;
int sz1, sz2;
(void) alpha; /* unused */
if (words_bigendian == -1)
{
unsigned long int v;
@ -619,7 +625,7 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
ptr = data;
while (cinfo.next_scanline < cinfo.image_height)
{
int i, j;
unsigned int i, j;
/* convert scaline from ARGB to RGB packed */
for (j = 0, i = 0; i < w; i++)
@ -702,7 +708,7 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
ptr = data;
while (cinfo.next_scanline < cinfo.image_height)
{
int i, j;
unsigned int i, j;
/* convert scaline from ARGB to RGB packed */
for (j = 0, i = 0; i < w; i++)
@ -750,7 +756,7 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
int
eet_data_image_write(Eet_File *ef, char *name,
void *data, int w, int h, int alpha,
void *data, unsigned int w, unsigned int h, int alpha,
int compress, int quality, int lossy)
{
void *d = NULL;
@ -770,7 +776,7 @@ eet_data_image_write(Eet_File *ef, char *name,
void *
eet_data_image_read(Eet_File *ef, char *name,
int *w, int *h, int *alpha,
unsigned int *w, unsigned int *h, int *alpha,
int *compress, int *quality, int *lossy)
{
void *data;
@ -786,7 +792,7 @@ eet_data_image_read(Eet_File *ef, char *name,
int
eet_data_image_header_read(Eet_File *ef, char *name,
int *w, int *h, int *alpha,
unsigned int *w, unsigned int *h, int *alpha,
int *compress, int *quality, int *lossy)
{
void *data;
@ -801,7 +807,7 @@ eet_data_image_header_read(Eet_File *ef, char *name,
}
void *
eet_data_image_encode(void *data, int *size_ret, int w, int h, int alpha, int compress, int quality, int lossy)
eet_data_image_encode(void *data, int *size_ret, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy)
{
void *d = NULL;
int size = 0;
@ -825,7 +831,7 @@ eet_data_image_encode(void *data, int *size_ret, int w, int h, int alpha, int co
}
int
eet_data_image_header_decode(void *data, int size, int *w, int *h, int *alpha, int *compress, int *quality, int *lossy)
eet_data_image_header_decode(void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy)
{
int header[8];
@ -847,7 +853,7 @@ eet_data_image_header_decode(void *data, int size, int *w, int *h, int *alpha, i
for (i = 0; i < 8; i++) SWAP32(header[i]);
}
if (header[0] == 0xac1dfeed)
if ((unsigned)header[0] == 0xac1dfeed)
{
int iw, ih, al, cp;
@ -865,11 +871,11 @@ eet_data_image_header_decode(void *data, int size, int *w, int *h, int *alpha, i
if (quality) *quality = 100;
return 1;
}
else if (header[0] == 0xbeeff00d)
else if ((unsigned)header[0] == 0xbeeff00d)
{
int iw = 0, ih = 0;
int sz1, sz2;
unsigned int iw = 0, ih = 0;
unsigned char *dt;
int sz1, sz2;
int ok;
sz1 = header[1];
@ -890,7 +896,7 @@ eet_data_image_header_decode(void *data, int size, int *w, int *h, int *alpha, i
}
else
{
int iw = 0, ih = 0;
unsigned int iw = 0, ih = 0;
int ok;
ok = eet_data_image_jpeg_header_decode(data, size, &iw, &ih);
@ -909,7 +915,7 @@ eet_data_image_header_decode(void *data, int size, int *w, int *h, int *alpha, i
}
void *
eet_data_image_decode(void *data, int size, int *w, int *h, int *alpha, int *compress, int *quality, int *lossy)
eet_data_image_decode(void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy)
{
unsigned int *d = NULL;
int header[8];
@ -932,7 +938,7 @@ eet_data_image_decode(void *data, int size, int *w, int *h, int *alpha, int *com
for (i = 0; i < 8; i++) SWAP32(header[i]);
}
if (header[0] == 0xac1dfeed)
if ((unsigned)header[0] == 0xac1dfeed)
{
int iw, ih, al, cp;
unsigned int *body;
@ -980,11 +986,11 @@ eet_data_image_decode(void *data, int size, int *w, int *h, int *alpha, int *com
if (quality) *quality = 100;
}
}
else if (header[0] == 0xbeeff00d)
else if ((unsigned)header[0] == 0xbeeff00d)
{
int iw = 0, ih = 0;
int sz1, sz2;
unsigned int iw = 0, ih = 0;
unsigned char *dt;
int sz1, sz2;
sz1 = header[1];
sz2 = header[2];
@ -1008,7 +1014,7 @@ eet_data_image_decode(void *data, int size, int *w, int *h, int *alpha, int *com
}
else
{
int iw = 0, ih = 0;
unsigned int iw = 0, ih = 0;
d = eet_data_image_jpeg_rgb_decode(data, size, &iw, &ih);
if (d)

View File

@ -219,7 +219,8 @@ eet_hash_gen(char *key, int hash_size)
if (!key) return 0;
/* calc hash num */
for (ptr = key; *ptr; ptr++) hash_num ^= (int)(*ptr);
for (ptr = (unsigned char *)key; *ptr; ptr++)
hash_num ^= (int)(*ptr);
/* mask it */
hash_num &= masks[hash_size];
@ -564,7 +565,7 @@ eet_open(const char *file, Eet_File_Mode mode)
return NULL;
}
/* copy name in and terminate it */
strncpy(name, p + 20, name_size);
strncpy(name, (char *)p + 20, name_size);
name[name_size] = 0;
/* get hask bucket it should go in */
hash = eet_hash_gen(name, ef->header->directory->size);