diff options
Diffstat (limited to 'converter/other/jpeg2000/libjasper/jpc')
-rw-r--r-- | converter/other/jpeg2000/libjasper/jpc/jpc_dec.c | 15 | ||||
-rw-r--r-- | converter/other/jpeg2000/libjasper/jpc/jpc_enc.c | 494 | ||||
-rw-r--r-- | converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c | 1557 | ||||
-rw-r--r-- | converter/other/jpeg2000/libjasper/jpc/jpc_util.c | 26 |
4 files changed, 1106 insertions, 986 deletions
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c index 72bd0126..cada97f8 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_dec.c @@ -458,6 +458,12 @@ static int jpc_dec_decode(jpc_dec_t *dec) static int jpc_dec_process_crg(jpc_dec_t *dec, jpc_ms_t *ms) { + /* Ignore the information in the CRG marker segment for now. + This information serves no useful purpose for decoding anyhow. + Some other parts of the code need to be changed if these lines + are enabled. + */ +#ifdef USING_CRG uint_fast16_t cmptno; jpc_dec_cmpt_t *cmpt; jpc_crg_t *crg; @@ -465,14 +471,10 @@ static int jpc_dec_process_crg(jpc_dec_t *dec, jpc_ms_t *ms) crg = &ms->parms.crg; for (cmptno = 0, cmpt = dec->cmpts; cmptno < dec->numcomps; ++cmptno, ++cmpt) { - /* Ignore the information in the CRG marker segment for now. - This information serves no useful purpose for decoding anyhow. - Some other parts of the code need to be changed if these lines - are uncommented. cmpt->hsubstep = crg->comps[cmptno].hoff; cmpt->vsubstep = crg->comps[cmptno].voff; - */ } +#endif return 0; } @@ -701,7 +703,6 @@ static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile) uint_fast32_t tlcbgxstart; uint_fast32_t tlcbgystart; uint_fast32_t brcbgxend; - uint_fast32_t brcbgyend; uint_fast32_t cbgxstart; uint_fast32_t cbgystart; uint_fast32_t cbgxend; @@ -792,14 +793,12 @@ rlvl->bands = 0; tlcbgxstart = tlprcxstart; tlcbgystart = tlprcystart; brcbgxend = brprcxend; - brcbgyend = brprcyend; rlvl->cbgwidthexpn = rlvl->prcwidthexpn; rlvl->cbgheightexpn = rlvl->prcheightexpn; } else { tlcbgxstart = JPC_CEILDIVPOW2(tlprcxstart, 1); tlcbgystart = JPC_CEILDIVPOW2(tlprcystart, 1); brcbgxend = JPC_CEILDIVPOW2(brprcxend, 1); - brcbgyend = JPC_CEILDIVPOW2(brprcyend, 1); rlvl->cbgwidthexpn = rlvl->prcwidthexpn - 1; rlvl->cbgheightexpn = rlvl->prcheightexpn - 1; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c index d17e9aa3..9db41ca2 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c @@ -73,9 +73,9 @@ int ratestrtosize(const char *s, uint_fast32_t rawsize, uint_fast32_t *size); static void pass_destroy(jpc_enc_pass_t *pass); void jpc_enc_dump(jpc_enc_t *enc); -/******************************************************************************\ +/*****************************************************************************\ * Local prototypes. -\******************************************************************************/ +\*****************************************************************************/ void quantize(jas_matrix_t *data, jpc_fix_t stepsize); static int jpc_enc_encodemainhdr(jpc_enc_t *enc); @@ -90,8 +90,11 @@ int setins(int numvalues, jpc_flt_t *values, jpc_flt_t value); static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image); void jpc_enc_cp_destroy(jpc_enc_cp_t *cp); -static uint_fast32_t jpc_abstorelstepsize(jpc_fix_t absdelta, int scaleexpn) -{ + + +static uint_fast32_t +jpc_abstorelstepsize(jpc_fix_t absdelta, int scaleexpn) { + int p; uint_fast32_t mant; uint_fast32_t expn; @@ -111,6 +114,8 @@ static uint_fast32_t jpc_abstorelstepsize(jpc_fix_t absdelta, int scaleexpn) return JPC_QCX_EXPN(expn) | JPC_QCX_MANT(mant); } + + typedef enum { OPT_DEBUG, OPT_IMGAREAOFFX, @@ -199,6 +204,7 @@ jas_taginfo_t modetab[] = { }; + static void tracev(const char * const fmt, va_list args) { @@ -224,12 +230,9 @@ trace(const char * const fmt, ...) { -/******************************************************************************\ -* The main encoder entry point. -\******************************************************************************/ +int +jpc_encode(jas_image_t *image, jas_stream_t *out, char *optstr) { -int jpc_encode(jas_image_t *image, jas_stream_t *out, char *optstr) -{ jpc_enc_t *enc; jpc_enc_cp_t *cp; @@ -287,12 +290,15 @@ error: return -1; } -/******************************************************************************\ + + +/*****************************************************************************\ * Option parsing code. -\******************************************************************************/ +\*****************************************************************************/ + +static jpc_enc_cp_t * +cp_create(char *optstr, jas_image_t *image) { -static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image) -{ jpc_enc_cp_t *cp; jas_tvparser_t *tvp; int ret; @@ -343,10 +349,12 @@ static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image) hsteplcm = 1; vsteplcm = 1; for (cmptno = 0; cmptno < jas_image_numcmpts(image); ++cmptno) { - if (jas_image_cmptbrx(image, cmptno) + jas_image_cmpthstep(image, cmptno) <= + if (jas_image_cmptbrx(image, cmptno) + + jas_image_cmpthstep(image, cmptno) <= jas_image_brx(image) || jas_image_cmptbry(image, cmptno) + jas_image_cmptvstep(image, cmptno) <= jas_image_bry(image)) { - fprintf(stderr, "We don't know how to interpret this image type\n"); + fprintf(stderr, + "We don't know how to interpret this image type\n"); goto error; } /* Note: We ought to be calculating the LCMs here. Fix some day. */ @@ -495,7 +503,8 @@ static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image) if (jpc_atoaf(jas_tvparser_getval(tvp), &numilyrrates, &ilyrrates)) { fprintf(stderr, - "warning: invalid intermediate layer rates specifier ignored (%s)\n", + "warning: invalid intermediate layer rates specifier " + "ignored (%s)\n", jas_tvparser_getval(tvp)); } break; @@ -552,20 +561,26 @@ static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image) if (cp->numcmpts == 3) { mctvalid = true; for (cmptno = 0; cmptno < jas_image_numcmpts(image); ++cmptno) { - if (jas_image_cmptprec(image, cmptno) != jas_image_cmptprec(image, 0) || - jas_image_cmptsgnd(image, cmptno) != jas_image_cmptsgnd(image, 0) || - jas_image_cmptwidth(image, cmptno) != jas_image_cmptwidth(image, 0) || - jas_image_cmptheight(image, cmptno) != jas_image_cmptheight(image, 0)) { + if (jas_image_cmptprec(image, cmptno) != + jas_image_cmptprec(image, 0) || + jas_image_cmptsgnd(image, cmptno) != + jas_image_cmptsgnd(image, 0) || + jas_image_cmptwidth(image, cmptno) != + jas_image_cmptwidth(image, 0) || + jas_image_cmptheight(image, cmptno) != + jas_image_cmptheight(image, 0)) { mctvalid = false; } } } else { mctvalid = false; } - if (mctvalid && enablemct && jas_image_colorspace(image) != JAS_IMAGE_CS_RGB) { + if (mctvalid && enablemct && jas_image_colorspace(image) != + JAS_IMAGE_CS_RGB) { fprintf(stderr, "warning: color model apparently not RGB\n"); } - if (mctvalid && enablemct && jas_image_colorspace(image) == JAS_IMAGE_CS_RGB) { + if (mctvalid && enablemct && jas_image_colorspace(image) == + JAS_IMAGE_CS_RGB) { tcp->mctid = (tcp->intmode) ? (JPC_MCT_RCT) : (JPC_MCT_ICT); } else { tcp->mctid = JPC_MCT_NONE; @@ -682,16 +697,20 @@ static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image) /* The intermediate layers rates must increase monotonically. */ for (lyrno = 0; lyrno + 2 < tcp->numlyrs; ++lyrno) { if (tcp->ilyrrates[lyrno] >= tcp->ilyrrates[lyrno + 1]) { - fprintf(stderr, "intermediate layer rates must increase monotonically\n"); + fprintf(stderr, + "intermediate layer rates must increase " + "monotonically\n"); goto error; } } /* The intermediate layer rates must be less than the overall rate. */ if (cp->totalsize != UINT_FAST32_MAX) { for (lyrno = 0; lyrno < tcp->numlyrs - 1; ++lyrno) { - if (jpc_fixtodbl(tcp->ilyrrates[lyrno]) > ((double) cp->totalsize) - / cp->rawsize) { - fprintf(stderr, "warning: intermediate layer rates must be less than overall rate\n"); + if (jpc_fixtodbl(tcp->ilyrrates[lyrno]) > + ((double) cp->totalsize) / cp->rawsize) { + fprintf(stderr, + "warning: intermediate layer rates must be " + "less than overall rate\n"); goto error; } } @@ -718,8 +737,11 @@ error: return 0; } -void jpc_enc_cp_destroy(jpc_enc_cp_t *cp) -{ + + +void +jpc_enc_cp_destroy(jpc_enc_cp_t *cp) { + if (cp->ccps) { if (cp->tcp.ilyrrates) { jas_free(cp->tcp.ilyrrates); @@ -729,8 +751,11 @@ void jpc_enc_cp_destroy(jpc_enc_cp_t *cp) jas_free(cp); } -int ratestrtosize(const char *s, uint_fast32_t rawsize, uint_fast32_t *size) -{ + + +int +ratestrtosize(const char *s, uint_fast32_t rawsize, uint_fast32_t *size) { + char *cp; jpc_flt_t f; @@ -750,12 +775,13 @@ int ratestrtosize(const char *s, uint_fast32_t rawsize, uint_fast32_t *size) return 0; } -/******************************************************************************\ +/*****************************************************************************\ * Encoder constructor and destructor. -\******************************************************************************/ +\*****************************************************************************/ + +jpc_enc_t * +jpc_enc_create(jpc_enc_cp_t *cp, jas_stream_t *out, jas_image_t *image) { -jpc_enc_t *jpc_enc_create(jpc_enc_cp_t *cp, jas_stream_t *out, jas_image_t *image) -{ jpc_enc_t *enc; enc = 0; @@ -788,11 +814,15 @@ error: return 0; } -void jpc_enc_destroy(jpc_enc_t *enc) -{ + + +void +jpc_enc_destroy(jpc_enc_t *enc) { + /* The image object (i.e., enc->image) and output stream object - (i.e., enc->out) are created outside of the encoder. - Therefore, they must not be destroyed here. */ + (i.e., enc->out) are created outside of the encoder. + Therefore, they must not be destroyed here. + */ if (enc->curtile) { jpc_enc_tile_destroy(enc->curtile); @@ -810,24 +840,22 @@ void jpc_enc_destroy(jpc_enc_t *enc) jas_free(enc); } -/******************************************************************************\ -* Code. -\******************************************************************************/ -static int jpc_enc_encodemainhdr(jpc_enc_t *enc) -{ + +static int +jpc_enc_encodemainhdr(jpc_enc_t *enc) { + jpc_siz_t *siz; jpc_cod_t *cod; jpc_qcd_t *qcd; int i; -long startoff; -long mainhdrlen; + long startoff; + long mainhdrlen; jpc_enc_cp_t *cp; jpc_qcc_t *qcc; jpc_enc_tccp_t *tccp; uint_fast16_t cmptno; jpc_tsfb_band_t bandinfos[JPC_MAXBANDS]; - jpc_fix_t mctsynweight; jpc_enc_tcp_t *tcp; jpc_tsfb_t *tsfb; jpc_tsfb_band_t *bandinfo; @@ -841,7 +869,7 @@ long mainhdrlen; cp = enc->cp; -startoff = jas_stream_getrwcount(enc->out); + startoff = jas_stream_getrwcount(enc->out); /* Write SOC marker segment. */ if (!(enc->mrk = jpc_ms_create(JPC_MS_SOC))) { @@ -922,7 +950,6 @@ startoff = jas_stream_getrwcount(enc->out); jpc_tsfb_getbands(tsfb, 0, 0, 1 << tccp->maxrlvls, 1 << tccp->maxrlvls, bandinfos); jpc_tsfb_destroy(tsfb); - mctsynweight = jpc_mct_getsynweight(tcp->mctid, cmptno); numbands = 3 * tccp->maxrlvls - 2; for (bandno = 0, bandinfo = bandinfos; bandno < numbands; ++bandno, ++bandinfo) { @@ -953,14 +980,17 @@ startoff = jas_stream_getrwcount(enc->out); cod->prg = cp->tcp.prg; cod->numlyrs = cp->tcp.numlyrs; cod->compparms.cblkwidthval = JPC_COX_CBLKSIZEEXPN(cp->tccp.cblkwidthexpn); - cod->compparms.cblkheightval = JPC_COX_CBLKSIZEEXPN(cp->tccp.cblkheightexpn); + cod->compparms.cblkheightval = + JPC_COX_CBLKSIZEEXPN(cp->tccp.cblkheightexpn); cod->compparms.cblksty = cp->tccp.cblksty; cod->compparms.qmfbid = cp->tccp.qmfbid; cod->mctrans = (cp->tcp.mctid != JPC_MCT_NONE); if (tccp->csty & JPC_COX_PRT) { for (rlvlno = 0; rlvlno < tccp->maxrlvls; ++rlvlno) { - cod->compparms.rlvls[rlvlno].parwidthval = tccp->prcwidthexpns[rlvlno]; - cod->compparms.rlvls[rlvlno].parheightval = tccp->prcheightexpns[rlvlno]; + cod->compparms.rlvls[rlvlno].parwidthval = + tccp->prcwidthexpns[rlvlno]; + cod->compparms.rlvls[rlvlno].parheightval = + tccp->prcheightexpns[rlvlno]; } } if (jpc_putms(enc->out, enc->cstate, enc->mrk)) { @@ -1023,17 +1053,23 @@ startoff = jas_stream_getrwcount(enc->out); return 0; } -int jpc_enc_encodetiledata(jpc_enc_t *enc) -{ -assert(enc->tmpstream); + + +int +jpc_enc_encodetiledata(jpc_enc_t *enc) { + + assert(enc->tmpstream); if (jpc_enc_encpkts(enc, enc->tmpstream)) { return -1; } return 0; } -void quantize(jas_matrix_t *data, jpc_fix_t stepsize) -{ + + +void +quantize(jas_matrix_t *data, jpc_fix_t stepsize) { + int i; int j; jpc_fix_t t; @@ -1059,8 +1095,11 @@ void quantize(jas_matrix_t *data, jpc_fix_t stepsize) } } -static void calcrdslopes(jpc_enc_cblk_t *cblk) -{ + + +static void +calcrdslopes(jpc_enc_cblk_t *cblk) { + jpc_enc_pass_t *endpasses; jpc_enc_pass_t *pass0; jpc_enc_pass_t *pass1; @@ -1113,10 +1152,12 @@ static void calcrdslopes(jpc_enc_cblk_t *cblk) #if 0 for (pass0 = cblk->passes; pass0 != endpasses; ++pass0) { -if (pass0->rdslope > 0.0) { - fprintf(stderr, "pass %02d nmsedec=%lf dec=%lf end=%d %lf\n", pass0 - cblk->passes, - fixtodbl(pass0->nmsedec), pass0->wmsedec, pass0->end, pass0->rdslope); -} + if (pass0->rdslope > 0.0) { + fprintf(stderr, "pass %02d nmsedec=%lf dec=%lf end=%d %lf\n", + pass0 - cblk->passes, + fixtodbl(pass0->nmsedec), pass0->wmsedec, + pass0->end, pass0->rdslope); + } } #endif } @@ -1196,8 +1237,8 @@ computeLayerSizes(jpc_enc_t * const encP, -static void dump_layeringinfo(jpc_enc_t *enc) -{ +static void +dump_layeringinfo(jpc_enc_t *enc) { jpc_enc_tcmpt_t *tcmpt; uint_fast16_t tcmptno; @@ -1626,12 +1667,15 @@ performTier2Coding(jpc_enc_t * const encP, JAS_DBGLOG(10, ("done doing rateallocation\n")); } + + /*****************************************************************************\ * Tile constructors and destructors. \*****************************************************************************/ -jpc_enc_tile_t *jpc_enc_tile_create(jpc_enc_cp_t *cp, jas_image_t *image, int tileno) -{ +jpc_enc_tile_t * +jpc_enc_tile_create(jpc_enc_cp_t *cp, jas_image_t *image, int tileno) { + jpc_enc_tile_t *tile; uint_fast32_t htileno; uint_fast32_t vtileno; @@ -1733,8 +1777,11 @@ error: return 0; } -void jpc_enc_tile_destroy(jpc_enc_tile_t *tile) -{ + + +void +jpc_enc_tile_destroy(jpc_enc_tile_t *tile) { + jpc_enc_tcmpt_t *tcmpt; uint_fast16_t cmptno; @@ -1754,9 +1801,14 @@ void jpc_enc_tile_destroy(jpc_enc_tile_t *tile) jas_free(tile); } -static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp, - jas_image_t *image, jpc_enc_tile_t *tile) -{ + + +static jpc_enc_tcmpt_t * +tcmpt_create(jpc_enc_tcmpt_t * const tcmpt, + jpc_enc_cp_t * const cp, + jas_image_t * const image, + jpc_enc_tile_t * const tile) { + uint_fast16_t cmptno; uint_fast16_t rlvlno; jpc_enc_rlvl_t *rlvl; @@ -1787,15 +1839,15 @@ static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp, bry = JPC_CEILDIV(tile->bry, ccp->sampgrdstepy); /* Create a sequence to hold the tile-component sample data. */ - if (!(tcmpt->data = jas_seq2d_create(tlx, tly, brx, bry))) { + tcmpt->data = jas_seq2d_create(tlx, tly, brx, bry); + if (!tcmpt->data) goto error; - } /* Get the image data associated with this tile-component. */ cmpttlx = JPC_CEILDIV(cp->imgareatlx, ccp->sampgrdstepx); cmpttly = JPC_CEILDIV(cp->imgareatly, ccp->sampgrdstepy); if (jas_image_readcmpt(image, cmptno, tlx - cmpttlx, tly - cmpttly, - brx - tlx, bry - tly, tcmpt->data)) { + brx - tlx, bry - tly, tcmpt->data)) { goto error; } @@ -1803,9 +1855,11 @@ static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp, tcmpt->qmfbid = cp->tccp.qmfbid; tcmpt->numrlvls = cp->tccp.maxrlvls; tcmpt->numbands = 3 * tcmpt->numrlvls - 2; - if (!(tcmpt->tsfb = jpc_cod_gettsfb(tcmpt->qmfbid, tcmpt->numrlvls - 1))) { + + tcmpt->tsfb = jpc_cod_gettsfb(tcmpt->qmfbid, tcmpt->numrlvls - 1); + + if (!tcmpt->tsfb) goto error; - } for (rlvlno = 0; rlvlno < tcmpt->numrlvls; ++rlvlno) { tcmpt->prcwidthexpns[rlvlno] = cp->tccp.prcwidthexpns[rlvlno]; @@ -1818,17 +1872,19 @@ static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp, tcmpt->numstepsizes = tcmpt->numbands; assert(tcmpt->numstepsizes <= JPC_MAXBANDS); - memset(tcmpt->stepsizes, 0, sizeof(tcmpt->numstepsizes * - sizeof(uint_fast16_t))); + memset(tcmpt->stepsizes, 0, + sizeof(tcmpt->numstepsizes * sizeof(uint_fast16_t))); /* Retrieve information about the various bands. */ jpc_tsfb_getbands(tcmpt->tsfb, jas_seq2d_xstart(tcmpt->data), - jas_seq2d_ystart(tcmpt->data), jas_seq2d_xend(tcmpt->data), - jas_seq2d_yend(tcmpt->data), bandinfos); + jas_seq2d_ystart(tcmpt->data), + jas_seq2d_xend(tcmpt->data), + jas_seq2d_yend(tcmpt->data), bandinfos); - if (!(tcmpt->rlvls = jas_malloc(tcmpt->numrlvls * sizeof(jpc_enc_rlvl_t)))) { + tcmpt->rlvls = jas_malloc(tcmpt->numrlvls * sizeof(jpc_enc_rlvl_t)); + if (!tcmpt->rlvls) goto error; - } + for (rlvlno = 0, rlvl = tcmpt->rlvls; rlvlno < tcmpt->numrlvls; ++rlvlno, ++rlvl) { rlvl->bands = 0; @@ -1850,8 +1906,11 @@ error: } -static void tcmpt_destroy(jpc_enc_tcmpt_t *tcmpt) -{ + + +static void +tcmpt_destroy(jpc_enc_tcmpt_t *tcmpt) { + jpc_enc_rlvl_t *rlvl; uint_fast16_t rlvlno; @@ -1871,9 +1930,12 @@ static void tcmpt_destroy(jpc_enc_tcmpt_t *tcmpt) } } -static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, - jpc_enc_tcmpt_t *tcmpt, jpc_tsfb_band_t *bandinfos) -{ + + +static jpc_enc_rlvl_t * +rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, + jpc_enc_tcmpt_t *tcmpt, jpc_tsfb_band_t *bandinfos) { + uint_fast16_t rlvlno; uint_fast32_t tlprctlx; uint_fast32_t tlprctly; @@ -1891,14 +1953,18 @@ static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, /* Compute the coordinates of the top-left and bottom-right corners of the tile-component at this resolution. */ - rlvl->tlx = JPC_CEILDIVPOW2(jas_seq2d_xstart(tcmpt->data), tcmpt->numrlvls - - 1 - rlvlno); - rlvl->tly = JPC_CEILDIVPOW2(jas_seq2d_ystart(tcmpt->data), tcmpt->numrlvls - - 1 - rlvlno); - rlvl->brx = JPC_CEILDIVPOW2(jas_seq2d_xend(tcmpt->data), tcmpt->numrlvls - - 1 - rlvlno); - rlvl->bry = JPC_CEILDIVPOW2(jas_seq2d_yend(tcmpt->data), tcmpt->numrlvls - - 1 - rlvlno); + rlvl->tlx = + JPC_CEILDIVPOW2(jas_seq2d_xstart(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->tly = + JPC_CEILDIVPOW2(jas_seq2d_ystart(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->brx = + JPC_CEILDIVPOW2(jas_seq2d_xend(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); + rlvl->bry = + JPC_CEILDIVPOW2(jas_seq2d_yend(tcmpt->data), tcmpt->numrlvls - + 1 - rlvlno); if (rlvl->tlx >= rlvl->brx || rlvl->tly >= rlvl->bry) { rlvl->numhprcs = 0; @@ -1917,8 +1983,10 @@ static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, rlvl->cbgwidthexpn = rlvl->prcwidthexpn - 1; rlvl->cbgheightexpn = rlvl->prcheightexpn - 1; } - rlvl->cblkwidthexpn = JAS_MIN(cp->tccp.cblkwidthexpn, rlvl->cbgwidthexpn); - rlvl->cblkheightexpn = JAS_MIN(cp->tccp.cblkheightexpn, rlvl->cbgheightexpn); + rlvl->cblkwidthexpn = + JAS_MIN(cp->tccp.cblkwidthexpn, rlvl->cbgwidthexpn); + rlvl->cblkheightexpn = + JAS_MIN(cp->tccp.cblkheightexpn, rlvl->cbgheightexpn); /* Compute the number of precincts. */ tlprctlx = JPC_FLOORTOMULTPOW2(rlvl->tlx, rlvl->prcwidthexpn); @@ -1926,20 +1994,22 @@ static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp, brprcbrx = JPC_CEILTOMULTPOW2(rlvl->brx, rlvl->prcwidthexpn); brprcbry = JPC_CEILTOMULTPOW2(rlvl->bry, rlvl->prcheightexpn); rlvl->numhprcs = JPC_FLOORDIVPOW2(brprcbrx - tlprctlx, rlvl->prcwidthexpn); - rlvl->numvprcs = JPC_FLOORDIVPOW2(brprcbry - tlprctly, rlvl->prcheightexpn); + rlvl->numvprcs = + JPC_FLOORDIVPOW2(brprcbry - tlprctly, rlvl->prcheightexpn); rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs; - if (!(rlvl->bands = jas_malloc(rlvl->numbands * sizeof(jpc_enc_band_t)))) { + rlvl->bands = jas_malloc(rlvl->numbands * sizeof(jpc_enc_band_t)); + if (!rlvl->bands) goto error; - } + for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; - ++bandno, ++band) { + ++bandno, ++band) { band->prcs = 0; band->data = 0; band->rlvl = rlvl; } for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands; - ++bandno, ++band) { + ++bandno, ++band) { if (!band_create(band, cp, rlvl, bandinfos)) { goto error; } @@ -1952,8 +2022,11 @@ error: return 0; } -static void rlvl_destroy(jpc_enc_rlvl_t *rlvl) -{ + + +static void +rlvl_destroy(jpc_enc_rlvl_t *rlvl) { + jpc_enc_band_t *band; uint_fast16_t bandno; @@ -1966,9 +2039,12 @@ static void rlvl_destroy(jpc_enc_rlvl_t *rlvl) } } -static jpc_enc_band_t *band_create(jpc_enc_band_t *band, jpc_enc_cp_t *cp, - jpc_enc_rlvl_t *rlvl, jpc_tsfb_band_t *bandinfos) -{ + + +static jpc_enc_band_t * +band_create(jpc_enc_band_t *band, jpc_enc_cp_t *cp, + jpc_enc_rlvl_t *rlvl, jpc_tsfb_band_t *bandinfos) { + uint_fast16_t bandno; uint_fast16_t gblbandno; uint_fast16_t rlvlno; @@ -1989,42 +2065,46 @@ static jpc_enc_band_t *band_create(jpc_enc_band_t *band, jpc_enc_cp_t *cp, bandinfo = &bandinfos[gblbandno]; -if (bandinfo->xstart != bandinfo->xend && bandinfo->ystart != bandinfo->yend) { - if (!(band->data = jas_seq2d_create(0, 0, 0, 0))) { - goto error; + if (bandinfo->xstart != bandinfo->xend && + bandinfo->ystart != bandinfo->yend) { + band->data = jas_seq2d_create(0, 0, 0, 0); + if (!band->data) + goto error; + jas_seq2d_bindsub(band->data, tcmpt->data, bandinfo->locxstart, + bandinfo->locystart, bandinfo->locxend, + bandinfo->locyend); + jas_seq2d_setshift(band->data, bandinfo->xstart, bandinfo->ystart); } - jas_seq2d_bindsub(band->data, tcmpt->data, bandinfo->locxstart, - bandinfo->locystart, bandinfo->locxend, bandinfo->locyend); - jas_seq2d_setshift(band->data, bandinfo->xstart, bandinfo->ystart); -} band->orient = bandinfo->orient; band->analgain = JPC_NOMINALGAIN(cp->tccp.qmfbid, tcmpt->numrlvls, rlvlno, - band->orient); + band->orient); band->numbps = 0; band->absstepsize = 0; band->stepsize = 0; band->synweight = bandinfo->synenergywt; -if (band->data) { - if (!(band->prcs = jas_malloc(rlvl->numprcs * sizeof(jpc_enc_prc_t)))) { - goto error; - } - for (prcno = 0, prc = band->prcs; prcno < rlvl->numprcs; ++prcno, - ++prc) { - prc->cblks = 0; - prc->incltree = 0; - prc->nlibtree = 0; - prc->savincltree = 0; - prc->savnlibtree = 0; - prc->band = band; - } - for (prcno = 0, prc = band->prcs; prcno < rlvl->numprcs; ++prcno, - ++prc) { - if (!prc_create(prc, cp, band)) { + if (band->data) { + band->prcs = jas_malloc(rlvl->numprcs * sizeof(jpc_enc_prc_t)); + if (!band->prcs) goto error; + for (prcno = 0, prc = band->prcs; + prcno < rlvl->numprcs; + ++prcno, ++prc) { + prc->cblks = 0; + prc->incltree = 0; + prc->nlibtree = 0; + prc->savincltree = 0; + prc->savnlibtree = 0; + prc->band = band; + } + for (prcno = 0, prc = band->prcs; + prcno < rlvl->numprcs; + ++prcno, ++prc) { + if (!prc_create(prc, cp, band)) { + goto error; + } } } -} return band; @@ -2033,8 +2113,11 @@ error: return 0; } -static void band_destroy(jpc_enc_band_t *band) -{ + + +static void +band_destroy(jpc_enc_band_t *band) { + jpc_enc_prc_t *prc; jpc_enc_rlvl_t *rlvl; uint_fast32_t prcno; @@ -2052,8 +2135,11 @@ static void band_destroy(jpc_enc_band_t *band) } } -static jpc_enc_prc_t *prc_create(jpc_enc_prc_t *prc, jpc_enc_cp_t *cp, jpc_enc_band_t *band) -{ + + +static jpc_enc_prc_t * +prc_create(jpc_enc_prc_t *prc, jpc_enc_cp_t *cp, jpc_enc_band_t *band) { + uint_fast32_t prcno; uint_fast32_t prcxind; uint_fast32_t prcyind; @@ -2081,32 +2167,34 @@ static jpc_enc_prc_t *prc_create(jpc_enc_prc_t *prc, jpc_enc_cp_t *cp, jpc_enc_b rlvl = band->rlvl; tcmpt = rlvl->tcmpt; -rlvlno = rlvl - tcmpt->rlvls; + rlvlno = rlvl - tcmpt->rlvls; prcno = prc - band->prcs; prcxind = prcno % rlvl->numhprcs; prcyind = prcno / rlvl->numhprcs; prc->band = band; -tlprctlx = JPC_FLOORTOMULTPOW2(rlvl->tlx, rlvl->prcwidthexpn); -tlprctly = JPC_FLOORTOMULTPOW2(rlvl->tly, rlvl->prcheightexpn); -if (!rlvlno) { - tlcbgtlx = tlprctlx; - tlcbgtly = tlprctly; -} else { - tlcbgtlx = JPC_CEILDIVPOW2(tlprctlx, 1); - tlcbgtly = JPC_CEILDIVPOW2(tlprctly, 1); -} + tlprctlx = JPC_FLOORTOMULTPOW2(rlvl->tlx, rlvl->prcwidthexpn); + tlprctly = JPC_FLOORTOMULTPOW2(rlvl->tly, rlvl->prcheightexpn); - /* Compute the coordinates of the top-left and bottom-right - corners of the precinct. */ + if (!rlvlno) { + tlcbgtlx = tlprctlx; + tlcbgtly = tlprctly; + } else { + tlcbgtlx = JPC_CEILDIVPOW2(tlprctlx, 1); + tlcbgtly = JPC_CEILDIVPOW2(tlprctly, 1); + } + + /* Compute the coordinates of the top-left and bottom-right corners of the + precinct. + */ cbgtlx = tlcbgtlx + (prcxind << rlvl->cbgwidthexpn); cbgtly = tlcbgtly + (prcyind << rlvl->cbgheightexpn); prc->tlx = JAS_MAX(jas_seq2d_xstart(band->data), cbgtlx); prc->tly = JAS_MAX(jas_seq2d_ystart(band->data), cbgtly); prc->brx = JAS_MIN(jas_seq2d_xend(band->data), cbgtlx + - (1 << rlvl->cbgwidthexpn)); + (1 << rlvl->cbgwidthexpn)); prc->bry = JAS_MIN(jas_seq2d_yend(band->data), cbgtly + - (1 << rlvl->cbgheightexpn)); + (1 << rlvl->cbgheightexpn)); if (prc->tlx < prc->brx && prc->tly < prc->bry) { /* The precinct contains at least one code block. */ @@ -2116,33 +2204,35 @@ if (!rlvlno) { brcblkbrx = JPC_CEILTOMULTPOW2(prc->brx, rlvl->cblkwidthexpn); brcblkbry = JPC_CEILTOMULTPOW2(prc->bry, rlvl->cblkheightexpn); prc->numhcblks = JPC_FLOORDIVPOW2(brcblkbrx - tlcblktlx, - rlvl->cblkwidthexpn); + rlvl->cblkwidthexpn); prc->numvcblks = JPC_FLOORDIVPOW2(brcblkbry - tlcblktly, - rlvl->cblkheightexpn); + rlvl->cblkheightexpn); prc->numcblks = prc->numhcblks * prc->numvcblks; if (!(prc->incltree = jpc_tagtree_create(prc->numhcblks, - prc->numvcblks))) { + prc->numvcblks))) { goto error; } if (!(prc->nlibtree = jpc_tagtree_create(prc->numhcblks, - prc->numvcblks))) { + prc->numvcblks))) { goto error; } if (!(prc->savincltree = jpc_tagtree_create(prc->numhcblks, - prc->numvcblks))) { + prc->numvcblks))) { goto error; } if (!(prc->savnlibtree = jpc_tagtree_create(prc->numhcblks, - prc->numvcblks))) { + prc->numvcblks))) { goto error; } - if (!(prc->cblks = jas_malloc(prc->numcblks * sizeof(jpc_enc_cblk_t)))) { + prc->cblks = jas_malloc(prc->numcblks * sizeof(jpc_enc_cblk_t)); + + if (!prc->cblks) goto error; - } - for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks; - ++cblkno, ++cblk) { + for (cblkno = 0, cblk = prc->cblks; + cblkno < prc->numcblks; + ++cblkno, ++cblk) { cblk->passes = 0; cblk->stream = 0; cblk->mqenc = 0; @@ -2150,8 +2240,9 @@ if (!rlvlno) { cblk->flags = 0; cblk->prc = prc; } - for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks; - ++cblkno, ++cblk) { + for (cblkno = 0, cblk = prc->cblks; + cblkno < prc->numcblks; + ++cblkno, ++cblk) { if (!cblk_create(cblk, cp, prc)) { goto error; } @@ -2177,8 +2268,11 @@ error: return 0; } -static void prc_destroy(jpc_enc_prc_t *prc) -{ + + +static void +prc_destroy(jpc_enc_prc_t *prc) { + jpc_enc_cblk_t *cblk; uint_fast32_t cblkno; @@ -2203,8 +2297,11 @@ static void prc_destroy(jpc_enc_prc_t *prc) } } -static jpc_enc_cblk_t *cblk_create(jpc_enc_cblk_t *cblk, jpc_enc_cp_t *cp, jpc_enc_prc_t *prc) -{ + + +static jpc_enc_cblk_t * +cblk_create(jpc_enc_cblk_t *cblk, jpc_enc_cp_t *cp, jpc_enc_prc_t *prc) { + jpc_enc_band_t *band; uint_fast32_t cblktlx; uint_fast32_t cblktly; @@ -2241,18 +2338,22 @@ static jpc_enc_cblk_t *cblk_create(jpc_enc_cblk_t *cblk, jpc_enc_cp_t *cp, jpc_e band = prc->band; tlcblktlx = JPC_FLOORTOMULTPOW2(prc->tlx, rlvl->cblkwidthexpn); tlcblktly = JPC_FLOORTOMULTPOW2(prc->tly, rlvl->cblkheightexpn); - cblktlx = JAS_MAX(tlcblktlx + (cblkxind << rlvl->cblkwidthexpn), prc->tlx); - cblktly = JAS_MAX(tlcblktly + (cblkyind << rlvl->cblkheightexpn), prc->tly); - cblkbrx = JAS_MIN(tlcblktlx + ((cblkxind + 1) << rlvl->cblkwidthexpn), - prc->brx); - cblkbry = JAS_MIN(tlcblktly + ((cblkyind + 1) << rlvl->cblkheightexpn), - prc->bry); + cblktlx = + JAS_MAX(tlcblktlx + (cblkxind << rlvl->cblkwidthexpn), prc->tlx); + cblktly = + JAS_MAX(tlcblktly + (cblkyind << rlvl->cblkheightexpn), prc->tly); + cblkbrx = + JAS_MIN(tlcblktlx + ((cblkxind + 1) << rlvl->cblkwidthexpn), prc->brx); + cblkbry = + JAS_MIN(tlcblktly + ((cblkyind + 1) << rlvl->cblkheightexpn), + prc->bry); assert(cblktlx < cblkbrx && cblktly < cblkbry); - if (!(cblk->data = jas_seq2d_create(0, 0, 0, 0))) { + cblk->data = jas_seq2d_create(0, 0, 0, 0); + if (!cblk->data) goto error; - } - jas_seq2d_bindsub(cblk->data, band->data, cblktlx, cblktly, cblkbrx, cblkbry); + jas_seq2d_bindsub(cblk->data, band->data, + cblktlx, cblktly, cblkbrx, cblkbry); return cblk; @@ -2261,8 +2362,11 @@ error: return 0; } -static void cblk_destroy(jpc_enc_cblk_t *cblk) -{ + + +static void +cblk_destroy(jpc_enc_cblk_t *cblk) { + uint_fast16_t passno; jpc_enc_pass_t *pass; if (cblk->passes) { @@ -2286,13 +2390,19 @@ static void cblk_destroy(jpc_enc_cblk_t *cblk) } } -static void pass_destroy(jpc_enc_pass_t *pass) -{ + + +static void +pass_destroy(jpc_enc_pass_t *pass) { + /* XXX - need to free resources here */ } -void jpc_enc_dump(jpc_enc_t *enc) -{ + + +void +jpc_enc_dump(jpc_enc_t *enc) { + jpc_enc_tile_t *tile; jpc_enc_tcmpt_t *tcmpt; jpc_enc_rlvl_t *rlvl; @@ -2358,11 +2468,10 @@ void jpc_enc_dump(jpc_enc_t *enc) -static int jpc_enc_encodemainbody(jpc_enc_t *enc) -{ +static int +jpc_enc_encodemainbody(jpc_enc_t *enc) { + int tileno; - int tilex; - int tiley; int i; jpc_sot_t *sot; jpc_enc_tcmpt_t *comp; @@ -2376,7 +2485,6 @@ static int jpc_enc_encodemainbody(jpc_enc_t *enc) int adjust; int j; int absbandno; - long numbytes; long tilehdrlen; long tilelen; jpc_enc_tile_t *tile; @@ -2398,13 +2506,7 @@ static int jpc_enc_encodemainbody(jpc_enc_t *enc) cp = enc->cp; - /* Avoid compile warnings. */ - numbytes = 0; - for (tileno = 0; tileno < cp->numtiles; ++tileno) { - tilex = tileno % cp->numhtiles; - tiley = tileno / cp->numhtiles; - enc->curtile = jpc_enc_tile_create(enc->cp, enc->image, tileno); if (!enc->curtile) abort(); @@ -2459,7 +2561,6 @@ static int jpc_enc_encodemainbody(jpc_enc_t *enc) } - endcomps = &tile->tcmpts[tile->numtcmpts]; for (cmptno = 0, comp = tile->tcmpts; comp != endcomps; @@ -2544,15 +2645,16 @@ static int jpc_enc_encodemainbody(jpc_enc_t *enc) return -1; } - if (!(enc->tmpstream = jas_stream_memopen(0, 0))) { + enc->tmpstream = jas_stream_memopen(0, 0); + if (!enc->tmpstream) { fprintf(stderr, "cannot open tmp file\n"); return -1; } /* Write the tile header. */ - if (!(enc->mrk = jpc_ms_create(JPC_MS_SOT))) { + enc->mrk = jpc_ms_create(JPC_MS_SOT); + if (!enc->mrk) return -1; - } sot = &enc->mrk->parms.sot; sot->len = 0; sot->tileno = tileno; diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c index 8aa024a9..e1af0f61 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_t1enc.c @@ -1,4 +1,4 @@ -/* + /* * Copyright (c) 1999-2000 Image Power, Inc. and the University of * British Columbia. * Copyright (c) 2001-2002 Michael David Adams. @@ -156,853 +156,872 @@ static int jpc_encrawrefpass(jpc_bitstream_t *out, int bitpos, int, /* Encode all of the code blocks associated with the current tile. */ int jpc_enc_enccblks(jpc_enc_t *enc) { - jpc_enc_tcmpt_t *tcmpt; - jpc_enc_tcmpt_t *endcomps; - jpc_enc_rlvl_t *lvl; - jpc_enc_rlvl_t *endlvls; - jpc_enc_band_t *band; - jpc_enc_band_t *endbands; - jpc_enc_cblk_t *cblk; - jpc_enc_cblk_t *endcblks; - int i; - int j; - int mx; - int bmx; - int v; - jpc_enc_tile_t *tile; - uint_fast32_t prcno; - jpc_enc_prc_t *prc; - - tile = enc->curtile; - - endcomps = &tile->tcmpts[tile->numtcmpts]; - for (tcmpt = tile->tcmpts; tcmpt != endcomps; ++tcmpt) { - endlvls = &tcmpt->rlvls[tcmpt->numrlvls]; - for (lvl = tcmpt->rlvls; lvl != endlvls; ++lvl) { - if (!lvl->bands) { - continue; - } - endbands = &lvl->bands[lvl->numbands]; - for (band = lvl->bands; band != endbands; ++band) { - if (!band->data) { - continue; - } - for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) { - if (!prc->cblks) { - continue; - } - bmx = 0; - endcblks = &prc->cblks[prc->numcblks]; - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - mx = 0; - for (i = 0; i < jas_matrix_numrows(cblk->data); ++i) { - for (j = 0; j < jas_matrix_numcols(cblk->data); ++j) { - v = abs(jas_matrix_get(cblk->data, i, j)); - if (v > mx) { - mx = v; - } - } - } - if (mx > bmx) { - bmx = mx; - } - cblk->numbps = JAS_MAX(jpc_firstone(mx) + 1 - JPC_NUMEXTRABITS, 0); - } - - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - cblk->numimsbs = band->numbps - cblk->numbps; - assert(cblk->numimsbs >= 0); - } - - for (cblk = prc->cblks; cblk != endcblks; ++cblk) { - if (jpc_enc_enccblk(enc, cblk->stream, tcmpt, band, cblk)) { - return -1; - } - } - } - } - } - } - return 0; + jpc_enc_tcmpt_t *tcmpt; + jpc_enc_tcmpt_t *endcomps; + jpc_enc_rlvl_t *lvl; + jpc_enc_rlvl_t *endlvls; + jpc_enc_band_t *band; + jpc_enc_band_t *endbands; + jpc_enc_cblk_t *cblk; + jpc_enc_cblk_t *endcblks; + int i; + int j; + int mx; + int bmx; + int v; + jpc_enc_tile_t *tile; + uint_fast32_t prcno; + jpc_enc_prc_t *prc; + + tile = enc->curtile; + + endcomps = &tile->tcmpts[tile->numtcmpts]; + for (tcmpt = tile->tcmpts; tcmpt != endcomps; ++tcmpt) { + endlvls = &tcmpt->rlvls[tcmpt->numrlvls]; + for (lvl = tcmpt->rlvls; lvl != endlvls; ++lvl) { + if (!lvl->bands) { + continue; + } + endbands = &lvl->bands[lvl->numbands]; + for (band = lvl->bands; band != endbands; ++band) { + if (!band->data) { + continue; + } + for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) { + if (!prc->cblks) { + continue; + } + bmx = 0; + endcblks = &prc->cblks[prc->numcblks]; + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + mx = 0; + for (i = 0; i < jas_matrix_numrows(cblk->data); ++i) { + for (j = 0; j < jas_matrix_numcols(cblk->data); ++j) { + v = abs(jas_matrix_get(cblk->data, i, j)); + if (v > mx) { + mx = v; + } + } + } + if (mx > bmx) { + bmx = mx; + } + cblk->numbps = JAS_MAX(jpc_firstone(mx) + 1 - JPC_NUMEXTRABITS, 0); + } + + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + cblk->numimsbs = band->numbps - cblk->numbps; + assert(cblk->numimsbs >= 0); + } + + for (cblk = prc->cblks; cblk != endcblks; ++cblk) { + if (jpc_enc_enccblk(enc, cblk->stream, tcmpt, band, cblk)) { + return -1; + } + } + } + } + } + } + return 0; } static int getthebyte(jas_stream_t *in, long off) { - int c; - long oldpos; - oldpos = jas_stream_tell(in); - assert(oldpos >= 0); - jas_stream_seek(in, off, SEEK_SET); - c = jas_stream_peekc(in); - jas_stream_seek(in, oldpos, SEEK_SET); - return c; + int c; + long oldpos; + oldpos = jas_stream_tell(in); + assert(oldpos >= 0); + jas_stream_seek(in, off, SEEK_SET); + c = jas_stream_peekc(in); + jas_stream_seek(in, oldpos, SEEK_SET); + return c; } -/* Encode a single code block. */ -int jpc_enc_enccblk(jpc_enc_t *enc, jas_stream_t *out, jpc_enc_tcmpt_t *tcmpt, jpc_enc_band_t *band, jpc_enc_cblk_t *cblk) -{ - jpc_enc_pass_t *pass; - jpc_enc_pass_t *endpasses; - int bitpos; - int n; - int adjust; - int ret; - int passtype; - int t; - jpc_bitstream_t *bout; - jpc_enc_pass_t *termpass; - jpc_enc_rlvl_t *rlvl; - int vcausal; - int segsym; - int termmode; - int c; - - bout = 0; - rlvl = band->rlvl; - - cblk->stream = jas_stream_memopen(0, 0); - assert(cblk->stream); - cblk->mqenc = jpc_mqenc_create(JPC_NUMCTXS, cblk->stream); - assert(cblk->mqenc); - jpc_mqenc_setctxs(cblk->mqenc, JPC_NUMCTXS, jpc_mqctxs); - - cblk->numpasses = (cblk->numbps > 0) ? (3 * cblk->numbps - 2) : 0; - if (cblk->numpasses > 0) { - cblk->passes = jas_malloc(cblk->numpasses * sizeof(jpc_enc_pass_t)); - assert(cblk->passes); - } else { - cblk->passes = 0; - } - endpasses = &cblk->passes[cblk->numpasses]; - for (pass = cblk->passes; pass != endpasses; ++pass) { - pass->start = 0; - pass->end = 0; - pass->term = JPC_ISTERMINATED(pass - cblk->passes, 0, cblk->numpasses, (tcmpt->cblksty & JPC_COX_TERMALL) != 0, (tcmpt->cblksty & JPC_COX_LAZY) != 0); - pass->type = JPC_SEGTYPE(pass - cblk->passes, 0, (tcmpt->cblksty & JPC_COX_LAZY) != 0); - pass->lyrno = -1; -if (pass == endpasses - 1) { -assert(pass->term == 1); - pass->term = 1; -} - } - - cblk->flags = jas_matrix_create(jas_matrix_numrows(cblk->data) + 2, - jas_matrix_numcols(cblk->data) + 2); - assert(cblk->flags); - - bitpos = cblk->numbps - 1; - pass = cblk->passes; - n = cblk->numpasses; - while (--n >= 0) { - if (pass->type == JPC_SEG_MQ) { - /* NOP */ - } else { - assert(pass->type == JPC_SEG_RAW); - if (!bout) { - bout = jpc_bitstream_sopen(cblk->stream, "w"); - assert(bout); - } - } +int +jpc_enc_enccblk(jpc_enc_t *enc, jas_stream_t *out, jpc_enc_tcmpt_t *tcmpt, + jpc_enc_band_t *band, jpc_enc_cblk_t *cblk) { +/*---------------------------------------------------------------------------- + Encode a single code block. +-----------------------------------------------------------------------------*/ + jpc_enc_pass_t *pass; + jpc_enc_pass_t *endpasses; + int bitpos; + int n; + int adjust; + int passtype; + int t; + jpc_bitstream_t *bout; + jpc_enc_pass_t *termpass; + int vcausal; + int segsym; + int termmode; + int c; + + bout = 0; + + cblk->stream = jas_stream_memopen(0, 0); + assert(cblk->stream); + cblk->mqenc = jpc_mqenc_create(JPC_NUMCTXS, cblk->stream); + assert(cblk->mqenc); + jpc_mqenc_setctxs(cblk->mqenc, JPC_NUMCTXS, jpc_mqctxs); + + cblk->numpasses = (cblk->numbps > 0) ? (3 * cblk->numbps - 2) : 0; + if (cblk->numpasses > 0) { + cblk->passes = jas_malloc(cblk->numpasses * sizeof(jpc_enc_pass_t)); + assert(cblk->passes); + } else { + cblk->passes = 0; + } + endpasses = &cblk->passes[cblk->numpasses]; + for (pass = cblk->passes; pass != endpasses; ++pass) { + pass->start = 0; + pass->end = 0; + pass->term = + JPC_ISTERMINATED(pass - cblk->passes, 0, + cblk->numpasses, + (tcmpt->cblksty & JPC_COX_TERMALL) != 0, + (tcmpt->cblksty & JPC_COX_LAZY) != 0); + pass->type = JPC_SEGTYPE(pass - cblk->passes, 0, + (tcmpt->cblksty & JPC_COX_LAZY) != 0); + pass->lyrno = -1; + if (pass == endpasses - 1) { + assert(pass->term == 1); + pass->term = 1; + } + } + + cblk->flags = jas_matrix_create(jas_matrix_numrows(cblk->data) + 2, + jas_matrix_numcols(cblk->data) + 2); + assert(cblk->flags); + + + bitpos = cblk->numbps - 1; + pass = cblk->passes; + n = cblk->numpasses; + while (--n >= 0) { + + if (pass->type == JPC_SEG_MQ) { + /* NOP */ + } else { + assert(pass->type == JPC_SEG_RAW); + if (!bout) { + bout = jpc_bitstream_sopen(cblk->stream, "w"); + assert(bout); + } + } #if 1 - passtype = (pass - cblk->passes + 2) % 3; + passtype = (pass - cblk->passes + 2) % 3; #else - passtype = JPC_PASSTYPE(pass - cblk->passes + 2); + passtype = JPC_PASSTYPE(pass - cblk->passes + 2); #endif - pass->start = jas_stream_tell(cblk->stream); + pass->start = jas_stream_tell(cblk->stream); #if 0 assert(jas_stream_tell(cblk->stream) == jas_stream_getrwcount(cblk->stream)); #endif - assert(bitpos >= 0); - vcausal = (tcmpt->cblksty & JPC_COX_VSC) != 0; - segsym = (tcmpt->cblksty & JPC_COX_SEGSYM) != 0; - if (pass->term) { - termmode = ((tcmpt->cblksty & JPC_COX_PTERM) ? - JPC_MQENC_PTERM : JPC_MQENC_DEFTERM) + 1; - } else { - termmode = 0; - } - switch (passtype) { - case JPC_SIGPASS: - ret = (pass->type == JPC_SEG_MQ) ? jpc_encsigpass(cblk->mqenc, - bitpos, band->orient, vcausal, cblk->flags, - cblk->data, termmode, &pass->nmsedec) : - jpc_encrawsigpass(bout, bitpos, vcausal, cblk->flags, - cblk->data, termmode, &pass->nmsedec); - break; - case JPC_REFPASS: - ret = (pass->type == JPC_SEG_MQ) ? jpc_encrefpass(cblk->mqenc, - bitpos, vcausal, cblk->flags, cblk->data, termmode, - &pass->nmsedec) : jpc_encrawrefpass(bout, bitpos, - vcausal, cblk->flags, cblk->data, termmode, - &pass->nmsedec); - break; - case JPC_CLNPASS: - assert(pass->type == JPC_SEG_MQ); - ret = jpc_encclnpass(cblk->mqenc, bitpos, band->orient, - vcausal, segsym, cblk->flags, cblk->data, termmode, - &pass->nmsedec); - break; - default: - assert(0); - break; - } - - if (pass->type == JPC_SEG_MQ) { - if (pass->term) { - jpc_mqenc_init(cblk->mqenc); - } - jpc_mqenc_getstate(cblk->mqenc, &pass->mqencstate); - pass->end = jas_stream_tell(cblk->stream); - if (tcmpt->cblksty & JPC_COX_RESET) { - jpc_mqenc_setctxs(cblk->mqenc, JPC_NUMCTXS, jpc_mqctxs); - } - } else { - if (pass->term) { - if (jpc_bitstream_pending(bout)) { - jpc_bitstream_outalign(bout, 0x2a); - } - jpc_bitstream_close(bout); - bout = 0; - pass->end = jas_stream_tell(cblk->stream); - } else { - pass->end = jas_stream_tell(cblk->stream) + - jpc_bitstream_pending(bout); -/* NOTE - This will not work. need to adjust by # of pending output bytes */ - } - } + assert(bitpos >= 0); + vcausal = (tcmpt->cblksty & JPC_COX_VSC) != 0; + segsym = (tcmpt->cblksty & JPC_COX_SEGSYM) != 0; + if (pass->term) { + termmode = ((tcmpt->cblksty & JPC_COX_PTERM) ? + JPC_MQENC_PTERM : JPC_MQENC_DEFTERM) + 1; + } else { + termmode = 0; + } + switch (passtype) { + case JPC_SIGPASS: + if (pass->type == JPC_SEG_MQ) + jpc_encsigpass(cblk->mqenc, + bitpos, band->orient, vcausal, cblk->flags, + cblk->data, termmode, &pass->nmsedec); + else + jpc_encrawsigpass(bout, bitpos, vcausal, cblk->flags, + cblk->data, termmode, &pass->nmsedec); + break; + case JPC_REFPASS: + if (pass->type == JPC_SEG_MQ) + jpc_encrefpass( + cblk->mqenc, + bitpos, vcausal, cblk->flags, cblk->data, termmode, + &pass->nmsedec); + else + jpc_encrawrefpass(bout, bitpos, + vcausal, cblk->flags, cblk->data, termmode, + &pass->nmsedec); + break; + case JPC_CLNPASS: + assert(pass->type == JPC_SEG_MQ); + jpc_encclnpass( + cblk->mqenc, bitpos, band->orient, + vcausal, segsym, cblk->flags, cblk->data, termmode, + &pass->nmsedec); + break; + default: + assert(false); + break; + } + + if (pass->type == JPC_SEG_MQ) { + if (pass->term) { + jpc_mqenc_init(cblk->mqenc); + } + jpc_mqenc_getstate(cblk->mqenc, &pass->mqencstate); + pass->end = jas_stream_tell(cblk->stream); + if (tcmpt->cblksty & JPC_COX_RESET) { + jpc_mqenc_setctxs(cblk->mqenc, JPC_NUMCTXS, jpc_mqctxs); + } + } else { + if (pass->term) { + if (jpc_bitstream_pending(bout)) { + jpc_bitstream_outalign(bout, 0x2a); + } + jpc_bitstream_close(bout); + bout = 0; + pass->end = jas_stream_tell(cblk->stream); + } else { + pass->end = jas_stream_tell(cblk->stream) + + jpc_bitstream_pending(bout); + /* NOTE - This will not work. need to adjust by # of pending + output bytes + */ + } + } #if 0 -/* XXX - This assertion fails sometimes when various coding modes are used. -This seems to be harmless, but why does it happen at all? */ -assert(jas_stream_tell(cblk->stream) == jas_stream_getrwcount(cblk->stream)); + /* XXX - This assertion fails sometimes when various coding modes are used. + This seems to be harmless, but why does it happen at all? */ + assert(jas_stream_tell(cblk->stream) == + jas_stream_getrwcount(cblk->stream)); #endif - pass->wmsedec = jpc_fixtodbl(band->rlvl->tcmpt->synweight) * - jpc_fixtodbl(band->rlvl->tcmpt->synweight) * - jpc_fixtodbl(band->synweight) * - jpc_fixtodbl(band->synweight) * - jpc_fixtodbl(band->absstepsize) * jpc_fixtodbl(band->absstepsize) * - ((double) (1 << bitpos)) * ((double)(1 << bitpos)) * - jpc_fixtodbl(pass->nmsedec); - pass->cumwmsedec = pass->wmsedec; - if (pass != cblk->passes) { - pass->cumwmsedec += pass[-1].cumwmsedec; - } - if (passtype == JPC_CLNPASS) { - --bitpos; - } - ++pass; - } + pass->wmsedec = jpc_fixtodbl(band->rlvl->tcmpt->synweight) * + jpc_fixtodbl(band->rlvl->tcmpt->synweight) * + jpc_fixtodbl(band->synweight) * + jpc_fixtodbl(band->synweight) * + jpc_fixtodbl(band->absstepsize) * jpc_fixtodbl(band->absstepsize) * + ((double) (1 << bitpos)) * ((double)(1 << bitpos)) * + jpc_fixtodbl(pass->nmsedec); + pass->cumwmsedec = pass->wmsedec; + if (pass != cblk->passes) { + pass->cumwmsedec += pass[-1].cumwmsedec; + } + if (passtype == JPC_CLNPASS) { + --bitpos; + } + ++pass; + } #if 0 -dump_passes(cblk->passes, cblk->numpasses, cblk); + dump_passes(cblk->passes, cblk->numpasses, cblk); #endif - n = 0; - endpasses = &cblk->passes[cblk->numpasses]; - for (pass = cblk->passes; pass != endpasses; ++pass) { - if (pass->start < n) { - pass->start = n; - } - if (pass->end < n) { - pass->end = n; - } - if (!pass->term) { - termpass = pass; - while (termpass - pass < cblk->numpasses && - !termpass->term) { - ++termpass; - } - if (pass->type == JPC_SEG_MQ) { - t = (pass->mqencstate.lastbyte == 0xff) ? 1 : 0; - if (pass->mqencstate.ctreg >= 5) { - adjust = 4 + t; - } else { - adjust = 5 + t; - } - pass->end += adjust; - } - if (pass->end > termpass->end) { - pass->end = termpass->end; - } - if ((c = getthebyte(cblk->stream, pass->end - 1)) == EOF) { - abort(); - } - if (c == 0xff) { - ++pass->end; - } - n = JAS_MAX(n, pass->end); - } else { - n = JAS_MAX(n, pass->end); - } - } + n = 0; + endpasses = &cblk->passes[cblk->numpasses]; + for (pass = cblk->passes; pass != endpasses; ++pass) { + if (pass->start < n) { + pass->start = n; + } + if (pass->end < n) { + pass->end = n; + } + if (!pass->term) { + termpass = pass; + while (termpass - pass < cblk->numpasses && + !termpass->term) { + ++termpass; + } + if (pass->type == JPC_SEG_MQ) { + t = (pass->mqencstate.lastbyte == 0xff) ? 1 : 0; + if (pass->mqencstate.ctreg >= 5) { + adjust = 4 + t; + } else { + adjust = 5 + t; + } + pass->end += adjust; + } + if (pass->end > termpass->end) { + pass->end = termpass->end; + } + if ((c = getthebyte(cblk->stream, pass->end - 1)) == EOF) { + abort(); + } + if (c == 0xff) { + ++pass->end; + } + n = JAS_MAX(n, pass->end); + } else { + n = JAS_MAX(n, pass->end); + } + } #if 0 -dump_passes(cblk->passes, cblk->numpasses, cblk); + dump_passes(cblk->passes, cblk->numpasses, cblk); #endif - if (bout) { - jpc_bitstream_close(bout); - } + if (bout) { + jpc_bitstream_close(bout); + } - return 0; + return 0; } -/******************************************************************************\ + + +/*****************************************************************************\ * Code for significance pass. -\******************************************************************************/ +\*****************************************************************************/ -#define sigpass_step(fp, frowstep, dp, bitpos, one, nmsedec, orient, mqenc, vcausalflag) \ +#define sigpass_step(fp, frowstep, dp, bitpos, one, nmsedec, orient, mqenc, vcausalflag) \ { \ - int f; \ - int v; \ - f = *(fp); \ - if ((f & JPC_OTHSIGMSK) && !(f & (JPC_SIG | JPC_VISIT))) { \ - v = (abs(*(dp)) & (one)) ? 1 : 0; \ - jpc_mqenc_setcurctx(mqenc, JPC_GETZCCTXNO(f, (orient))); \ - jpc_mqenc_putbit(mqenc, v); \ - if (v) { \ - *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ - v = ((*(dp) < 0) ? 1 : 0); \ - jpc_mqenc_setcurctx(mqenc, JPC_GETSCCTXNO(f)); \ - jpc_mqenc_putbit(mqenc, v ^ JPC_GETSPB(f)); \ - JPC_UPDATEFLAGS4(fp, frowstep, v, vcausalflag); \ - *(fp) |= JPC_SIG; \ - } \ - *(fp) |= JPC_VISIT; \ - } \ + int f; \ + int v; \ + f = *(fp); \ + if ((f & JPC_OTHSIGMSK) && !(f & (JPC_SIG | JPC_VISIT))) { \ + v = (abs(*(dp)) & (one)) ? 1 : 0; \ + jpc_mqenc_setcurctx(mqenc, JPC_GETZCCTXNO(f, (orient))); \ + jpc_mqenc_putbit(mqenc, v); \ + if (v) { \ + *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ + v = ((*(dp) < 0) ? 1 : 0); \ + jpc_mqenc_setcurctx(mqenc, JPC_GETSCCTXNO(f)); \ + jpc_mqenc_putbit(mqenc, v ^ JPC_GETSPB(f)); \ + JPC_UPDATEFLAGS4(fp, frowstep, v, vcausalflag); \ + *(fp) |= JPC_SIG; \ + } \ + *(fp) |= JPC_VISIT; \ + } \ } static int jpc_encsigpass(jpc_mqenc_t *mqenc, int bitpos, int orient, int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data, int term, long *nmsedec) { - int i; - int j; - int one; - int vscanlen; - int width; - int height; - int frowstep; - int drowstep; - int fstripestep; - int dstripestep; - jpc_fix_t *fstripestart; - jpc_fix_t *dstripestart; - jpc_fix_t *fp; - jpc_fix_t *dp; - jpc_fix_t *fvscanstart; - jpc_fix_t *dvscanstart; - int k; - - *nmsedec = 0; - width = jas_matrix_numcols(data); - height = jas_matrix_numrows(data); - frowstep = jas_matrix_rowstep(flags); - drowstep = jas_matrix_rowstep(data); - fstripestep = frowstep << 2; - dstripestep = drowstep << 2; - - one = 1 << (bitpos + JPC_NUMEXTRABITS); - - fstripestart = jas_matrix_getref(flags, 1, 1); - dstripestart = jas_matrix_getref(data, 0, 0); - for (i = height; i > 0; i -= 4, fstripestart += fstripestep, - dstripestart += dstripestep) { - fvscanstart = fstripestart; - dvscanstart = dstripestart; - vscanlen = JAS_MIN(i, 4); - for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { - fp = fvscanstart; - dp = dvscanstart; - k = vscanlen; - - sigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, orient, mqenc, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - sigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, orient, mqenc, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - sigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, orient, mqenc, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - sigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, orient, mqenc, 0); - - } - } - - if (term) { - jpc_mqenc_flush(mqenc, term - 1); - } - - return jpc_mqenc_error(mqenc) ? (-1) : 0; + int i; + int j; + int one; + int vscanlen; + int width; + int height; + int frowstep; + int drowstep; + int fstripestep; + int dstripestep; + jpc_fix_t *fstripestart; + jpc_fix_t *dstripestart; + jpc_fix_t *fp; + jpc_fix_t *dp; + jpc_fix_t *fvscanstart; + jpc_fix_t *dvscanstart; + int k; + + *nmsedec = 0; + width = jas_matrix_numcols(data); + height = jas_matrix_numrows(data); + frowstep = jas_matrix_rowstep(flags); + drowstep = jas_matrix_rowstep(data); + fstripestep = frowstep << 2; + dstripestep = drowstep << 2; + + one = 1 << (bitpos + JPC_NUMEXTRABITS); + + fstripestart = jas_matrix_getref(flags, 1, 1); + dstripestart = jas_matrix_getref(data, 0, 0); + for (i = height; i > 0; i -= 4, fstripestart += fstripestep, + dstripestart += dstripestep) { + fvscanstart = fstripestart; + dvscanstart = dstripestart; + vscanlen = JAS_MIN(i, 4); + for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { + fp = fvscanstart; + dp = dvscanstart; + k = vscanlen; + + sigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, orient, mqenc, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + sigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, orient, mqenc, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + sigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, orient, mqenc, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + sigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, orient, mqenc, 0); + + } + } + + if (term) { + jpc_mqenc_flush(mqenc, term - 1); + } + + return jpc_mqenc_error(mqenc) ? (-1) : 0; } -#define rawsigpass_step(fp, frowstep, dp, bitpos, one, nmsedec, out, vcausalflag) \ +#define rawsigpass_step(fp, frowstep, dp, bitpos, one, nmsedec, out, vcausalflag) \ { \ - jpc_fix_t f = *(fp); \ - jpc_fix_t v; \ - if ((f & JPC_OTHSIGMSK) && !(f & (JPC_SIG | JPC_VISIT))) { \ - v = (abs(*(dp)) & (one)) ? 1 : 0; \ - if ((jpc_bitstream_putbit((out), v)) == EOF) { \ - return -1; \ - } \ - if (v) { \ - *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ - v = ((*(dp) < 0) ? 1 : 0); \ - if (jpc_bitstream_putbit(out, v) == EOF) { \ - return -1; \ - } \ - JPC_UPDATEFLAGS4(fp, frowstep, v, vcausalflag); \ - *(fp) |= JPC_SIG; \ - } \ - *(fp) |= JPC_VISIT; \ - } \ + jpc_fix_t f = *(fp); \ + jpc_fix_t v; \ + if ((f & JPC_OTHSIGMSK) && !(f & (JPC_SIG | JPC_VISIT))) { \ + v = (abs(*(dp)) & (one)) ? 1 : 0; \ + if ((jpc_bitstream_putbit((out), v)) == EOF) { \ + return -1; \ + } \ + if (v) { \ + *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ + v = ((*(dp) < 0) ? 1 : 0); \ + if (jpc_bitstream_putbit(out, v) == EOF) { \ + return -1; \ + } \ + JPC_UPDATEFLAGS4(fp, frowstep, v, vcausalflag); \ + *(fp) |= JPC_SIG; \ + } \ + *(fp) |= JPC_VISIT; \ + } \ } static int jpc_encrawsigpass(jpc_bitstream_t *out, int bitpos, int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data, int term, long *nmsedec) { - int i; - int j; - int k; - int one; - int vscanlen; - int width; - int height; - int frowstep; - int drowstep; - int fstripestep; - int dstripestep; - jpc_fix_t *fstripestart; - jpc_fix_t *dstripestart; - jpc_fix_t *fp; - jpc_fix_t *dp; - jpc_fix_t *fvscanstart; - jpc_fix_t *dvscanstart; - - *nmsedec = 0; - width = jas_matrix_numcols(data); - height = jas_matrix_numrows(data); - frowstep = jas_matrix_rowstep(flags); - drowstep = jas_matrix_rowstep(data); - fstripestep = frowstep << 2; - dstripestep = drowstep << 2; - - one = 1 << (bitpos + JPC_NUMEXTRABITS); - - fstripestart = jas_matrix_getref(flags, 1, 1); - dstripestart = jas_matrix_getref(data, 0, 0); - for (i = height; i > 0; i -= 4, fstripestart += fstripestep, - dstripestart += dstripestep) { - fvscanstart = fstripestart; - dvscanstart = dstripestart; - vscanlen = JAS_MIN(i, 4); - for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { - fp = fvscanstart; - dp = dvscanstart; - k = vscanlen; - - rawsigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, out, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - - rawsigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, out, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - - rawsigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, out, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - - rawsigpass_step(fp, frowstep, dp, bitpos, one, - nmsedec, out, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - - } - } - - if (term) { - jpc_bitstream_outalign(out, 0x2a); - } - - return 0; + int i; + int j; + int k; + int one; + int vscanlen; + int width; + int height; + int frowstep; + int drowstep; + int fstripestep; + int dstripestep; + jpc_fix_t *fstripestart; + jpc_fix_t *dstripestart; + jpc_fix_t *fp; + jpc_fix_t *dp; + jpc_fix_t *fvscanstart; + jpc_fix_t *dvscanstart; + + *nmsedec = 0; + width = jas_matrix_numcols(data); + height = jas_matrix_numrows(data); + frowstep = jas_matrix_rowstep(flags); + drowstep = jas_matrix_rowstep(data); + fstripestep = frowstep << 2; + dstripestep = drowstep << 2; + + one = 1 << (bitpos + JPC_NUMEXTRABITS); + + fstripestart = jas_matrix_getref(flags, 1, 1); + dstripestart = jas_matrix_getref(data, 0, 0); + for (i = height; i > 0; i -= 4, fstripestart += fstripestep, + dstripestart += dstripestep) { + fvscanstart = fstripestart; + dvscanstart = dstripestart; + vscanlen = JAS_MIN(i, 4); + for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { + fp = fvscanstart; + dp = dvscanstart; + k = vscanlen; + + rawsigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, out, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + + rawsigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, out, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + + rawsigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, out, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + + rawsigpass_step(fp, frowstep, dp, bitpos, one, + nmsedec, out, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + + } + } + + if (term) { + jpc_bitstream_outalign(out, 0x2a); + } + + return 0; } /******************************************************************************\ * Code for refinement pass. \******************************************************************************/ -#define refpass_step(fp, dp, bitpos, one, nmsedec, mqenc, vcausalflag) \ +#define refpass_step(fp, dp, bitpos, one, nmsedec, mqenc, vcausalflag) \ { \ - int v; \ - if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \ - (d) = *(dp); \ - *(nmsedec) += JPC_GETREFNMSEDEC(abs(d), (bitpos) + JPC_NUMEXTRABITS); \ - jpc_mqenc_setcurctx((mqenc), JPC_GETMAGCTXNO(*(fp))); \ - v = (abs(d) & (one)) ? 1 : 0; \ - jpc_mqenc_putbit((mqenc), v); \ - *(fp) |= JPC_REFINE; \ - } \ + int v; \ + if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \ + (d) = *(dp); \ + *(nmsedec) += JPC_GETREFNMSEDEC(abs(d), (bitpos) + JPC_NUMEXTRABITS); \ + jpc_mqenc_setcurctx((mqenc), JPC_GETMAGCTXNO(*(fp))); \ + v = (abs(d) & (one)) ? 1 : 0; \ + jpc_mqenc_putbit((mqenc), v); \ + *(fp) |= JPC_REFINE; \ + } \ } static int jpc_encrefpass(jpc_mqenc_t *mqenc, int bitpos, int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data, int term, long *nmsedec) { - int i; - int j; - int one; - int vscanlen; - int d; - int width; - int height; - int frowstep; - int drowstep; - int fstripestep; - int dstripestep; - jpc_fix_t *fstripestart; - jpc_fix_t *dstripestart; - jpc_fix_t *fvscanstart; - jpc_fix_t *dvscanstart; - jpc_fix_t *dp; - jpc_fix_t *fp; + int i; + int j; + int one; + int vscanlen; + int d; + int width; + int height; + int frowstep; + int drowstep; + int fstripestep; + int dstripestep; + jpc_fix_t *fstripestart; + jpc_fix_t *dstripestart; + jpc_fix_t *fvscanstart; + jpc_fix_t *dvscanstart; + jpc_fix_t *dp; + jpc_fix_t *fp; int k; - *nmsedec = 0; - width = jas_matrix_numcols(data); - height = jas_matrix_numrows(data); - frowstep = jas_matrix_rowstep(flags); - drowstep = jas_matrix_rowstep(data); - fstripestep = frowstep << 2; - dstripestep = drowstep << 2; - - one = 1 << (bitpos + JPC_NUMEXTRABITS); - - fstripestart = jas_matrix_getref(flags, 1, 1); - dstripestart = jas_matrix_getref(data, 0, 0); - for (i = height; i > 0; i -= 4, fstripestart += fstripestep, - dstripestart += dstripestep) { - fvscanstart = fstripestart; - dvscanstart = dstripestart; - vscanlen = JAS_MIN(i, 4); - for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { - fp = fvscanstart; - dp = dvscanstart; - k = vscanlen; - - refpass_step(fp, dp, bitpos, one, nmsedec, - mqenc, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - refpass_step(fp, dp, bitpos, one, nmsedec, - mqenc, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - refpass_step(fp, dp, bitpos, one, nmsedec, - mqenc, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - refpass_step(fp, dp, bitpos, one, nmsedec, - mqenc, 0); - - } - } - - if (term) { - jpc_mqenc_flush(mqenc, term - 1); - } - - return jpc_mqenc_error(mqenc) ? (-1) : 0; + *nmsedec = 0; + width = jas_matrix_numcols(data); + height = jas_matrix_numrows(data); + frowstep = jas_matrix_rowstep(flags); + drowstep = jas_matrix_rowstep(data); + fstripestep = frowstep << 2; + dstripestep = drowstep << 2; + + one = 1 << (bitpos + JPC_NUMEXTRABITS); + + fstripestart = jas_matrix_getref(flags, 1, 1); + dstripestart = jas_matrix_getref(data, 0, 0); + for (i = height; i > 0; i -= 4, fstripestart += fstripestep, + dstripestart += dstripestep) { + fvscanstart = fstripestart; + dvscanstart = dstripestart; + vscanlen = JAS_MIN(i, 4); + for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { + fp = fvscanstart; + dp = dvscanstart; + k = vscanlen; + + refpass_step(fp, dp, bitpos, one, nmsedec, + mqenc, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + refpass_step(fp, dp, bitpos, one, nmsedec, + mqenc, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + refpass_step(fp, dp, bitpos, one, nmsedec, + mqenc, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + refpass_step(fp, dp, bitpos, one, nmsedec, + mqenc, 0); + + } + } + + if (term) { + jpc_mqenc_flush(mqenc, term - 1); + } + + return jpc_mqenc_error(mqenc) ? (-1) : 0; } -#define rawrefpass_step(fp, dp, bitpos, one, nmsedec, out, vcausalflag) \ +#define rawrefpass_step(fp, dp, bitpos, one, nmsedec, out, vcausalflag) \ { \ - jpc_fix_t d; \ - jpc_fix_t v; \ - if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \ - d = *(dp); \ - *(nmsedec) += JPC_GETREFNMSEDEC(abs(d), (bitpos) + JPC_NUMEXTRABITS); \ - v = (abs(d) & (one)) ? 1 : 0; \ - if (jpc_bitstream_putbit((out), v) == EOF) { \ - return -1; \ - } \ - *(fp) |= JPC_REFINE; \ - } \ + jpc_fix_t d; \ + jpc_fix_t v; \ + if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \ + d = *(dp); \ + *(nmsedec) += JPC_GETREFNMSEDEC(abs(d), (bitpos) + JPC_NUMEXTRABITS); \ + v = (abs(d) & (one)) ? 1 : 0; \ + if (jpc_bitstream_putbit((out), v) == EOF) { \ + return -1; \ + } \ + *(fp) |= JPC_REFINE; \ + } \ } static int jpc_encrawrefpass(jpc_bitstream_t *out, int bitpos, int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data, int term, long *nmsedec) { - int i; - int j; - int k; - int one; - int vscanlen; - int width; - int height; - int frowstep; - int drowstep; - int fstripestep; - int dstripestep; - jpc_fix_t *fstripestart; - jpc_fix_t *dstripestart; - jpc_fix_t *fvscanstart; - jpc_fix_t *dvscanstart; - jpc_fix_t *dp; - jpc_fix_t *fp; - - *nmsedec = 0; - width = jas_matrix_numcols(data); - height = jas_matrix_numrows(data); - frowstep = jas_matrix_rowstep(flags); - drowstep = jas_matrix_rowstep(data); - fstripestep = frowstep << 2; - dstripestep = drowstep << 2; - - one = 1 << (bitpos + JPC_NUMEXTRABITS); - - fstripestart = jas_matrix_getref(flags, 1, 1); - dstripestart = jas_matrix_getref(data, 0, 0); - for (i = height; i > 0; i -= 4, fstripestart += fstripestep, - dstripestart += dstripestep) { - fvscanstart = fstripestart; - dvscanstart = dstripestart; - vscanlen = JAS_MIN(i, 4); - for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { - fp = fvscanstart; - dp = dvscanstart; - k = vscanlen; - - rawrefpass_step(fp, dp, bitpos, one, nmsedec, - out, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - rawrefpass_step(fp, dp, bitpos, one, nmsedec, - out, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - rawrefpass_step(fp, dp, bitpos, one, nmsedec, - out, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - rawrefpass_step(fp, dp, bitpos, one, nmsedec, - out, vcausalflag); - - } - } - - if (term) { - jpc_bitstream_outalign(out, 0x2a); - } - - return 0; + int i; + int j; + int k; + int one; + int vscanlen; + int width; + int height; + int frowstep; + int drowstep; + int fstripestep; + int dstripestep; + jpc_fix_t *fstripestart; + jpc_fix_t *dstripestart; + jpc_fix_t *fvscanstart; + jpc_fix_t *dvscanstart; + jpc_fix_t *dp; + jpc_fix_t *fp; + + *nmsedec = 0; + width = jas_matrix_numcols(data); + height = jas_matrix_numrows(data); + frowstep = jas_matrix_rowstep(flags); + drowstep = jas_matrix_rowstep(data); + fstripestep = frowstep << 2; + dstripestep = drowstep << 2; + + one = 1 << (bitpos + JPC_NUMEXTRABITS); + + fstripestart = jas_matrix_getref(flags, 1, 1); + dstripestart = jas_matrix_getref(data, 0, 0); + for (i = height; i > 0; i -= 4, fstripestart += fstripestep, + dstripestart += dstripestep) { + fvscanstart = fstripestart; + dvscanstart = dstripestart; + vscanlen = JAS_MIN(i, 4); + for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { + fp = fvscanstart; + dp = dvscanstart; + k = vscanlen; + + rawrefpass_step(fp, dp, bitpos, one, nmsedec, + out, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + rawrefpass_step(fp, dp, bitpos, one, nmsedec, + out, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + rawrefpass_step(fp, dp, bitpos, one, nmsedec, + out, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + rawrefpass_step(fp, dp, bitpos, one, nmsedec, + out, vcausalflag); + + } + } + + if (term) { + jpc_bitstream_outalign(out, 0x2a); + } + + return 0; } /******************************************************************************\ * Code for cleanup pass. \******************************************************************************/ -#define clnpass_step(fp, frowstep, dp, bitpos, one, orient, nmsedec, mqenc, label1, label2, vcausalflag) \ +#define clnpass_step(fp, frowstep, dp, bitpos, one, orient, nmsedec, mqenc, label1, label2, vcausalflag) \ { \ - int f; \ - int v; \ + int f; \ + int v; \ label1 \ - f = *(fp); \ - if (!(f & (JPC_SIG | JPC_VISIT))) { \ - jpc_mqenc_setcurctx(mqenc, JPC_GETZCCTXNO(f, (orient))); \ - v = (abs(*(dp)) & (one)) ? 1 : 0; \ - jpc_mqenc_putbit((mqenc), v); \ - if (v) { \ + f = *(fp); \ + if (!(f & (JPC_SIG | JPC_VISIT))) { \ + jpc_mqenc_setcurctx(mqenc, JPC_GETZCCTXNO(f, (orient))); \ + v = (abs(*(dp)) & (one)) ? 1 : 0; \ + jpc_mqenc_putbit((mqenc), v); \ + if (v) { \ label2 \ - f = *(fp); \ - /* Coefficient is significant. */ \ - *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ - jpc_mqenc_setcurctx((mqenc), JPC_GETSCCTXNO(f)); \ - v = ((*(dp) < 0) ? 1 : 0); \ - jpc_mqenc_putbit((mqenc), v ^ JPC_GETSPB(f)); \ - JPC_UPDATEFLAGS4((fp), (frowstep), v, vcausalflag); \ - *(fp) |= JPC_SIG; \ - } \ - } \ - *(fp) &= ~JPC_VISIT; \ + f = *(fp); \ + /* Coefficient is significant. */ \ + *(nmsedec) += JPC_GETSIGNMSEDEC(abs(*(dp)), (bitpos) + JPC_NUMEXTRABITS); \ + jpc_mqenc_setcurctx((mqenc), JPC_GETSCCTXNO(f)); \ + v = ((*(dp) < 0) ? 1 : 0); \ + jpc_mqenc_putbit((mqenc), v ^ JPC_GETSPB(f)); \ + JPC_UPDATEFLAGS4((fp), (frowstep), v, vcausalflag); \ + *(fp) |= JPC_SIG; \ + } \ + } \ + *(fp) &= ~JPC_VISIT; \ } static int jpc_encclnpass(jpc_mqenc_t *mqenc, int bitpos, int orient, int vcausalflag, int segsymflag, jas_matrix_t *flags, jas_matrix_t *data, int term, long *nmsedec) { - int i; - int j; - int k; - int vscanlen; - int v; - int runlen; - jpc_fix_t *fp; - int width; - int height; - jpc_fix_t *dp; - int one; - int frowstep; - int drowstep; - int fstripestep; - int dstripestep; - jpc_fix_t *fstripestart; - jpc_fix_t *dstripestart; - jpc_fix_t *fvscanstart; - jpc_fix_t *dvscanstart; - - *nmsedec = 0; - width = jas_matrix_numcols(data); - height = jas_matrix_numrows(data); - frowstep = jas_matrix_rowstep(flags); - drowstep = jas_matrix_rowstep(data); - fstripestep = frowstep << 2; - dstripestep = drowstep << 2; - - one = 1 << (bitpos + JPC_NUMEXTRABITS); - - fstripestart = jas_matrix_getref(flags, 1, 1); - dstripestart = jas_matrix_getref(data, 0, 0); - for (i = height; i > 0; i -= 4, fstripestart += fstripestep, - dstripestart += dstripestep) { - fvscanstart = fstripestart; - dvscanstart = dstripestart; - vscanlen = JAS_MIN(i, 4); - for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { - - fp = fvscanstart; - if (vscanlen >= 4 && !((*fp) & (JPC_SIG | JPC_VISIT | - JPC_OTHSIGMSK)) && (fp += frowstep, !((*fp) & (JPC_SIG | - JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep, !((*fp) & - (JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep, - !((*fp) & (JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK)))) { - dp = dvscanstart; - for (k = 0; k < vscanlen; ++k) { - v = (abs(*dp) & one) ? 1 : 0; - if (v) { - break; - } - dp += drowstep; - } - runlen = k; - if (runlen >= 4) { - jpc_mqenc_setcurctx(mqenc, JPC_AGGCTXNO); - jpc_mqenc_putbit(mqenc, 0); - continue; - } - jpc_mqenc_setcurctx(mqenc, JPC_AGGCTXNO); - jpc_mqenc_putbit(mqenc, 1); - jpc_mqenc_setcurctx(mqenc, JPC_UCTXNO); - jpc_mqenc_putbit(mqenc, runlen >> 1); - jpc_mqenc_putbit(mqenc, runlen & 1); - fp = fvscanstart + frowstep * runlen; - dp = dvscanstart + drowstep * runlen; - k = vscanlen - runlen; - switch (runlen) { - case 0: - goto clnpass_partial0; - break; - case 1: - goto clnpass_partial1; - break; - case 2: - goto clnpass_partial2; - break; - case 3: - goto clnpass_partial3; - break; - } - } else { - runlen = 0; - fp = fvscanstart; - dp = dvscanstart; - k = vscanlen; - goto clnpass_full0; - } - clnpass_step(fp, frowstep, dp, bitpos, one, - orient, nmsedec, mqenc, clnpass_full0:, clnpass_partial0:, vcausalflag); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - clnpass_step(fp, frowstep, dp, bitpos, one, - orient, nmsedec, mqenc, ;, clnpass_partial1:, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - clnpass_step(fp, frowstep, dp, bitpos, one, - orient, nmsedec, mqenc, ;, clnpass_partial2:, 0); - if (--k <= 0) { - continue; - } - fp += frowstep; - dp += drowstep; - clnpass_step(fp, frowstep, dp, bitpos, one, - orient, nmsedec, mqenc, ;, clnpass_partial3:, 0); - } - } - - if (segsymflag) { - jpc_mqenc_setcurctx(mqenc, JPC_UCTXNO); - jpc_mqenc_putbit(mqenc, 1); - jpc_mqenc_putbit(mqenc, 0); - jpc_mqenc_putbit(mqenc, 1); - jpc_mqenc_putbit(mqenc, 0); - } - - if (term) { - jpc_mqenc_flush(mqenc, term - 1); - } - - return jpc_mqenc_error(mqenc) ? (-1) : 0; + int i; + int j; + int k; + int vscanlen; + int v; + int runlen; + jpc_fix_t *fp; + int width; + int height; + jpc_fix_t *dp; + int one; + int frowstep; + int drowstep; + int fstripestep; + int dstripestep; + jpc_fix_t *fstripestart; + jpc_fix_t *dstripestart; + jpc_fix_t *fvscanstart; + jpc_fix_t *dvscanstart; + + *nmsedec = 0; + width = jas_matrix_numcols(data); + height = jas_matrix_numrows(data); + frowstep = jas_matrix_rowstep(flags); + drowstep = jas_matrix_rowstep(data); + fstripestep = frowstep << 2; + dstripestep = drowstep << 2; + + one = 1 << (bitpos + JPC_NUMEXTRABITS); + + fstripestart = jas_matrix_getref(flags, 1, 1); + dstripestart = jas_matrix_getref(data, 0, 0); + for (i = height; i > 0; i -= 4, fstripestart += fstripestep, + dstripestart += dstripestep) { + fvscanstart = fstripestart; + dvscanstart = dstripestart; + vscanlen = JAS_MIN(i, 4); + for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) { + + fp = fvscanstart; + if (vscanlen >= 4 && !((*fp) & (JPC_SIG | JPC_VISIT | + JPC_OTHSIGMSK)) && (fp += frowstep, !((*fp) & (JPC_SIG | + JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep, !((*fp) & + (JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep, + !((*fp) & (JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK)))) { + dp = dvscanstart; + for (k = 0; k < vscanlen; ++k) { + v = (abs(*dp) & one) ? 1 : 0; + if (v) { + break; + } + dp += drowstep; + } + runlen = k; + if (runlen >= 4) { + jpc_mqenc_setcurctx(mqenc, JPC_AGGCTXNO); + jpc_mqenc_putbit(mqenc, 0); + continue; + } + jpc_mqenc_setcurctx(mqenc, JPC_AGGCTXNO); + jpc_mqenc_putbit(mqenc, 1); + jpc_mqenc_setcurctx(mqenc, JPC_UCTXNO); + jpc_mqenc_putbit(mqenc, runlen >> 1); + jpc_mqenc_putbit(mqenc, runlen & 1); + fp = fvscanstart + frowstep * runlen; + dp = dvscanstart + drowstep * runlen; + k = vscanlen - runlen; + switch (runlen) { + case 0: + goto clnpass_partial0; + break; + case 1: + goto clnpass_partial1; + break; + case 2: + goto clnpass_partial2; + break; + case 3: + goto clnpass_partial3; + break; + } + } else { + runlen = 0; + fp = fvscanstart; + dp = dvscanstart; + k = vscanlen; + goto clnpass_full0; + } + clnpass_step(fp, frowstep, dp, bitpos, one, + orient, nmsedec, mqenc, clnpass_full0:, clnpass_partial0:, vcausalflag); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + clnpass_step(fp, frowstep, dp, bitpos, one, + orient, nmsedec, mqenc, ;, clnpass_partial1:, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + clnpass_step(fp, frowstep, dp, bitpos, one, + orient, nmsedec, mqenc, ;, clnpass_partial2:, 0); + if (--k <= 0) { + continue; + } + fp += frowstep; + dp += drowstep; + clnpass_step(fp, frowstep, dp, bitpos, one, + orient, nmsedec, mqenc, ;, clnpass_partial3:, 0); + } + } + + if (segsymflag) { + jpc_mqenc_setcurctx(mqenc, JPC_UCTXNO); + jpc_mqenc_putbit(mqenc, 1); + jpc_mqenc_putbit(mqenc, 0); + jpc_mqenc_putbit(mqenc, 1); + jpc_mqenc_putbit(mqenc, 0); + } + + if (term) { + jpc_mqenc_flush(mqenc, term - 1); + } + + return jpc_mqenc_error(mqenc) ? (-1) : 0; } diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_util.c b/converter/other/jpeg2000/libjasper/jpc/jpc_util.c index ecc4b914..fede2bef 100644 --- a/converter/other/jpeg2000/libjasper/jpc/jpc_util.c +++ b/converter/other/jpeg2000/libjasper/jpc/jpc_util.c @@ -6,14 +6,14 @@ */ /* __START_OF_JASPER_LICENSE__ - * + * * JasPer Software License - * + * * IMAGE POWER JPEG-2000 PUBLIC LICENSE * ************************************ - * + * * GRANT: - * + * * Permission is hereby granted, free of charge, to any person (the "User") * obtaining a copy of this software and associated documentation, to deal * in the JasPer Software without restriction, including without limitation @@ -21,22 +21,22 @@ * and/or sell copies of the JasPer Software (in source and binary forms), * and to permit persons to whom the JasPer Software is furnished to do so, * provided further that the License Conditions below are met. - * + * * License Conditions * ****************** - * + * * A. Redistributions of source code must retain the above copyright notice, * and this list of conditions, and the following disclaimer. - * + * * B. Redistributions in binary form must reproduce the above copyright * notice, and this list of conditions, and the following disclaimer in * the documentation and/or other materials provided with the distribution. - * + * * C. Neither the name of Image Power, Inc. nor any other contributor * (including, but not limited to, the University of British Columbia and * Michael David Adams) may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * D. User agrees that it shall not commence any action against Image Power, * Inc., the University of British Columbia, Michael David Adams, or any * other contributors (collectively "Licensors") for infringement of any @@ -56,17 +56,17 @@ * trade dress, or service mark rights); and (v) divisions, continuations, * renewals, reissues and extensions of the foregoing (as and to the extent * applicable) now existing, hereafter filed, issued or acquired. - * + * * E. If User commences an infringement action against any Licensor(s) then * such Licensor(s) shall have the right to terminate User's license and * all sublicenses that have been granted hereunder by User to other parties. - * + * * F. This software is for use only in hardware or software products that * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license * or right to this Software is granted for products that do not comply * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased * from the ISO. - * + * * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND @@ -106,7 +106,7 @@ * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE * NOTICE SPECIFIED IN THIS SECTION. - * + * * __END_OF_JASPER_LICENSE__ */ |