*/
/*
- * $Id: jpc_enc.c,v 1.1 2005/05/22 18:33:04 malaterre Exp $
+ * $Id: jpc_enc.c,v 1.5 2005/06/11 02:05:20 malaterre Exp $
*/
/******************************************************************************\
int dump_passes(jpc_enc_pass_t *passes, int numpasses, jpc_enc_cblk_t *cblk);
void calcrdslopes(jpc_enc_cblk_t *cblk);
void dump_layeringinfo(jpc_enc_t *enc);
-static int jpc_calcssexp(jpc_fix_t stepsize);
-static int jpc_calcssmant(jpc_fix_t stepsize);
+/*static int jpc_calcssexp(jpc_fix_t stepsize);*/
+/*static int jpc_calcssmant(jpc_fix_t stepsize);*/
void quantize(jas_matrix_t *data, jpc_fix_t stepsize);
static int jpc_enc_encodemainhdr(jpc_enc_t *enc);
static int jpc_enc_encodemainbody(jpc_enc_t *enc);
if (cp) {
jpc_enc_cp_destroy(cp);
}
+ (void)ret; /* ret' is assigned a value that is never used in function cp_create */
return 0;
}
} else if (f > 1.0) {
*size = rawsize + 1;
} else {
- *size = f * rawsize;
+ *size = (uint_fast32_t)(f * rawsize);
}
}
+ (void)cp; /* 'cp' is assigned a value that is never used in function ratestrtosize */
return 0;
}
* Code.
\******************************************************************************/
+#if 0
static int jpc_calcssmant(jpc_fix_t stepsize)
{
int n;
{
return jpc_firstone(stepsize) - JPC_FIX_FRACBITS;
}
+#endif
static int jpc_enc_encodemainhdr(jpc_enc_t *enc)
{
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 = (uint_fast8_t)tccp->prcwidthexpns[rlvlno];
+ cod->compparms.rlvls[rlvlno].parheightval = (uint_fast8_t)tccp->prcheightexpns[rlvlno];
}
}
if (jpc_putms(enc->out, enc->cstate, enc->mrk)) {
enc->mainbodysize = UINT_FAST32_MAX;
}
+ (void)mctsynweight; /* 'mctsynweight' is assigned a value that is never used in function jpc_enc_encodemainhdr */
return 0;
}
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;
int adjust;
int j;
int absbandno;
- long numbytes;
long tilehdrlen;
long tilelen;
jpc_enc_tile_t *tile;
cp = enc->cp;
- /* Avoid compile warnings. */
- numbytes = 0;
-
for (tileno = 0; tileno < JAS_CAST(int, cp->numtiles); ++tileno) {
- tilex = tileno % cp->numhtiles;
- tiley = tileno / cp->numhtiles;
if (!(enc->curtile = jpc_enc_tile_create(enc->cp, enc->image, tileno))) {
abort();
rho = (double) (tile->brx - tile->tlx) * (tile->bry - tile->tly) /
((cp->refgrdwidth - cp->imgareatlx) * (cp->refgrdheight -
cp->imgareatly));
- tile->rawsize = cp->rawsize * rho;
+ tile->rawsize = (uint_fast32_t)(cp->rawsize * rho);
for (lyrno = 0; lyrno < tile->numlyrs - 1; ++lyrno) {
- tile->lyrsizes[lyrno] = tile->rawsize * jpc_fixtodbl(
- cp->tcp.ilyrrates[lyrno]);
+ tile->lyrsizes[lyrno] = (uint_fast32_t)(tile->rawsize * jpc_fixtodbl(
+ cp->tcp.ilyrrates[lyrno]));
}
- tile->lyrsizes[tile->numlyrs - 1] = (cp->totalsize != UINT_FAST32_MAX) ?
- (rho * enc->mainbodysize) : UINT_FAST32_MAX;
+ tile->lyrsizes[tile->numlyrs - 1] = (uint_fast32_t)((cp->totalsize != UINT_FAST32_MAX) ?
+ (rho * enc->mainbodysize) : UINT_FAST32_MAX);
for (lyrno = 0; lyrno < tile->numlyrs; ++lyrno) {
if (tile->lyrsizes[lyrno] != UINT_FAST32_MAX) {
if (tilehdrlen <= JAS_CAST(long, tile->lyrsizes[lyrno])) {
jpc_flt_t lo;
jpc_flt_t hi;
jas_stream_t *out;
- long cumlen;
+ unsigned long cumlen;
int lyrno;
jpc_flt_t thresh;
jpc_flt_t goodthresh;
/* Check the rate constraint. */
assert(pos >= 0);
- if (pos > cumlen) {
+ if (pos > (long)cumlen) {
/* The rate is too high. */
lo = thresh;
- } else if (pos <= cumlen) {
+ } else if (pos <= (long)cumlen) {
/* The rate is low enough, so try higher. */
hi = thresh;
if (!success || thresh < goodthresh) {
jpc_enc_tile_t *tile;
uint_fast32_t htileno;
uint_fast32_t vtileno;
- uint_fast16_t lyrno;
+ int_fast16_t lyrno;
uint_fast16_t cmptno;
jpc_enc_tcmpt_t *tcmpt;
void jpc_enc_tile_destroy(jpc_enc_tile_t *tile)
{
jpc_enc_tcmpt_t *tcmpt;
- uint_fast16_t cmptno;
+ int_fast16_t cmptno;
if (tile->tcmpts) {
for (cmptno = 0, tcmpt = tile->tcmpts; cmptno <
jas_image_t *image, jpc_enc_tile_t *tile)
{
uint_fast16_t cmptno;
- uint_fast16_t rlvlno;
+ int_fast16_t rlvlno;
jpc_enc_rlvl_t *rlvl;
uint_fast32_t tlx;
uint_fast32_t tly;
static void tcmpt_destroy(jpc_enc_tcmpt_t *tcmpt)
{
jpc_enc_rlvl_t *rlvl;
- uint_fast16_t rlvlno;
+ int_fast16_t rlvlno;
if (tcmpt->rlvls) {
for (rlvlno = 0, rlvl = tcmpt->rlvls; rlvlno < tcmpt->numrlvls;
uint_fast32_t tlprctly;
uint_fast32_t brprcbrx;
uint_fast32_t brprcbry;
- uint_fast16_t bandno;
+ int_fast16_t bandno;
jpc_enc_band_t *band;
/* Deduce the resolution level. */
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((int)cp->tccp.cblkwidthexpn, rlvl->cbgwidthexpn);
+ rlvl->cblkheightexpn = JAS_MIN((int)cp->tccp.cblkheightexpn, rlvl->cbgheightexpn);
/* Compute the number of precincts. */
tlprctlx = JPC_FLOORTOMULTPOW2(rlvl->tlx, rlvl->prcwidthexpn);
static void rlvl_destroy(jpc_enc_rlvl_t *rlvl)
{
jpc_enc_band_t *band;
- uint_fast16_t bandno;
+ int_fast16_t bandno;
if (rlvl->bands) {
for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands;
uint_fast16_t rlvlno;
jpc_tsfb_band_t *bandinfo;
jpc_enc_tcmpt_t *tcmpt;
- uint_fast32_t prcno;
+ int_fast32_t prcno;
jpc_enc_prc_t *prc;
tcmpt = rlvl->tcmpt;
{
jpc_enc_prc_t *prc;
jpc_enc_rlvl_t *rlvl;
- uint_fast32_t prcno;
+ int_fast32_t prcno;
if (band->prcs) {
rlvl = band->rlvl;
uint_fast32_t tlcblktly;
uint_fast32_t brcblkbrx;
uint_fast32_t brcblkbry;
- uint_fast32_t cblkno;
+ int_fast32_t cblkno;
jpc_enc_cblk_t *cblk;
jpc_enc_tcmpt_t *tcmpt;
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 +
+ prc->tlx = JAS_MAX((uint_fast32_t)jas_seq2d_xstart(band->data), cbgtlx);
+ prc->tly = JAS_MAX((uint_fast32_t)jas_seq2d_ystart(band->data), cbgtly);
+ prc->brx = JAS_MIN((uint_fast32_t)jas_seq2d_xend(band->data), cbgtlx +
(1 << rlvl->cbgwidthexpn));
- prc->bry = JAS_MIN(jas_seq2d_yend(band->data), cbgtly +
+ prc->bry = JAS_MIN((uint_fast32_t)jas_seq2d_yend(band->data), cbgtly +
(1 << rlvl->cbgheightexpn));
if (prc->tlx < prc->brx && prc->tly < prc->bry) {
static void prc_destroy(jpc_enc_prc_t *prc)
{
jpc_enc_cblk_t *cblk;
- uint_fast32_t cblkno;
+ int_fast32_t cblkno;
if (prc->cblks) {
for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks;
uint_fast32_t cblkno;
uint_fast32_t tlcblktlx;
uint_fast32_t tlcblktly;
+ /* unused:*/
+ (void)cp;
cblkno = cblk - prc->cblks;
cblkxind = cblkno % prc->numhcblks;
static void cblk_destroy(jpc_enc_cblk_t *cblk)
{
- uint_fast16_t passno;
+ int_fast16_t passno;
jpc_enc_pass_t *pass;
if (cblk->passes) {
for (passno = 0, pass = cblk->passes; passno < cblk->numpasses;
static void pass_destroy(jpc_enc_pass_t *pass)
{
/* XXX - need to free resources here */
+ (void)pass;
}
void jpc_enc_dump(jpc_enc_t *enc)
jpc_enc_band_t *band;
jpc_enc_prc_t *prc;
jpc_enc_cblk_t *cblk;
- uint_fast16_t cmptno;
- uint_fast16_t rlvlno;
- uint_fast16_t bandno;
- uint_fast32_t prcno;
- uint_fast32_t cblkno;
+ int_fast16_t cmptno;
+ int_fast16_t rlvlno;
+ int_fast16_t bandno;
+ int_fast32_t prcno;
+ int_fast32_t cblkno;
tile = enc->curtile;