Commit a458b91c authored by Michael Niedermayer's avatar Michael Niedermayer Committed by Luca Barbato

jpeg2000: Split int/float codepaths depending on the DWT

DWT53 is always int, DWT97 is always float.
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent f9581f14
...@@ -1119,10 +1119,10 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, ...@@ -1119,10 +1119,10 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
x = cblk->coord[0][0]; x = cblk->coord[0][0];
y = cblk->coord[1][0]; y = cblk->coord[1][0];
if (s->avctx->flags & CODEC_FLAG_BITEXACT) if (codsty->transform == FF_DWT97)
dequantization_int(x, y, cblk, comp, &t1, band);
else
dequantization_float(x, y, cblk, comp, &t1, band); dequantization_float(x, y, cblk, comp, &t1, band);
else
dequantization_int(x, y, cblk, comp, &t1, band);
} /* end cblk */ } /* end cblk */
} /*end prec */ } /*end prec */
} /* end band */ } /* end band */
...@@ -1142,7 +1142,8 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, ...@@ -1142,7 +1142,8 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
if (s->precision <= 8) { if (s->precision <= 8) {
for (compno = 0; compno < s->ncomponents; compno++) { for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = tile->comp + compno; Jpeg2000Component *comp = tile->comp + compno;
int32_t *datap = (int32_t *)comp->data; float *datap = comp->data;
int32_t *i_datap = (int32_t *) comp->data;
y = tile->comp[compno].coord[1][0] - s->image_offset_y; y = tile->comp[compno].coord[1][0] - s->image_offset_y;
line = picture->data[0] + y * picture->linesize[0]; line = picture->data[0] + y * picture->linesize[0];
for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) { for (; y < tile->comp[compno].coord[1][1] - s->image_offset_y; y += s->cdy[compno]) {
...@@ -1152,12 +1153,16 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, ...@@ -1152,12 +1153,16 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
dst = line + x * s->ncomponents + compno; dst = line + x * s->ncomponents + compno;
for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) { for (; x < tile->comp[compno].coord[0][1] - s->image_offset_x; x += s->cdx[compno]) {
*datap += 1 << (s->cbps[compno] - 1); int val;
if (*datap < 0) /* DC level shift and clip see ISO 15444-1:2002 G.1.2 */
*datap = 0; if (tile->codsty->transform == FF_DWT97)
else if (*datap >= (1 << s->cbps[compno])) val = lrintf(*datap) + (1 << (s->cbps[compno] - 1));
*datap = (1 << s->cbps[compno]) - 1; else
*dst = *datap++; val = *i_datap + (1 << (s->cbps[compno] - 1));
val = av_clip(val, 0, (1 << s->cbps[compno]) - 1);
*dst = val << (8 - s->cbps[compno]);
datap++;
i_datap++;
dst += s->ncomponents; dst += s->ncomponents;
} }
line += picture->linesize[0]; line += picture->linesize[0];
...@@ -1177,15 +1182,15 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, ...@@ -1177,15 +1182,15 @@ static int jpeg2000_decode_tile(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
x = tile->comp[compno].coord[0][0] - s->image_offset_x; x = tile->comp[compno].coord[0][0] - s->image_offset_x;
dst = linel + (x * s->ncomponents + compno); dst = linel + (x * s->ncomponents + compno);
for (; x < s->avctx->width; x += s->cdx[compno]) { for (; x < s->avctx->width; x += s->cdx[compno]) {
int16_t val; int val;
/* DC level shift and clip see ISO 15444-1:2002 G.1.2 */ /* DC level shift and clip see ISO 15444-1:2002 G.1.2 */
if (s->avctx->flags & CODEC_FLAG_BITEXACT) if (tile->codsty->transform == FF_DWT97)
val = *i_datap + (1 << (s->cbps[compno] - 1));
else
val = lrintf(*datap) + (1 << (s->cbps[compno] - 1)); val = lrintf(*datap) + (1 << (s->cbps[compno] - 1));
else
val = *i_datap + (1 << (s->cbps[compno] - 1));
val = av_clip(val, 0, (1 << s->cbps[compno]) - 1); val = av_clip(val, 0, (1 << s->cbps[compno]) - 1);
/* align 12 bit values in little-endian mode */ /* align 12 bit values in little-endian mode */
*dst = val << 4; *dst = val << (16 - s->cbps[compno]);
datap++; datap++;
i_datap++; i_datap++;
dst += s->ncomponents; dst += s->ncomponents;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment