aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Bertrand <nicoinattendu@gmail.com>2013-07-12 23:01:43 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-07-12 23:43:09 +0200
commitdd1382ac9534bd9b5ec7833eed9ab6f383e68a50 (patch)
treeb9a3d04b87897df874a124d3699f75122b223fa1
parent7f4a1fddd39e331464e443f95f10e225882b5c53 (diff)
downloadffmpeg-dd1382ac9534bd9b5ec7833eed9ab6f383e68a50.tar.gz
jpeg2000: Initialize only once mqc arrays
Increases encoding and decoding speed Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/j2kenc.c2
-rw-r--r--libavcodec/jpeg2000dec.c1
-rw-r--r--libavcodec/mqc.c15
-rw-r--r--libavcodec/mqc.h5
4 files changed, 16 insertions, 7 deletions
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index e4c84efd1a..48c1db8071 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1016,7 +1016,7 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
}
ff_jpeg2000_init_tier1_luts();
-
+ ff_mqc_init_context_tables();
init_luts();
init_quantization(s);
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 4018dc904d..e2a9a95f3e 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1466,6 +1466,7 @@ end:
static void jpeg2000_init_static_data(AVCodec *codec)
{
ff_jpeg2000_init_tier1_luts();
+ ff_mqc_init_context_tables();
}
#define OFFSET(x) offsetof(Jpeg2000DecoderContext, x)
diff --git a/libavcodec/mqc.c b/libavcodec/mqc.c
index 288570d309..f8294cd54c 100644
--- a/libavcodec/mqc.c
+++ b/libavcodec/mqc.c
@@ -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;
@@ -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;
+}
diff --git a/libavcodec/mqc.h b/libavcodec/mqc.h
index a0112d1159..c0827bd526 100644
--- a/libavcodec/mqc.h
+++ b/libavcodec/mqc.h
@@ -79,6 +79,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
*/