diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-12 03:02:09 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-12 03:02:09 +0200 |
commit | eea92133a16e7e0a837ad680afd4a05d08683a61 (patch) | |
tree | 5b7dab8bc94dd988746bd1a0973c5fa65b184484 /libavcodec | |
parent | b395fd3de7dab14841b3c7898aaea04d29c11bc7 (diff) | |
download | ffmpeg-eea92133a16e7e0a837ad680afd4a05d08683a61.tar.gz |
avcodec/mqcdec: Support raw bypass and non reseting init
Some broken code that used the old mqc is removed
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/jpeg2000dec.c | 7 | ||||
-rw-r--r-- | libavcodec/mqc.h | 5 | ||||
-rw-r--r-- | libavcodec/mqcdec.c | 18 |
3 files changed, 21 insertions, 9 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 099242de44..7e62880a01 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -1135,7 +1135,7 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, cblk->data[cblk->length] = 0xff; cblk->data[cblk->length+1] = 0xff; - ff_mqc_initdec(&t1->mqc, cblk->data); + ff_mqc_initdec(&t1->mqc, cblk->data, 0, 1); while (passno--) { switch(pass_t) { @@ -1146,16 +1146,11 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, break; case 1: decode_refpass(t1, width, height, bpno + 1); - if (bpass_csty_symbol && clnpass_cnt >= 4) - ff_mqc_initdec(&t1->mqc, cblk->data); break; case 2: decode_clnpass(s, t1, width, height, bpno + 1, bandpos, codsty->cblk_style & JPEG2000_CBLK_SEGSYM, vert_causal_ctx_csty_symbol); - clnpass_cnt = clnpass_cnt + 1; - if (bpass_csty_symbol && clnpass_cnt >= 4) - ff_mqc_initdec(&t1->mqc, cblk->data); break; } diff --git a/libavcodec/mqc.h b/libavcodec/mqc.h index c0827bd526..e4123c2109 100644 --- a/libavcodec/mqc.h +++ b/libavcodec/mqc.h @@ -43,6 +43,7 @@ typedef struct MqcState { unsigned int c; unsigned int ct; uint8_t cx_states[19]; + int raw; } MqcState; /* encoder */ @@ -65,8 +66,10 @@ int ff_mqc_flush(MqcState *mqc); * Initialize MQ-decoder. * @param mqc MQ decoder state * @param bp byte poiter + * @param raw raw mode + * @param reset reset states */ -void ff_mqc_initdec(MqcState *mqc, uint8_t *bp); +void ff_mqc_initdec(MqcState *mqc, uint8_t *bp, int raw, int reset); /** * MQ decoder. diff --git a/libavcodec/mqcdec.c b/libavcodec/mqcdec.c index 362506992a..aebc36f1b8 100644 --- a/libavcodec/mqcdec.c +++ b/libavcodec/mqcdec.c @@ -68,18 +68,32 @@ static int exchange(MqcState *mqc, uint8_t *cxstate, int lps) return d; } -void ff_mqc_initdec(MqcState *mqc, uint8_t *bp) +void ff_mqc_initdec(MqcState *mqc, uint8_t *bp, int raw, int reset) { - ff_mqc_init_contexts(mqc); + if (reset) + ff_mqc_init_contexts(mqc); mqc->bp = bp; mqc->c = (*mqc->bp ^ 0xff) << 16; bytein(mqc); mqc->c = mqc->c << 7; mqc->a = 0x8000; + mqc->raw = raw; +} + +static int mqc_decode_bypass(MqcState *mqc) { + int bit = !(mqc->c & 0x40000000); + if (!(mqc->c & 0xff)) { + mqc->c -= 0x100; + bytein(mqc); + } + mqc->c += mqc->c; + return bit; } int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate) { + if (mqc->raw) + return mqc_decode_bypass(mqc); mqc->a -= ff_mqc_qe[*cxstate]; if ((mqc->c >> 16) < mqc->a) { if (mqc->a & 0x8000) |