V2 branch :

- found a bug in tcd.c that was preventing to find the correct threshold in tcd_rateallocate.c for high-precision images. Applied a temporary patch but a better solution should be found.
- Modified the way raw images with more that 8bpp are read and written
This commit is contained in:
Antonin Descampe 2009-09-10 13:34:19 +00:00
parent b1d8788a46
commit ec400c4fa5
4 changed files with 36 additions and 6 deletions

View File

@ -8,6 +8,12 @@ What's New for OpenJPEG
September 10, 2009
* [antonin] fixed minor bugs which were triggering warnings at compilation (different signedness, wrong pointer type, etc)
August 21, 2008
* [antonin] found a bug in tcd.c that was preventing to find the correct threshold in tcd_rateallocate.c for high-precision images. Applied a temporary patch but a better solution should be found.
August 8, 2008
! [FOD] Modified the way raw images with more that 8bpp are read and written
August 2nd, 2008
* [Mathieu Malaterre] remove INLINE from forward decl. Fix CMakeLists.txt for UNIX platforms

View File

@ -2012,19 +2012,30 @@ opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw
}
}
}
else
else if(raw_cp->rawBitDepth <= 16)
{
unsigned short value = 0;
unsigned short value;
for(compno = 0; compno < numcomps; compno++) {
for (i = 0; i < w * h; i++) {
if (!fread(&value, 2, 1, f)) {
unsigned char temp;
if (!fread(&temp, 1, 1, f)) {
fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
return NULL;
}
value = temp << 8;
if (!fread(&temp, 1, 1, f)) {
fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
return NULL;
}
value += temp;
image->comps[compno].data[i] = raw_cp->rawSigned?(short)value:value;
}
}
}
else {
fprintf(stderr,"OpenJPEG cannot encode raw components with bit depth higher than 16 bits.\n");
return NULL;
}
if (fread(&ch, 1, 1, f)) {
fprintf(stderr,"Warning. End of raw file not reached... processing anyway\n");
@ -2102,8 +2113,12 @@ int imagetoraw(opj_image_t * image, const char *outfile)
ptr = image->comps[compno].data;
for (line = 0; line < h; line++) {
for(row = 0; row < w; row++) {
unsigned char temp;
curr = (signed short int) (*ptr & mask);
fwrite(&curr, sizeof(signed short int), 1, rawFile);
temp = curr >> 8;
fwrite(&temp, 1, 1, rawFile);
temp = curr;
fwrite(&temp, 1, 1, rawFile);
ptr++;
}
}
@ -2115,8 +2130,12 @@ int imagetoraw(opj_image_t * image, const char *outfile)
ptr = image->comps[compno].data;
for (line = 0; line < h; line++) {
for(row = 0; row < w; row++) {
unsigned char temp;
curr = (unsigned short int) (*ptr & mask);
fwrite(&curr, sizeof(unsigned short int), 1, rawFile);
temp = curr >> 8;
fwrite(&temp, 1, 1, rawFile);
temp = curr;
fwrite(&temp, 1, 1, rawFile);
ptr++;
}
}

View File

@ -654,6 +654,11 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete
parameters->tp_on = 0;
parameters->decod_format = -1;
parameters->cod_format = -1;
parameters->tcp_rates[0] = 0;
parameters->tcp_numlayers = 0;
parameters->cp_disto_alloc = 0;
parameters->cp_fixed_alloc = 0;
parameters->cp_fixed_quality = 0;
/* UniPG>> */
#ifdef USE_JPWL
parameters->jpwl_epc_on = false;

View File

@ -1019,7 +1019,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, OPJ_BYTE *dest, OPJ_UINT32 * p_data_writte
}
for
(i = 0; i < 32; ++i)
(i = 0; i < 128; ++i)
{
OPJ_FLOAT64 distoachieved = 0; /* fixed_quality */
thresh = (lo + hi) / 2;