[FFmpeg-soc] [soc]: r1154 - in jpeg2000: aec.c aec.h aecdec.c aecenc.c checkout.sh ffmpeg.patch j2k.h j2kdec.c j2kenc.c mqc.c mqc.h mqcdec.c mqcenc.c
k.nowosad
subversion at mplayerhq.hu
Wed Aug 22 16:11:27 CEST 2007
Author: k.nowosad
Date: Wed Aug 22 16:11:27 2007
New Revision: 1154
Log:
renamed "arithmetic entropy coder" to "MQ-coder"
Added:
jpeg2000/mqc.c
- copied, changed from r1143, /jpeg2000/aec.c
jpeg2000/mqc.h
- copied, changed from r1070, /jpeg2000/aec.h
jpeg2000/mqcdec.c
- copied, changed from r1048, /jpeg2000/aecdec.c
jpeg2000/mqcenc.c
- copied, changed from r1047, /jpeg2000/aecenc.c
Removed:
jpeg2000/aec.c
jpeg2000/aec.h
jpeg2000/aecdec.c
jpeg2000/aecenc.c
Modified:
jpeg2000/checkout.sh
jpeg2000/ffmpeg.patch
jpeg2000/j2k.h
jpeg2000/j2kdec.c
jpeg2000/j2kenc.c
Modified: jpeg2000/checkout.sh
==============================================================================
--- jpeg2000/checkout.sh (original)
+++ jpeg2000/checkout.sh Wed Aug 22 16:11:27 2007
@@ -10,8 +10,8 @@ ln -s ../../j2kenc.c j2kenc.c
ln -s ../../j2kdec.c j2kdec.c
ln -s ../../j2k.h j2k.h
ln -s ../../j2k.c j2k.c
-ln -s ../../aecenc.c aecenc.c
-ln -s ../../aec.h aec.h
-ln -s ../../aec.c aec.c
-ln -s ../../aecdec.c aecdec.c
+ln -s ../../mqcenc.c mqcenc.c
+ln -s ../../mqc.h mqc.h
+ln -s ../../mqc.c mqc.c
+ln -s ../../mqcdec.c mqcdec.c
echo "Done, now just do a regular configure and make to build."
Modified: jpeg2000/ffmpeg.patch
==============================================================================
--- jpeg2000/ffmpeg.patch (original)
+++ jpeg2000/ffmpeg.patch Wed Aug 22 16:11:27 2007
@@ -6,8 +6,8 @@ Index: Makefile
OBJS-$(CONFIG_INDEO3_DECODER) += indeo3.o
OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o
OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER) += dpcm.o
-+OBJS-$(CONFIG_JPEG2000_DECODER) += j2kdec.o aecdec.o aec.o j2k.o
-+OBJS-$(CONFIG_JPEG2000_ENCODER) += j2kenc.o aecenc.o aec.o j2k.o
++OBJS-$(CONFIG_JPEG2000_DECODER) += j2kdec.o mqcdec.o mqc.o j2k.o
++OBJS-$(CONFIG_JPEG2000_ENCODER) += j2kenc.o mqcenc.o mqc.o j2k.o
OBJS-$(CONFIG_JPEGLS_DECODER) += jpeglsdec.o jpegls.o mjpegdec.o mjpeg.o golomb.o
OBJS-$(CONFIG_JPEGLS_ENCODER) += jpeglsenc.o jpegls.o golomb.o
OBJS-$(CONFIG_KMVC_DECODER) += kmvc.o
Modified: jpeg2000/j2k.h
==============================================================================
--- jpeg2000/j2k.h (original)
+++ jpeg2000/j2k.h Wed Aug 22 16:11:27 2007
@@ -28,7 +28,7 @@
#ifndef J2K_H
#define J2K_H
-#include "aec.h"
+#include "mqc.h"
enum J2kMarkers{
J2K_SOC = 0xff4f, ///< start of codestream
@@ -92,7 +92,7 @@ enum J2kQuantsty{ ///< quantization styl
typedef struct {
int data[J2K_MAX_CBLKW][J2K_MAX_CBLKH];
int flags[J2K_MAX_CBLKW+2][J2K_MAX_CBLKH+2];
- AecState aec;
+ MqcState mqc;
} J2kT1Context;
typedef struct J2kTgtNode {
Modified: jpeg2000/j2kdec.c
==============================================================================
--- jpeg2000/j2kdec.c (original)
+++ jpeg2000/j2kdec.c Wed Aug 22 16:11:27 2007
@@ -676,10 +676,10 @@ static void decode_sigpass(J2kT1Context
for (y = y0; y < height && y < y0+4; y++){
if ((t1->flags[y+1][x+1] & J2K_T1_SIG_NB)
&& !(t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS))){
- if (ff_aec_decode(&t1->aec, t1->aec.cx_states + ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno))){
+ if (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno))){
int xorbit, ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit);
- t1->data[y][x] = (ff_aec_decode(&t1->aec, t1->aec.cx_states + ctxno) ^ xorbit) ? -mask : mask;
+ t1->data[y][x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ? -mask : mask;
ff_j2k_set_significant(t1, x, y);
}
@@ -701,7 +701,7 @@ static void decode_refpass(J2kT1Context
for (y = y0; y < height && y < y0+4; y++){
if ((t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS)) == J2K_T1_SIG){
int ctxno = ff_j2k_getrefctxno(t1->flags[y+1][x+1]);
- int r = ff_aec_decode(&t1->aec, t1->aec.cx_states + ctxno) ? phalf : nhalf;
+ int r = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ? phalf : nhalf;
t1->data[y][x] += t1->data[y][x] < 0 ? -r : r;
t1->flags[y+1][x+1] |= J2K_T1_REF;
}
@@ -719,10 +719,10 @@ static void decode_clnpass(J2kT1Context
(t1->flags[y0+2][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)) ||
(t1->flags[y0+3][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)) ||
(t1->flags[y0+4][x+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)))){
- if (!ff_aec_decode(&t1->aec, t1->aec.cx_states + AEC_CX_RL))
+ if (!ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL))
continue;
- runlen = ff_aec_decode(&t1->aec, t1->aec.cx_states + AEC_CX_UNI);
- runlen = (runlen << 1) | ff_aec_decode(&t1->aec, t1->aec.cx_states + AEC_CX_UNI);
+ runlen = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);
+ runlen = (runlen << 1) | ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI);
dec = 1;
}
else{
@@ -733,11 +733,11 @@ static void decode_clnpass(J2kT1Context
for (y = y0 + runlen; y < y0 + 4 && y < height; y++){
if (!dec){
if (!(t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS)))
- dec = ff_aec_decode(&t1->aec, t1->aec.cx_states + ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno));
+ dec = ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno));
}
if (dec){
int xorbit, ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit);
- t1->data[y][x] = (ff_aec_decode(&t1->aec, t1->aec.cx_states + ctxno) ^ xorbit) ? -mask : mask;
+ t1->data[y][x] = (ff_mqc_decode(&t1->mqc, t1->mqc.cx_states + ctxno) ^ xorbit) ? -mask : mask;
ff_j2k_set_significant(t1, x, y);
}
dec = 0;
@@ -756,7 +756,7 @@ static int decode_cblk(J2kDecoderContext
for (y = 0; y < height; y++)
memset(t1->data[y], 0, width*sizeof(int));
- ff_aec_initdec(&t1->aec, cblk->data);
+ ff_mqc_initdec(&t1->mqc, cblk->data);
cblk->data[cblk->length] = 0xff;
cblk->data[cblk->length+1] = 0xff;
Modified: jpeg2000/j2kenc.c
==============================================================================
--- jpeg2000/j2kenc.c (original)
+++ jpeg2000/j2kenc.c Wed Aug 22 16:11:27 2007
@@ -600,11 +600,11 @@ static void encode_sigpass(J2kT1Context
if (!(t1->flags[y+1][x+1] & J2K_T1_SIG) && (t1->flags[y+1][x+1] & J2K_T1_SIG_NB)){
int ctxno = ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno),
bit = abs(t1->data[y][x]) & mask ? 1 : 0;
- ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, bit);
+ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, bit);
if (bit){
int xorbit;
int ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit);
- ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, (t1->data[y][x] < 0) ^ xorbit);
+ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->data[y][x] < 0) ^ xorbit);
*nmsedec += getnmsedec_sig(abs(t1->data[y][x]), bpno + NMSEDEC_FRACBITS);
ff_j2k_set_significant(t1, x, y);
}
@@ -622,7 +622,7 @@ static void encode_refpass(J2kT1Context
if ((t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS)) == J2K_T1_SIG){
int ctxno = ff_j2k_getrefctxno(t1->flags[y+1][x+1]);
*nmsedec += getnmsedec_ref(abs(t1->data[y][x]), bpno + NMSEDEC_FRACBITS);
- ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, abs(t1->data[y][x]) & mask ? 1:0);
+ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, abs(t1->data[y][x]) & mask ? 1:0);
t1->flags[y+1][x+1] |= J2K_T1_REF;
}
}
@@ -643,21 +643,21 @@ static void encode_clnpass(J2kT1Context
for (rlen = 0; rlen < 4; rlen++)
if (abs(t1->data[y0+rlen][x]) & mask)
break;
- ff_aec_encode(&t1->aec, t1->aec.cx_states + AEC_CX_RL, rlen != 4);
+ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + MQC_CX_RL, rlen != 4);
if (rlen == 4)
continue;
- ff_aec_encode(&t1->aec, t1->aec.cx_states + AEC_CX_UNI, rlen >> 1);
- ff_aec_encode(&t1->aec, t1->aec.cx_states + AEC_CX_UNI, rlen & 1);
+ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI, rlen >> 1);
+ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + MQC_CX_UNI, rlen & 1);
for (y = y0 + rlen; y < y0 + 4; y++){
if (!(t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS))){
int ctxno = ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno);
if (y > y0 + rlen)
- ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, abs(t1->data[y][x]) & mask ? 1:0);
+ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, abs(t1->data[y][x]) & mask ? 1:0);
if (abs(t1->data[y][x]) & mask){ // newly significant
int xorbit;
int ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit);
*nmsedec += getnmsedec_sig(abs(t1->data[y][x]), bpno + NMSEDEC_FRACBITS);
- ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, (t1->data[y][x] < 0) ^ xorbit);
+ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->data[y][x] < 0) ^ xorbit);
ff_j2k_set_significant(t1, x, y);
}
}
@@ -668,12 +668,12 @@ static void encode_clnpass(J2kT1Context
for (y = y0; y < y0 + 4 && y < height; y++){
if (!(t1->flags[y+1][x+1] & (J2K_T1_SIG | J2K_T1_VIS))){
int ctxno = ff_j2k_getnbctxno(t1->flags[y+1][x+1], bandno);
- ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, abs(t1->data[y][x]) & mask ? 1:0);
+ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, abs(t1->data[y][x]) & mask ? 1:0);
if (abs(t1->data[y][x]) & mask){ // newly significant
int xorbit;
int ctxno = ff_j2k_getsgnctxno(t1->flags[y+1][x+1], &xorbit);
*nmsedec += getnmsedec_sig(abs(t1->data[y][x]), bpno + NMSEDEC_FRACBITS);
- ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, (t1->data[y][x] < 0) ^ xorbit);
+ ff_mqc_encode(&t1->mqc, t1->mqc.cx_states + ctxno, (t1->data[y][x] < 0) ^ xorbit);
ff_j2k_set_significant(t1, x, y);
}
}
@@ -706,7 +706,7 @@ static void encode_cblk(J2kEncoderContex
bpno = cblk->nonzerobits - 1;
}
- ff_aec_initenc(&t1->aec, cblk->data);
+ ff_mqc_initenc(&t1->mqc, cblk->data);
for (passno = 0; bpno >= 0; passno++){
nmsedec=0;
@@ -720,7 +720,7 @@ static void encode_cblk(J2kEncoderContex
break;
}
- cblk->passes[passno].rate = 3 + ff_aec_length(&t1->aec);
+ cblk->passes[passno].rate = 3 + ff_mqc_length(&t1->mqc);
wmsedec += (int64_t)nmsedec << (2*bpno);
cblk->passes[passno].disto = wmsedec;
@@ -733,7 +733,7 @@ static void encode_cblk(J2kEncoderContex
cblk->ninclpasses = passno;
// TODO: optional flush on each pass
- cblk->passes[passno-1].rate = ff_aec_flush(&t1->aec);
+ cblk->passes[passno-1].rate = ff_mqc_flush(&t1->mqc);
}
/* tier-2 routines: */
Copied: jpeg2000/mqc.c (from r1143, /jpeg2000/aec.c)
==============================================================================
--- /jpeg2000/aec.c (original)
+++ jpeg2000/mqc.c Wed Aug 22 16:11:27 2007
@@ -1,5 +1,5 @@
/*
- * Arithmetic entropy encoder and decoder common functions
+ * MQ-coder encoder and decoder common functions
* Copyright (c) 2007 Kamil Nowosad
*
* This file is part of FFmpeg.
@@ -20,21 +20,21 @@
*/
/**
- * Arithmetic entropy coder and decoder common functions
- * @file aec.c
+ * MQ-coder ecoder and decoder common functions
+ * @file mqc.c
* @author Kamil Nowosad
*/
-#include "aec.h"
+#include "mqc.h"
typedef struct {
uint16_t qe;
uint8_t nmps;
uint8_t nlps;
uint8_t sw;
-} AecCxState;
+} MqcCxState;
-const static AecCxState cx_states[47] = {
+const static MqcCxState cx_states[47] = {
{0x5601, 1, 1, 1},
{0x3401, 2, 6, 0},
{0x1801, 3, 9, 0},
@@ -84,25 +84,25 @@ const static AecCxState cx_states[47] =
{0x5601, 46, 46, 0}
};
-uint16_t ff_aec_qe [2*47];
-uint8_t ff_aec_nlps[2*47];
-uint8_t ff_aec_nmps[2*47];
+uint16_t ff_mqc_qe [2*47];
+uint8_t ff_mqc_nlps[2*47];
+uint8_t ff_mqc_nmps[2*47];
-void ff_aec_init_contexts(AecState *aec)
+void ff_mqc_init_contexts(MqcState *mqc)
{
int i;
- memset(aec->cx_states, 0, sizeof(aec->cx_states));
- aec->cx_states[AEC_CX_UNI] = 2 * 46;
- aec->cx_states[AEC_CX_RL] = 2 * 3;
- aec->cx_states[0] = 2 * 4;
+ 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_aec_qe[2*i ] =
- ff_aec_qe[2*i+1] = cx_states[i].qe;
+ ff_mqc_qe[2*i ] =
+ ff_mqc_qe[2*i+1] = cx_states[i].qe;
- ff_aec_nlps[2*i ] = 2*cx_states[i].nlps + cx_states[i].sw;
- ff_aec_nlps[2*i+1] = 2*cx_states[i].nlps + 1 - cx_states[i].sw;
- ff_aec_nmps[2*i ] = 2*cx_states[i].nmps;
- ff_aec_nmps[2*i+1] = 2*cx_states[i].nmps + 1;
+ ff_mqc_nlps[2*i ] = 2*cx_states[i].nlps + cx_states[i].sw;
+ ff_mqc_nlps[2*i+1] = 2*cx_states[i].nlps + 1 - cx_states[i].sw;
+ ff_mqc_nmps[2*i ] = 2*cx_states[i].nmps;
+ ff_mqc_nmps[2*i+1] = 2*cx_states[i].nmps + 1;
}
}
Copied: jpeg2000/mqc.h (from r1070, /jpeg2000/aec.h)
==============================================================================
--- /jpeg2000/aec.h (original)
+++ jpeg2000/mqc.h Wed Aug 22 16:11:27 2007
@@ -1,5 +1,5 @@
/*
- * Arithmetic entropy coder
+ * MQ-coder
* Copyright (c) 2007 Kamil Nowosad
*
* This file is part of FFmpeg.
@@ -20,22 +20,22 @@
*/
/**
- * Arithmetic entropy coder
- * @file aec.h
+ * MQ-coder
+ * @file mqc.h
* @author Kamil Nowosad
*/
-#ifndef AEC_H
-#define AEC_H
+#ifndef MQC_H
+#define MQC_H
#include "avcodec.h"
-#define AEC_CX_UNI 17
-#define AEC_CX_RL 18
+#define MQC_CX_UNI 17
+#define MQC_CX_RL 18
-extern uint16_t ff_aec_qe[2*47];
-extern uint8_t ff_aec_nlps[2*47];
-extern uint8_t ff_aec_nmps[2*47];
+extern uint16_t ff_mqc_qe[2*47];
+extern uint8_t ff_mqc_nlps[2*47];
+extern uint8_t ff_mqc_nmps[2*47];
typedef struct {
uint8_t *bp, *bpstart;
@@ -43,33 +43,33 @@ typedef struct {
unsigned int c;
unsigned int ct;
uint8_t cx_states[19];
-} AecState;
+} MqcState;
/* encoder */
/** initialize the encoder */
-void ff_aec_initenc(AecState *aec, uint8_t *bp);
+void ff_mqc_initenc(MqcState *mqc, uint8_t *bp);
/** code bit d with context cx */
-void ff_aec_encode(AecState *aec, uint8_t *cxstate, int d);
+void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d);
/** number of encoded bytes */
-int ff_aec_length(AecState *aec);
+int ff_mqc_length(MqcState *mqc);
/** flush the encoder [returns number of bytes encoded] */
-int ff_aec_flush(AecState *aec);
+int ff_mqc_flush(MqcState *mqc);
/* decoder */
/** initialize the decoder */
-void ff_aec_initdec(AecState *aec, uint8_t *bp);
+void ff_mqc_initdec(MqcState *mqc, uint8_t *bp);
/** returns decoded bit with context cx */
-int ff_aec_decode(AecState *aec, uint8_t *cxstate);
+int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate);
/* common */
/** initialize the contexts */
-void ff_aec_init_contexts(AecState *aec);
+void ff_mqc_init_contexts(MqcState *mqc);
#endif
Copied: jpeg2000/mqcdec.c (from r1048, /jpeg2000/aecdec.c)
==============================================================================
--- /jpeg2000/aecdec.c (original)
+++ jpeg2000/mqcdec.c Wed Aug 22 16:11:27 2007
@@ -1,5 +1,5 @@
/*
- * Arithmetic entropy decoder
+ * MQ-coder decoder
* Copyright (c) 2007 Kamil Nowosad
*
* This file is part of FFmpeg.
@@ -20,76 +20,76 @@
*/
/**
- * Arithmetic entropy decoder
- * @file aecdec.c
+ * MQ-coder decoder
+ * @file mqcdec.c
* @author Kamil Nowosad
*/
-#include "aec.h"
+#include "mqc.h"
-static void bytein(AecState *aec)
+static void bytein(MqcState *mqc)
{
- if (*aec->bp == 0xff){
- if (*(aec->bp+1) > 0x8f)
- aec->c++;
+ if (*mqc->bp == 0xff){
+ if (*(mqc->bp+1) > 0x8f)
+ mqc->c++;
else{
- aec->bp++;
- aec->c += 2 + 0xfe00 - (*aec->bp << 9);
+ mqc->bp++;
+ mqc->c += 2 + 0xfe00 - (*mqc->bp << 9);
}
}
else{
- aec->bp++;
- aec->c += 1 + 0xff00 - (*aec->bp << 8);
+ mqc->bp++;
+ mqc->c += 1 + 0xff00 - (*mqc->bp << 8);
}
}
-static int exchange(AecState *aec, uint8_t *cxstate, int lps)
+static int exchange(MqcState *mqc, uint8_t *cxstate, int lps)
{
int d;
- if ((aec->a < ff_aec_qe[*cxstate]) ^ (!lps)){
+ if ((mqc->a < ff_mqc_qe[*cxstate]) ^ (!lps)){
if (lps)
- aec->a = ff_aec_qe[*cxstate];
+ mqc->a = ff_mqc_qe[*cxstate];
d = *cxstate & 1;
- *cxstate = ff_aec_nmps[*cxstate];
+ *cxstate = ff_mqc_nmps[*cxstate];
}
else{
if (lps)
- aec->a = ff_aec_qe[*cxstate];
+ mqc->a = ff_mqc_qe[*cxstate];
d = 1 - (*cxstate & 1);
- *cxstate = ff_aec_nlps[*cxstate];
+ *cxstate = ff_mqc_nlps[*cxstate];
}
// renormd:
do{
- if (!(aec->c & 0xff)){
- aec->c -= 0x100;
- bytein(aec);
+ if (!(mqc->c & 0xff)){
+ mqc->c -= 0x100;
+ bytein(mqc);
}
- aec->a += aec->a;
- aec->c += aec->c;
- } while (!(aec->a & 0x8000));
+ mqc->a += mqc->a;
+ mqc->c += mqc->c;
+ } while (!(mqc->a & 0x8000));
return d;
}
-void ff_aec_initdec(AecState *aec, uint8_t *bp)
+void ff_mqc_initdec(MqcState *mqc, uint8_t *bp)
{
- ff_aec_init_contexts(aec);
- aec->bp = bp;
- aec->c = (*aec->bp ^ 0xff) << 16;
- bytein(aec);
- aec->c = aec->c << 7;
- aec->a = 0x8000;
+ ff_mqc_init_contexts(mqc);
+ mqc->bp = bp;
+ mqc->c = (*mqc->bp ^ 0xff) << 16;
+ bytein(mqc);
+ mqc->c = mqc->c << 7;
+ mqc->a = 0x8000;
}
-int ff_aec_decode(AecState *aec, uint8_t *cxstate)
+int ff_mqc_decode(MqcState *mqc, uint8_t *cxstate)
{
- aec->a -= ff_aec_qe[*cxstate];
- if ((aec->c >> 16) < aec->a){
- if (aec->a & 0x8000)
+ mqc->a -= ff_mqc_qe[*cxstate];
+ if ((mqc->c >> 16) < mqc->a){
+ if (mqc->a & 0x8000)
return *cxstate & 1;
else
- return exchange(aec, cxstate, 0);
+ return exchange(mqc, cxstate, 0);
} else {
- aec->c -= aec->a << 16;
- return exchange(aec, cxstate, 1);
+ mqc->c -= mqc->a << 16;
+ return exchange(mqc, cxstate, 1);
}
}
Copied: jpeg2000/mqcenc.c (from r1047, /jpeg2000/aecenc.c)
==============================================================================
--- /jpeg2000/aecenc.c (original)
+++ jpeg2000/mqcenc.c Wed Aug 22 16:11:27 2007
@@ -1,5 +1,5 @@
/*
- * Arithmetic entropy coder
+ * MQ-coder encoder
* Copyright (c) 2007 Kamil Nowosad
*
* This file is part of FFmpeg.
@@ -20,100 +20,100 @@
*/
/**
- * Arithmetic entropy coder
- * @file aecenc.c
+ * MQ-coder encoder
+ * @file mqcenc.c
* @author Kamil Nowosad
*/
-#include "aec.h"
+#include "mqc.h"
-static void byteout(AecState *aec)
+static void byteout(MqcState *mqc)
{
retry:
- if (*aec->bp == 0xff){
- aec->bp++;
- *aec->bp = aec->c >> 20;
- aec->c &= 0xfffff;
- aec->ct = 7;
- } else if ((aec->c & 0x8000000)){
- (*aec->bp)++;
- aec->c &= 0x7ffffff;
+ if (*mqc->bp == 0xff){
+ mqc->bp++;
+ *mqc->bp = mqc->c >> 20;
+ mqc->c &= 0xfffff;
+ mqc->ct = 7;
+ } else if ((mqc->c & 0x8000000)){
+ (*mqc->bp)++;
+ mqc->c &= 0x7ffffff;
goto retry;
} else{
- aec->bp++;
- *aec->bp = aec->c >> 19;
- aec->c &= 0x7ffff;
- aec->ct = 8;
+ mqc->bp++;
+ *mqc->bp = mqc->c >> 19;
+ mqc->c &= 0x7ffff;
+ mqc->ct = 8;
}
}
-static void renorme(AecState *aec)
+static void renorme(MqcState *mqc)
{
do{
- aec->a += aec->a;
- aec->c += aec->c;
- if (!--aec->ct)
- byteout(aec);
- } while (!(aec->a & 0x8000));
+ mqc->a += mqc->a;
+ mqc->c += mqc->c;
+ if (!--mqc->ct)
+ byteout(mqc);
+ } while (!(mqc->a & 0x8000));
}
-static void setbits(AecState *aec)
+static void setbits(MqcState *mqc)
{
- int tmp = aec->c + aec->a;
- aec->c |= 0xffff;
- if (aec->c >= tmp)
- aec->c -= 0x8000;
+ int tmp = mqc->c + mqc->a;
+ mqc->c |= 0xffff;
+ if (mqc->c >= tmp)
+ mqc->c -= 0x8000;
}
-void ff_aec_initenc(AecState *aec, uint8_t *bp)
+void ff_mqc_initenc(MqcState *mqc, uint8_t *bp)
{
- ff_aec_init_contexts(aec);
- aec->a = 0x8000;
- aec->c = 0;
- aec->bp = bp-1;
- aec->bpstart = bp;
- aec->ct = 12 + (*aec->bp == 0xff);
+ ff_mqc_init_contexts(mqc);
+ mqc->a = 0x8000;
+ mqc->c = 0;
+ mqc->bp = bp-1;
+ mqc->bpstart = bp;
+ mqc->ct = 12 + (*mqc->bp == 0xff);
}
-void ff_aec_encode(AecState *aec, uint8_t *cxstate, int d)
+void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d)
{
int qe;
- qe = ff_aec_qe[*cxstate];
- aec->a -= qe;
+ qe = ff_mqc_qe[*cxstate];
+ mqc->a -= qe;
if ((*cxstate & 1) == d){
- if (!(aec->a & 0x8000)){
- if (aec->a < qe)
- aec->a = qe;
+ if (!(mqc->a & 0x8000)){
+ if (mqc->a < qe)
+ mqc->a = qe;
else
- aec->c += qe;
- *cxstate = ff_aec_nmps[*cxstate];
- renorme(aec);
+ mqc->c += qe;
+ *cxstate = ff_mqc_nmps[*cxstate];
+ renorme(mqc);
} else
- aec->c += qe;
+ mqc->c += qe;
} else{
- if (aec->a < qe)
- aec->c += qe;
+ if (mqc->a < qe)
+ mqc->c += qe;
else
- aec->a = qe;
- *cxstate = ff_aec_nlps[*cxstate];
- renorme(aec);
+ mqc->a = qe;
+ *cxstate = ff_mqc_nlps[*cxstate];
+ renorme(mqc);
}
}
-int ff_aec_length(AecState *aec)
+int ff_mqc_length(MqcState *mqc)
{
- return aec->bp - aec->bpstart;
+ return mqc->bp - mqc->bpstart;
}
-int ff_aec_flush(AecState *aec)
+int ff_mqc_flush(MqcState *mqc)
{
- setbits(aec);
- aec->c = aec->c << aec->ct;
- byteout(aec);
- aec->c = aec->c << aec->ct;
- byteout(aec);
- if (*aec->bp != 0xff)
- aec->bp++;
- return aec->bp - aec->bpstart;
+ setbits(mqc);
+ mqc->c = mqc->c << mqc->ct;
+ byteout(mqc);
+ mqc->c = mqc->c << mqc->ct;
+ byteout(mqc);
+ if (*mqc->bp != 0xff)
+ mqc->bp++;
+ return mqc->bp - mqc->bpstart;
}
More information about the FFmpeg-soc
mailing list