Tweaks
This commit is contained in:
parent
8cb975f345
commit
887c373c92
|
@ -123,16 +123,6 @@
|
||||||
|
|
||||||
#define HDLC_FRAMING_OK_THRESHOLD 8
|
#define HDLC_FRAMING_OK_THRESHOLD 8
|
||||||
|
|
||||||
static void fax_modems_hdlc_tx_frame(void *user_data, const uint8_t *msg, int len)
|
|
||||||
{
|
|
||||||
fax_modems_state_t *s;
|
|
||||||
|
|
||||||
s = (fax_modems_state_t *) user_data;
|
|
||||||
|
|
||||||
hdlc_tx_frame(&s->hdlc_tx, msg, len);
|
|
||||||
}
|
|
||||||
/*- End of function --------------------------------------------------------*/
|
|
||||||
|
|
||||||
static void tone_detected(void *user_data, int tone, int level, int delay)
|
static void tone_detected(void *user_data, int tone, int level, int delay)
|
||||||
{
|
{
|
||||||
t30_state_t *s;
|
t30_state_t *s;
|
||||||
|
|
|
@ -98,6 +98,12 @@ SPAN_DECLARE(int) t42_encode_set_row_read_handler(t42_encode_state_t *s,
|
||||||
t4_row_read_handler_t handler,
|
t4_row_read_handler_t handler,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
|
/*! Get the logging context associated with a T.42 encode context.
|
||||||
|
\brief Get the logging context associated with a T.42 encode context.
|
||||||
|
\param s The T.42 encode context.
|
||||||
|
\return A pointer to the logging context */
|
||||||
|
SPAN_DECLARE(logging_state_t *) t42_encode_get_logging_state(t42_encode_state_t *s);
|
||||||
|
|
||||||
SPAN_DECLARE(int) t42_encode_restart(t42_encode_state_t *s, uint32_t image_width, uint32_t image_length);
|
SPAN_DECLARE(int) t42_encode_restart(t42_encode_state_t *s, uint32_t image_width, uint32_t image_length);
|
||||||
|
|
||||||
SPAN_DECLARE(t42_encode_state_t *) t42_encode_init(t42_encode_state_t *s,
|
SPAN_DECLARE(t42_encode_state_t *) t42_encode_init(t42_encode_state_t *s,
|
||||||
|
@ -135,6 +141,12 @@ SPAN_DECLARE(int) t42_decode_get_compressed_image_size(t42_decode_state_t *s);
|
||||||
|
|
||||||
SPAN_DECLARE(int) t42_decode_new_plane(t42_decode_state_t *s);
|
SPAN_DECLARE(int) t42_decode_new_plane(t42_decode_state_t *s);
|
||||||
|
|
||||||
|
/*! Get the logging context associated with a T.42 decode context.
|
||||||
|
\brief Get the logging context associated with a T.42 decode context.
|
||||||
|
\param s The T.42 decode context.
|
||||||
|
\return A pointer to the logging context */
|
||||||
|
SPAN_DECLARE(logging_state_t *) t42_decode_get_logging_state(t42_decode_state_t *s);
|
||||||
|
|
||||||
SPAN_DECLARE(int) t42_decode_restart(t42_decode_state_t *s);
|
SPAN_DECLARE(int) t42_decode_restart(t42_decode_state_t *s);
|
||||||
|
|
||||||
SPAN_DECLARE(t42_decode_state_t *) t42_decode_init(t42_decode_state_t *s,
|
SPAN_DECLARE(t42_decode_state_t *) t42_decode_init(t42_decode_state_t *s,
|
||||||
|
|
|
@ -74,10 +74,11 @@ typedef enum
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
T4_IMAGE_TYPE_BILEVEL = 0,
|
T4_IMAGE_TYPE_BILEVEL = 0,
|
||||||
T4_IMAGE_TYPE_GRAY_8BIT = 1,
|
T4_IMAGE_TYPE_COLOUR_BILEVEL = 1,
|
||||||
T4_IMAGE_TYPE_GRAY_12BIT = 2,
|
T4_IMAGE_TYPE_GRAY_8BIT = 2,
|
||||||
T4_IMAGE_TYPE_COLOUR_8BIT = 3,
|
T4_IMAGE_TYPE_GRAY_12BIT = 3,
|
||||||
T4_IMAGE_TYPE_COLOUR_12BIT = 4
|
T4_IMAGE_TYPE_COLOUR_8BIT = 4,
|
||||||
|
T4_IMAGE_TYPE_COLOUR_12BIT = 5
|
||||||
} t4_image_types_t;
|
} t4_image_types_t;
|
||||||
|
|
||||||
/*! Supported X resolutions, in pixels per metre. */
|
/*! Supported X resolutions, in pixels per metre. */
|
||||||
|
|
|
@ -396,16 +396,16 @@ SPAN_DECLARE(void) srgb_to_lab(lab_params_t *s, uint8_t lab[], const uint8_t srg
|
||||||
cielab_t l;
|
cielab_t l;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < pixels; i++)
|
for (i = 0; i < 3*pixels; i += 3)
|
||||||
{
|
{
|
||||||
#if defined(T42_USE_LUTS)
|
#if defined(T42_USE_LUTS)
|
||||||
r = srgb_to_linear[srgb[0]];
|
r = srgb_to_linear[srgb[i]];
|
||||||
g = srgb_to_linear[srgb[1]];
|
g = srgb_to_linear[srgb[i + 1]];
|
||||||
b = srgb_to_linear[srgb[2]];
|
b = srgb_to_linear[srgb[i + 2]];
|
||||||
#else
|
#else
|
||||||
r = srgb[0]/256.0f;
|
r = srgb[i]/256.0f;
|
||||||
g = srgb[1]/256.0f;
|
g = srgb[i + 1]/256.0f;
|
||||||
b = srgb[2]/256.0f;
|
b = srgb[i + 2]/256.0f;
|
||||||
|
|
||||||
/* sRGB to linear RGB */
|
/* sRGB to linear RGB */
|
||||||
r = (r > 0.04045f) ? powf((r + 0.055f)/1.055f, 2.4f) : r/12.92f;
|
r = (r > 0.04045f) ? powf((r + 0.055f)/1.055f, 2.4f) : r/12.92f;
|
||||||
|
@ -433,7 +433,6 @@ SPAN_DECLARE(void) srgb_to_lab(lab_params_t *s, uint8_t lab[], const uint8_t srg
|
||||||
|
|
||||||
lab_to_itu(s, lab, &l);
|
lab_to_itu(s, lab, &l);
|
||||||
|
|
||||||
srgb += 3;
|
|
||||||
lab += 3;
|
lab += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,7 +451,7 @@ SPAN_DECLARE(void) lab_to_srgb(lab_params_t *s, uint8_t srgb[], const uint8_t la
|
||||||
int val;
|
int val;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < pixels; i++)
|
for (i = 0; i < 3*pixels; i += 3)
|
||||||
{
|
{
|
||||||
itu_to_lab(s, &l, lab);
|
itu_to_lab(s, &l, lab);
|
||||||
|
|
||||||
|
@ -477,22 +476,21 @@ SPAN_DECLARE(void) lab_to_srgb(lab_params_t *s, uint8_t srgb[], const uint8_t la
|
||||||
|
|
||||||
#if defined(T42_USE_LUTS)
|
#if defined(T42_USE_LUTS)
|
||||||
val = r*4096.0f;
|
val = r*4096.0f;
|
||||||
srgb[0] = linear_to_srgb[(val < 0) ? 0 : (val < 4095) ? val : 4095];
|
srgb[i] = linear_to_srgb[(val < 0) ? 0 : (val < 4095) ? val : 4095];
|
||||||
val = g*4096.0f;
|
val = g*4096.0f;
|
||||||
srgb[1] = linear_to_srgb[(val < 0) ? 0 : (val < 4095) ? val : 4095];
|
srgb[i + 1] = linear_to_srgb[(val < 0) ? 0 : (val < 4095) ? val : 4095];
|
||||||
val = b*4096.0f;
|
val = b*4096.0f;
|
||||||
srgb[2] = linear_to_srgb[(val < 0) ? 0 : (val < 4095) ? val : 4095];
|
srgb[i + 2] = linear_to_srgb[(val < 0) ? 0 : (val < 4095) ? val : 4095];
|
||||||
#else
|
#else
|
||||||
/* Linear RGB to sRGB */
|
/* Linear RGB to sRGB */
|
||||||
r = (r > 0.0031308f) ? (1.055f*powf(r, 1.0f/2.4f) - 0.055f) : r*12.92f;
|
r = (r > 0.0031308f) ? (1.055f*powf(r, 1.0f/2.4f) - 0.055f) : r*12.92f;
|
||||||
g = (g > 0.0031308f) ? (1.055f*powf(g, 1.0f/2.4f) - 0.055f) : g*12.92f;
|
g = (g > 0.0031308f) ? (1.055f*powf(g, 1.0f/2.4f) - 0.055f) : g*12.92f;
|
||||||
b = (b > 0.0031308f) ? (1.055f*powf(b, 1.0f/2.4f) - 0.055f) : b*12.92f;
|
b = (b > 0.0031308f) ? (1.055f*powf(b, 1.0f/2.4f) - 0.055f) : b*12.92f;
|
||||||
|
|
||||||
srgb[0] = saturateu8(floorf(r*256.0f));
|
srgb[i] = saturateu8(floorf(r*256.0f));
|
||||||
srgb[1] = saturateu8(floorf(g*256.0f));
|
srgb[i + 1] = saturateu8(floorf(g*256.0f));
|
||||||
srgb[2] = saturateu8(floorf(b*256.0f));
|
srgb[i + 2] = saturateu8(floorf(b*256.0f));
|
||||||
#endif
|
#endif
|
||||||
srgb += 3;
|
|
||||||
lab += 3;
|
lab += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1233,6 +1231,12 @@ SPAN_DECLARE(int) t42_encode_set_row_read_handler(t42_encode_state_t *s,
|
||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
|
SPAN_DECLARE(logging_state_t *) t42_encode_get_logging_state(t42_encode_state_t *s)
|
||||||
|
{
|
||||||
|
return &s->logging;
|
||||||
|
}
|
||||||
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(int) t42_encode_restart(t42_encode_state_t *s, uint32_t image_width, uint32_t image_length)
|
SPAN_DECLARE(int) t42_encode_restart(t42_encode_state_t *s, uint32_t image_width, uint32_t image_length)
|
||||||
{
|
{
|
||||||
//s->image_width = image_width;
|
//s->image_width = image_width;
|
||||||
|
@ -1357,6 +1361,12 @@ SPAN_DECLARE(int) t42_decode_new_plane(t42_decode_state_t *s)
|
||||||
}
|
}
|
||||||
/*- End of function --------------------------------------------------------*/
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
|
SPAN_DECLARE(logging_state_t *) t42_decode_get_logging_state(t42_decode_state_t *s)
|
||||||
|
{
|
||||||
|
return &s->logging;
|
||||||
|
}
|
||||||
|
/*- End of function --------------------------------------------------------*/
|
||||||
|
|
||||||
SPAN_DECLARE(int) t42_decode_restart(t42_decode_state_t *s)
|
SPAN_DECLARE(int) t42_decode_restart(t42_decode_state_t *s)
|
||||||
{
|
{
|
||||||
s->compressed_image_size = 0;
|
s->compressed_image_size = 0;
|
||||||
|
|
|
@ -170,6 +170,16 @@ static int get_tiff_directory_info(t4_tx_state_t *s)
|
||||||
{1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200},
|
{1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200},
|
||||||
{ -1.00f, -1}
|
{ -1.00f, -1}
|
||||||
};
|
};
|
||||||
|
static const char *tiff_fx_fax_profiles[] =
|
||||||
|
{
|
||||||
|
"???",
|
||||||
|
"profile S",
|
||||||
|
"profile F",
|
||||||
|
"profile J",
|
||||||
|
"profile C",
|
||||||
|
"profile L",
|
||||||
|
"profile M"
|
||||||
|
};
|
||||||
uint16_t res_unit;
|
uint16_t res_unit;
|
||||||
uint8_t parm8;
|
uint8_t parm8;
|
||||||
uint16_t parm16;
|
uint16_t parm16;
|
||||||
|
@ -184,14 +194,14 @@ static int get_tiff_directory_info(t4_tx_state_t *s)
|
||||||
uint16_t samples_per_pixel;
|
uint16_t samples_per_pixel;
|
||||||
|
|
||||||
t = &s->tiff;
|
t = &s->tiff;
|
||||||
parm16 = 0;
|
bits_per_sample = 1;
|
||||||
TIFFGetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, &parm16);
|
TIFFGetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, &bits_per_sample);
|
||||||
bits_per_sample = parm16;
|
samples_per_pixel = 1;
|
||||||
parm16 = 0;
|
TIFFGetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel);
|
||||||
TIFFGetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, &parm16);
|
|
||||||
samples_per_pixel = parm16;
|
|
||||||
if (samples_per_pixel == 1 && bits_per_sample == 1)
|
if (samples_per_pixel == 1 && bits_per_sample == 1)
|
||||||
t->image_type = T4_IMAGE_TYPE_BILEVEL;
|
t->image_type = T4_IMAGE_TYPE_BILEVEL;
|
||||||
|
else if (samples_per_pixel == 3 && bits_per_sample == 1)
|
||||||
|
t->image_type = T4_IMAGE_TYPE_COLOUR_BILEVEL;
|
||||||
else if (samples_per_pixel == 1 && bits_per_sample == 8)
|
else if (samples_per_pixel == 1 && bits_per_sample == 8)
|
||||||
t->image_type = T4_IMAGE_TYPE_GRAY_8BIT;
|
t->image_type = T4_IMAGE_TYPE_GRAY_8BIT;
|
||||||
else if (samples_per_pixel == 1 && bits_per_sample > 8)
|
else if (samples_per_pixel == 1 && bits_per_sample > 8)
|
||||||
|
@ -260,19 +270,19 @@ static int get_tiff_directory_info(t4_tx_state_t *s)
|
||||||
}
|
}
|
||||||
#if defined(SPANDSP_SUPPORT_TIFF_FX)
|
#if defined(SPANDSP_SUPPORT_TIFF_FX)
|
||||||
if (TIFFGetField(t->tiff_file, TIFFTAG_PROFILETYPE, &parm32))
|
if (TIFFGetField(t->tiff_file, TIFFTAG_PROFILETYPE, &parm32))
|
||||||
printf("Profile type %u\n", parm32);
|
span_log(&s->logging, SPAN_LOG_FLOW, "Profile type %u\n", parm32);
|
||||||
if (TIFFGetField(t->tiff_file, TIFFTAG_FAXPROFILE, &parm8))
|
if (TIFFGetField(t->tiff_file, TIFFTAG_FAXPROFILE, &parm8))
|
||||||
printf("FAX profile %u\n", parm8);
|
span_log(&s->logging, SPAN_LOG_FLOW, "FAX profile %s (%u)\n", tiff_fx_fax_profiles[parm8], parm8);
|
||||||
if (TIFFGetField(t->tiff_file, TIFFTAG_CODINGMETHODS, &parm32))
|
if (TIFFGetField(t->tiff_file, TIFFTAG_CODINGMETHODS, &parm32))
|
||||||
printf("Coding methods 0x%x\n", parm32);
|
span_log(&s->logging, SPAN_LOG_FLOW, "Coding methods 0x%x\n", parm32);
|
||||||
if (TIFFGetField(t->tiff_file, TIFFTAG_VERSIONYEAR, &u))
|
if (TIFFGetField(t->tiff_file, TIFFTAG_VERSIONYEAR, &u))
|
||||||
{
|
{
|
||||||
memcpy(uu, u, 4);
|
memcpy(uu, u, 4);
|
||||||
uu[4] = '\0';
|
uu[4] = '\0';
|
||||||
printf("Version year \"%s\"\n", uu);
|
span_log(&s->logging, SPAN_LOG_FLOW, "Version year \"%s\"\n", uu);
|
||||||
}
|
}
|
||||||
if (TIFFGetField(t->tiff_file, TIFFTAG_MODENUMBER, &parm8))
|
if (TIFFGetField(t->tiff_file, TIFFTAG_MODENUMBER, &parm8))
|
||||||
printf("Mode number %u\n", parm8);
|
span_log(&s->logging, SPAN_LOG_FLOW, "Mode number %u\n", parm8);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -319,11 +329,11 @@ static int test_tiff_directory_info(t4_tx_state_t *s)
|
||||||
t4_tx_tiff_state_t *t;
|
t4_tx_tiff_state_t *t;
|
||||||
|
|
||||||
t = &s->tiff;
|
t = &s->tiff;
|
||||||
parm16 = 0;
|
parm16 = 1;
|
||||||
TIFFGetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, &parm16);
|
TIFFGetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, &parm16);
|
||||||
if (parm16 != 1)
|
if (parm16 != 1)
|
||||||
return -1;
|
return -1;
|
||||||
parm16 = 0;
|
parm16 = 1;
|
||||||
TIFFGetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, &parm16);
|
TIFFGetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, &parm16);
|
||||||
if (parm16 != 1)
|
if (parm16 != 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -111,7 +111,7 @@ static void create_undithered_50_by_50(image_descriptor_t *im, uint8_t buf[], in
|
||||||
{
|
{
|
||||||
for (j = 0; j < 50; j++)
|
for (j = 0; j < 50; j++)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 0
|
||||||
image8[50*3*i + 3*j + 0] = ((i + j)*655) >> 8;
|
image8[50*3*i + 3*j + 0] = ((i + j)*655) >> 8;
|
||||||
image8[50*3*i + 3*j + 1] = ((i + j)*655) >> 8;
|
image8[50*3*i + 3*j + 1] = ((i + j)*655) >> 8;
|
||||||
image8[50*3*i + 3*j + 2] = ((i + j)*655) >> 8;
|
image8[50*3*i + 3*j + 2] = ((i + j)*655) >> 8;
|
||||||
|
@ -129,7 +129,7 @@ static void create_undithered_50_by_50(image_descriptor_t *im, uint8_t buf[], in
|
||||||
{
|
{
|
||||||
for (j = 0; j < 50; j++)
|
for (j = 0; j < 50; j++)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 0
|
||||||
image16[50*3*i + 3*j + 0] = (i + j)*655;
|
image16[50*3*i + 3*j + 0] = (i + j)*655;
|
||||||
image16[50*3*i + 3*j + 1] = (i + j)*655;
|
image16[50*3*i + 3*j + 1] = (i + j)*655;
|
||||||
image16[50*3*i + 3*j + 2] = (i + j)*655;
|
image16[50*3*i + 3*j + 2] = (i + j)*655;
|
||||||
|
@ -350,7 +350,7 @@ static void get_colour8_image(image_translate_state_t *s, int compare)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 50; j++)
|
for (j = 0; j < 50; j++)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 0
|
||||||
r = ((i + j)*655) >> 8;
|
r = ((i + j)*655) >> 8;
|
||||||
g = ((i + j)*655) >> 8;
|
g = ((i + j)*655) >> 8;
|
||||||
b = ((i + j)*655) >> 8;
|
b = ((i + j)*655) >> 8;
|
||||||
|
@ -399,7 +399,7 @@ static void get_colour16_image(image_translate_state_t *s, int compare)
|
||||||
{
|
{
|
||||||
for (j = 0; j < 50; j++)
|
for (j = 0; j < 50; j++)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 0
|
||||||
r = (i + j)*655;
|
r = (i + j)*655;
|
||||||
g = (i + j)*655;
|
g = (i + j)*655;
|
||||||
b = (i + j)*655;
|
b = (i + j)*655;
|
||||||
|
@ -638,7 +638,7 @@ static void lenna_tests(int output_width, int output_length_scaling, const char
|
||||||
TIFFGetField(in_file, TIFFTAG_BITSPERSAMPLE, &bits_per_sample);
|
TIFFGetField(in_file, TIFFTAG_BITSPERSAMPLE, &bits_per_sample);
|
||||||
samples_per_pixel = 0;
|
samples_per_pixel = 0;
|
||||||
TIFFGetField(in_file, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel);
|
TIFFGetField(in_file, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel);
|
||||||
printf("Original image is %d x %d, %f x %f resolution, %d bits per sample, %d samples per pixel\n", image_width, image_length, x_resolution, y_resolution, bits_per_sample, samples_per_pixel);
|
printf("Original image is %d x %d, %.2f x %.2f resolution, %d bits per sample, %d samples per pixel\n", image_width, image_length, x_resolution, y_resolution, bits_per_sample, samples_per_pixel);
|
||||||
if ((image = malloc(image_width*image_length*samples_per_pixel)) == NULL)
|
if ((image = malloc(image_width*image_length*samples_per_pixel)) == NULL)
|
||||||
return;
|
return;
|
||||||
for (total = 0, i = 0; i < 1000; i++)
|
for (total = 0, i = 0; i < 1000; i++)
|
||||||
|
|
|
@ -54,7 +54,7 @@ int data5_ptr = 0;
|
||||||
int plane = 0;
|
int plane = 0;
|
||||||
int bit_mask;
|
int bit_mask;
|
||||||
|
|
||||||
uint8_t xxx[3*256];
|
uint8_t colour_map[3*256];
|
||||||
|
|
||||||
lab_params_t lab_param;
|
lab_params_t lab_param;
|
||||||
|
|
||||||
|
@ -141,10 +141,10 @@ int main(int argc, char *argv[])
|
||||||
t85_decode_state_t t85_dec;
|
t85_decode_state_t t85_dec;
|
||||||
uint64_t start;
|
uint64_t start;
|
||||||
uint64_t end;
|
uint64_t end;
|
||||||
uint16_t *yyyL;
|
uint16_t *map_L;
|
||||||
uint16_t *yyya;
|
uint16_t *map_a;
|
||||||
uint16_t *yyyb;
|
uint16_t *map_b;
|
||||||
uint16_t *yyyz;
|
uint16_t *map_z;
|
||||||
logging_state_t *logging;
|
logging_state_t *logging;
|
||||||
|
|
||||||
printf("Demo of ITU/Lab library.\n");
|
printf("Demo of ITU/Lab library.\n");
|
||||||
|
@ -187,37 +187,37 @@ int main(int argc, char *argv[])
|
||||||
planar_config = 0;
|
planar_config = 0;
|
||||||
TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planar_config);
|
TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planar_config);
|
||||||
off = 0;
|
off = 0;
|
||||||
yyyL = NULL;
|
map_L = NULL;
|
||||||
yyya = NULL;
|
map_a = NULL;
|
||||||
yyyb = NULL;
|
map_b = NULL;
|
||||||
yyyz = NULL;
|
map_z = NULL;
|
||||||
if (TIFFGetField(tif, TIFFTAG_COLORMAP, &yyyL, &yyya, &yyyb, &yyyz))
|
if (TIFFGetField(tif, TIFFTAG_COLORMAP, &map_L, &map_a, &map_b, &map_z))
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
/* Sweep the colormap in the proper order */
|
/* Sweep the colormap in the proper order */
|
||||||
for (i = 0; i < (1 << bits_per_pixel); i++)
|
for (i = 0; i < (1 << bits_per_pixel); i++)
|
||||||
{
|
{
|
||||||
xxx[3*i] = (yyyL[i] >> 8) & 0xFF;
|
colour_map[3*i] = (map_L[i] >> 8) & 0xFF;
|
||||||
xxx[3*i + 1] = (yyya[i] >> 8) & 0xFF;
|
colour_map[3*i + 1] = (map_a[i] >> 8) & 0xFF;
|
||||||
xxx[3*i + 2] = (yyyb[i] >> 8) & 0xFF;
|
colour_map[3*i + 2] = (map_b[i] >> 8) & 0xFF;
|
||||||
printf("Map %3d - %5d %5d %5d\n", i, xxx[3*i], xxx[3*i + 1], xxx[3*i + 2]);
|
printf("Map %3d - %5d %5d %5d\n", i, colour_map[3*i], colour_map[3*i + 1], colour_map[3*i + 2]);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Sweep the colormap in the order that seems to work for l04x_02x.tif */
|
/* Sweep the colormap in the order that seems to work for l04x_02x.tif */
|
||||||
for (i = 0; i < (1 << bits_per_pixel); i++)
|
for (i = 0; i < (1 << bits_per_pixel); i++)
|
||||||
{
|
{
|
||||||
xxx[i] = (yyyL[i] >> 8) & 0xFF;
|
colour_map[i] = (map_L[i] >> 8) & 0xFF;
|
||||||
xxx[256 + i] = (yyya[i] >> 8) & 0xFF;
|
colour_map[256 + i] = (map_a[i] >> 8) & 0xFF;
|
||||||
xxx[2*256 + i] = (yyyb[i] >> 8) & 0xFF;
|
colour_map[2*256 + i] = (map_b[i] >> 8) & 0xFF;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
lab_params_t lab;
|
lab_params_t lab;
|
||||||
|
|
||||||
set_lab_illuminant(&lab, 0.9638f, 1.0f, 0.8245f);
|
set_lab_illuminant(&lab, 0.9638f, 1.0f, 0.8245f);
|
||||||
set_lab_gamut(&lab, 0, 100, -85, 85, -75, 125, FALSE);
|
set_lab_gamut(&lab, 0, 100, -85, 85, -75, 125, FALSE);
|
||||||
lab_to_srgb(&lab, xxx, xxx, 256);
|
lab_to_srgb(&lab, colour_map, colour_map, 256);
|
||||||
for (i = 0; i < (1 << bits_per_pixel); i++)
|
for (i = 0; i < (1 << bits_per_pixel); i++)
|
||||||
printf("Map %3d - %5d %5d %5d\n", i, xxx[3*i], xxx[3*i + 1], xxx[3*i + 2]);
|
printf("Map %3d - %5d %5d %5d\n", i, colour_map[3*i], colour_map[3*i + 1], colour_map[3*i + 2]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -273,7 +273,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (total_len != total_image_len)
|
if (total_len != total_image_len)
|
||||||
printf("Size mismatch %d %d\n", total_len, total_image_len);
|
printf("Size mismatch %ld %ld\n", total_len, total_image_len);
|
||||||
off = total_len;
|
off = total_len;
|
||||||
switch (compression)
|
switch (compression)
|
||||||
{
|
{
|
||||||
|
@ -282,7 +282,7 @@ int main(int argc, char *argv[])
|
||||||
case COMPRESSION_CCITT_T6:
|
case COMPRESSION_CCITT_T6:
|
||||||
break;
|
break;
|
||||||
case COMPRESSION_T85:
|
case COMPRESSION_T85:
|
||||||
printf("T.85 image %d bytes\n", total_len);
|
printf("T.85 image %ld bytes\n", total_len);
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
printf("0x%02x\n", data[i]);
|
printf("0x%02x\n", data[i]);
|
||||||
t85_decode_init(&t85_dec, t85_row_write_handler, NULL);
|
t85_decode_init(&t85_dec, t85_row_write_handler, NULL);
|
||||||
|
@ -295,7 +295,7 @@ int main(int argc, char *argv[])
|
||||||
t85_decode_release(&t85_dec);
|
t85_decode_release(&t85_dec);
|
||||||
return 0;
|
return 0;
|
||||||
case COMPRESSION_T43:
|
case COMPRESSION_T43:
|
||||||
printf("T.43 image %d bytes\n", total_len);
|
printf("T.43 image %ld bytes\n", total_len);
|
||||||
if (pack_16(data) == 0xFFA8)
|
if (pack_16(data) == 0xFFA8)
|
||||||
{
|
{
|
||||||
data += 2;
|
data += 2;
|
||||||
|
@ -359,10 +359,10 @@ int main(int argc, char *argv[])
|
||||||
for (j = 0; j < data5_ptr; j += 3)
|
for (j = 0; j < data5_ptr; j += 3)
|
||||||
{
|
{
|
||||||
i = data5[j] & 0xFF;
|
i = data5[j] & 0xFF;
|
||||||
//printf("%d %d %d %d %d %d\n", data5_ptr, j, i, xxx[3*i], xxx[3*i + 1], xxx[3*i + 2]);
|
//printf("%d %d %d %d %d %d\n", data5_ptr, j, i, colour_map[3*i], colour_map[3*i + 1], colour_map[3*i + 2]);
|
||||||
data5[j] = xxx[3*i];
|
data5[j] = colour_map[3*i];
|
||||||
data5[j + 1] = xxx[3*i + 1];
|
data5[j + 1] = colour_map[3*i + 1];
|
||||||
data5[j + 2] = xxx[3*i + 2];
|
data5[j + 2] = colour_map[3*i + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tif = TIFFOpen(OUT_FILE_NAME, "w")) == NULL)
|
if ((tif = TIFFOpen(OUT_FILE_NAME, "w")) == NULL)
|
||||||
|
@ -420,7 +420,7 @@ int main(int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
off += bytes_per_row;
|
off += bytes_per_row;
|
||||||
}
|
}
|
||||||
printf("total %d, off %d\n", totdata, off);
|
printf("total %d, off %ld\n", totdata, off);
|
||||||
|
|
||||||
/* We now have the image in memory in RGB form */
|
/* We now have the image in memory in RGB form */
|
||||||
|
|
||||||
|
@ -440,17 +440,20 @@ int main(int argc, char *argv[])
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
start = rdtscll();
|
start = rdtscll();
|
||||||
if (photometric == PHOTOMETRIC_CIELAB)
|
switch (photometric)
|
||||||
{
|
{
|
||||||
|
case PHOTOMETRIC_CIELAB:
|
||||||
printf("CIELAB\n");
|
printf("CIELAB\n");
|
||||||
/* The default luminant is D50 */
|
/* The default luminant is D50 */
|
||||||
set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f);
|
set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f);
|
||||||
set_lab_gamut(&lab_param, 0, 100, -128, 127, -128, 127, TRUE);
|
set_lab_gamut(&lab_param, 0, 100, -128, 127, -128, 127, TRUE);
|
||||||
lab_to_srgb(&lab_param, data, data, w*h);
|
lab_to_srgb(&lab_param, data, data, w*h);
|
||||||
|
break;
|
||||||
|
case PHOTOMETRIC_ITULAB:
|
||||||
|
set_lab_illuminant(&lab_param, 0.9638f, 1.0f, 0.8245f);
|
||||||
|
set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_lab_illuminant(&lab_param, 0.9638f, 1.0f, 0.8245f);
|
|
||||||
set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE);
|
|
||||||
if (!t42_srgb_to_itulab(logging, &lab_param, (tdata_t) &outptr, &outsize, data, off, w, h))
|
if (!t42_srgb_to_itulab(logging, &lab_param, (tdata_t) &outptr, &outsize, data, off, w, h))
|
||||||
{
|
{
|
||||||
printf("Failed to convert to ITULAB\n");
|
printf("Failed to convert to ITULAB\n");
|
||||||
|
@ -465,7 +468,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
TIFFClose(tif);
|
TIFFClose(tif);
|
||||||
|
|
||||||
printf("XXX - image is %d by %d, %d bytes\n", w, h, off);
|
printf("XXX - image is %d by %d, %ld bytes\n", w, h, off);
|
||||||
|
|
||||||
/* We now have the image in memory in ITULAB form */
|
/* We now have the image in memory in ITULAB form */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue