diff --git a/ChangeLog b/ChangeLog index 641636f4..938a89d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/codec/convert.c b/codec/convert.c index ada2af08..cd5c1c5f 100644 --- a/codec/convert.c +++ b/codec/convert.c @@ -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++; } } diff --git a/libopenjpeg/openjpeg.c b/libopenjpeg/openjpeg.c index 574b5135..dbace581 100644 --- a/libopenjpeg/openjpeg.c +++ b/libopenjpeg/openjpeg.c @@ -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; diff --git a/libopenjpeg/tcd.c b/libopenjpeg/tcd.c index 1cfbc5af..d8bd08b6 100644 --- a/libopenjpeg/tcd.c +++ b/libopenjpeg/tcd.c @@ -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;