fixed various minor warnings occuring under gcc, added corrections proposed in the...
authorFreeimage <freeimage@aliceadsl.fr>
Thu, 26 Jan 2006 20:02:04 +0000 (20:02 +0000)
committerFreeimage <freeimage@aliceadsl.fr>
Thu, 26 Jan 2006 20:02:04 +0000 (20:02 +0000)
ChangeLog
codec/image_to_j2k.c
codec/j2k_to_image.c
libopenjpeg/jp2.c
libopenjpeg/jp2.h
libopenjpeg/openjpeg.c
libopenjpeg/pi.c

index 1c5c9dc97cf12330149866c922bc45856af4b2fa..e5e936009d0f30defc78f0b4ab403a69c84cd988 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,11 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+January 26, 2006
+* [Herve Drolon] fixed various minor warnings occuring under gcc
+* [__david__] fixed a segfault in codec/image_to_j2k.c & codec/j2k_to_image.c
+* [__david__] fixed help option in codec/j2k_to_image & codec/image_to_j2k
+
 January 25, 2006
 ! [Mathieu Malaterre] Sync with ITK repository, also add ref to doxygen
 ! [Mathieu Malaterre] Add a lot of comments on the CMake build system
index 5508a26024bc138f70219e2ad8f9bdbfac77051a..80de10061f09ee37ca020c0e5ae3d3e9946704ec 100644 (file)
@@ -204,7 +204,7 @@ int get_file_format(char *filename) {
        static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp", "j2k", "jp2" };
        static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, J2K_CFMT, JP2_CFMT };
        char * ext = strrchr(filename, '.') + 1;
-       for(i = 0; i < sizeof(format); i++) {
+       for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
                if(strnicmp(ext, extension[i], 3) == 0) {
                        return format[i];
                }
@@ -221,7 +221,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters)
        /* parse the command line */
 
        while (1) {
-               int c = getopt(argc, argv, "i:o:r:q:f:t:n:c:b:x:p:s:d:h:P:S:E:M:R:T:C:I");
+               int c = getopt(argc, argv, "i:o:r:q:f:t:n:c:b:x:p:s:d:hP:S:E:M:R:T:C:I");
                if (c == -1)
                        break;
                switch (c) {
index b62c1e3353ebf6ecc4fc6e000c46376f506acfd1..13338f2c2ee5098cd13e6ba2122b3968816a4914 100644 (file)
@@ -92,7 +92,7 @@ int get_file_format(char *filename) {
        static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT };
        char * ext = strrchr(filename, '.') + 1;
        if(ext) {
-               for(i = 0; i < sizeof(format); i++) {
+               for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
                        if(strnicmp(ext, extension[i], 3) == 0) {
                                return format[i];
                        }
@@ -108,7 +108,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters)
        /* parse the command line */
 
        while (1) {
-               int c = getopt(argc, argv, "i:o:r:q:f:t:n:c:b:x:p:s:d:h:P:S:E:M:R:T:C:I");
+               int c = getopt(argc, argv, "i:o:r:q:f:t:n:c:b:x:p:s:d:hP:S:E:M:R:T:C:I");
                if (c == -1)
                        break;
                switch (c) {
index e224f4c6c82c93ff5b3cf09d1712ffbf33b3602f..c411f7e0c8478ae449d66e51693210c292a9e439 100644 (file)
@@ -81,7 +81,7 @@ Read the FTYP box - File type box
 @return Returns true if successful, returns false otherwise
 */
 static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio);
-static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, char *index);
+static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index);
 static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset);
 static void jp2_write_jp(opj_cio_t *cio);
 /**
@@ -414,12 +414,11 @@ static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio) {
        return true;
 }
 
-static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, char *index) {
+static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index) {
        unsigned int j2k_codestream_offset, j2k_codestream_length;
        opj_jp2_box_t box;
 
        opj_j2k_t *j2k = jp2->j2k;
-       opj_image_t *image = jp2->image;
 
        box.init_pos = cio_tell(cio);
        cio_skip(cio, 4);
@@ -635,8 +634,6 @@ void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_
 
        /* Image Header box */
 
-       jp2->image = image;
-
        jp2->numcomps = image->numcomps;        /* NC */
        jp2->comps = (opj_jp2_comps_t*) opj_malloc(jp2->numcomps * sizeof(opj_jp2_comps_t));
        jp2->h = image->y1 - image->y0;         /* HEIGHT */
@@ -684,7 +681,6 @@ void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_
 }
 
 bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index) {
-       (void)image;
 
        /* JP2 encoding */
 
@@ -697,7 +693,7 @@ bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index)
 
        /* J2K encoding */
 
-       if(!jp2_write_jp2c(jp2, cio, index)) {
+       if(!jp2_write_jp2c(jp2, cio, image, index)) {
                opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n");
                return false;
        }
index 2e4623f181780dbfa19e7a39b91b5e09e15bf187..f42689e15c3d698947941d281a680d48beaee218 100644 (file)
@@ -84,7 +84,6 @@ typedef struct opj_jp2 {
        unsigned int numcl;
        unsigned int *cl;
        opj_jp2_comps_t *comps;
-       opj_image_t *image;
        unsigned int j2k_codestream_offset;
        unsigned int j2k_codestream_length;
 } opj_jp2_t;
index 51d97e182b6af9c47c4c91a0b0bb043051b35a3f..b90eca6f3a972d81de568d54ba883b9055147500 100644 (file)
@@ -52,6 +52,7 @@ opj_dinfo_t* opj_create_decompress(OPJ_CODEC_FORMAT format) {
                                return NULL;
                        }
                        break;
+               case CODEC_UNKNOWN:
                default:
                        opj_free(dinfo);
                        return NULL;
@@ -73,6 +74,9 @@ void opj_destroy_decompress(opj_dinfo_t *dinfo) {
                        case CODEC_JP2:
                                jp2_destroy_decompress((opj_jp2_t*)dinfo->jp2_handle);
                                break;
+                       case CODEC_UNKNOWN:
+                       default:
+                               break;
                }
                /* destroy the decompressor */
                opj_free(dinfo);
@@ -101,6 +105,9 @@ void opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
                        case CODEC_JP2:
                                jp2_setup_decoder((opj_jp2_t*)dinfo->jp2_handle, parameters);
                                break;
+                       case CODEC_UNKNOWN:
+                       default:
+                               break;
                }
        }
 }
@@ -141,6 +148,8 @@ opj_cinfo_t* opj_create_compress(OPJ_CODEC_FORMAT format) {
                                return NULL;
                        }
                        break;
+               case CODEC_JPT:
+               case CODEC_UNKNOWN:
                default:
                        opj_free(cinfo);
                        return NULL;
@@ -161,6 +170,10 @@ void opj_destroy_compress(opj_cinfo_t *cinfo) {
                        case CODEC_JP2:
                                jp2_destroy_decompress((opj_jp2_t*)cinfo->jp2_handle);
                                break;
+                       case CODEC_JPT:
+                       case CODEC_UNKNOWN:
+                       default:
+                               break;
                }
                /* destroy the decompressor */
                opj_free(cinfo);
@@ -193,6 +206,10 @@ void opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_im
                        case CODEC_JP2:
                                jp2_setup_encoder((opj_jp2_t*)cinfo->jp2_handle, parameters, image);
                                break;
+                       case CODEC_JPT:
+                       case CODEC_UNKNOWN:
+                       default:
+                               break;
                }
        }
 }
@@ -204,6 +221,10 @@ bool opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *in
                                return j2k_encode((opj_j2k_t*)cinfo->j2k_handle, cio, image, index);
                        case CODEC_JP2:
                                return jp2_encode((opj_jp2_t*)cinfo->jp2_handle, cio, image, index);
+                       case CODEC_JPT:
+                       case CODEC_UNKNOWN:
+                       default:
+                               break;
                }
        }
 
index 1ac811e4d9045ff52c3012a77d0803927cd030bd..c13ff472299286fa91f122f00c3141ee3ed72cfc 100644 (file)
@@ -545,6 +545,8 @@ bool pi_next(opj_pi_iterator_t * pi) {
                        return pi_next_pcrl(pi);
                case CPRL:
                        return pi_next_cprl(pi);
+               case PROG_UNKNOWN:
+                       return false;
        }
        
        return false;