summaryrefslogtreecommitdiff
path: root/libavcodec/j2k.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-28 22:12:34 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-28 22:16:14 +0200
commitfe7136ef8202b19fda262ea91adc09b3367d37d7 (patch)
treea90e7814be95420970639e8204364bf96dc6e637 /libavcodec/j2k.c
parentaa0d11ed0bdfc38f800771b1d695469ff691dd96 (diff)
j2k/jpeg2000: split stepsize in float & int variables
This is more clear and less prone to mistakes. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/j2k.c')
-rw-r--r--libavcodec/j2k.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/libavcodec/j2k.c b/libavcodec/j2k.c
index 96fe2597cb..5a7949737b 100644
--- a/libavcodec/j2k.c
+++ b/libavcodec/j2k.c
@@ -248,7 +248,6 @@ int ff_j2k_init_component(Jpeg2000Component *comp,
Jpeg2000Band *band = reslevel->band + bandno;
int cblkno, precno;
int nb_precincts;
- double stepsize;
/* TODO: Implementation of quantization step not finished,
* see ISO/IEC 15444-1:2002 E.1 and A.6.4. */
@@ -257,13 +256,13 @@ int ff_j2k_init_component(Jpeg2000Component *comp,
int numbps;
case JPEG2000_QSTY_NONE:
/* TODO: to verify. No quantization in this case */
- stepsize = 1;
+ band->f_stepsize = 1;
break;
case JPEG2000_QSTY_SI:
/*TODO: Compute formula to implement. */
numbps = cbps +
lut_gain[codsty->transform][bandno + (reslevelno > 0)];
- stepsize = SHL(2048 + qntsty->mant[gbandno],
+ band->f_stepsize = SHL(2048 + qntsty->mant[gbandno],
2 + numbps - qntsty->expn[gbandno]);
break;
case JPEG2000_QSTY_SE:
@@ -276,21 +275,20 @@ int ff_j2k_init_component(Jpeg2000Component *comp,
* but it works (compared to OpenJPEG). Why?
* Further investigation needed. */
gain = cbps;
- stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
- stepsize *= (qntsty->mant[gbandno] / 2048.0 + 1.0);
+ band->f_stepsize = pow(2.0, gain - qntsty->expn[gbandno]);
+ band->f_stepsize *= (qntsty->mant[gbandno] / 2048.0 + 1.0);
break;
default:
- stepsize = 0;
+ band->f_stepsize = 0;
av_log(avctx, AV_LOG_ERROR, "Unknown quantization format\n");
break;
}
/* FIXME: In openjepg code stespize = stepsize * 0.5. Why?
* If not set output of entropic decoder is not correct. */
if (!av_codec_is_encoder(avctx->codec))
- stepsize *= 0.5;
- /* BITEXACT computing case --> convert to int */
-// if (avctx->flags & CODEC_FLAG_BITEXACT)
- band->stepsize = stepsize * (1 << 16);
+ band->f_stepsize *= 0.5;
+
+ band->i_stepsize = band->f_stepsize * (1 << 16);
/* computation of tbx_0, tbx_1, tby_0, tby_1
* see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1