From: Nuno Ferreira Date: Thu, 21 Feb 2019 22:57:02 +0000 (+0000) Subject: code style review X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~11^2~143 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=bde05d17a04499da307e3a7e146e747f49bf0eeb;p=babl.git code style review fixed function headers in .c files --- diff --git a/babl/babl-cache.c b/babl/babl-cache.c index 48e359c..7479c90 100644 --- a/babl/babl-cache.c +++ b/babl/babl-cache.c @@ -73,7 +73,8 @@ mk_ancestry (const char *path) return mk_ancestry_iter (copy); } -static const char *fish_cache_path (void) +static const char * +fish_cache_path (void) { struct stat stat_buf; static char path[4096]; @@ -153,14 +154,16 @@ babl_fish_serialize (Babl *fish, char *dest, int n) return dest; } -static int compare_fish_pixels (const void *a, const void *b) +static int +compare_fish_pixels (const void *a, const void *b) { const Babl **fa = (void*)a; const Babl **fb = (void*)b; return ((*fb)->fish.pixels - (*fa)->fish.pixels); } -static const char *cache_header (void) +static const char * +cache_header (void) { static char buf[2048]; if (strchr (BABL_GIT_VERSION, ' ')) // we must be building from tarball @@ -174,7 +177,8 @@ static const char *cache_header (void) return buf; } -void babl_store_db (void) +void +babl_store_db (void) { BablDb *db = babl_fish_db (); int i; @@ -223,7 +227,8 @@ _babl_fish_create_name (char *buf, const Babl *destination, int is_reference); -void babl_init_db (void) +void +babl_init_db (void) { const char *path = fish_cache_path (); long length = -1; diff --git a/babl/babl-component.c b/babl/babl-component.c index ad9dfa1..2993e81 100644 --- a/babl/babl-component.c +++ b/babl/babl-component.c @@ -47,7 +47,10 @@ component_new (const char *name, static int -is_component_duplicate (Babl *babl, int luma, int chroma, int alpha) +is_component_duplicate (Babl *babl, + int luma, + int chroma, + int alpha) { if (babl->component.luma != luma || babl->component.chroma != chroma || diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c index 2428780..7cca1f2 100644 --- a/babl/babl-conversion.c +++ b/babl/babl-conversion.c @@ -43,10 +43,10 @@ babl_conversion_plane_process (BablConversion *conversion, static void babl_conversion_planar_process (const Babl *babl, - const char *src, - char *dst, - long n, - void *user_data) + const char *src, + char *dst, + long n, + void *user_data) { BablConversion *conversion = (void*)babl; const BablImage *source = (void*)src; @@ -74,9 +74,9 @@ babl_conversion_planar_process (const Babl *babl, static void dispatch_plane (const Babl *babl, const char *source, - char *destination, - long n, - void *user_data) + char *destination, + long n, + void *user_data) { const BablConversion *conversion = &babl->conversion; const void *src_data = NULL; @@ -248,8 +248,11 @@ _conversion_new (const char *name, static char buf[512] = ""; static int collisions = 0; + static char * -create_name (Babl *source, Babl *destination, int type) +create_name (Babl *source, + Babl *destination, + int type) { if (babl_extender ()) { @@ -276,8 +279,10 @@ create_name (Babl *source, Babl *destination, int type) } const char * -babl_conversion_create_name (Babl *source, Babl *destination, int type, - int allow_collision) +babl_conversion_create_name (Babl *source, + Babl *destination, + int type, + int allow_collision) { Babl *babl; char *name; @@ -533,12 +538,14 @@ babl_conversion_error (BablConversion *conversion) return error; } -const Babl *babl_conversion_get_source_space (const Babl *conversion) +const Babl * +babl_conversion_get_source_space (const Babl *conversion) { return conversion->conversion.source->format.space; } -const Babl *babl_conversion_get_destination_space (const Babl *conversion) +const Babl * +babl_conversion_get_destination_space (const Babl *conversion) { return conversion->conversion.destination->format.space; } diff --git a/babl/babl-db.c b/babl/babl-db.c index 7b45af0..ba62a54 100644 --- a/babl/babl-db.c +++ b/babl/babl-db.c @@ -28,7 +28,8 @@ #include "babl-internal.h" static int -db_find_by_name (Babl *item, void *data) +db_find_by_name (Babl *item, + void *data) { if (!strcmp (item->instance.name, (char *) data)) return 1; @@ -36,7 +37,8 @@ db_find_by_name (Babl *item, void *data) } static int -db_find_by_id (Babl *item, void *data) +db_find_by_id (Babl *item, + void *data) { if (item->instance.id == *((int *) data)) return 1; @@ -44,13 +46,15 @@ db_find_by_id (Babl *item, void *data) } static int -db_hash_by_name (BablHashTable *htab, Babl *item) +db_hash_by_name (BablHashTable *htab, + Babl *item) { return babl_hash_by_str (htab, item->instance.name); } static int -db_hash_by_id (BablHashTable *htab, Babl *item) +db_hash_by_id (BablHashTable *htab, + Babl *item) { return babl_hash_by_int (htab, item->instance.id); } diff --git a/babl/babl-extension.c b/babl/babl-extension.c index 3898ef0..41edb8e 100644 --- a/babl/babl-extension.c +++ b/babl/babl-extension.c @@ -114,7 +114,8 @@ babl_extension_base (void) return babl; } -void babl_extension_deinit (void) +void +babl_extension_deinit (void) { babl_free (babl_quiet); babl_quiet = NULL; @@ -150,7 +151,11 @@ void babl_extension_deinit (void) #define dlopen(path, flags) shl_load (path, flags, 0L) #define dlclose(handle) shl_unload (handle) #define dlerror() strerror (errno) -static void *dlsym (HLIB handle, const char *name) { + +static void * +dlsym (HLIB handle, + const char *name) +{ void *address = 0; shl_findsym(&handle, name, TYPE_UNDEFINED, &address); return address; diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c index 2524bb4..469b5ab 100644 --- a/babl/babl-fish-path.c +++ b/babl/babl-fish-path.c @@ -103,7 +103,8 @@ static int max_path_length (void); static int debug_conversions = 0; int _babl_instrument = 0; -double _babl_legal_error (void) +double +_babl_legal_error (void) { static double error = 0.0; const char *env; @@ -132,7 +133,8 @@ double _babl_legal_error (void) return error; } -static int max_path_length (void) +static int +max_path_length (void) { static int max_length = 0; const char *env; @@ -155,7 +157,8 @@ static int max_path_length (void) return max_length; } -int _babl_max_path_len (void) +int +_babl_max_path_len (void) { return max_path_length (); } @@ -652,7 +655,8 @@ babl_fish_path2 (const Babl *source, return babl; } -const Babl * babl_fast_fish (const void *source_format, +const Babl * +babl_fast_fish (const void *source_format, const void *destination_format, const char *performance) { diff --git a/babl/babl-fish-reference.c b/babl/babl-fish-reference.c index ab5b2fd..d05dc61 100644 --- a/babl/babl-fish-reference.c +++ b/babl/babl-fish-reference.c @@ -56,7 +56,7 @@ static __thread char buf[1024]; static char * create_name (const Babl *source, const Babl *destination, - int is_reference) + int is_reference) { int size = 0; @@ -74,7 +74,7 @@ create_name (const Babl *source, static char * create_name (const Babl *source, const Babl *destination, - int is_reference) + int is_reference) { int size = 0; char *buf = NULL; diff --git a/babl/babl-format.c b/babl/babl-format.c index 019744a..5784196 100644 --- a/babl/babl-format.c +++ b/babl/babl-format.c @@ -27,7 +27,8 @@ #include "babl-ref-pixels.h" -static int babl_format_destruct (void *babl) +static int +babl_format_destruct (void *babl) { BablFormat *format = babl; if (format->image_template != NULL) @@ -49,8 +50,8 @@ format_new (const char *name, int components, BablModel *model, const Babl *space, - BablComponent **component, - BablSampling **sampling, + BablComponent **component, + BablSampling **sampling, const BablType **type) { Babl *babl; @@ -131,7 +132,8 @@ format_new (const char *name, } Babl * -format_new_from_format_with_space (const Babl *format, const Babl *space) +format_new_from_format_with_space (const Babl *format, + const Babl *space) { Babl *ret; char new_name[256]; @@ -674,7 +676,8 @@ babl_get_user_data (const Babl *babl) } void -babl_set_user_data (const Babl *cbabl, void *data) +babl_set_user_data (const Babl *cbabl, + void *data) { Babl *babl = (Babl*) cbabl; switch (cbabl->instance.class_type) diff --git a/babl/babl-icc.c b/babl/babl-icc.c index a87def5..9df1954 100644 --- a/babl/babl-icc.c +++ b/babl/babl-icc.c @@ -32,9 +32,15 @@ typedef struct ICC { int psize; } ICC; -ICC *icc_state_new (char *data, int length, int tags); - -ICC *icc_state_new (char *data, int length, int tags) +ICC * +icc_state_new (char *data, + int length, + int tags); + +ICC * +icc_state_new (char *data, + int length, + int tags) { ICC *ret = babl_calloc (sizeof (ICC), 1); ret->data = data; @@ -64,21 +70,29 @@ typedef struct { #define icc_write(type, offset, value) write_##type(state,offset,value) #define icc_read(type, offset) read_##type(state,offset) -static void write_u8 (ICC *state, int offset, uint8_t value) +static void +write_u8 (ICC *state, + int offset, + uint8_t value) { if (offset < 0 || offset >= state->length) return; *(uint8_t*) (&state->data[offset]) = value; } -static void write_s8 (ICC *state, int offset, int8_t value) +static void +write_s8 (ICC *state, + int offset, + int8_t value) { if (offset < 0 || offset >= state->length) return; *(int8_t*) (&state->data[offset]) = value; } -static int read_u8 (ICC *state, int offset) +static int +read_u8 (ICC *state, + int offset) { /* all reading functions take both the char *pointer and the length of the * buffer, and all reads thus gets protected by this condition. @@ -89,7 +103,9 @@ static int read_u8 (ICC *state, int offset) return *(uint8_t*) (&state->data[offset]); } -static int read_s8 (ICC *state, int offset) +static int +read_s8 (ICC *state, + int offset) { if (offset < 0 || offset > state->length) return 0; @@ -97,57 +113,78 @@ static int read_s8 (ICC *state, int offset) return *(int8_t*) (&state->data[offset]); } -static void write_s16 (ICC *state, int offset, int16_t value) +static void +write_s16 (ICC *state, + int offset, + int16_t value) { write_s8 (state, offset + 0, value >> 8); write_u8 (state, offset + 1, value & 0xff); } -static int16_t read_s16 (ICC *state, int offset) +static int16_t +read_s16 (ICC *state, + int offset) { return icc_read (u8, offset + 1) + (read_s8 (state, offset + 0) << 8); //XXX: transform to icc_read macro } -static uint16_t read_u16 (ICC *state, int offset) +static +uint16_t read_u16 (ICC *state, + int offset) { return icc_read (u8, offset + 1) + (icc_read (u8, offset + 0) << 8); } -static void write_u16 (ICC *state, int offset, uint16_t value) +static void +write_u16 (ICC *state, + int offset, + uint16_t value) { write_u8 (state, offset + 0, value >> 8); write_u8 (state, offset + 1, value & 0xff); } -static u8f8_t read_u8f8_ (ICC *state, int offset) +static u8f8_t +read_u8f8_ (ICC *state, + int offset) { u8f8_t ret ={icc_read (u8, offset), icc_read (u8, offset + 1)}; return ret; } -static s15f16_t read_s15f16_ (ICC *state, int offset) +static s15f16_t +read_s15f16_ (ICC *state, + int offset) { s15f16_t ret ={icc_read (s16, offset), icc_read (u16, offset + 2)}; return ret; } -static void write_u8f8_ (ICC *state, int offset, u8f8_t val) +static void +write_u8f8_ (ICC *state, + int offset, + u8f8_t val) { icc_write (u8, offset, val.integer), icc_write (u8, offset + 1, val.fraction); } -static void write_s15f16_ (ICC *state, int offset, s15f16_t val) +static void +write_s15f16_ (ICC *state, + int offset, + s15f16_t val) { icc_write (s16, offset, val.integer), icc_write (u16, offset + 2, val.fraction); } -static s15f16_t d_to_s15f16 (double value) +static s15f16_t +d_to_s15f16 (double value) { s15f16_t ret; ret.integer = floor (value); @@ -155,7 +192,8 @@ static s15f16_t d_to_s15f16 (double value) return ret; } -static u8f8_t d_to_u8f8 (double value) +static u8f8_t +d_to_u8f8 (double value) { u8f8_t ret; ret.integer = floor (value); @@ -163,39 +201,52 @@ static u8f8_t d_to_u8f8 (double value) return ret; } -static double s15f16_to_d (s15f16_t fix) +static double +s15f16_to_d (s15f16_t fix) { return fix.integer + fix.fraction / 65536.0; } -static double u8f8_to_d (u8f8_t fix) +static double +u8f8_to_d (u8f8_t fix) { return fix.integer + fix.fraction / 256.0; } -static void write_s15f16 (ICC *state, int offset, double value) +static void +write_s15f16 (ICC *state, + int offset, + double value) { write_s15f16_ (state, offset, d_to_s15f16 (value)); } -static void write_u8f8 (ICC *state, int offset, double value) +static void +write_u8f8 (ICC *state, + int offset, + double value) { write_u8f8_ (state, offset, d_to_u8f8 (value)); } -static double read_s15f16 (ICC *state, int offset) +static double +read_s15f16 (ICC *state, + int offset) { return s15f16_to_d (read_s15f16_ (state, offset)); } -static double read_u8f8 (ICC *state, int offset) +static double +read_u8f8 (ICC *state, + int offset) { return u8f8_to_d (read_u8f8_ (state, offset)); } #if 0 -static inline void print_u8f8 (u8f8_t fix) +static inline void +print_u8f8 (u8f8_t fix) { int i; uint32_t foo; @@ -209,7 +260,8 @@ static inline void print_u8f8 (u8f8_t fix) } } -static inline void print_s15f16 (s15f16_t fix) +static inline void +print_s15f16 (s15f16_t fix) { int i; uint32_t foo; @@ -240,7 +292,10 @@ static inline void print_s15f16 (s15f16_t fix) } #endif -static void write_u32 (ICC *state, int offset, uint32_t value) +static void +write_u32 (ICC *state, + int offset, + uint32_t value) { int i; for (i = 0; i < 4; i ++) @@ -252,7 +307,9 @@ static void write_u32 (ICC *state, int offset, uint32_t value) } } -static uint32_t read_u32 (ICC *state, int offset) +static uint32_t +read_u32 (ICC *state, + int offset) { return icc_read (u8, offset + 3) + (icc_read (u8, offset + 2) << 8) + @@ -260,7 +317,9 @@ static uint32_t read_u32 (ICC *state, int offset) (icc_read (u8, offset + 0) << 24); } -static sign_t read_sign (ICC *state, int offset) +static sign_t +read_sign (ICC *state, + int offset) { sign_t ret; ret.str[0]=icc_read (u8, offset); @@ -271,7 +330,10 @@ static sign_t read_sign (ICC *state, int offset) return ret; } -static void write_sign (ICC *state, int offset, const char *sign) +static void +write_sign (ICC *state, + int offset, + const char *sign) { int i; for (i = 0; i < 4; i ++) @@ -280,8 +342,11 @@ static void write_sign (ICC *state, int offset, const char *sign) /* looks up offset and length for a specific icc tag */ -static int icc_tag (ICC *state, - const char *tag, int *offset, int *el_length) +static int +icc_tag (ICC *state, + const char *tag, + int *offset, + int *el_length) { int tag_count = icc_read (u32, TAG_COUNT_OFF); int t; @@ -301,8 +366,10 @@ static int icc_tag (ICC *state, return 0; } -static const Babl *babl_trc_from_icc (ICC *state, int offset, - const char **error) +static const Babl * +babl_trc_from_icc (ICC *state, + int offset, + const char **error) { { int count = icc_read (u32, offset + 8); @@ -390,7 +457,10 @@ static const Babl *babl_trc_from_icc (ICC *state, int offset, return NULL; } -static void icc_allocate_tag (ICC *state, const char *tag, int size) +static void +icc_allocate_tag (ICC *state, + const char *tag, + int size) { while (state->no % 4 != 0) state->no++; @@ -403,7 +473,9 @@ static void icc_allocate_tag (ICC *state, const char *tag, int size) state->no+=size; } -static void icc_duplicate_tag(ICC *state, const char *tag) +static void +icc_duplicate_tag(ICC *state, + const char *tag) { icc_write (sign, 128 + 4 + 4 * state->headpos++, tag); icc_write (u32, 128 + 4 + 4 * state->headpos++, state->p); @@ -414,14 +486,15 @@ static void icc_duplicate_tag(ICC *state, const char *tag) static const uint16_t lut_srgb_26[]={0,202,455,864,1423,2154,3060,4156,5454,6960,8689,10637,12821,15247,17920,20855,24042,27501,31233,35247,39549,44132,49018,54208,59695,65535}; -void write_trc (ICC *state, - const char *name, +void write_trc (ICC *state, + const char *name, const BablTRC *trc, - BablICCFlags flags); -void write_trc (ICC *state, - const char *name, + BablICCFlags flags); + +void write_trc (ICC *state, + const char *name, const BablTRC *trc, - BablICCFlags flags) + BablICCFlags flags) { switch (trc->type) { @@ -485,9 +558,11 @@ switch (trc->type) } } -static void symmetry_test (ICC *state); +static void +symmetry_test (ICC *state); -char *babl_space_to_icc (const Babl *babl, +char * +babl_space_to_icc (const Babl *babl, const char *description, const char *copyright, BablICCFlags flags, @@ -616,7 +691,9 @@ char *babl_space_to_icc (const Babl *babl, } } -const char *babl_space_get_icc (const Babl *babl, int *length) +const char * +babl_space_get_icc (const Babl *babl, + int *length) { if (!babl->space.icc_profile) { @@ -640,17 +717,19 @@ typedef enum { lenientConversion } ConversionFlags; -static int ConvertUTF16toUTF8 (const UTF16** sourceStart, - const UTF16* sourceEnd, - UTF8** targetStart, - UTF8* targetEnd, - ConversionFlags flags); - -static char *icc_decode_mluc (ICC *state, - int offset, - int element_length, - const char *lang, - const char *country) +static int +ConvertUTF16toUTF8 (const UTF16 **sourceStart, + const UTF16 *sourceEnd, + UTF8 **targetStart, + UTF8 *targetEnd, + ConversionFlags flags); + +static char * +icc_decode_mluc (ICC *state, + int offset, + int element_length, + const char *lang, + const char *country) { int n_records = icc_read (u32, offset + 8); int record_size = icc_read (u32, offset + 12); @@ -698,7 +777,11 @@ static char *icc_decode_mluc (ICC *state, return NULL; } -static char *decode_string (ICC *state, const char *tag, const char *lang, const char *country) +static char * +decode_string (ICC *state, + const char *tag, + const char *lang, + const char *country) { int offset, element_size; @@ -1032,11 +1115,12 @@ static void symmetry_test (ICC *state) assert (icc_read (u32, 8) == 4); } -char *babl_icc_get_key (const char *icc_data, - int icc_length, - const char *key, - const char *language, - const char *country) +char * +babl_icc_get_key (const char *icc_data, + int icc_length, + const char *key, + const char *language, + const char *country) { char *ret = NULL; ICC *state = icc_state_new ((void*)icc_data, icc_length, 0); @@ -1140,6 +1224,7 @@ typedef uint32_t UTF32; /* at least 32 bits */ typedef unsigned short UTF16; /* at least 16 bits */ typedef unsigned char UTF8; /* typically 8 bits */ typedef unsigned char Boolean; /* 0 or 1 */ + typedef enum { conversionOK, /* conversion successful */ sourceExhausted, /* partial character in source, but hit end */ @@ -1159,8 +1244,12 @@ static const int halfShift = 10; /* used for shifting by 10 bits */ static const UTF32 halfBase = 0x0010000UL; static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; -static int ConvertUTF16toUTF8 (const UTF16** sourceStart, const UTF16* sourceEnd, - UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) +static int +ConvertUTF16toUTF8 (const UTF16 **sourceStart, + const UTF16 *sourceEnd, + UTF8 **targetStart, + UTF8 *targetEnd, + ConversionFlags flags) { ConversionResult result = conversionOK; const UTF16* source = *sourceStart; diff --git a/babl/babl-image.c b/babl/babl-image.c index 5ab9765..44c0cac 100644 --- a/babl/babl-image.c +++ b/babl/babl-image.c @@ -22,7 +22,8 @@ #include "babl-internal.h" -static int babl_image_destruct (void *babl) +static int +babl_image_destruct (void *babl) { BablFormat *format = BABL (babl)->image.format; if (format && format->image_template == NULL) diff --git a/babl/babl-model.c b/babl/babl-model.c index 0085a7c..90b1ad0 100644 --- a/babl/babl-model.c +++ b/babl/babl-model.c @@ -83,7 +83,10 @@ model_new (const char *name, } static int -is_model_duplicate (Babl *babl, const Babl *space, int components, BablComponent **component) +is_model_duplicate (Babl *babl, + const Babl *space, + int components, + BablComponent **component) { int i; @@ -274,7 +277,8 @@ babl_model_new (void *first_argument, #define TOLERANCE 0.001 -static const Babl *reference_format (void) +static const Babl * +reference_format (void) { static const Babl *self = NULL; @@ -290,7 +294,8 @@ static const Babl *reference_format (void) return self; } -static const Babl *construct_double_format (const Babl *model) +static const Babl * +construct_double_format (const Babl *model) { const void *argument[44 + 1]; int args = 0; @@ -411,7 +416,8 @@ static const Babl *babl_remodels[512]={NULL,}; int babl_n_remodels = 0; const Babl * -babl_remodel_with_space (const Babl *model, const Babl *space) +babl_remodel_with_space (const Babl *model, + const Babl *space) { Babl *ret; int i; @@ -458,12 +464,14 @@ babl_remodel_with_space (const Babl *model, const Babl *space) } const Babl * -babl_model_with_space (const char *name, const Babl *space) +babl_model_with_space (const char *name, + const Babl *space) { return babl_remodel_with_space (babl_model (name), space); } -BablModelFlag babl_get_model_flags (const Babl *babl) +BablModelFlag +babl_get_model_flags (const Babl *babl) { if (!babl) return 0; switch (babl->class_type) diff --git a/babl/babl-mutex.c b/babl/babl-mutex.c index 3df646e..92191c4 100644 --- a/babl/babl-mutex.c +++ b/babl/babl-mutex.c @@ -43,7 +43,7 @@ get_mutex_attr (void) #endif -BablMutex * +BablMutex * babl_mutex_new (void) { BablMutex *mutex = malloc (sizeof (BablMutex)); diff --git a/babl/babl-palette.c b/babl/babl-palette.c index d03ad1d..f0eecc5 100644 --- a/babl/babl-palette.c +++ b/babl/babl-palette.c @@ -239,7 +239,11 @@ babl_palette_lookup (BablPalette *pal, } } -static BablPalette *make_pal (const Babl *pal_space, const Babl *format, const void *data, int count) +static BablPalette * +make_pal (const Babl *pal_space, + const Babl *format, + const void *data, + int count) { BablPalette *pal = NULL; int bpp = babl_format_get_bytes_per_pixel (format); @@ -270,7 +274,8 @@ static BablPalette *make_pal (const Babl *pal_space, const Babl *format, const v return pal; } -static void babl_palette_free (BablPalette *pal) +static void +babl_palette_free (BablPalette *pal) { babl_free (pal->data); babl_free (pal->data_double); @@ -279,7 +284,8 @@ static void babl_palette_free (BablPalette *pal) babl_free (pal); } -static BablPalette *default_palette (void) +static BablPalette * +default_palette (void) { static BablPalette pal; static int inited = 0; @@ -673,8 +679,10 @@ pala_u8_to_rgba_u8 (Babl *conversion, #include "base/util.h" static inline long -conv_pal8_pala8 (Babl *conversion, - unsigned char *src, unsigned char *dst, long samples) +conv_pal8_pala8 (Babl *conversion, + unsigned char *src, + unsigned char *dst, + long samples) { long n = samples; @@ -689,8 +697,10 @@ conv_pal8_pala8 (Babl *conversion, } static inline long -conv_pala8_pal8 (Babl *conversion, - unsigned char *src, unsigned char *dst, long samples) +conv_pala8_pal8 (Babl *conversion, + unsigned char *src, + unsigned char *dst, + long samples) { long n = samples; @@ -712,10 +722,11 @@ babl_format_is_palette (const Babl *format) } -const Babl *babl_new_palette_with_space (const char *name, - const Babl *space, - const Babl **format_u8, - const Babl **format_u8_with_alpha) +const Babl * +babl_new_palette_with_space (const char *name, + const Babl *space, + const Babl **format_u8, + const Babl **format_u8_with_alpha) { const Babl *model; const Babl *model_no_alpha; @@ -872,9 +883,10 @@ const Babl *babl_new_palette_with_space (const char *name, /* should return the BablModel, permitting to fetch * other formats out of it? */ -const Babl *babl_new_palette (const char *name, - const Babl **format_u8, - const Babl **format_u8_with_alpha) +const Babl * +babl_new_palette (const char *name, + const Babl **format_u8, + const Babl **format_u8_with_alpha) { return babl_new_palette_with_space (name, NULL, format_u8, format_u8_with_alpha); diff --git a/babl/babl-polynomial.c b/babl/babl-polynomial.c index cf29567..bf3b6a8 100644 --- a/babl/babl-polynomial.c +++ b/babl/babl-polynomial.c @@ -154,7 +154,6 @@ babl_polynomial_set_degree (BablPolynomial *poly, static double babl_polynomial_get (const BablPolynomial *poly, int i) - { return poly->coeff[poly->degree - i]; } @@ -163,7 +162,6 @@ static void babl_polynomial_set (BablPolynomial *poly, int i, double c) - { poly->coeff[poly->degree - i] = c; } diff --git a/babl/babl-sanity.c b/babl/babl-sanity.c index 7282766..3cfce14 100644 --- a/babl/babl-sanity.c +++ b/babl/babl-sanity.c @@ -29,7 +29,8 @@ foo (Babl *babl, return 0; } -static Babl *babl_conversion_destination (Babl *babl); +static Babl * +babl_conversion_destination (Babl *babl); static int type_sanity (Babl *babl, @@ -136,7 +137,8 @@ babl_sanity (void) return OK; } -static Babl *babl_conversion_destination (Babl *babl) +static Babl * +babl_conversion_destination (Babl *babl) { return (Babl *)babl->conversion.destination; } diff --git a/babl/babl-space.c b/babl/babl-space.c index e475b52..ebf05be 100644 --- a/babl/babl-space.c +++ b/babl/babl-space.c @@ -26,7 +26,7 @@ static BablSpace space_db[MAX_SPACES]; static void babl_chromatic_adaptation_matrix (const double *whitepoint, const double *target_whitepoint, - double *chad_matrix) + double *chad_matrix) { double bradford[9]={ 0.8951000, 0.2664000, -0.1614000, -0.7502000, 1.7135000, 0.0367000, @@ -101,7 +101,8 @@ XYZ_to_LAB (double X, * matrix looking for the bit-exact inverse of this integer-solution. * */ -static void babl_matrix_equalize (double *in_mat) +static void +babl_matrix_equalize (double *in_mat) { double mat[9]; int j[9]; @@ -167,7 +168,9 @@ static void babl_matrix_equalize (double *in_mat) } } -static void babl_space_compute_matrices (BablSpace *space, BablSpaceFlags equalize_matrix) +static void +babl_space_compute_matrices (BablSpace *space, + BablSpaceFlags equalize_matrix) { #define _ space-> /* transform spaces xy(Y) specified data to XYZ */ @@ -220,7 +223,8 @@ babl_space (const char *name) } Babl * -_babl_space_for_lcms (const char *icc_data, int icc_length) +_babl_space_for_lcms (const char *icc_data, + int icc_length) { int i=0; BablSpace space; @@ -358,15 +362,16 @@ babl_space_from_rgbxyz_matrix (const char *name, return (Babl*)&space_db[i]; } -const Babl * babl_space_from_chromaticities (const char *name, - double wx, double wy, - double rx, double ry, - double gx, double gy, - double bx, double by, - const Babl *trc_red, - const Babl *trc_green, - const Babl *trc_blue, - BablSpaceFlags flags) +const Babl * +babl_space_from_chromaticities (const char *name, + double wx, double wy, + double rx, double ry, + double gx, double gy, + double bx, double by, + const Babl *trc_red, + const Babl *trc_green, + const Babl *trc_blue, + BablSpaceFlags flags) { int i=0; static BablSpace space; @@ -584,17 +589,24 @@ computations of uniform gray axis */ } -void babl_space_to_xyz (const Babl *space, const double *rgb, double *xyz) +void +babl_space_to_xyz (const Babl *space, + const double *rgb, + double *xyz) { _babl_space_to_xyz (space, rgb, xyz); } -void babl_space_from_xyz (const Babl *space, const double *xyz, double *rgb) +void +babl_space_from_xyz (const Babl *space, + const double *xyz, + double *rgb) { _babl_space_from_xyz (space, xyz, rgb); } -const double * babl_space_get_rgbtoxyz (const Babl *space) +const double * +babl_space_get_rgbtoxyz (const Babl *space) { return space->space.RGBtoXYZ; } @@ -602,7 +614,8 @@ const double * babl_space_get_rgbtoxyz (const Babl *space) /////////////////// -static void prep_conversion (const Babl *babl) +static void +prep_conversion (const Babl *babl) { Babl *conversion = (void*) babl; const Babl *source_space = babl_conversion_get_source_space (conversion); @@ -679,7 +692,11 @@ static void prep_conversion (const Babl *babl) static inline void -universal_nonlinear_rgba_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_nonlinear_rgba_converter (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { const Babl *source_space = babl_conversion_get_source_space (conversion); const Babl *destination_space = babl_conversion_get_destination_space (conversion); @@ -696,7 +713,11 @@ universal_nonlinear_rgba_converter (const Babl *conversion,unsigned char *src_ch } static inline void -universal_nonlinear_rgb_linear_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_nonlinear_rgb_linear_converter (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { const Babl *source_space = babl_conversion_get_source_space (conversion); float * matrixf = data; @@ -709,7 +730,11 @@ universal_nonlinear_rgb_linear_converter (const Babl *conversion,unsigned char * } static inline void -universal_nonlinear_rgba_u8_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_nonlinear_rgba_u8_converter (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { const Babl *destination_space = conversion->conversion.destination->format.space; @@ -749,7 +774,11 @@ universal_nonlinear_rgba_u8_converter (const Babl *conversion,unsigned char *src static inline void -universal_rgba_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_rgba_converter (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { float *matrixf = data; float *rgba_in = (void*)src_char; @@ -759,7 +788,11 @@ universal_rgba_converter (const Babl *conversion,unsigned char *src_char, unsign } static inline void -universal_rgb_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_rgb_converter (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { float *matrixf = data; float *rgb_in = (void*)src_char; @@ -770,7 +803,11 @@ universal_rgb_converter (const Babl *conversion,unsigned char *src_char, unsigne static inline void -universal_nonlinear_rgb_u8_converter (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_nonlinear_rgb_u8_converter (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { const Babl *destination_space = conversion->conversion.destination->format.space; @@ -815,8 +852,8 @@ universal_nonlinear_rgb_u8_converter (const Babl *conversion,unsigned char *src_ static inline void babl_matrix_mul_vectorff_buf4_sse2 (const float *mat, const float *v_in, - float *v_out, - int samples) + float *v_out, + int samples) { const __v4sf m___0 = {m(mat, 0, 0), m(mat, 1, 0), m(mat, 2, 0), 0}; const __v4sf m___1 = {m(mat, 0, 1), m(mat, 1, 1), m(mat, 2, 1), 0}; @@ -839,7 +876,11 @@ static inline void babl_matrix_mul_vectorff_buf4_sse2 (const float *mat, static inline void -universal_nonlinear_rgba_converter_sse2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_nonlinear_rgba_converter_sse2 (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { const Babl *source_space = babl_conversion_get_source_space (conversion); const Babl *destination_space = babl_conversion_get_destination_space (conversion); @@ -856,7 +897,11 @@ universal_nonlinear_rgba_converter_sse2 (const Babl *conversion,unsigned char *s static inline void -universal_rgba_converter_sse2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_rgba_converter_sse2 (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { float *matrixf = data; float *rgba_in = (void*)src_char; @@ -866,7 +911,11 @@ universal_rgba_converter_sse2 (const Babl *conversion,unsigned char *src_char, u } static inline void -universal_nonlinear_rgba_u8_converter_sse2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_nonlinear_rgba_u8_converter_sse2 (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { const Babl *destination_space = conversion->conversion.destination->format.space; @@ -903,7 +952,11 @@ universal_nonlinear_rgba_u8_converter_sse2 (const Babl *conversion,unsigned char } static inline void -universal_nonlinear_rgb_u8_converter_sse2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_nonlinear_rgb_u8_converter_sse2 (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { const Babl *destination_space = conversion->conversion.destination->format.space; @@ -940,7 +993,11 @@ universal_nonlinear_rgb_u8_converter_sse2 (const Babl *conversion,unsigned char static inline void -universal_nonlinear_rgb_linear_converter_sse2 (const Babl *conversion,unsigned char *src_char, unsigned char *dst_char, long samples, void *data) +universal_nonlinear_rgb_linear_converter_sse2 (const Babl *conversion, + unsigned char *src_char, + unsigned char *dst_char, + long samples, + void *data) { const Babl *source_space = babl_conversion_get_source_space (conversion); float * matrixf = data; @@ -1054,18 +1111,20 @@ add_rgb_adapter (Babl *babl, * with conversions internally as well as for conversions to and from other RGB * spaces. */ -void _babl_space_add_universal_rgb (const Babl *space) +void +_babl_space_add_universal_rgb (const Babl *space) { babl_space_class_for_each (add_rgb_adapter, (void*)space); } -const Babl *babl_space_match_trc_matrix (const Babl *trc_red, - const Babl *trc_green, - const Babl *trc_blue, - float rx, float ry, float rz, - float gx, float gy, float gz, - float bx, float by, float bz) +const Babl * +babl_space_match_trc_matrix (const Babl *trc_red, + const Babl *trc_green, + const Babl *trc_blue, + float rx, float ry, float rz, + float gx, float gy, float gz, + float bx, float by, float bz) { int i; double delta = 0.001; @@ -1092,7 +1151,9 @@ const Babl *babl_space_match_trc_matrix (const Babl *trc_red, return NULL; } -const Babl *babl_space_with_trc (const Babl *babl, const Babl *trc) +const Babl * +babl_space_with_trc (const Babl *babl, + const Babl *trc) { double xw, yw, xr, yr, xg, yg, xb, yb; const Babl *red_trc = NULL; @@ -1113,14 +1174,15 @@ const Babl *babl_space_with_trc (const Babl *babl, const Babl *trc) } -void babl_space_get (const Babl *babl, - double *xw, double *yw, - double *xr, double *yr, - double *xg, double *yg, - double *xb, double *yb, - const Babl **red_trc, - const Babl **green_trc, - const Babl **blue_trc) +void +babl_space_get (const Babl *babl, + double *xw, double *yw, + double *xr, double *yr, + double *xg, double *yg, + double *xb, double *yb, + const Babl **red_trc, + const Babl **green_trc, + const Babl **blue_trc) { const BablSpace *space = &babl->space; /* XXX: note: for spaces set by matrix should be possible to derive @@ -1140,7 +1202,8 @@ void babl_space_get (const Babl *babl, if(blue_trc)*blue_trc = space->trc[2]; } -int babl_space_is_cmyk (const Babl *space) +int +babl_space_is_cmyk (const Babl *space) { return space?space->space.cmyk.is_cmyk:0; } diff --git a/babl/babl-trc.c b/babl/babl-trc.c index cf75eb9..59d4b1a 100644 --- a/babl/babl-trc.c +++ b/babl/babl-trc.c @@ -30,12 +30,16 @@ static BablTRC trc_db[MAX_TRCS]; -static inline float _babl_trc_linear (const Babl *trc_, float value) +static inline float +_babl_trc_linear (const Babl *trc_, + float value) { return value; } -static inline float babl_trc_lut_from_linear (const Babl *trc_, float x) +static inline float +babl_trc_lut_from_linear (const Babl *trc_, + float x) { BablTRC *trc = (void*)trc_; int entry; @@ -62,7 +66,9 @@ static inline float babl_trc_lut_from_linear (const Babl *trc_, float x) return ret; } -static inline float babl_trc_lut_to_linear (const Babl *trc_, float x) +static inline float +babl_trc_lut_to_linear (const Babl *trc_, + float x) { BablTRC *trc = (void*)trc_; int entry; @@ -85,7 +91,9 @@ static inline float babl_trc_lut_to_linear (const Babl *trc_, float x) return ret; } -static inline float _babl_trc_gamma_to_linear (const Babl *trc_, float value) +static inline float +_babl_trc_gamma_to_linear (const Babl *trc_, + float value) { BablTRC *trc = (void*)trc_; if (value >= trc->poly_gamma_to_linear_x0 && @@ -100,7 +108,9 @@ static inline float _babl_trc_gamma_to_linear (const Babl *trc_, float value) return 0.0f; } -static inline float _babl_trc_gamma_from_linear (const Babl *trc_, float value) +static inline float +_babl_trc_gamma_from_linear (const Babl *trc_, + float value) { BablTRC *trc = (void*)trc_; if (value >= trc->poly_gamma_from_linear_x0 && @@ -115,7 +125,14 @@ static inline float _babl_trc_gamma_from_linear (const Babl *trc_, float value) return 0.0f; } -static inline void _babl_trc_gamma_to_linear_buf (const Babl *trc_, const float *in, float *out, int in_gap, int out_gap, int components, int count) +static inline void +_babl_trc_gamma_to_linear_buf (const Babl *trc_, + const float *in, + float *out, + int in_gap, + int out_gap, + int components, + int count) { int i, c; for (i = 0; i < count; i ++) @@ -123,7 +140,14 @@ static inline void _babl_trc_gamma_to_linear_buf (const Babl *trc_, const float out[out_gap * i + c] = _babl_trc_gamma_to_linear (trc_, in[in_gap *i + c]); } -static inline void _babl_trc_gamma_from_linear_buf (const Babl *trc_, const float *in, float *out, int in_gap, int out_gap, int components, int count) +static inline void +_babl_trc_gamma_from_linear_buf (const Babl *trc_, + const float *in, + float *out, + int in_gap, + int out_gap, + int components, + int count) { int i, c; for (i = 0; i < count; i ++) @@ -131,7 +155,9 @@ static inline void _babl_trc_gamma_from_linear_buf (const Babl *trc_, const floa out[out_gap * i + c] = _babl_trc_gamma_from_linear (trc_, in[in_gap *i + c]); } -static inline float _babl_trc_formula_srgb_from_linear (const Babl *trc_, float value) +static inline float +_babl_trc_formula_srgb_from_linear (const Babl *trc_, + float value) { BablTRC *trc = (void*)trc_; float x= value; @@ -152,7 +178,9 @@ static inline float _babl_trc_formula_srgb_from_linear (const Babl *trc_, float return 0.0; } -static inline float _babl_trc_formula_srgb_to_linear (const Babl *trc_, float value) +static inline float +_babl_trc_formula_srgb_to_linear (const Babl *trc_, + float value) { BablTRC *trc = (void*)trc_; float x= value; @@ -168,17 +196,28 @@ static inline float _babl_trc_formula_srgb_to_linear (const Babl *trc_, float va return c * x; } -static inline float _babl_trc_srgb_to_linear (const Babl *trc_, float value) +static inline float +_babl_trc_srgb_to_linear (const Babl *trc_, + float value) { return babl_gamma_2_2_to_linearf (value); } -static inline float _babl_trc_srgb_from_linear (const Babl *trc_, float value) +static inline float +_babl_trc_srgb_from_linear (const Babl *trc_, + float value) { return babl_linear_to_gamma_2_2f (value); } -static inline void _babl_trc_srgb_to_linear_buf (const Babl *trc_, const float *in, float *out, int in_gap, int out_gap, int components, int count) +static inline void +_babl_trc_srgb_to_linear_buf (const Babl *trc_, + const float *in, + float *out, + int in_gap, + int out_gap, + int components, + int count) { int i, c; for (i = 0; i < count; i ++) @@ -186,11 +225,14 @@ static inline void _babl_trc_srgb_to_linear_buf (const Babl *trc_, const float * out[out_gap * i + c] = babl_gamma_2_2_to_linearf (in[in_gap * i + c]); } -static inline void _babl_trc_srgb_from_linear_buf (const Babl *trc_, - const float *in, float *out, - int in_gap, int out_gap, - int components, - int count) +static inline void +_babl_trc_srgb_from_linear_buf (const Babl *trc_, + const float *in, + float *out, + int in_gap, + int out_gap, + int components, + int count) { int i, c; for (i = 0; i < count; i ++) @@ -198,7 +240,14 @@ static inline void _babl_trc_srgb_from_linear_buf (const Babl *trc_, out[out_gap * i + c] = babl_linear_to_gamma_2_2f (in[in_gap * i + c]); } -static inline void _babl_trc_to_linear_buf_generic (const Babl *trc_, const float *in, float *out, int in_gap, int out_gap, int components, int count) +static inline void +_babl_trc_to_linear_buf_generic (const Babl *trc_, + const float *in, + float *out, + int in_gap, + int out_gap, + int components, + int count) { int i, c; BablTRC *trc = (void*)trc_; @@ -207,11 +256,14 @@ static inline void _babl_trc_to_linear_buf_generic (const Babl *trc_, const floa out[out_gap * i + c] = trc->fun_to_linear (trc_, in[in_gap * i + c]); } -static inline void _babl_trc_from_linear_buf_generic (const Babl *trc_, - const float *in, float *out, - int in_gap, int out_gap, - int components, - int count) +static inline void +_babl_trc_from_linear_buf_generic (const Babl *trc_, + const float *in, + float *out, + int in_gap, + int out_gap, + int components, + int count) { int i, c; BablTRC *trc = (void*)trc_; @@ -220,11 +272,13 @@ static inline void _babl_trc_from_linear_buf_generic (const Babl *trc_, out[out_gap * i + c] = trc->fun_from_linear (trc_, in[in_gap * i + c]); } -static inline void _babl_trc_linear_buf (const Babl *trc_, - const float *in, float *out, - int in_gap, int out_gap, - int components, - int count) +static inline void _babl_trc_linear_buf (const Babl *trc_, + const float *in, + float *out, + int in_gap, + int out_gap, + int components, + int count) { int i, c; for (i = 0; i < count; i ++) @@ -402,14 +456,17 @@ babl_trc_new (const char *name, return (Babl*)&trc_db[i]; } -const Babl * babl_trc_lut (const char *name, int n, float *entries) +const Babl * +babl_trc_lut (const char *name, + int n, + float *entries) { return babl_trc_new (name, BABL_TRC_LUT, 0, n, entries); } void babl_trc_class_for_each (BablEachFunction each_fun, - void *user_data) + void *user_data) { int i=0; for (i = 0; trc_db[i].instance.class_type; i++) @@ -418,7 +475,11 @@ babl_trc_class_for_each (BablEachFunction each_fun, } const Babl * -babl_trc_formula_srgb (double g, double a, double b, double c, double d) +babl_trc_formula_srgb (double g, + double a, + double b, + double c, + double d) { char name[128]; int i; @@ -466,19 +527,25 @@ babl_trc_class_init (void) } #if 0 -float babl_trc_from_linear (const Babl *trc_, float value) +float +babl_trc_from_linear (const Babl *trc_, + float value) { return babl_trc_from_linear (trc_, value); } -float babl_trc_to_linear (const Babl *trc_, float value) +float +babl_trc_to_linear (const Babl *trc_, + float value) { return babl_trc_to_linear (trc_, value); } #endif static int -babl_lut_match_gamma (float *lut, int lut_size, float gamma) +babl_lut_match_gamma (float *lut, + int lut_size, + float gamma) { int match = 1; int i; @@ -501,7 +568,9 @@ babl_lut_match_gamma (float *lut, int lut_size, float gamma) return match; } -const Babl *babl_trc_lut_find (float *lut, int lut_size) +const Babl * +babl_trc_lut_find (float *lut, + int lut_size) { int i; int match = 1; diff --git a/babl/babl-type.c b/babl/babl-type.c index 759d604..12a3e02 100644 --- a/babl/babl-type.c +++ b/babl/babl-type.c @@ -58,7 +58,8 @@ type_new (const char *name, } static int -is_type_duplicate (Babl *babl, int bits) +is_type_duplicate (Babl *babl, + int bits) { if (babl->type.bits != bits) return 0; @@ -161,7 +162,8 @@ babl_type_new (void *first_arg, #define TOLERANCE 0.000000001 -static const Babl *double_vector_format (void) +static const Babl * +double_vector_format (void) { static const Babl *self = NULL; diff --git a/babl/babl.c b/babl/babl.c index 4479f68..fd90323 100644 --- a/babl/babl.c +++ b/babl/babl.c @@ -183,7 +183,9 @@ babl_exit (void) #undef babl_model_is -int babl_model_is (const Babl *babl, const char *model) +int +babl_model_is (const Babl *babl, + const char *model) { return babl && ((babl)==babl_model_with_space(model, babl)); } diff --git a/babl/gettimeofday.c b/babl/gettimeofday.c index 6640abc..169d609 100644 --- a/babl/gettimeofday.c +++ b/babl/gettimeofday.c @@ -33,7 +33,9 @@ struct timezone }; -int gettimeofday (struct timeval *tv, struct timezone *tz) +int +gettimeofday (struct timeval *tv, + struct timezone *tz) { FILETIME ft; LARGE_INTEGER li;