diff options
| author | Mickael Savinaud <savmickael@users.noreply.github.com> | 2011-08-11 10:18:02 +0000 |
|---|---|---|
| committer | Mickael Savinaud <savmickael@users.noreply.github.com> | 2011-08-11 10:18:02 +0000 |
| commit | 2724f85cadd8c24dfb235d790989edd19629a2cb (patch) | |
| tree | 01ab33fe728b35e7029781ae9848d04e9d1ecd95 /libopenjpeg | |
| parent | 40b989ce0066a4a15e8891209eeb3df510a158ff (diff) | |
| parent | e3e2dc1f6e5045ba7b180a7917b5b91a3a9b9e31 (diff) | |
backport rev[824-834] and rev[837-859] into the openjpeg-1.5 branch
Diffstat (limited to 'libopenjpeg')
| -rw-r--r-- | libopenjpeg/dwt.c | 2 | ||||
| -rw-r--r-- | libopenjpeg/event.c | 3 | ||||
| -rw-r--r-- | libopenjpeg/j2k.c | 27 | ||||
| -rw-r--r-- | libopenjpeg/jp2.c | 23 | ||||
| -rw-r--r-- | libopenjpeg/jpwl/jpwl.c | 11 | ||||
| -rw-r--r-- | libopenjpeg/jpwl/jpwl_lib.c | 9 | ||||
| -rw-r--r-- | libopenjpeg/openjpeg.c | 4 | ||||
| -rw-r--r-- | libopenjpeg/openjpeg.h | 2 | ||||
| -rw-r--r-- | libopenjpeg/t1.c | 6 | ||||
| -rw-r--r-- | libopenjpeg/t2.c | 4 | ||||
| -rw-r--r-- | libopenjpeg/tcd.c | 31 |
11 files changed, 82 insertions, 40 deletions
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/event.c b/libopenjpeg/event.c index df684ba2..0dc22f12 100644 --- a/libopenjpeg/event.c +++ b/libopenjpeg/event.c @@ -30,6 +30,7 @@ Utility functions ==========================================================*/ +#ifdef OPJ_CODE_NOT_USED #ifndef _WIN32 static char* i2a(unsigned i, char *a, unsigned r) { @@ -58,7 +59,7 @@ _itoa(int i, char *a, int r) { } #endif /* !_WIN32 */ - +#endif /* ----------------------------------------------------------------------- */ opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) { diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c index cbdee114..a07951ad 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[] = { @@ -297,6 +297,9 @@ static int j2k_get_num_tp(opj_cp_t *cp,int pino,int tileno){ /** mem allocation for TLM marker*/ int j2k_calculate_tp(opj_cp_t *cp,int img_numcomp,opj_image_t *image,opj_j2k_t *j2k ){ int pino,tileno,totnum_tp=0; + + OPJ_ARG_NOT_USED(img_numcomp); + j2k->cur_totnum_tp = (int *) opj_malloc(cp->tw * cp->th * sizeof(int)); for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { int cur_totnum_tp = 0; @@ -835,6 +838,15 @@ static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) { }; }; + +#else + /* We check whether there are too many subbands */ + if ((numbands < 0) || (numbands >= J2K_MAXBANDS)) { + opj_event_msg(j2k->cinfo, EVT_WARNING , + "bad number of subbands in Sqcx (%d) regarding to J2K_MAXBANDS (%d) \n" + "- limiting number of bands to J2K_MAXBANDS and try to move to the next markers\n", numbands, J2K_MAXBANDS); + } + #endif /* USE_JPWL */ for (bandno = 0; bandno < numbands; bandno++) { @@ -847,8 +859,10 @@ static void j2k_read_qcx(opj_j2k_t *j2k, int compno, int len) { expn = tmp >> 11; mant = tmp & 0x7ff; } - tccp->stepsizes[bandno].expn = expn; - tccp->stepsizes[bandno].mant = mant; + if (bandno < J2K_MAXBANDS){ + tccp->stepsizes[bandno].expn = expn; + tccp->stepsizes[bandno].mant = mant; + } } /* Add Antonin : if scalar_derived -> compute other stepsizes */ @@ -912,7 +926,7 @@ static void j2k_read_qcc(opj_j2k_t *j2k) { int len, compno; int numcomp = j2k->image->numcomps; opj_cio_t *cio = j2k->cio; - + len = cio_read(cio, 2); /* Lqcc */ compno = cio_read(cio, numcomp <= 256 ? 1 : 2); /* Cqcc */ @@ -1847,9 +1861,10 @@ opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestre opj_image_t *image = NULL; opj_jpt_msg_header_t header; int position; - opj_common_ptr cinfo = j2k->cinfo; - + + OPJ_ARG_NOT_USED(cstr_info); + j2k->cio = cio; /* create an empty image */ diff --git a/libopenjpeg/jp2.c b/libopenjpeg/jp2.c index ffbf270f..9c9c476f 100644 --- a/libopenjpeg/jp2.c +++ b/libopenjpeg/jp2.c @@ -398,13 +398,16 @@ static opj_bool jp2_read_pclr(opj_jp2_t *jp2, opj_cio_t *cio, unsigned short i, j; unsigned char uc; + OPJ_ARG_NOT_USED(box); + OPJ_ARG_NOT_USED(jp2); + /* Part 1, I.5.3.4: 'There shall be at most one Palette box inside * a JP2 Header box' : */ if(color->jp2_pclr) return OPJ_FALSE; - nr_entries = cio_read(cio, 2); /* NE */ - nr_channels = cio_read(cio, 1);/* NPC */ + nr_entries = (unsigned short)cio_read(cio, 2); /* NE */ + nr_channels = (unsigned short)cio_read(cio, 1);/* NPC */ entries = (unsigned int*) opj_malloc(nr_channels * nr_entries * sizeof(unsigned int)); @@ -446,6 +449,9 @@ static opj_bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_cmap_comp_t *cmap; unsigned short i, nr_channels; + OPJ_ARG_NOT_USED(box); + OPJ_ARG_NOT_USED(jp2); + /* Need nr_channels: */ if(color->jp2_pclr == NULL) return OPJ_FALSE; @@ -460,7 +466,7 @@ static opj_bool jp2_read_cmap(opj_jp2_t *jp2, opj_cio_t *cio, for(i = 0; i < nr_channels; ++i) { - cmap[i].cmp = cio_read(cio, 2); + cmap[i].cmp = (unsigned short)cio_read(cio, 2); cmap[i].mtyp = cio_read(cio, 1); cmap[i].pcol = cio_read(cio, 1); @@ -511,12 +517,15 @@ static opj_bool jp2_read_cdef(opj_jp2_t *jp2, opj_cio_t *cio, opj_jp2_cdef_info_t *info; unsigned short i, n; + OPJ_ARG_NOT_USED(box); + OPJ_ARG_NOT_USED(jp2); + /* Part 1, I.5.3.6: 'The shall be at most one Channel Definition box * inside a JP2 Header box.' */ if(color->jp2_cdef) return OPJ_FALSE; - if((n = cio_read(cio, 2)) == 0) return OPJ_FALSE; /* szukw000: FIXME */ + if((n = (unsigned short)cio_read(cio, 2)) == 0) return OPJ_FALSE; /* szukw000: FIXME */ info = (opj_jp2_cdef_info_t*) opj_malloc(n * sizeof(opj_jp2_cdef_info_t)); @@ -527,9 +536,9 @@ static opj_bool jp2_read_cdef(opj_jp2_t *jp2, opj_cio_t *cio, for(i = 0; i < n; ++i) { - info[i].cn = cio_read(cio, 2); - info[i].typ = cio_read(cio, 2); - info[i].asoc = cio_read(cio, 2); + info[i].cn = (unsigned short)cio_read(cio, 2); + info[i].typ = (unsigned short)cio_read(cio, 2); + info[i].asoc = (unsigned short)cio_read(cio, 2); } return OPJ_TRUE; 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 */ diff --git a/libopenjpeg/openjpeg.c b/libopenjpeg/openjpeg.c index 790f2eea..00a910ec 100644 --- a/libopenjpeg/openjpeg.c +++ b/libopenjpeg/openjpeg.c @@ -36,6 +36,10 @@ #ifndef OPJ_STATIC BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + + OPJ_ARG_NOT_USED(lpReserved); + OPJ_ARG_NOT_USED(hModule); + switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH : break; diff --git a/libopenjpeg/openjpeg.h b/libopenjpeg/openjpeg.h index dfc4dc64..c46d896f 100644 --- a/libopenjpeg/openjpeg.h +++ b/libopenjpeg/openjpeg.h @@ -63,6 +63,8 @@ typedef int opj_bool; #define OPJ_TRUE 1 #define OPJ_FALSE 0 +// Avoid compile-time warning because parameter is not used +#define OPJ_ARG_NOT_USED(x) (void)(x) /* ========================================================== Useful constant definitions diff --git a/libopenjpeg/t1.c b/libopenjpeg/t1.c index 002a82d4..b3ede36a 100644 --- a/libopenjpeg/t1.c +++ b/libopenjpeg/t1.c @@ -382,9 +382,10 @@ static INLINE void t1_dec_sigpass_step_raw( int vsc) { int v, flag; - opj_raw_t *raw = t1->raw; /* RAW component */ + OPJ_ARG_NOT_USED(orient); + flag = vsc ? ((*flagsp) & (~(T1_SIG_S | T1_SIG_SE | T1_SIG_SW | T1_SGN_S))) : (*flagsp); if ((flag & T1_SIG_OTH) && !(flag & (T1_SIG | T1_VISIT))) { if (raw_decode(raw)) { @@ -823,9 +824,10 @@ static void t1_dec_clnpass_step_partial( int oneplushalf) { int v, flag; - opj_mqc_t *mqc = t1->mqc; /* MQC component */ + OPJ_ARG_NOT_USED(orient); + flag = *flagsp; mqc_setcurctx(mqc, t1_getctxno_sc(flag)); v = mqc_decode(mqc) ^ t1_getspb(flag); diff --git a/libopenjpeg/t2.c b/libopenjpeg/t2.c index 4af8eb84..76821afc 100644 --- a/libopenjpeg/t2.c +++ b/libopenjpeg/t2.c @@ -149,8 +149,8 @@ static int t2_encode_packet(opj_tcd_tile_t * tile, opj_tcp_t * tcp, opj_pi_itera c[1] = 145; c[2] = 0; c[3] = 4; - c[4] = (tile->packno % 65536) / 256; - c[5] = (tile->packno % 65536) % 256; + c[4] = (unsigned char)((tile->packno % 65536) / 256); + c[5] = (unsigned char)((tile->packno % 65536) % 256); c += 6; } /* </SOP> */ diff --git a/libopenjpeg/tcd.c b/libopenjpeg/tcd.c index 26548564..9c7bcc0d 100644 --- a/libopenjpeg/tcd.c +++ b/libopenjpeg/tcd.c @@ -676,6 +676,8 @@ void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, opj_tcp_t *tcp; opj_tcd_tile_t *tile; + OPJ_ARG_NOT_USED(cstr_info); + tcd->cp = cp; tcp = &(cp->tcps[cp->tileno[tileno]]); @@ -1416,18 +1418,23 @@ opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno if (tcd->tcp->mct) { int n = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0); - if (tcd->tcp->tccps[0].qmfbid == 1) { - mct_decode( - tile->comps[0].data, - tile->comps[1].data, - tile->comps[2].data, - n); - } else { - mct_decode_real( - (float*)tile->comps[0].data, - (float*)tile->comps[1].data, - (float*)tile->comps[2].data, - n); + + if (tile->numcomps >= 3 ){ + if (tcd->tcp->tccps[0].qmfbid == 1) { + mct_decode( + tile->comps[0].data, + tile->comps[1].data, + tile->comps[2].data, + n); + } else { + mct_decode_real( + (float*)tile->comps[0].data, + (float*)tile->comps[1].data, + (float*)tile->comps[2].data, + n); + } + } else{ + opj_event_msg(tcd->cinfo, EVT_WARNING,"Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",tile->numcomps); } } |
