From e716a316f60f66cd5a6fb07b88b2cb8b9c815cec Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Thu, 28 Jul 2011 10:45:22 +0000 Subject: [PATCH] manage case 0 frames inside yuv_num_frames function and correct some warnings with gcc4.5 (credit to Winfried) --- applications/codec/convert.c | 3 +-- applications/codec/j2k_to_image.c | 2 +- applications/common/getopt.c | 2 +- .../opj_dec_server/opj_dec_server.c | 2 +- applications/mj2/frames_to_mj2.c | 20 +++++++++---------- applications/mj2/mj2.c | 14 +++++-------- applications/mj2/mj2.h | 8 ++++---- applications/mj2/mj2_convert.c | 18 ++++++++--------- applications/mj2/mj2_convert.h | 2 +- libopenjpeg/dwt.c | 2 +- libopenjpeg/j2k.c | 2 +- libopenjpeg/jpwl/jpwl.c | 11 +++++----- libopenjpeg/jpwl/jpwl_lib.c | 9 +++++---- 13 files changed, 45 insertions(+), 50 deletions(-) diff --git a/applications/codec/convert.c b/applications/codec/convert.c index 502539f7..c7adabe9 100644 --- a/applications/codec/convert.c +++ b/applications/codec/convert.c @@ -1968,7 +1968,6 @@ int imagetotif(opj_image_t * image, const char *outfile) int width, height, imgsize; int bps,index,adjust, sgnd; int ushift, dshift, has_alpha, force16; - unsigned int last_i=0; TIFF *tif; tdata_t buf; tstrip_t strip; @@ -2029,7 +2028,7 @@ int imagetotif(opj_image_t * image, const char *outfile) for(strip = 0; strip < TIFFNumberOfStrips(tif); strip++) { unsigned char *dat8; - tsize_t i, ssize; + tsize_t i, ssize, last_i = 0; int step, restx; ssize = TIFFStripSize(tif); dat8 = (unsigned char*)buf; diff --git a/applications/codec/j2k_to_image.c b/applications/codec/j2k_to_image.c index b8f237bd..3da83119 100644 --- a/applications/codec/j2k_to_image.c +++ b/applications/codec/j2k_to_image.c @@ -595,7 +595,7 @@ int main(int argc, char **argv) { file_length = ftell(fsrc); fseek(fsrc, 0, SEEK_SET); src = (unsigned char *) malloc(file_length); - if (fread(src, 1, file_length, fsrc) != file_length) + if (fread(src, 1, file_length, fsrc) != (size_t)file_length) { free(src); fclose(fsrc); diff --git a/applications/common/getopt.c b/applications/common/getopt.c index 5e444d39..a02dde96 100644 --- a/applications/common/getopt.c +++ b/applications/common/getopt.c @@ -129,7 +129,7 @@ int getopt(int nargc, char *const *nargv, const char *ostr) { int getopt_long(int argc, char * const argv[], const char *optstring, -struct option *longopts, int totlen) { +const struct option *longopts, int totlen) { static int lastidx,lastofs; char *tmp; int i,len; diff --git a/applications/jpip/opj_client/opj_dec_server/opj_dec_server.c b/applications/jpip/opj_client/opj_dec_server/opj_dec_server.c index e2709797..895ade5c 100644 --- a/applications/jpip/opj_client/opj_dec_server/opj_dec_server.c +++ b/applications/jpip/opj_client/opj_dec_server/opj_dec_server.c @@ -144,7 +144,7 @@ int main(int argc, char *argv[]){ int listening_socket = open_listeningsocket(); - int addrlen = sizeof(peer_sin); + unsigned int addrlen = sizeof(peer_sin); cachelist_param_t *cachelist = gene_cachelist(); diff --git a/applications/mj2/frames_to_mj2.c b/applications/mj2/frames_to_mj2.c index 4e89956f..1e0d29a9 100644 --- a/applications/mj2/frames_to_mj2.c +++ b/applications/mj2/frames_to_mj2.c @@ -199,29 +199,29 @@ void help_display() fprintf(stdout,"TotalDisto\n\n"); } -int give_progression(char progression[4]) +OPJ_PROG_ORDER give_progression(char progression[5]) { if (progression[0] == 'L' && progression[1] == 'R' && progression[2] == 'C' && progression[3] == 'P') { - return 0; + return LRCP; } else { if (progression[0] == 'R' && progression[1] == 'L' && progression[2] == 'C' && progression[3] == 'P') { - return 1; + return RLCP; } else { if (progression[0] == 'R' && progression[1] == 'P' && progression[2] == 'C' && progression[3] == 'L') { - return 2; + return RPCL; } else { if (progression[0] == 'P' && progression[1] == 'C' && progression[2] == 'R' && progression[3] == 'L') { - return 3; + return PCRL; } else { if (progression[0] == 'C' && progression[1] == 'P' && progression[2] == 'R' && progression[3] == 'L') { - return 4; + return CPRL; } else { - return -1; + return PROG_UNKNOWN; } } } @@ -475,9 +475,9 @@ int main(int argc, char **argv) /* ----------------------------------------------------- */ case 'p': /* progression order */ { - char progression[4]; + char progression[5]; - strncpy(progression, optarg, 4); + strncpy(progression, optarg, 5); j2k_parameters->prog_order = give_progression(progression); if (j2k_parameters->prog_order == -1) { fprintf(stderr, "Unrecognized progression order " @@ -696,7 +696,7 @@ int main(int argc, char **argv) movie->tk[0].num_samples = yuv_num_frames(&movie->tk[0],mj2_parameters.infile); - if (movie->tk[0].num_samples == -1) { + if (movie->tk[0].num_samples == 0) { return 1; } diff --git a/applications/mj2/mj2.c b/applications/mj2/mj2.c index dfab1917..fe48415b 100644 --- a/applications/mj2/mj2.c +++ b/applications/mj2/mj2.c @@ -240,9 +240,7 @@ void mj2_tts_decompact(mj2_tk_t * tk) */ void mj2_stsc_decompact(mj2_tk_t * tk) { - int j, i; - unsigned int k; - int sampleno=0; + unsigned int i, j, k, sampleno = 0; if (tk->num_samplestochunk == 1) { tk->num_chunks = @@ -283,10 +281,8 @@ void mj2_stsc_decompact(mj2_tk_t * tk) */ void mj2_stco_decompact(mj2_tk_t * tk) { - int j; - unsigned int i; - int k = 0; - int intra_chunk_offset; + unsigned int i, j, k = 0; + unsigned int intra_chunk_offset; for (i = 0; i < tk->num_chunks; i++) { intra_chunk_offset = 0; @@ -585,7 +581,7 @@ int mj2_read_stsz(mj2_tk_t * tk, opj_cio_t *cio) */ void mj2_write_stsc(mj2_tk_t * tk, opj_cio_t *cio) { - int i; + unsigned int i; mj2_box_t box; box.init_pos = cio_tell(cio); @@ -617,7 +613,7 @@ void mj2_write_stsc(mj2_tk_t * tk, opj_cio_t *cio) */ int mj2_read_stsc(mj2_tk_t * tk, opj_cio_t *cio) { - int i; + unsigned int i; mj2_box_t box; mj2_read_boxhdr(&box, cio); /* Box Size */ diff --git a/applications/mj2/mj2.h b/applications/mj2/mj2.h index d4f27451..2e3d0b15 100644 --- a/applications/mj2/mj2.h +++ b/applications/mj2/mj2.h @@ -103,7 +103,7 @@ typedef struct mj2_tts { Chunk */ typedef struct mj2_chunk { - int num_samples; + unsigned int num_samples; int sample_descr_idx; int offset; } mj2_chunk_t; @@ -112,8 +112,8 @@ typedef struct mj2_chunk { Sample to chunk */ typedef struct mj2_sampletochunk { - int first_chunk; - int samples_per_chunk; + unsigned int first_chunk; + unsigned int samples_per_chunk; int sample_descr_idx; } mj2_sampletochunk_t; @@ -205,7 +205,7 @@ typedef struct mj2_tk { mj2_tts_t *tts; unsigned int num_chunks; mj2_chunk_t *chunk; - int num_samplestochunk; + unsigned int num_samplestochunk; mj2_sampletochunk_t *sampletochunk; char *name; opj_jp2_t jp2_struct; diff --git a/applications/mj2/mj2_convert.c b/applications/mj2/mj2_convert.c index 0f2d975d..3d842883 100644 --- a/applications/mj2/mj2_convert.c +++ b/applications/mj2/mj2_convert.c @@ -37,20 +37,20 @@ /* */ /* ----------------------- */ -int yuv_num_frames(mj2_tk_t * tk, char *infile) +unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile) { - int numimages, frame_size, prec_size; - long end_of_f; + unsigned int prec_size; + long end_of_f, frame_size; FILE *f; f = fopen(infile,"rb"); if (!f) { fprintf(stderr, "failed to open %s for reading\n",infile); - return -1; + return 0; } prec_size = (tk->depth + 7)/8;/* bytes of precision */ - frame_size = (int) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy))); /* Calculate frame size */ + frame_size = (long) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy))); /* Calculate frame size */ frame_size *= prec_size; fseek(f, 0, SEEK_END); @@ -60,13 +60,11 @@ int yuv_num_frames(mj2_tk_t * tk, char *infile) fprintf(stderr, "YUV does not contains any frame of %d x %d size\n", tk->w, tk->h); - return -1; + return 0; } + fclose(f); - numimages = end_of_f / frame_size; /* Calculate number of images */ - fclose(f); - - return numimages; + return (unsigned int)(end_of_f / frame_size); } // ----------------------- diff --git a/applications/mj2/mj2_convert.h b/applications/mj2/mj2_convert.h index 78e6c470..19ba99f7 100644 --- a/applications/mj2/mj2_convert.h +++ b/applications/mj2/mj2_convert.h @@ -39,7 +39,7 @@ opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters); char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile); -int yuv_num_frames(mj2_tk_t * tk, char *infile); +unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile); #endif diff --git a/libopenjpeg/dwt.c b/libopenjpeg/dwt.c index 3436b103..e7d74e2f 100644 --- a/libopenjpeg/dwt.c +++ b/libopenjpeg/dwt.c @@ -527,7 +527,7 @@ static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1 int w = tilec->x1 - tilec->x0; - h.mem = opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int)); + h.mem = (int*)opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int)); v.mem = h.mem; while( --numres) { diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c index cbdee114..0b09899a 100644 --- a/libopenjpeg/j2k.c +++ b/libopenjpeg/j2k.c @@ -236,7 +236,7 @@ static void j2k_read_unk(opj_j2k_t *j2k); /* ----------------------------------------------------------------------- */ typedef struct j2k_prog_order{ OPJ_PROG_ORDER enum_prog; - char str_prog[4]; + char str_prog[5]; }j2k_prog_order_t; j2k_prog_order_t j2k_prog_order_list[] = { diff --git a/libopenjpeg/jpwl/jpwl.c b/libopenjpeg/jpwl/jpwl.c index 707e46fd..a910ea78 100644 --- a/libopenjpeg/jpwl/jpwl.c +++ b/libopenjpeg/jpwl/jpwl.c @@ -75,9 +75,10 @@ jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, opj_bool esd_on, opj_bool red_on, @param sensval pointer to an array of sensitivity values (if NULL, they will be automatically filled) @return returns the freshly created ESD */ -jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comps, unsigned char addrm, unsigned char ad_size, - unsigned char senst, int se_size, int tileno, - unsigned long int svalnum, void *sensval); +jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comps, + unsigned char addrm, unsigned char ad_size, + unsigned char senst, int se_size, int tileno, + unsigned long int svalnum, void *sensval); /** this function is used to compare two JPWL markers based on their relevant wishlist position @@ -168,7 +169,7 @@ void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, i /* expand the list? */ if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) { cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F); - cstr_info->marker = opj_realloc(cstr_info->marker, cstr_info->maxmarknum); + cstr_info->marker = (opj_marker_info_t*)opj_realloc(cstr_info->marker, cstr_info->maxmarknum); } /* add the marker */ @@ -906,7 +907,7 @@ void j2k_read_epc(opj_j2k_t *j2k) { unsigned short int Lepc, Pcrc = 0x0000; unsigned char Pepc; opj_cio_t *cio = j2k->cio; - char *ans1; + const char *ans1; /* Simply read the EPC parameters */ Lepcp = cio_tell(cio); diff --git a/libopenjpeg/jpwl/jpwl_lib.c b/libopenjpeg/jpwl/jpwl_lib.c index f60d33b1..90a71cec 100644 --- a/libopenjpeg/jpwl/jpwl_lib.c +++ b/libopenjpeg/jpwl/jpwl_lib.c @@ -1200,9 +1200,10 @@ int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num, return 0; } -jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, unsigned char ad_size, - unsigned char senst, unsigned char se_size, int tileno, - unsigned long int svalnum, void *sensval) { +jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, + unsigned char addrm, unsigned char ad_size, + unsigned char senst, int se_size, int tileno, + unsigned long int svalnum, void *sensval) { jpwl_esd_ms_t *esd = NULL; @@ -1232,7 +1233,7 @@ jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, un /* packet mode */ case (0): ad_size = 0; /* as per the standard */ - esd->sensval_size = se_size; + esd->sensval_size = (unsigned int)se_size; break; /* byte range */