jpc_qmfb.c.svn-base

来自「SumatraPDF是一款小型开源的pdf阅读工具。虽然玲珑小巧(只有800多K」· SVN-BASE 代码 · 共 1,657 行 · 第 1/3 页

SVN-BASE
1,657
字号
	{
		interstep = jas_seq2d_rowstep(x);
		intrastep = 1;
		numseq = jas_seq2d_height(x);
		startind = jas_seq2d_xstart(x);
		endind = jas_seq2d_xend(x);
	}

	assert(startind < endind);

	startptr = jas_seq2d_getref(x, jas_seq2d_xstart(x), jas_seq2d_ystart(x));

	if (!(flags & JPC_QMFB1D_RITIMODE)) 
	{
		while (numseq-- > 0) 
		{
			jpc_qmfb1d_setup(	startptr, 
								startind, 
								endind, 
								intrastep,
								&lstartptr, 
								&lstartind, 
								&lendind, 
								&hstartptr,
								&hstartind, 
								&hendind
							);

			if (endind - startind > 1) 
			{
#if !defined(USE_LF_ASM)
				NNS_SCALE(	lstartptr, 
							lstartind, 
							lendind,
							intrastep, 
							DBL_FIX_A
						);
#else

	__asm	mov	esi,	lstartptr
	__asm	mov	eax,	lstartind
	__asm	mov ebx,	lendind
	__asm	sub ebx,	eax
	__asm	mov			ecx, intrastep
	__asm	shl			ecx, 2

scale_lp0:	;
	__asm	test	ebx, ebx
	__asm	je		skip_scale0

	__asm	mov		eax, [esi]
	__asm	test	eax, eax
	__asm	je		skip_mul0
	__asm	mov		edx, DBL_FIX_A
	__asm	imul	edx
	__asm	shrd	eax, edx, JPC_FIX_FRACBITS
	__asm	mov		[esi], eax
skip_mul0:	;
	__asm	add		esi, ecx
	__asm	sub		ebx, 1
	__asm	jmp		scale_lp0
skip_scale0:	;

#endif

#if !defined(USE_LF_ASM)
				NNS_SCALE(	hstartptr, 
							hstartind, 
							hendind,
							intrastep, 
							DBL_FIX_B
						);
#else

	__asm	mov	esi,	hstartptr
	__asm	mov	eax,	hstartind
	__asm	mov ebx,	hendind
	__asm	sub ebx,	eax

scale_lp1:	;
	__asm	test	ebx, ebx
	__asm	je		skip_scale1

	__asm	mov		eax, [esi]
	__asm	test	eax, eax
	__asm	je		skip_mul1
	__asm	mov		edx, DBL_FIX_B
	__asm	imul	edx
	__asm	shrd	eax, edx, JPC_FIX_FRACBITS
	__asm	mov		[esi], eax
skip_mul1:	;
	__asm	add		esi, ecx
	__asm	sub		ebx, 1
	__asm	jmp		scale_lp1
skip_scale1:	;

#endif

#if !defined(USE_LF_ASM)
				RA_NNS_LIFT1(	lstartptr, 
								lstartind, 
								lendind,
								hstartptr, 
								hstartind, 
								hendind, 
								intrastep,
								DBL_FIX_C,
								twoalpha_C
							);
#else

	__asm	mov	esi,	lstartptr
	__asm	mov	edi,	hstartptr
	__asm	mov	eax,	lstartind
	__asm	mov ebx,	lendind
	__asm	sub ebx,	eax

	__asm	mov	eax,	hstartind
	__asm	cmp	eax,	lstartind
	__asm	jl			no_1C
	
	__asm	mov			eax, [edi]
	__asm	test		eax, eax
	__asm	je			skip_slow1C
	__asm	mov			edx, twoalpha_C
	__asm	imul		edx
	__asm	shrd		eax, edx, JPC_FIX_FRACBITS
	__asm	add			dword ptr[esi], eax
skip_slow1C:

	__asm	add			esi, ecx
	__asm	sub			ebx, 1
no_1C:
	__asm	mov	eax,	lendind
	__asm	cmp	eax,	hendind
	__asm	jle			lpC
	__asm	sub			ebx, 1

lpC:
	__asm	test	ebx, ebx
	__asm	jle		done_lpC
lpaC:
	__asm	mov		eax, dword ptr[edi]
	__asm	sub		ebx, 1
	__asm	add		eax, dword ptr[edi + ecx ]
	__asm	test	eax, eax
	__asm	je		skip_slowC

	__asm	mov		edx, DBL_FIX_C
	__asm	imul	edx
	__asm	shrd	eax, edx, JPC_FIX_FRACBITS
	__asm	add		dword ptr[esi], eax

skip_slowC:
	__asm	add		esi, ecx
	__asm	add		edi, ecx
	__asm	test	ebx, ebx
	__asm	jg		lpaC
done_lpC:					;

	__asm	mov	eax,	lendind
	__asm	cmp	eax,	hendind
	__asm	jle			no_3C
	__asm	mov			eax, dword ptr[edi]
	__asm	test		eax, eax
	__asm	je			no_3C
	__asm	mov			edx, dword ptr[twoalpha_C]
	__asm	imul		edx
	__asm	shrd		eax, edx, JPC_FIX_FRACBITS
	__asm	add			dword ptr[esi],eax
no_3C:		;

#endif


#if !defined(USE_LF_ASM)
				NNS_LIFT0(	lstartptr, 
							lstartind, 
							lendind,
							hstartptr, 
							hstartind, 
							hendind, 
							intrastep,
							DBL_FIX_D
						);
#else

	__asm	mov	esi,	lstartptr
	__asm	mov	edi,	hstartptr
	__asm	mov	eax,	hstartind
	__asm	mov ebx,	hendind
	__asm	sub ebx,	eax

	__asm	mov	eax,	hstartind
	__asm	cmp	eax,	lstartind
	__asm	jge			no_lift0a
	
	__asm	mov			eax, [edi]
	__asm	test		eax, eax
	__asm	je			skip_slow_lift0
	__asm	mov			edx, twoalpha_D
	__asm	imul		edx
	__asm	shrd		eax, edx, JPC_FIX_FRACBITS
	__asm	add			dword ptr[esi], eax
skip_slow_lift0:

	__asm	add			esi, ecx
	__asm	sub			ebx, 1
no_lift0a:

	__asm	mov	eax,	hendind
	__asm	cmp	eax,	lendind
	__asm	jl			lpa_lift0
	__asm	dec			ebx

lpa_lift0:	;
	__asm	test	ebx, ebx
	__asm	jle		done_lpa_lift0
lpb_lift0:
	__asm	mov		eax, dword ptr[esi]
	__asm	sub		ebx, 1
	__asm	add		eax, dword ptr[esi + ecx ]
	__asm	test	eax, eax
	__asm	je		skip_slowa_lift0

	__asm	mov		edx, DBL_FIX_D
	__asm	imul	edx
	__asm	shrd	eax, edx, JPC_FIX_FRACBITS
	__asm	add		dword ptr[edi], eax

skip_slowa_lift0:
	__asm	add		esi, ecx
	__asm	add		edi, ecx
	__asm	test	ebx, ebx
	__asm	jg		lpb_lift0
done_lpa_lift0:	;

	__asm	mov	eax,	hendind
	__asm	cmp	eax,	lendind
	__asm	jl			no_3b_lift0
	__asm	mov			eax, dword ptr[esi]
	__asm	test		eax, eax
	__asm	je			no_3b_lift0
	__asm	mov			edx, twoalpha_D
	__asm	imul		edx
	__asm	shrd		eax, edx, JPC_FIX_FRACBITS
	__asm	add			dword ptr[edi],eax
no_3b_lift0:		;


#endif

#if !defined(USE_LF_ASM)
				NNS_LIFT1(	lstartptr, 
							lstartind, 
							lendind,
							hstartptr, 
							hstartind, 
							hendind, 
							intrastep,
							DBL_FIX_E
						);
#else

	__asm	mov	esi,	lstartptr
	__asm	mov	edi,	hstartptr
	__asm	mov	eax,	lstartind
	__asm	mov ebx,	lendind
	__asm	sub ebx,	eax

	__asm	mov	eax,	hstartind
	__asm	cmp	eax,	lstartind
	__asm	jl			no_1a
	
	__asm	mov			eax, [edi]
	__asm	test		eax, eax
	__asm	je			skip_slow1
	__asm	mov			edx, twoalpha_E
	__asm	imul		edx
	__asm	shrd		eax, edx, JPC_FIX_FRACBITS
	__asm	add			dword ptr[esi], eax
skip_slow1:

	__asm	add			esi, ecx
	__asm	sub			ebx, 1
no_1a:
	__asm	mov	eax,	lendind
	__asm	cmp	eax,	hendind
	__asm	jle			lpa
	__asm	sub			ebx, 1

lpa:
	__asm	test	ebx, ebx
	__asm	jle		done_lpa
lpaa:
	__asm	mov		eax, dword ptr[edi]
	__asm	sub		ebx, 1
	__asm	add		eax, dword ptr[edi + ecx ]
	__asm	test	eax, eax
	__asm	je		skip_slow

	__asm	mov		edx, DBL_FIX_E
	__asm	imul	edx
	__asm	shrd	eax, edx, JPC_FIX_FRACBITS
	__asm	add		dword ptr[esi], eax

skip_slow:
	__asm	add		esi, ecx
	__asm	add		edi, ecx
	__asm	test	ebx, ebx
	__asm	jg		lpaa
done_lpa:							;

	__asm	mov	eax,	lendind
	__asm	cmp	eax,	hendind
	__asm	jle			no_3a
	__asm	mov			eax, dword ptr[edi]
	__asm	test		eax, eax
	__asm	je			no_3a
	__asm	mov			edx, dword ptr[twoalpha_E]
	__asm	imul		edx
	__asm	shrd		eax, edx, JPC_FIX_FRACBITS
	__asm	add			dword ptr[esi],eax
no_3a:		;
#endif



#if !defined(USE_LF_ASM)
				NNS_LIFT0(	lstartptr, 
							lstartind, 
	  						lendind,
							hstartptr, 
							hstartind, 
							hendind, 
							intrastep,
							DBL_FIX_F
						);
#else

	__asm	mov	esi,	lstartptr
	__asm	mov	edi,	hstartptr
	__asm	mov	eax,	hstartind
	__asm	mov ebx,	hendind
	__asm	sub ebx,	eax

	__asm	mov	eax,	hstartind
	__asm	cmp	eax,	lstartind
	__asm	jge			no_1d
	
	__asm	mov			eax, [edi]
	__asm	test		eax, eax
	__asm	je			skip_slow4
	__asm	mov			edx, twoalpha_F
	__asm	imul		edx
	__asm	shrd		eax, edx, JPC_FIX_FRACBITS
	__asm	add			dword ptr[esi], eax
skip_slow4:

	__asm	add			esi, ecx
	__asm	sub			ebx, 1
no_1d:

	__asm	mov	eax,	hendind
	__asm	cmp	eax,	lendind
	__asm	jl			lpd
	__asm	dec			ebx

lpd:	;
	__asm	test	ebx, ebx
	__asm	jle		done_lpd
lpad:
	__asm	mov		eax, dword ptr[esi]
	__asm	sub		ebx, 1
	__asm	add		eax, dword ptr[esi + ecx ]
	__asm	test	eax, eax
	__asm	je		skip_slowd

	__asm	mov		edx, DBL_FIX_F
	__asm	imul	edx
	__asm	shrd	eax, edx, JPC_FIX_FRACBITS
	__asm	add		dword ptr[edi], eax

skip_slowd:
	__asm	add		esi, ecx
	__asm	add		edi, ecx
	__asm	test	ebx, ebx
	__asm	jg		lpad
done_lpd:	;

	__asm	mov	eax,	hendind
	__asm	cmp	eax,	lendind
	__asm	jl			no_3d
	__asm	mov			eax, dword ptr[esi]
	__asm	test		eax, eax
	__asm	je			no_3d
	__asm	mov			edx, twoalpha_F
	__asm	imul		edx
	__asm	shrd		eax, edx, JPC_FIX_FRACBITS
	__asm	add			dword ptr[edi],eax
no_3d:		;
#endif


				jpc_qmfb1d_join(	startptr, 
									startind, 
									endind,
									intrastep, 
									lstartptr, 
									lstartind, 
									lendind,
									hstartptr, 
									hstartind, 
									hendind
								);
			} else 
			{
#if !defined(USE_LF_ASM)
				if (lstartind == lendind) {
					*startptr = jpc_fix_asr(*startptr, 1);
				}
#endif
			}
			startptr += interstep;
		}
	} else {
		/* The reversible integer-to-integer mode is not supported
		  for this transform. */
		jas_error(	JAS_ERR_UNSUPPORTED_MODE_JPC_NS_SYNTHESIZE,
					"JAS_ERR_UNSUPPORTED_MODE_JPC_NS_SYNTHESIZE"
				);
	}
}

