Skip to content

Commit

Permalink
jpeg2000: Initialize only once mqc arrays
Browse files Browse the repository at this point in the history
Improves decoding speed.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
  • Loading branch information
NicolasBertrand authored and lu-zero committed Jul 13, 2013
1 parent bec509d commit f56fe04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions libavcodec/jpeg2000dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,7 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data,
static void jpeg2000_init_static_data(AVCodec *codec)
{
ff_jpeg2000_init_tier1_luts();
ff_mqc_init_context_tables();
}

#define OFFSET(x) offsetof(Jpeg2000DecoderContext, x)
Expand Down
15 changes: 9 additions & 6 deletions libavcodec/mqc.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,9 @@ uint16_t ff_mqc_qe [2 * 47];
uint8_t ff_mqc_nlps[2 * 47];
uint8_t ff_mqc_nmps[2 * 47];

void ff_mqc_init_contexts(MqcState *mqc)
void ff_mqc_init_context_tables(void)
{
int i;
memset(mqc->cx_states, 0, sizeof(mqc->cx_states));
mqc->cx_states[MQC_CX_UNI] = 2 * 46;
mqc->cx_states[MQC_CX_RL] = 2 * 3;
mqc->cx_states[0] = 2 * 4;

for (i = 0; i < 47; i++) {
ff_mqc_qe[2 * i] =
ff_mqc_qe[2 * i + 1] = cx_states[i].qe;
Expand All @@ -110,3 +105,11 @@ void ff_mqc_init_contexts(MqcState *mqc)
ff_mqc_nmps[2 * i + 1] = 2 * cx_states[i].nmps + 1;
}
}

void ff_mqc_init_contexts(MqcState *mqc)
{
memset(mqc->cx_states, 0, sizeof(mqc->cx_states));
mqc->cx_states[MQC_CX_UNI] = 2 * 46;
mqc->cx_states[MQC_CX_RL] = 2 * 3;
mqc->cx_states[0] = 2 * 4;
}
5 changes: 5 additions & 0 deletions libavcodec/mqc.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate);

/* common */

/**
* MQ-coder Initialize context tables (QE, NLPS, NMPS)
*/
void ff_mqc_init_context_tables(void);

/**
* MQ-coder context initialisations.
* @param mqc MQ-coder context
Expand Down

0 comments on commit f56fe04

Please sign in to comment.