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 \
34 (NO_FINITE_RULE && NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
336 static void quant_table_increase(
struct Quant *q)
368 quant_update_limits(q, dLeft, dLeft, c, c);
416 quant_update_limits(q, dRight, dRight, c, c);
475 quant_table_increase(q);
521 while (pLeft < pRight) {
554 static int less_or_equal(
double x,
double y)
562 static int less(
double x,
double y)
596 int try, min_ind, max_ind;
598 int (*lower)(double, double);
611 return (
CELL)(dcellVal + .5);
612 return (
CELL)(dcellVal - .5);
624 if (dcellVal < q->fp_lookup.vals[0]) {
625 if (dcellVal <= q->fp_lookup.inf_dmin)
651 lower = less_or_equal;
657 try = (max_ind + min_ind) / 2;
665 try = (max_ind + min_ind) / 2;
675 if (dcellVal <= q->fp_lookup.inf_dmin)
720 for (i = 0; i < n; i++, dcell++)
740 for (i = 0; i < n; i++, fcell++)
747 static int double_comp(
const void *xx,
const void *yy)
780 if ((val >= p->
dLow) && (val <= p->
dHigh))
void G_free(void *)
Free allocated memory.
#define Rast_is_f_null_value(fcellVal)
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
void Rast_set_c_null_value(CELL *, int)
To set a number of CELL raster values to NULL.
#define Rast_is_d_null_value(dcellVal)
#define NO_LEFT_INFINITE_RULE
void Rast_quant_free(struct Quant *q)
Resets and frees allocated memory.
#define MAX_LOOKUP_TABLE_SIZE
#define NO_RIGHT_INFINITE_RULE
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.
int Rast_quant_is_truncate(const struct Quant *quant)
Returns whether or not quant rules are set to truncate map.
int Rast__quant_organize_fp_lookup(struct Quant *q)
Organized fp_lookup table.
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_perform_d(struct Quant *q, const DCELL *dcell, CELL *cell, int n)
Returns in "cell" the quantized CELL values.
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.
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_quant_perform_f(struct Quant *q, const FCELL *fcell, CELL *cell, int n)
Same as Rast_quant_perform_d(), except the type.
void Rast_quant_set_neg_infinite_rule(struct Quant *q, DCELL dLeft, CELL c)
Defines a rule for values "dLeft" and smaller.
void Rast_quant_truncate(struct Quant *quant)
Sets the quant rules to perform simple truncation on floats.
int Rast_quant_get_pos_infinite_rule(const struct Quant *q, DCELL *dRight, CELL *c)
Returns in "dRight" and "c" the rule values.
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_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_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 Rast_quant_reverse_rule_order(struct Quant *q)
Rreverses the order in which the qunatization rules are stored.
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_set_pos_infinite_rule(struct Quant *q, DCELL dRight, CELL c)
Defines a rule for values "dRight" and larger.
int Rast_quant_is_round(const struct Quant *quant)
Returns whether or not quant rules are set to round map.
struct Quant_table ** rules
struct Quant_table * table
struct Quant::@5 fp_lookup