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) 32 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 33 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 35 #define NO_LEFT_INFINITE_RULE (! q->infiniteLeftSet) 36 #define NO_RIGHT_INFINITE_RULE (! q->infiniteRightSet) 37 #define NO_FINITE_RULE (q->nofRules <= 0) 38 #define NO_EXPLICIT_RULE (NO_FINITE_RULE && \ 39 NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE) 130 sizeof(
DCELL), double_comp);
239 static void quant_set_limits(
struct Quant *q,
248 static void quant_update_limits(
struct Quant *q,
344 static void quant_table_increase(
struct Quant *q)
377 quant_update_limits(q, dLeft, dLeft, c, c);
425 quant_update_limits(q, dRight, dRight, c, c);
484 quant_table_increase(q);
510 quant_update_limits(q, dLow, dHigh, cLow, cHigh);
530 while (pLeft < pRight) {
563 static int less_or_equal(
double x,
double y)
571 static int less(
double x,
double y)
605 int try, min_ind, max_ind;
620 return (
CELL) (dcellVal + .5);
621 return (
CELL) (dcellVal - .5);
633 if (dcellVal < q->fp_lookup.vals[0]) {
634 if (dcellVal <= q->fp_lookup.inf_dmin)
660 lower = less_or_equal;
665 try = (max_ind + min_ind) / 2;
671 try = (max_ind + min_ind) / 2;
681 if (dcellVal <= q->fp_lookup.inf_dmin)
726 for (i = 0; i < n; i++, dcell++)
746 for (i = 0; i < n; i++, fcell++)
753 static int double_comp(
const void *xx,
const void *yy)
786 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.