#endif


/******************************************************************************\
*
\******************************************************************************/

jpc_qmfb1d_t *jpc_qmfb1d_make(int qmfbid)
{
	jpc_qmfb1d_t *qmfb;
	if (!(qmfb = jpc_qmfb1d_create())) {
		return 0;
	}
	switch (qmfbid) {
	case JPC_QMFB1D_FT:
		qmfb->ops = &jpc_ft_ops;
		break;
	case JPC_QMFB1D_NS:
		qmfb->ops = &jpc_ns_ops;
		break;
	default:
		jpc_qmfb1d_destroy(qmfb);
		return 0;
		break;
	}
	return qmfb;
}

static jpc_qmfb1d_t *jpc_qmfb1d_create()
{
	jpc_qmfb1d_t *qmfb;
	if (!(qmfb = jas_malloc(sizeof(jpc_qmfb1d_t)))) {
		return 0;
	}
	qmfb->ops = 0;
	return qmfb;
}

jpc_qmfb1d_t *jpc_qmfb1d_copy(jpc_qmfb1d_t *qmfb)
{
	jpc_qmfb1d_t *newqmfb;

	if (!(newqmfb = jpc_qmfb1d_create())) {
		return 0;
	}
	newqmfb->ops = qmfb->ops;
	return newqmfb;
}

