⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpc_qmfb.c

📁 jasper最新版本
💻 C
📖 第 1 页 / 共 5 页
字号:
				++lptr2;				++hptr2;			}		}		/* Apply the second lifting step. */		lptr = &a[0];		hptr = &a[llen * stride];		if (!parity) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < numcols; ++i) {				lptr2[0] += (hptr2[0] + 1) >> 1;				++lptr2;				++hptr2;			}			lptr += stride;		}		n = llen - (!parity) - (parity != (numrows & 1));		while (n-- > 0) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < numcols; ++i) {				lptr2[0] += (hptr2[0] + hptr2[stride] + 2) >> 2;				++lptr2;				++hptr2;			}			lptr += stride;			hptr += stride;		}		if (parity != (numrows & 1)) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < numcols; ++i) {				lptr2[0] += (hptr2[0] + 1) >> 1;				++lptr2;				++hptr2;			}		}	} else {		if (parity) {			lptr2 = &a[0];			for (i = 0; i < numcols; ++i) {				lptr2[0] <<= 1;				++lptr2;			}		}	}}void jpc_ft_invlift_row(jpc_fix_t *a, int numcols, int parity){	register jpc_fix_t *lptr;	register jpc_fix_t *hptr;	register int n;	int llen;	llen = (numcols + 1 - parity) >> 1;	if (numcols > 1) {		/* Apply the first lifting step. */		lptr = &a[0];		hptr = &a[llen];		if (!parity) {			lptr[0] -= (hptr[0] + 1) >> 1;			++lptr;		}		n = llen - (!parity) - (parity != (numcols & 1));		while (n-- > 0) {			lptr[0] -= (hptr[0] + hptr[1] + 2) >> 2;			++lptr;			++hptr;		}		if (parity != (numcols & 1)) {			lptr[0] -= (hptr[0] + 1) >> 1;		}		/* Apply the second lifting step. */		lptr = &a[0];		hptr = &a[llen];		if (parity) {			hptr[0] += lptr[0];			++hptr;		}		n = numcols - llen - parity - (parity == (numcols & 1));		while (n-- > 0) {			hptr[0] += (lptr[0] + lptr[1]) >> 1;			++hptr;			++lptr;		}		if (parity == (numcols & 1)) {			hptr[0] += lptr[0];		}	} else {		if (parity) {			lptr = &a[0];			lptr[0] >>= 1;		}	}}void jpc_ft_invlift_col(jpc_fix_t *a, int numrows, int stride, int parity){	jpc_fix_t *lptr;	jpc_fix_t *hptr;#if 0	register jpc_fix_t *lptr2;	register jpc_fix_t *hptr2;	register int i;#endif	register int n;	int llen;	llen = (numrows + 1 - parity) >> 1;	if (numrows > 1) {		/* Apply the first lifting step. */		lptr = &a[0];		hptr = &a[llen * stride];		if (!parity) {			lptr[0] -= (hptr[0] + 1) >> 1;			lptr += stride;		}		n = llen - (!parity) - (parity != (numrows & 1));		while (n-- > 0) {			lptr[0] -= (hptr[0] + hptr[stride] + 2) >> 2;			lptr += stride;			hptr += stride;		}		if (parity != (numrows & 1)) {			lptr[0] -= (hptr[0] + 1) >> 1;		}		/* Apply the second lifting step. */		lptr = &a[0];		hptr = &a[llen * stride];		if (parity) {			hptr[0] += lptr[0];			hptr += stride;		}		n = numrows - llen - parity - (parity == (numrows & 1));		while (n-- > 0) {			hptr[0] += (lptr[0] + lptr[stride]) >> 1;			hptr += stride;			lptr += stride;		}		if (parity == (numrows & 1)) {			hptr[0] += lptr[0];		}	} else {		if (parity) {			lptr = &a[0];			lptr[0] >>= 1;		}	}}void jpc_ft_invlift_colgrp(jpc_fix_t *a, int numrows, int stride, int parity){	jpc_fix_t *lptr;	jpc_fix_t *hptr;	register jpc_fix_t *lptr2;	register jpc_fix_t *hptr2;	register int n;	register int i;	int llen;	llen = (numrows + 1 - parity) >> 1;	if (numrows > 1) {		/* Apply the first lifting step. */		lptr = &a[0];		hptr = &a[llen * stride];		if (!parity) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {				lptr2[0] -= (hptr2[0] + 1) >> 1;				++lptr2;				++hptr2;			}			lptr += stride;		}		n = llen - (!parity) - (parity != (numrows & 1));		while (n-- > 0) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {				lptr2[0] -= (hptr2[0] + hptr2[stride] + 2) >> 2;				++lptr2;				++hptr2;			}			lptr += stride;			hptr += stride;		}		if (parity != (numrows & 1)) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {				lptr2[0] -= (hptr2[0] + 1) >> 1;				++lptr2;				++hptr2;			}		}		/* Apply the second lifting step. */		lptr = &a[0];		hptr = &a[llen * stride];		if (parity) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {				hptr2[0] += lptr2[0];				++hptr2;				++lptr2;			}			hptr += stride;		}		n = numrows - llen - parity - (parity == (numrows & 1));		while (n-- > 0) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {				hptr2[0] += (lptr2[0] + lptr2[stride]) >> 1;				++lptr2;				++hptr2;			}			hptr += stride;			lptr += stride;		}		if (parity == (numrows & 1)) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {				hptr2[0] += lptr2[0];				++lptr2;				++hptr2;			}		}	} else {		if (parity) {			lptr2 = &a[0];			for (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {				lptr2[0] >>= 1;				++lptr2;			}		}	}}void jpc_ft_invlift_colres(jpc_fix_t *a, int numrows, int numcols, int stride,  int parity){	jpc_fix_t *lptr;	jpc_fix_t *hptr;	register jpc_fix_t *lptr2;	register jpc_fix_t *hptr2;	register int n;	register int i;	int llen;	llen = (numrows + 1 - parity) >> 1;	if (numrows > 1) {		/* Apply the first lifting step. */		lptr = &a[0];		hptr = &a[llen * stride];		if (!parity) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < numcols; ++i) {				lptr2[0] -= (hptr2[0] + 1) >> 1;				++lptr2;				++hptr2;			}			lptr += stride;		}		n = llen - (!parity) - (parity != (numrows & 1));		while (n-- > 0) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < numcols; ++i) {				lptr2[0] -= (hptr2[0] + hptr2[stride] + 2) >> 2;				++lptr2;				++hptr2;			}			lptr += stride;			hptr += stride;		}		if (parity != (numrows & 1)) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < numcols; ++i) {				lptr2[0] -= (hptr2[0] + 1) >> 1;				++lptr2;				++hptr2;			}		}		/* Apply the second lifting step. */		lptr = &a[0];		hptr = &a[llen * stride];		if (parity) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < numcols; ++i) {				hptr2[0] += lptr2[0];				++hptr2;				++lptr2;			}			hptr += stride;		}		n = numrows - llen - parity - (parity == (numrows & 1));		while (n-- > 0) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < numcols; ++i) {				hptr2[0] += (lptr2[0] + lptr2[stride]) >> 1;				++lptr2;				++hptr2;			}			hptr += stride;			lptr += stride;		}		if (parity == (numrows & 1)) {			lptr2 = lptr;			hptr2 = hptr;			for (i = 0; i < numcols; ++i) {				hptr2[0] += lptr2[0];				++lptr2;				++hptr2;			}		}	} else {		if (parity) {			lptr2 = &a[0];			for (i = 0; i < numcols; ++i) {				lptr2[0] >>= 1;				++lptr2;			}		}	}}int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,  int stride){	int numrows = height;	int numcols = width;	int rowparity = ystart & 1;	int colparity = xstart & 1;	int i;	jpc_fix_t *startptr;	int maxcols;	maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE;	startptr = &a[0];	for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {		jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity);		jpc_ft_fwdlift_colgrp(startptr, numrows, stride, rowparity);		startptr += JPC_QMFB_COLGRPSIZE;	}	if (maxcols < numcols) {		jpc_qmfb_split_colres(startptr, numrows, numcols - maxcols, stride,		  rowparity);		jpc_ft_fwdlift_colres(startptr, numrows, numcols - maxcols, stride,		  rowparity);	}	startptr = &a[0];	for (i = 0; i < numrows; ++i) {		jpc_qmfb_split_row(startptr, numcols, colparity);		jpc_ft_fwdlift_row(startptr, numcols, colparity);		startptr += stride;	}	return 0;}int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height,  int stride){	int numrows = height;	int numcols = width;	int rowparity = ystart & 1;	int colparity = xstart & 1;	int maxcols;	jpc_fix_t *startptr;	int i;	startptr = &a[0];	for (i = 0; i < numrows; ++i) {		jpc_ft_invlift_row(startptr, numcols, colparity);		jpc_qmfb_join_row(startptr, numcols, colparity);		startptr += stride;	}	maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE;	startptr = &a[0];	for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {		jpc_ft_invlift_colgrp(startptr, numrows, stride, rowparity);		jpc_qmfb_join_colgrp(startptr, numrows, stride, rowparity);		startptr += JPC_QMFB_COLGRPSIZE;	}	if (maxcols < numcols) {		jpc_ft_invlift_colres(startptr, numrows, numcols - maxcols, stride,		  rowparity);		jpc_qmfb_join_colres(startptr, numrows, numcols - maxcols, stride,		  rowparity);	}	return 0;}/******************************************************************************\* 9/7 transform\******************************************************************************/#define ALPHA (-1.586134342059924)#define BETA (-0.052980118572961)#define GAMMA (0.882911075530934)#define DELTA (0.443506852043971)#define LGAIN (1.0 / 1.23017410558578)#define HGAIN (1.0 / 1.62578613134411)void jpc_ns_fwdlift_row(jpc_fix_t *a, int numcols, int parity){	register jpc_fix_t *lptr;	register jpc_fix_t *hptr;	register int n;	int llen;	llen = (numcols + 1 - parity) >> 1;	if (numcols > 1) {		/* Apply the first lifting step. */		lptr = &a[0];		hptr = &a[llen];		if (parity) {			jpc_fix_pluseq(hptr[0], jpc_fix_mul(jpc_dbltofix(2.0 * ALPHA),			  lptr[0]));			++hptr;		}		n = numcols - llen - parity - (parity == (numcols & 1));		while (n-- > 0) {			jpc_fix_pluseq(hptr[0], jpc_fix_mul(jpc_dbltofix(ALPHA),			  jpc_fix_add(lptr[0], lptr[1])));			++hptr;			++lptr;		}		if (parity == (numcols & 1)) {			jpc_fix_pluseq(hptr[0], jpc_fix_mul(jpc_dbltofix(2.0 * ALPHA),			  lptr[0]));		}		/* Apply the second lifting step. */		lptr = &a[0];		hptr = &a[llen];		if (!parity) {			jpc_fix_pluseq(lptr[0], jpc_fix_mul(jpc_dbltofix(2.0 * BETA),			  hptr[0]));			++lptr;		}		n = llen - (!parity) - (parity != (numcols & 1));		while (n-- > 0) {			jpc_fix_pluseq(lptr[0], jpc_fix_mul(jpc_dbltofix(BETA),			  jpc_fix_add(hptr[0], hptr[1])));			++lptr;			++hptr;		}		if (parity != (numcols & 1)) {			jpc_fix_pluseq(lptr[0], jpc_fix_mul(jpc_dbltofix(2.0 * BETA),			  hptr[0]));		}		/* Apply the third lifting step. */		lptr = &a[0];		hptr = &a[llen];		if (parity) {			jpc_fix_pluseq(hptr[0], jpc_fix_mul(jpc_dbltofix(2.0 * GAMMA),			  lptr[0]));			++hptr;		}		n = numcols - llen - parity - (parity == (numcols & 1));		while (n-- > 0) {			jpc_fix_pluseq(hptr[0], jpc_fix_mul(jpc_dbltofix(GAMMA),			  jpc_fix_add(lptr[0], lptr[1])));			++hptr;			++lptr;		}		if (parity == (numcols & 1)) {			jpc_fix_pluseq(hptr[0], jpc_fix_mul(jpc_dbltofix(2.0 * GAMMA),			  lptr[0]));		}		/* Apply the fourth lifting step. */		lptr = &a[0];		hptr = &a[llen];		if (!parity) {			jpc_fix_pluseq(lptr[0], jpc_fix_mul(jpc_dbltofix(2.0 * DELTA),			  hptr[0]));			++lptr;		}		n = llen - (!parity) - (parity != (numcols & 1));		while (n-- > 0) {			jpc_fix_pluseq(lptr[0], jpc_fix_mul(jpc_dbltofix(DELTA),			  jpc_fix_add(hptr[0], hptr[1])));			++lptr;			++hptr;		}		if (parity != (numcols & 1)) {			jpc_fix_pluseq(lptr[0], jpc_fix_mul(jpc_dbltofix(2.0 * DELTA),			  hptr[0]));		}		/* Apply the scaling step. */#if defined(WT_DOSCALE)		lptr = &a[0];		n = llen;		while (n-- > 0) {			lptr[0] = jpc_fix_mul(lptr[0], jpc_dbltofix(LGAIN));			++lptr;		}		hptr = &a[llen];		n = numcols - llen;		while (n-- > 0) {			hptr[0] = jpc_fix_mul(hptr[0], jpc_dbltofix(HGAIN));			++hptr;		}#endif	} else {#if defined(WT_LENONE)		if (parity) {			lptr = &a[0];			lptr[0] <<= 1;		}#endif	}}void jpc_ns_fwdlift_colgrp(jpc_fix_t *a, int numrows, int stride,  int parity){	jpc_fix_t *lptr;	jpc_fix_t *hptr;	register jpc_fix_t *lptr2;	register jpc_fix_t *hptr2;	register int n;	register int i;	int llen;	llen = (numrows + 1 - parity) >> 1;	if (numrows > 1) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -