Commit eea92133 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/mqcdec: Support raw bypass and non reseting init

Some broken code that used the old mqc is removed
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent b395fd3d
...@@ -1135,7 +1135,7 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, ...@@ -1135,7 +1135,7 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
cblk->data[cblk->length] = 0xff; cblk->data[cblk->length] = 0xff;
cblk->data[cblk->length+1] = 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--) { while (passno--) {
switch(pass_t) { switch(pass_t) {
...@@ -1146,16 +1146,11 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, ...@@ -1146,16 +1146,11 @@ static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
break; break;
case 1: case 1:
decode_refpass(t1, width, height, bpno + 1); decode_refpass(t1, width, height, bpno + 1);
if (bpass_csty_symbol && clnpass_cnt >= 4)
ff_mqc_initdec(&t1->mqc, cblk->data);
break; break;
case 2: case 2:
decode_clnpass(s, t1, width, height, bpno + 1, bandpos, decode_clnpass(s, t1, width, height, bpno + 1, bandpos,
codsty->cblk_style & JPEG2000_CBLK_SEGSYM, codsty->cblk_style & JPEG2000_CBLK_SEGSYM,
vert_causal_ctx_csty_symbol); 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; break;
} }
......
...@@ -43,6 +43,7 @@ typedef struct MqcState { ...@@ -43,6 +43,7 @@ typedef struct MqcState {
unsigned int c; unsigned int c;
unsigned int ct; unsigned int ct;
uint8_t cx_states[19]; uint8_t cx_states[19];
int raw;
} MqcState; } MqcState;
/* encoder */ /* encoder */
...@@ -65,8 +66,10 @@ int ff_mqc_flush(MqcState *mqc); ...@@ -65,8 +66,10 @@ int ff_mqc_flush(MqcState *mqc);
* Initialize MQ-decoder. * Initialize MQ-decoder.
* @param mqc MQ decoder state * @param mqc MQ decoder state
* @param bp byte poiter * @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. * MQ decoder.
......
...@@ -68,18 +68,32 @@ static int exchange(MqcState *mqc, uint8_t *cxstate, int lps) ...@@ -68,18 +68,32 @@ static int exchange(MqcState *mqc, uint8_t *cxstate, int lps)
return d; 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->bp = bp;
mqc->c = (*mqc->bp ^ 0xff) << 16; mqc->c = (*mqc->bp ^ 0xff) << 16;
bytein(mqc); bytein(mqc);
mqc->c = mqc->c << 7; mqc->c = mqc->c << 7;
mqc->a = 0x8000; 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) int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate)
{ {
if (mqc->raw)
return mqc_decode_bypass(mqc);
mqc->a -= ff_mqc_qe[*cxstate]; mqc->a -= ff_mqc_qe[*cxstate];
if ((mqc->c >> 16) < mqc->a) { if ((mqc->c >> 16) < mqc->a) {
if (mqc->a & 0x8000) if (mqc->a & 0x8000)
......
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