*/
#include "fix.h"
+#include <math.h> //Add Antonin : multbug1
#ifdef WIN32
#define int64 __int64
/*
* Multiply two fixed-precision rational numbers.
*/
+
+//int fix_mul(int a, int b)
+//{
+// return (int) ((int64) a * (int64) b >> 13);
+//}
+
+//Mod Antonin : multbug1
int fix_mul(int a, int b)
{
- return (int) ((int64) a * (int64) b >> 13);
+ double tmp= (double) ((int64) a * (int64) b);
+ int64 v = (int64) ((fabs(tmp/8192.0)>=floor(fabs(tmp/8192.0))+0.5)?fabs(tmp/8192.0)+1.0:fabs(tmp/8192.0));
+ v = (tmp<0)?-v:v;
+ return (int) v;
}
+//doM
+
static int t1_lut_nmsedec_ref[1 << T1_NMSEDEC_BITS];
static int t1_lut_nmsedec_ref0[1 << T1_NMSEDEC_BITS];
-static int t1_data[T1_MAXCBLKH][T1_MAXCBLKH];
+static int t1_data[T1_MAXCBLKH][T1_MAXCBLKW];
static int t1_flags[T1_MAXCBLKH + 2][T1_MAXCBLKH + 2];
int t1_getctxno_zc(int f, int orient)
}
}
+
void t1_dec_sigpass_step(int *fp, int *dp, int orient, int oneplushalf,
char type, int vsc)
{
vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC)
&& (j == k + 3 || j == h - 1)) ? 1 : 0;
t1_dec_sigpass_step(&t1_flags[1 + j][1 + i],
- &t1_data[j][i], orient, oneplushalf,
+ &t1_data[j][i],
+ orient,
+ oneplushalf,
type, vsc);
}
}
}
}
+
void t1_dec_refpass_step(int *fp, int *dp, int poshalf, int neghalf,
char type, int vsc)
{
vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC)
&& (j == k + 3 || j == h - 1)) ? 1 : 0;
t1_dec_refpass_step(&t1_flags[1 + j][1 + i],
- &t1_data[j][i], poshalf, neghalf, type, vsc);
+ &t1_data[j][i],
+ poshalf,
+ neghalf,
+ type, vsc);
}
}
}
*fp &= ~T1_VISIT;
}
+
void t1_dec_clnpass_step(int *fp, int *dp, int orient, int oneplushalf,
int partial, int vsc)
{
vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC)
&& (j == k + 3 || j == h - 1)) ? 1 : 0;
t1_dec_clnpass_step(&t1_flags[1 + j][1 + i],
- &t1_data[j][i], orient, oneplushalf,
+ &t1_data[j][i],
+ orient,
+ oneplushalf,
agg && (j == k + runlen), vsc);
}
}
mqc_init_dec(seg->data, seg->len);
/* dda */
+ if (bpno==0) cblk->lastbp=1; // Add Antonin : quantizbug1
+
for (passno = 0; passno < seg->numpasses; passno++) {
switch (passtype) {
case 0:
for (i = 0; i < cblk->x1 - cblk->x0; i++) {
if (t1_data[j][i] == 0) {
tilec->data[x + i +
- (y + j) * (tilec->x1 - tilec->x0)] = 0;
+ (y + j) * (tilec->x1 - tilec->x0)] = 0;
} else {
+ // Add antonin : quantizbug1
+ t1_data[j][i]<<=1;
+ //if (cblk->lastbp)
+ t1_data[j][i]+=t1_data[j][i]>0?1:-1;
+ // ddA
tilec->data[x + i +
(y + j) * (tilec->x1 -
tilec->
x0)] =
- fix_mul(t1_data[j][i] << 13, band->stepsize);
+ fix_mul(t1_data[j][i] << 12, band->stepsize); //Mod Antonin : quantizbug1 (before : << 13)
}
}
}
cblk->y0 = int_max(cblkystart, prc->y0);
cblk->x1 = int_min(cblkxend, prc->x1);
cblk->y1 = int_min(cblkyend, prc->y1);
+
+ cblk->lastbp = 0; // Add Antonin : quantizbug1
}
}
}
for (i = res->x0; i < res->x1; i++) {
int v;
+ double tmp= (double) tilec->data[i - res->x0 + (j - res->y0) * tw];
if (tcd_tcp->tccps[compno].qmfbid == 1) {
- v = tilec->data[i - res->x0 + (j - res->y0) * tw];
+ v = (int) tmp;
} else {
- v = tilec->data[i - res->x0 + (j - res->y0) * tw] >> 13;
+ //v = (int) tmp >> 13;
+ //Mod antonin : multbug1
+ v = (int) ((fabs(tmp/8192.0)>=floor(fabs(tmp/8192.0))+0.5)?fabs(tmp/8192.0)+1.0:fabs(tmp/8192.0));
+ v = (tmp<0)?-v:v;
+ //doM
}
v += adjust;