void jpc_qmfb1d_destroy(jpc_qmfb1d_t *qmfb)
{
	jas_free(qmfb);
}

/******************************************************************************\
*
\******************************************************************************/

void jpc_qmfb1d_getbands(jpc_qmfb1d_t *qmfb, int flags, uint_fast32_t xstart,
  uint_fast32_t ystart, uint_fast32_t xend, uint_fast32_t yend, int maxbands,
  int *numbandsptr, jpc_qmfb1dband_t *bands)
{
	int start;
	int end;

	assert(maxbands >= 2);

	if (flags & JPC_QMFB1D_VERT) {
		start = ystart;
		end = yend;
	} else {
		start = xstart;
		end = xend;
	}
/*	assert(jpc_qmfb1d_getnumchans(qmfb) == 2);	*/
	assert(start <= end);
	bands[0].start = JPC_CEILDIVPOW2(start, 1);
	bands[0].end = JPC_CEILDIVPOW2(end, 1);
	bands[0].locstart = start;
	bands[0].locend = start + bands[0].end - bands[0].start;
	bands[1].start = JPC_FLOORDIVPOW2(start, 1);
	bands[1].end = JPC_FLOORDIVPOW2(end, 1);
	bands[1].locstart = bands[0].locend;
	bands[1].locend = bands[1].locstart + bands[1].end - bands[1].start;
	assert(bands[1].locend == end);
	*numbandsptr = 2;
}

/******************************************************************************\
*
\******************************************************************************/

int jpc_qmfb1d_getnumchans(jpc_qmfb1d_t *qmfb)
{
	return (*qmfb->ops->getnumchans)(qmfb);
}

int jpc_qmfb1d_getanalfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters)
{
	return (*qmfb->ops->getanalfilters)(qmfb, len, filters);
}

int jpc_qmfb1d_getsynfilters(jpc_qmfb1d_t *qmfb, int len, jas_seq2d_t **filters)
{
	return (*qmfb->ops->getsynfilters)(qmfb, len, filters);
}

void jpc_qmfb1d_analyze(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x)
{
	(*qmfb->ops->analyze)(qmfb, flags, x);
}

void jpc_qmfb1d_synthesize(jpc_qmfb1d_t *qmfb, int flags, jas_seq2d_t *x)
{
	(*qmfb->ops->synthesize)(qmfb, flags, x);
}

⌨️ 快捷键说明

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