diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2020-03-26 02:53:02 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2020-03-26 02:53:02 +0000 |
commit | b117a415aaf58c435805243a930e833f8cf62421 (patch) | |
tree | ca6cda4c24d37737a3942e534b95006bcd566c5a /converter/other | |
parent | 34bb24c566c9d9fe3c4ae71fc4c6b53323fb1dd9 (diff) | |
download | netpbm-mirror-b117a415aaf58c435805243a930e833f8cf62421.tar.gz netpbm-mirror-b117a415aaf58c435805243a930e833f8cf62421.tar.xz netpbm-mirror-b117a415aaf58c435805243a930e833f8cf62421.zip |
Promote trunk (10.90.00) to advanced
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3784 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other')
56 files changed, 1263 insertions, 1228 deletions
diff --git a/converter/other/cameratopam/cameratopam.c b/converter/other/cameratopam/cameratopam.c index 2c832714..78eb6854 100644 --- a/converter/other/cameratopam/cameratopam.c +++ b/converter/other/cameratopam/cameratopam.c @@ -10,7 +10,7 @@ #define _DEFAULT_SOURCE 1 /* New name for SVID & BSD source defines */ #define _BSD_SOURCE 1 /* Make sure string.h contains strdup() */ #define _XOPEN_SOURCE 500 - /* Make sure unistd.h contains swab(), string.h constains strdup() */ + /* Make sure unistd.h contains swab(), string.h contains strdup() */ #include "pm_config.h" diff --git a/converter/other/fiasco/codec/coder.c b/converter/other/fiasco/codec/coder.c index 1e21994d..dc774a19 100644 --- a/converter/other/fiasco/codec/coder.c +++ b/converter/other/fiasco/codec/coder.c @@ -2,7 +2,7 @@ * coder.c: WFA coder toplevel functions * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -56,7 +56,7 @@ /***************************************************************************** global variables - + *****************************************************************************/ const real_t MAXCOSTS = 1e20; @@ -64,7 +64,7 @@ const real_t MAXCOSTS = 1e20; /***************************************************************************** private code - + *****************************************************************************/ static char * @@ -109,44 +109,44 @@ get_input_image_name (char const * const *templptr, unsigned ith_image) strcpy (prefix, template); prefix [s - template] = '\0'; - + for (s2 = ++s, n_digits = 0; ISDIGIT (*s2); s2++, n_digits++) ; if (sscanf (s, "%d", &dummy) == 0 || dummy < 0) error ("Input name template conversion failure.\n" "Check spelling of template."); first = (unsigned) dummy; - + if (*s2++ != '-') error ("Input name template conversion failure.\n" "Check spelling of template."); - + for (s = s2; ISDIGIT (*s2); s2++) ; if (sscanf (s, "%d", &dummy) == 0 || dummy < 0) error ("Input name template conversion failure.\n" "Check spelling of template."); last = (unsigned) dummy; - - if (*s2 == '+' || *s2 == '-') + + if (*s2 == '+' || *s2 == '-') { for (s = s2++; ISDIGIT (*s2); s2++) ; if (sscanf (s, "%d", &increment) == 0) error ("Input name template conversion failure.\n" "Check spelling of template."); - } + } if (*s2 != ']') error ("Input name template conversion failure.\n" "Check spelling of template."); suffix = s2 + 1; - + image_num = first + increment * ith_image; if (image_num < 0) error ("Input name template conversion failure.\n" "Check spelling of template."); - - if ((increment > 0 && (unsigned) image_num > last) || + + if ((increment > 0 && (unsigned) image_num > last) || (increment <= 0 && (unsigned) image_num < last)) { /* TODO: check this */ @@ -158,7 +158,7 @@ get_input_image_name (char const * const *templptr, unsigned ith_image) /* format string for image filename */ char image_name [MAXSTRLEN]; /* image file name to be composed */ - + strcpy (formatstr, "%s%0?d%s"); formatstr [4] = '0' + (char) n_digits; sprintf (image_name, formatstr, prefix, image_num, suffix); @@ -167,7 +167,7 @@ get_input_image_name (char const * const *templptr, unsigned ith_image) } } return NULL; -} +} @@ -191,7 +191,7 @@ alloc_coder (char const * const * const inputname, coding_t * c; c = NULL; /* initial value */ - + /* * Check whether all specified image frames are readable and of same type */ @@ -200,7 +200,7 @@ alloc_coder (char const * const * const inputname, int width, w = 0, height, h = 0; bool_t color, c = NO; unsigned n; - + for (n = 0; (filename = get_input_image_name (inputname, n)); n++) { xelval maxval; @@ -220,7 +220,7 @@ alloc_coder (char const * const * const inputname, pm_close(file); } color = (PNM_FORMAT_TYPE(format) == PPM_FORMAT) ? TRUE: FALSE; - + if (n > 0) { if (w != width || h != height || c != color) @@ -249,13 +249,13 @@ alloc_coder (char const * const * const inputname, */ { unsigned lx, ly; - + lx = (unsigned) (log2 (wi->width - 1) + 1); ly = (unsigned) (log2 (wi->height - 1) + 1); - + wi->level = MAX(lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0); } - + c = Calloc (1, sizeof (coding_t)); c->options = *options; @@ -278,10 +278,10 @@ alloc_coder (char const * const * const inputname, c->options.lc_max_level, wi->level - c->tiling->exponent - 1); c->options.lc_max_level = wi->level - c->tiling->exponent - 1; } - + if (c->options.lc_min_level > c->options.lc_max_level) c->options.lc_min_level = c->options.lc_max_level; - + /* * p_min_level, p_max_level min and max level for ND/MC prediction * [p_min_level, p_max_level] must be a subset of [min_level, max_level] ! @@ -293,7 +293,7 @@ alloc_coder (char const * const * const inputname, c->options.images_level = MIN(c->options.images_level, c->options.lc_max_level - 1); - + c->products_level = MAX(0, ((signed int) c->options.lc_max_level - (signed int) c->options.images_level - 1)); c->pixels = Calloc (size_of_level (c->options.lc_max_level), @@ -301,7 +301,7 @@ alloc_coder (char const * const * const inputname, c->images_of_state = Calloc (MAXSTATES, sizeof (real_t *)); c->ip_images_state = Calloc (MAXSTATES, sizeof (real_t *)); c->ip_states_state = Calloc (MAXSTATES * MAXLEVEL, sizeof (real_t *)); - + debug_message ("Imageslevel :%d, Productslevel :%d", c->options.images_level, c->products_level); debug_message ("Memory : (%d + %d + %d * 'states') * 'states' + %d", @@ -309,7 +309,7 @@ alloc_coder (char const * const * const inputname, size_of_tree (c->products_level) * 4, (c->options.lc_max_level - c->options.images_level), size_of_level (c->options.lc_max_level)); - + /* * Domain pools ... */ @@ -333,7 +333,7 @@ alloc_coder (char const * const * const inputname, */ wi->title = strdup (options->title); wi->comment = strdup (options->comment); - + /* * Reduced precision format */ @@ -345,7 +345,7 @@ alloc_coder (char const * const * const inputname, = alloc_rpf (options->d_rpf_mantissa, options->d_rpf_range); wi->d_dc_rpf = alloc_rpf (options->d_dc_rpf_mantissa, options->d_dc_rpf_range); - + /* * Color image options ... */ @@ -361,7 +361,7 @@ alloc_coder (char const * const * const inputname, wi->cross_B_search = options->half_pixel_prediction; wi->B_as_past_ref = options->B_as_past_ref; wi->smoothing = options->smoothing; - + c->mt = alloc_motion (wi); return c; @@ -383,7 +383,7 @@ free_coder (coding_t *c) { free_tiling (c->tiling); free_motion (c->mt); - + Free (c->pixels); Free (c->images_of_state); Free (c->ip_images_state); @@ -424,13 +424,13 @@ print_statistics (char c, real_t costs, const wfa_t *wfa, const image_t *image, const range_t *range) { unsigned max_level, min_level, state, label, lincomb; - + for (max_level = 0, min_level = MAXLEVEL, state = wfa->basis_states; state < wfa->states; state++) { for (lincomb = 0, label = 0; label < MAXLABELS; label++) lincomb += isrange(wfa->tree[state][label]) ? 1 : 0; - + if (lincomb) { max_level = MAX(max_level, @@ -483,10 +483,10 @@ print_statistics (char c, real_t costs, const wfa_t *wfa, const image_t *image, -static void +static void frame_coder (wfa_t *wfa, coding_t *c, bitfile_t *output) /* - * + * * WFA Coding of next frame. All important coding parameters are * stored in 'c'. The generated 'wfa' is written to stream 'output' * immediately after coding. @@ -499,11 +499,11 @@ frame_coder (wfa_t *wfa, coding_t *c, bitfile_t *output) real_t costs; /* total costs (minimized quantity) */ unsigned bits; /* number of bits written on disk */ clock_t ptimer; - + prg_timer (&ptimer, START); bits = bits_processed (output); - + init_tree_model (&c->tree); init_tree_model (&c->p_tree); @@ -552,9 +552,9 @@ frame_coder (wfa_t *wfa, coding_t *c, bitfile_t *output) int YCb_node = -1; int tree [3]; /* 3 root states of each color comp. */ color_e band; - + /* - * When compressing color images, the three color components (YCbCr) + * When compressing color images, the three color components (YCbCr) * are copied into a large image: * [ Y Cr ] * [ Cb 0 ] @@ -573,14 +573,14 @@ frame_coder (wfa_t *wfa, coding_t *c, bitfile_t *output) c->domain_pool->chroma (wfa->wfainfo->chroma_max_states, wfa, c->domain_pool->model); /* - * Don't use a finer partioning for the chrominancy bands than - * for the luminancy band. + * Don't use a finer partitioning for the chrominancy bands + * than for the luminancy band. */ for (min_level = MAXLEVEL, state = wfa->basis_states; state < wfa->states; state++) { unsigned lincomb, label; - + for (lincomb = 0, label = 0; label < MAXLABELS; label++) lincomb += isrange (wfa->tree [state][label]) ? 1 : 0; if (lincomb) @@ -596,23 +596,23 @@ frame_coder (wfa_t *wfa, coding_t *c, bitfile_t *output) memset (&range, 0, sizeof (range_t)); range.level = wfa->wfainfo->level; - + costs = subdivide (MAXCOSTS, band, tree [Y], &range, wfa, c, c->mt->frame_type != I_FRAME && band == Y, NO); if (c->options.progress_meter != FIASCO_PROGRESS_NONE) message (""); { char colors [] = {'Y', 'B', 'R'}; - + print_statistics (colors [band], costs, wfa, c->mt->original, &range); } - + if (isrange (range.tree)) /* whole image is approx. by a l.c. */ error ("No root state generated for color component %d!", band); else tree[band] = range.tree; - + if (band == Cb) { wfa->tree [wfa->states][0] = tree[Y]; @@ -623,13 +623,13 @@ frame_coder (wfa_t *wfa, coding_t *c, bitfile_t *output) } } /* - * generate two virtual states (*) + * generate two virtual states (*) * * * * / \ * + * - * / \ / - * Y CbCr + * / \ / + * Y CbCr */ wfa->tree [wfa->states][0] = tree[Cr]; wfa->tree [wfa->states][1] = RANGE; @@ -646,7 +646,7 @@ frame_coder (wfa_t *wfa, coding_t *c, bitfile_t *output) for (state = wfa->basis_states; state < MAXSTATES; state++) { unsigned level; - + if (c->images_of_state [state]) { Free (c->images_of_state [state]); @@ -665,12 +665,12 @@ frame_coder (wfa_t *wfa, coding_t *c, bitfile_t *output) Free (c->ip_states_state [state][level]); c->ip_states_state [state][level] = NULL; } - + } - + locate_delta_images (wfa); write_next_wfa (wfa, c, output); - + bits = bits_processed (output) - bits; debug_message ("Total number of bits written: %d (%d bytes, %5.3f bpp)", bits, bits >> 3, @@ -712,7 +712,7 @@ video_coder(char const * const * const image_template, /* image name of current frame. File name or "-" for Standard Input */ image_t *reconst = NULL; /* decoded reference image */ bool_t future_frame = NO; /* YES if last frame was in future */ - + debug_message ("Generating %d WFA's ...", wfa->wfainfo->frames); future_display = -1; @@ -722,7 +722,7 @@ video_coder(char const * const * const image_template, while ((image_name = get_input_image_name (image_template, display))) { frame_type_e type; /* current frame type: I, B, P */ - + /* * Determine type of next frame. * Skip already coded frames (future reference!) @@ -731,7 +731,7 @@ video_coder(char const * const * const image_template, type = I_FRAME; /* Force first frame to be intra */ else type = pattern2type (display, c->options.pattern); - + if (type != I_FRAME && c->options.reference_filename) /* Load reference from disk */ { @@ -741,12 +741,12 @@ video_coder(char const * const * const image_template, c->options.reference_filename = NULL; } if ((int) display == future_display) - { + { /* Skip already coded future ref */ display++; continue; - } - else if (type == B_FRAME && (int) display > future_display) + } + else if (type == B_FRAME && (int) display > future_display) { unsigned i = display; /* @@ -758,7 +758,7 @@ video_coder(char const * const * const image_template, i++; name = get_input_image_name (image_template, i); - + if (!name) /* Force last valid frame to be 'P' */ { future_display = i - 1; @@ -766,7 +766,7 @@ video_coder(char const * const * const image_template, } else { - future_display = i; + future_display = i; image_name = name; type = pattern2type (i, c->options.pattern); } @@ -781,7 +781,7 @@ video_coder(char const * const * const image_template, debug_message ("Coding \'%s\' [%c-frame].", image_name, type == I_FRAME ? 'I' : (type == P_FRAME ? 'P' : 'B')); - + /* * Depending on current frame type update past and future frames * which are needed as reference frames. @@ -846,10 +846,10 @@ video_coder(char const * const * const image_template, c->mt->original = read_image_stream(stdin, stdinwidth, stdinheight, stdinmaxval, stdinformat); - else + else c->mt->original = read_image_file(image_name); - if (c->tiling->exponent && type == I_FRAME) + if (c->tiling->exponent && type == I_FRAME) perform_tiling (c->mt->original, c->tiling); frame_coder (wfa, c, output); @@ -869,7 +869,7 @@ video_coder(char const * const * const image_template, if (c->mt->original) free_image (c->mt->original); c->mt->original = NULL; - + remove_states (wfa->basis_states, wfa); /* Clear WFA structure */ } @@ -927,7 +927,7 @@ read_stdin_header(const char * const * const template, /***************************************************************************** public code - + *****************************************************************************/ int @@ -957,7 +957,7 @@ fiasco_coder (char const * const *inputname, const char *outputname, unsigned int stdinheight, stdinwidth; xelval stdinmaxval; int stdinformat; - + /* * Check parameters */ @@ -965,7 +965,7 @@ fiasco_coder (char const * const *inputname, const char *outputname, template = default_input; else template = inputname; - + if (quality <= 0) { set_error (_("Compression quality has to be positive.")); @@ -1013,20 +1013,20 @@ fiasco_coder (char const * const *inputname, const char *outputname, coding_t *c = alloc_coder(template, cop, wfa->wfainfo, stdinwidth, stdinheight, stdinmaxval, stdinformat); - + read_basis (cop->basis_name, wfa); append_basis_states (wfa->basis_states, wfa, c); - + c->price = 128 * 64 / quality; - + video_coder (template, output, wfa, c, stdinwidth, stdinheight, stdinmaxval, stdinformat); - + close_bitfile (output); free_wfa (wfa); free_coder (c); - + if (default_options) fiasco_c_options_delete (default_options); } diff --git a/converter/other/fiasco/codec/cwfa.h b/converter/other/fiasco/codec/cwfa.h index dd86fbfc..e8e2d474 100644 --- a/converter/other/fiasco/codec/cwfa.h +++ b/converter/other/fiasco/codec/cwfa.h @@ -33,7 +33,7 @@ extern const real_t MAXCOSTS; typedef struct motion { image_t *original; /* Current image */ - image_t *past; /* Preceeding image */ + image_t *past; /* Preceding image */ image_t *future; /* Succeeding image */ frame_type_e frame_type; /* frame type: B_, P_ I_FRAME */ unsigned number; /* display number of frame */ diff --git a/converter/other/fiasco/codec/dfiasco.c b/converter/other/fiasco/codec/dfiasco.c index d45c9e39..ce25654a 100644 --- a/converter/other/fiasco/codec/dfiasco.c +++ b/converter/other/fiasco/codec/dfiasco.c @@ -2,11 +2,11 @@ * dfiasco.c: Decoder public interface * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ - + /* * $Date: 2000/10/28 17:39:30 $ * $Author: hafner $ @@ -38,7 +38,7 @@ /***************************************************************************** prototypes - + *****************************************************************************/ static dfiasco_t * @@ -52,7 +52,7 @@ alloc_dfiasco (wfa_t *wfa, video_t *video, bitfile_t *input, /***************************************************************************** public code - + *****************************************************************************/ fiasco_decoder_t * @@ -79,7 +79,7 @@ fiasco_decoder_new (const char *filename, const fiasco_d_options_t *options) default_options = fiasco_d_options_new (); dop = cast_d_options (default_options); } - + wfa = alloc_wfa (NO); video = alloc_video (NO); input = open_wfa (filename, wfa->wfainfo); @@ -102,7 +102,7 @@ fiasco_decoder_new (const char *filename, const fiasco_d_options_t *options) dop->magnification, dop->smoothing, dop->image_format); - + if (default_options) fiasco_d_options_delete (default_options); if (dfiasco->enlarge_factor >= 0) @@ -115,7 +115,7 @@ fiasco_decoder_new (const char *filename, const fiasco_d_options_t *options) if (pixels << (n << 1) > 2048 * 2048) { set_error (_("Magnifaction factor `%d' is too large. " - "Maximium value is %d."), + "Maximum value is %d."), dfiasco->enlarge_factor, MAX(0, n - 1)); fiasco_decoder_delete (decoder); return NULL; @@ -152,7 +152,7 @@ fiasco_decoder_write_frame (fiasco_decoder_t *decoder, const char *filename) { dfiasco_t *dfiasco = cast_dfiasco (decoder); - + if (!dfiasco) return 0; else @@ -177,7 +177,7 @@ fiasco_image_t * fiasco_decoder_get_frame (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); - + if (!dfiasco) return NULL; else @@ -197,7 +197,7 @@ fiasco_decoder_get_frame (fiasco_decoder_t *decoder) image->get_width = fiasco_image_get_width; image->get_height = fiasco_image_get_height; image->is_color = fiasco_image_is_color; - + return image; } catch @@ -211,7 +211,7 @@ unsigned fiasco_decoder_get_length (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); - + if (!dfiasco) return 0; else @@ -222,7 +222,7 @@ unsigned fiasco_decoder_get_rate (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); - + if (!dfiasco) return 0; else @@ -239,12 +239,12 @@ fiasco_decoder_get_width (fiasco_decoder_t *decoder) else { unsigned width; - + if (dfiasco->enlarge_factor >= 0) width = dfiasco->wfa->wfainfo->width << dfiasco->enlarge_factor; else width = dfiasco->wfa->wfainfo->width >> - dfiasco->enlarge_factor; - + return width & 1 ? width + 1 : width; } } @@ -259,7 +259,7 @@ fiasco_decoder_get_height (fiasco_decoder_t *decoder) else { unsigned height; - + if (dfiasco->enlarge_factor >= 0) height = dfiasco->wfa->wfainfo->height << dfiasco->enlarge_factor; else @@ -306,10 +306,10 @@ int fiasco_decoder_delete (fiasco_decoder_t *decoder) { dfiasco_t *dfiasco = cast_dfiasco (decoder); - + if (!dfiasco) return 1; - + try { free_wfa (dfiasco->wfa); @@ -330,7 +330,7 @@ fiasco_decoder_delete (fiasco_decoder_t *decoder) /***************************************************************************** private code - + *****************************************************************************/ static dfiasco_t * @@ -347,14 +347,14 @@ alloc_dfiasco (wfa_t *wfa, video_t *video, bitfile_t *input, dfiasco_t *dfiasco = Calloc (1, sizeof (dfiasco_t)); strcpy (dfiasco->id, "DFIASCO"); - + dfiasco->wfa = wfa; dfiasco->video = video; dfiasco->input = input; dfiasco->enlarge_factor = enlarge_factor; dfiasco->smoothing = smoothing; dfiasco->image_format = image_format; - + return dfiasco; } diff --git a/converter/other/fiasco/codec/ip.c b/converter/other/fiasco/codec/ip.c index 56b0ae9a..18257a06 100644 --- a/converter/other/fiasco/codec/ip.c +++ b/converter/other/fiasco/codec/ip.c @@ -2,7 +2,7 @@ * ip.c: Computation of inner products * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -27,40 +27,40 @@ /***************************************************************************** prototypes - + *****************************************************************************/ -static real_t +static real_t standard_ip_image_state (unsigned address, unsigned level, unsigned domain, const coding_t *c); -static real_t +static real_t standard_ip_state_state (unsigned domain1, unsigned domain2, unsigned level, const coding_t *c); /***************************************************************************** public code - + *****************************************************************************/ -real_t +real_t get_ip_image_state (unsigned image, unsigned address, unsigned level, unsigned domain, const coding_t *c) /* * Return value: * Inner product between 'image' ('address') and - * 'domain' at given 'level' + * 'domain' at given 'level' */ { if (level <= c->options.images_level) { /* - * Compute the inner product in the standard way by multiplying + * Compute the inner product in the standard way by multiplying * the pixel-values of the given domain and range image. - */ + */ return standard_ip_image_state (address, level, domain, c); } - else + else { /* * Use the already computed inner products stored in 'ip_images_states' @@ -69,29 +69,29 @@ get_ip_image_state (unsigned image, unsigned address, unsigned level, } } -void +void compute_ip_images_state (unsigned image, unsigned address, unsigned level, unsigned n, unsigned from, const wfa_t *wfa, coding_t *c) /* * Compute the inner products between all states * 'from', ... , 'wfa->max_states' and the range images 'image' - * (and childs) up to given level. + * (and children) up to given level. * * No return value. * * Side effects: * inner product tables 'c->ip_images_states' are updated - */ + */ { - if (level > c->options.images_level) + if (level > c->options.images_level) { unsigned state, label; if (level > c->options.images_level + 1) /* recursive computation */ compute_ip_images_state (MAXLABELS * image + 1, address * MAXLABELS, level - 1, MAXLABELS * n, from, wfa, c); - + /* * Compute inner product <f, Phi_i> */ @@ -102,7 +102,7 @@ compute_ip_images_state (unsigned image, unsigned address, unsigned level, unsigned edge, count; int domain; real_t *dst, *src; - + if (ischild (domain = wfa->tree [state][label])) { if (level > c->options.images_level + 1) @@ -116,9 +116,9 @@ compute_ip_images_state (unsigned image, unsigned address, unsigned level, else { unsigned newadr = address * MAXLABELS + label; - + dst = c->ip_images_state [state] + image; - + for (count = n; count; count--, newadr += MAXLABELS) *dst++ += standard_ip_image_state (newadr, level - 1, domain, c); @@ -128,7 +128,7 @@ compute_ip_images_state (unsigned image, unsigned address, unsigned level, edge++) { real_t weight = wfa->weight [state][label][edge]; - + if (level > c->options.images_level + 1) { dst = c->ip_images_state [state] + image; @@ -142,7 +142,7 @@ compute_ip_images_state (unsigned image, unsigned address, unsigned level, unsigned newadr = address * MAXLABELS + label; dst = c->ip_images_state [state] + image; - + for (count = n; count; count--, newadr += MAXLABELS) *dst++ += weight * standard_ip_image_state (newadr, level - 1, @@ -153,7 +153,7 @@ compute_ip_images_state (unsigned image, unsigned address, unsigned level, } } -real_t +real_t get_ip_state_state (unsigned domain1, unsigned domain2, unsigned level, const coding_t *c) /* @@ -164,12 +164,12 @@ get_ip_state_state (unsigned domain1, unsigned domain2, unsigned level, if (level <= c->options.images_level) { /* - * Compute the inner product in the standard way by multiplying + * Compute the inner product in the standard way by multiplying * the pixel-values of both state-images - */ + */ return standard_ip_state_state (domain1, domain2, level, c); } - else + else { /* * Use already computed inner products stored in 'ip_images_states' @@ -181,7 +181,7 @@ get_ip_state_state (unsigned domain1, unsigned domain2, unsigned level, } } -void +void compute_ip_states_state (unsigned from, unsigned to, const wfa_t *wfa, coding_t *c) /* @@ -192,7 +192,7 @@ compute_ip_states_state (unsigned from, unsigned to, * * Side effects: * inner product tables 'c->ip_states_state' are computed. - */ + */ { unsigned level; unsigned state1, state2; @@ -204,25 +204,25 @@ compute_ip_states_state (unsigned from, unsigned to, for (level = c->options.images_level + 1; level <= c->options.lc_max_level; level++) for (state1 = from; state1 <= to; state1++) - for (state2 = 0; state2 <= state1; state2++) + for (state2 = 0; state2 <= state1; state2++) if (need_image (state2, wfa)) { unsigned label; real_t ip = 0; - + for (label = 0; label < MAXLABELS; label++) { int domain1, domain2; unsigned edge1, edge2; real_t sum, weight2; - + if (ischild (domain1 = wfa->tree [state1][label])) { sum = 0; if (ischild (domain2 = wfa->tree [state2][label])) sum = get_ip_state_state (domain1, domain2, level - 1, c); - + for (edge2 = 0; isedge (domain2 = wfa->into [state2][label][edge2]); edge2++) @@ -238,12 +238,12 @@ compute_ip_states_state (unsigned from, unsigned to, edge1++) { real_t weight1 = wfa->weight [state1][label][edge1]; - + sum = 0; if (ischild (domain2 = wfa->tree [state2][label])) sum = get_ip_state_state (domain1, domain2, level - 1, c); - + for (edge2 = 0; isedge (domain2 = wfa->into [state2][label][edge2]); edge2++) @@ -262,10 +262,10 @@ compute_ip_states_state (unsigned from, unsigned to, /***************************************************************************** private code - + *****************************************************************************/ -static real_t +static real_t standard_ip_image_state (unsigned address, unsigned level, unsigned domain, const coding_t *c) /* @@ -283,18 +283,18 @@ standard_ip_image_state (unsigned address, unsigned level, unsigned domain, if (level > c->options.images_level) error ("We cannot interpret a Level %d image.", level); - + imageptr = &c->pixels [address * size_of_level (level)]; stateptr = c->images_of_state [domain] + address_of_level (level); - + for (i = size_of_level (level); i; i--) ip += *imageptr++ * *stateptr++; return ip; } -static real_t +static real_t standard_ip_state_state (unsigned domain1, unsigned domain2, unsigned level, const coding_t *c) /* @@ -315,7 +315,7 @@ standard_ip_state_state (unsigned domain1, unsigned domain2, unsigned level, state1ptr = c->images_of_state [domain1] + address_of_level (level); state2ptr = c->images_of_state [domain2] + address_of_level (level); - + for (i = size_of_level (level); i; i--) ip += *state1ptr++ * *state2ptr++; diff --git a/converter/other/fiasco/codec/prediction.c b/converter/other/fiasco/codec/prediction.c index e78e5acc..c592baa5 100644 --- a/converter/other/fiasco/codec/prediction.c +++ b/converter/other/fiasco/codec/prediction.c @@ -1,9 +1,9 @@ /* - * prediction.c: Range image prediction with MC or ND + * prediction.c: Range image prediction with MC or ND * * Written by: Ullrich Hafner * Michael Unger - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -41,7 +41,7 @@ /***************************************************************************** local variables - + *****************************************************************************/ typedef struct state_data @@ -71,7 +71,7 @@ typedef struct state_data /***************************************************************************** prototypes - + *****************************************************************************/ static real_t @@ -90,9 +90,9 @@ restore_state_data (unsigned from, unsigned to, unsigned max_level, /***************************************************************************** public code - + *****************************************************************************/ - + real_t predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa, coding_t *c, unsigned band, int y_state, unsigned states, @@ -124,11 +124,11 @@ predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa, rec_d_coeff_model = c->d_coeff->model; rec_tree_model = c->tree; rec_p_tree_model = c->p_tree; - rec_states = wfa->states; + rec_states = wfa->states; rec_pixels = c->pixels; rec_state_data = store_state_data (states, rec_states - 1, c->options.lc_max_level, wfa, c); - + /* * Restore probability models to the state before the recursive subdivision * has been started. @@ -141,14 +141,14 @@ predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa, c->coeff->model = c->coeff->model_duplicate (c->coeff, coeff_model); c->d_coeff->model = c->d_coeff->model_duplicate (c->d_coeff, d_coeff_model); - + if (c->mt->frame_type == I_FRAME) - costs = nd_prediction (max_costs, price, band, y_state, range, wfa, c); + costs = nd_prediction (max_costs, price, band, y_state, range, wfa, c); else costs = mc_prediction (max_costs, price, band, y_state, range, wfa, c); - + c->pixels = rec_pixels; - + if (costs < MAXCOSTS) { /* @@ -187,25 +187,25 @@ predict_range (real_t max_costs, real_t price, range_t *range, wfa_t *wfa, c->d_domain_pool->model_free (c->d_domain_pool->model); c->coeff->model_free (c->coeff->model); c->d_coeff->model_free (c->d_coeff->model); - + c->domain_pool->model = rec_domain_model; c->d_domain_pool->model = rec_d_domain_model; c->coeff->model = rec_coeff_model; c->d_coeff->model = rec_d_coeff_model; c->tree = rec_tree_model; c->p_tree = rec_p_tree_model; - + range->prediction = NO; - + if (wfa->states != states) remove_states (states, wfa); restore_state_data (states, rec_states - 1, c->options.lc_max_level, rec_state_data, wfa, c); costs = MAXCOSTS; } - + return costs; -} +} void clear_norms_table (unsigned level, const wfa_info_t *wi, motion_t *mt) @@ -238,11 +238,11 @@ update_norms_table (unsigned level, const wfa_info_t *wi, motion_t *mt) unsigned range_size = wi->half_pixel ? square (wi->search_range) : square (2 * wi->search_range); - + if (level > wi->p_min_level) { unsigned index; /* index of motion vector */ - + for (index = 0; index < range_size; index++) mt->mc_forward_norms [level][index] += mt->mc_forward_norms [level - 1][index]; @@ -256,7 +256,7 @@ update_norms_table (unsigned level, const wfa_info_t *wi, motion_t *mt) /***************************************************************************** private code - + *****************************************************************************/ static real_t @@ -273,7 +273,7 @@ mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state, * If we are at the bottom level of the mc tree: * Fill in the norms table */ - if (prange.level == wfa->wfainfo->p_min_level) + if (prange.level == wfa->wfainfo->p_min_level) fill_norms_table (prange.x, prange.y, prange.level, wfa->wfainfo, c->mt); /* * Predict 'range' with motion compensation according to frame type. @@ -283,19 +283,19 @@ mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state, find_P_frame_mc (mcpe, price, &prange, wfa->wfainfo, c->mt); else find_B_frame_mc (mcpe, price, &prange, wfa->wfainfo, c->mt); - + costs = (prange.mv_tree_bits + prange.mv_coord_bits) * price; - + if (costs < max_costs) /* motion vector not too expensive */ { unsigned last_state; /* last WFA state before recursion */ real_t *ipi [MAXSTATES]; /* inner products pointers */ unsigned state; real_t mvt, mvc; - + c->pixels = Calloc (width * height, sizeof (real_t)); cut_to_bintree (c->pixels, mcpe, width, height, 0, 0, width, height); - + /* * Approximate MCPE recursively. */ @@ -310,7 +310,7 @@ mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state, mvc = prange.mv_coord_bits; mvt = prange.mv_tree_bits; - + prange.image = 0; prange.address = 0; prange.tree_bits = 0; @@ -329,7 +329,7 @@ mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state, if (costs < max_costs) /* use motion compensation */ { unsigned img, adr; /* temp. values */ - + img = range->image; adr = range->address; *range = prange; @@ -362,7 +362,7 @@ mc_prediction (real_t max_costs, real_t price, unsigned band, int y_state, } else costs = MAXCOSTS; - + Free (mcpe); return costs; @@ -374,7 +374,7 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state, { real_t costs; /* current approximation costs */ range_t lrange = *range; - + /* * Predict 'range' with DC component approximation */ @@ -397,11 +397,11 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state, lrange.weights_bits = c->coeff->bits (&w, s, range->level, c->coeff); } costs = price * (lrange.weights_bits + lrange.nd_tree_bits); - + /* - * Recursive aproximation of difference image + * Recursive approximation of difference image */ - if (costs < max_costs) + if (costs < max_costs) { unsigned state; range_t rrange; /* range: recursive subdivision */ @@ -418,14 +418,14 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state, unsigned n; real_t *src, *dst; /* pointers to image data */ real_t w = - lrange.weight [0] * c->images_of_state [0][0]; - - src = c->pixels + range->address * size_of_level (range->level); + + src = c->pixels + range->address * size_of_level (range->level); dst = c->pixels = pixels = Calloc (width * height, sizeof (real_t)); for (n = width * height; n; n--) *dst++ = *src++ + w; } - + /* * Approximate difference recursively. */ @@ -448,13 +448,13 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state, c->ip_images_state[state] = Calloc (size_of_tree (c->products_level), sizeof (real_t)); } - + compute_ip_images_state (rrange.image, rrange.address, rrange.level, 1, 0, wfa, c); - + costs += subdivide (max_costs - costs, band, y_state, &rrange, wfa, c, NO, YES); - + Free (pixels); if (costs < max_costs && ischild (rrange.tree)) /* use prediction */ @@ -469,7 +469,7 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state, range->address = adr; range->nd_tree_bits += lrange.nd_tree_bits; range->nd_weights_bits += lrange.weights_bits; - + for (edge = 0; isedge (lrange.into [edge]); edge++) { range->into [edge] = lrange.into [edge]; @@ -485,7 +485,7 @@ nd_prediction (real_t max_costs, real_t price, unsigned band, int y_state, } else costs = MAXCOSTS; - + for (state = 0; state <= last_state; state++) if (need_image (state, wfa)) { @@ -515,9 +515,9 @@ store_state_data (unsigned from, unsigned to, unsigned max_level, if (to < from) return NULL; /* nothing to do */ - + data = Calloc (to - from + 1, sizeof (state_data_t)); - + for (state = from; state <= to; state++) { sd = &data [state - from]; @@ -527,12 +527,12 @@ store_state_data (unsigned from, unsigned to, unsigned max_level, sd->domain_type = wfa->domain_type [state]; sd->images_of_state = c->images_of_state [state]; sd->inner_products = c->ip_images_state [state]; - + wfa->domain_type [state] = 0; c->images_of_state [state] = NULL; c->ip_images_state [state] = NULL; - - for (label = 0; label < MAXLABELS; label++) + + for (label = 0; label < MAXLABELS; label++) { sd->tree [label] = wfa->tree [state][label]; sd->y_state [label] = wfa->y_state [state][label]; @@ -542,11 +542,11 @@ store_state_data (unsigned from, unsigned to, unsigned max_level, sd->y [label] = wfa->y [state][label]; sd->prediction [label] = wfa->prediction [state][label]; - memcpy (sd->weight [label], wfa->weight [state][label], + memcpy (sd->weight [label], wfa->weight [state][label], sizeof (real_t) * (MAXEDGES + 1)); - memcpy (sd->int_weight [label], wfa->int_weight [state][label], + memcpy (sd->int_weight [label], wfa->int_weight [state][label], sizeof (word_t) * (MAXEDGES + 1)); - memcpy (sd->into [label], wfa->into [state][label], + memcpy (sd->into [label], wfa->into [state][label], sizeof (word_t) * (MAXEDGES + 1)); wfa->into [state][label][0] = NO_EDGE; @@ -569,7 +569,7 @@ restore_state_data (unsigned from, unsigned to, unsigned max_level, state_data_t *data, wfa_t *wfa, coding_t *c) /* * Restore all state data starting from state 'from'. - * + * * No return value. */ { @@ -578,15 +578,15 @@ restore_state_data (unsigned from, unsigned to, unsigned max_level, if (to < from) return; /* nothing to do */ - + for (state = from; state <= to; state++) { sd = &data [state - from]; - + wfa->final_distribution [state] = sd->final_distribution; wfa->level_of_state [state] = sd->level_of_state; wfa->domain_type [state] = sd->domain_type; - + if (c->images_of_state [state] != NULL) Free (c->images_of_state [state]); c->images_of_state [state] = sd->images_of_state; @@ -603,14 +603,14 @@ restore_state_data (unsigned from, unsigned to, unsigned max_level, wfa->x [state][label] = sd->x [label]; wfa->y [state][label] = sd->y [label]; wfa->prediction [state][label] = sd->prediction [label]; - - memcpy (wfa->weight [state][label], sd->weight [label], + + memcpy (wfa->weight [state][label], sd->weight [label], sizeof(real_t) * (MAXEDGES + 1)); - memcpy (wfa->int_weight [state][label], sd->int_weight [label], + memcpy (wfa->int_weight [state][label], sd->int_weight [label], sizeof(word_t) * (MAXEDGES + 1)); - memcpy (wfa->into [state][label], sd->into [label], + memcpy (wfa->into [state][label], sd->into [label], sizeof(word_t) * (MAXEDGES + 1)); - } + } for (level = c->options.images_level + 1; level <= max_level; level++) { diff --git a/converter/other/fiasco/codec/subdivide.c b/converter/other/fiasco/codec/subdivide.c index 348f838a..3ddf1ffc 100644 --- a/converter/other/fiasco/codec/subdivide.c +++ b/converter/other/fiasco/codec/subdivide.c @@ -2,7 +2,7 @@ * subdivide.c: Recursive subdivision of range images * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -56,10 +56,10 @@ init_range (range_t *range, const image_t *image, unsigned band, /***************************************************************************** public code - + *****************************************************************************/ -real_t +real_t subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, wfa_t *wfa, coding_t *c, bool_t prediction, bool_t delta) /* @@ -71,7 +71,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, * If 'prediction' is TRUE then also test motion compensation or * nondeterministic approximation. * If 'delta' is TRUE then current range is already predicted. - * + * * Return value: * costs of the best approximation or MAXCOSTS if costs exceed 'max_costs' * @@ -82,7 +82,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, */ { real_t subdivide_costs; /* Costs arising from approx. the current - range with two childs */ + range with two children */ real_t lincomb_costs; /* Costs arising from approx. the current range with a linear combination */ int new_y_state [MAXLABELS]; /* Corresponding state of Y */ @@ -91,7 +91,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, bool_t try_nd; /* YES: try ND prediction */ unsigned states; /* Number of states before the recursive subdivision starts */ - void *domain_model; /* copy of domain pool model */ + void *domain_model; /* copy of domain pool model */ void *d_domain_model; /* copy of delta domain pool model */ void *lc_domain_model; /* copy of domain pool model */ void *lc_d_domain_model; /* copy of delta domain pool model */ @@ -103,17 +103,17 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, tree_t p_tree_model; /* copy of pred. tree model */ range_t lrange; /* range of lin. comb. approx. */ range_t rrange; /* range of recursive approx. */ - range_t child [MAXLABELS]; /* new childs of the current range */ + range_t child [MAXLABELS]; /* new children of the current range */ static unsigned percent = 0; /* status of progress meter */ if (wfa->wfainfo->level == range->level) percent = 0; - + range->into [0] = NO_EDGE; /* default approximation: empty */ range->tree = RANGE; if (range->level < 3) /* Don't process small ranges */ - return MAXCOSTS; + return MAXCOSTS; /* * If image permutation (tiling) is performed and the tiling level @@ -123,7 +123,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, && range->level == wfa->wfainfo->level - c->tiling->exponent) { unsigned width, height; /* size of range (dummies)*/ - + if (c->tiling->vorder [range->global_address] < 0) return 0; /* nothing to do */ else @@ -140,7 +140,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, * Check whether prediction is allowed or not * mc == motion compensation, nd == nondeterminism */ - try_mc = (prediction && c->mt->frame_type != I_FRAME + try_mc = (prediction && c->mt->frame_type != I_FRAME && range->level >= wfa->wfainfo->p_min_level && range->level <= wfa->wfainfo->p_max_level && (range->x + width_of_level (range->level) @@ -155,21 +155,21 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, if (try_mc) clear_norms_table (range->level, wfa->wfainfo, c->mt); - + /* * Check if current range must be initialized. I.e. range pixels must * be copied from entire image to bintree pixel buffer. Moreover, * all inner products tables must be initialized. */ - if (range->level == c->options.lc_max_level) + if (range->level == c->options.lc_max_level) init_range (range, c->mt->original, band, wfa, c); - + price = c->price; - if (band != Y) + if (band != Y) price *= c->options.chroma_decrease; /* less quality for chroma bands */ /* - * Compute childs of corresponding state in Y band + * Compute children of corresponding state in Y band */ if (band != Y) /* Cb and Cr bands only */ { @@ -183,7 +183,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, } else new_y_state [0] = new_y_state [1] = RANGE; - + /* * Store contents of all models that may get modified during recursion */ @@ -193,8 +193,8 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, d_coeff_model = c->d_coeff->model_duplicate (c->d_coeff, c->d_coeff->model); tree_model = c->tree; p_tree_model = c->p_tree; - states = wfa->states; - + states = wfa->states; + /* * First alternative of range approximation: * Compute costs of linear combination. @@ -208,10 +208,10 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, lrange.weights_bits = 0; lrange.mv_tree_bits = try_mc ? 1 : 0; /* mc allowed but not used */ lrange.mv_coord_bits = 0; - lrange.nd_tree_bits = 0; - lrange.nd_weights_bits = 0; + lrange.nd_tree_bits = 0; + lrange.nd_weights_bits = 0; lrange.prediction = NO; - + lincomb_costs = approximate_range (max_costs, price, c->options.max_elements, y_state, &lrange, @@ -219,7 +219,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, (delta ? c->d_coeff : c->coeff), wfa, c); } else - lincomb_costs = MAXCOSTS; + lincomb_costs = MAXCOSTS; /* * Store contents of models that have been modified @@ -237,7 +237,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, c->coeff->model = c->coeff->model_duplicate (c->coeff, coeff_model); c->d_coeff->model = c->d_coeff->model_duplicate (c->d_coeff, d_coeff_model); - + /* * Second alternative of range approximation: * Compute costs of recursive subdivision. @@ -245,8 +245,8 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, if (range->level > c->options.lc_min_level) /* range is large enough */ { unsigned label; - - memset (&child [0], 0, 2 * sizeof (range_t)); /* initialize childs */ + + memset (&child [0], 0, 2 * sizeof (range_t)); /* initialize children */ /* * Initialize a new range for recursive approximation @@ -260,7 +260,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, rrange.mv_coord_bits = 0; rrange.nd_tree_bits = try_nd ? tree_bits (CHILD, lrange.level, &c->p_tree): 0; - rrange.nd_weights_bits = 0; + rrange.nd_weights_bits = 0; rrange.prediction = NO; /* @@ -271,11 +271,11 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, + rrange.matrix_bits + rrange.mv_tree_bits + rrange.mv_coord_bits + rrange.nd_tree_bits + rrange.nd_weights_bits) * price; - - for (label = 0; label < MAXLABELS; label++) + + for (label = 0; label < MAXLABELS; label++) { real_t remaining_costs; /* upper limit for next recursion */ - + child[label].image = rrange.image * MAXLABELS + label + 1; child[label].address = rrange.address * MAXLABELS + label; child[label].global_address = rrange.global_address * MAXLABELS @@ -289,8 +289,8 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, ? (rrange.y + label * height_of_level (rrange.level - 1)) : rrange.y; - - /* + + /* * If necessary compute the inner products of the new states * (generated during the recursive approximation of child [0]) */ @@ -298,7 +298,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, compute_ip_images_state (child[label].image, child[label].address, child[label].level, 1, states, wfa, c); /* - * Call subdivide() for both childs. + * Call subdivide() for both children. * Abort the recursion if 'subdivide_costs' exceed 'lincomb_costs' * or 'max_costs'. */ @@ -315,10 +315,10 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, fill_norms_table (child[label].x, child[label].y, child[label].level, wfa->wfainfo, c->mt); } - + if (try_mc) update_norms_table (rrange.level, wfa->wfainfo, c->mt); - + /* * Update of progress meter */ @@ -327,7 +327,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, if (c->options.progress_meter == FIASCO_PROGRESS_PERCENT) { unsigned new_percent; /* new status of progress meter */ - + new_percent = (child[label].global_address + 1) * 100.0 / (1 << (wfa->wfainfo->level - child[label].level)); if (new_percent > percent) @@ -339,7 +339,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, else if (c->options.progress_meter == FIASCO_PROGRESS_BAR) { unsigned new_percent; /* new status of progress meter */ - + new_percent = (child[label].global_address + 1) * 50.0 / (1 << (wfa->wfainfo->level - child[label].level)); @@ -349,15 +349,15 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, } } } - + /* - * If costs of subdivision exceed costs of linear combination + * If costs of subdivision exceed costs of linear combination * then abort recursion. */ - if (subdivide_costs >= MIN(lincomb_costs, max_costs)) + if (subdivide_costs >= MIN(lincomb_costs, max_costs)) { subdivide_costs = MAXCOSTS; - break; + break; } rrange.err += child [label].err; rrange.tree_bits += child [label].tree_bits; @@ -379,8 +379,8 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, /* * Third alternative of range approximation: - * Predict range via motion compensation or nondeterminism and - * approximate delta image. + * Predict range via motion compensation or nondeterminism and + * approximate delta image. */ if (try_mc || try_nd) /* try prediction */ { @@ -403,7 +403,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, c->d_coeff->model_free (d_coeff_model); c->coeff->model_free (lc_coeff_model); c->d_coeff->model_free (lc_d_coeff_model); - + return prediction_costs; } } @@ -423,25 +423,25 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, c->d_coeff->model_free (c->d_coeff->model); c->coeff->model_free (lc_coeff_model); c->d_coeff->model_free (lc_d_coeff_model); - + c->domain_pool->model = domain_model; c->d_domain_pool->model = d_domain_model; c->coeff->model = coeff_model; c->d_coeff->model = d_coeff_model; c->tree = tree_model; c->p_tree = p_tree_model; - + if (wfa->states != states) remove_states (states, wfa); return MAXCOSTS; } - else if (lincomb_costs < subdivide_costs) + else if (lincomb_costs < subdivide_costs) { /* * Use the linear combination: The factors of the linear combination * are stored already in 'range', so revert the probability models - * only. + * only. */ c->domain_pool->model_free (c->domain_pool->model); c->d_domain_pool->model_free (c->d_domain_pool->model); @@ -452,7 +452,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, c->d_coeff->model_free (c->d_coeff->model); c->coeff->model_free (coeff_model); c->d_coeff->model_free (d_coeff_model); - + c->domain_pool->model = lc_domain_model; c->d_domain_pool->model = lc_d_domain_model; c->coeff->model = lc_coeff_model; @@ -461,7 +461,7 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, c->p_tree = p_tree_model; *range = lrange; - + if (wfa->states != states) remove_states (states, wfa); @@ -474,8 +474,8 @@ subdivide (real_t max_costs, unsigned band, int y_state, range_t *range, * given in child[]. * Don't use state in linear combinations in any of the following cases: * - if color component is Cb or Cr - * - if level of state > tiling level - * - if state is (partially) outside image geometry + * - if level of state > tiling level + * - if state is (partially) outside image geometry */ if (band > Y || (c->tiling->exponent @@ -545,7 +545,7 @@ cut_to_bintree (real_t *dst, const word_t *src, /***************************************************************************** private code - + *****************************************************************************/ static void @@ -558,7 +558,7 @@ init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range, * If flag 'delta' is set then state represents a delta image (prediction via * nondeterminism or motion compensation). * 'range' the current range image, - * 'child []' the left and right childs of 'range'. + * 'child []' the left and right children of 'range'. * * No return value. * @@ -583,11 +583,11 @@ init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range, } else state_is_domain = NO; - + range->into [0] = NO_EDGE; range->tree = wfa->states; - - for (label = 0; label < MAXLABELS; label++) + + for (label = 0; label < MAXLABELS; label++) { wfa->tree [wfa->states][label] = child [label].tree; wfa->y_state [wfa->states][label] = y_state [label]; @@ -605,7 +605,7 @@ init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range, warning ("Negative image norm: %f, %f", child [0].err, child [1].err); /* state_is_domain = YES; */ - + append_state (!state_is_domain, compute_final_distribution (wfa->states, wfa), range->level, wfa, c); @@ -621,13 +621,13 @@ init_range (range_t *range, const image_t *image, unsigned band, * No return value. * * Side effects: - * 'c->pixels' are filled with pixel values of image block - * 'c->ip_images_state' are computed with respect to new image block + * 'c->pixels' are filled with pixel values of image block + * 'c->ip_images_state' are computed with respect to new image block * 'range->address' and 'range->image' are initialized with zero */ { unsigned state; - + /* * Clear already computed products */ @@ -640,7 +640,7 @@ init_range (range_t *range, const image_t *image, unsigned band, image->width, image->height, range->x, range->y, width_of_level (range->level), height_of_level (range->level)); - + range->address = range->image = 0; compute_ip_images_state (0, 0, range->level, 1, 0, wfa, c); } diff --git a/converter/other/fiasco/codec/wfa.h b/converter/other/fiasco/codec/wfa.h index 59020fc1..4e66ccbd 100644 --- a/converter/other/fiasco/codec/wfa.h +++ b/converter/other/fiasco/codec/wfa.h @@ -2,7 +2,7 @@ * wfa.h * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -20,7 +20,7 @@ #define MAXEDGES 5 #define MAXSTATES 6000 #define MAXLABELS 2 /* only bintree possible anymore */ -#define MAXLEVEL 22 +#define MAXLEVEL 22 #define FIASCO_BINFILE_RELEASE 2 #define FIASCO_MAGIC "FIASCO" /* FIASCO magic number */ @@ -85,7 +85,7 @@ typedef struct wfa_info char *basis_name; /* filename of the initial basis */ char *title; /* title of FIASCO stream */ char *comment; /* comment for FIASCO stream */ - + unsigned max_states; /* max. cardinality of domain pool */ unsigned chroma_max_states; /* max. cardinality of domain pool for chroma band coding */ @@ -111,7 +111,7 @@ typedef struct wfa_info typedef struct wfa /* - * Used to store all informations and data structures of a WFA + * Used to store all information and data structures of a WFA */ { wfa_info_t *wfainfo; /* misc. information about the WFA */ diff --git a/converter/other/fiasco/doc/fiasco_c_options_new.3 b/converter/other/fiasco/doc/fiasco_c_options_new.3 index d873b642..a7a96409 100644 --- a/converter/other/fiasco/doc/fiasco_c_options_new.3 +++ b/converter/other/fiasco/doc/fiasco_c_options_new.3 @@ -407,11 +407,10 @@ during coding. The following types are available: .SH RETURN VALUES The function \fBfiasco_c_options_new()\fP returns a pointer to the -newly allocated coder option object. If an error has been catched, a +newly allocated coder option object. If an error has been caught, a NULL pointer is returned. -All set functions return 1 on success and 0 if an error has been -catched. +All set functions return 1 on success and 0 if an error has been caught. In case of an error, use the function fiasco_get_error_message(3) to get a string with the last error message of FIASCO. diff --git a/converter/other/fiasco/doc/fiasco_coder.3 b/converter/other/fiasco/doc/fiasco_coder.3 index 9f2e0f8e..ce32bb4d 100644 --- a/converter/other/fiasco/doc/fiasco_coder.3 +++ b/converter/other/fiasco/doc/fiasco_coder.3 @@ -73,7 +73,7 @@ available to change the default values. .SH RETURN VALUE The function \fBfiasco_coder()\fP returns 1 if the FIASCO file has -been successfully written. If an error has been catched during +been successfully written. If an error has been caught during compression, 0 is returned - use the function fiasco_get_error_message(3) to get the last error message of FIASCO. diff --git a/converter/other/fiasco/doc/fiasco_d_options_new.3 b/converter/other/fiasco/doc/fiasco_d_options_new.3 index d7f2181a..02feabb0 100644 --- a/converter/other/fiasco/doc/fiasco_d_options_new.3 +++ b/converter/other/fiasco/doc/fiasco_d_options_new.3 @@ -97,11 +97,11 @@ channel is only one half of the width and height of the luminance. .SH RETURN VALUES The function \fBfiasco_d_options_new()\fP returns a pointer to the -newly allocated decoder option object. If an error has been catched, a +newly allocated decoder option object. If an error has been caught, a NULL pointer is returned. All set functions return 1 on success and 0 if an error has been -catched. +caught. In case of an error, use the function fiasco_get_error_message(3) to get a string with the last error message of FIASCO. diff --git a/converter/other/fiasco/doc/fiasco_decoder_new.3 b/converter/other/fiasco/doc/fiasco_decoder_new.3 index 5d1d0d08..2af44f43 100644 --- a/converter/other/fiasco/doc/fiasco_decoder_new.3 +++ b/converter/other/fiasco/doc/fiasco_decoder_new.3 @@ -125,37 +125,37 @@ store the internal state of the decoder. .SH RETURN VALUES The function \fBfiasco_decoder_new()\fP returns a pointer to the newly -allocated decoder object. If an error has been catched, a NULL pointer +allocated decoder object. If an error has been caught, a NULL pointer is returned. The function \fBfiasco_decoder_write_frame()\fP returns 1 if the file has been successfully written. Otherwise, the function returns 0. The function \fBfiasco_decoder_get_frame()\fP returns a pointer to the -newly allocated FIASCO image object. If an error has been catched, a NULL +newly allocated FIASCO image object. If an error has been caught, a NULL pointer is returned. The function \fBfiasco_decoder_get_length()\fP returns the number of -frames of the FIASCO file. If an error has been catched, 0 is +frames of the FIASCO file. If an error has been caught, 0 is returned. The function \fBfiasco_decoder_get_rate()\fP returns the framerate (number of frames per second) of the FIASCO file. If an -error has been catched, 0 is returned. +error has been caught, 0 is returned. The function \fBfiasco_decoder_get_width()\fP returns the width of the -decoded frames of the FIASCO file. If an error has been catched, 0 is +decoded frames of the FIASCO file. If an error has been caught, 0 is returned. The function \fBfiasco_decoder_get_height()\fP returns the height of the -decoded frames of the FIASCO file. If an error has been catched, 0 is +decoded frames of the FIASCO file. If an error has been caught, 0 is returned. The function \fBfiasco_decoder_get_title()\fP returns an optional -title of the FIASCO file. If an error has been catched, 0 is returned. +title of the FIASCO file. If an error has been caught, 0 is returned. The function \fBfiasco_decoder_get_comment()\fP returns an optional -comment of the FIASCO file. If an error has been catched, 0 is returned. +comment of the FIASCO file. If an error has been caught, 0 is returned. The function \fBfiasco_decoder_is_color()\fP returns 0 if the decoded frames are grayscale images, otherwise a non-zero value is diff --git a/converter/other/fiasco/doc/fiasco_get_error_message.3 b/converter/other/fiasco/doc/fiasco_get_error_message.3 index ce53e6d9..da32c94e 100644 --- a/converter/other/fiasco/doc/fiasco_get_error_message.3 +++ b/converter/other/fiasco/doc/fiasco_get_error_message.3 @@ -3,7 +3,7 @@ .SH NAME .B fiasco_get_error_message -\- return string describing last error catched in FIASCO library +\- return string describing last error caught in FIASCO library .SH SYNOPSIS .B #include <fiasco.h> @@ -15,11 +15,11 @@ .SH DESCRIPTION The \fBfiasco_get_error_message()\fP function returns a string -describing the last error that has been catched in the FIASCO library. +describing the last error that has been caught in the FIASCO library. .SH RETURN VALUE The function \fBfiasco_get_error_message()\fP returns the appropriate -description string, or an empty string if no error has been catched so +description string, or an empty string if no error has been caught so far. .SH "SEE ALSO" diff --git a/converter/other/fiasco/doc/fiasco_image_new.3 b/converter/other/fiasco/doc/fiasco_image_new.3 index ac3297bf..e4701a14 100644 --- a/converter/other/fiasco/doc/fiasco_image_new.3 +++ b/converter/other/fiasco/doc/fiasco_image_new.3 @@ -61,14 +61,14 @@ the environment variable \fBFIASCO_IMAGES\fP. .SH RETURN VALUE The function \fBfiasco_image_new()\fP returns a pointer to the newly -allocated image object. If an error has been catched, a NULL pointer +allocated image object. If an error has been caught, a NULL pointer is returned. The function \fBfiasco_image_get_width()\fP returns the width of the -image. If an error has been catched, 0 is returned. +image. If an error has been caught, 0 is returned. The function \fBfiasco_image_get_height()\fP returns the height of the -image. If an error has been catched, 0 is returned. +image. If an error has been caught, 0 is returned. The function \fBfiasco_image_is_color()\fP returns 0 if the image object is a grayscale image, otherwise a non-zero value is returned. diff --git a/converter/other/fiasco/doc/fiasco_options_new.3 b/converter/other/fiasco/doc/fiasco_options_new.3 index f26586a7..884876c7 100644 --- a/converter/other/fiasco/doc/fiasco_options_new.3 +++ b/converter/other/fiasco/doc/fiasco_options_new.3 @@ -416,11 +416,11 @@ during coding. The following types are available: .SH RETURN VALUES The function \fBfiasco_decoder_new()\fP returns a pointer to the newly -allocated option object. If an error has been catched, a NULL pointer +allocated option object. If an error has been caught, a NULL pointer is returned. All set functions return 1 on success and 0 if an error has been -catched. +caught. In case of an error, use the function fiasco_get_error_message(3) to get a string with the last error message of FIASCO. diff --git a/converter/other/fiasco/doc/fiasco_renderer_new.3 b/converter/other/fiasco/doc/fiasco_renderer_new.3 index 8b5e47cd..54bbdbcf 100644 --- a/converter/other/fiasco/doc/fiasco_renderer_new.3 +++ b/converter/other/fiasco/doc/fiasco_renderer_new.3 @@ -97,7 +97,7 @@ fiasco_image_new(3). .SH RETURN VALUE The function \fBfiasco_renderer_new()\fP returns a pointer to the newly -allocated renderer object. If an error has been catched, a NULL pointer +allocated renderer object. If an error has been caught, a NULL pointer is returned. The function \fBfiasco_renderer_render()\fP returns 1 if the image diff --git a/converter/other/fiasco/input/basis.c b/converter/other/fiasco/input/basis.c index aa371ea1..e5ced0d0 100644 --- a/converter/other/fiasco/input/basis.c +++ b/converter/other/fiasco/input/basis.c @@ -1,8 +1,8 @@ /* - * basis.c: WFA initial basis files + * basis.c: WFA initial basis files * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -44,29 +44,29 @@ typedef struct /***************************************************************************** prototypes - + *****************************************************************************/ static void small_init (basis_values_t *bv); -static basis_file_t const basis_files[] = { +static basis_file_t const basis_files[] = { {"small.fco", small_init}, {"small.wfa", small_init}, - {NULL, NULL} + {NULL, NULL} }; /***************************************************************************** public code - + *****************************************************************************/ bool_t get_linked_basis (const char *basis_name, wfa_t *wfa) /* - * Check wether given WFA initial basis 'basis_name' is already linked - * with the excecutable. If the basis is available then fill the 'wfa' struct + * Check whether given WFA initial basis 'basis_name' is already linked + * with the executable. If the basis is available then fill the 'wfa' struct * according to the stored data, otherwise print a warning message. * * Return value: @@ -79,18 +79,18 @@ get_linked_basis (const char *basis_name, wfa_t *wfa) bool_t success = NO; /* indicates if basis is found */ unsigned n; /* counter */ basis_values_t bv; /* basis values */ - + for (n = 0; basis_files [n].filename != NULL; n++) if (streq (basis_files [n].filename, basis_name)) /* basis is stored */ { - unsigned state, edge; - + unsigned state, edge; + (*basis_files [n].function) (&bv); /* initialize local variables */ /* * Generate WFA */ wfa->basis_states = wfa->states = bv.states + 1; - wfa->domain_type[0] = USE_DOMAIN_MASK; + wfa->domain_type[0] = USE_DOMAIN_MASK; wfa->final_distribution[0] = 128; append_edge (0, 0, 1.0, 0, wfa); append_edge (0, 0, 1.0, 1, wfa); @@ -105,13 +105,13 @@ get_linked_basis (const char *basis_name, wfa_t *wfa) append_edge (bv.transitions [edge][0], bv.transitions [edge][1], bv.transitions [edge][2], bv.transitions [edge][3], wfa); - + success = YES; break; } if (!success) - warning ("WFA initial basis '%s' isn't linked with the excecutable yet." + warning ("WFA initial basis '%s' isn't linked with the executable yet." "\nLoading basis from disk instead.", basis_name); return success; @@ -120,7 +120,7 @@ get_linked_basis (const char *basis_name, wfa_t *wfa) /***************************************************************************** private code - + *****************************************************************************/ /***************************************************************************** @@ -141,3 +141,6 @@ small_init (basis_values_t *bv) bv->use_domain = use_domain_small; bv->transitions = transitions_small; } + + + diff --git a/converter/other/fiasco/input/matrices.c b/converter/other/fiasco/input/matrices.c index 388855ea..d20a27eb 100644 --- a/converter/other/fiasco/input/matrices.c +++ b/converter/other/fiasco/input/matrices.c @@ -2,7 +2,7 @@ * matrices.c: Input of transition matrices * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -34,7 +34,7 @@ /***************************************************************************** prototypes - + *****************************************************************************/ static unsigned @@ -49,19 +49,19 @@ compute_y_state (int state, int y_state, wfa_t *wfa); /***************************************************************************** public code - + *****************************************************************************/ unsigned read_matrices (wfa_t *wfa, bitfile_t *input) -/* +/* * Read transitions of WFA given from the stream 'input'. * * Return value: * number of edges * * Side effects: - * 'wfa->into' is filled with decoded values + * 'wfa->into' is filled with decoded values */ { unsigned total; /* total number of edges in the WFA */ @@ -73,14 +73,14 @@ read_matrices (wfa_t *wfa, bitfile_t *input) total += delta_decoding (wfa, root_state, input); if (wfa->wfainfo->color) total += chroma_decoding (wfa, input); - + return total; } /***************************************************************************** private code - + *****************************************************************************/ static unsigned @@ -94,7 +94,7 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input) * number of non-zero matrix elements (WFA edges) * * Side effects: - * 'wfa->into' is filled with decoded values + * 'wfa->into' is filled with decoded values */ { range_sort_t rs; /* ranges are sorted as in the coder */ @@ -128,26 +128,26 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input) arith_t *decoder; model_t *elements; unsigned max_edges = read_rice_code (3, input); - + /* * Get the probability array of the number of edges distribution * and allocate the corresponding model. */ { unsigned edge; - + for (edge = 0; edge <= max_edges; edge++) count [edge] = read_rice_code ((int) log2 (last_domain) - 2, input); elements = alloc_model (max_edges + 1, 0, 0, count); } - + /* * Get number of elements per matrix row */ { unsigned row; - + n_edges = Calloc (wfa->states, sizeof (unsigned)); decoder = alloc_decoder (input); for (row = range = 0; range < rs.range_no; range++) @@ -155,17 +155,17 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input) { state = rs.range_state [range]; label = rs.range_label [range]; - + n_edges [row++] = decode_symbol (decoder, elements) - (isedge (wfa->into [state][label][0]) ? 1 : 0); } - + free_decoder (decoder); free_model (elements); } } - + /* * Get matrix elements */ @@ -177,18 +177,18 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input) u_word_t *mapping_coder2 = Calloc (wfa->states, sizeof (word_t)); bool_t use_normal_domains = get_bit (input); bool_t use_delta_domains = get_bit (input); - + /* * Generate array of states which are admitted domains. * When coding intra frames 'mapping1' == 'mapping2' otherwise - * 'mapping1' is a list of 'normal' domains which are admitted for + * 'mapping1' is a list of 'normal' domains which are admitted for * coding intra blocks * 'mapping2' is a list of 'delta' domains which are admitted for - * coding the motion compensated prediction error + * coding the motion compensated prediction error */ { unsigned n1, n2, state; - + for (n1 = n2 = state = 0; state < wfa->states; state++) { mapping1 [n1] = state; @@ -197,7 +197,7 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input) && (state < wfa->basis_states || use_delta_domains || !wfa->delta_state [state])) n1++; - + mapping2 [n2] = state; mapping_coder2 [state] = n2; if (usedomain (state, wfa) @@ -206,7 +206,7 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input) n2++; } } - + for (row = 0, range = 0; range < rs.range_no; range++) if (!rs.range_subdivided [range]) { @@ -249,7 +249,7 @@ delta_decoding (wfa_t *wfa, unsigned last_domain, bitfile_t *input) Free (mapping2); Free (mapping_coder2); } - + Free (n_edges); Free (rs.range_state); Free (rs.range_label); @@ -265,12 +265,12 @@ column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input) * Read column 0 of the transition matrices of the 'wfa' which are coded * with quasi arithmetic coding from stream 'input'. * All rows from 'wfa->basis_states' up to 'last_row' are decoded. - * + * * Return value: * number of non-zero matrix elements (WFA edges) * * Side effects: - * 'wfa->into' is filled with decoded values + * 'wfa->into' is filled with decoded values */ { unsigned row; /* current matrix row */ @@ -294,9 +294,9 @@ column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input) unsigned n; unsigned index; /* probability index */ unsigned exp; /* current exponent */ - + prob = Calloc (1 << (MAX_PROB + 1), sizeof (unsigned)); - + for (index = 0, n = MIN_PROB; n <= MAX_PROB; n++) for (exp = 0; exp < 1U << n; exp++, index++) prob [index] = n; @@ -304,12 +304,12 @@ column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input) first = prob_ptr = new_prob_ptr = prob; last = first + 1020; - + is_leaf = wfa->tree [wfa->basis_states]; /* use pointer arithmetics ... */ high = HIGH; /* 1.0 */ low = LOW; /* 0.0 */ - code = get_bits (input, 16); + code = get_bits (input, 16); /* * Decode column 0 with a quasi arithmetic coder (QAC). @@ -325,7 +325,7 @@ column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input) for (row = wfa->basis_states; row <= last_row; row++) { unsigned count; /* value in the current interval */ - + /* * Read label 0 element */ @@ -397,7 +397,7 @@ column_0_decoding (wfa_t *wfa, unsigned last_row, bitfile_t *input) INPUT_BYTE_ALIGN (input); Free (prob); - + return total; } @@ -411,7 +411,7 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input) * number of non-zero matrix elements (WFA edges) * * Side effects: - * 'wfa->into' is filled with decoded values + * 'wfa->into' is filled with decoded values */ { unsigned domain; /* current domain, counter */ @@ -425,7 +425,7 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input) u_word_t low; /* End of the current code range */ u_word_t code; /* The present input code value */ word_t *y_domains; /* domain images corresponding to Y */ - int save_index; /* YES: store current probabilty */ + int save_index; /* YES: store current probability */ /* * Compute the asymmetric probability array @@ -436,9 +436,9 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input) unsigned n; unsigned index; /* probability index */ unsigned exp; /* current exponent */ - + prob = Calloc (1 << (MAX_PROB + 1), sizeof (unsigned)); - + for (index = 0, n = MIN_PROB; n <= MAX_PROB; n++) for (exp = 0; exp < 1U << n; exp++, index++) prob [index] = n; @@ -454,7 +454,7 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input) y_domains = compute_hits (wfa->basis_states, wfa->tree [wfa->tree [wfa->root_state][0]][0], wfa->wfainfo->chroma_max_states, wfa); - + first = prob_ptr = new_prob_ptr = prob; last = first + 1020; @@ -554,7 +554,7 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input) wfa->tree [wfa->tree [wfa->root_state][0]][0], wfa); compute_y_state (wfa->tree [wfa->tree [wfa->root_state][1]][0], wfa->tree [wfa->tree [wfa->root_state][0]][0], wfa); - + first = prob_ptr = new_prob_ptr = prob; /* @@ -566,7 +566,7 @@ chroma_decoding (wfa_t *wfa, bitfile_t *input) */ { unsigned row; - + for (row = wfa->tree [wfa->tree [wfa->root_state][0]][0] + 1; row < wfa->states; row++) { @@ -629,7 +629,7 @@ compute_y_state (int state, int y_state, wfa_t *wfa) */ { unsigned label; - + for (label = 0; label < MAXLABELS; label++) if (isrange (y_state)) wfa->y_state [state][label] = RANGE; @@ -640,5 +640,7 @@ compute_y_state (int state, int y_state, wfa_t *wfa) compute_y_state (wfa->tree [state][label], wfa->y_state [state][label], wfa); } - + } + + diff --git a/converter/other/fiasco/input/mc.c b/converter/other/fiasco/input/mc.c index 2d4a073d..afc0c1c3 100644 --- a/converter/other/fiasco/input/mc.c +++ b/converter/other/fiasco/input/mc.c @@ -1,9 +1,9 @@ /* - * mc.c: Input of motion compensation + * mc.c: Input of motion compensation * * written by: Michael Unger * Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -32,10 +32,10 @@ /***************************************************************************** local variables - + *****************************************************************************/ -typedef struct huff_node +typedef struct huff_node { int code_index; /* leaf if index >= 0 */ struct huff_node *left; /* follow if '0' bit read */ @@ -46,7 +46,7 @@ typedef struct huff_node /***************************************************************************** prototypes - + *****************************************************************************/ static void @@ -64,7 +64,7 @@ create_huff_node (huff_node_t *hn, int bits_processed); /***************************************************************************** public code - + *****************************************************************************/ void @@ -90,7 +90,7 @@ read_mc (frame_type_e frame_type, wfa_t *wfa, bitfile_t *input) /***************************************************************************** private code - + *****************************************************************************/ static void @@ -114,8 +114,8 @@ decode_mc_tree (frame_type_e frame_type, unsigned max_state, /* * Traverse tree in breadth first order (starting at level - * 'wfa->wfainfo->p_max_level'). Use a queue to store the childs - * of each node ('last' is the next free queue element). + * 'wfa->wfainfo->p_max_level'). Use a queue to store the children + * of each node ('last' is the next free queue element). */ queue = Calloc (MAXSTATES, sizeof (unsigned)); for (last = 0, state = wfa->basis_states; state < max_state; state++) @@ -126,7 +126,7 @@ decode_mc_tree (frame_type_e frame_type, unsigned max_state, { unsigned label; /* current label */ unsigned current; /* current node to process */ - + for (current = 0; current < last; current++) for (label = 0; label < MAXLABELS; label++) { @@ -147,7 +147,7 @@ decode_mc_tree (frame_type_e frame_type, unsigned max_state, if (wfa->mv_tree [state][label].type == NONE && !isrange (wfa->tree [state][label]) && wfa->level_of_state [state] - 1 >= - (int) wfa->wfainfo->p_min_level) + (int) wfa->wfainfo->p_min_level) queue [last++] = wfa->tree [state][label]; /* append child */ } } @@ -155,7 +155,7 @@ decode_mc_tree (frame_type_e frame_type, unsigned max_state, { unsigned label; /* current label */ unsigned current; /* current node to process */ - + for (current = 0; current < last; current++) for (label = 0; label < MAXLABELS; label++) { @@ -172,18 +172,18 @@ decode_mc_tree (frame_type_e frame_type, unsigned max_state, wfa->mv_tree[state][label].type = NONE; else if (get_bit (input)) /* 01 */ wfa->mv_tree[state][label].type = INTERPOLATED; - else if (get_bit (input)) /* 001 */ + else if (get_bit (input)) /* 001 */ wfa->mv_tree[state][label].type = BACKWARD; - else /* 000 */ + else /* 000 */ wfa->mv_tree[state][label].type = FORWARD; if (wfa->mv_tree[state][label].type == NONE && !isrange (wfa->tree[state][label]) && wfa->level_of_state[state] - 1 - >= (int) wfa->wfainfo->p_min_level) + >= (int) wfa->wfainfo->p_min_level) queue[last++] = wfa->tree[state][label]; /* append child */ } } - + INPUT_BYTE_ALIGN (input); Free (queue); } @@ -205,10 +205,10 @@ decode_mc_coords (unsigned max_state, wfa_t *wfa, bitfile_t *input) unsigned state; /* current state */ mv_t *mv; /* current motion vector */ static huff_node_t *huff_mv_root = NULL; /* root of huffman tree */ - + if (huff_mv_root == NULL) huff_mv_root = create_huff_tree (); - + for (state = wfa->basis_states; state < max_state; state++) for (label = 0; label < MAXLABELS; label++) { @@ -220,12 +220,12 @@ decode_mc_coords (unsigned max_state, wfa_t *wfa, bitfile_t *input) case FORWARD: mv->fx = get_mv (1, huff_mv_root, input); mv->fy = get_mv (1, huff_mv_root, input); - break; - case BACKWARD: + break; + case BACKWARD: mv->bx = get_mv (1, huff_mv_root, input); mv->by = get_mv (1, huff_mv_root, input); - break; - case INTERPOLATED: + break; + case INTERPOLATED: mv->fx = get_mv (1, huff_mv_root, input); mv->fy = get_mv (1, huff_mv_root, input); mv->bx = get_mv (1, huff_mv_root, input); @@ -236,11 +236,11 @@ decode_mc_coords (unsigned max_state, wfa_t *wfa, bitfile_t *input) INPUT_BYTE_ALIGN (input); } - + static int get_mv (int f_code, huff_node_t *hn, bitfile_t *input) -/* - * Decode next motion vector component in bitstream +/* + * Decode next motion vector component in bitstream * by traversing the huffman tree. */ { @@ -256,7 +256,7 @@ get_mv (int f_code, huff_node_t *hn, bitfile_t *input) hn = hn->left; } vlc_code = hn->code_index - 16; - if (vlc_code == 0 || f_code == 1) + if (vlc_code == 0 || f_code == 1) return vlc_code; vlc_code_magnitude = abs (vlc_code) - 1; @@ -265,7 +265,7 @@ get_mv (int f_code, huff_node_t *hn, bitfile_t *input) else residual = get_bits (input, f_code - 1); diffvec = (vlc_code_magnitude << (f_code - 1)) + residual + 1; - + return vlc_code > 0 ? diffvec : - diffvec; } @@ -277,7 +277,7 @@ create_huff_tree (void) { unsigned i; huff_node_t *huff_root = Calloc (1, sizeof (huff_node_t)); - + /* * The nodes' index set contains indices of all codewords that are * still decodable by traversing further down from the node. @@ -318,7 +318,7 @@ create_huff_node (huff_node_t *hn, int bits_processed) if (code_len == bits_processed) /* generate leaf */ { hn->code_index = ind; - Free (hn->left); + Free (hn->left); Free (hn->right); return; } @@ -332,3 +332,6 @@ create_huff_node (huff_node_t *hn, int bits_processed) create_huff_node (hn->left, bits_processed + 1); create_huff_node (hn->right, bits_processed + 1); } + + + diff --git a/converter/other/fiasco/input/nd.c b/converter/other/fiasco/input/nd.c index 52d48e61..129a150e 100644 --- a/converter/other/fiasco/input/nd.c +++ b/converter/other/fiasco/input/nd.c @@ -1,8 +1,8 @@ /* - * nd.c: Input of prediction tree + * nd.c: Input of prediction tree * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -31,7 +31,7 @@ /***************************************************************************** prototypes - + *****************************************************************************/ static void @@ -42,7 +42,7 @@ decode_nd_tree (wfa_t *wfa, bitfile_t *input); /***************************************************************************** public code - + *****************************************************************************/ void @@ -56,7 +56,7 @@ read_nd (wfa_t *wfa, bitfile_t *input) */ { unsigned total = decode_nd_tree (wfa, input); - + if (total > 0) decode_nd_coefficients (total, wfa, input); } @@ -64,7 +64,7 @@ read_nd (wfa_t *wfa, bitfile_t *input) /***************************************************************************** private code - + *****************************************************************************/ static unsigned @@ -106,7 +106,7 @@ decode_nd_tree (wfa_t *wfa, bitfile_t *input) { unsigned label; - if (wfa->level_of_state [next] > wfa->wfainfo->p_max_level + 1) + if (wfa->level_of_state [next] > wfa->wfainfo->p_max_level + 1) { /* * Nondetermismn is not allowed at levels larger than @@ -114,7 +114,7 @@ decode_nd_tree (wfa_t *wfa, bitfile_t *input) */ for (label = 0; label < MAXLABELS; label++) if (ischild (state = wfa->tree [next][label])) - queue_append (queue, &state); /* continue with childs */ + queue_append (queue, &state); /* continue with children */ } else if (wfa->level_of_state [next] > wfa->wfainfo->p_min_level) { @@ -123,7 +123,7 @@ decode_nd_tree (wfa_t *wfa, bitfile_t *input) { unsigned count; /* Current interval count */ unsigned range; /* Current interval range */ - + count = (((code - low) + 1) * sum1 - 1) / ((high - low) + 1); if (count < sum0) { @@ -192,7 +192,7 @@ decode_nd_tree (wfa_t *wfa, bitfile_t *input) static void decode_nd_coefficients (unsigned total, wfa_t *wfa, bitfile_t *input) /* - * Read #'total' weights of nondeterministic part of 'wfa' + * Read #'total' weights of nondeterministic part of 'wfa' * of given 'input' stream. * 'frame' gives the current frame number. * @@ -204,24 +204,24 @@ decode_nd_coefficients (unsigned total, wfa_t *wfa, bitfile_t *input) { unsigned *coefficients; /* array of factors to encode */ unsigned *ptr; /* pointer to current factor */ - + /* * Decode array of coefficients stored with arithmetic coding */ { const int scaling = 50; /* scaling factor of prob. model */ unsigned c_symbols = 1 << (wfa->wfainfo->dc_rpf->mantissa_bits + 1); - + ptr = coefficients = decode_array (input, NULL, &c_symbols, 1, total, scaling); } - + /* * Fill 'wfa->weights' with decoded coefficients */ { unsigned state, label; - + for (state = wfa->basis_states; state < wfa->states; state++) for (label = 0; label < MAXLABELS; label++) if (ischild (wfa->tree [state][label]) @@ -235,3 +235,6 @@ decode_nd_coefficients (unsigned total, wfa_t *wfa, bitfile_t *input) } Free (coefficients); } + + + diff --git a/converter/other/fiasco/input/read.c b/converter/other/fiasco/input/read.c index 9f4ac993..b4fcefc5 100644 --- a/converter/other/fiasco/input/read.c +++ b/converter/other/fiasco/input/read.c @@ -2,7 +2,7 @@ * read.c: Input of WFA files * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -47,7 +47,7 @@ /***************************************************************************** prototypes - + *****************************************************************************/ static void @@ -57,7 +57,7 @@ read_tiling (tiling_t *tiling, unsigned image_width, unsigned image_height, /***************************************************************************** public code - + *****************************************************************************/ bitfile_t * @@ -69,14 +69,14 @@ open_wfa (const char *filename, wfa_info_t *wi) * Pointer to input stream (fileposition: first WFA frame) * * Side effects: - * The values of the header of 'filename' are copied to 'wfainfo'. + * The values of the header of 'filename' are copied to 'wfainfo'. * */ { bitfile_t *input; /* pointer to WFA bitfile */ - + assert (filename && wi); - + wi->wfa_name = strdup (filename); /* @@ -85,16 +85,16 @@ open_wfa (const char *filename, wfa_info_t *wi) { unsigned n; const char *str; - + if (!(input = open_bitfile (filename, "FIASCO_DATA", READ_ACCESS))) file_error (filename); - + for (str = FIASCO_MAGIC, n = strlen (FIASCO_MAGIC); n; n--) if (get_bits (input, 8) != (unsigned) *str++) error ("Input file %s is not a valid FIASCO file!", filename); get_bits (input, 8); /* fetch newline */ } - + /* * Read WFA header information */ @@ -102,13 +102,13 @@ open_wfa (const char *filename, wfa_info_t *wi) char basis_name [MAXSTRLEN]; /* temp. buffer */ const unsigned rice_k = 8; /* parameter of Rice Code */ char *str = basis_name; - + while ((*str++ = get_bits (input, 8)) != 0 && str < basis_name + MAXSTRLEN) ; if (str == basis_name + MAXSTRLEN) error ("Input file %s is not a valid FIASCO file!", filename); - + { wi->release = read_rice_code (rice_k, input); @@ -121,12 +121,12 @@ open_wfa (const char *filename, wfa_info_t *wi) if (wi->release > 1) { header_type_e type; - + while ((type = read_rice_code (rice_k, input)) != HEADER_END) { char buffer [MAXSTRLEN]; unsigned n = 0; - + switch (type) { case HEADER_TITLE: @@ -157,7 +157,7 @@ open_wfa (const char *filename, wfa_info_t *wi) { unsigned lx = log2 (wi->width - 1) + 1; unsigned ly = log2 (wi->height - 1) + 1; - + wi->level = MAX(lx, ly) * 2 - ((ly == lx + 1) ? 1 : 0); } wi->chroma_max_states = wi->color ? read_rice_code (rice_k, input) : -1; @@ -176,14 +176,14 @@ open_wfa (const char *filename, wfa_info_t *wi) mantissa = get_bits (input, 3) + 2; range = get_bits (input, 2); wi->rpf = alloc_rpf (mantissa, range); - + if (get_bit (input)) /* different DC model */ { mantissa = get_bits (input, 3) + 2; range = get_bits (input, 2); wi->dc_rpf = alloc_rpf (mantissa, range); } - else /* use same model for DC coefficents */ + else /* use same model for DC coefficients */ wi->dc_rpf = alloc_rpf (wi->rpf->mantissa_bits, wi->rpf->range_e); @@ -196,7 +196,7 @@ open_wfa (const char *filename, wfa_info_t *wi) else wi->d_rpf = alloc_rpf (wi->rpf->mantissa_bits, wi->rpf->range_e); - + if (get_bit (input)) /* different DC delta model */ { mantissa = get_bits (input, 3) + 2; @@ -216,7 +216,7 @@ open_wfa (const char *filename, wfa_info_t *wi) wi->B_as_past_ref = get_bit (input) ? YES : NO; } } - + INPUT_BYTE_ALIGN (input); return input; @@ -246,10 +246,10 @@ read_basis (const char *filename, wfa_t *wfa) Free (wfa->wfainfo->basis_name); wfa->wfainfo->basis_name = strdup (filename); } - + if (get_linked_basis (filename, wfa)) - return; /* basis is linked with excecutable */ - + return; /* basis is linked with executable */ + /* * Check whether 'wfa_name' is a regular ASCII WFA initial basis file */ @@ -258,19 +258,19 @@ read_basis (const char *filename, wfa_t *wfa) if (!(input = open_file (filename, "FIASCO_DATA", READ_ACCESS))) file_error(filename); - + if (fscanf (input, MAXSTRLEN_SCANF, magic) != 1) error ("Format error: ASCII FIASCO initial basis file %s", filename); else if (strneq (FIASCO_BASIS_MAGIC, magic)) error ("Input file %s is not an ASCII FIASCO initial basis!", filename); } - + /* * WFA ASCII format: * * Note: State 0 is assumed to be the constant function f(x, y) = 128. - * Don't define any transitions of state 0 in an initial basis. + * Don't define any transitions of state 0 in an initial basis. * * Header: * type |description @@ -307,14 +307,14 @@ read_basis (const char *filename, wfa_t *wfa) /* * State 0 is assumed to be the constant function f(x, y) = 128. */ - wfa->domain_type [0] = USE_DOMAIN_MASK; + wfa->domain_type [0] = USE_DOMAIN_MASK; wfa->final_distribution [0] = 128; wfa->states = wfa->basis_states; wfa->basis_states++; append_edge (0, 0, 1.0, 0, wfa); append_edge (0, 0, 1.0, 1, wfa); - + for (state = 1; state < wfa->basis_states; state++) wfa->domain_type [state] = read_int (input) ? USE_DOMAIN_MASK : AUXILIARY_MASK; @@ -343,7 +343,7 @@ read_basis (const char *filename, wfa_t *wfa) } } } - + fclose (input); } @@ -353,7 +353,7 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input) * Read next WFA frame of the WFA stream 'input'. * WFA header information has to be already present in the 'wfainfo' struct. * (i.e. open_wfa must be called first!) - * + * * No return value. * * Side effects: @@ -364,9 +364,9 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input) { tiling_t tiling; /* tiling information */ unsigned frame_number; /* current frame number */ - + assert (wfa && input); - + /* * Frame header information */ @@ -382,16 +382,16 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input) { INPUT_BYTE_ALIGN (input); } - + /* - * Read image tiling info + * Read image tiling info */ if (get_bit (input)) /* tiling performed ? */ read_tiling (&tiling, wfa->wfainfo->width, wfa->wfainfo->height, wfa->wfainfo->level, input); else tiling.exponent = 0; - + INPUT_BYTE_ALIGN (input); read_tree (wfa, &tiling, input); @@ -402,7 +402,7 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input) */ { unsigned state; - + for (state = wfa->basis_states; state < wfa->states; state++) if ((!wfa->wfainfo->color || (int) state <= wfa->tree [wfa->tree [wfa->root_state][0]][0]) @@ -420,7 +420,7 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input) else wfa->domain_type [state] = 0; } - + if (tiling.exponent) Free (tiling.vorder); @@ -431,12 +431,12 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input) read_mc (wfa->frame_type, wfa, input); locate_delta_images (wfa); - + /* * Read linear combinations (coefficients and indices) */ { - unsigned edges = read_matrices (wfa, input); + unsigned edges = read_matrices (wfa, input); if (edges) read_weights (edges, wfa, input); @@ -447,7 +447,7 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input) */ { unsigned state; - + for (state = wfa->basis_states; state <= wfa->states; state++) wfa->final_distribution[state] = compute_final_distribution (state, wfa); @@ -459,7 +459,7 @@ read_next_wfa (wfa_t *wfa, bitfile_t *input) /***************************************************************************** private code - + *****************************************************************************/ static void @@ -468,14 +468,14 @@ read_tiling (tiling_t *tiling, unsigned image_width, unsigned image_height, /* * Read image tiling information from the given file 'input' * and store parameters in struct 'tiling'. - * + * * No return value. */ { const unsigned rice_k = 8; /* parameter of Rice Code */ - + tiling->exponent = read_rice_code (rice_k, input); - + if (get_bit (input)) /* variance order */ { unsigned tile; /* current image tile */ @@ -487,7 +487,7 @@ read_tiling (tiling_t *tiling, unsigned image_width, unsigned image_height, { locate_subimage (image_level, image_level - tiling->exponent, tile, &x0, &y0, &width, &height); - if (x0 < image_width && y0 < image_height) + if (x0 < image_width && y0 < image_height) tiling->vorder [tile] = get_bits (input, tiling->exponent); else tiling->vorder [tile] = -1; @@ -500,3 +500,6 @@ read_tiling (tiling_t *tiling, unsigned image_width, unsigned image_height, tiling->exponent, get_bit (input) ? YES : NO); } } + + + diff --git a/converter/other/fiasco/input/tree.c b/converter/other/fiasco/input/tree.c index 0ac2b6ae..74ceeb68 100644 --- a/converter/other/fiasco/input/tree.c +++ b/converter/other/fiasco/input/tree.c @@ -2,7 +2,7 @@ * tree.c: Input of bintree partitioning * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -31,7 +31,7 @@ /***************************************************************************** prototypes - + *****************************************************************************/ static unsigned @@ -39,14 +39,14 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x, unsigned y, unsigned *dst_state, word_t (*bfo_tree)[MAXLABELS], wfa_t *wfa, tiling_t *tiling); -static void +static void decode_tree (bitfile_t *input, byte_t *data, unsigned n_data, unsigned scaling, u_word_t sum0, u_word_t sum1); /***************************************************************************** public code - + *****************************************************************************/ void @@ -64,7 +64,7 @@ read_tree (wfa_t *wfa, tiling_t *tiling, bitfile_t *input) { byte_t *bitstring; /* the encoded data */ word_t (*bfo_tree)[MAXLABELS]; /* node numbers in BFO */ - + /* * Read WFA tree stored in breadth first order */ @@ -75,7 +75,7 @@ read_tree (wfa_t *wfa, tiling_t *tiling, bitfile_t *input) bitstring = Calloc (total, sizeof (byte_t)); decode_tree (input, bitstring, total, scale, 1, 11); } - + /* * Generate tree using a breadth first traversal */ @@ -84,7 +84,7 @@ read_tree (wfa_t *wfa, tiling_t *tiling, bitfile_t *input) unsigned state; unsigned label; byte_t *buffer = bitstring; /* pointer to decoded data */ - + bfo_tree = Calloc (wfa->states * MAXLABELS, sizeof (word_t)); for (state = 0, next = 1; state < next; state++) for (label = 0; label < MAXLABELS; label++) @@ -110,7 +110,7 @@ read_tree (wfa_t *wfa, tiling_t *tiling, bitfile_t *input) /***************************************************************************** private code - + *****************************************************************************/ static unsigned @@ -119,13 +119,13 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x, word_t (*bfo_tree)[MAXLABELS], wfa_t *wfa, tiling_t *tiling) /* - * Map state 'src_state' (breadth first order) + * Map state 'src_state' (breadth first order) * to state '*dst_state' (depth first order) * Add a tree edge 'state' --> 'child' with label and weight 1.0 * if required. * 'x', 'y' give the coordinates of the current state in the 'color' image - * of size 'image_level'. 'tiling' defines the image partitioning. - * + * of size 'image_level'. 'tiling' defines the image partitioning. + * * Return value: * new node number in depth first order * @@ -134,8 +134,8 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x, * are filled with decoded values. */ { - unsigned newx [MAXLABELS]; /* x coordinate of childs */ - unsigned newy [MAXLABELS]; /* y coordinate of childs */ + unsigned newx [MAXLABELS]; /* x coordinate of children */ + unsigned newy [MAXLABELS]; /* y coordinate of children */ unsigned x0, y0; /* NW corner of image tile */ unsigned width, height; /* size of image tile */ @@ -145,7 +145,7 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x, if (tiling->exponent && level == wfa->wfainfo->level - tiling->exponent) { unsigned tile; - + for (tile = 0; tile < 1U << tiling->exponent; tile++) { locate_subimage (wfa->wfainfo->level, level, tile, @@ -159,7 +159,7 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x, } } /* - * Coordinates of childs 0 and 1 + * Coordinates of children 0 and 1 */ if (wfa->wfainfo->color && level == wfa->wfainfo->level + 1) newx[0] = newy[0] = newx[1] = newy[1] = 0; @@ -170,12 +170,12 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x, newx[1] = level & 1 ? x : x + width_of_level (level - 1); newy[1] = level & 1 ? y + height_of_level (level - 1) : y; } - + /* * Remap node numbers */ { - int child [MAXLABELS]; /* childs of current node (state) */ + int child [MAXLABELS]; /* children of current node (state) */ int domain; /* current domain */ unsigned label; @@ -196,17 +196,17 @@ restore_depth_first_order (unsigned src_state, unsigned level, unsigned x, } wfa->level_of_state [*dst_state] = level; } - + return (*dst_state)++; -} +} /**************************************************************************** Binary adaptive arithmetic compression - + ****************************************************************************/ -static void +static void decode_tree (bitfile_t *input, byte_t *data, unsigned n_data, unsigned scaling, u_word_t sum0, u_word_t sum1) /* @@ -235,11 +235,11 @@ decode_tree (bitfile_t *input, byte_t *data, unsigned n_data, unsigned scaling, low = 0; high = 0xffff; - for (n = n_data; n; n--) + for (n = n_data; n; n--) { unsigned count; /* Current interval count */ unsigned range; /* Current interval range */ - + count = (((code - low) + 1) * sum1 - 1) / ((high - low) + 1); if (count < sum0) { diff --git a/converter/other/fiasco/lib/arith.c b/converter/other/fiasco/lib/arith.c index 825d4757..e61e753e 100644 --- a/converter/other/fiasco/lib/arith.c +++ b/converter/other/fiasco/lib/arith.c @@ -2,7 +2,7 @@ * arith.c: Adaptive arithmetic coding and decoding * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -27,7 +27,7 @@ /****************************************************************************** public code - + ******************************************************************************/ arith_t * @@ -35,7 +35,7 @@ alloc_encoder (bitfile_t *output) /* * Arithmetic coder constructor: * Initialize the arithmetic coder. - * + * * Return value: * A pointer to the new coder structure */ @@ -43,7 +43,7 @@ alloc_encoder (bitfile_t *output) arith_t *arith = Calloc (1, sizeof (arith_t)); assert (output); - + arith->low = LOW; arith->high = HIGH; arith->underflow = 0; @@ -58,7 +58,7 @@ free_encoder (arith_t *arith) * Arithmetic encoder destructor. * Flush the arithmetic coder. Append all remaining bits to the * output stream. Append zero bits to get the output file byte aligned. - * + * * No return value. */ { @@ -66,14 +66,14 @@ free_encoder (arith_t *arith) u_word_t high; /* end of the current code range */ u_word_t underflow; /* number of underflow bits pending */ bitfile_t *output; - + assert (arith); low = arith->low; high = arith->high; underflow = arith->underflow; output = arith->file; - + low = high; RESCALE_OUTPUT_INTERVAL; @@ -92,7 +92,7 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model) * * The model is updated after encoding the symbol (if necessary the * symbol counts are rescaled). - * + * * Return value: * information content of the encoded symbol. * @@ -110,7 +110,7 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model) u_word_t high; /* end of the current code range */ u_word_t underflow; /* number of underflow bits pending */ bitfile_t *output; /* output file */ - + assert (model && arith); /* @@ -122,7 +122,7 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model) output = arith->file; assert (high > low); - + if (model->order > 0) /* order-'n' model*/ { unsigned power; /* multiplicator */ @@ -134,10 +134,10 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model) */ power = 1; /* multiplicator */ index = 0; /* address of prob. model */ - - for (i = 0; i < model->order; i++) /* genarate a M-nary number */ + + for (i = 0; i < model->order; i++) /* generate a M-nary number */ { - index += model->context [i] * power; + index += model->context [i] * power; power *= model->symbols; } @@ -160,9 +160,9 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model) range = (high - low) + 1; high = low + (u_word_t) ((range * high_count) / scale - 1); low = low + (u_word_t) ((range * low_count) / scale); - + RESCALE_OUTPUT_INTERVAL; - + if (model->scale > 0) /* adaptive model */ { unsigned i; @@ -189,7 +189,7 @@ encode_symbol (unsigned symbol, arith_t *arith, model_t *model) arith->low = low; arith->high = high; arith->underflow = underflow; - + return - log2 ((high_count - low_count) / (real_t) scale); } @@ -214,21 +214,21 @@ encode_array (bitfile_t *output, const unsigned *data, const unsigned *context, assert (output && c_symbols && data); assert (n_context == 1 || context); - + /* * Allocate probability models, start with uniform distribution */ totals = Calloc (n_context, sizeof (u_word_t *)); { unsigned c; - + for (c = 0; c < n_context; c++) { unsigned i; - + totals [c] = Calloc (c_symbols [c] + 1, sizeof (u_word_t)); totals [c][0] = 0; - + for (i = 0; i < c_symbols [c]; i++) totals [c][i + 1] = totals [c][i] + 1; } @@ -242,7 +242,7 @@ encode_array (bitfile_t *output, const unsigned *data, const unsigned *context, u_word_t high = 0xffff; /* End of the current code range */ u_word_t underflow = 0; /* Number of underflow bits pending */ unsigned n; - + for (n = 0; n < n_data; n++) { u_word_t low_count; /* lower bound of 'symbol' interval */ @@ -253,8 +253,8 @@ encode_array (bitfile_t *output, const unsigned *data, const unsigned *context, int c; /* context of current data symbol */ d = data [n]; - c = n_context > 1 ? context [n] : 0; - + c = n_context > 1 ? context [n] : 0; + scale = totals [c][c_symbols [c]]; low_count = totals [c][d]; high_count = totals [c][d + 1]; @@ -266,7 +266,7 @@ encode_array (bitfile_t *output, const unsigned *data, const unsigned *context, high = low + (u_word_t) ((range * high_count) / scale - 1); low = low + (u_word_t) ((range * low_count) / scale); RESCALE_OUTPUT_INTERVAL; - + /* * Update probability models */ @@ -275,7 +275,7 @@ encode_array (bitfile_t *output, const unsigned *data, const unsigned *context, for (i = d + 1; i < c_symbols [c] + 1; i++) totals [c][i]++; - + if (totals [c][c_symbols [c]] > scaling) /* scaling */ for (i = 1; i < c_symbols [c] + 1; i++) { @@ -292,7 +292,7 @@ encode_array (bitfile_t *output, const unsigned *data, const unsigned *context, RESCALE_OUTPUT_INTERVAL; OUTPUT_BYTE_ALIGN (output); } - + /* * Cleanup ... */ @@ -310,16 +310,16 @@ alloc_decoder (bitfile_t *input) * Arithmetic decoder constructor: * Initialize the arithmetic decoder with the first * 16 input bits from the stream 'input'. - * + * * Return value: * A pointer to the new decoder structure */ { arith_t *arith = Calloc (1, sizeof (arith_t)); - + assert (input); - + arith->low = LOW; arith->high = HIGH; arith->code = get_bits (input, 16); @@ -333,8 +333,8 @@ free_decoder (arith_t *arith) /* * Arithmetic decoder destructor: * Flush the arithmetic decoder, i.e., read bits to get the input - * file byte aligned. - * + * file byte aligned. + * * No return value. * * Side effects: @@ -354,8 +354,8 @@ decode_symbol (arith_t *arith, model_t *model) * Decode the next symbol - the state of the arithmetic decoder * is given in 'arith'. Read refinement bits from the stream 'input' * and use the given probability 'model'. Update the probability model after - * deconding the symbol (if necessary also rescale the symbol counts). - * + * decoding the symbol (if necessary also rescale the symbol counts). + * * Return value: * decoded symbol * @@ -375,7 +375,7 @@ decode_symbol (arith_t *arith, model_t *model) bitfile_t *input; /* input file */ assert (arith && model); - + /* * Get interval values */ @@ -385,22 +385,22 @@ decode_symbol (arith_t *arith, model_t *model) input = arith->file; assert (high > low); - + if (model->order > 0) /* order-'n' model */ { unsigned power; /* multiplicator */ unsigned i; - + /* * Compute index of the probability model to use. * See init_model() for more details. */ power = 1; /* multiplicator */ index = 0; /* address of prob. model */ - - for (i = 0; i < model->order; i++) /* genarate a m-nary number */ + + for (i = 0; i < model->order; i++) /* generate a m-nary number */ { - index += model->context[i] * power; + index += model->context[i] * power; power *= model->symbols; } @@ -420,7 +420,7 @@ decode_symbol (arith_t *arith, model_t *model) if (model->order > 0) /* order-'n' model */ { unsigned i; - + for (i = 0; i < model->order - 1; i++) model->context [i] = model->context [i + 1]; model->context [i] = symbol; @@ -432,15 +432,15 @@ decode_symbol (arith_t *arith, model_t *model) { u_word_t low_count; /* lower bound of 'symbol' interval */ u_word_t high_count; /* upper bound of 'symbol' interval */ - + low_count = model->totals [index + symbol]; high_count = model->totals [index + symbol + 1]; high = low + (u_word_t) ((range * high_count) / scale - 1 ); low = low + (u_word_t) ((range * low_count) / scale ); } - + RESCALE_INPUT_INTERVAL; - + if (model->scale > 0) /* adaptive model */ { unsigned i; @@ -460,7 +460,7 @@ decode_symbol (arith_t *arith, model_t *model) } } } - + /* * Store interval values */ @@ -488,28 +488,28 @@ decode_array (bitfile_t *input, const unsigned *context, { unsigned *data; /* array to store decoded symbols */ u_word_t **totals; /* probability model */ - + if (n_context < 1) n_context = 1; /* always use one context */ assert (input && c_symbols); assert (n_context == 1 || context); data = Calloc (n_data, sizeof (unsigned)); - + /* * Allocate probability models, start with uniform distribution */ totals = Calloc (n_context, sizeof (u_word_t *)); { unsigned c; - + for (c = 0; c < n_context; c++) { unsigned i; - + totals [c] = Calloc (c_symbols [c] + 1, sizeof (u_word_t)); totals [c][0] = 0; - + for (i = 0; i < c_symbols [c]; i++) totals [c][i + 1] = totals [c][i] + 1; } @@ -523,8 +523,8 @@ decode_array (bitfile_t *input, const unsigned *context, u_word_t low = 0; /* Start of the current code range */ u_word_t high = 0xffff; /* End of the current code range */ unsigned n; - - for (n = 0; n < n_data; n++) + + for (n = 0; n < n_data; n++) { u_word_t scale; /* range of all 'm' symbol intervals */ u_word_t low_count; /* lower bound of 'symbol' interval */ @@ -534,13 +534,13 @@ decode_array (bitfile_t *input, const unsigned *context, unsigned d; /* current data symbol */ unsigned c; /* context of current data symbol */ - c = n_context > 1 ? context [n] : 0; + c = n_context > 1 ? context [n] : 0; assert (high > low); scale = totals [c][c_symbols [c]]; range = (high - low) + 1; count = (((code - low) + 1 ) * scale - 1) / range; - + for (d = c_symbols [c]; count < totals [c][d]; d--) /* next symbol */ ; low_count = totals [c][d]; @@ -558,7 +558,7 @@ decode_array (bitfile_t *input, const unsigned *context, for (i = d + 1; i < c_symbols [c] + 1; i++) totals [c][i]++; - + if (totals [c][c_symbols [c]] > scaling) /* scaling */ for (i = 1; i < c_symbols [c] + 1; i++) { @@ -577,12 +577,12 @@ decode_array (bitfile_t *input, const unsigned *context, */ { unsigned c; - + for (c = 0; c < n_context; c++) Free (totals [c]); Free (totals); } - + return data; } @@ -600,10 +600,10 @@ alloc_model (unsigned m, unsigned scale, unsigned n, unsigned *totals) * * Return value: * a pointer to the new probability model structure. - * + * * Note: We recommend a small size of the alphabet because no escape codes * are used to encode/decode previously unseen symbols. - * + * */ { model_t *model; /* new probability model */ @@ -621,7 +621,7 @@ alloc_model (unsigned m, unsigned scale, unsigned n, unsigned *totals) model->order = n; model->context = n > 0 ? Calloc (n, sizeof (unsigned)) : NULL; /* - * Allocate memory for the probabilty model. + * Allocate memory for the probability model. * Each of the m^n different contexts requires its own probability model. */ for (num = 1, i = 0; i < model->order; i++) @@ -644,17 +644,17 @@ alloc_model (unsigned m, unsigned scale, unsigned n, unsigned *totals) */ power = 1; /* multiplicator */ index = 0; /* address of prob. model */ - - for (i = 0; i < model->order; i++) /* genarate a m-nary number */ + + for (i = 0; i < model->order; i++) /* generate a m-nary number */ { - index += model->context[i] * power; + index += model->context[i] * power; power *= model->symbols; } index *= model->symbols + 1; /* size of each model is m + 1 */ model->totals [index + 0] = 0; /* always zero */ - + for (i = 1; i <= model->symbols; i++) /* prob of each symbol is 1/m or as given in totals */ model->totals[index + i] = model->totals [index + i - 1] @@ -667,14 +667,14 @@ alloc_model (unsigned m, unsigned scale, unsigned n, unsigned *totals) { dec = NO; model->context[i]++; - if (model->context[i] >= model->symbols) + if (model->context[i] >= model->symbols) { /* change previous context */ model->context[i] = 0; if (i > 0) /* there's still a context remaining */ dec = YES; else - cont = NO; /* all context models initilized */ + cont = NO; /* all context models initialized */ } } } diff --git a/converter/other/fiasco/lib/bit-io.c b/converter/other/fiasco/lib/bit-io.c index f69343e6..04716f05 100644 --- a/converter/other/fiasco/lib/bit-io.c +++ b/converter/other/fiasco/lib/bit-io.c @@ -1,12 +1,12 @@ /* - * bit-io.c: Buffered and bit oriented file I/O + * bit-io.c: Buffered and bit oriented file I/O * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ - + /* * $Date: 2000/06/14 20:49:37 $ * $Author: hafner $ @@ -35,7 +35,7 @@ /***************************************************************************** local constants - + *****************************************************************************/ static const unsigned BUFFER_SIZE = 16350; @@ -48,7 +48,7 @@ static const unsigned mask[] = {0x0001, 0x0002, 0x0004, 0x0008, /***************************************************************************** public code - + *****************************************************************************/ FILE * @@ -57,7 +57,7 @@ open_file (const char *filename, const char *env_var, openmode_e mode) * Try to open file 'filename' with mode 'mode' (READ_ACCESS, WRITE_ACCESS). * Scan the current directory first and then cycle through the * path given in the environment variable 'env_var', if set. - * + * * Return value: * Pointer to open file on success, else NULL. */ @@ -81,42 +81,42 @@ open_file (const char *filename, const char *env_var, openmode_e mode) { if (mode == READ_ACCESS) return stdin; - else + else return stdout; } - + /* * Try to open 'readonly' file in the current directory */ if (mode == READ_ACCESS && (fp = fopen (filename, read_mode))) - return fp; + return fp; if (mode == WRITE_ACCESS && strchr (filename, '/')) /* contains path */ return fopen (filename, write_mode); - + /* * Get value of environment variable 'env_var', if set * else use DEFAULT_PATH ("./") */ if (env_var != NULL) env_path = getenv (env_var); - if (env_path == NULL) + if (env_path == NULL) env_path = strdup (DEFAULT_PATH); else env_path = strdup (env_path); - + /* * Try to open file in the directory given by the environment - * variable env_var - individual path components are separated by PATH_SEP + * variable env_var - individual path components are separated by PATH_SEP */ path = strtok (env_path, PATH_SEP); - do + do { - if (ext_filename) + if (ext_filename) Free (ext_filename); ext_filename = Calloc (strlen (path) + strlen (filename) + 2, sizeof (char)); - strcpy (ext_filename, path); + strcpy (ext_filename, path); if (*(ext_filename + strlen (ext_filename) - 1) != '/') strcat (ext_filename, "/"); strcat (ext_filename, filename); @@ -125,7 +125,7 @@ open_file (const char *filename, const char *env_var, openmode_e mode) while (fp == NULL && (path = strtok (NULL, PATH_SEP)) != NULL); Free (env_path); - + return fp; } @@ -143,7 +143,7 @@ open_bitfile (const char *filename, const char *env_var, openmode_e mode) */ { bitfile_t *bitfile = Calloc (1, sizeof (bitfile_t)); - + bitfile->file = open_file (filename, env_var, mode); if (bitfile->file == NULL) @@ -164,8 +164,8 @@ open_bitfile (const char *filename, const char *env_var, openmode_e mode) bitfile->filename = filename ? strdup (filename) : strdup ("(stdout)"); } else - error ("Unknow file access mode '%d'.", mode); - + error ("Unknown file access mode '%d'.", mode); + bitfile->bits_processed = 0; bitfile->buffer = Calloc (BUFFER_SIZE, sizeof (byte_t)); bitfile->ptr = bitfile->buffer; @@ -187,7 +187,7 @@ get_bit (bitfile_t *bitfile) */ { assert (bitfile); - + if (!bitfile->bitpos--) /* use next byte ? */ { bitfile->ptr++; @@ -226,7 +226,7 @@ get_bits (bitfile_t *bitfile, unsigned bits) */ { unsigned value = 0; /* input value */ - + while (bits--) value = (unsigned) (value << 1) | get_bit (bitfile); @@ -235,7 +235,7 @@ get_bits (bitfile_t *bitfile, unsigned bits) void put_bit (bitfile_t *bitfile, unsigned value) -/* +/* * Put the bit 'value' to the bitfile buffer. * The buffer is written to the file 'bitfile->file' if the number of * buffer bytes exceeds 'BUFFER_SIZE'. @@ -247,7 +247,7 @@ put_bit (bitfile_t *bitfile, unsigned value) */ { assert (bitfile); - + if (!bitfile->bitpos--) /* use next byte ? */ { bitfile->ptr++; @@ -265,7 +265,7 @@ put_bit (bitfile_t *bitfile, unsigned value) } bitfile->bitpos = 7; } - + if (value) *bitfile->ptr |= mask [bitfile->bitpos]; @@ -274,7 +274,7 @@ put_bit (bitfile_t *bitfile, unsigned value) void put_bits (bitfile_t *bitfile, unsigned value, unsigned bits) -/* +/* * Put #'bits' bits of integer 'value' to the bitfile buffer 'bitfile'. * * No return value. @@ -292,7 +292,7 @@ close_bitfile (bitfile_t *bitfile) /* * Bitfile destructor: * Close 'bitfile', if 'bitfile->mode' == WRITE_ACCESS write bit buffer - * to disk. + * to disk. * * No return value. * @@ -301,7 +301,7 @@ close_bitfile (bitfile_t *bitfile) */ { assert (bitfile); - + if (bitfile->mode == WRITE_ACCESS) { unsigned bytes = fwrite (bitfile->buffer, sizeof (byte_t), diff --git a/converter/other/fiasco/output/mc.c b/converter/other/fiasco/output/mc.c index d048bef5..170a2648 100644 --- a/converter/other/fiasco/output/mc.c +++ b/converter/other/fiasco/output/mc.c @@ -1,9 +1,9 @@ /* - * mc.c: Output of motion compensation + * mc.c: Output of motion compensation * * Written by: Michael Unger * Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -30,7 +30,7 @@ /***************************************************************************** local variables - + *****************************************************************************/ static unsigned p_frame_codes [4][2] = @@ -39,7 +39,7 @@ static unsigned p_frame_codes [4][2] = * NONE, FORWARD */ { - {1, 1}, {0, 1}, {0, 0}, {0, 0} + {1, 1}, {0, 1}, {0, 0}, {0, 0} }; static unsigned b_frame_codes [4][2] = @@ -48,7 +48,7 @@ static unsigned b_frame_codes [4][2] = * NONE, FORWARD, BACKWARD, INTERPOLATED */ { - {1, 1}, {000, 3}, {001, 3}, {01, 2} + {1, 1}, {000, 3}, {001, 3}, {01, 2} }; enum vlc_e {CODE = 0, BITS = 1}; @@ -56,7 +56,7 @@ enum vlc_e {CODE = 0, BITS = 1}; /***************************************************************************** prototypes - + *****************************************************************************/ static void @@ -68,7 +68,7 @@ encode_mc_coords (unsigned max_state, const wfa_t *wfa, bitfile_t *output); /***************************************************************************** public code - + *****************************************************************************/ void @@ -85,7 +85,7 @@ write_mc (frame_type_e frame_type, const wfa_t *wfa, bitfile_t *output) /***************************************************************************** private code - + *****************************************************************************/ static void @@ -108,22 +108,22 @@ encode_mc_tree (unsigned max_state, frame_type_e frame_type, const wfa_t *wfa, mc_type_e type; /* type of motion compensation */ unsigned (*mc_tree_codes)[2]; /* pointer to VLC table */ unsigned bits = bits_processed (output); /* number of bits used */ - + if (frame_type == P_FRAME) mc_tree_codes = p_frame_codes; /* binary code */ - else + else mc_tree_codes = b_frame_codes; /* variable length code */ - + /* * Traverse tree in breadth first order (starting at - * level 'wfa->p_max_level'). Use a queue to store the childs - * of each node ('last' is the next free queue element). + * level 'wfa->p_max_level'). Use a queue to store the children + * of each node ('last' is the next free queue element). */ for (last = 0, state = wfa->basis_states; state < max_state; state++) if (wfa->level_of_state [state] - 1 == (int) wfa->wfainfo->p_max_level) queue [last++] = state; /* init level = 'mc_max_level' */ - + for (current = 0; current < last; current++) for (label = 0; label < MAXLABELS; label++) { @@ -145,7 +145,7 @@ encode_mc_tree (unsigned max_state, frame_type_e frame_type, const wfa_t *wfa, wfa->level_of_state [state] - 1 >= (int) wfa->wfainfo->p_min_level) queue [last++] = wfa->tree [state][label]; /* append child */ - + } OUTPUT_BYTE_ALIGN (output); @@ -174,16 +174,16 @@ encode_mc_coords (unsigned max_state, const wfa_t *wfa, bitfile_t *output) unsigned itotal = 0; /* #interpolated decisions */ unsigned bits = bits_processed (output); /* number of bits used */ unsigned sr = wfa->wfainfo->search_range; /* search range */ - + for (level = wfa->wfainfo->p_max_level; level >= wfa->wfainfo->p_min_level; level--) level_count [level] = 0; - + for (state = wfa->basis_states; state < max_state; state++) for (label = 0; label < MAXLABELS; label++) { mv_t *mv = &wfa->mv_tree[state][label]; /* motion vector info */ - + if (mv->type != NONE) { level_count [wfa->level_of_state [state] - 1]++; @@ -229,14 +229,14 @@ encode_mc_coords (unsigned max_state, const wfa_t *wfa, bitfile_t *output) } OUTPUT_BYTE_ALIGN (output); - + debug_message ("Motion compensation: %d forward, %d backward, " "%d interpolated", ftotal, btotal, itotal); for (level = wfa->wfainfo->p_max_level; level >= wfa->wfainfo->p_min_level; level--) debug_message ("Level %d: %d motion vectors", level, level_count[level]); - + { unsigned total = ftotal * 2 + btotal * 2 + itotal * 4; diff --git a/converter/other/fiasco/output/nd.c b/converter/other/fiasco/output/nd.c index 65a85467..b1dd6746 100644 --- a/converter/other/fiasco/output/nd.c +++ b/converter/other/fiasco/output/nd.c @@ -1,8 +1,8 @@ /* - * nd.c: Output of prediction tree + * nd.c: Output of prediction tree * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -32,7 +32,7 @@ /***************************************************************************** prototypes - + *****************************************************************************/ static unsigned @@ -43,7 +43,7 @@ encode_nd_coefficients (unsigned total, const wfa_t *wfa, bitfile_t *output); /***************************************************************************** public code - + *****************************************************************************/ void @@ -56,7 +56,7 @@ write_nd (const wfa_t *wfa, bitfile_t *output) */ { unsigned total = encode_nd_tree (wfa, output); - + if (total > 0) encode_nd_coefficients (total, wfa, output); } @@ -64,13 +64,13 @@ write_nd (const wfa_t *wfa, bitfile_t *output) /***************************************************************************** private code - + *****************************************************************************/ static unsigned encode_nd_tree (const wfa_t *wfa, bitfile_t *output) /* - * Write prediction tree of 'wfa' to given stream 'output'. + * Write prediction tree of 'wfa' to given stream 'output'. * * No return value. */ @@ -85,7 +85,7 @@ encode_nd_tree (const wfa_t *wfa, bitfile_t *output) unsigned bits = bits_processed (output); used = not_used = 0; - + /* * Initialize arithmetic coder */ @@ -94,18 +94,18 @@ encode_nd_tree (const wfa_t *wfa, bitfile_t *output) underflow = 0; sum0 = 1; sum1 = 11; - + queue = alloc_queue (sizeof (int)); state = wfa->root_state; queue_append (queue, &state); - + /* * Traverse the WFA tree in breadth first order (using a queue). */ while (queue_remove (queue, &next)) { unsigned label; - + if (wfa->level_of_state [next] > wfa->wfainfo->p_max_level + 1) { /* @@ -114,7 +114,7 @@ encode_nd_tree (const wfa_t *wfa, bitfile_t *output) */ for (label = 0; label < MAXLABELS; label++) if (ischild (state = wfa->tree [next][label])) - queue_append (queue, &state); /* continue with childs */ + queue_append (queue, &state); /* continue with children */ } else if (wfa->level_of_state [next] > wfa->wfainfo->p_min_level) { @@ -126,7 +126,7 @@ encode_nd_tree (const wfa_t *wfa, bitfile_t *output) if (isedge (wfa->into [next][label][0])) /* prediction used */ { used++; - + /* * Encode a '1' symbol */ @@ -134,12 +134,12 @@ encode_nd_tree (const wfa_t *wfa, bitfile_t *output) low = low + (u_word_t) ((range * sum0) / sum1); RESCALE_OUTPUT_INTERVAL; } - else /* no predict., continue with childs */ + else /* no predict., continue with children */ { not_used++; if (wfa->level_of_state [state] > wfa->wfainfo->p_min_level) queue_append (queue, &state); - + /* * Encode a '0' symbol */ @@ -162,7 +162,7 @@ encode_nd_tree (const wfa_t *wfa, bitfile_t *output) sum1 = sum0 + 1; } } - + } } free_queue (queue); @@ -178,7 +178,7 @@ encode_nd_tree (const wfa_t *wfa, bitfile_t *output) used, not_used); { unsigned total = used + not_used; - + debug_message ("nd-tree: %5d bits. (%5d symbols => %5.2f bps)", bits_processed (output) - bits, total, total > 0 ? ((bits_processed (output) - bits) / @@ -205,7 +205,7 @@ encode_nd_coefficients (unsigned total, const wfa_t *wfa, bitfile_t *output) unsigned *ptr; /* pointer to current factor */ unsigned state, label, edge; word_t domain; - + ptr = coefficients = Calloc (total, sizeof (unsigned)); for (state = wfa->basis_states; state < wfa->states; state++) @@ -232,7 +232,7 @@ encode_nd_coefficients (unsigned total, const wfa_t *wfa, bitfile_t *output) encode_array (output, coefficients, NULL, &c_symbols, 1, total, scaling); } - + debug_message ("nd-factors: %5d bits. (%5d symbols => %5.2f bps)", bits_processed (output) - bits, total, total ? ((bits_processed (output) - bits) diff --git a/converter/other/fiasco/output/tree.c b/converter/other/fiasco/output/tree.c index 2eae2df9..55080a51 100644 --- a/converter/other/fiasco/output/tree.c +++ b/converter/other/fiasco/output/tree.c @@ -2,7 +2,7 @@ * tree.c: Output of bintree partitioning * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -30,7 +30,7 @@ /***************************************************************************** prototypes - + *****************************************************************************/ static void @@ -40,7 +40,7 @@ encode_tree (bitfile_t *output, const byte_t *data, unsigned n_data, /***************************************************************************** public code - + *****************************************************************************/ void @@ -64,9 +64,9 @@ write_tree (const wfa_t *wfa, bitfile_t *output) /* * Traverse tree in breadth first order. Use a queue to store - * the childs of each node ('last' is the next free queue element). + * the children of each node ('last' is the next free queue element). * The first element ('current') of this queue will get the new parent - * node. + * node. */ tree_string = Calloc (MAXSTATES * MAXLABELS, sizeof (byte_t)); queue [0] = wfa->root_state; @@ -83,7 +83,7 @@ write_tree (const wfa_t *wfa, bitfile_t *output) if (total != (wfa->states - wfa->basis_states) * MAXLABELS) error ("total [%d] != (states - basis_states) * 2 [%d]", total, (wfa->states - wfa->basis_states) * MAXLABELS); - + { unsigned scale = total / 20 ; @@ -91,7 +91,7 @@ write_tree (const wfa_t *wfa, bitfile_t *output) } Free (tree_string); - + debug_message ("tree: %5d bits. (%5d symbols => %5.2f bps)", bits_processed (output) - bits, total, total > 0 ? ((bits_processed (output) - bits) @@ -101,7 +101,7 @@ write_tree (const wfa_t *wfa, bitfile_t *output) /***************************************************************************** private code - + *****************************************************************************/ static void @@ -128,7 +128,7 @@ encode_tree (bitfile_t *output, const byte_t *data, unsigned n_data, for (n = n_data; n; n--) { unsigned range; /* Current interval range */ - + if (!*data++) { /* diff --git a/converter/other/fiasco/params.c b/converter/other/fiasco/params.c index 7d0b84ab..29f52afc 100644 --- a/converter/other/fiasco/params.c +++ b/converter/other/fiasco/params.c @@ -3,7 +3,7 @@ * * Written by: Stefan Frank * Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ @@ -28,7 +28,7 @@ #include <stdlib.h> #include <string.h> - + #include <getopt.h> /* system or ../lib */ #include "pm_c_util.h" @@ -47,7 +47,7 @@ /***************************************************************************** prototypes - + *****************************************************************************/ static void @@ -56,7 +56,7 @@ static int get_parameter_index (const param_t *params, const char *search_string); static void set_parameter (param_t *parameter, const char *value); -static void +static void usage (const param_t *params, const char *progname, const char *synopsis, const char *comment, const char *non_opt_string, bool_t show_all_options, const char *sys_file_name, @@ -65,17 +65,17 @@ usage (const param_t *params, const char *progname, const char *synopsis, /***************************************************************************** public code - + *****************************************************************************/ int -parseargs (param_t *usr_params, - int argc, char **argv, +parseargs (param_t *usr_params, + int argc, char **argv, const char *synopsis, - const char *comment, - const char *non_opt_string, + const char *comment, + const char *non_opt_string, const char *path, - const char *sys_file_name, + const char *sys_file_name, const char *usr_file_name) /* * Perform the command line parsing. @@ -95,7 +95,7 @@ parseargs (param_t *usr_params, * * Side effects: * the elements of ARGV are permuted - * usr_params [].value is modified + * usr_params [].value is modified */ { extern int optind; /* index in ARGV of the 1st element @@ -146,7 +146,7 @@ parseargs (param_t *usr_params, */ { param_t *p; - + for (p = usr_params; p->name != NULL; p++) { set_parameter (p, p->default_value); @@ -155,7 +155,7 @@ parseargs (param_t *usr_params, } sys_params = detailed_help ? detailed_sys_params : short_sys_params; - + for (p = sys_params; p->name != NULL; p++) set_parameter (p, p->default_value); } @@ -210,12 +210,12 @@ parseargs (param_t *usr_params, int optchar; /* found option character */ /* - * Build short option string for getopt_long (). + * Build short option string for getopt_long (). */ { param_t *p; /* counter */ char *ptr_optstr; /* pointer to position in string */ - + ptr_optstr = optstr; for (p = params; p->name != NULL; p++) if (p->optchar != '\0') @@ -231,13 +231,13 @@ parseargs (param_t *usr_params, } *ptr_optstr = '\0'; } - + /* - * Build long option string for getopt_long (). + * Build long option string for getopt_long (). */ { int i; - + long_options = calloc (n1 + n2 + 1, sizeof (struct option)); if (!long_options) error ("Out of memory."); @@ -264,15 +264,15 @@ parseargs (param_t *usr_params, long_options [i].val = 0; } } - + /* - * Parse comand line + * Parse command line */ while ((optchar = getopt_long (argc, argv, optstr, long_options, &option_index)) != EOF) { int param_index = -1; - + switch (optchar) { case 0: @@ -303,7 +303,7 @@ parseargs (param_t *usr_params, default: { int i; - + for (i = 0; params [i].name != NULL; i++) if (params [i].optchar == optchar) { @@ -350,7 +350,7 @@ parseargs (param_t *usr_params, free (long_options); } - + /* * Read config-file if specified by option -f */ @@ -361,7 +361,7 @@ parseargs (param_t *usr_params, if ((filename = (char *) parameter_value (params, "config")) != NULL) { FILE *parameter_file; /* input file */ - + warning ("Options set in file `%s' will override" " command line options.", filename); parameter_file = open_file (filename, NULL, READ_ACCESS); @@ -379,10 +379,10 @@ parseargs (param_t *usr_params, memcpy (usr_params, params, n1 * sizeof (param_t)); /* fill user struct */ free (sys_path); - + return optind; } - + void * parameter_value (const param_t *params, const char *name) /* @@ -399,7 +399,7 @@ parameter_value (const param_t *params, const char *name) if (params [pind].type == PSTR || params [pind].type == POSTR) return (void *) params [pind].value.s; - + return (void *) &(params [pind].value); } @@ -414,7 +414,7 @@ ask_and_set (param_t *params, const char *name, const char *msg) * Side effects: * 'params ['name'].value' is changed */ -{ +{ char answer [MAXSTRLEN]; int index = get_parameter_index (params, name); @@ -423,7 +423,7 @@ ask_and_set (param_t *params, const char *name, const char *msg) if (msg) fprintf (stderr, "%s\n", msg); - + switch (params [index].type) { case PFLAG: /* Unusual, at least. */ @@ -439,7 +439,7 @@ ask_and_set (param_t *params, const char *name, const char *msg) default: error ("Invalid parameter type for %s", name); } -} +} void write_parameters (const param_t *params, FILE *output) @@ -483,7 +483,7 @@ write_parameters (const param_t *params, FILE *output) /***************************************************************************** private code - + *****************************************************************************/ static void @@ -498,7 +498,7 @@ set_parameter (param_t *parameter, const char *value) */ { assert (parameter); - + switch (parameter->type) { case PFLAG: @@ -516,7 +516,7 @@ set_parameter (param_t *parameter, const char *value) { long int data; char *endptr; - + data = strtol (value, &endptr, 0); if (*endptr != '\0' || endptr == value) warning ("Invalid value `%s' converted to %d", @@ -531,7 +531,7 @@ set_parameter (param_t *parameter, const char *value) { long int data; char *endptr; - + data = strtol (value, &endptr, 0); if (*endptr != '\0' || endptr == value) warning ("Invalid value `%s' converted to %d", @@ -543,7 +543,7 @@ set_parameter (param_t *parameter, const char *value) { double data; char *endptr; - + data = strtod (value, &endptr); if (*endptr != '\0' || endptr == value) warning ("Invalid value `%s' converted to %f", @@ -555,7 +555,7 @@ set_parameter (param_t *parameter, const char *value) case POSTR: parameter->value.s = value ? strdup (value) : NULL; break; - default: + default: error ("Invalid parameter type for %s", parameter->name); } } @@ -606,7 +606,7 @@ read_parameter_file (param_t *params, FILE *file) char *name; /* parameter name */ char *value; /* parameter value */ int pind; /* current argument number */ - + b = strchr (buffer, '#'); if (b != NULL) /* Strip comments. */ *b = '\0'; @@ -619,7 +619,7 @@ read_parameter_file (param_t *params, FILE *file) /* * Extract value of parameter */ - for (value = b + 1; ISSPACE (*value); value++) + for (value = b + 1; ISSPACE (*value); value++) ; /* Delete leading spaces */ for (b = value + strlen (value) - 1; b >= value && ISSPACE (*b); b--) @@ -628,7 +628,7 @@ read_parameter_file (param_t *params, FILE *file) /* * Extract parameter name */ - for (name = buffer; ISSPACE (*name); name++) + for (name = buffer; ISSPACE (*name); name++) ; /* Delete leading spaces */ for (b = name + strlen (name) - 1; b >= name && ISSPACE (*b); b--) @@ -637,21 +637,21 @@ read_parameter_file (param_t *params, FILE *file) pind = get_parameter_index (params, name); if (pind >= 0) set_parameter (¶ms [pind], value); - + n++; } -} +} -static void +static void usage (const param_t *params, const char *progname, const char *synopsis, const char *comment, const char *non_opt_string, bool_t show_all_options, const char *sys_file_name, const char *usr_file_name) /* * Generates and prints command line description from param_t struct 'params'. - * 'progname' is the name of the excecutable, 'synopsis' a short program + * 'progname' is the name of the executable, 'synopsis' a short program * description, and 'comment' some more advice. * If flag 'show_all_options' is set then print also options that are not * associated with a short option character. @@ -662,7 +662,7 @@ usage (const param_t *params, const char *progname, const char *synopsis, { int i; size_t width = 0; - + fprintf (stderr, "Usage: %s [OPTION]...%s\n", progname, non_opt_string ? non_opt_string : " "); if (synopsis != NULL) @@ -683,7 +683,7 @@ usage (const param_t *params, const char *progname, const char *synopsis, else width = MAX(width, (strlen (params [i].name)) - 1); } - + for (i = 0; params [i].name != NULL; i++) if (params [i].optchar != '\0' || show_all_options) { @@ -691,7 +691,7 @@ usage (const param_t *params, const char *progname, const char *synopsis, fprintf (stderr, " -%c, --", params [i].optchar); else fprintf (stderr, " --"); - + if (params [i].type == POSTR) fprintf (stderr, "%s=[%s]%-*s ", params [i].name, params [i].argument_name, @@ -707,7 +707,7 @@ usage (const param_t *params, const char *progname, const char *synopsis, (unsigned)(width + 1), params [i].name); fprintf (stderr, params [i].use, params [i].argument_name); - + switch (params [i].type) { case PFLAG: diff --git a/converter/other/fiasco/pnmtofiasco.c b/converter/other/fiasco/pnmtofiasco.c index e2656c71..9f63e7a1 100644 --- a/converter/other/fiasco/pnmtofiasco.c +++ b/converter/other/fiasco/pnmtofiasco.c @@ -2,11 +2,11 @@ * cwfa.c: FIASCO coder * * Written by: Ullrich Hafner - * + * * This file is part of FIASCO (Fractal Image And Sequence COdec) * Copyright (C) 1994-2000 Ullrich Hafner */ - + /* * $Date: 2000/10/28 17:39:29 $ * $Author: hafner $ @@ -33,7 +33,7 @@ /***************************************************************************** local variables - + *****************************************************************************/ static param_t params [] = @@ -107,7 +107,7 @@ static param_t params [] = "Set domain pool of r-lc to `%s'."}, {"coeff", "NAME", '\0', PSTR, {0}, "adaptive", "Set coefficients model to `%s'."}, - /* DELTA APPROXIATION */ + /* DELTA APPROXIMATION */ {"d-domain-pool", "NAME", '\0', PSTR, {0}, "rle", "Set domain pool of d-lc to `%s'."}, {"d-coeff", "NAME", '\0', PSTR, {0}, "adaptive", @@ -132,36 +132,36 @@ static param_t params [] = "Smooth frames by factor `%s' (0.5 - 1.0)"}, {"reference-frame", "FILE", '\0', PSTR, {0}, NULL, "Use PPM/PGM image `%s' as reference frame."}, -#endif +#endif {NULL, NULL, 0, PSTR, {0}, NULL, NULL } }; /***************************************************************************** prototypes - + *****************************************************************************/ -static void +static void checkargs (int argc, char **argv, char const ***image_template, char **wfa_name, float *quality, fiasco_c_options_t **options); /***************************************************************************** public code - + *****************************************************************************/ - -int + +int main (int argc, char **argv) { char const **image_template; /* template for input image files */ char *wfa_name; /* filename of output WFA */ float quality; /* approximation quality */ fiasco_c_options_t *options; /* additional coder options */ - + pnm_init(&argc, argv); - + init_error_handling (argv [0]); checkargs (argc, argv, &image_template, &wfa_name, &quality, &options); @@ -179,10 +179,10 @@ main (int argc, char **argv) /***************************************************************************** private code - + *****************************************************************************/ -static void +static void checkargs (int argc, char **argv, char const ***image_template, char **wfa_name, float *quality, fiasco_c_options_t **options) /* @@ -191,7 +191,7 @@ checkargs (int argc, char **argv, char const ***image_template, * Return value: * 1 on success * 0 otherwise - * + * * * Side effects: * 'image_template', 'wfa_name', 'quality' and 'options' are set. @@ -200,7 +200,7 @@ checkargs (int argc, char **argv, char const ***image_template, int optind; /* last processed commandline param */ char *image_name; /* filename given by option '--input_name' */ int i; /* counter */ - + optind = parseargs (params, argc, argv, "Compress raw PPM/PGM image FILEs to a FIASCO file.", "With no image FILE, or if FILE is -, " @@ -220,7 +220,7 @@ checkargs (int argc, char **argv, char const ***image_template, /* * Default options ... */ - image_name = (char *) parameter_value (params, "image-name"); + image_name = (char *) parameter_value (params, "image-name"); *wfa_name = (char *) parameter_value (params, "output-name"); for (;;) { @@ -233,7 +233,7 @@ checkargs (int argc, char **argv, char const ***image_template, ask_and_set (params, "quality", "Please enter coding quality 'q' ('q' > 0): "); } - + if (optind < argc) /* Additional command line param */ { if (image_name) @@ -260,7 +260,7 @@ checkargs (int argc, char **argv, char const ***image_template, */ { *options = fiasco_c_options_new (); - + { char *pattern = (char *) parameter_value (params, "pattern"); @@ -270,7 +270,7 @@ checkargs (int argc, char **argv, char const ***image_template, { char *basis = (char *) parameter_value (params, "basis-name"); - + if (!fiasco_c_options_set_basisfile (*options, basis)) error (fiasco_get_error_message ()); } @@ -278,41 +278,41 @@ checkargs (int argc, char **argv, char const ***image_template, { int n = * (int *) parameter_value (params, "chroma-dictionary"); float q = * (float *) parameter_value (params, "chroma-qfactor"); - + if (!fiasco_c_options_set_chroma_quality (*options, q, MAX(0, n))) error (fiasco_get_error_message ()); } - + { int n = *((int *) parameter_value (params, "smooth")); - + if (!fiasco_c_options_set_smoothing (*options, MAX(0, n))) error (fiasco_get_error_message ()); } - + { int n = * (int *) parameter_value (params, "progress-meter"); - fiasco_progress_e type = (n < 0) ? + fiasco_progress_e type = (n < 0) ? FIASCO_PROGRESS_NONE : (fiasco_progress_e) n; - + if (!fiasco_c_options_set_progress_meter (*options, type)) error (fiasco_get_error_message ()); } - + { char *t = (char *) parameter_value (params, "title"); - + if (strlen (t) > 0 && !fiasco_c_options_set_title (*options, t)) error (fiasco_get_error_message ()); } - + { char *c = (char *) parameter_value (params, "comment"); if (strlen (c) > 0 && !fiasco_c_options_set_comment (*options, c)) error (fiasco_get_error_message ()); } - + { fiasco_tiling_e method = FIASCO_TILING_VARIANCE_DSC; int e = * (int *) parameter_value (params, "tiling-exponent"); @@ -332,7 +332,7 @@ checkargs (int argc, char **argv, char const ***image_template, if (!fiasco_c_options_set_tiling (*options, method, MAX(0, e))) error (fiasco_get_error_message ()); } - + { int M/* = * (int *) parameter_value (params, "max-level") */; int m/* = * (int *) parameter_value (params, "min-level") */; @@ -354,7 +354,7 @@ checkargs (int argc, char **argv, char const ***image_template, m = 4; N = 5; } - + if (!fiasco_c_options_set_optimizations (*options, m, M, N, MAX(0, D), o)) error (fiasco_get_error_message ()); @@ -363,7 +363,7 @@ checkargs (int argc, char **argv, char const ***image_template, int M = * (int *) parameter_value (params, "max-level"); int m = * (int *) parameter_value (params, "min-level"); int p = * (int *) parameter_value (params, "prediction"); - + if (!fiasco_c_options_set_prediction (*options, p, MAX(0, m), MAX(0, M))) error (fiasco_get_error_message ()); @@ -374,7 +374,7 @@ checkargs (int argc, char **argv, char const ***image_template, int m = * (int *) parameter_value(params, "rpf-mantissa"); int dc_m = * (int *) parameter_value(params, "dc-rpf-mantissa"); fiasco_rpf_range_e range, dc_range; - + if (r < 1) range = FIASCO_RPF_RANGE_0_75; else if (r < 1.5) @@ -383,7 +383,7 @@ checkargs (int argc, char **argv, char const ***image_template, range = FIASCO_RPF_RANGE_1_50; else range = FIASCO_RPF_RANGE_2_00; - + if (dc_r < 1) dc_range = FIASCO_RPF_RANGE_0_75; else if (dc_r < 1.5) @@ -392,7 +392,7 @@ checkargs (int argc, char **argv, char const ***image_template, dc_range = FIASCO_RPF_RANGE_1_50; else dc_range = FIASCO_RPF_RANGE_2_00; - + if (!fiasco_c_options_set_quantization (*options, MAX(0, m), range, MAX(0, dc_m), dc_range)) @@ -402,4 +402,7 @@ checkargs (int argc, char **argv, char const ***image_template, if (fiasco_get_verbosity () == FIASCO_ULTIMATE_VERBOSITY) write_parameters (params, stderr); } -} +} + + + diff --git a/converter/other/gemtopnm.c b/converter/other/gemtopnm.c index d862213f..6bbfcc05 100644 --- a/converter/other/gemtopnm.c +++ b/converter/other/gemtopnm.c @@ -25,7 +25,7 @@ * * 92/07/11 Johann Haider * Changed to read from stdin if file is omitted - * Changed to handle line length not a multipe of 8 + * Changed to handle line length not a multiple of 8 * * 94/01/31 Andreas Schwab (schwab@ls5.informatik.uni-dortmund.de) * Changed to remove architecture dependency and conform to diff --git a/converter/other/giftopnm.c b/converter/other/giftopnm.c index e2d5923d..470c85b7 100644 --- a/converter/other/giftopnm.c +++ b/converter/other/giftopnm.c @@ -867,7 +867,7 @@ termStack(struct Stack * const stackP) { What we call 'dataWidth', others call the "minimum code size," which is a misnomer, because the minimum code size in a stream must be at least one - more than 'dataWidth', to accomodate the clear and end codes. + more than 'dataWidth', to accommmodate the clear and end codes. -----------------------------------------------------------------------------*/ static int const maxLzwCodeCt = (1<<MAX_LZW_BITS); @@ -1722,7 +1722,7 @@ readImageData(FILE * const ifP, pm_error("Invalid data width (bits for a true data item) " "in image data: %u. " "Maximum allowable code size in GIF is %u, " - "and a code has to be wide enough to accomodate both " + "and a code has to be wide enough to accommodate both " "all possible data values and two control codes", lzwDataWidth, MAX_LZW_BITS); diff --git a/converter/other/infotopam.c b/converter/other/infotopam.c index f2e35827..24c4d776 100644 --- a/converter/other/infotopam.c +++ b/converter/other/infotopam.c @@ -99,7 +99,7 @@ typedef struct IconInfo_ { typedef struct IconHeader_ { /* 20 bytes */ unsigned char pad0[4]; /* Padding (always seems to be zero) */ unsigned char iconWidth[2]; /* Width (usually equal to Gadget width) */ - unsigned char iconHeight[2]; + unsigned char iconHeight[2]; /* Height (usually equal to Gadget height -1) */ unsigned char bpp[2]; /* Bits per pixel */ unsigned char pad1[10]; /* ??? */ @@ -134,7 +134,7 @@ parseCommandLine( int argc, unsigned int numColorArgs, /* Number of arguments for overriding colors */ colorIdx, /* Color index */ i; /* Argument index */ - const char * const colors[4] = { + const char * const colors[4] = { /* Pixel colors based on original Amiga colors */ "#0055AA", /* Blue 0, 85, 170 */ "#FFFFFF", /* White 255, 255, 255 */ @@ -147,7 +147,7 @@ parseCommandLine( int argc, optStruct3 opt; unsigned int option_def_index; unsigned int numColorsSpec, forceColorSpec, selectedSpec; - + MALLOCARRAY_NOFAIL(option_def, 100); /* Set command line options */ @@ -166,7 +166,7 @@ parseCommandLine( int argc, infoP->depth = 0; infoP->icon = NULL; for ( colorIdx = 0; colorIdx < 4; colorIdx++ ) - infoP->colors[colorIdx] = + infoP->colors[colorIdx] = ppm_parsecolor( (char*) colors[colorIdx], 0xFF ); /* Initialize option structure */ @@ -258,7 +258,7 @@ getDiskObject( IconInfo * const infoP ) { -static void +static void getIconHeader(IconInfo * const infoP) { /*------------------------------------------------------------------------- * Get fields from icon header portion of info file @@ -277,7 +277,7 @@ getIconHeader(IconInfo * const infoP) { "Only read 0x%X of 0x%X bytes", infoP->name, (unsigned)bytesRead, (unsigned)sizeof(ihead)); - /* Get icon width, heigh, and bitplanes */ + /* Get icon width, height, and bitplanes */ infoP->width = (ihead.iconWidth[0] << 8) + ihead.iconWidth[1]; infoP->height = (ihead.iconHeight[0] << 8) + ihead.iconHeight[1]; infoP->depth = (ihead.bpp[0] << 8) + ihead.bpp[1]; @@ -299,7 +299,7 @@ addBitplane(unsigned char * const icon, -----------------------------------------------------------------------------*/ unsigned int i; unsigned int j; - + for (i = j = 0; i < bpsize; ++i, j += 8) { icon[j+0] = (icon[j+0] << 1) | ((buff[i] >> 0) & 0x01); icon[j+1] = (icon[j+1] << 1) | ((buff[i] >> 1) & 0x01); @@ -317,7 +317,7 @@ addBitplane(unsigned char * const icon, static void readIconData(FILE * const fileP, unsigned int const width, - unsigned int const height, + unsigned int const height, unsigned int const depth, unsigned char ** const iconP) { /*------------------------------------------------------------------------- @@ -330,7 +330,7 @@ readIconData(FILE * const fileP, unsigned int const bpsize = height * (((width + 15) / 16) * 2); /* Bitplane size in bytes, with padding */ - + MALLOCARRAY(buff, bpsize); if ( buff == NULL ) pm_error( "Cannot allocate memory to hold icon pixels" ); @@ -350,10 +350,10 @@ readIconData(FILE * const fileP, * points to the next byte in buff to fill in. When the inner * loop is done, bp points to the end of buff. * - * After reading in the entire bitplane, the second inner loop splits the - * eight pixels in each byte of the bitplane into eight separate bytes in - * the icon buffer. The existing contents of each byte in icon are left - * shifted by one to make room for the next bit. + * After reading in the entire bitplane, the second inner loop splits the + * eight pixels in each byte of the bitplane into eight separate bytes in + * the icon buffer. The existing contents of each byte in icon are left + * shifted by one to make room for the next bit. * * Each byte in the completed icon contains a value from 0 to * 2^depth (0 to 1 for depth of 1 and 0 to 3 for a depth of 3). @@ -363,7 +363,7 @@ readIconData(FILE * const fileP, /* Read bitplane into buffer */ int toread; /* Number of bytes left to read */ unsigned char * buffp; /* Buffer point for reading data */ - + toread = bpsize; buffp = &buff[0]; while (toread > 0) { @@ -378,7 +378,7 @@ readIconData(FILE * const fileP, pm_error("Premature end-of-file. " "Still have 0x%X bytes to read", toread ); - + toread -= bytesRead; buffp += bytesRead; } @@ -542,3 +542,6 @@ main( int argc, return 0; } + + + diff --git a/converter/other/jbig/libjbig/include/jbig_ar.h b/converter/other/jbig/libjbig/include/jbig_ar.h index d58b1ae0..ed5f2f86 100644 --- a/converter/other/jbig/libjbig/include/jbig_ar.h +++ b/converter/other/jbig/libjbig/include/jbig_ar.h @@ -14,7 +14,7 @@ struct jbg_arenc_state { unsigned char st[4096]; /* probability status for contexts, MSB = MPS */ - unsigned long c; /* register C: base of coding intervall, * + unsigned long c; /* register C: base of coding interval, * * layout as in Table 23 */ unsigned long a; /* register A: normalized size of coding interval */ long sc; /* number of buffered 0xff values that might still overflow */ @@ -30,7 +30,7 @@ struct jbg_arenc_state { struct jbg_ardec_state { unsigned char st[4096]; /* probability status for contexts, MSB = MPS */ - unsigned long c; /* register C: base of coding intervall, * + unsigned long c; /* register C: base of coding interval, * * layout as in Table 25 */ unsigned long a; /* register A: normalized size of coding interval */ unsigned char *pscd_ptr; /* pointer to next PSCD data byte */ diff --git a/converter/other/jbig/libjbig/jbig.c b/converter/other/jbig/libjbig/jbig.c index e8141070..cf24a93b 100644 --- a/converter/other/jbig/libjbig/jbig.c +++ b/converter/other/jbig/libjbig/jbig.c @@ -109,7 +109,7 @@ static const char *errmsg[] = { * The following three functions are the only places in this code, were * C library memory management functions are called. The whole JBIG * library has been designed in order to allow multi-threaded - * execution. No static or global variables are used, so all fuctions + * execution. No static or global variables are used, so all functions * are fully reentrant. However if you want to use this multi-thread * capability and your malloc, realloc and free are not reentrant, * then simply add the necessary semaphores or mutex primitives below. @@ -776,7 +776,7 @@ void jbg_enc_init(struct jbg_enc_state *s, unsigned long x, unsigned long y, assert(x > 0 && y > 0 && planes > 0 && planes < 256); s->xd = x; s->yd = y; - s->yd1 = y; /* This is the hight initially announced in BIH. To provoke + s->yd1 = y; /* This is the height initially announced in BIH. To provoke generation of NEWLEN for T.85 compatibility tests, overwrite with new value s->yd1 > s->yd */ s->planes = planes; @@ -1106,7 +1106,7 @@ static void encode_sde(struct jbg_enc_state *s, if (!at_determined && j >= s->mx && j < hx-2) { p = (line_h1 & 0x100) != 0; /* current pixel value */ c[0] += ((line_h2 & 0x4000) != 0) == p; /* default position */ - assert(!(((line_h2 >> 6) ^ line_h1) & 0x100) == + assert((!(((line_h2 >> 6) ^ line_h1) & 0x100)) == (((line_h2 & 0x4000) != 0) == p)); for (t = 5; t <= s->mx && t <= j; t++) { o = (j - t) - (j & ~7L); @@ -1151,7 +1151,7 @@ static void encode_sde(struct jbg_enc_state *s, if (!at_determined && j >= s->mx && j < hx-2) { p = (line_h1 & 0x100) != 0; /* current pixel value */ c[0] += ((line_h2 & 0x4000) != 0) == p; /* default position */ - assert(!(((line_h2 >> 6) ^ line_h1) & 0x100) == + assert((!(((line_h2 >> 6) ^ line_h1) & 0x100)) == (((line_h2 & 0x4000) != 0) == p)); for (t = 3; t <= s->mx && t <= j; t++) { o = (j - t) - (j & ~7L); @@ -3240,7 +3240,7 @@ static unsigned char *jbg_next_pscdms(unsigned char *p, size_t len) * depends on the fact that section 6.2.6.2 of ITU-T T.82 says that a * NEWLEN marker segment "could refer to a line in the immediately * preceding stripe due to an unexpected termination of the image or - * the use of only such stripe". ITU-T.85 explicitely suggests the + * the use of only such stripe". ITU-T.85 explicitly suggests the * use of this for fax machines that start transmission before having * encountered the end of the page. None of this is necessary for * BIEs produced by JBIG-KIT, which normally does not use NEWLEN. diff --git a/converter/other/jpeg2000/libjasper/base/jas_stream.c b/converter/other/jpeg2000/libjasper/base/jas_stream.c index 16c948eb..20336fd7 100644 --- a/converter/other/jpeg2000/libjasper/base/jas_stream.c +++ b/converter/other/jpeg2000/libjasper/base/jas_stream.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,10 +106,11 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ +#define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */ #define _SVID_SOURCE /* Make sure P_tmpdir is defined in GNU libc 2.0.7 (_XOPEN_SOURCE 500 does it in other libc's). pm_config.h defines TMPDIR as P_tmpdir @@ -276,7 +277,7 @@ jas_stream_t *jas_stream_memopen(char *buf, int bufsize) obj->len_ = 0; } obj->pos_ = 0; - + return stream; } @@ -409,7 +410,7 @@ jas_stream_t *jas_stream_tmpfile() */ jmp_buf jmpbuf; int rc; - + rc = setjmp(jmpbuf); if (rc == 0) { pm_setjmpbuf(&jmpbuf); diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h index 02c5553d..fe0e9616 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.h @@ -236,7 +236,7 @@ typedef struct { } jpc_dec_ccp_t; -/* Coding paramters. */ +/* Coding parameters. */ typedef struct { diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h index cfd754c9..86a8e59c 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.h @@ -145,7 +145,7 @@ * Coding parameters types. \******************************************************************************/ -/* Per-component coding paramters. */ +/* Per-component coding parameters. */ typedef struct { diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.c index 3f6122e3..54472481 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_mqenc.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ @@ -223,7 +223,7 @@ } /******************************************************************************\ -* Local function protoypes. +* Local function prototypes. \******************************************************************************/ static void jpc_mqenc_setbits(jpc_mqenc_t *mqenc); @@ -439,3 +439,6 @@ int jpc_mqenc_dump(jpc_mqenc_t *mqenc, FILE *out) (unsigned)(*mqenc->curctx)->qeval); return 0; } + + + diff --git a/converter/other/pamtogif.c b/converter/other/pamtogif.c index 8d432da1..9b833214 100644 --- a/converter/other/pamtogif.c +++ b/converter/other/pamtogif.c @@ -19,8 +19,6 @@ #define MAXCMAPSIZE 256 -static unsigned int const gifMaxval = 255; - static bool verbose; @@ -796,7 +794,7 @@ typedef struct { */ bool lzw; /* We're actually doing LZW compression. False means we follow - the algorithm enough tht an LZW decompressor will recover the + the algorithm enough that an LZW decompressor will recover the proper data, but always using one code per pixel, and therefore not effecting any compression and not using the LZW patent. */ diff --git a/converter/other/pamtopng.c b/converter/other/pamtopng.c index cfff38cb..3a987820 100644 --- a/converter/other/pamtopng.c +++ b/converter/other/pamtopng.c @@ -16,7 +16,7 @@ had become rather complex. This program is roughly 1/3 the size of pnmtopng.c that it replaces. - - In 1995, bandwith was limited and therefore filesize had to be kept + - In 1995, bandwid was limited and therefore filesize had to be kept small. The original program tried to optimize for that by applying many "clever tricks". Today that isn't an issue anymore, so gone are filters, palettes, etc. Also, image conversions were removed, @@ -278,7 +278,7 @@ colorTypeFromInputType(const struct pam * const pamP) { retval = PNG_COLOR_TYPE_GRAY_ALPHA; else pm_error("Input tuple type is GRAYSCALE_ALPHA, " - "but number of planes is %u instread of 2", + "but number of planes is %u instead of 2", pamP->depth); } else if (strneq(pamP->tuple_type, "GRAYSCALE", 9)) { if (pamP->depth == 1) diff --git a/converter/other/pamtosvg/fit.c b/converter/other/pamtosvg/fit.c index 5ba7a2f6..179b3bdf 100644 --- a/converter/other/pamtosvg/fit.c +++ b/converter/other/pamtosvg/fit.c @@ -67,7 +67,7 @@ real_to_int_coord(float_coord const real_coord) { int_coord.col = ROUND(real_coord.x); int_coord.row = ROUND(real_coord.y); - + return int_coord; } @@ -152,7 +152,7 @@ find_vectors(unsigned int const test_index, in->dx = in->dy = in->dz = 0.0; out->dx = out->dy = out->dz = 0.0; - + /* Add up the differences from p of the `corner_surround' points before p. */ @@ -160,7 +160,7 @@ find_vectors(unsigned int const test_index, n_done < corner_surround; i = O_PREV(outline, i), ++n_done) *in = Vadd(*in, IPsubtract(O_COORDINATE(outline, i), candidate)); - + /* And the points after p. */ for (i = O_NEXT (outline, test_index), n_done = 0; n_done < corner_surround; @@ -207,19 +207,19 @@ lookAheadForBetterCorner(pixel_outline_type const outline, bestCornerIndex = basePixelSeq; /* initial assumption */ bestCornerAngle = baseCornerAngle; /* initial assumption */ - + equallyGoodList = new_index_list(); - + q = basePixelSeq; i = basePixelSeq + 1; /* Start with the next pixel */ - + while (i < bestCornerIndex + cornerSurround && i < O_LENGTH(outline) && !at_exception_got_fatal(exceptionP)) { vector_type inVector, outVector; float cornerAngle; - + /* Check the angle. */ q = i % O_LENGTH(outline); @@ -446,7 +446,7 @@ filter(curve * const curveP, unsigned int iteration, thisPoint; float_coord prevNewPoint; - + /* We must have at least three points -- the previous one, the current one, and the next one. But if we don't have at least five, we will probably collapse the curve down onto a single point, which means @@ -460,26 +460,26 @@ filter(curve * const curveP, prevNewPoint.x = FLT_MAX; prevNewPoint.y = FLT_MAX; prevNewPoint.z = FLT_MAX; - + for (iteration = 0; iteration < fittingOptsP->filter_iterations; ++iteration) { curve * const newcurveP = copy_most_of_curve(curveP); bool collapsed; - + collapsed = false; /* initial value */ /* Keep the first point on the curve. */ if (offset) append_point(newcurveP, CURVE_POINT(curveP, 0)); - + for (thisPoint = offset; thisPoint < CURVE_LENGTH(curveP) - offset; ++thisPoint) { vector_type in, out, sum; float_coord newPoint; - + /* Calculate the vectors in and out, computed by looking at n points on either side of this_point. Experimental it was found that 2 is optimal. @@ -488,12 +488,12 @@ filter(curve * const curveP, signed int prev, prevprev; /* have to be signed */ unsigned int next, nextnext; float_coord candidate = CURVE_POINT(curveP, thisPoint); - + prev = CURVE_PREV(curveP, thisPoint); prevprev = CURVE_PREV(curveP, prev); next = CURVE_NEXT(curveP, thisPoint); nextnext = CURVE_NEXT(curveP, next); - + /* Add up the differences from p of the `surround' points before p. */ @@ -503,18 +503,18 @@ filter(curve * const curveP, if (prevprev >= 0) in = Vadd(in, Psubtract(CURVE_POINT(curveP, prevprev), candidate)); - + /* And the points after p. Don't use more points after p than we ended up with before it. */ out.dx = out.dy = out.dz = 0.0; - + out = Vadd(out, Psubtract(CURVE_POINT(curveP, next), candidate)); if (nextnext < CURVE_LENGTH(curveP)) out = Vadd(out, Psubtract(CURVE_POINT(curveP, nextnext), candidate)); - + /* Start with the old point. */ newPoint = candidate; sum = Vadd(in, out); @@ -528,13 +528,13 @@ filter(curve * const curveP, collapsed = true; break; } - + /* Put the newly computed point into a separate curve, so it doesn't affect future computation (on this iteration). */ append_point(newcurveP, prevNewPoint = newPoint); } - + if (collapsed) free_curve(newcurveP); else { @@ -543,7 +543,7 @@ filter(curve * const curveP, */ if (offset) append_point(newcurveP, LAST_CURVE_POINT(curveP)); - + /* Set the original curve to the newly filtered one, and go again. */ @@ -560,7 +560,7 @@ removeAdjacent(index_list_type * const cornerListP, pixel_outline_type const outline, fitting_opts_type * const fittingOptsP, at_exception_type * const exception) { - + /* We never want two corners next to each other, since the only way to fit such a ``curve'' would be with a straight line, which usually interrupts the continuity dreadfully. @@ -598,7 +598,7 @@ find_corners(pixel_outline_type const outline, establishCornerSearchLimits(outline, fittingOptsP, &firstPixelSeq, &lastPixelSeq); - + /* Consider each pixel on the outline in turn. */ for (p = firstPixelSeq; p <= lastPixelSeq;) { vector_type inVector, outVector; @@ -655,10 +655,10 @@ find_corners(pixel_outline_type const outline, && bestCornerIndex >= p) { unsigned int j; - + appendCorner(&cornerList, bestCornerIndex, outline, bestCornerAngle, '/'); - + for (j = 0; j < INDEX_LIST_LENGTH (equallyGoodList); ++j) appendCorner(&cornerList, GET_INDEX(equallyGoodList, j), outline, bestCornerAngle, '@'); @@ -675,7 +675,7 @@ find_corners(pixel_outline_type const outline, } removeAdjacent(&cornerList, outline, fittingOptsP, exceptionP); -cleanup: +cleanup: return cornerList; } @@ -696,12 +696,12 @@ makeOutlineOneCurve(pixel_outline_type const outline, for (pixelSeq = 0; pixelSeq < O_LENGTH(outline); ++pixelSeq) append_pixel(curveP, O_COORDINATE(outline, pixelSeq)); - + if (outline.open) CURVE_CYCLIC(curveP) = false; else CURVE_CYCLIC(curveP) = true; - + /* Make it a one-curve cycle */ NEXT_CURVE(curveP) = curveP; PREVIOUS_CURVE(curveP) = curveP; @@ -728,23 +728,23 @@ addCurveStartingAtCorner(pixel_outline_type const outline, Don't include beginning and ending slope information for that curve. -----------------------------------------------------------------------------*/ unsigned int const cornerPixelSeq = GET_INDEX(cornerList, cornerSeq); - + unsigned int lastPixelSeq; curve * curveP; unsigned int pixelSeq; - + if (cornerSeq + 1 >= cornerList.length) /* No more corners, so we go through the end of the outline. */ lastPixelSeq = O_LENGTH(outline) - 1; else /* Go through the next corner */ lastPixelSeq = GET_INDEX(cornerList, cornerSeq + 1); - + curveP = new_curve(); for (pixelSeq = cornerPixelSeq; pixelSeq <= lastPixelSeq; ++pixelSeq) append_pixel(curveP, O_COORDINATE(outline, pixelSeq)); - + append_curve(curveListP, curveP); { /* Add the new curve to the outline chain */ @@ -803,7 +803,7 @@ divideOutlineWithCorners(pixel_outline_type const outline, */ curve * curveP; unsigned int pixelSeq; - + curveP = new_curve(); for (pixelSeq = 0; pixelSeq <= GET_INDEX(cornerList, 0); ++pixelSeq) @@ -897,7 +897,7 @@ split_at_corners(pixel_outline_list_type const pixel_list, curve_list.open = outline.open; LOG1("#%u:", outlineSeq); - + /* If the outline does not have enough points, we can't do anything. The endpoints of the outlines are automatically corners. We need at least `corner_surround' more pixels on @@ -926,7 +926,7 @@ split_at_corners(pixel_outline_list_type const pixel_list, makeOutlineOneCurve(outline, &curve_list); else divideOutlineWithCorners(outline, corner_list, &curve_list); - + LOG1(" [%u].\n", corner_list.length); free_index_list(&corner_list); @@ -947,7 +947,7 @@ removeKnees(curve_list_type const curveList) { removing a point that should be a corner. -----------------------------------------------------------------------------*/ unsigned int curveSeq; - + LOG("\nRemoving knees:\n"); for (curveSeq = 0; curveSeq < curveList.length; ++curveSeq) { LOG1("#%u:", curveSeq); @@ -955,7 +955,7 @@ removeKnees(curve_list_type const curveList) { CURVE_LIST_CLOCKWISE(curveList)); } } - + static void @@ -966,7 +966,7 @@ computePointWeights(curve_list_type const curveList, unsigned int const height = distP->height; unsigned int curveSeq; - + for (curveSeq = 0; curveSeq < curveList.length; ++curveSeq) { unsigned pointSeq; curve_type const curve = CURVE_LIST_ELT(curveList, curveSeq); @@ -974,13 +974,13 @@ computePointWeights(curve_list_type const curveList, float_coord * const coordP = &CURVE_POINT(curve, pointSeq); unsigned int x = coordP->x; unsigned int y = height - (unsigned int)coordP->y - 1; - + float width, w; /* Each (x, y) is a point on the skeleton of the curve, which might be offset from the true centerline, where the width is maximal. Therefore, use as the local line width the - maximum distance over the neighborhood of (x, y). + maximum distance over the neighborhood of (x, y). */ width = distP->d[y][x]; /* initial value */ if (y - 1 >= 0) { @@ -1017,7 +1017,7 @@ computePointWeights(curve_list_type const curveList, static void filterCurves(curve_list_type const curveList, fitting_opts_type * const fittingOptsP) { - + unsigned int curveSeq; LOG("\nFiltering curves:\n"); @@ -1044,8 +1044,8 @@ logSplinesForCurve(unsigned int const curveSeq, if (log_file) print_spline(log_file, SPLINE_LIST_ELT(curveSplines, splineSeq)); } -} - +} + static void @@ -1212,7 +1212,7 @@ fitWithLine(curve * const curveP) { #define B3(t) CUBE (t) static spline_type -fitOneSpline(curve * const curveP, +fitOneSpline(curve * const curveP, vector_type const begSlope, vector_type const endSlope, at_exception_type * const exceptionP) { @@ -1311,7 +1311,7 @@ fitOneSpline(curve * const curveP, free(A); C.end.beg = C.beg.end; - + X_Cend_det = X.beg * C.end.end - X.end * C.beg.end; Cbeg_X_det = C.beg.beg * X.end - C.beg.end * X.beg; C_det = C.beg.beg * C.end.end - C.end.beg * C.beg.end; @@ -1328,7 +1328,7 @@ fitOneSpline(curve * const curveP, CONTROL2(spline) = Vadd_point(END_POINT(spline), Vmult_scalar(tang.end, alpha.end)); SPLINE_DEGREE(spline) = CUBICTYPE; - } + } return spline; } @@ -1341,7 +1341,7 @@ logSplineFit(spline_type const spline) { LOG(" fitted to line:\n"); else LOG(" fitted to spline:\n"); - + if (log_file) { LOG (" "); print_spline (log_file, spline); @@ -1458,7 +1458,7 @@ findTangent(curve * const curveP, means the previous curve in the outline chain for the slope at the start point ('toStartPoint' == true), the next curve otherwise. If *curveP is cyclic, then it is its own adjacent curve. - + It is important to compute an accurate approximation, because the control points that we eventually decide upon to fit the curve will be placed on the half-lines defined by the slopes and endpoints, and @@ -1478,7 +1478,7 @@ findTangent(curve * const curveP, vector_type const slopeAdj = findHalfTangent(!toStartPoint, adjacentCurveP, tangentSurround); - + LOG3("(adjacent curve half tangent (%.3f,%.3f,%.3f)) ", slopeAdj.dx, slopeAdj.dy, slopeAdj.dz); slope = Vmult_scalar(Vadd(slope, slopeAdj), 0.5); @@ -1487,7 +1487,7 @@ findTangent(curve * const curveP, } while (slope.dx == 0.0 && slope.dy == 0.0); *tangentP = slope; - + LOG3("(%.3f,%.3f,%.3f).\n", tangentP->dx, tangentP->dy, tangentP->dz); } @@ -1502,8 +1502,8 @@ findError(curve * const curveP, at_exception_type * const exceptionP) { /*---------------------------------------------------------------------------- Tell how good a fit 'spline' is for *curveP. - - Return the error (maximum Euclidian distance between a point on + + Return the error (maximum Euclidean distance between a point on *curveP and the corresponding point on 'spline') as *errorP and the sequence number of the point on the curve where the error is greatest as *worstPointP. @@ -1521,7 +1521,7 @@ findError(curve * const curveP, totalError = 0.0; /* initial value */ worstError = FLT_MIN; /* initial value */ worstPoint = 0; - + for (thisPoint = 0; thisPoint < CURVE_LENGTH(curveP); ++thisPoint) { float_coord const curvePoint = CURVE_POINT(curveP, thisPoint); float const t = CURVE_T(curveP, thisPoint); @@ -1608,7 +1608,7 @@ subdivideCurve(curve * const curveP, Split curve *curveP into two, at 'subdivisionIndex'. (Actually, leave *curveP alone, but return as *leftCurvePP and *rghtCurvePP two new curves that are the pieces). - + Return as *joinSlopeP what should be the slope where the subcurves join, i.e. the slope of the end of the left subcurve and of the start of the right subcurve. @@ -1670,7 +1670,7 @@ leftRightConcat(const spline_list_type * const leftSplineListP, of splines to that side of the curve. -----------------------------------------------------------------------------*/ spline_list_type * retval; - + retval = new_spline_list(); if (leftSplineListP == NULL) { @@ -1678,7 +1678,7 @@ leftRightConcat(const spline_list_type * const leftSplineListP, at_exception_warning(exceptionP, "Could not fit left spline list"); } else concat_spline_lists(retval, *leftSplineListP); - + if (rghtSplineListP == NULL) { LOG("Could not fit spline to right curve.\n"); at_exception_warning(exceptionP, "Could not fit right spline list"); @@ -1742,7 +1742,7 @@ divideAndFit(curve * const curveP, subcurve. */ spline_list_type * leftSplineListP; - + assert(subdivisionIndex > 1); assert(subdivisionIndex < CURVE_LENGTH(curveP)-1); subdivideCurve(curveP, subdivisionIndex, fittingOptsP, @@ -1792,18 +1792,18 @@ fitWithLeastSquares(curve * const curveP, /*---------------------------------------------------------------------------- The least squares method is well described in Schneider's thesis. Briefly, we try to fit the entire curve with one spline. If that - fails, we subdivide the curve. + fails, we subdivide the curve. -----------------------------------------------------------------------------*/ spline_list_type * retval; spline_type spline; - + LOG("\nFitting with least squares:\n"); - + /* Phoenix reduces the number of points with a "linear spline technique." But for fitting letterforms, that is inappropriate. We want all the points we can get. */ - + setInitialParameterValues(curveP); if (CURVE_CYCLIC(curveP) && CURVE_LENGTH(curveP) < 4) { @@ -1822,7 +1822,7 @@ fitWithLeastSquares(curve * const curveP, unsigned int worstPoint; logSplineFit(spline); - + findError(curveP, spline, &error, &worstPoint, exceptionP); assert(worstPoint < CURVE_LENGTH(curveP)); @@ -1873,7 +1873,7 @@ fitCurve(curve * const curveP, if (CURVE_LENGTH(curveP) < 2) { LOG("Tried to fit curve with fewer than two points"); - at_exception_warning(exceptionP, + at_exception_warning(exceptionP, "Tried to fit curve with less than two points"); fittedSplinesP = NULL; } else if (CURVE_LENGTH(curveP) < 4) @@ -1894,12 +1894,12 @@ fitCurves(curve_list_type const curveList, const fitting_opts_type * const fittingOptsP, spline_list_type * const splinesP, at_exception_type * const exceptionP) { - + spline_list_type curveListSplines; unsigned int curveSeq; curveListSplines = empty_spline_list(); - + curveListSplines.open = curveList.open; curveListSplines.clockwise = curveList.clockwise; curveListSplines.color = color; @@ -1932,13 +1932,13 @@ fitCurves(curve_list_type const curveList, at_exception_warning(exceptionP, "Could not fit curve"); } else { logSplinesForCurve(curveSeq, *curveSplinesP); - + /* After fitting, we may need to change some would-be lines back to curves, because they are in a list with other curves. */ change_bad_lines(curveSplinesP, fittingOptsP); - + concat_spline_lists(&curveListSplines, *curveSplinesP); free_spline_list(*curveSplinesP); free(curveSplinesP); @@ -1950,7 +1950,7 @@ fitCurves(curve_list_type const curveList, else *splinesP = curveListSplines; } - + static void @@ -1989,7 +1989,7 @@ fitCurveList(curve_list_type const curveList, if (dist != NULL) computePointWeights(curveList, fittingOptsP, dist); - + /* We filter all the curves in 'curveList' at once; otherwise, we would look at an unfiltered curve when computing tangents. */ @@ -2030,12 +2030,12 @@ fitCurvesToSplines(curve_list_array_type const curveArray, unsigned short const width, unsigned short const height, at_exception_type * const exception, - at_progress_func notifyProgress, + at_progress_func notifyProgress, void * const progressData, at_testcancel_func testCancel, void * const testcancelData, spline_list_array_type * const splineListArrayP) { - + unsigned splineListSeq; bool cancelled; spline_list_array_type splineListArray; @@ -2049,7 +2049,7 @@ fitCurvesToSplines(curve_list_array_type const curveArray, /* Set dummy values. Real value is set in upper context. */ splineListArray.width = width; splineListArray.height = height; - + for (splineListSeq = 0, cancelled = false; splineListSeq < CURVE_LIST_ARRAY_LENGTH(curveArray) && !at_exception_got_fatal(exception) && !cancelled; @@ -2057,7 +2057,7 @@ fitCurvesToSplines(curve_list_array_type const curveArray, curve_list_type const curveList = CURVE_LIST_ARRAY_ELT(curveArray, splineListSeq); - + spline_list_type curveSplineList; if (notifyProgress) @@ -2087,7 +2087,7 @@ fit_outlines_to_splines(pixel_outline_list_type const pixelOutlineList, unsigned short const width, unsigned short const height, at_exception_type * const exception, - at_progress_func notifyProgress, + at_progress_func notifyProgress, void * const progressData, at_testcancel_func testCancel, void * const testcancelData, @@ -2104,7 +2104,7 @@ fit_outlines_to_splines(pixel_outline_list_type const pixelOutlineList, testCancel, testcancelData, splineListArrayP); free_curve_list_array(&curveListArray, notifyProgress, progressData); - + flush_log_output(); } diff --git a/converter/other/pamtotiff.c b/converter/other/pamtotiff.c index 115b8b4a..1718c933 100644 --- a/converter/other/pamtotiff.c +++ b/converter/other/pamtotiff.c @@ -838,7 +838,7 @@ computeRasterParm(struct pam * const pamP, 2. Direct mode (specified with -output) We have the Tiff library write output to the specified file. As the Tiff - library requires taht it be be seekable and readable, we fail the program + library requires that it be be seekable and readable, we fail the program rather than ask the Tiff library to use the file if it does not meet these requirements. diff --git a/converter/other/pamtowinicon.c b/converter/other/pamtowinicon.c index 3d77d731..e8a9cc23 100644 --- a/converter/other/pamtowinicon.c +++ b/converter/other/pamtowinicon.c @@ -71,8 +71,6 @@ parseCommandLine(int argc, const char **argv, static bool verbose; -static unsigned char const pngHeader[] = PNG_HEADER; - struct Palette { diff --git a/converter/other/pbmtopgm.c b/converter/other/pbmtopgm.c index c35e1cbe..817fb5b3 100644 --- a/converter/other/pbmtopgm.c +++ b/converter/other/pbmtopgm.c @@ -6,6 +6,7 @@ #include <limits.h> #include "pm_c_util.h" +#include "nstring.h" #include "pgm.h" int @@ -17,26 +18,23 @@ main(int argc, char *argv[]) { int rows, cols; FILE *ifd; int row; - int width, height; + unsigned int width, height; const char * const usage = "<w> <h> [pbmfile]"; - + const char * error; /* error message of pm_string_to_uint */ pgm_init( &argc, argv ); if (argc > 4 || argc < 3) pm_usage(usage); - width = atoi(argv[1]); - height = atoi(argv[2]); + pm_string_to_uint(argv[1], &width, &error); + if (error) + pm_error("Invalid width argument: %s", error); + pm_string_to_uint(argv[2], &height, &error); + if (error) + pm_error("Invalid height argument: %s", error); if (width < 1 || height < 1) pm_error("width and height must be > 0"); - if (width > INT_MAX / height) - /* prevent overflow of "value" below */ - pm_error("sample area (%u columns %u rows) too large", - width, height); - - left=width/2; right=width-left; - up=height/2; down=height-up; if (argc == 4) ifd = pm_openr(argv[3]); @@ -44,13 +42,22 @@ main(int argc, char *argv[]) { ifd = stdin ; inbits = pbm_readpbm(ifd, &cols, &rows) ; - + if (width > cols) pm_error("You specified a sample width (%u columns) which is greater " "than the image width (%u columns)", height, rows); if (height > rows) pm_error("You specified a sample height (%u rows) which is greater " "than the image height (%u rows)", height, rows); + if (width > INT_MAX / height) + /* prevent overflow of "value" below */ + pm_error("sample area (%u columns %u rows) too large", + width, height); + + left = width / 2; right = width - left; + up = height / 2; down = height - up; + + outrow = pgm_allocrow(cols) ; maxval = MIN(PGM_OVERALLMAXVAL, width*height); @@ -65,7 +72,7 @@ main(int argc, char *argv[]) { int const l = (col > left) ? (col-left) : 0; int const r = (col+right < cols) ? (col+right) : cols; int const onh = width - (l-col+left) - (col+right-r); - int value; + int value; /* See above */ int x; value = 0; /* initial value */ @@ -73,10 +80,10 @@ main(int argc, char *argv[]) { for (x = l; x < r; ++x) { int y; for (y = t; y < b; ++y) - if (inbits[y][x] == PBM_WHITE) + if (inbits[y][x] == PBM_WHITE) ++value; } - outrow[col] = maxval*value/(onh*onv); + outrow[col] = (gray) ((double) maxval*value/(onh*onv)); } pgm_writepgmrow(stdout, outrow, cols, maxval, 0) ; } diff --git a/converter/other/pngtopam.c b/converter/other/pngtopam.c index 1023c6c6..9098154a 100644 --- a/converter/other/pngtopam.c +++ b/converter/other/pngtopam.c @@ -22,7 +22,7 @@ #include <math.h> #include <float.h> #include <png.h> -/* Becaues of a design error in png.h, you must not #include <setjmp.h> before +/* Because of a design error in png.h, you must not #include <setjmp.h> before <png.h>. If you do, png.h won't compile. */ #include <setjmp.h> diff --git a/converter/other/pnmtoddif.c b/converter/other/pnmtoddif.c index ac02e425..b7b942b3 100644 --- a/converter/other/pnmtoddif.c +++ b/converter/other/pnmtoddif.c @@ -53,7 +53,7 @@ typedef struct { #define CONS 1 /* "tag": Emit an ASN tag of the specified class and tag number. */ -/* This is used in conjuntion with the */ +/* This is used in conjunction with the */ /* wr_xxx routines that follow to construct the various ASN.1 entities. */ /* Writing each entity is a two-step process, where first the tag is */ /* written and then the length and value. */ @@ -263,7 +263,7 @@ write_header(FILE *file, imageparams *ip) tag(&p,CONTEXT,CONS, 0); ind(&p); /* Document Descriptor */ tag(&p,CONTEXT,PRIM, 0); wr_int(&p,1); /* Major Version */ tag(&p,CONTEXT,PRIM, 1); wr_int(&p,3); /* Minor Version */ - tag(&p,CONTEXT,PRIM, 2); wr_string(&p,"PBM+"); /* Product Indentifier */ + tag(&p,CONTEXT,PRIM, 2); wr_string(&p,"PBM+"); /* Product Identifier */ tag(&p,CONTEXT,CONS, 3); ind(&p); /* Product Name */ tag(&p,PRIVATE,PRIM, 9); emit_isolatin1(&p,"PBMPLUS Writer V1.0"); eoc(&p); diff --git a/converter/other/pnmtojpeg.c b/converter/other/pnmtojpeg.c index 44826245..e3458319 100644 --- a/converter/other/pnmtojpeg.c +++ b/converter/other/pnmtojpeg.c @@ -9,7 +9,7 @@ This program is by Bryan Henderson on 2000.03.06, but is derived with permission from the program cjpeg, which is in the Independent Jpeg Group's JPEG library package. Under the terms of that permission, - redistribution of this software is restricted as described in the + redistribution of this software is restricted as described in the file README.JPEG. Copyright (C) 1991-1998, Thomas G. Lane. @@ -84,12 +84,12 @@ struct cmdlineInfo { struct density density; }; -static void -interpret_maxmemory (const char * const maxmemory, - long int * const max_memory_to_use_p) { +static void +interpret_maxmemory (const char * const maxmemory, + long int * const max_memory_to_use_p) { long int lval; char ch; - + if (maxmemory == NULL) { *max_memory_to_use_p = -1; /* unspecified */ } else if (sscanf(maxmemory, "%ld%c", &lval, &ch) < 1) { @@ -119,9 +119,9 @@ interpret_restart(const char * const restart, long lval; char ch; unsigned int matches; - + matches= sscanf(restart, "%ld%c", &lval, &ch); - if (matches == 0) + if (matches == 0) pm_error("Invalid value for the --restart option : '%s'.", restart); else { @@ -160,7 +160,7 @@ interpret_density(const char * const densityString, int horiz, vert; unitName = malloc(strlen(densityString)+1); - + matched = sscanf(densityString, "%dx%d%s", &horiz, &vert, unitName); if (matched < 2) @@ -178,7 +178,7 @@ interpret_density(const char * const densityString, densityP->horiz = horiz; densityP->vert = vert; - if (matched < 3) + if (matched < 3) densityP->unit = DEN_UNSPECIFIED; else { if (streq(unitName, "dpi") || streq(unitName, "DPI")) @@ -235,7 +235,7 @@ parseCommandLine(const int argc, char ** argv, option_def_index = 0; /* incremented by OPTENTRY */ OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); - OPTENT3(0, "quality", OPT_UINT, &cmdlineP->quality, + OPTENT3(0, "quality", OPT_UINT, &cmdlineP->quality, &qualitySpec, 0); OPTENT3(0, "baseline", OPT_FLAG, NULL, &cmdlineP->force_baseline, 0); OPTENT3(0, "progressive", OPT_FLAG, NULL, &cmdlineP->progressive, 0); @@ -250,14 +250,14 @@ parseCommandLine(const int argc, char ** argv, OPTENT3(0, "qtables", OPT_STRING, &cmdlineP->qtablefile, NULL, 0); OPTENT3(0, "sample", OPT_STRING, &cmdlineP->sample, NULL, 0); OPTENT3(0, "scans", OPT_STRING, &cmdlineP->scans, NULL, 0); - OPTENT3(0, "smooth", OPT_UINT, &cmdlineP->smoothing_factor, + OPTENT3(0, "smooth", OPT_UINT, &cmdlineP->smoothing_factor, &smoothSpec, 0); OPTENT3(0, "optimize", OPT_FLAG, NULL, &cmdlineP->optimize, 0); OPTENT3(0, "optimise", OPT_FLAG, NULL, &cmdlineP->optimize, 0); OPTENT3(0, "restart", OPT_STRING, &restart, NULL, 0); OPTENT3(0, "comment", OPT_STRING, &cmdlineP->comment, NULL, 0); OPTENT3(0, "exif", OPT_STRING, &cmdlineP->exif_filespec, NULL, 0); - OPTENT3(0, "density", OPT_STRING, &density, + OPTENT3(0, "density", OPT_STRING, &density, &cmdlineP->density_spec, 0); /* Set the defaults */ @@ -295,7 +295,7 @@ parseCommandLine(const int argc, char ** argv, cmdlineP->input_filespec = strdup("-"); /* he wants stdin */ else if (argc_parse - 1 == 1) cmdlineP->input_filespec = strdup(argv_parse[1]); - else + else pm_error("Too many arguments. The only argument accepted " "is the input file specification."); if (dctval == NULL) @@ -314,15 +314,15 @@ parseCommandLine(const int argc, char ** argv, interpret_maxmemory(maxmemory, &cmdlineP->max_memory_to_use); interpret_restart(restart, &cmdlineP->restart_value, &cmdlineP->restart_unit); - if (cmdlineP->density_spec) + if (cmdlineP->density_spec) interpret_density(density, &cmdlineP->density); - + if (cmdlineP->smoothing_factor > 100) pm_error("Smoothing factor %d is greater than 100 (%%).", cmdlineP->smoothing_factor); if (streq(cmdlineP->input_filespec, "=") && - cmdlineP->exif_filespec && + cmdlineP->exif_filespec && streq(cmdlineP->exif_filespec, "-")) pm_error("Cannot have both input image and exif header be from " @@ -336,7 +336,7 @@ parseCommandLine(const int argc, char ** argv, static void report_compressor(const struct jpeg_compress_struct cinfo) { - + if (cinfo.scan_info == NULL) pm_message("No scan script is being used"); else { @@ -346,7 +346,7 @@ report_compressor(const struct jpeg_compress_struct cinfo) { for (i = 0; i < cinfo.num_scans; i++) { int j; pm_message(" Scan %2d: Ss=%2d Se=%2d Ah=%2d Al=%2d " - "%d components", + "%d components", i, cinfo.scan_info[i].Ss, cinfo.scan_info[i].Se, @@ -364,11 +364,11 @@ report_compressor(const struct jpeg_compress_struct cinfo) { static void -setup_jpeg_source_parameters(struct jpeg_compress_struct * const cinfoP, - int const width, int const height, +setup_jpeg_source_parameters(struct jpeg_compress_struct * const cinfoP, + int const width, int const height, int const format) { /*---------------------------------------------------------------------------- - Set up in the compressor descriptor *cinfoP the description of the + Set up in the compressor descriptor *cinfoP the description of the source image as required by the compressor. -----------------------------------------------------------------------------*/ @@ -379,7 +379,7 @@ setup_jpeg_source_parameters(struct jpeg_compress_struct * const cinfoP, cinfoP->input_components = 1; break; case PPM_TYPE: - cinfoP->in_color_space = JCS_RGB; + cinfoP->in_color_space = JCS_RGB; cinfoP->input_components = 3; break; default: @@ -391,7 +391,7 @@ setup_jpeg_source_parameters(struct jpeg_compress_struct * const cinfoP, static void -setup_jpeg_density(struct jpeg_compress_struct * const cinfoP, +setup_jpeg_density(struct jpeg_compress_struct * const cinfoP, struct density const density) { /*---------------------------------------------------------------------------- Set up in the compressor descriptor *cinfoP the density information @@ -402,7 +402,7 @@ setup_jpeg_density(struct jpeg_compress_struct * const cinfoP, case DEN_DOTS_PER_INCH: cinfoP->density_unit = 1; break; case DEN_DOTS_PER_CM: cinfoP->density_unit = 2; break; } - + cinfoP->X_density = density.horiz; cinfoP->Y_density = density.vert; } @@ -411,7 +411,7 @@ setup_jpeg_density(struct jpeg_compress_struct * const cinfoP, /*---------------------------------------------------------------------------- The functions below here are essentially the file rdswitch.c from - the JPEG library. They perform the functions specifed by the following + the JPEG library. They perform the functions specified by the following pnmtojpeg options: -qtables file Read quantization tables from text file @@ -426,7 +426,7 @@ text_getc (FILE * file) /* A comment/newline sequence is returned as a newline */ { register int ch; - + ch = getc(file); if (ch == '#') { do { @@ -454,12 +454,12 @@ readTextInteger(FILE * const fileP, -----------------------------------------------------------------------------*/ int ch; boolean retval; - + /* Skip any leading whitespace, detect EOF */ do { ch = text_getc(fileP); } while (isspace(ch)); - + if (!isdigit(ch)) retval = FALSE; else { @@ -554,7 +554,7 @@ read_scan_script(j_compress_ptr const cinfo, ncomps = 1; while (termchar == ' ') { if (ncomps >= MAX_COMPS_IN_SCAN) { - pm_message("Too many components in one scan in file %s", + pm_message("Too many components in one scan in file %s", filename); fclose(fp); return FALSE; @@ -603,10 +603,10 @@ read_scan_script(j_compress_ptr const cinfo, /* Stash completed scan list in cinfo structure. NOTE: in this program, JPOOL_IMAGE is the right lifetime for this data, but if you want to compress multiple images you'd - want JPOOL_PERMANENT. + want JPOOL_PERMANENT. */ const unsigned int scan_info_size = nscans * sizeof(jpeg_scan_info); - jpeg_scan_info * const scan_info = + jpeg_scan_info * const scan_info = (jpeg_scan_info *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, scan_info_size); @@ -656,7 +656,7 @@ read_quant_tables (j_compress_ptr cinfo, char * filename, if (tblno >= NUM_QUANT_TBLS) { pm_message("Too many tables in file %s", filename); error = TRUE; - } else { + } else { unsigned int table[DCTSIZE2]; unsigned int i; @@ -686,7 +686,7 @@ read_quant_tables (j_compress_ptr cinfo, char * filename, fclose(fp); retval = !error; } - + return retval; } @@ -717,7 +717,7 @@ set_quant_slots (j_compress_ptr cinfo, char *arg) return FALSE; } cinfo->comp_info[ci].quant_tbl_no = val; - while (*arg && *arg++ != ',') + while (*arg && *arg++ != ',') /* advance to next segment of arg string */ ; } else { @@ -747,7 +747,7 @@ set_sample_factors (j_compress_ptr cinfo, char *arg) if ((ch1 != 'x' && ch1 != 'X') || ch2 != ',') /* syntax check */ return FALSE; if (val1 <= 0 || val1 > 4) { - pm_message("Invalid sampling factor: %d. " + pm_message("Invalid sampling factor: %d. " "JPEG sampling factors must be 1..4", val1); return FALSE; } @@ -758,11 +758,11 @@ set_sample_factors (j_compress_ptr cinfo, char *arg) } cinfo->comp_info[ci].h_samp_factor = val1; cinfo->comp_info[ci].v_samp_factor = val2; - while (*arg && *arg++ != ',') + while (*arg && *arg++ != ',') /* advance to next segment of arg string */ ; } else { - /* reached end of parameter, set remaining components + /* reached end of parameter, set remaining components to 1x1 sampling */ cinfo->comp_info[ci].h_samp_factor = 1; cinfo->comp_info[ci].v_samp_factor = 1; @@ -776,13 +776,13 @@ set_sample_factors (j_compress_ptr cinfo, char *arg) static void setup_jpeg(struct jpeg_compress_struct * const cinfoP, struct jpeg_error_mgr * const jerrP, - struct cmdlineInfo const cmdline, + struct cmdlineInfo const cmdline, int const width, int const height, pixval const maxval, int const input_fmt, FILE * const output_file) { - + int quality; int q_scale_factor; @@ -794,14 +794,14 @@ setup_jpeg(struct jpeg_compress_struct * const cinfoP, jpeg_set_defaults(cinfoP); - cinfoP->data_precision = BITS_IN_JSAMPLE; + cinfoP->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */ cinfoP->image_width = (unsigned int) width; cinfoP->image_height = (unsigned int) height; cinfoP->arith_code = cmdline.arith_code; cinfoP->dct_method = cmdline.dct_method; - if (cmdline.trace_level == 0 && cmdline.verbose) + if (cmdline.trace_level == 0 && cmdline.verbose) cinfoP->err->trace_level = 1; else cinfoP->err->trace_level = cmdline.trace_level; if (cmdline.grayscale) @@ -822,26 +822,26 @@ setup_jpeg(struct jpeg_compress_struct * const cinfoP, quality = cmdline.quality; q_scale_factor = jpeg_quality_scaling(cmdline.quality); } - if (cmdline.smoothing_factor != -1) + if (cmdline.smoothing_factor != -1) cinfoP->smoothing_factor = cmdline.smoothing_factor; /* Set quantization tables for selected quality. */ /* Some or all may be overridden if user specified --qtables. */ jpeg_set_quality(cinfoP, quality, cmdline.force_baseline); - + if (cmdline.qtablefile != NULL) { if (! read_quant_tables(cinfoP, cmdline.qtablefile, - q_scale_factor, cmdline.force_baseline)) + q_scale_factor, cmdline.force_baseline)) pm_error("Can't use quantization table file '%s'.", cmdline.qtablefile); } - + if (cmdline.qslots != NULL) { if (! set_quant_slots(cinfoP, cmdline.qslots)) - pm_error("Bad quantization-table-selectors parameter string '%s'.", + pm_error("Bad quantization-table-selectors parameter string '%s'.", cmdline.qslots); } - + if (cmdline.sample != NULL) { if (! set_sample_factors(cinfoP, cmdline.sample)) pm_error("Bad sample-factors parameters string '%s'.", @@ -878,7 +878,7 @@ write_exif_header(struct jpeg_compress_struct * const cinfoP, /*---------------------------------------------------------------------------- Generate an APP1 marker in the JFIF output that is an Exif header. - The contents of the Exif header are in the file with filespec + The contents of the Exif header are in the file with filespec 'exif_filespec' (file spec and contents are not validated). exif_filespec = "-" means Standard Input. @@ -888,7 +888,7 @@ write_exif_header(struct jpeg_compress_struct * const cinfoP, -----------------------------------------------------------------------------*/ FILE * exif_file; unsigned short length; - + exif_file = pm_openr(exif_filespec); pm_readbigshort(exif_file, (short*)&length); @@ -900,7 +900,7 @@ write_exif_header(struct jpeg_compress_struct * const cinfoP, else { unsigned char * exif_data; size_t rc; - size_t const data_length = length - 2; + size_t const data_length = length - 2; /* Subtract 2 byte length field*/ assert(data_length > 0); @@ -917,16 +917,16 @@ write_exif_header(struct jpeg_compress_struct * const cinfoP, "%u bytes of data, read only %u", (unsigned)data_length, (unsigned)rc); - jpeg_write_marker(cinfoP, JPEG_APP0+1, + jpeg_write_marker(cinfoP, JPEG_APP0+1, (const JOCTET *) exif_data, data_length); free(exif_data); } - + pm_close(exif_file); } - + static void compute_rescaling_array(JSAMPLE ** const rescale_p, const pixval maxval, @@ -940,7 +940,7 @@ compute_rescaling_array(JSAMPLE ** const rescale_p, const pixval maxval, *rescale_p = (JSAMPLE *) (cinfo.mem->alloc_small) ((j_common_ptr) &cinfo, JPOOL_IMAGE, - (size_t) (((long) maxval + 1L) * + (size_t) (((long) maxval + 1L) * sizeof(JSAMPLE))); for (val = 0; val <= maxval; val++) { /* The multiplication here must be done in 32 bits to avoid overflow */ @@ -951,9 +951,9 @@ compute_rescaling_array(JSAMPLE ** const rescale_p, const pixval maxval, static void -translate_row(const pixel pnm_buffer[], - JSAMPLE jpeg_buffer[], - int const width, +translate_row(const pixel pnm_buffer[], + JSAMPLE jpeg_buffer[], + int const width, int const input_components, const JSAMPLE translate[]) { /*---------------------------------------------------------------------------- @@ -971,16 +971,16 @@ translate_row(const pixel pnm_buffer[], switch (input_components) { case 1: - for (column = 0; column < width; column++) + for (column = 0; column < width; column++) jpeg_buffer[column] = translate[(int)PNM_GET1(pnm_buffer[column])]; break; case 3: for (column = 0; column < width; column++) { - jpeg_buffer[column*3+0] = + jpeg_buffer[column*3+0] = translate[(int)PPM_GETR(pnm_buffer[column])]; - jpeg_buffer[column*3+1] = + jpeg_buffer[column*3+1] = translate[(int)PPM_GETG(pnm_buffer[column])]; - jpeg_buffer[column*3+2] = + jpeg_buffer[column*3+2] = translate[(int)PPM_GETB(pnm_buffer[column])]; } break; @@ -1000,17 +1000,17 @@ convert_scanlines(struct jpeg_compress_struct * const cinfo_p, int const input_fmt, JSAMPLE xlate_table[]){ /*---------------------------------------------------------------------------- - Read scan lines from the input file, which is already opened in the - netpbm library sense and ready for reading, and write them to the + Read scan lines from the input file, which is already opened in the + netpbm library sense and ready for reading, and write them to the output JPEG object. Translate the pnm sample values to JPEG sample values through the thable xlate_table[]. -----------------------------------------------------------------------------*/ - xel * pnm_buffer; + xel * pnm_buffer; /* contains the row of the input image currently being processed, in pnm_readpnmrow format */ JSAMPARRAY buffer; - /* Row 0 of this array contains the row of the output image currently + /* Row 0 of this array contains the row of the output image currently being processed, in JPEG compressor input format. The array only has that one row. */ @@ -1018,26 +1018,26 @@ convert_scanlines(struct jpeg_compress_struct * const cinfo_p, /* Allocate the libpnm output and compressor input buffers */ buffer = (*cinfo_p->mem->alloc_sarray) ((j_common_ptr) cinfo_p, JPOOL_IMAGE, - (unsigned int) cinfo_p->image_width * cinfo_p->input_components, + (unsigned int) cinfo_p->image_width * cinfo_p->input_components, (unsigned int) 1); - + pnm_buffer = pnm_allocrow(cinfo_p->image_width); while (cinfo_p->next_scanline < cinfo_p->image_height) { - if (cinfo_p->err->trace_level > 1) + if (cinfo_p->err->trace_level > 1) pm_message("Converting Row %d...", cinfo_p->next_scanline); - pnm_readpnmrow(input_file, pnm_buffer, cinfo_p->image_width, + pnm_readpnmrow(input_file, pnm_buffer, cinfo_p->image_width, maxval, input_fmt); - translate_row(pnm_buffer, buffer[0], + translate_row(pnm_buffer, buffer[0], cinfo_p->image_width, cinfo_p->input_components, xlate_table); jpeg_write_scanlines(cinfo_p, buffer, 1); - if (cinfo_p->err->trace_level > 1) + if (cinfo_p->err->trace_level > 1) pm_message("Done."); } pnm_freerow(pnm_buffer); - /* Don't worry about the compressor input buffer; it gets freed + /* Don't worry about the compressor input buffer; it gets freed automatically */ } @@ -1053,11 +1053,11 @@ main(int argc, struct jpeg_error_mgr jerr; FILE * input_file; FILE * output_file; - int height; + int height; /* height of the input image in rows, as specified by its header */ - int width; + int width; /* width of the input image in columns, as specified by its header */ - pixval maxval; + pixval maxval; /* maximum value of an input pixel component, as specified by header */ int input_fmt; /* The input format, as determined by its header. */ @@ -1081,7 +1081,7 @@ main(int argc, if (cmdline.verbose) { pm_message("Input file has format %c%c.\n" "It has %d rows of %d columns of pixels " - "with max sample value of %d.", + "with max sample value of %d.", (char) (input_fmt/256), (char) (input_fmt % 256), height, width, maxval); } @@ -1091,13 +1091,13 @@ main(int argc, compute_rescaling_array(&rescale, maxval, cinfo); - if (cmdline.comment) - jpeg_write_marker(&cinfo, JPEG_COM, (const JOCTET *) cmdline.comment, + if (cmdline.comment) + jpeg_write_marker(&cinfo, JPEG_COM, (const JOCTET *) cmdline.comment, strlen(cmdline.comment)); if (cmdline.exif_filespec) write_exif_header(&cinfo, cmdline.exif_filespec); - + /* Translate and copy over the actual scanlines */ convert_scanlines(&cinfo, input_file, maxval, input_fmt, rescale); @@ -1110,7 +1110,10 @@ main(int argc, pm_close(input_file); /* Program may have exited with non-zero completion code via - various function calls above. + various function calls above. */ return jerr.num_warnings > 0 ? EXIT_WARNING : EXIT_SUCCESS; } + + + diff --git a/converter/other/pnmtopalm/README b/converter/other/pnmtopalm/README index ebae9492..3a2cf18d 100644 --- a/converter/other/pnmtopalm/README +++ b/converter/other/pnmtopalm/README @@ -40,7 +40,7 @@ Usage: ppmtoTbmp [-2bit] [file.ppm] If the ppm file is not specified, one is read from stdin. The -2bit option produces a 2-bit bitmap instead of the normal 1-bit bitmap. The ppm must have at most 4 colors in it (for 2-bit) or at most 2 colors (for 1-bit). -Common invokations might be: +Common invocations might be: xbmtopbm icon.xbm | ppmquant -fs -map q2.map | ppmtoTbmp > tAIB03e8.bin giftopnm image.gif | ppmquant -fs -map q4.map | ppmtoTbmp -2bit > Tbmp0bb8.bin diff --git a/converter/other/pnmtopalm/pnmtopalm.c b/converter/other/pnmtopalm/pnmtopalm.c index 4f535d1a..9fc92790 100644 --- a/converter/other/pnmtopalm/pnmtopalm.c +++ b/converter/other/pnmtopalm/pnmtopalm.c @@ -787,7 +787,7 @@ computeRawRowNonDirect(const xel * const xelrow, sizeof(ColormapEntry), palmcolor_compare_colors); if (!foundEntryP) { - pm_error("INERNAL ERROR: " + pm_error("INTERNAL ERROR: " "Color (%u,%u,%u) not found in colormap, " "though it was supposedly there before", PPM_GETR(xelrow[col]), diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c index 60b8276b..b7bd6d07 100644 --- a/converter/other/pnmtopng.c +++ b/converter/other/pnmtopng.c @@ -424,7 +424,7 @@ parseCommandLine(int argc, const char ** argv, cmdlineP->palette = NULL; if (filterSpec && (nofilter + sub + up + avg + paeth > 0)) - pm_error("You may mot specify -filter with " + pm_error("You may not specify -filter with " "-nofilter, -sub, -up, -avg, or -paeth"); if (filterSpec) { diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c index de0dfd8d..45d856d0 100644 --- a/converter/other/pnmtops.c +++ b/converter/other/pnmtops.c @@ -125,8 +125,8 @@ static bool verbose; static void -parseDpi(const char * const dpiOpt, - unsigned int * const dpiXP, +parseDpi(const char * const dpiOpt, + unsigned int * const dpiXP, unsigned int * const dpiYP) { char *dpistr2; @@ -253,9 +253,9 @@ parseCommandLine(int argc, const char ** argv, OPTENT3(0, "showpage", OPT_FLAG, NULL, &showpage, 0); OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); OPTENT3(0, "debug", OPT_FLAG, NULL, &cmdlineP->debug, 0); - OPTENT3(0, "level", OPT_UINT, &cmdlineP->level, + OPTENT3(0, "level", OPT_UINT, &cmdlineP->level, &cmdlineP->levelSpec, 0); - + opt.opt_table = option_def; opt.short_allowed = FALSE; opt.allowNegNum = FALSE; @@ -293,7 +293,7 @@ parseCommandLine(int argc, const char ** argv, validateCompDimension(width, 72, "-width value"); validateCompDimension(height, 72, "-height value"); - + cmdlineP->width = width * 72; cmdlineP->height = height * 72; @@ -318,7 +318,7 @@ parseCommandLine(int argc, const char ** argv, if (cmdlineP->bitspersampleSpec) validateBps_1_2_4_8_12(cmdlineP->bitspersample); - if (argc-1 == 0) + if (argc-1 == 0) cmdlineP->inputFileName = "-"; else if (argc-1 != 1) pm_error("Program takes zero or one argument (filename). You " @@ -326,7 +326,7 @@ parseCommandLine(int argc, const char ** argv, else cmdlineP->inputFileName = argv[1]; - free(option_def); + free(option_def); } @@ -432,7 +432,7 @@ addToPidList(pid_t * const pidList, /*=========================================================================== The output encoder ===========================================================================*/ - + enum OutputType {AsciiHex, Ascii85}; typedef struct { @@ -453,7 +453,7 @@ bytesPerRow (unsigned int const cols, -----------------------------------------------------------------------------*/ unsigned int retval; - assert(bitsPerSample==1 || bitsPerSample==2 || bitsPerSample==4 || + assert(bitsPerSample==1 || bitsPerSample==2 || bitsPerSample==4 || bitsPerSample==8 || bitsPerSample==12); switch (bitsPerSample) { @@ -519,7 +519,7 @@ typedef void FilterFn(FILE * const ifP, /* This is a function that can be run in a separate process to do arbitrary modifications of the raster data stream. */ - + #ifndef NOFLATE @@ -545,7 +545,7 @@ initZlib(z_stream * const strmP) { static FilterFn flateFilter; -static void +static void flateFilter(FILE * const ifP, FILE * const ofP, OutputEncoder * const oeP) { @@ -600,12 +600,12 @@ flateFilter(FILE * const ifP, } while (flush != Z_FINISH); free(in); - free(out); + free(out); deflateEnd(&strm); fclose(ifP); fclose(ofP); #else - assert(false); /* filter is never used */ + assert(false); /* filter is never used */ #endif } @@ -687,7 +687,7 @@ asciiHexFilter(FILE * const ifP, unsigned int i; for (i = 0; i < readCt; ++i) { - int const item = inbuff[i]; + int const item = inbuff[i]; outbuff[i*2] = hexits[item >> 4]; outbuff[i*2+1] = hexits[item & 15]; } @@ -736,7 +736,7 @@ ascii85Filter(FILE * const ifP, ++outcount; count = 0; } else if (count == 4) { - outbuff[4] = value % 85 + 33; value/=85; + outbuff[4] = value % 85 + 33; value/=85; outbuff[3] = value % 85 + 33; value/=85; outbuff[2] = value % 85 + 33; value/=85; outbuff[1] = value % 85 + 33; @@ -745,7 +745,7 @@ ascii85Filter(FILE * const ifP, writeFileChar(outbuff, count + 1, "ASCII 85 filter", ofP); count = value = 0; - outcount += 5; + outcount += 5; } if (outcount > 75) { @@ -794,9 +794,9 @@ closeAllBut(int const saveFd0, 'saveFd1', and 'saveFd2'. This is helpful because even if this process doesn't touch other file - desriptors, its very existence will keep the files open. + descriptors, its very existence will keep the files open. -----------------------------------------------------------------------------*/ - + /* Unix provides no good way to do this; we just assume file descriptors above 9 are not used in this program; Caller must ensure that is true. */ @@ -829,15 +829,15 @@ spawnFilter(FILE * const ofP, pid_t rc; makePipe(pipeFd); - + rc = fork(); if (rc == (pid_t)-1) - pm_error("fork() of filter process failed. errno=%d (%s)", + pm_error("fork() of filter process failed. errno=%d (%s)", errno, strerror(errno)); else if (rc == 0) { /* This is the child process */ - + FILE * ifP; ifP = fdopen(pipeFd[0], "r"); @@ -892,11 +892,11 @@ addFilter(const char * const description, pid_t pid; spawnFilter(oldFeedFileP, filter, oeP, &newFeedFileP, &pid); - + if (verbose) pm_message("%s filter spawned: pid %u", description, (unsigned)pid); - + if (debug) { int const outFd = fileno(oldFeedFileP); int const supplyFd = fileno(newFeedFileP); @@ -971,7 +971,7 @@ waitForChildren(const pid_t * const pidList) { signal is the default), the process' children do not become zombies. Consequently, waitpid() always fails with ECHILD - but nonetheless waits for the child to exit. - + We expect the process not to have the action for SIGCHLD set that way. */ @@ -1004,9 +1004,9 @@ waitForChildren(const pid_t * const pidList) { static void -validateComputableBoundingBox(float const scols, +validateComputableBoundingBox(float const scols, float const srows, - float const llx, + float const llx, float const lly) { float const bbWidth = llx + scols + 0.5; @@ -1036,22 +1036,22 @@ warnUserRescaling(float const scale) { static void -computeImagePosition(int const dpiX, - int const dpiY, - int const icols, +computeImagePosition(int const dpiX, + int const dpiY, + int const icols, int const irows, bool const mustturn, bool const canturn, bool const center, - int const pagewid, - int const pagehgt, + int const pagewid, + int const pagehgt, float const requestedScale, float const imagewidth, float const imageheight, bool const equalpixels, float * const scolsP, float * const srowsP, - float * const llxP, + float * const llxP, float * const llyP, bool * const turnedP ) { /*---------------------------------------------------------------------------- @@ -1091,7 +1091,7 @@ computeImagePosition(int const dpiX, rotated if applicable */ bool shouldturn; /* The image fits the page better if we turn it */ - + if (icols > irows && pagehgt > pagewid) shouldturn = TRUE; else if (irows > icols && pagewid > pagehgt) @@ -1120,27 +1120,27 @@ computeImagePosition(int const dpiX, scale = (float) imagewidth/cols; else scale = MIN((float)imagewidth/cols, (float)imageheight/rows); - + *scolsP = cols*scale; *srowsP = rows*scale; } else { /* He didn't give us a bounding box for the image so figure out output image size from other inputs. */ - const int devpixX = dpiX / 72.0 + 0.5; - const int devpixY = dpiY / 72.0 + 0.5; + const int devpixX = dpiX / 72.0 + 0.5; + const int devpixY = dpiY / 72.0 + 0.5; /* How many device pixels make up 1/72 inch, rounded to nearest integer */ const float pixfacX = 72.0 / dpiX * devpixX; /* 1, approx. */ const float pixfacY = 72.0 / dpiY * devpixY; /* 1, approx. */ float scale; - scale = MIN(requestedScale, + scale = MIN(requestedScale, MIN((float)pagewid/cols, (float)pagehgt/rows)); *scolsP = scale * cols * pixfacX; *srowsP = scale * rows * pixfacY; - + if (scale != requestedScale) warnUserRescaling(scale); @@ -1236,7 +1236,7 @@ defineReadstring(bool const rle) { static void setupReadstringNative(bool const rle, bool const color, - unsigned int const icols, + unsigned int const icols, unsigned int const bitsPerSample) { /*---------------------------------------------------------------------------- Write to Standard Output statements to define /readstring and also @@ -1247,7 +1247,7 @@ setupReadstringNative(bool const rle, /* Size of row buffer, padded up to byte boundary. */ defineReadstring(rle); - + if (color) { printf("/rpicstr %d string def\n", bytesPerRow); printf("/gpicstr %d string def\n", bytesPerRow); @@ -1266,18 +1266,18 @@ putFilters(unsigned int const postscriptLevel, bool const color) { assert(postscriptLevel > 1); - + /* We say to decode flate, then rle, so Caller must ensure it encodes rel, then flate. */ if (ascii85) printf("/ASCII85Decode filter "); - else + else printf("/ASCIIHexDecode filter "); if (flate) printf("/FlateDecode filter "); - if (rle) + if (rle) printf("/RunLengthDecode filter "); } @@ -1311,7 +1311,7 @@ putSetup(unsigned int const dictSize, if (dictSize > 0) /* inputf {r,g,b,}pictsr readstring readrlestring rlestring */ printf("%u dict begin\n", dictSize); - + if (!psFilter) setupReadstringNative(rle, color, icols, bitsPerSample); @@ -1353,7 +1353,7 @@ putInitPsFilter(unsigned int const postscriptLevel, putFilters(postscriptLevel, rle, flate, ascii85, color); putImage(filterTrue, color); - + printf(" } exec"); } @@ -1365,7 +1365,7 @@ putInitReadstringNative(bool const color) { bool const filterFalse = FALSE; putReadstringNative(color); - + putImage(filterFalse, color); } @@ -1373,18 +1373,18 @@ putInitReadstringNative(bool const color) { static void putInit(unsigned int const postscriptLevel, - char const name[], - int const icols, - int const irows, - float const scols, + char const name[], + int const icols, + int const irows, + float const scols, float const srows, - float const llx, + float const llx, float const lly, int const bitsPerSample, - int const pagewid, + int const pagewid, int const pagehgt, - bool const color, - bool const turned, + bool const color, + bool const turned, bool const rle, bool const flate, bool const ascii85, @@ -1438,7 +1438,7 @@ putInit(unsigned int const postscriptLevel, static void -putEnd(bool const showpage, +putEnd(bool const showpage, bool const psFilter, bool const ascii85, unsigned int const dictSize, @@ -1486,7 +1486,7 @@ validateBpsRequest(unsigned int const bitsPerSampleReq, "-psfilter, the maximum is 8", bitsPerSampleReq); } - + static unsigned int bpsFromInput(unsigned int const bitsRequiredByMaxval, @@ -1553,7 +1553,7 @@ warnUserAboutReducedDepth(unsigned int const bitsGot, static void computeDepth(xelval const inputMaxval, - unsigned int const postscriptLevel, + unsigned int const postscriptLevel, bool const psFilter, unsigned int const bitsPerSampleReq, unsigned int * const bitsPerSampleP) { @@ -1584,7 +1584,7 @@ computeDepth(xelval const inputMaxval, "%u bits per sample, so maxval = %u", inputMaxval, *bitsPerSampleP, psMaxval); } -} +} @@ -1643,7 +1643,7 @@ ba_add(BitAccumulator * const baP, /*---------------------------------------------------------------------------- Combine bit sequences that do not fit into a byte. - Used when bitsPerSample =1, 2, 4. + Used when bitsPerSample =1, 2, 4. Logic also works for bitsPerSample = 8, 16. The accumulator, baP->value is unsigned int (usually 32 bits), but @@ -1725,7 +1725,7 @@ flushOutput(BitAccumulator * const baP, convertRowNative and convertRowPsFilter are the general converters. They are quite similar, the differences being: - (1) Native output separates the color planes: + (1) Native output separates the color planes: (RRR...RRR GGG...GGG BBB...BBB), whereas psFilter does not: (RGB RGB RGB RGB ......... RGB). @@ -1765,10 +1765,10 @@ convertRowPbm(struct pam * const pamP, static void -convertRowNative(struct pam * const pamP, - tuple * tuplerow, +convertRowNative(struct pam * const pamP, + tuple * tuplerow, unsigned int const bitsPerSample, - FILE * const fP) { + FILE * const fP) { unsigned int const psMaxval = pm_bitstomaxval(bitsPerSample); @@ -1795,7 +1795,7 @@ static void convertRowPsFilter(struct pam * const pamP, tuple * tuplerow, unsigned int const bitsPerSample, - FILE * const fP) { + FILE * const fP) { unsigned int const psMaxval = pm_bitstomaxval(bitsPerSample); @@ -1828,7 +1828,7 @@ selectPostscriptLevel(bool const levelIsGiven, bool const psFilter, unsigned int * const postscriptLevelP) { - unsigned int const maxPermittedLevel = + unsigned int const maxPermittedLevel = levelIsGiven ? levelGiven : UINT_MAX; unsigned int minPossibleLevel; @@ -1877,7 +1877,7 @@ convertRaster(struct pam * const inpamP, Read the raster described by *inpamP, and write a bit stream of samples to *fP. This stream has to be compressed and converted to text before it can be part of a Postscript program. - + 'psFilter' means to do the conversion using built in Postscript filters, as opposed to our own filters via /readstring. @@ -1897,7 +1897,7 @@ convertRaster(struct pam * const inpamP, } else { tuple *tuplerow; unsigned int row; - + tuplerow = pnm_allocpamrow(inpamP); for (row = 0; row < inpamP->height; ++row) { @@ -1920,31 +1920,31 @@ convertRaster(struct pam * const inpamP, pipe but this program's output, then we don't want it closed when the filter terminates because we'll need it to be open for the next image the program converts (with a whole new chain of filters). - - To prevent the progam output file from getting closed, we pass a + + To prevent the program output file from getting closed, we pass a duplicate of it to spawnFilters() and keep the original open. */ static void -convertPage(FILE * const ifP, - int const turnflag, - int const turnokflag, +convertPage(FILE * const ifP, + int const turnflag, + int const turnokflag, bool const psFilter, - bool const rle, + bool const rle, bool const flate, bool const ascii85, bool const setpage, bool const showpage, - bool const center, + bool const center, float const scale, - int const dpiX, - int const dpiY, - int const pagewid, + int const dpiX, + int const dpiY, + int const pagewid, int const pagehgt, - int const imagewidth, - int const imageheight, + int const imagewidth, + int const imageheight, bool const equalpixels, unsigned int const bitsPerSampleReq, char const name[], @@ -1952,7 +1952,7 @@ convertPage(FILE * const ifP, bool const vmreclaim, bool const levelIsGiven, unsigned int const levelGiven) { - + struct pam inpam; float scols, srows; float llx, lly; @@ -1960,7 +1960,7 @@ convertPage(FILE * const ifP, bool color; unsigned int postscriptLevel; unsigned int bitsPerSample; - unsigned int dictSize; + unsigned int dictSize; /* Size of Postscript dictionary we should define */ OutputEncoder oe; pid_t filterPidList[MAX_FILTER_CT + 1]; @@ -1974,19 +1974,19 @@ convertPage(FILE * const ifP, pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type)); validateCompDimension(inpam.width, 16, "Input image width"); - + if (!STRSEQ(inpam.tuple_type, PAM_PBM_TUPLETYPE) && !STRSEQ(inpam.tuple_type, PAM_PGM_TUPLETYPE) && !STRSEQ(inpam.tuple_type, PAM_PPM_TUPLETYPE)) pm_error("Unrecognized tuple type %s. This program accepts only " - "PBM, PGM, PPM, and equivalent PAM input images", + "PBM, PGM, PPM, and equivalent PAM input images", inpam.tuple_type); color = STRSEQ(inpam.tuple_type, PAM_PPM_TUPLETYPE); - - selectPostscriptLevel(levelIsGiven, levelGiven, color, + + selectPostscriptLevel(levelIsGiven, levelGiven, color, dict, flate, ascii85, psFilter, &postscriptLevel); - + if (color) pm_message("generating color Postscript program."); @@ -1996,16 +1996,16 @@ convertPage(FILE * const ifP, /* In positioning/scaling the image, we treat the input image as if it has a density of 72 pixels per inch. */ - computeImagePosition(dpiX, dpiY, inpam.width, inpam.height, + computeImagePosition(dpiX, dpiY, inpam.width, inpam.height, turnflag, turnokflag, center, pagewid, pagehgt, scale, imagewidth, imageheight, equalpixels, &scols, &srows, &llx, &lly, &turned); determineDictionaryRequirement(dict, psFilter, &dictSize); - - putInit(postscriptLevel, name, inpam.width, inpam.height, - scols, srows, llx, lly, bitsPerSample, + + putInit(postscriptLevel, name, inpam.width, inpam.height, + scols, srows, llx, lly, bitsPerSample, pagewid, pagehgt, color, turned, rle, flate, ascii85, setpage, psFilter, dictSize); @@ -2017,7 +2017,7 @@ convertPage(FILE * const ifP, /* spawnFilters() closes this. See FILE MANAGEMENT above */ spawnFilters(filterChainOfP, &oe, &feedFileP, filterPidList); - + convertRaster(&inpam, bitsPerSample, psFilter, feedFileP); fflush(feedFileP); @@ -2081,17 +2081,17 @@ main(int argc, const char * argv[]) { eof = FALSE; /* There is always at least one image */ for (imageSeq = 0; !eof; ++imageSeq) { - convertPage(ifP, cmdline.mustturn, cmdline.canturn, + convertPage(ifP, cmdline.mustturn, cmdline.canturn, cmdline.psfilter, - cmdline.rle, cmdline.flate, cmdline.ascii85, + cmdline.rle, cmdline.flate, cmdline.ascii85, cmdline.setpage, cmdline.showpage, cmdline.center, cmdline.scale, cmdline.dpiX, cmdline.dpiY, - cmdline.width, cmdline.height, - cmdline.imagewidth, cmdline.imageheight, + cmdline.width, cmdline.height, + cmdline.imagewidth, cmdline.imageheight, cmdline.equalpixels, cmdline.bitspersampleSpec ? cmdline.bitspersample : 0, - name, + name, cmdline.dict, cmdline.vmreclaim, cmdline.levelSpec, cmdline.level); pnm_nextimage(ifP, &eof); @@ -2121,7 +2121,7 @@ main(int argc, const char * argv[]) { ** wrzl@gup.uni-linz.ac.at. ** ** July 2011 afu -** row convertors rewritten, fast PBM-only row convertor added, +** row converters rewritten, fast PBM-only row converter added, ** rle compression slightly modified, flate compression added ** ascii85 output end added. ** diff --git a/converter/other/pstopnm.csh b/converter/other/pstopnm.csh index adde3e6f..22e3306d 100755 --- a/converter/other/pstopnm.csh +++ b/converter/other/pstopnm.csh @@ -5,7 +5,7 @@ # pstopnm will create as many files as the number of pages in # the Postscript document. The name of the files will be # psfile001.ppm, psfile002.ppm, etc. -# The ouput files will contain the area inside the BoundingBox. +# The output files will contain the area inside the BoundingBox. # If BoundingBox parameters are not found in the PostScript # document, default values are used. # diff --git a/converter/other/rlatopam.c b/converter/other/rlatopam.c index 703c4820..2c694bd4 100644 --- a/converter/other/rlatopam.c +++ b/converter/other/rlatopam.c @@ -85,9 +85,9 @@ read_header(FILE * const ifP, rlahdr hdr; size_t bytesRead; - + fseek (ifP, 0, SEEK_SET); - + /* Here we have a hack. The bytes in the file are almost in the same format as the compiler stores 'hdr' in memory. The only difference is that the compiler may store the integer values @@ -185,7 +185,7 @@ decode(unsigned char * const input, x = xFile; bytes = 0; useX = 0; - + while (x > 0) { int count; @@ -246,7 +246,7 @@ decode_row(FILE * const ifP, for (chan = 0; chan < outpam.depth; ++chan) { unsigned short length; size_t bytesRead; - + pm_readbigshortu(ifP, &length); if (length > width * 4) pm_error("Line too long - row %u, channel %u", row, chan); @@ -266,7 +266,7 @@ decode_row(FILE * const ifP, decode(newpos, rb + chan * 2 + 1, width, width, outpam.depth * 2); } else - decode(read_buffer, rb + chan, width, width, outpam.depth); + decode(read_buffer, rb + chan, width, width, outpam.depth); } } @@ -280,7 +280,7 @@ getHeaderInfo(FILE * const ifP, bool * const hasMatteP, unsigned int * const chanBitsP, short * const storageType) { - + rlahdr hdr; int width, height; @@ -350,7 +350,7 @@ readAndWriteRaster(FILE * const ifP, /* Hold one row of all image planes */ rowBuffer = calloc(1, width * outpamP->depth * 4); if (rowBuffer == NULL) - pm_error("Unable to allocate memor for row buffer."); + pm_error("Unable to allocate memory for row buffer."); tuplerow = pnm_allocpamrow(outpamP); @@ -403,7 +403,7 @@ main(int argc, outpam.height = height; outpam.width = width; outpam.depth = numChan + (has_matte ? 1 : 0); - outpam.maxval = (1 << (chanBits > 16 ? + outpam.maxval = (1 << (chanBits > 16 ? (9 + (chanBits - 1) % 8) /* Take top 2 of 3 or 4 bytes */ : chanBits)) - 1; @@ -427,8 +427,11 @@ main(int argc, readAndWriteRaster(ifP, &outpam); destroyOffsetArray(offsets); - + pm_close(ifP); - return 0; + return 0; } + + + diff --git a/converter/other/tifftopnm.c b/converter/other/tifftopnm.c index c1e7af85..05493e73 100644 --- a/converter/other/tifftopnm.c +++ b/converter/other/tifftopnm.c @@ -24,16 +24,16 @@ /* Design note: We have two different ways of converting from Tiff, as provided by the - Tiff library: + Tiff library: 1) decode the entire image into memory at once, using TIFFRGBAImageGet(), then convert to PNM and output row by row. - + 2) read, convert, and output one row at a time using TIFFReadScanline(). (1) is preferable because the Tiff library does more of the work, which - means it understands more of the Tiff format possibilities now and in - the future. Also, some compressed TIFF formats don't allow you to + means it understands more of the Tiff format possibilities now and in + the future. Also, some compressed TIFF formats don't allow you to extract an individual row. (2) uses far less memory, and because our code does more of the work, @@ -117,17 +117,17 @@ parseCommandLine(int argc, const char ** const argv, opt.allowNegNum = FALSE; option_def_index = 0; /* incremented by OPTENT3 */ - OPTENT3(0, "verbose", + OPTENT3(0, "verbose", OPT_FLAG, NULL, &cmdlineP->verbose, 0); - OPTENT3(0, "respectfillorder", + OPTENT3(0, "respectfillorder", OPT_FLAG, NULL, &cmdlineP->respectfillorder, 0); - OPTENT3(0, "byrow", + OPTENT3(0, "byrow", OPT_FLAG, NULL, &cmdlineP->byrow, 0); - OPTENT3(0, "orientraw", + OPTENT3(0, "orientraw", OPT_FLAG, NULL, &cmdlineP->orientraw, 0); - OPTENT3('h', "headerdump", + OPTENT3('h', "headerdump", OPT_FLAG, NULL, &cmdlineP->headerdump, 0); - OPTENT3(0, "alphaout", + OPTENT3(0, "alphaout", OPT_STRING, &cmdlineP->alphaFilename, &alphaSpec, 0); pm_optParseOptions3(&argc, (char **)argv, opt, sizeof(opt), 0); @@ -136,7 +136,7 @@ parseCommandLine(int argc, const char ** const argv, cmdlineP->inputFilename = strdup("-"); /* he wants stdin */ else if (argc - 1 == 1) cmdlineP->inputFilename = strdup(argv[1]); - else + else pm_error("Too many arguments. The only argument accepted " "is the input file name"); @@ -309,11 +309,11 @@ validatePlanarConfig(unsigned short const planarconfig, case PLANARCONFIG_CONTIG: break; case PLANARCONFIG_SEPARATE: - if (photomet != PHOTOMETRIC_RGB && + if (photomet != PHOTOMETRIC_RGB && photomet != PHOTOMETRIC_SEPARATED) pm_error("This program can handle separate planes only " "with RGB (PHOTOMETRIC tag = %u) or SEPARATED " - "(PHOTOMETRIC tag = %u) data. The input Tiff file " + "(PHOTOMETRIC tag = %u) data. The input Tiff file " "has PHOTOMETRIC tag = %hu.", PHOTOMETRIC_RGB, PHOTOMETRIC_SEPARATED, photomet); @@ -351,7 +351,7 @@ dumpHeader(const struct tiffDirInfo * const headerP) { -static void +static void readDirectory(TIFF * const tiffP, bool const headerdump, struct tiffDirInfo * const headerP) { @@ -409,11 +409,11 @@ readDirectory(TIFF * const tiffP, static void -readscanline(TIFF * const tif, +readscanline(TIFF * const tif, unsigned char * const scanbuf, - int const row, + int const row, int const plane, - unsigned int const cols, + unsigned int const cols, unsigned short const bps, unsigned short const spp, unsigned short const fillorder, @@ -433,7 +433,7 @@ readscanline(TIFF * const tif, /* The TIFFReadScanline man page doesn't tell the format of its 'buf' return value, but it is exactly the same format as the 'buf' - input to TIFFWriteScanline. The man page for that doesn't say + input to TIFFWriteScanline. The man page for that doesn't say anything either, but the source code for Pamtotiff contains a specification. */ @@ -446,7 +446,7 @@ readscanline(TIFF * const tif, row, plane); else if (bps == 8) { unsigned int sample; - for (sample = 0; sample < cols * spp; ++sample) + for (sample = 0; sample < cols * spp; ++sample) samplebuf[sample] = scanbuf[sample]; } else if (bps < 8) { /* Note that in this format, samples do not span bytes. Rather, @@ -458,26 +458,26 @@ readscanline(TIFF * const tif, unsigned int bitsleft; unsigned char * inP; - for (sample = 0, bitsleft = 8, inP = scanbuf; - sample < cols * spp; + for (sample = 0, bitsleft = 8, inP = scanbuf; + sample < cols * spp; ++sample) { if (bitsleft == 0) { - ++inP; + ++inP; bitsleft = 8; - } + } switch (fillorder) { case FILLORDER_MSB2LSB: - samplebuf[sample] = (*inP >> (bitsleft-bps)) & bpsmask; + samplebuf[sample] = (*inP >> (bitsleft-bps)) & bpsmask; break; case FILLORDER_LSB2MSB: samplebuf[sample] = (*inP >> (8-bitsleft)) & bpsmask; break; default: - pm_error("Internal error: invalid value for fillorder: %u", + pm_error("Internal error: invalid value for fillorder: %u", fillorder); } assert(bitsleft >= bps); - bitsleft -= bps; + bitsleft -= bps; if (bitsleft < bps) /* Don't count dregs at end of byte */ bitsleft = 0; @@ -490,7 +490,7 @@ readscanline(TIFF * const tif, none of our concern). The pre-9.17 code also presumed that the TIFF "FILLORDER" tag determined the order in which the bytes of each sample appear in a TIFF file, which is - contrary to the TIFF spec. + contrary to the TIFF spec. */ const uint16 * const scanbuf16 = (const uint16 *) scanbuf; unsigned int sample; @@ -500,10 +500,10 @@ readscanline(TIFF * const tif, } else if (bps == 32) { const uint32 * const scanbuf32 = (const uint32 *) scanbuf; unsigned int sample; - + for (sample = 0; sample < cols * spp; ++sample) samplebuf[sample] = scanbuf32[sample]; - } else + } else pm_error("Internal error: invalid bits per sample passed to " "readscanline()"); } @@ -528,7 +528,7 @@ pick_cmyk_pixel(unsigned int const samplebuf[], unsigned int const y = samplebuf[sampleCursor + 2]; unsigned int const k = samplebuf[sampleCursor + 3]; - /* The CMYK->RGB formula used by TIFFRGBAImageGet() in the TIFF + /* The CMYK->RGB formula used by TIFFRGBAImageGet() in the TIFF library is the following, (with some apparent confusion with the names of the yellow and magenta pigments being reversed). @@ -539,9 +539,9 @@ pick_cmyk_pixel(unsigned int const samplebuf[], We used that too before Netpbm 10.21 (March 2004). Now we use the inverse of what Pnmtotiffcmyk has always used, which - makes sense as follows: A microliter of black ink is simply a + makes sense as follows: A microliter of black ink is simply a substitute for a microliter each of cyan, magenta, and yellow ink. - Yellow ink removes blue light from what the white paper reflects. + Yellow ink removes blue light from what the white paper reflects. */ *redP = 255 - MIN(255, c + k); @@ -552,16 +552,16 @@ pick_cmyk_pixel(unsigned int const samplebuf[], static void -computeFillorder(unsigned short const fillorderTag, - unsigned short * const fillorderP, +computeFillorder(unsigned short const fillorderTag, + unsigned short * const fillorderP, bool const respectfillorder) { if (respectfillorder) { - if (fillorderTag != FILLORDER_MSB2LSB && + if (fillorderTag != FILLORDER_MSB2LSB && fillorderTag != FILLORDER_LSB2MSB) pm_error("Invalid value in Tiff input for the FILLORDER tag: %u. " "Valid values are %u and %u. Try omitting the " - "-respectfillorder option.", + "-respectfillorder option.", fillorderTag, FILLORDER_MSB2LSB, FILLORDER_LSB2MSB); else *fillorderP = fillorderTag; @@ -577,12 +577,12 @@ computeFillorder(unsigned short const fillorderTag, static void -analyzeImageType(TIFF * const tiffP, - unsigned short const bps, - unsigned short const spp, +analyzeImageType(TIFF * const tiffP, + unsigned short const bps, + unsigned short const spp, unsigned short const photomet, - xelval * const maxvalP, - int * const formatP, + xelval * const maxvalP, + int * const formatP, xel * const colormap, bool const headerdump, struct CmdlineInfo const cmdline) { @@ -604,13 +604,13 @@ analyzeImageType(TIFF * const tiffP, *maxvalP = pm_bitstomaxval(MIN(bps, 16)); if (headerdump) - pm_message("grayscale image, (min=%s) output maxval %u ", - photomet == PHOTOMETRIC_MINISBLACK ? + pm_message("grayscale image, (min=%s) output maxval %u ", + photomet == PHOTOMETRIC_MINISBLACK ? "black" : "white", *maxvalP ); break; - + case PHOTOMETRIC_PALETTE: { int fldPresent; int i; @@ -627,7 +627,7 @@ analyzeImageType(TIFF * const tiffP, "We understand only 1.", spp); fldPresent = TIFFGetField( - tiffP, TIFFTAG_COLORMAP, + tiffP, TIFFTAG_COLORMAP, &redcolormap, &greencolormap, &bluecolormap); if (!fldPresent) @@ -662,7 +662,7 @@ analyzeImageType(TIFF * const tiffP, if (fldPresent && inkset != INKSET_CMYK) pm_error("This color separation file uses an inkset (%d) " "we can't handle. We handle only CMYK.", inkset); - if (spp != 4) + if (spp != 4) pm_error("This CMYK color separation file is %d samples per " "pixel. " "We need 4 samples, though: C, M, Y, and K. ", @@ -673,7 +673,7 @@ analyzeImageType(TIFF * const tiffP, *maxvalP = (1 << bps) - 1; } break; - + case PHOTOMETRIC_RGB: if (headerdump) pm_message("RGB truecolor"); @@ -704,7 +704,7 @@ analyzeImageType(TIFF * const tiffP, case PHOTOMETRIC_LOGLUV: pm_error("don't know how to handle PHOTOMETRIC_LOGLUV"); - + default: pm_error("unknown photometric: %d", photomet); } @@ -778,7 +778,7 @@ static const char * xformNeeded(unsigned short const tiffOrientation) { /*---------------------------------------------------------------------------- Return the value of the Pamflip -xform option that causes Pamflip - to change a raster from orienation 'tiffOrientation' to Row 0 top, + to change a raster from orientation 'tiffOrientation' to Row 0 top, Column 0 left. -----------------------------------------------------------------------------*/ switch (tiffOrientation) { @@ -829,7 +829,7 @@ spawnWithInputPipe(const char * const shellCmd, *pidP = childPid; *pipePP = fdopen(fd[PIPE_WRITE], "w"); - + if (*pipePP == NULL) pm_asprintf(errorP,"Unable to create stream from pipe. " "fdopen() fails with errno=%d (%s)", @@ -858,7 +858,7 @@ spawnWithInputPipe(const char * const shellCmd, } } - + static void createFlipProcess(FILE * const outFileP, @@ -964,7 +964,7 @@ setupFlipper(pnmOut * const pnmOutP, pnmOutP->flipping = FALSE; *flipOkP = FALSE; *noflipOkP = TRUE; - } else { + } else { if (flipIfNeeded) { if (verbose) pm_message("Transforming raster with Pamflip"); @@ -979,7 +979,7 @@ setupFlipper(pnmOut * const pnmOutP, verbose, &pnmOutP->imagePipeP, &pnmOutP->imageFlipPid); - + /* The stream will flip it, so Caller must not: */ pnmOutP->flipping = TRUE; *flipOkP = FALSE; @@ -1081,22 +1081,22 @@ pnmOut_init(FILE * const imageoutFileP, } else { pnmOutP->inCols = pnmOutP->outCols; /* Caller will flip */ pnmOutP->inRows = pnmOutP->outRows; - } + } if (pnmOutP->flipping) { - if (pnmOutP->imagePipeP != NULL) + if (pnmOutP->imagePipeP != NULL) pnm_writepnminit(pnmOutP->imagePipeP, pnmOutP->inCols, pnmOutP->inRows, pnmOutP->maxval, pnmOutP->format, 0); - if (pnmOutP->alphaPipeP != NULL) + if (pnmOutP->alphaPipeP != NULL) pgm_writepgminit(pnmOutP->alphaPipeP, pnmOutP->inCols, pnmOutP->inRows, pnmOutP->alphaMaxval, 0); } else { - if (imageoutFileP != NULL) + if (imageoutFileP != NULL) pnm_writepnminit(pnmOutP->imageoutFileP, pnmOutP->outCols, pnmOutP->outRows, pnmOutP->maxval, pnmOutP->format, 0); - if (alphaFileP != NULL) + if (alphaFileP != NULL) pgm_writepgminit(pnmOutP->alphaFileP, pnmOutP->outCols, pnmOutP->outRows, pnmOutP->alphaMaxval, 0); @@ -1149,19 +1149,19 @@ pnmOut_writeRow(pnmOut * const pnmOutP, assert(cols == pnmOutP->inCols); if (pnmOutP->flipping) { - if (pnmOutP->imagePipeP != NULL) + if (pnmOutP->imagePipeP != NULL) pnm_writepnmrow(pnmOutP->imagePipeP, (xel *)imageRow, pnmOutP->inCols, pnmOutP->maxval, pnmOutP->format, 0); - if (pnmOutP->alphaPipeP != NULL) + if (pnmOutP->alphaPipeP != NULL) pgm_writepgmrow(pnmOutP->alphaPipeP, alphaRow, pnmOutP->inCols, pnmOutP->alphaMaxval, 0); } else { - if (pnmOutP->imageoutFileP != NULL) + if (pnmOutP->imageoutFileP != NULL) pnm_writepnmrow(pnmOutP->imageoutFileP, (xel *)imageRow, pnmOutP->outCols, pnmOutP->maxval, pnmOutP->format, 0); - if (pnmOutP->alphaFileP != NULL) + if (pnmOutP->alphaFileP != NULL) pgm_writepgmrow(pnmOutP->alphaFileP, alphaRow, pnmOutP->outCols, pnmOutP->alphaMaxval, 0); } @@ -1170,12 +1170,12 @@ pnmOut_writeRow(pnmOut * const pnmOutP, static void -convertRow(unsigned int const samplebuf[], - xel * const xelrow, +convertRow(unsigned int const samplebuf[], + xel * const xelrow, gray * const alpharow, - int const cols, - xelval const maxval, - unsigned short const photomet, + int const cols, + xelval const maxval, + unsigned short const photomet, unsigned short const spp, xel const colormap[]) { /*---------------------------------------------------------------------------- @@ -1191,7 +1191,7 @@ convertRow(unsigned int const samplebuf[], } } break; - + case PHOTOMETRIC_MINISWHITE: { int col; for (col = 0; col < cols; ++col) { @@ -1220,7 +1220,7 @@ convertRow(unsigned int const samplebuf[], for (col = 0, sample = 0; col < cols; ++col, sample+=spp) { xelval r, g, b; pick_cmyk_pixel(samplebuf, sample, &r, &b, &g); - + PPM_ASSIGN(xelrow[col], r, g, b); alpharow[col] = 0; } @@ -1238,7 +1238,7 @@ convertRow(unsigned int const samplebuf[], alpharow[col] = 0; } break; - } + } default: pm_error("internal error: unknown photometric in the picking " "routine: %d", photomet); @@ -1257,7 +1257,7 @@ scale32to16(unsigned int * const samplebuf, -----------------------------------------------------------------------------*/ unsigned int i; for (i = 0; i < cols * spp; ++i) - samplebuf[i] >>= 16; + samplebuf[i] >>= 16; } @@ -1288,39 +1288,39 @@ convertMultiPlaneRow(TIFF * const tif, unsigned int col; /* First, clear the buffer so we can add red, green, - and blue one at a time. + and blue one at a time. */ - for (col = 0; col < cols; ++col) + for (col = 0; col < cols; ++col) PPM_ASSIGN(xelrow[col], 0, 0, 0); /* Read the reds */ - readscanline(tif, scanbuf, row, 0, cols, bps, spp, fillorder, + readscanline(tif, scanbuf, row, 0, cols, bps, spp, fillorder, samplebuf); if (bps == 32) scale32to16(samplebuf, cols, spp); - for (col = 0; col < cols; ++col) + for (col = 0; col < cols; ++col) PPM_PUTR(xelrow[col], samplebuf[col]); - + /* Next the greens */ readscanline(tif, scanbuf, row, 1, cols, bps, spp, fillorder, samplebuf); if (bps == 32) scale32to16(samplebuf, cols, spp); - for (col = 0; col < cols; ++col) + for (col = 0; col < cols; ++col) PPM_PUTG( xelrow[col], samplebuf[col] ); - + /* And finally the blues */ readscanline(tif, scanbuf, row, 2, cols, bps, spp, fillorder, samplebuf); if (bps == 32) scale32to16(samplebuf, cols, spp); - for (col = 0; col < cols; ++col) + for (col = 0; col < cols; ++col) PPM_PUTB(xelrow[col], samplebuf[col]); /* Could there be an alpha plane? (We assume no. But if so, - here is where to read it) + here is where to read it) */ - for (col = 0; col < cols; ++col) + for (col = 0; col < cols; ++col) alpharow[col] = 0; } } @@ -1329,11 +1329,11 @@ convertMultiPlaneRow(TIFF * const tif, static void convertRasterByRows(pnmOut * const pnmOutP, - unsigned int const cols, + unsigned int const cols, unsigned int const rows, xelval const maxval, TIFF * const tif, - unsigned short const photomet, + unsigned short const photomet, unsigned short const planarconfig, unsigned short const bps, unsigned short const spp, @@ -1341,7 +1341,7 @@ convertRasterByRows(pnmOut * const pnmOutP, xel const colormap[], bool const verbose) { /*---------------------------------------------------------------------------- - With the TIFF header all processed (and relevant information from it in + With the TIFF header all processed (and relevant information from it in our arguments), write out the TIFF raster to the Netpbm output files as described by *pnmOutP. @@ -1359,7 +1359,7 @@ convertRasterByRows(pnmOut * const pnmOutP, xel * xelrow; /* The ppm-format row of the image row we are presently converting */ gray * alpharow; - /* The pgm-format row representing the alpha values for the image + /* The pgm-format row representing the alpha values for the image row we are presently converting. */ @@ -1383,13 +1383,13 @@ convertRasterByRows(pnmOut * const pnmOutP, /* Read one row of samples into samplebuf[] */ if (planarconfig == PLANARCONFIG_CONTIG) { - readscanline(tif, scanbuf, row, 0, cols, bps, spp, fillorder, + readscanline(tif, scanbuf, row, 0, cols, bps, spp, fillorder, samplebuf); if (bps == 32) scale32to16(samplebuf, cols, spp); - convertRow(samplebuf, xelrow, alpharow, cols, maxval, + convertRow(samplebuf, xelrow, alpharow, cols, maxval, photomet, spp, colormap); - } else + } else convertMultiPlaneRow(tif, xelrow, alpharow, cols, maxval, row, photomet, bps, spp, fillorder, scanbuf, samplebuf); @@ -1401,7 +1401,7 @@ convertRasterByRows(pnmOut * const pnmOutP, free(samplebuf); free(scanbuf); -} +} @@ -1416,7 +1416,7 @@ warnBrokenTiffLibrary(TIFF * const tiffP) { the transposition part, so e.g. it treats ORIENTATION_LEFTBOT as ORIENTATION_BOTLEFT. And because we provide a raster buffer dimensioned for the properly transposed image, the result is somewhat of a mess. - + We have found no documentation of the TIFF library that suggests this behavior is as designed, so it's probably not a good idea to work around it; it might be fixed somewhere. @@ -1452,8 +1452,8 @@ warnBrokenTiffLibrary(TIFF * const tiffP) { -static void -convertTiffRaster(uint32 * const raster, +static void +convertTiffRaster(uint32 * const raster, unsigned int const cols, unsigned int const rows, xelval const maxval, @@ -1465,11 +1465,11 @@ convertTiffRaster(uint32 * const raster, -----------------------------------------------------------------------------*/ xel * xelrow; /* The ppm-format row of the image row we are - presently converting + presently converting */ gray * alpharow; /* The pgm-format row representing the alpha values - for the image row we are presently converting. + for the image row we are presently converting. */ unsigned int row; @@ -1477,35 +1477,35 @@ convertTiffRaster(uint32 * const raster, alpharow = pgm_allocrow(cols); for (row = 0; row < rows; ++row) { - uint32 * rp; + uint32 * rp; /* Address of pixel in 'raster' we are presently converting */ unsigned int col; /* Start at beginning of row: */ rp = raster + (rows - row - 1) * cols; - + for (col = 0; col < cols; ++col) { uint32 const tiffPixel = *rp++; - - PPM_ASSIGN(xelrow[col], - TIFFGetR(tiffPixel) * maxval / 255, - TIFFGetG(tiffPixel) * maxval / 255, + + PPM_ASSIGN(xelrow[col], + TIFFGetR(tiffPixel) * maxval / 255, + TIFFGetG(tiffPixel) * maxval / 255, TIFFGetB(tiffPixel) * maxval / 255); alpharow[col] = TIFFGetA(tiffPixel) * maxval / 255 ; } pnmOut_writeRow(pnmOutP, cols, xelrow, alpharow); } - + pgm_freerow(alpharow); pnm_freerow(xelrow); -} +} enum convertDisp {CONV_DONE, CONV_OOM, CONV_UNABLE, - CONV_FAILED, + CONV_FAILED, CONV_NOTATTEMPTED}; @@ -1524,7 +1524,7 @@ convertRasterIntoProvidedMemory(pnmOut * const pnmOutP, TIFFRGBAImage img; char emsg[1024]; int ok; - + ok = TIFFRGBAImageBegin(&img, tif, stopOnErrorFalse, emsg); if (!ok) { pm_message("%s", emsg); @@ -1540,7 +1540,7 @@ convertRasterIntoProvidedMemory(pnmOut * const pnmOutP, *statusP = CONV_DONE; convertTiffRaster(raster, cols, rows, maxval, pnmOutP); } - } + } } @@ -1584,7 +1584,7 @@ convertRasterInMemory(pnmOut * const pnmOutP, unsigned int cols, rows; /* Dimensions of output image */ getTiffDimensions(tif, &cols, &rows); - if (rows == 0 || cols == 0) + if (rows == 0 || cols == 0) *statusP = CONV_DONE; else { if (cols > UINT_MAX/rows) { @@ -1608,7 +1608,7 @@ convertRasterInMemory(pnmOut * const pnmOutP, convertRasterIntoProvidedMemory( pnmOutP, cols, rows, maxval, tif, verbose, raster, statusP); - + free(raster); } } @@ -1653,7 +1653,7 @@ convertRaster(pnmOut * const pnmOutP, "and we already committed to in-memory " "conversion. To avoid this failure, " "use -byrow ."); - } + } convertRasterByRows( pnmOutP, tiffDir.width, tiffDir.height, maxval, tifP, tiffDir.photomet, tiffDir.planarconfig, @@ -1681,7 +1681,7 @@ convertImage(TIFF * const tifP, computeFillorder(tiffDir.fillorder, &fillorder, cmdline.respectfillorder); - analyzeImageType(tifP, tiffDir.bps, tiffDir.spp, tiffDir.photomet, + analyzeImageType(tifP, tiffDir.bps, tiffDir.spp, tiffDir.photomet, &maxval, &format, colormap, cmdline.headerdump, cmdline); reportOutputFormat(format); @@ -1704,7 +1704,7 @@ convertImage(TIFF * const tifP, static void convertIt(TIFF * const tifP, - FILE * const alphaFile, + FILE * const alphaFile, FILE * const imageoutFile, struct CmdlineInfo const cmdline) { @@ -1744,19 +1744,19 @@ main(int argc, const char * argv[]) { if (cmdline.alphaStdout) alphaFile = stdout; - else if (cmdline.alphaFilename == NULL) + else if (cmdline.alphaFilename == NULL) alphaFile = NULL; else alphaFile = pm_openw(cmdline.alphaFilename); - if (cmdline.alphaStdout) + if (cmdline.alphaStdout) imageoutFile = NULL; else imageoutFile = stdout; convertIt(tiffP, alphaFile, imageoutFile, cmdline); - if (imageoutFile != NULL) + if (imageoutFile != NULL) pm_close( imageoutFile ); if (alphaFile != NULL) pm_close( alphaFile ); @@ -1770,3 +1770,6 @@ main(int argc, const char * argv[]) { */ return 0; } + + + diff --git a/converter/other/winicontopam.c b/converter/other/winicontopam.c index 69ce7f05..2ddf56b1 100644 --- a/converter/other/winicontopam.c +++ b/converter/other/winicontopam.c @@ -246,7 +246,7 @@ readIconDir(struct File * const fP, MALLOCVAR(dirP); if (dirP == NULL) - pm_error("Could't allocate memory for Icon directory"); + pm_error("Couldn't allocate memory for Icon directory"); MALLOCARRAY(dirP->entries, head.count); diff --git a/converter/other/xwdtopnm.c b/converter/other/xwdtopnm.c index df3c7375..a74da341 100644 --- a/converter/other/xwdtopnm.c +++ b/converter/other/xwdtopnm.c @@ -70,14 +70,14 @@ static unsigned int pixel_count = 0; static int zero_bits(const unsigned long mask) { /*---------------------------------------------------------------------------- - Return the number of consective zero bits at the least significant end + Return the number of consecutive zero bits at the least significant end of the binary representation of 'mask'. E.g. if mask == 0x00fff800, we would return 11. -----------------------------------------------------------------------------*/ int i; unsigned long shifted_mask; - for (i=0, shifted_mask = mask; + for (i=0, shifted_mask = mask; i < sizeof(mask)*8 && (shifted_mask & 0x00000001) == 0; i++, shifted_mask >>= 1 ); return(i); @@ -122,9 +122,9 @@ parseCommandLine(int argc, char ** argv, else if (argc - 1 == 1) { if (streq(argv[1], "-")) cmdlineP->inputFilename = NULL; /* he wants stdin */ - else + else cmdlineP->inputFilename = strdup(argv[1]); - } else + } else pm_error("Too many arguments. The only argument accepted\n" "is the input file specification"); } @@ -132,17 +132,17 @@ parseCommandLine(int argc, char ** argv, static void -processX10Header(X10WDFileHeader * const h10P, +processX10Header(X10WDFileHeader * const h10P, FILE * const file, - int * const colsP, - int * const rowsP, - unsigned int * const padrightP, - xelval * const maxvalP, - enum visualclass * const visualclassP, - int * const formatP, - xel ** const colorsP, - int * const bits_per_pixelP, - int * const bits_per_itemP, + int * const colsP, + int * const rowsP, + unsigned int * const padrightP, + xelval * const maxvalP, + enum visualclass * const visualclassP, + int * const formatP, + xel ** const colorsP, + int * const bits_per_pixelP, + int * const bits_per_itemP, struct compMask * const compMaskP, enum byteorder * const byte_orderP, enum byteorder * const bit_orderP) { @@ -214,7 +214,7 @@ processX10Header(X10WDFileHeader * const h10P, (((h10P->pixmap_width + 15) / 16) * 16 - h10P->pixmap_width) * 8; *bits_per_itemP = 16; *bits_per_pixelP = 1; - } else if (h10P->window_ncolors == 0) { + } else if (h10P->window_ncolors == 0) { /* Must be grayscale. */ unsigned int i; *formatP = PGM_TYPE; @@ -314,8 +314,8 @@ dumpX11Cmap(unsigned int const nColors, unsigned int i; for (i = 0; i < nColors; ++i) - pm_message("Color %u r/g/b = %u/%u/%u", i, - x11colors[i].red, x11colors[i].green, + pm_message("Color %u r/g/b = %u/%u/%u", i, + x11colors[i].red, x11colors[i].green, x11colors[i].blue); } @@ -323,11 +323,11 @@ dumpX11Cmap(unsigned int const nColors, static void readX11Colormap(FILE * const file, - unsigned int const nColors, + unsigned int const nColors, bool const byteSwap, bool const cmapDump, X11XColor** const x11colorsP) { - + X11XColor * x11colors; int rc; @@ -362,7 +362,7 @@ colormapAllGray(const X11XColor* const x11colors, bool grayscale; grayscale = TRUE; /* initial assumption */ - for (i = 0; i < ncolors; ++i) + for (i = 0; i < ncolors; ++i) if (x11colors[i].red != x11colors[i].green || x11colors[i].green != x11colors[i].blue ) grayscale = FALSE; @@ -383,7 +383,7 @@ dumpX11Header(X11WDFileHeader * const h11P) { X11WDFileHeader * h11FixedP; fixH11ByteOrder(h11P, &h11FixedP); - + switch(h11FixedP->pixmap_format) { case XYBitmap: formatDesc = "XY bit map"; break; case XYPixmap: formatDesc = "XY pix map"; break; @@ -421,12 +421,12 @@ dumpX11Header(X11WDFileHeader * const h11P) { pm_message("X offset: %u", h11FixedP->xoffset); pm_message("byte order: %s (%u)", byteOrderDesc, h11FixedP->byte_order); pm_message("bitmap unit: %u", h11FixedP->bitmap_unit); - pm_message("bit order: %s (%u)", + pm_message("bit order: %s (%u)", bitOrderDesc, h11FixedP->bitmap_bit_order); pm_message("bitmap pad: %u", h11FixedP->bitmap_pad); pm_message("bits per pixel: %u", h11FixedP->bits_per_pixel); pm_message("bytes per line: %u", h11FixedP->bytes_per_line); - pm_message("visual class: %s (%u)", + pm_message("visual class: %s (%u)", visualClassDesc, h11FixedP->visual_class); pm_message("red mask: %08x", h11FixedP->red_mask); pm_message("green mask: %08x", h11FixedP->green_mask); @@ -517,18 +517,18 @@ computeComponentMasks(X11WDFileHeader * const h11P, static void -processX11Header(X11WDFileHeader * const h11P, +processX11Header(X11WDFileHeader * const h11P, FILE * const fileP, bool const cmapDump, - int * const colsP, - int * const rowsP, - unsigned int * const padrightP, - xelval * const maxvalP, - enum visualclass * const visualclassP, - int * const formatP, - xel ** const colorsP, - int * const bits_per_pixelP, - int * const bits_per_itemP, + int * const colsP, + int * const rowsP, + unsigned int * const padrightP, + xelval * const maxvalP, + enum visualclass * const visualclassP, + int * const formatP, + xel ** const colorsP, + int * const bits_per_pixelP, + int * const bits_per_itemP, struct compMask * const compMaskP, enum byteorder * const byte_orderP, enum byteorder * const bit_orderP) { @@ -538,12 +538,12 @@ processX11Header(X11WDFileHeader * const h11P, bool grayscale; bool const byte_swap = (h11P->file_version != X11WD_FILE_VERSION); X11WDFileHeader * h11FixedP; - + fixH11ByteOrder(h11P, &h11FixedP); if (byte_swap && verbose) pm_message("Header is different endianness from this machine."); - + for (i = 0; i < h11FixedP->header_size - sizeof(*h11FixedP); ++i) if (getc(fileP) == EOF) pm_error("couldn't read rest of X11 XWD file header"); @@ -649,7 +649,7 @@ processX11Header(X11WDFileHeader * const h11P, from a truecolor 32 bit window on a Hummingbird Exceed X server on Win32, and it had bitmap_unit = 8 and bitmap_pad = 32. - But Björn Eriksson in October 2003 had an xwd file from a 24 + But Bjorn Eriksson in October 2003 had an xwd file from a 24 bit-per-pixel direct color window that had bitmap_unit = 32 and bitmap_pad = 8. This was made by Xwd in Red Hat Xfree86 4.3.0-2. @@ -687,21 +687,21 @@ processX11Header(X11WDFileHeader * const h11P, computeComponentMasks(h11FixedP, compMaskP); free(h11FixedP); -} +} static void -getinit(FILE * const ifP, - int * const colsP, - int * const rowsP, - unsigned int * const padrightP, - xelval * const maxvalP, - enum visualclass * const visualclassP, - int * const formatP, +getinit(FILE * const ifP, + int * const colsP, + int * const rowsP, + unsigned int * const padrightP, + xelval * const maxvalP, + enum visualclass * const visualclassP, + int * const formatP, xel ** const colorsP, - int * const bits_per_pixelP, - int * const bits_per_itemP, + int * const bits_per_pixelP, + int * const bits_per_itemP, struct compMask * const compMaskP, enum byteorder * const byte_orderP, enum byteorder * const bit_orderP, @@ -729,13 +729,13 @@ getinit(FILE * const ifP, if ( sizeof(*h10P) > sizeof(*h11P) ) pm_error("ARGH! On this machine, X10 headers are larger than " "X11 headers!\n You will have to re-write xwdtopnm." ); - + /* We read an X10 header's worth of data from the file, then look at it to see if it looks like an X10 header. If so we process the X10 header. If not, but it looks like the beginning of an X11 header, we read more bytes so we have an X11 header's worth of data, then process the X11 header. Otherwise, we raise an - error. + error. */ rc = fread(&header[0], sizeof(*h10P), 1, ifP); @@ -744,23 +744,23 @@ getinit(FILE * const ifP, if (h10P->file_version == X10WD_FILE_VERSION || pm_bs_long(h10P->file_version) == X10WD_FILE_VERSION) { - + if (verbose) pm_message("Input is X10"); - processX10Header(h10P, ifP, colsP, rowsP, padrightP, maxvalP, - visualclassP, formatP, - colorsP, bits_per_pixelP, bits_per_itemP, + processX10Header(h10P, ifP, colsP, rowsP, padrightP, maxvalP, + visualclassP, formatP, + colorsP, bits_per_pixelP, bits_per_itemP, compMaskP, byte_orderP, bit_orderP); } else if (h11P->file_version == X11WD_FILE_VERSION || pm_bs_long(h11P->file_version) == X11WD_FILE_VERSION) { - + int rc; if (verbose) pm_message("Input is X11"); /* Read the balance of the X11 header */ - rc = fread(&header[sizeof(*h10P)], + rc = fread(&header[sizeof(*h10P)], sizeof(*h11P) - sizeof(*h10P), 1, ifP); if (rc != 1) pm_error("couldn't read end of X11 XWD file header"); @@ -769,9 +769,9 @@ getinit(FILE * const ifP, dumpX11Header(h11P); processX11Header(h11P, ifP, cmapDump, - colsP, rowsP, padrightP, maxvalP, - visualclassP, formatP, - colorsP, bits_per_pixelP, bits_per_itemP, + colsP, rowsP, padrightP, maxvalP, + visualclassP, formatP, + colorsP, bits_per_pixelP, bits_per_itemP, compMaskP, byte_orderP, bit_orderP); } else pm_error("unknown XWD file version: %u", h11P->file_version); @@ -786,7 +786,7 @@ getinit(FILE * const ifP, #define DEBUG_PIXEL_2 \ if (pixel_count < 4) \ - pm_message("item: %.8lx", row_controlP->item.l); + pm_message("item: %.8lx", row_controlP->item.l); #define DEBUG_PIXEL_3 \ @@ -876,10 +876,10 @@ static void pixelReader_init(pixelReader * const pixelReaderP, FILE * const fileP, int const bitsPerPixel, - int const bitsPerItem, + int const bitsPerItem, enum byteorder const byteOrder, enum byteorder const bitOrder) { - + pixelReaderP->fileP = fileP; pixelReaderP->bitsPerPixel = bitsPerPixel; pixelReaderP->bitsPerItem = bitsPerItem; @@ -887,7 +887,7 @@ pixelReader_init(pixelReader * const pixelReaderP, pixelReaderP->bitOrder = bitOrder; pixelReaderP->nBitsLeft = 0; -} +} @@ -950,10 +950,10 @@ readItem(pixelReader * const rdrP) { rdrP->nBitsLeft = 16; } break; - + case 32: { long item32; - + switch (rdrP->byteOrder) { case MSBFirst: pm_readbiglong(rdrP->fileP, &item32); @@ -979,7 +979,7 @@ static unsigned long const lsbmask[] = { of a bit string. -----------------------------------------------------------------------------*/ 0x00000000, - 0x00000001, 0x00000003, 0x00000007, 0x0000000f, + 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff, @@ -1002,7 +1002,7 @@ pixelReader_getbits(pixelReader * const rdrP, bits from the right end. The number of bits presently in the accumulator is rdrP->bitsPerPixel - nBitsStillNeeded . */ - + unsigned int nBitsStillNeeded; /* How many bits we still need to add to 'pixel', as we build it up to the @@ -1030,7 +1030,7 @@ pixelReader_getbits(pixelReader * const rdrP, /* The actual bits we take, in the 'nBitsToTake' low bits */ assert(nBitsToTake <= 32); - + if (rdrP->bitOrder == MSBFirst) { unsigned int const nBitsToLeave = rdrP->nBitsLeft - nBitsToTake; @@ -1039,7 +1039,7 @@ pixelReader_getbits(pixelReader * const rdrP, } else { bitsToTake = rdrP->itemBuffer & bitsToTakeMask; rdrP->itemBuffer >>= nBitsToTake; - } + } /* Shift the bits into the right end of the accumulator */ pixel <<= nBitsToTake; pixel |= bitsToTake; @@ -1064,7 +1064,7 @@ pixelReader_getpix(pixelReader * const rdrP) { We return an integer. It's the integer that the pixel represents as pure binary cipher, with the first bit the most significant bit. - + The basic unit of storage in the input file is an "item." An item can be 1, 2, or 4 bytes, and 'bits_per_item' tells us which. Each item can have its bytes stored in forward or reverse order, and @@ -1103,18 +1103,18 @@ pixelReader_getpix(pixelReader * const rdrP) { static void -reportInfo(int const cols, - int const rows, - unsigned int const padright, - xelval const maxval, +reportInfo(int const cols, + int const rows, + unsigned int const padright, + xelval const maxval, enum visualclass const visualclass, - int const format, + int const format, int const bits_per_pixel, - int const bits_per_item, + int const bits_per_item, struct compMask const compMask, - enum byteorder const byte_order, + enum byteorder const byte_order, enum byteorder const bit_order) { - + const char *visualclass_name; const char *byte_order_name; const char *bit_order_name; @@ -1140,7 +1140,7 @@ reportInfo(int const cols, pm_message("%d rows of %d columns with maxval %d", rows, cols, maxval); pm_message("padright=%u bits. visualclass = %s. format=%d (%c%c)", - padright, visualclass_name, + padright, visualclass_name, format, format/256, format%256); pm_message("bits_per_pixel=%d; bits_per_item=%d", bits_per_pixel, bits_per_item); @@ -1174,12 +1174,12 @@ warn16Bit(xelval const maxval) { -static void +static void convertRowSimpleIndex(pixelReader * const pixelReaderP, int const cols, const xel * const colors, xel * const xelrow) { - + unsigned int col; for (col = 0; col < cols; ++col) xelrow[col] = colors[pixelReader_getpix(pixelReaderP)]; @@ -1193,7 +1193,7 @@ convertRowDirect(pixelReader * const pixelReaderP, const xel * const colors, struct compMask const compMask, xel * const xelrow) { - + unsigned int col; for (col = 0; col < cols; ++col) { @@ -1204,11 +1204,11 @@ convertRowDirect(pixelReader * const pixelReaderP, unsigned int red_index, grn_index, blu_index; /* These are indices into the color map, unpacked from 'pixel'. */ - + pixel = pixelReader_getpix(pixelReaderP); red_index = (pixel & compMask.red) >> zero_bits(compMask.red); - grn_index = (pixel & compMask.grn) >> zero_bits(compMask.grn); + grn_index = (pixel & compMask.grn) >> zero_bits(compMask.grn); blu_index = (pixel & compMask.blu) >> zero_bits(compMask.blu); PPM_ASSIGN(xelrow[col], @@ -1263,12 +1263,12 @@ convertRowTrueColor(pixelReader * const pixelReaderP, static void convertRow(pixelReader * const pixelReaderP, FILE * const ofP, - unsigned int const padright, - int const cols, + unsigned int const padright, + int const cols, xelval const maxval, - int const format, + int const format, struct compMask const compMask, - const xel* const colors, + const xel* const colors, enum visualclass const visualclass) { /*---------------------------------------------------------------------------- Read a row from the XWD pixel input stream 'pixelReaderP' and write @@ -1290,20 +1290,20 @@ convertRow(pixelReader * const pixelReaderP, case PseudoColor: convertRowSimpleIndex(pixelReaderP, cols, colors, xelrow); break; - case DirectColor: + case DirectColor: convertRowDirect(pixelReaderP, cols, colors, compMask, xelrow); - + break; - case TrueColor: + case TrueColor: convertRowTrueColor(pixelReaderP, cols, maxval, colors, compMask, xelrow); break; - + default: pm_error("unknown visual class"); } pixelReader_getbits(pixelReaderP, padright); - + pnm_writepnmrow(ofP, xelrow, cols, maxval, format, 0); pnm_freerow(xelrow); } @@ -1321,11 +1321,11 @@ reportOutputType(int const format) { case PGM_TYPE: pm_message("writing PGM file"); break; - + case PPM_TYPE: pm_message("writing PPM file"); break; - + default: pm_error("shouldn't happen"); } @@ -1358,19 +1358,19 @@ main(int argc, char *argv[]) { debug = cmdline.debug; verbose = cmdline.verbose; - if (cmdline.inputFilename != NULL) + if (cmdline.inputFilename != NULL) ifP = pm_openr(cmdline.inputFilename); else ifP = stdin; - getinit(ifP, &cols, &rows, &padright, &maxval, &visualclass, &format, - &colors, &bitsPerPixel, &bitsPerItem, + getinit(ifP, &cols, &rows, &padright, &maxval, &visualclass, &format, + &colors, &bitsPerPixel, &bitsPerItem, &compMask, &byteOrder, &bitOrder, cmdline.headerdump, cmdline.cmapdump); warn16Bit(maxval); - - if (verbose) + + if (verbose) reportInfo(cols, rows, padright, maxval, visualclass, format, bitsPerPixel, bitsPerItem, compMask, byteOrder, bitOrder); @@ -1389,17 +1389,17 @@ main(int argc, char *argv[]) { } pixelReader_term(&pixelReader); - + pm_close(ifP); pm_close(stdout); - + return 0; } /* - This used to be the way we parsed a direct/true color pixel. I'm + This used to be the way we parsed a direct/true color pixel. I'm keeping it here in case we find out some application needs it this way. There doesn't seem to be any reason to do this hard-coded stuff when @@ -1411,7 +1411,7 @@ main(int argc, char *argv[]) { this whole switch thing. -Bryan 00.03.01 switch (bits_per_pixel) { - + case 16: PPM_ASSIGN( *xP, ( ( ul & red_mask ) >> 0 ), |