[FFmpeg-soc] [soc]: r1047 - in jpeg2000: aec.h aecdec.c aecenc.c j2kdec.c j2kenc.c
k.nowosad
subversion at mplayerhq.hu
Mon Aug 20 15:16:32 CEST 2007
Author: k.nowosad
Date: Mon Aug 20 15:16:32 2007
New Revision: 1047
Log:
removed curcxtstate from AecState struct
Modified:
jpeg2000/aec.h
jpeg2000/aecdec.c
jpeg2000/aecenc.c
jpeg2000/j2kdec.c
jpeg2000/j2kenc.c
Modified: jpeg2000/aec.h
==============================================================================
--- jpeg2000/aec.h (original)
+++ jpeg2000/aec.h Mon Aug 20 15:16:32 2007
@@ -45,7 +45,6 @@ typedef struct {
unsigned int c;
unsigned int ct;
uint8_t cx_states[19];
- uint8_t *curcxstate;
} AecState;
/** encoder */
@@ -54,7 +53,7 @@ typedef struct {
void ff_aec_initenc(AecState *aec, uint8_t *bp);
/** code bit d with context cx */
-void ff_aec_encode(AecState *aec, int cx, int d);
+void ff_aec_encode(AecState *aec, uint8_t *cxstate, int d);
/** number of encoded bytes */
int ff_aec_length(AecState *aec);
@@ -68,7 +67,7 @@ int ff_aec_flush(AecState *aec);
void ff_aec_initdec(AecState *aec, uint8_t *bp);
/** returns decoded bit with context cx */
-int ff_aec_decode(AecState *aec, int cx);
+int ff_aec_decode(AecState *aec, uint8_t *cxstate);
/** common */
Modified: jpeg2000/aecdec.c
==============================================================================
--- jpeg2000/aecdec.c (original)
+++ jpeg2000/aecdec.c Mon Aug 20 15:16:32 2007
@@ -45,20 +45,20 @@ static void bytein(AecState *aec)
}
}
-static int exchange(AecState *aec, int lps)
+static int exchange(AecState *aec, uint8_t *cxstate, int lps)
{
int d;
- if ((aec->a < ff_aec_qe[*aec->curcxstate]) ^ (!lps)){
+ if ((aec->a < ff_aec_qe[*cxstate]) ^ (!lps)){
if (lps)
- aec->a = ff_aec_qe[*aec->curcxstate];
- d = *aec->curcxstate & 1;
- *aec->curcxstate = ff_aec_nmps[*aec->curcxstate];
+ aec->a = ff_aec_qe[*cxstate];
+ d = *cxstate & 1;
+ *cxstate = ff_aec_nmps[*cxstate];
}
else{
if (lps)
- aec->a = ff_aec_qe[*aec->curcxstate];
- d = 1 - (*aec->curcxstate & 1);
- *aec->curcxstate = ff_aec_nlps[*aec->curcxstate];
+ aec->a = ff_aec_qe[*cxstate];
+ d = 1 - (*cxstate & 1);
+ *cxstate = ff_aec_nlps[*cxstate];
}
// renormd:
do{
@@ -82,17 +82,16 @@ void ff_aec_initdec(AecState *aec, uint8
aec->a = 0x8000;
}
-int ff_aec_decode(AecState *aec, int cx)
+int ff_aec_decode(AecState *aec, uint8_t *cxstate)
{
- aec->curcxstate = aec->cx_states + cx;
- aec->a -= ff_aec_qe[*aec->curcxstate];
+ aec->a -= ff_aec_qe[*cxstate];
if ((aec->c >> 16) < aec->a){
if (aec->a & 0x8000)
- return *aec->curcxstate & 1;
+ return *cxstate & 1;
else
- return exchange(aec, 0);
+ return exchange(aec, cxstate, 0);
} else {
aec->c -= aec->a << 16;
- return exchange(aec, 1);
+ return exchange(aec, cxstate, 1);
}
}
Modified: jpeg2000/aecenc.c
==============================================================================
--- jpeg2000/aecenc.c (original)
+++ jpeg2000/aecenc.c Mon Aug 20 15:16:32 2007
@@ -75,20 +75,19 @@ void ff_aec_initenc(AecState *aec, uint8
aec->ct = 12 + (*aec->bp == 0xff);
}
-void ff_aec_encode(AecState *aec, int cx, int d)
+void ff_aec_encode(AecState *aec, uint8_t *cxstate, int d)
{
int qe;
- aec->curcxstate = aec->cx_states + cx;
- qe = ff_aec_qe[*aec->curcxstate];
+ qe = ff_aec_qe[*cxstate];
aec->a -= qe;
- if ((*aec->curcxstate & 1) == d){
+ if ((*cxstate & 1) == d){
if (!(aec->a & 0x8000)){
if (aec->a < qe)
aec->a = qe;
else
aec->c += qe;
- *aec->curcxstate = ff_aec_nmps[*aec->curcxstate];
+ *cxstate = ff_aec_nmps[*cxstate];
renorme(aec);
} else
aec->c += qe;
@@ -97,7 +96,7 @@ void ff_aec_encode(AecState *aec, int cx
aec->c += qe;
else
aec->a = qe;
- *aec->curcxstate = ff_aec_nlps[*aec->curcxstate];
+ *cxstate = ff_aec_nlps[*cxstate];
renorme(aec);
}
}
Modified: jpeg2000/j2kdec.c
==============================================================================
--- jpeg2000/j2kdec.c (original)
+++ jpeg2000/j2kdec.c Mon Aug 20 15:16:32 2007
@@ -763,10 +763,10 @@ static void decode_sigpass(J2kT1Context
for (k = i; k < height && k < i+4; k++){
if ((t1->flags[k+1][j+1] & J2K_T1_SIG_NB)
&& !(t1->flags[k+1][j+1] & (J2K_T1_SIG | J2K_T1_VIS))){
- if (ff_aec_decode(&t1->aec, ff_j2k_getnbctxno(t1->flags[k+1][j+1], bandno))){
+ if (ff_aec_decode(&t1->aec, t1->aec.cx_states + ff_j2k_getnbctxno(t1->flags[k+1][j+1], bandno))){
int xorbit, ctxno = ff_j2k_getsgnctxno(t1->flags[k+1][j+1], &xorbit);
- t1->data[k][j] = (ff_aec_decode(&t1->aec, ctxno) ^ xorbit) ? -mask : mask;
+ t1->data[k][j] = (ff_aec_decode(&t1->aec, t1->aec.cx_states + ctxno) ^ xorbit) ? -mask : mask;
ff_j2k_set_significant(t1, j, k);
}
@@ -788,7 +788,7 @@ static void decode_refpass(J2kT1Context
for (k = i; k < height && k < i+4; k++){
if ((t1->flags[k+1][j+1] & (J2K_T1_SIG | J2K_T1_VIS)) == J2K_T1_SIG){
int ctxno = ff_j2k_getrefctxno(t1->flags[k+1][j+1]);
- int r = ff_aec_decode(&t1->aec, ctxno) ? phalf : nhalf;
+ int r = ff_aec_decode(&t1->aec, t1->aec.cx_states + ctxno) ? phalf : nhalf;
t1->data[k][j] += t1->data[k][j] < 0 ? -r : r;
t1->flags[k+1][j+1] |= J2K_T1_REF;
}
@@ -806,10 +806,10 @@ static void decode_clnpass(J2kT1Context
(t1->flags[i+2][j+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)) ||
(t1->flags[i+3][j+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)) ||
(t1->flags[i+4][j+1] & (J2K_T1_SIG_NB | J2K_T1_VIS | J2K_T1_SIG)))){
- if (!ff_aec_decode(&t1->aec, AEC_CX_RL))
+ if (!ff_aec_decode(&t1->aec, t1->aec.cx_states + AEC_CX_RL))
continue;
- runlen = ff_aec_decode(&t1->aec, AEC_CX_UNI);
- runlen = (runlen << 1) | ff_aec_decode(&t1->aec, AEC_CX_UNI);
+ 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);
dec = 1;
}
else{
@@ -820,11 +820,11 @@ static void decode_clnpass(J2kT1Context
for (k = i + runlen; k < i + 4 && k < height; k++){
if (!dec){
if (!(t1->flags[k+1][j+1] & (J2K_T1_SIG | J2K_T1_VIS)))
- dec = ff_aec_decode(&t1->aec, ff_j2k_getnbctxno(t1->flags[k+1][j+1], bandno));
+ dec = ff_aec_decode(&t1->aec, t1->aec.cx_states + ff_j2k_getnbctxno(t1->flags[k+1][j+1], bandno));
}
if (dec){
int xorbit, ctxno = ff_j2k_getsgnctxno(t1->flags[k+1][j+1], &xorbit);
- t1->data[k][j] = (ff_aec_decode(&t1->aec, ctxno) ^ xorbit) ? -mask : mask;
+ t1->data[k][j] = (ff_aec_decode(&t1->aec, t1->aec.cx_states + ctxno) ^ xorbit) ? -mask : mask;
ff_j2k_set_significant(t1, j, k);
}
dec = 0;
Modified: jpeg2000/j2kenc.c
==============================================================================
--- jpeg2000/j2kenc.c (original)
+++ jpeg2000/j2kenc.c Mon Aug 20 15:16:32 2007
@@ -641,11 +641,11 @@ static void encode_sigpass(J2kT1Context
if (!(t1->flags[k+1][j+1] & J2K_T1_SIG) && (t1->flags[k+1][j+1] & J2K_T1_SIG_NB)){
int ctxno = ff_j2k_getnbctxno(t1->flags[k+1][j+1], bandno),
bit = abs(t1->data[k][j]) & mask ? 1 : 0;
- ff_aec_encode(&t1->aec, ctxno, bit);
+ ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, bit);
if (bit){
int xorbit;
int ctxno = ff_j2k_getsgnctxno(t1->flags[k+1][j+1], &xorbit);
- ff_aec_encode(&t1->aec, ctxno, (t1->data[k][j] < 0) ^ xorbit);
+ ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, (t1->data[k][j] < 0) ^ xorbit);
*nmsedec += getnmsedec_sig(abs(t1->data[k][j]), bpno + NMSEDEC_FRACBITS);
ff_j2k_set_significant(t1, j, k);
}
@@ -663,7 +663,7 @@ static void encode_refpass(J2kT1Context
if ((t1->flags[k+1][j+1] & (J2K_T1_SIG | J2K_T1_VIS)) == J2K_T1_SIG){
int ctxno = ff_j2k_getrefctxno(t1->flags[k+1][j+1]);
*nmsedec += getnmsedec_ref(abs(t1->data[k][j]), bpno + NMSEDEC_FRACBITS);
- ff_aec_encode(&t1->aec, ctxno, abs(t1->data[k][j]) & mask ? 1:0);
+ ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, abs(t1->data[k][j]) & mask ? 1:0);
t1->flags[k+1][j+1] |= J2K_T1_REF;
}
}
@@ -684,21 +684,21 @@ static void encode_clnpass(J2kT1Context
for (rlen = 0; rlen < 4; rlen++)
if (abs(t1->data[i+rlen][j]) & mask)
break;
- ff_aec_encode(&t1->aec, AEC_CX_RL, rlen != 4);
+ ff_aec_encode(&t1->aec, t1->aec.cx_states + AEC_CX_RL, rlen != 4);
if (rlen == 4)
continue;
- ff_aec_encode(&t1->aec, AEC_CX_UNI, rlen >> 1);
- ff_aec_encode(&t1->aec, AEC_CX_UNI, rlen & 1);
+ 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);
for (k = i + rlen; k < i + 4; k++){
if (!(t1->flags[k+1][j+1] & (J2K_T1_SIG | J2K_T1_VIS))){
int ctxno = ff_j2k_getnbctxno(t1->flags[k+1][j+1], bandno);
if (k > i + rlen)
- ff_aec_encode(&t1->aec, ctxno, abs(t1->data[k][j]) & mask ? 1:0);
+ ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, abs(t1->data[k][j]) & mask ? 1:0);
if (abs(t1->data[k][j]) & mask){ // newly significant
int xorbit;
int ctxno = ff_j2k_getsgnctxno(t1->flags[k+1][j+1], &xorbit);
*nmsedec += getnmsedec_sig(abs(t1->data[k][j]), bpno + NMSEDEC_FRACBITS);
- ff_aec_encode(&t1->aec, ctxno, (t1->data[k][j] < 0) ^ xorbit);
+ ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, (t1->data[k][j] < 0) ^ xorbit);
ff_j2k_set_significant(t1, j, k);
}
}
@@ -709,12 +709,12 @@ static void encode_clnpass(J2kT1Context
for (k = i; k < i + 4 && k < height; k++){
if (!(t1->flags[k+1][j+1] & (J2K_T1_SIG | J2K_T1_VIS))){
int ctxno = ff_j2k_getnbctxno(t1->flags[k+1][j+1], bandno);
- ff_aec_encode(&t1->aec, ctxno, abs(t1->data[k][j]) & mask ? 1:0);
+ ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, abs(t1->data[k][j]) & mask ? 1:0);
if (abs(t1->data[k][j]) & mask){ // newly significant
int xorbit;
int ctxno = ff_j2k_getsgnctxno(t1->flags[k+1][j+1], &xorbit);
*nmsedec += getnmsedec_sig(abs(t1->data[k][j]), bpno + NMSEDEC_FRACBITS);
- ff_aec_encode(&t1->aec, ctxno, (t1->data[k][j] < 0) ^ xorbit);
+ ff_aec_encode(&t1->aec, t1->aec.cx_states + ctxno, (t1->data[k][j] < 0) ^ xorbit);
ff_j2k_set_significant(t1, j, k);
}
}
More information about the FFmpeg-soc
mailing list