From 9c911c0e1ee4367207cc9654ef109fb7250c5969 Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Wed, 16 Sep 2015 20:49:45 +0200 Subject: [PATCH 01/21] Update the version number --- doc/man/man1/opj_compress.1 | 2 +- doc/man/man1/opj_decompress.1 | 2 +- doc/man/man1/opj_dump.1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/man/man1/opj_compress.1 b/doc/man/man1/opj_compress.1 index 51e5b1a5..cb37a427 100644 --- a/doc/man/man1/opj_compress.1 +++ b/doc/man/man1/opj_compress.1 @@ -29,7 +29,7 @@ .SP .fi .. -.TH opj_compress 1 "Version 1.4.0" "opj_compress" "converts to jpeg2000 files" +.TH opj_compress 1 "Version 2.1.1" "opj_compress" "converts to jpeg2000 files" .P .SH NAME opj_compress - diff --git a/doc/man/man1/opj_decompress.1 b/doc/man/man1/opj_decompress.1 index 470fd3c1..38a404a4 100644 --- a/doc/man/man1/opj_decompress.1 +++ b/doc/man/man1/opj_decompress.1 @@ -29,7 +29,7 @@ .SP .fi .. -.TH opj_decompress 1 "Version 1.4.0" "opj_decompress" "converts jpeg2000 files" +.TH opj_decompress 1 "Version 2.1.1" "opj_decompress" "converts jpeg2000 files" .P .SH NAME opj_decompress - diff --git a/doc/man/man1/opj_dump.1 b/doc/man/man1/opj_dump.1 index a6033c61..160af63a 100644 --- a/doc/man/man1/opj_dump.1 +++ b/doc/man/man1/opj_dump.1 @@ -29,7 +29,7 @@ .SP .fi .. -.TH opj_dump 1 "Version 1.4.0" "opj_dump" "dumps jpeg2000 files" +.TH opj_dump 1 "Version 2.1.1" "opj_dump" "dumps jpeg2000 files" .P .SH NAME opj_dump - From 6cb56b36f627194fdfb13e306d27925b956af63f Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Wed, 16 Sep 2015 20:54:34 +0200 Subject: [PATCH 02/21] Update opj_decompress man page --- doc/man/man1/opj_decompress.1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/man/man1/opj_decompress.1 b/doc/man/man1/opj_decompress.1 index 38a404a4..1e7b6c54 100644 --- a/doc/man/man1/opj_decompress.1 +++ b/doc/man/man1/opj_decompress.1 @@ -73,9 +73,19 @@ n is the maximum number of quality layers to decode. See LAYERS below) .B \-\^OutFor "ext" (extension for output files) .P +.SH JPIP OPTIONS +Options usable only if the library has been compiled with +.B BUILD_JPIP +.TP +.B -jpip +Embed index table box into the output JP2 file (compulsory for JPIP) +.TP +.B -TP R +Partition a tile into tile parts of different resolution levels (compulsory for JPT-stream) +.P .SH JPWL OPTIONS Options usable only if the library has been compiled with -.B -DUSE_JPWL +.B BUILD_JPWL .TP .B -W c\fR[=Nc] (Nc is the number of expected components in the codestream; default:3) .TP From a4e93c3b0af1c42770206b5d25014a05a60ec8f5 Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 17 Sep 2015 12:31:18 +0200 Subject: [PATCH 03/21] fix resource leak in opj_j2k_decode_one_tile Fixes #597 --- src/lib/openjp2/j2k.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index d487d89d..e733c645 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -9668,14 +9668,14 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k, * so move to the last SOT read */ if ( !(opj_stream_read_seek(p_stream, p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos+2, p_manager)) ){ opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n"); - opj_free(l_current_data); + opj_free(l_current_data); return OPJ_FALSE; } } else{ if ( !(opj_stream_read_seek(p_stream, p_j2k->cstr_index->tile_index[l_tile_no_to_dec].tp_index[0].start_pos+2, p_manager)) ) { opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n"); - opj_free(l_current_data); + opj_free(l_current_data); return OPJ_FALSE; } } @@ -9733,6 +9733,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k, /* move into the codestream to the the first SOT (FIXME or not move?)*/ if (!(opj_stream_read_seek(p_stream, p_j2k->cstr_index->main_head_end + 2, p_manager) ) ) { opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n"); + opj_free(l_current_data); return OPJ_FALSE; } break; From c16c91797f4b15eb55d56f85fd497d588331e71f Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 17 Sep 2015 12:41:41 +0200 Subject: [PATCH 04/21] Fix resource leak in opj_j2k_encode Fixes #598 --- src/lib/openjp2/j2k.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index e733c645..ec3635b6 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -9999,11 +9999,15 @@ OPJ_BOOL opj_j2k_encode(opj_j2k_t * p_j2k, /* now copy this data into the tile component */ if (! opj_tcd_copy_tile_data(p_j2k->m_tcd,l_current_data,l_current_tile_size)) { opj_event_msg(p_manager, EVT_ERROR, "Size mismatch between tile data and sent data." ); + opj_free(l_current_data); return OPJ_FALSE; } } if (! opj_j2k_post_write_tile (p_j2k,p_stream,p_manager)) { + if (l_current_data) { + opj_free(l_current_data); + } return OPJ_FALSE; } } From 55dbf8acff9afab1591b6a094b744d8426a32dd4 Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 17 Sep 2015 12:46:42 +0200 Subject: [PATCH 05/21] Fix resource leak in opj_j2k_create_cstr_index Fixes #599 --- src/lib/openjp2/j2k.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index ec3635b6..f7a1d764 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -8603,8 +8603,10 @@ static opj_codestream_index_t* opj_j2k_create_cstr_index(void) cstr_index->marknum = 0; cstr_index->marker = (opj_marker_info_t*) opj_calloc(cstr_index->maxmarknum, sizeof(opj_marker_info_t)); - if (!cstr_index-> marker) + if (!cstr_index-> marker) { + opj_free(cstr_index); return NULL; + } cstr_index->tile_index = NULL; From 281537851b369e51bdaa8445014998c6b86c962b Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 17 Sep 2015 14:24:06 +0200 Subject: [PATCH 06/21] Add Coverity Scan status --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 65d37979..17b8957b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ Anyone. As the OpenJPEG code is released under the [2-clauses BSD license](https API Documentation needs a major refactoring. Meanwhile, you can check [installation](https://github.com/uclouvain/openjpeg/wiki/Installation) instructions and [codec documentation](https://github.com/uclouvain/openjpeg/wiki/DocJ2KCodec). ## Current Status -* Build status: [![Build Status](https://travis-ci.org/uclouvain/openjpeg.svg?branch=master)](https://travis-ci.org/uclouvain/openjpeg) +[![Build Status](https://travis-ci.org/uclouvain/openjpeg.svg?branch=master)](https://travis-ci.org/uclouvain/openjpeg) + +[![Coverity Scan Build Status](https://scan.coverity.com/projects/6383/badge.svg)](https://scan.coverity.com/projects/uclouvain-openjpeg) ## Who are the developers ? From faf63fddad6efab9fa4dcb14cd290766722a7eec Mon Sep 17 00:00:00 2001 From: mayeut Date: Wed, 23 Sep 2015 21:09:19 +0200 Subject: [PATCH 07/21] Fix warning in rle4 decoding --- src/bin/jp2/convertbmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/jp2/convertbmp.c b/src/bin/jp2/convertbmp.c index 1131a599..0678d9d3 100644 --- a/src/bin/jp2/convertbmp.c +++ b/src/bin/jp2/convertbmp.c @@ -572,7 +572,7 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN); for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) { - *pix = (j&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f); + *pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU)); } } else { /* absolute mode */ @@ -598,7 +598,7 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride if((j&1) == 0) { c1 = (OPJ_UINT8)getc(IN); } - *pix = (j&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f); + *pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU)); } if(((c&3) == 1) || ((c&3) == 2)) { /* skip padding byte */ getc(IN); From f82d7f3a63a99997449b15390d0c3f2fc6159d9c Mon Sep 17 00:00:00 2001 From: mayeut Date: Wed, 23 Sep 2015 21:17:06 +0200 Subject: [PATCH 08/21] Use buffer on stack to read TGA header Fixes a potential leak Fixes #601 --- src/bin/jp2/convert.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c index a894a369..1ccb34f8 100644 --- a/src/bin/jp2/convert.c +++ b/src/bin/jp2/convert.c @@ -573,7 +573,7 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel, unsigned int *width, unsigned int *height, int *flip_image) { int palette_size; - unsigned char *tga ; + unsigned char tga[TGA_HEADER_SIZE]; unsigned char id_len, /*cmap_type,*/ image_type; unsigned char pixel_depth, image_desc; unsigned short /*cmap_index,*/ cmap_len, cmap_entry_size; @@ -581,7 +581,6 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel, if (!bits_per_pixel || !width || !height || !flip_image) return 0; - tga = (unsigned char*)malloc(18); if ( fread(tga, TGA_HEADER_SIZE, 1, fp) != 1 ) { @@ -605,8 +604,6 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel, pixel_depth = (unsigned char)tga[16]; image_desc = (unsigned char)tga[17]; - free(tga); - *bits_per_pixel = (unsigned int)pixel_depth; *width = (unsigned int)image_w; *height = (unsigned int)image_h; From f9df8ba19a92d5c97532c8d52c034beabe957cf7 Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 24 Sep 2015 23:32:03 +0200 Subject: [PATCH 09/21] Fix some resource leaks --- src/bin/jp2/convert.c | 71 ++++++++++++++++++++++++++++---------- src/bin/jp2/convertbmp.c | 1 + src/bin/jp2/opj_compress.c | 15 +++++++- 3 files changed, 68 insertions(+), 19 deletions(-) diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c index 1ccb34f8..1fd64ee7 100644 --- a/src/bin/jp2/convert.c +++ b/src/bin/jp2/convert.c @@ -734,12 +734,16 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) { return 0; } - if (!tga_readheader(f, &pixel_bit_depth, &image_width, &image_height, &flip_image)) + if (!tga_readheader(f, &pixel_bit_depth, &image_width, &image_height, &flip_image)) { + fclose(f); return NULL; + } /* We currently only support 24 & 32 bit tga's ... */ - if (!((pixel_bit_depth == 24) || (pixel_bit_depth == 32))) + if (!((pixel_bit_depth == 24) || (pixel_bit_depth == 32))) { + fclose(f); return NULL; + } /* initialize image components */ memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t)); @@ -772,8 +776,11 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) { /* create the image */ image = opj_image_create((OPJ_UINT32)numcomps, &cmptparm[0], color_space); - if (!image) + if (!image) { + fclose(f); return NULL; + } + /* set image offset and reference grid */ image->x0 = (OPJ_UINT32)parameters->image_offset_x0; @@ -801,18 +808,21 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) { { fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); opj_image_destroy(image); + fclose(f); return NULL; } if ( !fread(&g, 1, 1, f) ) { fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); opj_image_destroy(image); + fclose(f); return NULL; } if ( !fread(&r, 1, 1, f) ) { fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); opj_image_destroy(image); + fclose(f); return NULL; } @@ -831,24 +841,28 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) { { fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); opj_image_destroy(image); + fclose(f); return NULL; } if ( !fread(&g, 1, 1, f) ) { fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); opj_image_destroy(image); + fclose(f); return NULL; } if ( !fread(&r, 1, 1, f) ) { fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); opj_image_destroy(image); + fclose(f); return NULL; } if ( !fread(&a, 1, 1, f) ) { fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); opj_image_destroy(image); + fclose(f); return NULL; } @@ -863,6 +877,7 @@ opj_image_t* tgatoimage(const char *filename, opj_cparameters_t *parameters) { fprintf(stderr, "Currently unsupported bit depth : %s\n", filename); } } + fclose(f); return image; } @@ -889,6 +904,7 @@ int imagetotga(opj_image_t * image, const char *outfile) { if ((image->comps[0].dx != image->comps[i+1].dx) ||(image->comps[0].dy != image->comps[i+1].dy) ||(image->comps[0].prec != image->comps[i+1].prec)) { + fclose(fdest); fprintf(stderr, "Unable to create a tga file with such J2K image charateristics."); return 1; } @@ -1081,6 +1097,7 @@ opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters) { fseek(f, 0, SEEK_SET); if( fscanf(f, "PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d",temp,&endian1,&endian2,signtmp,&prec,temp,&w,temp,&h) != 9){ + fclose(f); fprintf(stderr, "ERROR: Failed to read the right number of element from the fscanf() function!\n"); return NULL; } @@ -1098,6 +1115,7 @@ opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters) { } else if (endian2=='M' && endian1=='L') { bigendian = 0; } else { + fclose(f); fprintf(stderr, "Bad pgx header, please check input file\n"); return NULL; } @@ -1212,7 +1230,7 @@ int imagetopgx(opj_image_t * image, const char *outfile) FILE *fdest = NULL; for (compno = 0; compno < image->numcomps; compno++) - { + { opj_image_comp_t *comp = &image->comps[compno]; char bname[256]; /* buffer for name */ char *name = bname; /* pointer */ @@ -1223,25 +1241,30 @@ int imagetopgx(opj_image_t * image, const char *outfile) const size_t total = dotpos + 1 + 1 + 4; /* '-' + '[1-3]' + '.pgx' */ if( outfile[dotpos] != '.' ) - { + { /* `pgx` was recognized but there is no dot at expected position */ fprintf(stderr, "ERROR -> Impossible happen." ); goto fin; - } + } if( total > 256 ) - { + { name = (char*)malloc(total+1); - } + if (name == NULL) { + goto fin; + } + } strncpy(name, outfile, dotpos); sprintf(name+dotpos, "_%d.pgx", compno); fdest = fopen(name, "wb"); /* dont need name anymore */ - if( total > 256 ) free(name); + if (!fdest) - { + { + fprintf(stderr, "ERROR -> failed to open %s for writing\n", name); + if( total > 256 ) free(name); goto fin; - } + } w = (int)image->comps[compno].w; h = (int)image->comps[compno].h; @@ -1257,26 +1280,28 @@ int imagetopgx(opj_image_t * image, const char *outfile) nbytes = 4; for (i = 0; i < w * h; i++) - { + { /* FIXME: clamp func is being called within a loop */ const int val = clamp(image->comps[compno].data[i], (int)comp->prec, (int)comp->sgnd); for (j = nbytes - 1; j >= 0; j--) - { + { int v = (int)(val >> (j * 8)); unsigned char byte = (unsigned char)v; res = fwrite(&byte, 1, 1, fdest); if( res < 1 ) - { + { fprintf(stderr, "failed to write 1 byte for %s\n", name); + if( total > 256 ) free(name); goto fin; - } - } - } + } + } + } + if( total > 256 ) free(name); fclose(fdest); fdest = NULL; - } + } fails = 0; fin: if(fdest) fclose(fdest); @@ -1650,6 +1675,7 @@ opj_image_t* pnmtoimage(const char *filename, opj_cparameters_t *parameters) { { fprintf(stderr, "\nError: fread return a number of element different from the expected.\n"); opj_image_destroy(image); + fclose(fp); return NULL; } if(one) @@ -2003,6 +2029,7 @@ static opj_image_t* rawtoimage_common(const char *filename, opj_cparameters_t *p if (!cmptparm) { fprintf(stderr, "Failed to allocate image components parameters !!\n"); fprintf(stderr,"Aborting\n"); + fclose(f); return NULL; } /* initialize image components */ @@ -2036,6 +2063,8 @@ static opj_image_t* rawtoimage_common(const char *filename, opj_cparameters_t *p for (i = 0; i < nloop; i++) { if (!fread(&value, 1, 1, f)) { fprintf(stderr,"Error reading raw file. End of file probably reached.\n"); + opj_image_destroy(image); + fclose(f); return NULL; } image->comps[compno].data[i] = raw_cp->rawSigned?(char)value:value; @@ -2052,10 +2081,14 @@ static opj_image_t* rawtoimage_common(const char *filename, opj_cparameters_t *p unsigned char temp2; if (!fread(&temp1, 1, 1, f)) { fprintf(stderr,"Error reading raw file. End of file probably reached.\n"); + opj_image_destroy(image); + fclose(f); return NULL; } if (!fread(&temp2, 1, 1, f)) { fprintf(stderr,"Error reading raw file. End of file probably reached.\n"); + opj_image_destroy(image); + fclose(f); return NULL; } if( big_endian ) @@ -2072,6 +2105,8 @@ static opj_image_t* rawtoimage_common(const char *filename, opj_cparameters_t *p } else { fprintf(stderr,"OpenJPEG cannot encode raw components with bit depth higher than 16 bits.\n"); + opj_image_destroy(image); + fclose(f); return NULL; } diff --git a/src/bin/jp2/convertbmp.c b/src/bin/jp2/convertbmp.c index 0678d9d3..78ca4af5 100644 --- a/src/bin/jp2/convertbmp.c +++ b/src/bin/jp2/convertbmp.c @@ -729,6 +729,7 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters) image = opj_image_create(numcmpts, &cmptparm[0], (numcmpts == 1U) ? OPJ_CLRSPC_GRAY : OPJ_CLRSPC_SRGB); if(!image) { fclose(IN); + free(pData); return NULL; } if (numcmpts == 4U) { diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c index ee473ce3..d3dc62ff 100644 --- a/src/bin/jp2/opj_compress.c +++ b/src/bin/jp2/opj_compress.c @@ -391,6 +391,7 @@ static unsigned int get_num_images(char *imgdirpath){ continue; num_images++; } + closedir(dir); return num_images; } @@ -416,6 +417,7 @@ static int load_images(dircnt_t *dirptr, char *imgdirpath){ strcpy(dirptr->filename[i],content->d_name); i++; } + closedir(dir); return 0; } @@ -1058,9 +1060,16 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param lStrLen = (size_t)ftell(lFile); fseek(lFile,0,SEEK_SET); lMatrix = (char *) malloc(lStrLen + 1); + if (lMatrix == NULL) { + fclose(lFile); + return 1; + } lStrFread = fread(lMatrix, 1, lStrLen, lFile); fclose(lFile); - if( lStrLen != lStrFread ) return 1; + if( lStrLen != lStrFread ) { + free(lMatrix); + return 1; + } lMatrix[lStrLen] = 0; lCurrentPtr = lMatrix; @@ -1080,6 +1089,10 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param lMctComp = lNbComp * lNbComp; lTotalComp = lMctComp + lNbComp; lSpace = (float *) malloc((size_t)lTotalComp * sizeof(float)); + if(lSpace == NULL) { + free(lMatrix); + return 1; + } lCurrentDoublePtr = lSpace; for (i2=0;i2 Date: Fri, 25 Sep 2015 00:08:34 +0200 Subject: [PATCH 10/21] Fix resource leaks & unchecked resource allocations --- src/bin/jp2/convertbmp.c | 4 ++++ src/bin/jp2/convertpng.c | 2 +- src/bin/jp2/opj_compress.c | 9 ++++++--- src/bin/jp2/opj_decompress.c | 2 +- src/bin/jp2/opj_dump.c | 2 ++ 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/bin/jp2/convertbmp.c b/src/bin/jp2/convertbmp.c index 78ca4af5..910574b8 100644 --- a/src/bin/jp2/convertbmp.c +++ b/src/bin/jp2/convertbmp.c @@ -903,6 +903,10 @@ int imagetobmp(opj_image_t * image, const char *outfile) { <<-- <<-- <<-- <<-- */ fdest = fopen(outfile, "wb"); + if (!fdest) { + fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile); + return 1; + } w = (int)image->comps[0].w; h = (int)image->comps[0].h; diff --git a/src/bin/jp2/convertpng.c b/src/bin/jp2/convertpng.c index 5a72d9fe..0999edbf 100644 --- a/src/bin/jp2/convertpng.c +++ b/src/bin/jp2/convertpng.c @@ -486,7 +486,7 @@ fin: } fclose(writer); - if(fails) remove(write_idf); + if(fails) (void)remove(write_idf); /* ignore return value */ return fails; }/* imagetopng() */ diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c index d3dc62ff..e5f98532 100644 --- a/src/bin/jp2/opj_compress.c +++ b/src/bin/jp2/opj_compress.c @@ -456,7 +456,7 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_c if (parameters->decod_format == -1) return 1; sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename); - strncpy(parameters->infile, infilename, sizeof(infilename)); + strncpy(parameters->infile, infilename, sizeof(infilename) - 1U); /*Set output file*/ strcpy(temp_ofname,get_file_name(image_filename)); @@ -466,7 +466,7 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_c } if(img_fol->set_out_format==1){ sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format); - strncpy(parameters->outfile, outfilename, sizeof(outfilename)); + strncpy(parameters->outfile, outfilename, sizeof(outfilename) - 1U); } return 0; } @@ -612,6 +612,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param substr2++; /* skip '@' character */ } substr1 = (char*) malloc((len+1)*sizeof(char)); + if (substr1 == NULL) { + return 1; + } memcpy(substr1,opj_optarg,len); substr1[len] = '\0'; if (sscanf(substr1, "%d,%d,%d,%d,%c", &width, &height, &ncomp, &bitdepth, &signo) == 5) { @@ -663,7 +666,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param } } } - if (substr1) free(substr1); + free(substr1); if (wrong) { fprintf(stderr,"\nError: invalid raw image parameters\n"); fprintf(stderr,"Please use the Format option -F:\n"); diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c index da566ac2..bd755c82 100644 --- a/src/bin/jp2/opj_decompress.c +++ b/src/bin/jp2/opj_decompress.c @@ -1550,7 +1550,7 @@ int main(int argc, char **argv) /* destroy the codestream index */ opj_destroy_cstr_index(&cstr_index); - if(failed) remove(parameters.outfile); + if(failed) (void)remove(parameters.outfile); /* ignore return value */ } destroy_parameters(¶meters); if (numDecompressedImages) { diff --git a/src/bin/jp2/opj_dump.c b/src/bin/jp2/opj_dump.c index a85cfe90..4005f1c2 100644 --- a/src/bin/jp2/opj_dump.c +++ b/src/bin/jp2/opj_dump.c @@ -134,6 +134,7 @@ static int get_num_images(char *imgdirpath){ continue; num_images++; } + closedir(dir); return num_images; } @@ -160,6 +161,7 @@ static int load_images(dircnt_t *dirptr, char *imgdirpath){ strcpy(dirptr->filename[i],content->d_name); i++; } + closedir(dir); return 0; } From 4da7e9617fd28bee0b8c7509a00759ca9da6fb32 Mon Sep 17 00:00:00 2001 From: mayeut Date: Fri, 25 Sep 2015 00:39:05 +0200 Subject: [PATCH 11/21] Fix resource leak --- src/bin/jp2/opj_decompress.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c index bd755c82..c27dc201 100644 --- a/src/bin/jp2/opj_decompress.c +++ b/src/bin/jp2/opj_decompress.c @@ -361,6 +361,7 @@ int get_num_images(char *imgdirpath){ continue; num_images++; } + closedir(dir); return num_images; } @@ -387,6 +388,7 @@ int load_images(dircnt_t *dirptr, char *imgdirpath){ strcpy(dirptr->filename[i],content->d_name); i++; } + closedir(dir); return 0; } From 838dfb8058df62af44905e1fa3936d989844effc Mon Sep 17 00:00:00 2001 From: mayeut Date: Fri, 25 Sep 2015 22:04:58 +0200 Subject: [PATCH 12/21] Provide safer string copy than strncpy As per @boxerab suggestion in commit b9ca882749597e4943e609daba1d3c27694fe2ff --- src/bin/common/opj_string.h | 72 ++++++++++++++++++++++++++++++++++++ src/bin/jp2/CMakeLists.txt | 1 + src/bin/jp2/opj_compress.c | 32 +++++++++++----- src/bin/jp2/opj_decompress.c | 49 +++++++++++++++--------- src/bin/jp2/opj_dump.c | 20 +++++++--- 5 files changed, 141 insertions(+), 33 deletions(-) create mode 100644 src/bin/common/opj_string.h diff --git a/src/bin/common/opj_string.h b/src/bin/common/opj_string.h new file mode 100644 index 00000000..8829926a --- /dev/null +++ b/src/bin/common/opj_string.h @@ -0,0 +1,72 @@ +/* + * The copyright in this software is being made available under the 2-clauses + * BSD License, included below. This software may be subject to other third + * party and contributor rights, including patent rights, and no such rights + * are granted under this license. + * + * Copyright (c) 2015, Matthieu Darbois + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef OPJ_STRING_H +#define OPJ_STRING_H + +#include +#include + +/* strnlen is not standard, strlen_s is C11... */ +/* keep in mind there still is a buffer read overflow possible */ +static size_t opj_strnlen_s(const char *src, size_t max_len) +{ + size_t len; + + if (src == NULL) { + return 0U; + } + for (len = 0U; (*src != '\0') && (len < max_len); src++, len++); + return len; +} + +/* should be equivalent to C11 function except for the handler */ +/* keep in mind there still is a buffer read overflow possible */ +static int opj_strcpy_s(char* dst, size_t dst_size, const char* src) +{ + size_t src_len = 0U; + if ((dst == NULL) || (dst_size == 0U)) { + return EINVAL; + } + if (src == NULL) { + dst[0] = '\0'; + return EINVAL; + } + src_len = opj_strnlen_s(src, dst_size); + if (src_len >= dst_size) { + return ERANGE; + } + memcpy(dst, src, src_len); + dst[src_len] = '\0'; + return 0; +} + +#endif /* OPJ_STRING_H */ diff --git a/src/bin/jp2/CMakeLists.txt b/src/bin/jp2/CMakeLists.txt index 7e2476df..d583c2e6 100644 --- a/src/bin/jp2/CMakeLists.txt +++ b/src/bin/jp2/CMakeLists.txt @@ -11,6 +11,7 @@ set(common_SRCS ${OPENJPEG_SOURCE_DIR}/src/bin/common/color.h ${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c ${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.h + ${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_string.h ) if(OPJ_HAVE_LIBTIFF) diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c index e5f98532..9d690a56 100644 --- a/src/bin/jp2/opj_compress.c +++ b/src/bin/jp2/opj_compress.c @@ -69,6 +69,7 @@ #include "index.h" #include "format_defs.h" +#include "opj_string.h" typedef struct dircnt{ /** Buffer for holding images read from Directory*/ @@ -456,8 +457,10 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_c if (parameters->decod_format == -1) return 1; sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename); - strncpy(parameters->infile, infilename, sizeof(infilename) - 1U); - + if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile), infilename) != 0) { + return 1; + } + /*Set output file*/ strcpy(temp_ofname,get_file_name(image_filename)); while((temp_p = strtok(NULL,".")) != NULL){ @@ -466,7 +469,9 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_c } if(img_fol->set_out_format==1){ sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format); - strncpy(parameters->outfile, outfilename, sizeof(outfilename) - 1U); + if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile), outfilename) != 0) { + return 1; + } } return 0; } @@ -474,7 +479,7 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_c /* ------------------------------------------------------------------------------------ */ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters, - img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename) { + img_fol_t *img_fol, raw_cparameters_t *raw_cp, char *indexfilename, size_t indexfilename_size) { OPJ_UINT32 i, j; int totlen, c; opj_option_t long_option[]={ @@ -528,7 +533,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param infile); return 1; } - strncpy(parameters->infile, infile, sizeof(parameters->infile)-1); + if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile), infile) != 0) { + return 1; + } } break; @@ -546,7 +553,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param fprintf(stderr, "Unknown output format image %s [only *.j2k, *.j2c or *.jp2]!! \n", outfile); return 1; } - strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1); + if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile), outfile) != 0) { + return 1; + } } break; @@ -812,8 +821,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param case 'x': /* creation of index file */ { - char *index = opj_optarg; - strncpy(indexfilename, index, OPJ_PATH_LEN); + if (opj_strcpy_s(indexfilename, indexfilename_size, opj_optarg) != 0) { + return 1; + } /* FIXME ADE INDEX >> */ fprintf(stderr, "[WARNING] Index file generation is currently broken.\n" @@ -1133,7 +1143,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param /* we need to enable indexing */ if (!indexfilename || !*indexfilename) { - strncpy(indexfilename, JPWL_PRIVATEINDEX_NAME, OPJ_PATH_LEN); + if (opj_strcpy_s(indexfilename, indexfilename_size, JPWL_PRIVATEINDEX_NAME) != 0) { + return 1; + } } /* search for different protection methods */ @@ -1622,7 +1634,7 @@ int main(int argc, char **argv) { /* parse input and get user encoding parameters */ parameters.tcp_mct = (char) 255; /* This will be set later according to the input image or the provided option */ - if(parse_cmdline_encoder(argc, argv, ¶meters,&img_fol, &raw_cp, indexfilename) == 1) { + if(parse_cmdline_encoder(argc, argv, ¶meters,&img_fol, &raw_cp, indexfilename, sizeof(indexfilename)) == 1) { return 1; } diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c index c27dc201..3db36ebe 100644 --- a/src/bin/jp2/opj_decompress.c +++ b/src/bin/jp2/opj_decompress.c @@ -75,6 +75,7 @@ #include "color.h" #include "format_defs.h" +#include "opj_string.h" typedef struct dircnt{ /** Buffer for holding images read from Directory*/ @@ -121,6 +122,8 @@ typedef struct opj_decompress_params int decod_format; /** output file format 0: PGX, 1: PxM, 2: BMP */ int cod_format; + /** index file name */ + char indexfilename[OPJ_PATH_LEN]; /** Decoding area left boundary */ OPJ_UINT32 DA_x0; @@ -157,7 +160,7 @@ int get_file_format(const char *filename); char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_decompress_parameters *parameters); static int infile_format(const char *fname); -int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *parameters,img_fol_t *img_fol, char *indexfilename); +int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *parameters,img_fol_t *img_fol); int parse_DA_values( char* inArg, unsigned int *DA_x0, unsigned int *DA_y0, unsigned int *DA_x1, unsigned int *DA_y1); static opj_image_t* convert_gray_to_rgb(opj_image_t* original); @@ -429,7 +432,9 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_decompre parameters->decod_format = infile_format(infilename); if (parameters->decod_format == -1) return 1; - strncpy(parameters->infile, infilename, sizeof(infilename)); + if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile), infilename) != 0) { + return 1; + } /*Set output file*/ strcpy(temp_ofname,strtok(image_filename,".")); @@ -439,7 +444,9 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_decompre } if(img_fol->set_out_format==1){ sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format); - strncpy(parameters->outfile, outfilename, sizeof(outfilename)); + if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile), outfilename) != 0) { + return 1; + } } return 0; } @@ -505,7 +512,7 @@ static int infile_format(const char *fname) * Parse the command line */ /* -------------------------------------------------------------------------- */ -int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *parameters,img_fol_t *img_fol, char *indexfilename) { +int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *parameters,img_fol_t *img_fol) { /* parse the command line */ int totlen, c; opj_option_t long_option[]={ @@ -561,7 +568,10 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para infile); return 1; } - strncpy(parameters->infile, infile, sizeof(parameters->infile)-1); + if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile), infile) != 0) { + fprintf(stderr, "[ERROR] Path is too long\n"); + return 1; + } } break; @@ -592,7 +602,10 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile); return 1; } - strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1); + if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile), outfile) != 0) { + fprintf(stderr, "[ERROR] Path is too long\n"); + return 1; + } } break; @@ -676,11 +689,14 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para case 'd': /* Input decode ROI */ { - int size_optarg = (int)strlen(opj_optarg) + 1; - char *ROI_values = (char*) malloc((size_t)size_optarg); + size_t size_optarg = (size_t)strlen(opj_optarg) + 1U; + char *ROI_values = (char*) malloc(size_optarg); + if (ROI_values == NULL) { + fprintf(stderr, "[ERROR] Couldn't allocate memory\n"); + return 1; + } ROI_values[0] = '\0'; - strncpy(ROI_values, opj_optarg, strlen(opj_optarg)); - ROI_values[strlen(opj_optarg)] = '\0'; + memcpy(ROI_values, opj_optarg, size_optarg); /*printf("ROI_values = %s [%d / %d]\n", ROI_values, strlen(ROI_values), size_optarg ); */ parse_DA_values( ROI_values, ¶meters->DA_x0, ¶meters->DA_y0, ¶meters->DA_x1, ¶meters->DA_y1); @@ -701,8 +717,10 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para case 'x': /* Creation of index file */ { - char *index = opj_optarg; - strncpy(indexfilename, index, OPJ_PATH_LEN); + if (opj_strcpy_s(parameters->indexfilename, sizeof(parameters->indexfilename), opj_optarg) != 0) { + fprintf(stderr, "[ERROR] Path is too long\n"); + return 1; + } } break; @@ -1167,8 +1185,6 @@ int main(int argc, char **argv) opj_codec_t* l_codec = NULL; /* Handle to a decompressor */ opj_codestream_index_t* cstr_index = NULL; - char indexfilename[OPJ_PATH_LEN]; /* index file name */ - OPJ_INT32 num_images, imageno; img_fol_t img_fol; dircnt_t *dirptr = NULL; @@ -1179,14 +1195,11 @@ int main(int argc, char **argv) /* set decoding parameters to default values */ set_default_parameters(¶meters); - /* FIXME Initialize indexfilename and img_fol */ - *indexfilename = 0; - /* Initialize img_fol */ memset(&img_fol,0,sizeof(img_fol_t)); /* parse input and get user encoding parameters */ - if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) { + if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) { destroy_parameters(¶meters); return EXIT_FAILURE; } diff --git a/src/bin/jp2/opj_dump.c b/src/bin/jp2/opj_dump.c index 4005f1c2..562fd5a5 100644 --- a/src/bin/jp2/opj_dump.c +++ b/src/bin/jp2/opj_dump.c @@ -57,6 +57,7 @@ #include "index.h" #include "format_defs.h" +#include "opj_string.h" typedef struct dircnt{ /** Buffer for holding images read from Directory*/ @@ -196,7 +197,9 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_d if (parameters->decod_format == -1) return 1; sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename); - strncpy(parameters->infile, infilename, sizeof(infilename)); + if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile), infilename) != 0) { + return 1; + } /*Set output file*/ strcpy(temp_ofname,strtok(image_filename,".")); @@ -206,7 +209,9 @@ static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_d } if(img_fol->set_out_format==1){ sprintf(outfilename,"%s/%s.%s",img_fol->imgdirpath,temp_ofname,img_fol->out_format); - strncpy(parameters->outfile, outfilename, sizeof(outfilename)); + if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile), outfilename) != 0) { + return 1; + } } return 0; } @@ -303,7 +308,10 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param infile); return 1; } - strncpy(parameters->infile, infile, sizeof(parameters->infile)-1); + if (opj_strcpy_s(parameters->infile, sizeof(parameters->infile), infile) != 0) { + fprintf(stderr, "[ERROR] Path is too long\n"); + return 1; + } } break; @@ -311,8 +319,10 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param case 'o': /* output file */ { - char *outfile = opj_optarg; - strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1); + if (opj_strcpy_s(parameters->outfile, sizeof(parameters->outfile), opj_optarg) != 0) { + fprintf(stderr, "[ERROR] Path is too long\n"); + return 1; + } } break; From 99fc1ab306f9db0085adf648369404ce8aae22a9 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 29 Sep 2015 05:55:43 +0200 Subject: [PATCH 13/21] Fix typos in comments and string Most typos were found by codespell. Signed-off-by: Stefan Weil --- cmake/CTestCustom.cmake.in | 2 +- doc/openjpip.dox.in | 2 +- src/bin/jp2/convert.c | 2 +- src/bin/jp2/opj_decompress.c | 6 +++--- src/bin/jp2/windirent.h | 6 +++--- src/bin/jp3d/windirent.h | 6 +++--- src/bin/jpwl/convert.c | 2 +- src/bin/jpwl/opj_jpwl_compress.c | 2 +- src/bin/jpwl/windirent.h | 6 +++--- src/bin/mj2/meta_out.c | 4 ++-- src/bin/mj2/mj2_to_metadata.c | 2 +- src/bin/mj2/opj_mj2_wrap.c | 2 +- src/bin/wx/OPJViewer/source/readmebefore.txt | 2 +- src/lib/openjp2/cio.h | 20 ++++++++++---------- src/lib/openjp2/dwt.h | 4 ++-- src/lib/openjp2/indexbox_manager.h | 2 +- src/lib/openjp2/invert.c | 2 +- src/lib/openjp2/j2k.c | 6 +++--- src/lib/openjp2/jp2.c | 8 ++++---- src/lib/openjp2/jp2.h | 2 +- src/lib/openjp2/mct.c | 4 ++-- src/lib/openjp2/openjpeg.h | 6 +++--- src/lib/openjp2/opj_malloc.h | 2 +- src/lib/openjp2/pi.h | 2 +- src/lib/openjp2/tcd.h | 2 +- src/lib/openjp3d/cio.h | 4 ++-- src/lib/openjp3d/dwt.c | 12 ++++++------ src/lib/openjp3d/dwt.h | 4 ++-- src/lib/openjp3d/mct.c | 4 ++-- src/lib/openjp3d/openjp3d.h | 2 +- src/lib/openjp3d/pi.h | 2 +- src/lib/openjpip/cachemodel_manager.h | 2 +- src/lib/openjpip/jpip_parser.c | 2 +- src/lib/openjpip/target_manager.h | 2 +- src/lib/openjpwl/jpwl.h | 2 +- src/lib/openjpwl/rs.c | 4 ++-- src/lib/openmj2/cio.h | 2 +- src/lib/openmj2/dwt.h | 4 ++-- src/lib/openmj2/jp2.h | 2 +- src/lib/openmj2/mct.c | 4 ++-- src/lib/openmj2/openjpeg.h | 2 +- src/lib/openmj2/opj_malloc.h | 2 +- src/lib/openmj2/pi.h | 2 +- tests/nonregression/CMakeLists.txt | 2 +- tests/nonregression/test_suite.ctest.in | 2 +- wrapping/java/openjp2/JavaOpenJPEG.c | 8 ++++---- wrapping/java/openjp2/JavaOpenJPEGDecoder.c | 12 ++++++------ 47 files changed, 93 insertions(+), 93 deletions(-) diff --git a/cmake/CTestCustom.cmake.in b/cmake/CTestCustom.cmake.in index a8cb57ae..70e045da 100644 --- a/cmake/CTestCustom.cmake.in +++ b/cmake/CTestCustom.cmake.in @@ -30,7 +30,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION # java also warns about deprecated API ".*java.*deprecation" ".*deprecation.*" - # supress warnings caused by 3rd party libs: + # suppress warnings caused by 3rd party libs: ".*thirdparty.*" "libtiff.*has no symbols" "libpng.*has no symbols" diff --git a/doc/openjpip.dox.in b/doc/openjpip.dox.in index e54ca75d..09ed9073 100644 --- a/doc/openjpip.dox.in +++ b/doc/openjpip.dox.in @@ -64,7 +64,7 @@ * * * \section sysarchtect System Architecture - * JPIP protocol is implimented between the JPIP server program (opj_server) and the JPIP client java program (opj_viewer).\n + * JPIP protocol is implemented between the JPIP server program (opj_server) and the JPIP client java program (opj_viewer).\n * Figure below represents the overview of our system architecture.\n * The JPIP server parses JPIP query and sends corresponding JPT/JPP-stream. * The JPIP client viewer is an image viewer with GUI to publish JPIP requests and receive JPT/JPP-stream.\n diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c index 1fd64ee7..1a18711c 100644 --- a/src/bin/jp2/convert.c +++ b/src/bin/jp2/convert.c @@ -1256,7 +1256,7 @@ int imagetopgx(opj_image_t * image, const char *outfile) strncpy(name, outfile, dotpos); sprintf(name+dotpos, "_%d.pgx", compno); fdest = fopen(name, "wb"); - /* dont need name anymore */ + /* don't need name anymore */ if (!fdest) { diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c index 3db36ebe..04803e0e 100644 --- a/src/bin/jp2/opj_decompress.c +++ b/src/bin/jp2/opj_decompress.c @@ -1108,7 +1108,7 @@ static opj_image_t* upsample_image_components(opj_image_t* original) l_dst += l_new_cmp->w; } - if(l_new_cmp->h > (l_org_cmp->dy - 1U)) { /* check substraction overflow for really small images */ + if(l_new_cmp->h > (l_org_cmp->dy - 1U)) { /* check subtraction overflow for really small images */ for (; y < l_new_cmp->h - (l_org_cmp->dy - 1U); y += l_org_cmp->dy) { OPJ_UINT32 x, dy; OPJ_UINT32 xorg; @@ -1117,7 +1117,7 @@ static opj_image_t* upsample_image_components(opj_image_t* original) for (x = 0U; x < xoff; ++x) { l_dst[x] = 0; } - if (l_new_cmp->w > (l_org_cmp->dx - 1U)) { /* check substraction overflow for really small images */ + if (l_new_cmp->w > (l_org_cmp->dx - 1U)) { /* check subtraction overflow for really small images */ for (; x < l_new_cmp->w - (l_org_cmp->dx - 1U); x += l_org_cmp->dx, ++xorg) { OPJ_UINT32 dx; for (dx = 0U; dx < l_org_cmp->dx; ++dx) { @@ -1145,7 +1145,7 @@ static opj_image_t* upsample_image_components(opj_image_t* original) for (x = 0U; x < xoff; ++x) { l_dst[x] = 0; } - if (l_new_cmp->w > (l_org_cmp->dx - 1U)) { /* check substraction overflow for really small images */ + if (l_new_cmp->w > (l_org_cmp->dx - 1U)) { /* check subtraction overflow for really small images */ for (; x < l_new_cmp->w - (l_org_cmp->dx - 1U); x += l_org_cmp->dx, ++xorg) { OPJ_UINT32 dx; for (dx = 0U; dx < l_org_cmp->dx; ++dx) { diff --git a/src/bin/jp2/windirent.h b/src/bin/jp2/windirent.h index 944b7d71..bef28194 100644 --- a/src/bin/jp2/windirent.h +++ b/src/bin/jp2/windirent.h @@ -243,7 +243,7 @@ * Substitute for real dirent structure. Note that `d_name' field is a * true character array although we have it copied in the implementation * dependent data. We could save some memory if we had declared `d_name' - * as a pointer refering the name within implementation dependent data. + * as a pointer referring the name within implementation dependent data. * We have not done that since some code may rely on sizeof(d_name) to be * something other than four. Besides, directory entries are typically so * small that it takes virtually no time to copy them from place to place. @@ -411,7 +411,7 @@ static DIR *opendir(const char *dirname) * capacity of d_name with different macros and some systems do not define * capacity at all (besides actual declaration of the field). If you really * need to find out storage capacity of d_name then you might want to try - * NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought + * NAME_MAX macro. The NAME_MAX is defined in POSIX standard although * there are many MS-DOS and MS-Windows implementations those do not define * it. There are also systems that declare d_name as "char d_name[1]" and * then allocate suitable amount of memory at run-time. Thanks to Alain @@ -466,7 +466,7 @@ readdir (DIR *dirp) /* fill in entry and return that */ #if defined(DIRENT_WIN32_INTERFACE) if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) { - /* Last file has been processed or an error occured */ + /* Last file has been processed or an error occurred */ FindClose (dirp->search_handle); dirp->search_handle = INVALID_HANDLE_VALUE; errno = ENOENT; diff --git a/src/bin/jp3d/windirent.h b/src/bin/jp3d/windirent.h index 72b38cea..2494cd4e 100644 --- a/src/bin/jp3d/windirent.h +++ b/src/bin/jp3d/windirent.h @@ -242,7 +242,7 @@ * Substitute for real dirent structure. Note that `d_name' field is a * true character array although we have it copied in the implementation * dependent data. We could save some memory if we had declared `d_name' - * as a pointer refering the name within implementation dependent data. + * as a pointer referring the name within implementation dependent data. * We have not done that since some code may rely on sizeof(d_name) to be * something other than four. Besides, directory entries are typically so * small that it takes virtually no time to copy them from place to place. @@ -410,7 +410,7 @@ static DIR *opendir(const char *dirname) * capacity of d_name with different macros and some systems do not define * capacity at all (besides actual declaration of the field). If you really * need to find out storage capacity of d_name then you might want to try - * NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought + * NAME_MAX macro. The NAME_MAX is defined in POSIX standard although * there are many MS-DOS and MS-Windows implementations those do not define * it. There are also systems that declare d_name as "char d_name[1]" and * then allocate suitable amount of memory at run-time. Thanks to Alain @@ -465,7 +465,7 @@ readdir (DIR *dirp) /* fill in entry and return that */ #if defined(DIRENT_WIN32_INTERFACE) if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) { - /* Last file has been processed or an error occured */ + /* Last file has been processed or an error occurred */ FindClose (dirp->search_handle); dirp->search_handle = INVALID_HANDLE_VALUE; errno = ENOENT; diff --git a/src/bin/jpwl/convert.c b/src/bin/jpwl/convert.c index de04e22f..bf7b5641 100644 --- a/src/bin/jpwl/convert.c +++ b/src/bin/jpwl/convert.c @@ -1436,7 +1436,7 @@ int imagetopgx(opj_image_t * image, const char *outfile) { fprintf(stderr, "ERROR -> failed to open %s for writing\n", name); return 1; } - /* dont need name anymore */ + /* don't need name anymore */ if( total > 256 ) { free(name); } diff --git a/src/bin/jpwl/opj_jpwl_compress.c b/src/bin/jpwl/opj_jpwl_compress.c index 7537b61d..7410486e 100644 --- a/src/bin/jpwl/opj_jpwl_compress.c +++ b/src/bin/jpwl/opj_jpwl_compress.c @@ -199,7 +199,7 @@ static void encode_help_display(void) { fprintf(stdout," Indicate multiple modes by adding their values. \n"); fprintf(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n"); fprintf(stdout,"\n"); - fprintf(stdout,"-TP : devide packets of every tile into tile-parts (-TP R) [R, L, C]\n"); + fprintf(stdout,"-TP : divide packets of every tile into tile-parts (-TP R) [R, L, C]\n"); fprintf(stdout,"\n"); fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n"); fprintf(stdout,"\n"); diff --git a/src/bin/jpwl/windirent.h b/src/bin/jpwl/windirent.h index 944b7d71..bef28194 100644 --- a/src/bin/jpwl/windirent.h +++ b/src/bin/jpwl/windirent.h @@ -243,7 +243,7 @@ * Substitute for real dirent structure. Note that `d_name' field is a * true character array although we have it copied in the implementation * dependent data. We could save some memory if we had declared `d_name' - * as a pointer refering the name within implementation dependent data. + * as a pointer referring the name within implementation dependent data. * We have not done that since some code may rely on sizeof(d_name) to be * something other than four. Besides, directory entries are typically so * small that it takes virtually no time to copy them from place to place. @@ -411,7 +411,7 @@ static DIR *opendir(const char *dirname) * capacity of d_name with different macros and some systems do not define * capacity at all (besides actual declaration of the field). If you really * need to find out storage capacity of d_name then you might want to try - * NAME_MAX macro. The NAME_MAX is defined in POSIX standard althought + * NAME_MAX macro. The NAME_MAX is defined in POSIX standard although * there are many MS-DOS and MS-Windows implementations those do not define * it. There are also systems that declare d_name as "char d_name[1]" and * then allocate suitable amount of memory at run-time. Thanks to Alain @@ -466,7 +466,7 @@ readdir (DIR *dirp) /* fill in entry and return that */ #if defined(DIRENT_WIN32_INTERFACE) if (FindNextFile (dirp->search_handle, &dirp->current.data) == FALSE) { - /* Last file has been processed or an error occured */ + /* Last file has been processed or an error occurred */ FindClose (dirp->search_handle); dirp->search_handle = INVALID_HANDLE_VALUE; errno = ENOENT; diff --git a/src/bin/mj2/meta_out.c b/src/bin/mj2/meta_out.c index b6795045..f5ca0be8 100644 --- a/src/bin/mj2/meta_out.c +++ b/src/bin/mj2/meta_out.c @@ -375,7 +375,7 @@ void xml_write_free_and_skip(FILE* xmlout, opj_mj2_t * movie) { } void xml_write_uuid(FILE* xmlout, opj_mj2_t * movie) { -/* Univeral Unique IDs of 16 bytes. */ +/* Universal Unique IDs of 16 bytes. */ #ifdef NOTYET /* NO-OP so far. There can be zero or more instances of private uuid boxes in a file. This function supports the top level of the file, but uuid may be elsewhere [not yet supported]. @@ -962,7 +962,7 @@ int xml_out_frame(FILE* file, FILE* xmlout, mj2_sample_t *sample, unsigned int s fprintf(xmlout, " \n", snum+1); fprintf(xmlout, " \n"); /* There can be multiple codestreams; a particular image is entirely within a single codestream */ - /* TO DO: A frame can be represented by two I-guess-contigious codestreams if its interleaved. */ + /* TO DO: A frame can be represented by two I-guess-contiguous codestreams if its interleaved. */ fprintf(xmlout, " \n"); /* "cp" stands for "coding parameter"; "tcp" is tile coding parameters, "tccp" is tile-component coding parameters */ xml_out_frame_siz(xmlout, img, cp); /* reqd in main */ diff --git a/src/bin/mj2/mj2_to_metadata.c b/src/bin/mj2/mj2_to_metadata.c index 489f19cb..2ec2829d 100644 --- a/src/bin/mj2/mj2_to_metadata.c +++ b/src/bin/mj2/mj2_to_metadata.c @@ -64,7 +64,7 @@ void help_display() fprintf(stdout,"----------\n"); fprintf(stdout,"The metadata includes the jp2 image and tile headers of the first frame.\n"); fprintf(stdout,"\n"); - fprintf(stdout,"Metadata values are shown in 'raw' form (e.g., hexidecimal) as stored in the\n"); + fprintf(stdout,"Metadata values are shown in 'raw' form (e.g., hexadecimal) as stored in the\n"); fprintf(stdout,"file, and, if apt, in a 'derived' form that is more quickly grasped.\n"); fprintf(stdout,"\n"); fprintf(stdout,"Notes explaining the XML are embedded as terse comments. These include\n"); diff --git a/src/bin/mj2/opj_mj2_wrap.c b/src/bin/mj2/opj_mj2_wrap.c index 7daa147f..59fb871d 100644 --- a/src/bin/mj2/opj_mj2_wrap.c +++ b/src/bin/mj2/opj_mj2_wrap.c @@ -356,7 +356,7 @@ static void setparams(opj_mj2_t *movie, opj_image_t *image) { movie->tk[0].jp2_struct.enumcs = 18; /* YUV */ else - movie->tk[0].jp2_struct.enumcs = 0; /* Unkown profile */ + movie->tk[0].jp2_struct.enumcs = 0; /* Unknown profile */ } int main(int argc, char *argv[]) { diff --git a/src/bin/wx/OPJViewer/source/readmebefore.txt b/src/bin/wx/OPJViewer/source/readmebefore.txt index a59b0e87..c945d291 100644 --- a/src/bin/wx/OPJViewer/source/readmebefore.txt +++ b/src/bin/wx/OPJViewer/source/readmebefore.txt @@ -8,4 +8,4 @@ Anybody. As the OpenJPEG library is released under the BSD license, anybody can Who is developing the library ? =============================== -The library is developed by the Communications and Remote Sensing Lab (TELE), in the Université Catholique de Louvain (UCL). The JPWL module is developped and maintained by the Digital Signal Processing Lab (DSPLab) of the University of Perugia, Italy (UNIPG). As our purpose is to make OpenJPEG really useful for those interested in the image compression field, any feedback/advices are obviously welcome ! We will do our best to handle them quickly. \ No newline at end of file +The library is developed by the Communications and Remote Sensing Lab (TELE), in the Université Catholique de Louvain (UCL). The JPWL module is developed and maintained by the Digital Signal Processing Lab (DSPLab) of the University of Perugia, Italy (UNIPG). As our purpose is to make OpenJPEG really useful for those interested in the image compression field, any feedback/advices are obviously welcome ! We will do our best to handle them quickly. diff --git a/src/lib/openjp2/cio.h b/src/lib/openjp2/cio.h index 6dfa5bb8..1b684ef8 100644 --- a/src/lib/openjp2/cio.h +++ b/src/lib/openjp2/cio.h @@ -184,7 +184,7 @@ void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_n * @param p_buffer pointer the data buffer to read data from. * @param p_value pointer to the value that will store the data. * @param p_nb_bytes the nb bytes to read. - * @return the number of bytes read or -1 if an error occured. + * @return the number of bytes read or -1 if an error occurred. */ void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes); @@ -193,7 +193,7 @@ void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT * @param p_buffer pointer the data buffer to write data to. * @param p_value the value to write * @param p_nb_bytes the number of bytes to write - * @return the number of bytes written or -1 if an error occured + * @return the number of bytes written or -1 if an error occurred */ void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_nb_bytes); @@ -202,7 +202,7 @@ void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_n * @param p_buffer pointer the data buffer to read data from. * @param p_value pointer to the value that will store the data. * @param p_nb_bytes the nb bytes to read. - * @return the number of bytes read or -1 if an error occured. + * @return the number of bytes read or -1 if an error occurred. */ void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT32 p_nb_bytes); @@ -269,7 +269,7 @@ void opj_write_float_BE(OPJ_BYTE * p_buffer, OPJ_FLOAT32 p_value); * @param p_buffer pointer to the data buffer that will receive the data. * @param p_size number of bytes to read. * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes read, or -1 if an error occured or if the stream is at the end. + * @return the number of bytes read, or -1 if an error occurred or if the stream is at the end. */ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr); @@ -279,7 +279,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu * @param p_buffer pointer to the data buffer holds the data to be writtent. * @param p_size number of bytes to write. * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes writtent, or -1 if an error occured. + * @return the number of bytes writtent, or -1 if an error occurred. */ OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream,const OPJ_BYTE * p_buffer, OPJ_SIZE_T p_size, struct opj_event_mgr * p_event_mgr); @@ -296,7 +296,7 @@ OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, struct opj_event_mgr * @param p_stream the stream to skip data from. * @param p_size the number of bytes to skip. * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes skipped, or -1 if an error occured. + * @return the number of bytes skipped, or -1 if an error occurred. */ OPJ_OFF_T opj_stream_skip (opj_stream_private_t * p_stream,OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); @@ -324,7 +324,7 @@ OPJ_OFF_T opj_stream_get_number_byte_left (const opj_stream_private_t * p_stream * @param p_stream the stream to skip data from. * @param p_size the number of bytes to skip. * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes skipped, or -1 if an error occured. + * @return the number of bytes skipped, or -1 if an error occurred. */ OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); @@ -333,7 +333,7 @@ OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_si * @param p_stream the stream to skip data from. * @param p_size the number of bytes to skip. * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes skipped, or -1 if an error occured. + * @return the number of bytes skipped, or -1 if an error occurred. */ OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); @@ -342,7 +342,7 @@ OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz * @param p_stream the stream to skip data from. * @param p_size the number of bytes to skip. * @param p_event_mgr the user event manager to be notified of special events. - * @return OPJ_TRUE if success, or OPJ_FALSE if an error occured. + * @return OPJ_TRUE if success, or OPJ_FALSE if an error occurred. */ OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); @@ -351,7 +351,7 @@ OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size * @param p_stream the stream to skip data from. * @param p_size the number of bytes to skip. * @param p_event_mgr the user event manager to be notified of special events. - * @return the number of bytes skipped, or -1 if an error occured. + * @return the number of bytes skipped, or -1 if an error occurred. */ OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, struct opj_event_mgr * p_event_mgr); diff --git a/src/lib/openjp2/dwt.h b/src/lib/openjp2/dwt.h index f8b57bc0..21fe942a 100644 --- a/src/lib/openjp2/dwt.h +++ b/src/lib/openjp2/dwt.h @@ -54,14 +54,14 @@ DWT.C are used by some function in TCD.C. /*@{*/ /* ----------------------------------------------------------------------- */ /** -Forward 5-3 wavelet tranform in 2-D. +Forward 5-3 wavelet transform in 2-D. Apply a reversible DWT transform to a component of an image. @param tilec Tile component information (current tile) */ OPJ_BOOL opj_dwt_encode(opj_tcd_tilecomp_t * tilec); /** -Inverse 5-3 wavelet tranform in 2-D. +Inverse 5-3 wavelet transform in 2-D. Apply a reversible inverse DWT transform to a component of an image. @param tilec Tile component information (current tile) @param numres Number of resolution levels to decode diff --git a/src/lib/openjp2/indexbox_manager.h b/src/lib/openjp2/indexbox_manager.h index ec5525f5..ebcde8fe 100644 --- a/src/lib/openjp2/indexbox_manager.h +++ b/src/lib/openjp2/indexbox_manager.h @@ -108,7 +108,7 @@ int opj_write_phix( int coff, opj_codestream_info_t cstr_info, OPJ_BOOL EPHused, opj_event_mgr_t * p_manager ); /* - * Wriet manifest box (box) + * Write manifest box (box) * * @param[in] second number to be visited * @param[in] v number of boxes diff --git a/src/lib/openjp2/invert.c b/src/lib/openjp2/invert.c index dd4998a9..7efaf6ec 100644 --- a/src/lib/openjp2/invert.c +++ b/src/lib/openjp2/invert.c @@ -125,7 +125,7 @@ static OPJ_BOOL opj_lupDecompose(OPJ_FLOAT32 * matrix,OPJ_UINT32 * permutations, { *tmpPermutations++ = i; } - /* now make a pivot with colum switch */ + /* now make a pivot with column switch */ tmpPermutations = permutations; for (k = 0; k < lLastColum; ++k) { p = 0.0; diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index f7a1d764..e612d06e 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -4351,7 +4351,7 @@ static OPJ_BOOL opj_j2k_read_sod (opj_j2k_t *p_j2k, } if (! *l_current_data) { /* LH: oddly enough, in this path, l_tile_len!=0. - * TODO: If this was consistant, we could simplify the code to only use realloc(), as realloc(0,...) default to malloc(0,...). + * TODO: If this was consistent, we could simplify the code to only use realloc(), as realloc(0,...) default to malloc(0,...). */ *l_current_data = (OPJ_BYTE*) opj_malloc(p_j2k->m_specific_param.m_decoder.m_sot_length); } @@ -5583,7 +5583,7 @@ static OPJ_BOOL opj_j2k_write_mco( opj_j2k_t *p_j2k, opj_write_bytes(l_current_data,l_mco_size-2,2); /* Lmco */ l_current_data += 2; - opj_write_bytes(l_current_data,l_tcp->m_nb_mcc_records,1); /* Nmco : only one tranform stage*/ + opj_write_bytes(l_current_data,l_tcp->m_nb_mcc_records,1); /* Nmco : only one transform stage*/ ++l_current_data; l_mcc_record = l_tcp->m_mcc_records; @@ -5635,7 +5635,7 @@ static OPJ_BOOL opj_j2k_read_mco ( opj_j2k_t *p_j2k, return OPJ_FALSE; } - opj_read_bytes(p_header_data,&l_nb_stages,1); /* Nmco : only one tranform stage*/ + opj_read_bytes(p_header_data,&l_nb_stages,1); /* Nmco : only one transform stage*/ ++p_header_data; if (l_nb_stages > 1) { diff --git a/src/lib/openjp2/jp2.c b/src/lib/openjp2/jp2.c index af692d59..8bf60f62 100644 --- a/src/lib/openjp2/jp2.c +++ b/src/lib/openjp2/jp2.c @@ -170,7 +170,7 @@ static OPJ_BOOL opj_jp2_skip_jp2c( opj_jp2_t *jp2, * @param p_header_size the size of the data contained in the file header box. * @param p_manager the user event manager. * - * @return true if the JP2 Header box was successfully reconized. + * @return true if the JP2 Header box was successfully recognized. */ static OPJ_BOOL opj_jp2_read_jp2h( opj_jp2_t *jp2, OPJ_BYTE *p_header_data, @@ -370,7 +370,7 @@ static OPJ_BOOL opj_jp2_exec ( opj_jp2_t * jp2, * @param p_number_bytes_read pointer to an int that will store the number of bytes read from the stream (shoul usually be 2). * @param p_manager user event manager. * - * @return true if the box is reconized, false otherwise + * @return true if the box is recognized, false otherwise */ static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box, OPJ_UINT32 * p_number_bytes_read, @@ -437,7 +437,7 @@ static const opj_jp2_header_handler_t jp2_img_header [] = * @param p_box_max_size the maximum number of bytes in the box. * @param p_manager FIXME DOC * - * @return true if the box is reconized, false otherwise + * @return true if the box is recognized, false otherwise */ static OPJ_BOOL opj_jp2_read_boxhdr_char( opj_jp2_box_t *box, OPJ_BYTE * p_data, @@ -2474,7 +2474,7 @@ static OPJ_BOOL opj_jpip_skip_iptr( opj_jp2_t *jp2, * @param p_header_size the size of the data contained in the file header box. * @param p_manager the user event manager. * - * @return true if the JP2 Header box was successfully reconized. + * @return true if the JP2 Header box was successfully recognized. */ static OPJ_BOOL opj_jp2_read_jp2h( opj_jp2_t *jp2, OPJ_BYTE *p_header_data, diff --git a/src/lib/openjp2/jp2.h b/src/lib/openjp2/jp2.h index 914c47f9..94138832 100644 --- a/src/lib/openjp2/jp2.h +++ b/src/lib/openjp2/jp2.h @@ -90,7 +90,7 @@ typedef enum JP2_IMG_STATE; /** -Channel description: channel index, type, assocation +Channel description: channel index, type, association */ typedef struct opj_jp2_cdef_info { diff --git a/src/lib/openjp2/mct.c b/src/lib/openjp2/mct.c index a0da0996..8b0276f3 100644 --- a/src/lib/openjp2/mct.c +++ b/src/lib/openjp2/mct.c @@ -70,7 +70,7 @@ const OPJ_FLOAT64 * opj_mct_get_mct_norms_real () } /* */ -/* Foward reversible MCT. */ +/* Forward reversible MCT. */ /* */ #ifdef __SSE2__ void opj_mct_encode( @@ -202,7 +202,7 @@ OPJ_FLOAT64 opj_mct_getnorm(OPJ_UINT32 compno) { } /* */ -/* Foward irreversible MCT. */ +/* Forward irreversible MCT. */ /* */ #ifdef __SSE4_1__ void opj_mct_encode_real( diff --git a/src/lib/openjp2/openjpeg.h b/src/lib/openjp2/openjpeg.h index 4a8e75ce..c07e9c84 100644 --- a/src/lib/openjp2/openjpeg.h +++ b/src/lib/openjp2/openjpeg.h @@ -97,7 +97,7 @@ The following ifdef block is the standard way of creating macros which make expo from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS symbol defined on the command line. this symbol should not be defined on any project that uses this DLL. This way any other project whose source files include this file see -OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols +OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols defined with this macro as being exported. */ # if defined(OPJ_EXPORTS) || defined(DLL_EXPORT) @@ -850,7 +850,7 @@ typedef struct opj_codestream_info { } opj_codestream_info_t; /* <----------------------------------------------------------- */ -/* new output managment of the codestream information and index */ +/* new output management of the codestream information and index */ /** * Tile-component coding parameters information @@ -1347,7 +1347,7 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_write_tile ( opj_codec_t *p_codec, opj_stream_t *p_stream ); /** - * Reads a tile header. This function is compulsory and allows one to know the size of the tile thta will be decoded. + * Reads a tile header. This function is compulsory and allows one to know the size of the tile that will be decoded. * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile. * * @param p_codec the jpeg2000 codec. diff --git a/src/lib/openjp2/opj_malloc.h b/src/lib/openjp2/opj_malloc.h index 5007b0c9..517707f9 100644 --- a/src/lib/openjp2/opj_malloc.h +++ b/src/lib/openjp2/opj_malloc.h @@ -79,7 +79,7 @@ void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements); #endif /** -Allocate memory aligned to a 16 byte boundry +Allocate memory aligned to a 16 byte boundary @param size Bytes to allocate @return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available */ diff --git a/src/lib/openjp2/pi.h b/src/lib/openjp2/pi.h index f239679f..265d5b1e 100644 --- a/src/lib/openjp2/pi.h +++ b/src/lib/openjp2/pi.h @@ -73,7 +73,7 @@ Packet iterator typedef struct opj_pi_iterator { /** Enabling Tile part generation*/ OPJ_BYTE tp_on; - /** precise if the packet has been already used (usefull for progression order change) */ + /** precise if the packet has been already used (useful for progression order change) */ OPJ_INT16 *include; /** layer step used to localize the packet in the include vector */ OPJ_UINT32 step_l; diff --git a/src/lib/openjp2/tcd.h b/src/lib/openjp2/tcd.h index bb9a6205..07f8379a 100644 --- a/src/lib/openjp2/tcd.h +++ b/src/lib/openjp2/tcd.h @@ -296,7 +296,7 @@ OPJ_UINT32 opj_tcd_get_decoded_tile_size (opj_tcd_t *p_tcd ); * @param p_data_written pointer to an int that is incremented by the number of bytes really written on p_dest * @param p_len Maximum length of the destination buffer * @param p_cstr_info Codestream information structure - * @return true if the coding is successfull. + * @return true if the coding is successful. */ OPJ_BOOL opj_tcd_encode_tile( opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, diff --git a/src/lib/openjp3d/cio.h b/src/lib/openjp3d/cio.h index 3617dad7..3cfa6fcb 100644 --- a/src/lib/openjp3d/cio.h +++ b/src/lib/openjp3d/cio.h @@ -65,7 +65,7 @@ Write some bytes @param cio CIO handle @param v Value to write @param n Number of bytes to write -@return Returns the number of bytes written or 0 if an error occured +@return Returns the number of bytes written or 0 if an error occurred */ unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n); /** @@ -86,7 +86,7 @@ Write some bytes @param cio CIO handle @param v Signed integer value to write @param n Number of bytes to write -@return Returns the number of bytes written or 0 if an error occured +@return Returns the number of bytes written or 0 if an error occurred */ int cio_write_int(opj_cio_t *cio, int v, int n); /** diff --git a/src/lib/openjp3d/dwt.c b/src/lib/openjp3d/dwt.c index 1558cc3f..a1e4e104 100644 --- a/src/lib/openjp3d/dwt.c +++ b/src/lib/openjp3d/dwt.c @@ -89,12 +89,12 @@ Inverse lazy transform (axial) */ static void dwt_interleave_z(int *a, int *b, int dn, int sn, int xy, int cas); /** -Forward 5-3 wavelet tranform in 1-D +Forward 5-3 wavelet transform in 1-D */ static void dwt_encode_53(int *a, int dn, int sn, int cas); static void dwt_encode_97(int *a, int dn, int sn, int cas); /** -Inverse 5-3 wavelet tranform in 1-D +Inverse 5-3 wavelet transform in 1-D */ static void dwt_decode_53(int *a, int dn, int sn, int cas); static void dwt_decode_97(int *a, int dn, int sn, int cas); @@ -333,7 +333,7 @@ static void dwt_interleave_z(int *a, int *b, int dn, int sn, int xy, int cas) { /* */ -/* Forward 5-3 or 9-7 wavelet tranform in 1-D. */ +/* Forward 5-3 or 9-7 wavelet transform in 1-D. */ /* */ static void dwt_encode_53(int *a, int dn, int sn, int cas) { int i; @@ -409,7 +409,7 @@ static void dwt_encode_97(int *a, int dn, int sn, int cas) { } } /* */ -/* Inverse 5-3 or 9-7 wavelet tranform in 1-D. */ +/* Inverse 5-3 or 9-7 wavelet transform in 1-D. */ /* */ static void dwt_decode_53(int *a, int dn, int sn, int cas) { int i; @@ -661,7 +661,7 @@ static void dwt_encode_stepsize(int stepsize, int numbps, opj_stepsize_t *bandno ========================================================== */ /* */ -/* Forward 5-3 wavelet tranform in 3-D. */ +/* Forward 5-3 wavelet transform in 3-D. */ /* */ void dwt_encode(opj_tcd_tilecomp_t * tilec, int dwtid[3]) { int i, j, k; @@ -792,7 +792,7 @@ void dwt_encode(opj_tcd_tilecomp_t * tilec, int dwtid[3]) { /* */ -/* Inverse 5-3 wavelet tranform in 3-D. */ +/* Inverse 5-3 wavelet transform in 3-D. */ /* */ void dwt_decode(opj_tcd_tilecomp_t * tilec, int stops[3], int dwtid[3]) { int i, j, k; diff --git a/src/lib/openjp3d/dwt.h b/src/lib/openjp3d/dwt.h index 5c3f6847..00082900 100644 --- a/src/lib/openjp3d/dwt.h +++ b/src/lib/openjp3d/dwt.h @@ -63,14 +63,14 @@ typedef struct opj_wtfilt { /*@{*/ /* ----------------------------------------------------------------------- */ /** -Forward 5-3 wavelet tranform in 3-D. +Forward 5-3 wavelet transform in 3-D. Apply a reversible DWT transform to a component of an volume. @param tilec Tile component information (current tile) @param dwtid Number of identification of wavelet kernel(s) used in DWT in each direction */ void dwt_encode(opj_tcd_tilecomp_t * tilec, int dwtid[3]); /** -Inverse 5-3 wavelet tranform in 3-D. +Inverse 5-3 wavelet transform in 3-D. Apply a reversible inverse DWT transform to a component of an volume. @param tilec Tile component information (current tile) @param stops Number of decoded resolution levels in each dimension diff --git a/src/lib/openjp3d/mct.c b/src/lib/openjp3d/mct.c index 5759047b..685a9f88 100644 --- a/src/lib/openjp3d/mct.c +++ b/src/lib/openjp3d/mct.c @@ -46,7 +46,7 @@ static const double mct_norms[3] = { 1.732, .8292, .8292 }; static const double mct_norms_real[3] = { 1.732, 1.805, 1.573 }; /* */ -/* Foward reversible MCT. */ +/* Forward reversible MCT. */ /* */ void mct_encode(int *c0, int *c1, int *c2, int n) { int i; @@ -91,7 +91,7 @@ double mct_getnorm(int compno) { } /* */ -/* Foward irreversible MCT. */ +/* Forward irreversible MCT. */ /* */ void mct_encode_real(int *c0, int *c1, int *c2, int n) { int i; diff --git a/src/lib/openjp3d/openjp3d.h b/src/lib/openjp3d/openjp3d.h index ae2507c0..a720bd37 100644 --- a/src/lib/openjp3d/openjp3d.h +++ b/src/lib/openjp3d/openjp3d.h @@ -60,7 +60,7 @@ The following ifdef block is the standard way of creating macros which make expo from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS symbol defined on the command line. this symbol should not be defined on any project that uses this DLL. This way any other project whose source files include this file see -OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols +OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols defined with this macro as being exported. */ #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT) diff --git a/src/lib/openjp3d/pi.h b/src/lib/openjp3d/pi.h index b3f287a3..c81f9ef0 100644 --- a/src/lib/openjp3d/pi.h +++ b/src/lib/openjp3d/pi.h @@ -82,7 +82,7 @@ typedef struct opj_pi_comp { Packet iterator */ typedef struct opj_pi_iterator { -/** precise if the packet has been already used (usefull for progression order change) */ +/** precise if the packet has been already used (useful for progression order change) */ short int *include; /** layer step used to localize the packet in the include vector */ int step_l; diff --git a/src/lib/openjpip/cachemodel_manager.h b/src/lib/openjpip/cachemodel_manager.h index ac54026d..041f1ad9 100644 --- a/src/lib/openjpip/cachemodel_manager.h +++ b/src/lib/openjpip/cachemodel_manager.h @@ -80,7 +80,7 @@ void print_cachemodel( cachemodel_param_t cachemodel); /** * search a cache model of a target * - * @param[in] target refering target + * @param[in] target referring target * @param[in] cachemodellist cache model list * @return found cache model pointer */ diff --git a/src/lib/openjpip/jpip_parser.c b/src/lib/openjpip/jpip_parser.c index c206662d..d44c84c8 100644 --- a/src/lib/openjpip/jpip_parser.c +++ b/src/lib/openjpip/jpip_parser.c @@ -357,7 +357,7 @@ void enqueue_precincts( int xmin, int xmax, int ymin, int ymax, int tile_id, int Byte4_t xminP, xmaxP, yminP, ymaxP; codeidx = msgqueue->cachemodel->target->codeidx; - /* MM: shouldnt xmin/xmax be Byte4_t instead ? */ + /* MM: shouldn't xmin/xmax be Byte4_t instead ? */ if( xmin < 0 || xmax < 0 || ymin < 0 || ymax < 0) return; /* MM: I think the API should not really be int should it ? */ diff --git a/src/lib/openjpip/target_manager.h b/src/lib/openjpip/target_manager.h index 4ed99a79..561510f5 100644 --- a/src/lib/openjpip/target_manager.h +++ b/src/lib/openjpip/target_manager.h @@ -46,7 +46,7 @@ typedef struct target_param{ #endif int csn; /**< codestream number */ index_param_t *codeidx; /**< index information of codestream */ - int num_of_use; /**< numbers of sessions refering to this target */ + int num_of_use; /**< numbers of sessions referring to this target */ OPJ_BOOL jppstream; /**< if this target can return JPP-stream */ OPJ_BOOL jptstream; /**< if this target can return JPP-stream */ struct target_param *next; /**< pointer to the next target */ diff --git a/src/lib/openjpwl/jpwl.h b/src/lib/openjpwl/jpwl.h index 748a6b38..ca0ee0a1 100644 --- a/src/lib/openjpwl/jpwl.h +++ b/src/lib/openjpwl/jpwl.h @@ -357,7 +357,7 @@ opj_bool jpwl_correct(opj_j2k_t *j2k); @param post_len length of post_data @param conn is a pointer to the length of all connected (packed) EPBs @param L4_bufp is a pointer to the buffer pointer of redundancy data -@return returns true if correction could be succesfully performed +@return returns true if correction could be successfully performed */ opj_bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn, unsigned char **L4_bufp); diff --git a/src/lib/openjpwl/rs.c b/src/lib/openjpwl/rs.c index e35781f6..a0bd7c71 100644 --- a/src/lib/openjpwl/rs.c +++ b/src/lib/openjpwl/rs.c @@ -225,7 +225,7 @@ void init_rs(int k) of the integer "alpha_to[i]" with a(0) being the LSB and a(m-1) the MSB. Thus for example the polynomial representation of @^5 would be given by the binary representation of the integer "alpha_to[5]". - Similarily, index_of[] can be used as follows: + Similarly, index_of[] can be used as follows: As above, let @ represent the primitive element of GF(2^m) that is the root of the primitive polynomial p(x). In order to find the power of @ (alpha) that has the polynomial representation @@ -237,7 +237,7 @@ void init_rs(int k) NOTE: The element alpha_to[2^m-1] = 0 always signifying that the representation of "@^infinity" = 0 is (0,0,0,...,0). - Similarily, the element index_of[0] = A0 always signifying + Similarly, the element index_of[0] = A0 always signifying that the power of alpha which has the polynomial representation (0,0,...,0) is "infinity". diff --git a/src/lib/openmj2/cio.h b/src/lib/openmj2/cio.h index f389d4e2..3cae708e 100644 --- a/src/lib/openmj2/cio.h +++ b/src/lib/openmj2/cio.h @@ -74,7 +74,7 @@ Write some bytes @param cio CIO handle @param v Value to write @param n Number of bytes to write -@return Returns the number of bytes written or 0 if an error occured +@return Returns the number of bytes written or 0 if an error occurred */ OPJ_API unsigned int OPJ_CALLCONV cio_write(opj_cio_t *cio, unsigned int64 v, int n); /** diff --git a/src/lib/openmj2/dwt.h b/src/lib/openmj2/dwt.h index 3cb3b209..5b9645bf 100644 --- a/src/lib/openmj2/dwt.h +++ b/src/lib/openmj2/dwt.h @@ -54,13 +54,13 @@ DWT.C are used by some function in TCD.C. /*@{*/ /* ----------------------------------------------------------------------- */ /** -Forward 5-3 wavelet tranform in 2-D. +Forward 5-3 wavelet transform in 2-D. Apply a reversible DWT transform to a component of an image. @param tilec Tile component information (current tile) */ void dwt_encode(opj_tcd_tilecomp_t * tilec); /** -Inverse 5-3 wavelet tranform in 2-D. +Inverse 5-3 wavelet transform in 2-D. Apply a reversible inverse DWT transform to a component of an image. @param tilec Tile component information (current tile) @param numres Number of resolution levels to decode diff --git a/src/lib/openmj2/jp2.h b/src/lib/openmj2/jp2.h index f1b9c0d3..fbd17a4d 100644 --- a/src/lib/openmj2/jp2.h +++ b/src/lib/openmj2/jp2.h @@ -58,7 +58,7 @@ /* ----------------------------------------------------------------------- */ /** -Channel description: channel index, type, assocation +Channel description: channel index, type, association */ typedef struct opj_jp2_cdef_info { diff --git a/src/lib/openmj2/mct.c b/src/lib/openmj2/mct.c index e507a781..0f926194 100644 --- a/src/lib/openmj2/mct.c +++ b/src/lib/openmj2/mct.c @@ -52,7 +52,7 @@ static const double mct_norms[3] = { 1.732, .8292, .8292 }; static const double mct_norms_real[3] = { 1.732, 1.805, 1.573 }; /* */ -/* Foward reversible MCT. */ +/* Forward reversible MCT. */ /* */ void mct_encode( int* restrict c0, @@ -105,7 +105,7 @@ double mct_getnorm(int compno) { } /* */ -/* Foward irreversible MCT. */ +/* Forward irreversible MCT. */ /* */ void mct_encode_real( int* restrict c0, diff --git a/src/lib/openmj2/openjpeg.h b/src/lib/openmj2/openjpeg.h index f765fc2c..132ec2fd 100644 --- a/src/lib/openmj2/openjpeg.h +++ b/src/lib/openmj2/openjpeg.h @@ -62,7 +62,7 @@ The following ifdef block is the standard way of creating macros which make expo from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS symbol defined on the command line. this symbol should not be defined on any project that uses this DLL. This way any other project whose source files include this file see -OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols +OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols defined with this macro as being exported. */ #if defined(OPJ_EXPORTS) || defined(DLL_EXPORT) diff --git a/src/lib/openmj2/opj_malloc.h b/src/lib/openmj2/opj_malloc.h index 9e4af234..1b62ab02 100644 --- a/src/lib/openmj2/opj_malloc.h +++ b/src/lib/openmj2/opj_malloc.h @@ -64,7 +64,7 @@ void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements); #endif /** -Allocate memory aligned to a 16 byte boundry +Allocate memory aligned to a 16 byte boundary @param size Bytes to allocate @return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available */ diff --git a/src/lib/openmj2/pi.h b/src/lib/openmj2/pi.h index fa0d08ab..7f2fe3ef 100644 --- a/src/lib/openmj2/pi.h +++ b/src/lib/openmj2/pi.h @@ -73,7 +73,7 @@ Packet iterator typedef struct opj_pi_iterator { /** Enabling Tile part generation*/ char tp_on; - /** precise if the packet has been already used (usefull for progression order change) */ + /** precise if the packet has been already used (useful for progression order change) */ short int *include; /** layer step used to localize the packet in the include vector */ int step_l; diff --git a/tests/nonregression/CMakeLists.txt b/tests/nonregression/CMakeLists.txt index 5ce37c81..ce95af87 100644 --- a/tests/nonregression/CMakeLists.txt +++ b/tests/nonregression/CMakeLists.txt @@ -405,7 +405,7 @@ foreach(OPJ_TEST_CMD_LINE ${OPJ_TEST_CMD_LINE_LIST}) ) # FIXME: add a compare2base function base on raw which -# can output png diff files if necesary +# can output png diff files if necessary # add_test(NR-${filename}-compare2base # ${EXECUTABLE_OUTPUT_PATH}/compare_images # -b ${BASELINE_NR}/opj_${filenameRef} diff --git a/tests/nonregression/test_suite.ctest.in b/tests/nonregression/test_suite.ctest.in index 7e3a35a8..25201c8f 100644 --- a/tests/nonregression/test_suite.ctest.in +++ b/tests/nonregression/test_suite.ctest.in @@ -1,7 +1,7 @@ # This file list all the input commands of the tests run by the ctest command which # are not related to the conformance files. # -# For each line of this file (exept line which begin with #) an opj_compress test or a +# For each line of this file (except line which begin with #) an opj_compress test or a # opj_decompress is run and its related tests. # + For encoder related tests = dump, compare dump to base, decode the encoded file with # reference and compare the decoded file with the baseline decoded previously with diff --git a/wrapping/java/openjp2/JavaOpenJPEG.c b/wrapping/java/openjp2/JavaOpenJPEG.c index c0a877d6..368cbfdb 100644 --- a/wrapping/java/openjp2/JavaOpenJPEG.c +++ b/wrapping/java/openjp2/JavaOpenJPEG.c @@ -206,7 +206,7 @@ static void encode_help_display() { fprintf(stdout," Indicate multiple modes by adding their values. \n"); fprintf(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n"); fprintf(stdout,"\n"); - fprintf(stdout,"-TP : devide packets of every tile into tile-parts (-TP R) [R, L, C]\n"); + fprintf(stdout,"-TP : divide packets of every tile into tile-parts (-TP R) [R, L, C]\n"); fprintf(stdout,"\n"); fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n"); fprintf(stdout,"\n"); @@ -1696,7 +1696,7 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec len = (*env)->GetArrayLength(env, jba); jbBody = (*env)->GetPrimitiveArrayCritical(env, jba, &isCopy); - /*printf("C: before transfering 8 bpp image\n");*/ + /*printf("C: before transferring 8 bpp image\n");*/ if (comp->sgnd) { for(i=0; i< len;i++) { comp->data[i] = (char) jbBody[i]; @@ -1715,7 +1715,7 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec len = (*env)->GetArrayLength(env, jsa); jsBody = (*env)->GetPrimitiveArrayCritical(env, jsa, &isCopy); - /*printf("C: before transfering 16 bpp image\n");*/ + /*printf("C: before transferring 16 bpp image\n");*/ if (comp->sgnd) { /* Special behaviour to deal with signed elements ??*/ comp->data[i] = (short) jsBody[i]; for(i=0; i< len;i++) { @@ -1735,7 +1735,7 @@ static opj_image_t* loadImage(opj_cparameters_t *parameters, JNIEnv *env, jobjec shift = compno*8; jiBody = (*env)->GetPrimitiveArrayCritical(env, jia, &isCopy); - /*printf("C: before transfering 24 bpp image (component %d, signed = %d)\n", compno, comp->sgnd);*/ + /*printf("C: before transferring 24 bpp image (component %d, signed = %d)\n", compno, comp->sgnd);*/ if (comp->sgnd) { /* Special behaviour to deal with signed elements ?? XXXXX*/ for(i=0; i< len;i++) { comp->data[i] = ( ((int) jiBody[i]) & (0xFF << shift) ) >> shift; diff --git a/wrapping/java/openjp2/JavaOpenJPEGDecoder.c b/wrapping/java/openjp2/JavaOpenJPEGDecoder.c index 80e09c39..f91267fc 100644 --- a/wrapping/java/openjp2/JavaOpenJPEGDecoder.c +++ b/wrapping/java/openjp2/JavaOpenJPEGDecoder.c @@ -604,7 +604,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto /*printf("C: %d bytes read from file\n",file_length);*/ } else { /* Preparing the transfer of the codestream from Java to C*/ - /*printf("C: before transfering codestream\n");*/ + /*printf("C: before transferring codestream\n");*/ fid = (*env)->GetFieldID(env, cls,"compressedStream", "[B"); jba = (*env)->GetObjectField(env, obj, fid); file_length = (*env)->GetArrayLength(env, jba); @@ -782,7 +782,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto jia = (*env)->GetObjectField(env, obj, fid); jiBody = (*env)->GetIntArrayElements(env, jia, 0); ptrIBody = jiBody; - printf("C: transfering image24: %d int to Java pointer=%d\n",image->numcomps*w*h, ptrIBody); + printf("C: transferring image24: %d int to Java pointer=%d\n",image->numcomps*w*h, ptrIBody); for (i=0; icomps[0].data; - printf("C: before transfering a %d bpp image to java (length = %d)\n",image->comps[0].prec ,w*h); + printf("C: before transferring a %d bpp image to java (length = %d)\n",image->comps[0].prec ,w*h); if (image->comps[0].prec<=8) { fid = (*env)->GetFieldID(env, cls,"image8", "[B"); jba = (*env)->GetObjectField(env, obj, fid); @@ -823,7 +823,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto max_value = 255; } #endif - /*printf("C: transfering %d shorts to Java image8 pointer = %d\n", wr*hr,ptrSBody);*/ + /*printf("C: transferring %d shorts to Java image8 pointer = %d\n", wr*hr,ptrSBody);*/ for (i=0; iReleaseByteArrayElements(env, jba, jbBody, 0); - printf("C: image8 transfered to Java\n"); + printf("C: image8 transferred to Java\n"); } else { fid = (*env)->GetFieldID(env, cls,"image16", "[S"); jsa = (*env)->GetObjectField(env, obj, fid); @@ -851,7 +851,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto } printf("C: minValue = %d, maxValue = %d\n", min_value, max_value); #endif - printf("C: transfering %d shorts to Java image16 pointer = %d\n", w*h,ptrSBody); + printf("C: transferring %d shorts to Java image16 pointer = %d\n", w*h,ptrSBody); for (i=0; i Date: Tue, 29 Sep 2015 05:57:09 +0200 Subject: [PATCH 14/21] Fix typo in variable name This makes checks with codespell easier. Signed-off-by: Stefan Weil --- src/lib/openjpip/imgsock_manager.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib/openjpip/imgsock_manager.c b/src/lib/openjpip/imgsock_manager.c index 10e997b1..4337e608 100644 --- a/src/lib/openjpip/imgsock_manager.c +++ b/src/lib/openjpip/imgsock_manager.c @@ -181,19 +181,19 @@ void send_PNMstream( SOCKET connected_socket, Byte_t *pnmstream, unsigned int wi void send_SIZstream( SOCKET connected_socket, unsigned int width, unsigned int height) { - Byte_t responce[9]; + Byte_t response[9]; - responce[0] = 'S'; - responce[1] = 'I'; - responce[2] = 'Z'; - responce[3] = (width >> 16) & 0xff; - responce[4] = (width >> 8) & 0xff; - responce[5] = width & 0xff; - responce[6] = (height >> 16) & 0xff; - responce[7] = (height >> 8) & 0xff; - responce[8] = height & 0xff; + response[0] = 'S'; + response[1] = 'I'; + response[2] = 'Z'; + response[3] = (width >> 16) & 0xff; + response[4] = (width >> 8) & 0xff; + response[5] = width & 0xff; + response[6] = (height >> 16) & 0xff; + response[7] = (height >> 8) & 0xff; + response[8] = height & 0xff; - send_stream( connected_socket, responce, 9); + send_stream( connected_socket, response, 9); } void response_signal( SOCKET connected_socket, OPJ_BOOL succeed) From cf352af089bd6adc89130fa839c57779e4870e6f Mon Sep 17 00:00:00 2001 From: mayeut Date: Tue, 29 Sep 2015 09:28:34 +0200 Subject: [PATCH 15/21] Fix up-scaling bit depth Fixes #609 --- src/bin/jp2/convert.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c index 1a18711c..73ec9f6e 100644 --- a/src/bin/jp2/convert.c +++ b/src/bin/jp2/convert.c @@ -114,6 +114,7 @@ static void scale_component_up(opj_image_comp_t* component, OPJ_UINT32 precision } } component->prec = precision; + component->bpp = precision; } void scale_component(opj_image_comp_t* component, OPJ_UINT32 precision) { From db23831d573cd5bd8ecb56040af7be7c5887fd28 Mon Sep 17 00:00:00 2001 From: mayeut Date: Fri, 2 Oct 2015 22:33:44 +0200 Subject: [PATCH 16/21] Add check for seek support before trying TPsot==TNsot workaround --- src/lib/openjp2/j2k.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index e612d06e..291c9b77 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -7682,6 +7682,11 @@ static OPJ_BOOL opj_j2k_need_nb_tile_parts_correction(opj_stream_private_t *p_st /* initialize to no correction needed */ *p_correction_needed = OPJ_FALSE; + if (!opj_stream_has_seek(p_stream)) { + /* We can't do much in this case, seek is needed */ + return OPJ_TRUE; + } + l_stream_pos_backup = opj_stream_tell(p_stream); if (l_stream_pos_backup == -1) { /* let's do nothing */ From d6b51b7041a9822ee6e658dc684049c6c31266e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Tue, 6 Oct 2015 15:33:46 +0200 Subject: [PATCH 17/21] Added missing casts for return values of opj_malloc()/opj_calloc(). --- src/lib/openjp2/j2k.c | 4 ++-- src/lib/openjp2/jp2.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index 291c9b77..c8d8cf1a 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -3562,7 +3562,7 @@ static OPJ_BOOL opj_j2k_read_ppm ( return OPJ_FALSE; } - l_cp->ppm_markers[l_Z_ppm].m_data = opj_malloc(p_header_size); + l_cp->ppm_markers[l_Z_ppm].m_data = (OPJ_BYTE *) opj_malloc(p_header_size); if (l_cp->ppm_markers[l_Z_ppm].m_data == NULL) { /* clean up to be done on l_cp destruction */ opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPM marker\n"); @@ -3784,7 +3784,7 @@ static OPJ_BOOL opj_j2k_read_ppt ( opj_j2k_t *p_j2k, return OPJ_FALSE; } - l_tcp->ppt_markers[l_Z_ppt].m_data = opj_malloc(p_header_size); + l_tcp->ppt_markers[l_Z_ppt].m_data = (OPJ_BYTE *) opj_malloc(p_header_size); if (l_tcp->ppt_markers[l_Z_ppt].m_data == NULL) { /* clean up to be done on l_tcp destruction */ opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read PPT marker\n"); diff --git a/src/lib/openjp2/jp2.c b/src/lib/openjp2/jp2.c index 8bf60f62..c14e9a06 100644 --- a/src/lib/openjp2/jp2.c +++ b/src/lib/openjp2/jp2.c @@ -889,7 +889,7 @@ static OPJ_BOOL opj_jp2_check_color(opj_image_t *image, opj_jp2_color_t *color, } } - pcol_usage = opj_calloc(nr_channels, sizeof(OPJ_BOOL)); + pcol_usage = (OPJ_BOOL *) opj_calloc(nr_channels, sizeof(OPJ_BOOL)); if (!pcol_usage) { opj_event_msg(p_manager, EVT_ERROR, "Unexpected OOM.\n"); return OPJ_FALSE; From 8414870ca7362723c796e7accdd11b0adf9cdc26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChlstrasser?= Date: Wed, 7 Oct 2015 12:28:12 +0200 Subject: [PATCH 18/21] Fixed problem that C++ compilation failed because of enum variable. Replaced usage of an enum typedef for a variable that is used for bit flags with OPJ_UINT32 type. --- src/lib/openjp2/cio.c | 36 ++++++++++++++++++------------------ src/lib/openjp2/cio.h | 17 ++++++----------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/lib/openjp2/cio.c b/src/lib/openjp2/cio.c index b2f6405f..b115cf52 100644 --- a/src/lib/openjp2/cio.c +++ b/src/lib/openjp2/cio.c @@ -166,12 +166,12 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size,OPJ_BOOL l l_stream->m_current_data = l_stream->m_stored_data; if (l_is_input) { - l_stream->m_status |= opj_stream_e_input; + l_stream->m_status |= OPJ_STREAM_STATUS_INPUT; l_stream->m_opj_skip = opj_stream_read_skip; l_stream->m_opj_seek = opj_stream_read_seek; } else { - l_stream->m_status |= opj_stream_e_output; + l_stream->m_status |= OPJ_STREAM_STATUS_OUTPUT; l_stream->m_opj_skip = opj_stream_write_skip; l_stream->m_opj_seek = opj_stream_write_seek; } @@ -207,7 +207,7 @@ void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_strea { opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream; - if ((!l_stream) || (! (l_stream->m_status & opj_stream_e_input))) { + if ((!l_stream) || (! (l_stream->m_status & OPJ_STREAM_STATUS_INPUT))) { return; } @@ -228,7 +228,7 @@ void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, opj_stre { opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream; - if ((!l_stream )|| (! (l_stream->m_status & opj_stream_e_output))) { + if ((!l_stream )|| (! (l_stream->m_status & OPJ_STREAM_STATUS_OUTPUT))) { return; } @@ -276,7 +276,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu } /* we are now in the case when the remaining data if not sufficient */ - if (p_stream->m_status & opj_stream_e_end) { + if (p_stream->m_status & OPJ_STREAM_STATUS_END) { l_read_nb_bytes += p_stream->m_bytes_in_buffer; memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer); p_stream->m_current_data += p_stream->m_bytes_in_buffer; @@ -313,7 +313,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n"); p_stream->m_bytes_in_buffer = 0; - p_stream->m_status |= opj_stream_e_end; + p_stream->m_status |= OPJ_STREAM_STATUS_END; /* end of stream */ return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T)-1; } @@ -345,7 +345,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n"); p_stream->m_bytes_in_buffer = 0; - p_stream->m_status |= opj_stream_e_end; + p_stream->m_status |= OPJ_STREAM_STATUS_END; /* end of stream */ return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T)-1; } @@ -378,7 +378,7 @@ OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream, OPJ_SIZE_T l_remaining_bytes = 0; OPJ_SIZE_T l_write_nb_bytes = 0; - if (p_stream->m_status & opj_stream_e_error) { + if (p_stream->m_status & OPJ_STREAM_STATUS_ERROR) { return (OPJ_SIZE_T)-1; } @@ -432,7 +432,7 @@ OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, opj_event_mgr_t * p_ p_stream->m_user_data); if (l_current_write_nb_bytes == (OPJ_SIZE_T)-1) { - p_stream->m_status |= opj_stream_e_error; + p_stream->m_status |= OPJ_STREAM_STATUS_ERROR; opj_event_msg(p_event_mgr, EVT_INFO, "Error on writing stream!\n"); return OPJ_FALSE; @@ -465,7 +465,7 @@ OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz } /* we are now in the case when the remaining data if not sufficient */ - if (p_stream->m_status & opj_stream_e_end) { + if (p_stream->m_status & OPJ_STREAM_STATUS_END) { l_skip_nb_bytes += (OPJ_OFF_T)p_stream->m_bytes_in_buffer; p_stream->m_current_data += p_stream->m_bytes_in_buffer; p_stream->m_bytes_in_buffer = 0; @@ -487,7 +487,7 @@ OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz if (l_current_skip_nb_bytes == (OPJ_OFF_T) -1) { opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n"); - p_stream->m_status |= opj_stream_e_end; + p_stream->m_status |= OPJ_STREAM_STATUS_END; p_stream->m_byte_offset += l_skip_nb_bytes; /* end if stream */ return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T) -1; @@ -507,14 +507,14 @@ OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_si OPJ_OFF_T l_current_skip_nb_bytes = 0; OPJ_OFF_T l_skip_nb_bytes = 0; - if (p_stream->m_status & opj_stream_e_error) { + if (p_stream->m_status & OPJ_STREAM_STATUS_ERROR) { return (OPJ_OFF_T) -1; } /* we should flush data */ l_is_written = opj_stream_flush (p_stream, p_event_mgr); if (! l_is_written) { - p_stream->m_status |= opj_stream_e_error; + p_stream->m_status |= OPJ_STREAM_STATUS_ERROR; p_stream->m_bytes_in_buffer = 0; return (OPJ_OFF_T) -1; } @@ -527,7 +527,7 @@ OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_si if (l_current_skip_nb_bytes == (OPJ_OFF_T)-1) { opj_event_msg(p_event_mgr, EVT_INFO, "Stream error!\n"); - p_stream->m_status |= opj_stream_e_error; + p_stream->m_status |= OPJ_STREAM_STATUS_ERROR; p_stream->m_byte_offset += l_skip_nb_bytes; /* end if stream */ return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T)-1; @@ -568,12 +568,12 @@ OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size p_stream->m_bytes_in_buffer = 0; if( !(p_stream->m_seek_fn(p_size,p_stream->m_user_data)) ) { - p_stream->m_status |= opj_stream_e_end; + p_stream->m_status |= OPJ_STREAM_STATUS_END; return OPJ_FALSE; } else { /* reset stream status */ - p_stream->m_status &= (~opj_stream_e_end); + p_stream->m_status &= (~OPJ_STREAM_STATUS_END); p_stream->m_byte_offset = p_size; } @@ -584,7 +584,7 @@ OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, opj_event_mgr_t * p_event_mgr) { if (! opj_stream_flush(p_stream,p_event_mgr)) { - p_stream->m_status |= opj_stream_e_error; + p_stream->m_status |= OPJ_STREAM_STATUS_ERROR; return OPJ_FALSE; } @@ -592,7 +592,7 @@ OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz p_stream->m_bytes_in_buffer = 0; if (! p_stream->m_seek_fn(p_size,p_stream->m_user_data)) { - p_stream->m_status |= opj_stream_e_error; + p_stream->m_status |= OPJ_STREAM_STATUS_ERROR; return OPJ_FALSE; } else { diff --git a/src/lib/openjp2/cio.h b/src/lib/openjp2/cio.h index 1b684ef8..4ea03ff3 100644 --- a/src/lib/openjp2/cio.h +++ b/src/lib/openjp2/cio.h @@ -70,16 +70,10 @@ The functions in CIO.C have for goal to realize a byte input / output process. #endif - -typedef enum -{ - opj_signed_sentinel = -1, /* do not use in code */ - opj_stream_e_output = 0x1, - opj_stream_e_input = 0x2, - opj_stream_e_end = 0x4, - opj_stream_e_error = 0x8 -} -opj_stream_flag ; +#define OPJ_STREAM_STATUS_OUTPUT 0x1U +#define OPJ_STREAM_STATUS_INPUT 0x2U +#define OPJ_STREAM_STATUS_END 0x4U +#define OPJ_STREAM_STATUS_ERROR 0x8U /** Byte input-output stream. @@ -162,8 +156,9 @@ typedef struct opj_stream_private /** * Flags to tell the status of the stream. + * Used with OPJ_STREAM_STATUS_* defines. */ - opj_stream_flag m_status; + OPJ_UINT32 m_status; } opj_stream_private_t; From c8ae3c522552271f426eaa9c6d158a72e9c5f26f Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 7 Oct 2015 11:58:11 +0200 Subject: [PATCH 19/21] Fix warnings for C++ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit g++ complains about invalid conversions like these ones: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] error: invalid conversion from ‘void*’ to ‘opj_precision* {aka opj_prec*}’ [-fpermissive] Signed-off-by: Stefan Weil --- src/bin/common/opj_getopt.c | 4 ++-- src/bin/jp2/convertpng.c | 2 +- src/bin/jp2/converttif.c | 6 +++--- src/bin/jp2/opj_decompress.c | 6 +++--- src/bin/jp2/opj_dump.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bin/common/opj_getopt.c b/src/bin/common/opj_getopt.c index 484c839d..65f271f8 100644 --- a/src/bin/common/opj_getopt.c +++ b/src/bin/common/opj_getopt.c @@ -66,7 +66,7 @@ void opj_reset_options_reading(void) { int opj_getopt(int nargc, char *const *nargv, const char *ostr) { # define __progname nargv[0] static char *place = EMSG; /* option letter processing */ - char *oli = NULL; /* option letter list index */ + const char *oli = NULL; /* option letter list index */ if (opj_optreset || !*place) { /* update scanning pointer */ opj_optreset = 0; @@ -125,7 +125,7 @@ int opj_getopt(int nargc, char *const *nargv, const char *ostr) { int opj_getopt_long(int argc, char * const argv[], const char *optstring, const opj_option_t *longopts, int totlen) { static int lastidx,lastofs; - char *tmp; + const char *tmp; int i,len; char param = 1; diff --git a/src/bin/jp2/convertpng.c b/src/bin/jp2/convertpng.c index 0999edbf..8d117412 100644 --- a/src/bin/jp2/convertpng.c +++ b/src/bin/jp2/convertpng.c @@ -211,7 +211,7 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params) image->x1 = (OPJ_UINT32)(image->x0 + (width - 1) * (OPJ_UINT32)params->subsampling_dx + 1 + image->x0); image->y1 = (OPJ_UINT32)(image->y0 + (height - 1) * (OPJ_UINT32)params->subsampling_dy + 1 + image->y0); - row32s = malloc((size_t)width * nr_comp * sizeof(OPJ_INT32)); + row32s = (OPJ_INT32 *)malloc((size_t)width * nr_comp * sizeof(OPJ_INT32)); if(row32s == NULL) goto fin; /* Set alpha channel */ diff --git a/src/bin/jp2/converttif.c b/src/bin/jp2/converttif.c index f164989f..dbda0741 100644 --- a/src/bin/jp2/converttif.c +++ b/src/bin/jp2/converttif.c @@ -290,7 +290,7 @@ int imagetotif(opj_image_t * image, const char *outfile) TIFFClose(tif); return 1; } - buffer32s = malloc((OPJ_SIZE_T)width * numcomps * sizeof(OPJ_INT32)); + buffer32s = (OPJ_INT32 *)malloc((OPJ_SIZE_T)width * numcomps * sizeof(OPJ_INT32)); if (buffer32s == NULL) { _TIFFfree(buf); TIFFClose(tif); @@ -299,7 +299,7 @@ int imagetotif(opj_image_t * image, const char *outfile) for (i = 0; i < image->comps[0].h; ++i) { cvtPxToCx(planes, buffer32s, (OPJ_SIZE_T)width, adjust); - cvt32sToTif(buffer32s, buf, (OPJ_SIZE_T)width * numcomps); + cvt32sToTif(buffer32s, (OPJ_BYTE *)buf, (OPJ_SIZE_T)width * numcomps); (void)TIFFWriteEncodedStrip(tif, i, (void*)buf, strip_size); planes[0] += width; planes[1] += width; @@ -590,7 +590,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters) return NULL; } rowStride = ((OPJ_SIZE_T)w * tiSpp * tiBps + 7U) / 8U; - buffer32s = malloc((OPJ_SIZE_T)w * tiSpp * sizeof(OPJ_INT32)); + buffer32s = (OPJ_INT32 *)malloc((OPJ_SIZE_T)w * tiSpp * sizeof(OPJ_INT32)); if (buffer32s == NULL) { _TIFFfree(buf); TIFFClose(tif); diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c index 04803e0e..eb319be4 100644 --- a/src/bin/jp2/opj_decompress.c +++ b/src/bin/jp2/opj_decompress.c @@ -291,7 +291,7 @@ static OPJ_BOOL parse_precision(const char* option, opj_decompress_parameters* p if (parameters->precision == NULL) { /* first one */ - parameters->precision = malloc(sizeof(opj_precision)); + parameters->precision = (opj_precision *)malloc(sizeof(opj_precision)); if (parameters->precision == NULL) { fprintf(stderr,"Could not allocate memory for precision option\n"); l_result = OPJ_FALSE; @@ -307,7 +307,7 @@ static OPJ_BOOL parse_precision(const char* option, opj_decompress_parameters* p break; } - l_new = realloc(parameters->precision, l_new_size * sizeof(opj_precision)); + l_new = (opj_precision *)realloc(parameters->precision, l_new_size * sizeof(opj_precision)); if (l_new == NULL) { fprintf(stderr,"Could not allocate memory for precision option\n"); l_result = OPJ_FALSE; @@ -400,7 +400,7 @@ int get_file_format(const char *filename) { unsigned int i; static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "rawl", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" }; static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, RAWL_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT }; - char * ext = strrchr(filename, '.'); + const char * ext = strrchr(filename, '.'); if (ext == NULL) return -1; ext++; diff --git a/src/bin/jp2/opj_dump.c b/src/bin/jp2/opj_dump.c index 562fd5a5..1e51f43c 100644 --- a/src/bin/jp2/opj_dump.c +++ b/src/bin/jp2/opj_dump.c @@ -171,7 +171,7 @@ static int get_file_format(const char *filename) { unsigned int i; static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" }; static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT }; - char * ext = strrchr(filename, '.'); + const char *ext = strrchr(filename, '.'); if (ext == NULL) return -1; ext++; From 553714a87a92930dd69f5762e0615c12dfcbd873 Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Fri, 9 Oct 2015 15:37:09 +0200 Subject: [PATCH 20/21] Make sure to allocate on 16bits alignement. Fix issue #624 --- src/lib/openjp2/tcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index 2fccff1c..3feb74ca 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -626,7 +626,7 @@ void opj_tcd_destroy(opj_tcd_t *tcd) { OPJ_BOOL opj_alloc_tile_component_data(opj_tcd_tilecomp_t *l_tilec) { if ((l_tilec->data == 00) || ((l_tilec->data_size_needed > l_tilec->data_size) && (l_tilec->ownsData == OPJ_FALSE))) { - l_tilec->data = (OPJ_INT32 *) opj_malloc(l_tilec->data_size_needed); + l_tilec->data = (OPJ_INT32 *) opj_aligned_malloc(l_tilec->data_size_needed); if (! l_tilec->data ) { return OPJ_FALSE; } From de0a9ed10302f94e1d0808ab4e88d6152742cb04 Mon Sep 17 00:00:00 2001 From: mayeut Date: Fri, 9 Oct 2015 21:13:06 +0200 Subject: [PATCH 21/21] Revert "Make sure to allocate on 16bits alignement. Fix issue #624" This reverts commit 553714a87a92930dd69f5762e0615c12dfcbd873. --- src/lib/openjp2/tcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index 3feb74ca..2fccff1c 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -626,7 +626,7 @@ void opj_tcd_destroy(opj_tcd_t *tcd) { OPJ_BOOL opj_alloc_tile_component_data(opj_tcd_tilecomp_t *l_tilec) { if ((l_tilec->data == 00) || ((l_tilec->data_size_needed > l_tilec->data_size) && (l_tilec->ownsData == OPJ_FALSE))) { - l_tilec->data = (OPJ_INT32 *) opj_aligned_malloc(l_tilec->data_size_needed); + l_tilec->data = (OPJ_INT32 *) opj_malloc(l_tilec->data_size_needed); if (! l_tilec->data ) { return OPJ_FALSE; }