diff options
Diffstat (limited to 'converter/other/fiasco/input')
-rw-r--r-- | converter/other/fiasco/input/basis.c | 33 | ||||
-rw-r--r-- | converter/other/fiasco/input/matrices.c | 80 | ||||
-rw-r--r-- | converter/other/fiasco/input/mc.c | 61 | ||||
-rw-r--r-- | converter/other/fiasco/input/nd.c | 31 | ||||
-rw-r--r-- | converter/other/fiasco/input/read.c | 89 | ||||
-rw-r--r-- | converter/other/fiasco/input/tree.c | 46 |
6 files changed, 177 insertions, 163 deletions
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) { |