backport rev 1013-1014 from trunk

This commit is contained in:
Mickael Savinaud 2011-10-19 15:45:03 +00:00
parent c1510793e3
commit 1dc6eddf1c
4 changed files with 85 additions and 20 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed ! : changed
+ : added + : added
October 19, 2011
* [mickael] backport rev 1013-1014 from trunk
October 10, 2011 October 10, 2011
* [vincent] fix 'distcheck' rule * [vincent] fix 'distcheck' rule
* [antonin] modified indexer for JPIP, JPP-stream * [antonin] modified indexer for JPIP, JPP-stream

View File

@ -389,7 +389,7 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) {
int imagetotga(opj_image_t * image, const char *outfile) { int imagetotga(opj_image_t * image, const char *outfile) {
int width, height, bpp, x, y; int width, height, bpp, x, y;
opj_bool write_alpha; opj_bool write_alpha;
int i; int i, adjustR, adjustG, adjustB;
unsigned int alpha_channel; unsigned int alpha_channel;
float r,g,b,a; float r,g,b,a;
unsigned char value; unsigned char value;
@ -426,15 +426,19 @@ int imagetotga(opj_image_t * image, const char *outfile) {
scale = 255.0f / (float)((1<<image->comps[0].prec)-1); scale = 255.0f / (float)((1<<image->comps[0].prec)-1);
adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
adjustG = (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
adjustB = (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
for (y=0; y < height; y++) { for (y=0; y < height; y++) {
unsigned int index=y*width; unsigned int index=y*width;
for (x=0; x < width; x++, index++) { for (x=0; x < width; x++, index++) {
r = (float)(image->comps[0].data[index]); r = (float)(image->comps[0].data[index] + adjustR);
if (image->numcomps>2) { if (image->numcomps>2) {
g = (float)(image->comps[1].data[index]); g = (float)(image->comps[1].data[index] + adjustG);
b = (float)(image->comps[2].data[index]); b = (float)(image->comps[2].data[index] + adjustB);
} }
else {// Greyscale ... else {// Greyscale ...
g = r; g = r;

View File

@ -321,7 +321,10 @@ double* parseToleranceValues( char* inArg, const int nbcomp)
} }
if (it_comp != nbcomp) if (it_comp != nbcomp)
{
free(outArgs);
return NULL; return NULL;
}
else else
return outArgs; return outArgs;
} }
@ -407,10 +410,21 @@ opj_image_t* readImageFromFilePGX(char* filename, int nbFilenamePGX, char *separ
// Read the pgx file corresponding to the component // Read the pgx file corresponding to the component
image_read = pgxtoimage(filenameComponentPGX, &parameters); image_read = pgxtoimage(filenameComponentPGX, &parameters);
if (!image_read) if (!image_read)
{ {
fprintf(stderr, "Unable to load pgx file\n"); int it_free_data;
return NULL; fprintf(stderr, "Unable to load pgx file\n");
}
free(param_image_read);
for (it_free_data = 0; it_free_data < it_file; it_free_data++) {
free(data[it_free_data]);
}
free(data);
free(filenameComponentPGX);
return NULL;
}
// Set the image_read parameters // Set the image_read parameters
param_image_read[it_file].x0 = 0; param_image_read[it_file].x0 = 0;
@ -498,10 +512,10 @@ int main(int argc, char **argv)
if( parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE ) if( parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE )
{ {
comparePGXimages_help_display(); comparePGXimages_help_display();
if (!inParam.tabMSEvalues) free(inParam.tabMSEvalues); if (inParam.tabMSEvalues) free(inParam.tabMSEvalues);
if (!inParam.tabPEAKvalues) free(inParam.tabPEAKvalues); if (inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
if (!inParam.base_filename) free(inParam.base_filename); if (inParam.base_filename) free(inParam.base_filename);
if (!inParam.test_filename) free(inParam.test_filename); if (inParam.test_filename) free(inParam.test_filename);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -560,10 +574,10 @@ int main(int argc, char **argv)
} }
else else
{ {
if (!inParam.tabMSEvalues) free(inParam.tabMSEvalues); if (inParam.tabMSEvalues) free(inParam.tabMSEvalues);
if (!inParam.tabPEAKvalues) free(inParam.tabPEAKvalues); if (inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
if (!inParam.base_filename) free(inParam.base_filename); if (inParam.base_filename) free(inParam.base_filename);
if (!inParam.test_filename) free(inParam.test_filename); if (inParam.test_filename) free(inParam.test_filename);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -582,10 +596,10 @@ int main(int argc, char **argv)
} }
else else
{ {
if (!inParam.tabMSEvalues) free(inParam.tabMSEvalues); if (inParam.tabMSEvalues) free(inParam.tabMSEvalues);
if (!inParam.tabPEAKvalues) free(inParam.tabPEAKvalues); if (inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
if (!inParam.base_filename) free(inParam.base_filename); if (inParam.base_filename) free(inParam.base_filename);
if (!inParam.test_filename) free(inParam.test_filename); if (inParam.test_filename) free(inParam.test_filename);
free(filenamePNGbase); free(filenamePNGbase);
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -127,18 +127,52 @@ int main(int argc, char **argv)
if (parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE) if (parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE)
{ {
compareRAWimages_help_display(); compareRAWimages_help_display();
/* Free Memory */
if (inParam.base_filename){
free(inParam.base_filename);
inParam.base_filename = NULL;
}
if (inParam.test_filename){
free(inParam.test_filename);
inParam.test_filename = NULL;
}
return EXIT_FAILURE; return EXIT_FAILURE;
} }
file_test = fopen(inParam.test_filename, "rb"); file_test = fopen(inParam.test_filename, "rb");
if (!file_test) { if (!file_test) {
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.test_filename); fprintf(stderr, "Failed to open %s for reading !!\n", inParam.test_filename);
/* Free Memory */
if (inParam.base_filename){
free(inParam.base_filename);
inParam.base_filename = NULL;
}
if (inParam.test_filename){
free(inParam.test_filename);
inParam.test_filename = NULL;
}
return EXIT_FAILURE; return EXIT_FAILURE;
} }
file_base = fopen(inParam.base_filename, "rb"); file_base = fopen(inParam.base_filename, "rb");
if (!file_base) { if (!file_base) {
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.base_filename); fprintf(stderr, "Failed to open %s for reading !!\n", inParam.base_filename);
/* Free Memory */
if (inParam.base_filename){
free(inParam.base_filename);
inParam.base_filename = NULL;
}
if (inParam.test_filename){
free(inParam.test_filename);
inParam.test_filename = NULL;
}
fclose(file_test);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -179,6 +213,16 @@ int main(int argc, char **argv)
} }
} }
/* Free Memory */
if (inParam.base_filename){
free(inParam.base_filename);
inParam.base_filename = NULL;
}
if (inParam.test_filename){
free(inParam.test_filename);
inParam.test_filename = NULL;
}
fclose(file_test); fclose(file_test);
fclose(file_base); fclose(file_base);