示例#1
0
文件: jpc_mqenc.c 项目: 353/viewercv
int jpc_mqenc_codemps2(jpc_mqenc_t* mqenc) {
    /* Note: This function only performs part of the work associated with
    the CODEMPS algorithm from the standard.  Some of the work is also
    performed by the caller. */

    jpc_mqstate_t* state = *(mqenc->curctx);
    if (mqenc->areg < state->qeval) {
        mqenc->areg = state->qeval;
    } else {
        mqenc->creg += state->qeval;
    }
    *mqenc->curctx = state->nmps;
    jpc_mqenc_renorme(mqenc->areg, mqenc->creg, mqenc->ctreg, mqenc);
    return jpc_mqenc_error(mqenc) ? (-1) : 0;
}
示例#2
0
文件: jpc_mqenc.c 项目: 353/viewercv
int jpc_mqenc_putbit_func(jpc_mqenc_t* mqenc, int bit) {
    const jpc_mqstate_t* state;
    JAS_DBGLOG(100, ("jpc_mqenc_putbit(%p, %d)\n", mqenc, bit));
    JPC_MQENC_CALL(100, jpc_mqenc_dump(mqenc, stderr));

    state = *(mqenc->curctx);

    if (state->mps == bit) {
        /* Apply the CODEMPS algorithm as defined in the standard. */
        mqenc->areg -= state->qeval;
        if (!(mqenc->areg & 0x8000)) {
            jpc_mqenc_codemps2(mqenc);
        } else {
            mqenc->creg += state->qeval;
        }
    } else {
        /* Apply the CODELPS algorithm as defined in the standard. */
        jpc_mqenc_codelps2(mqenc->areg, mqenc->creg, mqenc->ctreg, mqenc->curctx, mqenc);
    }

    return jpc_mqenc_error(mqenc) ? (-1) : 0;
}
static int jpc_encrefpass(jpc_mqenc_t *mqenc, int bitpos, int vcausalflag, jas_matrix_t *flags, jas_matrix_t *data,
  int term, long *nmsedec)
{
	int i;
	int j;
	int one;
	int vscanlen;
	int d;
	int width;
	int height;
	int frowstep;
	int drowstep;
	int fstripestep;
	int dstripestep;
	jpc_fix_t *fstripestart;
	jpc_fix_t *dstripestart;
	jpc_fix_t *fvscanstart;
	jpc_fix_t *dvscanstart;
	jpc_fix_t *dp;
	jpc_fix_t *fp;
int k;

	*nmsedec = 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 + JPC_NUMEXTRABITS);

	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;

			refpass_step(fp, dp, bitpos, one, nmsedec,
			  mqenc, vcausalflag);
			if (--k <= 0) {
				continue;
			}
			fp += frowstep;
			dp += drowstep;
			refpass_step(fp, dp, bitpos, one, nmsedec,
			  mqenc, 0);
			if (--k <= 0) {
				continue;
			}
			fp += frowstep;
			dp += drowstep;
			refpass_step(fp, dp, bitpos, one, nmsedec,
			  mqenc, 0);
			if (--k <= 0) {
				continue;
			}
			fp += frowstep;
			dp += drowstep;
			refpass_step(fp, dp, bitpos, one, nmsedec,
			  mqenc, 0);

		}
	}

	if (term) {
		jpc_mqenc_flush(mqenc, term - 1);
	}

	return jpc_mqenc_error(mqenc) ? (-1) : 0;
}
示例#4
0
int jpc_mqenc_codelps(jpc_mqenc_t *mqenc)
{
	jpc_mqenc_codelps2(mqenc->areg, mqenc->creg, mqenc->ctreg, mqenc->curctx, mqenc);
	return jpc_mqenc_error(mqenc) ? (-1) : 0;
}