kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Use std::vector for Genesys_Sensor::gamma_table
rodzic
555be1c3eb
commit
2dc4e5d1fc
|
@ -6739,11 +6739,6 @@ sane_close_impl(SANE_Handle handle)
|
|||
if (s->dev->force_calibration == 0)
|
||||
write_calibration (s->dev);
|
||||
|
||||
/* free allocated gamma tables */
|
||||
FREE_IFNOT_NULL (s->dev->sensor.gamma_table[0]);
|
||||
FREE_IFNOT_NULL (s->dev->sensor.gamma_table[1]);
|
||||
FREE_IFNOT_NULL (s->dev->sensor.gamma_table[2]);
|
||||
|
||||
s->dev->already_initialized = SANE_FALSE;
|
||||
|
||||
/* for an handful of bytes .. */
|
||||
|
@ -6881,15 +6876,15 @@ get_option_value (Genesys_Scanner * s, int option, void *val)
|
|||
table = (SANE_Word *) val;
|
||||
if (strcmp (s->val[OPT_COLOR_FILTER].s, "Red") == 0)
|
||||
{
|
||||
gamma = s->dev->sensor.gamma_table[GENESYS_RED];
|
||||
gamma = s->dev->sensor.gamma_table[GENESYS_RED].data();
|
||||
}
|
||||
else if (strcmp (s->val[OPT_COLOR_FILTER].s, "Blue") == 0)
|
||||
{
|
||||
gamma = s->dev->sensor.gamma_table[GENESYS_BLUE];
|
||||
gamma = s->dev->sensor.gamma_table[GENESYS_BLUE].data();
|
||||
}
|
||||
else
|
||||
{
|
||||
gamma = s->dev->sensor.gamma_table[GENESYS_GREEN];
|
||||
gamma = s->dev->sensor.gamma_table[GENESYS_GREEN].data();
|
||||
}
|
||||
for (i = 0; i < s->opt[option].size / sizeof (SANE_Word); i++)
|
||||
{
|
||||
|
@ -7219,17 +7214,17 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
|
|||
/* restore default sensor gamma table */
|
||||
/* currently there is no sensor's specific gamma table,
|
||||
* tables are built by sanei_genesys_create_gamma_table */
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.gamma_table[GENESYS_RED],
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.gamma_table[GENESYS_RED].data(),
|
||||
s->opt[OPT_GAMMA_VECTOR_R].size / sizeof (SANE_Word),
|
||||
s->opt[OPT_GAMMA_VECTOR_R].constraint.range->max,
|
||||
s->opt[OPT_GAMMA_VECTOR_R].constraint.range->max,
|
||||
s->dev->sensor.gamma[GENESYS_RED]);
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.gamma_table[GENESYS_GREEN],
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.gamma_table[GENESYS_GREEN].data(),
|
||||
s->opt[OPT_GAMMA_VECTOR_G].size / sizeof (SANE_Word),
|
||||
s->opt[OPT_GAMMA_VECTOR_G].constraint.range->max,
|
||||
s->opt[OPT_GAMMA_VECTOR_G].constraint.range->max,
|
||||
s->dev->sensor.gamma[GENESYS_GREEN]);
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.gamma_table[GENESYS_BLUE],
|
||||
sanei_genesys_create_gamma_table (s->dev->sensor.gamma_table[GENESYS_BLUE].data(),
|
||||
s->opt[OPT_GAMMA_VECTOR_B].size / sizeof (SANE_Word),
|
||||
s->opt[OPT_GAMMA_VECTOR_B].constraint.range->max,
|
||||
s->opt[OPT_GAMMA_VECTOR_B].constraint.range->max,
|
||||
|
|
|
@ -274,7 +274,6 @@ void genesys_init_sensor_tables()
|
|||
0x13, 0x17, 0x03, 0x07, 0x0b, 0x0f, 0x23, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -297,7 +296,6 @@ void genesys_init_sensor_tables()
|
|||
0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -320,7 +318,6 @@ void genesys_init_sensor_tables()
|
|||
0x17, 0x03, 0x07, 0x0b, 0x0f, 0x13, 0x03, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -343,7 +340,6 @@ void genesys_init_sensor_tables()
|
|||
0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x23, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
sensor.gamma = {2.38, 2.35, 2.34};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -366,7 +362,6 @@ void genesys_init_sensor_tables()
|
|||
0x0b, 0x0f, 0x13, 0x17, 0x03, 0x07, 0x63, 0x00, 0xc1, 0x00, 0x0e, 0x00, 0x00
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -389,7 +384,6 @@ void genesys_init_sensor_tables()
|
|||
0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0xc1, 0x06, 0x0b, 0x10, 0x16
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -412,7 +406,6 @@ void genesys_init_sensor_tables()
|
|||
0x05, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x03, 0x40, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -435,7 +428,6 @@ void genesys_init_sensor_tables()
|
|||
0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0xc1, 0x06, 0x0b, 0x10, 0x16
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -458,7 +450,6 @@ void genesys_init_sensor_tables()
|
|||
0x0f, 0x13, 0x17, 0x03, 0x07, 0x0b, 0x83, 0x00, 0x15, 0x05, 0x0a, 0x0f, 0x00
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -481,7 +472,6 @@ void genesys_init_sensor_tables()
|
|||
0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x54, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -504,7 +494,6 @@ void genesys_init_sensor_tables()
|
|||
0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x54, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -527,7 +516,6 @@ void genesys_init_sensor_tables()
|
|||
0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x54, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -550,7 +538,6 @@ void genesys_init_sensor_tables()
|
|||
0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x54, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -573,7 +560,6 @@ void genesys_init_sensor_tables()
|
|||
0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x54, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -596,7 +582,6 @@ void genesys_init_sensor_tables()
|
|||
0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xe1, 0x55, 0x00, 0x00, 0x00, 0x41
|
||||
};
|
||||
sensor.gamma = {1.7, 1.7, 1.7};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -621,7 +606,6 @@ void genesys_init_sensor_tables()
|
|||
0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xe1, 0x55, 0x00, 0x00, 0x00, 0x41
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -644,7 +628,6 @@ void genesys_init_sensor_tables()
|
|||
0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xe1, 0x55, 0x00, 0x00, 0x00, 0x41
|
||||
};
|
||||
sensor.gamma = {1.7, 1.7, 1.7};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -667,7 +650,6 @@ void genesys_init_sensor_tables()
|
|||
0x0c, 0x0f, 0x00, 0x03, 0x06, 0x09, 0x6b, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x23
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -691,7 +673,6 @@ void genesys_init_sensor_tables()
|
|||
0x0b, 0x0e, 0x11, 0x02, 0x05, 0x08, 0x63, 0x00, 0x40, 0x00, 0x00, 0x00, 0x6f
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -716,7 +697,6 @@ void genesys_init_sensor_tables()
|
|||
0x0a, 0x0d, 0x00, 0x03, 0x06, 0x08, 0x5b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3f
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -741,7 +721,6 @@ void genesys_init_sensor_tables()
|
|||
0x0a, 0x0d, 0x00, 0x03, 0x06, 0x08, 0x5b, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3f
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -764,7 +743,6 @@ void genesys_init_sensor_tables()
|
|||
0x0b, 0x0e, 0x11, 0x02, 0x05, 0x08, 0x63, 0x00, 0x40, 0x00, 0x00, 0x06, 0x6f
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -787,7 +765,6 @@ void genesys_init_sensor_tables()
|
|||
0x00, 0x02, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x1a, 0x00, 0xc0, 0x00, 0x00
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -811,7 +788,6 @@ void genesys_init_sensor_tables()
|
|||
0x04, 0x06, 0x00, 0x02, 0x04, 0x04, 0x04, 0x04, 0x3a, 0x00, 0x00, 0x00, 0x1f
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -834,7 +810,6 @@ void genesys_init_sensor_tables()
|
|||
0x00, 0x02, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x1a, 0x00, 0xc0, 0x00, 0x00
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -857,7 +832,6 @@ void genesys_init_sensor_tables()
|
|||
0x00, 0x02, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x1a, 0x00, 0xc0, 0x00, 0x00
|
||||
};
|
||||
sensor.gamma = {2.1, 2.1, 2.1};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -880,7 +854,6 @@ void genesys_init_sensor_tables()
|
|||
0x07, 0x0a, 0x0c, 0x00, 0x02, 0x06, 0x22, 0x69, 0x40, 0x00, 0x00, 0x00, 0x02
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -903,7 +876,6 @@ void genesys_init_sensor_tables()
|
|||
0x02, 0x04, 0x06, 0x08, 0x0a, 0x00, 0x59, 0x31, 0x40, 0x00, 0x00, 0x00, 0x1f
|
||||
};
|
||||
sensor.gamma = {1.7, 1.7, 1.7};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -926,7 +898,6 @@ void genesys_init_sensor_tables()
|
|||
0x02, 0x04, 0x06, 0x08, 0x0a, 0x00, 0x59, 0x31, 0x40, 0x00, 0x00, 0x00, 0x1f
|
||||
};
|
||||
sensor.gamma = {1.7, 1.7, 1.7};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
|
||||
|
||||
|
@ -953,7 +924,6 @@ void genesys_init_sensor_tables()
|
|||
0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x29, 0x69, 0x55, 0x00, 0x00, 0x20, 0x41
|
||||
};
|
||||
sensor.gamma = {1.0, 1.0, 1.0};
|
||||
sensor.gamma_table = {NULL, NULL, NULL};
|
||||
s_sensors->push_back(sensor);
|
||||
}
|
||||
|
||||
|
|
|
@ -4178,15 +4178,10 @@ gl646_init (Genesys_Device * dev)
|
|||
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
if (dev->sensor.gamma_table[i].empty())
|
||||
{
|
||||
dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG(DBG_error, "%s: could not allocate memory for gamma table %d\n", __func__, i);
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i],
|
||||
dev->sensor.gamma_table[i].resize(size, 0);
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i].data(),
|
||||
size,
|
||||
size - 1,
|
||||
size - 1,
|
||||
|
|
|
@ -5150,15 +5150,10 @@ gl841_init (Genesys_Device * dev)
|
|||
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
if (dev->sensor.gamma_table[i].empty())
|
||||
{
|
||||
dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG(DBG_error,"%s: could not allocate memory for gamma table %d\n", __func__, i);
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i],
|
||||
dev->sensor.gamma_table[i].resize(size, 0);
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i].data(),
|
||||
size,
|
||||
65535,
|
||||
65535,
|
||||
|
|
|
@ -1626,15 +1626,10 @@ sanei_genesys_asic_init (Genesys_Device * dev, int max_regs)
|
|||
size = 256;
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
FREE_IFNOT_NULL (dev->sensor.gamma_table[i]);
|
||||
dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size);
|
||||
if (dev->sensor.gamma_table[i] == NULL)
|
||||
{
|
||||
DBG (DBG_error, "%s: could not allocate memory for gamma table %d\n",
|
||||
__func__, i);
|
||||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i],
|
||||
dev->sensor.gamma_table[i].clear();
|
||||
dev->sensor.gamma_table[i].resize(size, 0);
|
||||
|
||||
sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i].data(),
|
||||
size,
|
||||
65535,
|
||||
65535,
|
||||
|
|
|
@ -277,20 +277,24 @@ struct AssignableArray : public std::array<T, Size> {
|
|||
};
|
||||
|
||||
struct Genesys_Sensor {
|
||||
|
||||
Genesys_Sensor() = default;
|
||||
~Genesys_Sensor() = default;
|
||||
|
||||
// id of the sensor description
|
||||
uint8_t sensor_id;
|
||||
int optical_res;
|
||||
int black_pixels;
|
||||
uint8_t sensor_id = 0;
|
||||
int optical_res = 0;
|
||||
int black_pixels = 0;
|
||||
// value of the dummy register
|
||||
int dummy_pixel;
|
||||
int dummy_pixel = 0;
|
||||
// last pixel of CCD margin at optical resolution
|
||||
int CCD_start_xoffset;
|
||||
int CCD_start_xoffset = 0;
|
||||
// total pixels used by the sensor
|
||||
int sensor_pixels;
|
||||
int sensor_pixels = 0;
|
||||
// TA CCD target code (reference gain)
|
||||
int fau_gain_white_ref;
|
||||
int fau_gain_white_ref = 0;
|
||||
// CCD target code (reference gain)
|
||||
int gain_white_ref;
|
||||
int gain_white_ref = 0;
|
||||
|
||||
AssignableArray<uint8_t, 4> regs_0x08_0x0b;
|
||||
// Initial exposure values, EXPR, EXPG and EXPB are contained in 0x10-0x15
|
||||
|
@ -301,7 +305,7 @@ struct Genesys_Sensor {
|
|||
AssignableArray<float, 3> gamma;
|
||||
|
||||
// sensor-specific gamma tables
|
||||
AssignableArray<uint16_t*, 3> gamma_table;
|
||||
std::vector<uint16_t> gamma_table[3];
|
||||
|
||||
size_t fread(FILE* fp)
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue