📄 jpc_t1dec.c
字号:
*(fp) |= JPC_VISIT; \
} \
}
static int dec_rawsigpass(jpc_dec_t *dec, jpc_bitstream_t *in, int bitpos, int vcausalflag,
jas_matrix_t *flags, jas_matrix_t *data)
{
int i;
int j;
int k;
int one;
int half;
int oneplushalf;
int vscanlen;
int width;
int height;
jpc_fix_t *fp;
int frowstep;
int fstripestep;
jpc_fix_t *fstripestart;
jpc_fix_t *fvscanstart;
jpc_fix_t *dp;
int drowstep;
int dstripestep;
jpc_fix_t *dstripestart;
jpc_fix_t *dvscanstart;
/* Avoid compiler warning about unused parameters. */
dec = 0;
width = jas_matrix_numcols(data);
height = jas_matrix_numrows(data);
frowstep = jas_matrix_rowstep(flags);
drowstep = jas_matrix_rowstep(data);
fstripestep = frowstep << 2;
dstripestep = drowstep << 2;
one = 1 << bitpos;
half = one >> 1;
oneplushalf = one | half;
fstripestart = jas_matrix_getref(flags, 1, 1);
dstripestart = jas_matrix_getref(data, 0, 0);
for (i = height; i > 0; i -= 4, fstripestart += fstripestep,
dstripestart += dstripestep) {
fvscanstart = fstripestart;
dvscanstart = dstripestart;
vscanlen = JAS_MIN(i, 4);
for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) {
fp = fvscanstart;
dp = dvscanstart;
k = vscanlen;
/* Process first sample in vertical scan. */
jpc_rawsigpass_step(fp, frowstep, dp, oneplushalf,
in, vcausalflag);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process second sample in vertical scan. */
jpc_rawsigpass_step(fp, frowstep, dp, oneplushalf,
in, 0);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process third sample in vertical scan. */
jpc_rawsigpass_step(fp, frowstep, dp, oneplushalf,
in, 0);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process fourth sample in vertical scan. */
jpc_rawsigpass_step(fp, frowstep, dp, oneplushalf,
in, 0);
}
}
return 0;
}
/******************************************************************************\
* Code for refinement pass.
\******************************************************************************/
#define jpc_refpass_step(fp, dp, poshalf, neghalf, mqdec, vcausalflag) \
{ \
int v; \
int t; \
if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \
jpc_mqdec_setcurctx((mqdec), JPC_GETMAGCTXNO(*(fp))); \
JPC_T1D_GETBITNOSKEW((mqdec), v, "REF", "MR"); \
t = (v ? (poshalf) : (neghalf)); \
*(dp) += (*(dp) < 0) ? (-t) : t; \
*(fp) |= JPC_REFINE; \
} \
}
static int dec_refpass(jpc_dec_t *dec, register jpc_mqdec_t *mqdec, int bitpos,
int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data)
{
int i;
int j;
int vscanlen;
int width;
int height;
int one;
int poshalf;
int neghalf;
jpc_fix_t *fp;
int frowstep;
int fstripestep;
jpc_fix_t *fstripestart;
jpc_fix_t *fvscanstart;
jpc_fix_t *dp;
int drowstep;
int dstripestep;
jpc_fix_t *dstripestart;
jpc_fix_t *dvscanstart;
int k;
/* Avoid compiler warning about unused parameters. */
dec = 0;
vcausalflag = 0;
width = jas_matrix_numcols(data);
height = jas_matrix_numrows(data);
frowstep = jas_matrix_rowstep(flags);
drowstep = jas_matrix_rowstep(data);
fstripestep = frowstep << 2;
dstripestep = drowstep << 2;
one = 1 << bitpos;
poshalf = one >> 1;
neghalf = (bitpos > 0) ? (-poshalf) : (-1);
fstripestart = jas_matrix_getref(flags, 1, 1);
dstripestart = jas_matrix_getref(data, 0, 0);
for (i = height; i > 0; i -= 4, fstripestart += fstripestep,
dstripestart += dstripestep) {
fvscanstart = fstripestart;
dvscanstart = dstripestart;
vscanlen = JAS_MIN(i, 4);
for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) {
fp = fvscanstart;
dp = dvscanstart;
k = vscanlen;
/* Process first sample in vertical scan. */
jpc_refpass_step(fp, dp, poshalf, neghalf, mqdec,
vcausalflag);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process second sample in vertical scan. */
jpc_refpass_step(fp, dp, poshalf, neghalf, mqdec, 0);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process third sample in vertical scan. */
jpc_refpass_step(fp, dp, poshalf, neghalf, mqdec, 0);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process fourth sample in vertical scan. */
jpc_refpass_step(fp, dp, poshalf, neghalf, mqdec, 0);
}
}
return 0;
}
#define jpc_rawrefpass_step(fp, dp, poshalf, neghalf, in, vcausalflag) \
{ \
jpc_fix_t v; \
jpc_fix_t t; \
if (((*(fp)) & (JPC_SIG | JPC_VISIT)) == JPC_SIG) { \
JPC_T1D_RAWGETBIT(in, v, "REF", "MAGREF"); \
if (v < 0) { \
return -1; \
} \
t = (v ? poshalf : neghalf); \
*(dp) += (*(dp) < 0) ? (-t) : t; \
*(fp) |= JPC_REFINE; \
} \
}
static int dec_rawrefpass(jpc_dec_t *dec, jpc_bitstream_t *in, int bitpos, int vcausalflag,
jas_matrix_t *flags, jas_matrix_t *data)
{
int i;
int j;
int k;
int vscanlen;
int width;
int height;
int one;
int poshalf;
int neghalf;
jpc_fix_t *fp;
int frowstep;
int fstripestep;
jpc_fix_t *fstripestart;
jpc_fix_t *fvscanstart;
jpc_fix_t *dp;
int drowstep;
int dstripestep;
jpc_fix_t *dstripestart;
jpc_fix_t *dvscanstart;
/* Avoid compiler warning about unused parameters. */
dec = 0;
vcausalflag = 0;
width = jas_matrix_numcols(data);
height = jas_matrix_numrows(data);
frowstep = jas_matrix_rowstep(flags);
drowstep = jas_matrix_rowstep(data);
fstripestep = frowstep << 2;
dstripestep = drowstep << 2;
one = 1 << bitpos;
poshalf = one >> 1;
neghalf = (bitpos > 0) ? (-poshalf) : (-1);
fstripestart = jas_matrix_getref(flags, 1, 1);
dstripestart = jas_matrix_getref(data, 0, 0);
for (i = height; i > 0; i -= 4, fstripestart += fstripestep,
dstripestart += dstripestep) {
fvscanstart = fstripestart;
dvscanstart = dstripestart;
vscanlen = JAS_MIN(i, 4);
for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) {
fp = fvscanstart;
dp = dvscanstart;
k = vscanlen;
/* Process first sample in vertical scan. */
jpc_rawrefpass_step(fp, dp, poshalf, neghalf, in,
vcausalflag);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process second sample in vertical scan. */
jpc_rawrefpass_step(fp, dp, poshalf, neghalf, in, 0);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process third sample in vertical scan. */
jpc_rawrefpass_step(fp, dp, poshalf, neghalf, in, 0);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process fourth sample in vertical scan. */
jpc_rawrefpass_step(fp, dp, poshalf, neghalf, in, 0);
}
}
return 0;
}
/******************************************************************************\
* Code for cleanup pass.
\******************************************************************************/
#define jpc_clnpass_step(f, fp, frowstep, dp, oneplushalf, orient, mqdec, flabel, plabel, vcausalflag) \
{ \
int v; \
flabel \
if (!((f) & (JPC_SIG | JPC_VISIT))) { \
jpc_mqdec_setcurctx((mqdec), JPC_GETZCCTXNO((f), (orient))); \
JPC_T1D_GETBIT((mqdec), v, "CLN", "ZC"); \
if (v) { \
plabel \
/* Coefficient is significant. */ \
jpc_mqdec_setcurctx((mqdec), JPC_GETSCCTXNO(f)); \
JPC_T1D_GETBIT((mqdec), v, "CLN", "SC"); \
v ^= JPC_GETSPB(f); \
*(dp) = (v) ? (-(oneplushalf)) : (oneplushalf); \
JPC_UPDATEFLAGS4((fp), (frowstep), v, (vcausalflag)); \
*(fp) |= JPC_SIG; \
} \
} \
/* XXX - Is this correct? Can aggregation cause some VISIT bits not to be reset? Check. */ \
*(fp) &= ~JPC_VISIT; \
}
static int dec_clnpass(jpc_dec_t *dec, register jpc_mqdec_t *mqdec, int bitpos, int orient,
int vcausalflag, int segsymflag, jas_matrix_t *flags, jas_matrix_t *data)
{
int i;
int j;
int k;
int vscanlen;
int v;
int half;
int runlen;
int f;
int width;
int height;
int one;
int oneplushalf;
jpc_fix_t *fp;
int frowstep;
int fstripestep;
jpc_fix_t *fstripestart;
jpc_fix_t *fvscanstart;
jpc_fix_t *dp;
int drowstep;
int dstripestep;
jpc_fix_t *dstripestart;
jpc_fix_t *dvscanstart;
/* Avoid compiler warning about unused parameters. */
dec = 0;
one = 1 << bitpos;
half = one >> 1;
oneplushalf = one | half;
width = jas_matrix_numcols(data);
height = jas_matrix_numrows(data);
frowstep = jas_matrix_rowstep(flags);
drowstep = jas_matrix_rowstep(data);
fstripestep = frowstep << 2;
dstripestep = drowstep << 2;
fstripestart = jas_matrix_getref(flags, 1, 1);
dstripestart = jas_matrix_getref(data, 0, 0);
for (i = 0; i < height; i += 4, fstripestart += fstripestep,
dstripestart += dstripestep) {
fvscanstart = fstripestart;
dvscanstart = dstripestart;
vscanlen = JAS_MIN(4, height - i);
for (j = width; j > 0; --j, ++fvscanstart, ++dvscanstart) {
fp = fvscanstart;
if (vscanlen >= 4 && (!((*fp) & (JPC_SIG | JPC_VISIT |
JPC_OTHSIGMSK))) && (fp += frowstep, !((*fp) & (JPC_SIG |
JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep, !((*fp) &
(JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK))) && (fp += frowstep,
!((*fp) & (JPC_SIG | JPC_VISIT | JPC_OTHSIGMSK)))) {
jpc_mqdec_setcurctx(mqdec, JPC_AGGCTXNO);
JPC_T1D_GETBIT(mqdec, v, "CLN", "AGG");
if (!v) {
continue;
}
jpc_mqdec_setcurctx(mqdec, JPC_UCTXNO);
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "RL");
runlen = v;
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "RL");
runlen = (runlen << 1) | v;
f = *(fp = fvscanstart + frowstep * runlen);
dp = dvscanstart + drowstep * runlen;
k = vscanlen - runlen;
switch (runlen) {
case 0:
goto clnpass_partial0;
break;
case 1:
goto clnpass_partial1;
break;
case 2:
goto clnpass_partial2;
break;
case 3:
goto clnpass_partial3;
break;
}
} else {
f = *(fp = fvscanstart);
dp = dvscanstart;
k = vscanlen;
goto clnpass_full0;
}
/* Process first sample in vertical scan. */
jpc_clnpass_step(f, fp, frowstep, dp, oneplushalf, orient,
mqdec, clnpass_full0:, clnpass_partial0:,
vcausalflag);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process second sample in vertical scan. */
f = *fp;
jpc_clnpass_step(f, fp, frowstep, dp, oneplushalf, orient,
mqdec, ;, clnpass_partial1:, 0);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process third sample in vertical scan. */
f = *fp;
jpc_clnpass_step(f, fp, frowstep, dp, oneplushalf, orient,
mqdec, ;, clnpass_partial2:, 0);
if (--k <= 0) {
continue;
}
fp += frowstep;
dp += drowstep;
/* Process fourth sample in vertical scan. */
f = *fp;
jpc_clnpass_step(f, fp, frowstep, dp, oneplushalf, orient,
mqdec, ;, clnpass_partial3:, 0);
}
}
if (segsymflag) {
int segsymval;
segsymval = 0;
jpc_mqdec_setcurctx(mqdec, JPC_UCTXNO);
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "SEGSYM");
segsymval = (segsymval << 1) | (v & 1);
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "SEGSYM");
segsymval = (segsymval << 1) | (v & 1);
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "SEGSYM");
segsymval = (segsymval << 1) | (v & 1);
JPC_T1D_GETBITNOSKEW(mqdec, v, "CLN", "SEGSYM");
segsymval = (segsymval << 1) | (v & 1);
if (segsymval != 0xa) {
jas_eprintf("warning: bad segmentation symbol\n");
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -