24 static int double_comp(
const void *,
const void *);
27 #define MAX_LOOKUP_TABLE_SIZE 2048 28 #define NO_DATA (Rast_set_c_null_value (&tmp, 1), (CELL) tmp) 30 #define NO_LEFT_INFINITE_RULE (! q->infiniteLeftSet) 31 #define NO_RIGHT_INFINITE_RULE (! q->infiniteRightSet) 32 #define NO_FINITE_RULE (q->nofRules <= 0) 33 #define NO_EXPLICIT_RULE (NO_FINITE_RULE && \ 34 NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE) 125 sizeof(
DCELL), double_comp);
234 static void quant_set_limits(
struct Quant *q,
243 static void quant_update_limits(
struct Quant *q,
339 static void quant_table_increase(
struct Quant *q)
372 quant_update_limits(q, dLeft, dLeft, c, c);
420 quant_update_limits(q, dRight, dRight, c, c);
479 quant_table_increase(q);
505 quant_update_limits(q, dLow, dHigh, cLow, cHigh);
525 while (pLeft < pRight) {
558 static int less_or_equal(
double x,
double y)
566 static int less(
double x,
double y)
600 int try, min_ind, max_ind;
615 return (
CELL) (dcellVal + .5);
616 return (
CELL) (dcellVal - .5);
628 if (dcellVal < q->fp_lookup.vals[0]) {
629 if (dcellVal <= q->fp_lookup.inf_dmin)
655 lower = less_or_equal;
660 try = (max_ind + min_ind) / 2;
666 try = (max_ind + min_ind) / 2;
676 if (dcellVal <= q->fp_lookup.inf_dmin)
721 for (i = 0; i < n; i++, dcell++)
741 for (i = 0; i < n; i++, fcell++)
748 static int double_comp(
const void *xx,
const void *yy)
781 if ((val >= p->
dLow) && (val <= p->
dHigh))
int Rast_quant_get_neg_infinite_rule(const struct Quant *q, DCELL *dLeft, CELL *c)
Returns in "dLeft" and "c" the rule values.
void Rast_set_c_null_value(CELL *, int)
To set a number of CELL raster values to NULL.
void Rast_quant_truncate(struct Quant *quant)
Sets the quant rules to perform simple truncation on floats.
#define NO_RIGHT_INFINITE_RULE
#define Rast_is_d_null_value(dcellVal)
struct Quant::@5 fp_lookup
int Rast_quant_is_truncate(const struct Quant *quant)
Returns whether or not quant rules are set to truncate map.
void Rast_quant_clear(struct Quant *q)
Resets the number of defined rules and number of infinite rules to 0.
int Rast_quant_nof_rules(const struct Quant *q)
Returns the number of quantization rules defined.
void G_free(void *)
Free allocated memory.
#define NO_LEFT_INFINITE_RULE
int Rast_quant_get_pos_infinite_rule(const struct Quant *q, DCELL *dRight, CELL *c)
Returns in "dRight" and "c" the rule values.
#define Rast_is_f_null_value(fcellVal)
void Rast_quant_free(struct Quant *q)
Resets and frees allocated memory.
void Rast_quant_reverse_rule_order(struct Quant *q)
Rreverses the order in which the qunatization rules are stored.
void Rast_quant_add_rule(struct Quant *q, DCELL dLow, DCELL dHigh, CELL cLow, CELL cHigh)
Adds a new rule to the set of quantization rules.
CELL Rast_quant_get_cell_value(struct Quant *q, DCELL dcellVal)
Returns a CELL category for the floating-point value based on the quantization rules in q...
void Rast_quant_perform_f(struct Quant *q, const FCELL *fcell, CELL *cell, int n)
Same as Rast_quant_perform_d(), except the type.
struct Quant_table * Rast__quant_get_rule_for_d_raster_val(const struct Quant *q, DCELL val)
Returns quant rule which will be applied.
int Rast__quant_organize_fp_lookup(struct Quant *q)
Organized fp_lookup table.
struct Quant_table * table
#define MAX_LOOKUP_TABLE_SIZE
struct Quant_table ** rules
void Rast_quant_perform_d(struct Quant *q, const DCELL *dcell, CELL *cell, int n)
Returns in "cell" the quantized CELL values.
int Rast_quant_is_round(const struct Quant *quant)
Returns whether or not quant rules are set to round map.
void Rast_quant_init(struct Quant *quant)
Initialize the structure.
void Rast_quant_round(struct Quant *quant)
Sets the quant rules to perform simple rounding on floats.
void Rast_quant_set_pos_infinite_rule(struct Quant *q, DCELL dRight, CELL c)
Defines a rule for values "dRight" and larger.
void Rast_quant_get_ith_rule(const struct Quant *q, int i, DCELL *dLow, DCELL *dHigh, CELL *cLow, CELL *cHigh)
Returns the i'th quantization rule.
void Rast_quant_set_neg_infinite_rule(struct Quant *q, DCELL dLeft, CELL c)
Defines a rule for values "dLeft" and smaller.
int Rast_quant_get_limits(const struct Quant *q, DCELL *dMin, DCELL *dMax, CELL *cMin, CELL *cMax)
Returns the minimum and maximum cell and dcell values of all the ranges defined.
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.