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

📄 ster_filt_dec.s

📁 关于DVD的MPEG2用的DSP代码,在DSP的实现MPEG的压缩,解压算法.
💻 S
字号:
;********************************************************************
;
; (c)1997 Copyright LuxSonor, Inc. All rights reserved
;
; Revision 1.0
;
;	
;	Module:	AUDIO code
;
;	Initial version:Cecile Foret, April 1997
;			Jinshi Huang 12/1/98 for LS388/LS500 
;	This subroutine performs the filtering-decimation of the input 
;	sequence. Adress a1 of input sequence is set up in main routine.
;
;	The coefficients of the filter are supposed to be preloaded
;	in the main routine. Idem, Dec is supposed to be preloaded in
;	local memory.
;	AGRSiz3 is supposed to be set up in the calling routine
;
;	calls:	r0=DRAM adress of history
;			r1=DRAM adress of pointer on history
;			r2=pointer on input data
;
;	Make sure the following instructions are done in calling routine 
;			movi	r0, history
;			movi	r1, hist_point
;			movi	r2, localA_data
;
;	return adress to main routine: r11
;	returns: none, the decimated sequence will be written in local memory
;	
;*********************************************************************
	.nolist
#include "regdef2.h"
#include "stereo_user.h"
#include "memory2.h"
	.list
	
	.data
	.global SUB_filtering



SUB_filtering:
;******* load the history of the filter in local memory *************
;		movi	StartAddrHigh, 0x7
		movi	StartAddrHigh, DataSeg	// 10-13-98

#ifdef	EFFECT
		movi	DMASize, 11
		movi	r20, localB_history
		shr	r20, 2
		mov	LocalAddr,r20
		shr	r0, 2
						; sets the location in local memory
		dmarr	r0			; r0= DRAM adress of history
		WaitDma
#else	//EFFECT
		movi	ByteSize, 44	; (23-1)*2	
		movi	ByteLocal,localB_history
						; sets the location in local memory
		dmabrr	r0			; r0= DRAM adress of history
#endif	//EFFECT
;******* reset the pointer on the set of filters ********************
		movi	AGRAdr0, coeff_inc
		movi	AGRSiz0, 0x077e	; circular buffer of size (720-1)*2

;******* reset the pointer on the input sequence ********************
		mov		AGRAdr1,r2		; adress of input sequence in loc memory
		movi	AGRSiz1,0x3fe	; buffer of 256*2 samples
		movi	AGRInc1, 0x4	; increments of two sample 

;******* read the address of pointer in history from DRAM ***********
;		movi	DirectBase, 0x7
		movi	DcacheBase, DataSeg	// 10-13-98
		dlhr	r2,r1			; load val of ptr on hist. r1= @ of Ptr in DRAM
		
;;		movi	ByteLocal, local_hist_point
;;		movi	ByteSize, 0x2
;;		dmabrr	r1
;;		movh	r2, %local_hist_point

#ifdef	EFFECT
		movi	AGRSiz4, 0x002c	; circular buffer of size 23 (23-1)*2
		movi	AGRMod4, 0
		movi	AGRInc4, 2		; increments of one sample (2 bytes)
		mov	AGRAdr4, r2		; r2=value of pointer on history
#else	//EFFECT
		movi	AGRSiz2, 0x002c	; circular buffer of size 23 (23-1)*2
		movi	AGRInc2, 2		; increments of one sample (2 bytes)	
		mov	AGRAdr2, r2		; r2=value of pointer on history
#endif	//EFFECT


;******* reset the pointer on the decimated sequence ****************
		movh	r4, %localsearch_ptr
#ifdef	EFFECT
		mov	AGRAdr5, r4		; a5 points at (Nb-1)*length	
		movi	AGRInc5, 0x2
#else	//EFFECT
		mov	AGRAdr3, r4		; a3 points at (Nb-1)*length	
		movi	AGRInc3, 0x2
#endif	//EFFECT
	
;******* filtering of the current sequence ***************************
		movh	r2, %key_value
		tstsi	r2,16
		bgte	key_pos

;******* case key< 0, dec<ratio **************************************
		movi	r2, Ratio
		subh	r2, %Dec		; first decrement value: Ratio-Dec
		movh	r4, %Dec
		addi	r4, 46			; r4= dec+(24-1)*2
		mov		AGRInc0, r4		; set increment = dec+(24-1)*2
		movi	r3, 0			; phase =0


;**************************************
;***** desable interrupt mask *********
		movi	TrapReg, 0x0
		nop
		nop
;**************************************
;**************************************


		loop	256, filter_seq
;****** first filtering **********************************************
;****** choice of the filter set *************************************

#ifdef	EFFECT
		mulhf	r6, i4, a0(-2)	; first mult of the filtering
		loop	22, filter1
		maddhf	r6, i4, a0(-2)	; use the history
filter1:
		movhf	r5, a1(0)
		maddhf	r6, r5,i0		; use the new sample, increments the filter
		nop
		rndhf	i5, r6			; rounds and put back in memory
#else	//EFFECT
		mulhf	r6, i2, a0(-2)	; first mult of the filtering
		loop	22, filter1
		maddhf	r6, i2, a0(-2)	; use the history
filter1:
		movhf	r5, a1(0)
		maddhf	r6, r5,i0		; use the new sample, increments the filter
		rndhf	i3, r6			; rounds and put back in memory
#endif	//EFFECT
		
		sub		r3,r2			; phase += (dec-ratio)
		tstsi	r3, 0x0
		bgte	update			; test if 2 filtering necessary

;***** second filtering **********************************************
		addh	r3, %Dec
#ifdef	EFFECT
		mulhf	r6, i4, a0(-2)	; first mult of the filtering
		loop	22, filter2
		maddhf	r6, i4, a0(-2)	; use the history
filter2:
#else	//EFFECT
		mulhf	r6, i2, a0(-2)	; first mult of the filtering
		loop	22, filter2
		maddhf	r6, i2, a0(-2)	; use the history
filter2:
#endif	//EFFECT
		movhf	r5, a1(0)
		maddhf	r6, r5,i0		; use the new sample
#ifdef	EFFECT
		nop
		rndhf	i5, r6			; rounds and put back in memory
#else	//EFFECT
		rndhf	i3, r6			; rounds and put back in memory
#endif	//EFFECT
		

;****** update the history of the fir ********************************
update:
#ifdef	EFFECT
		movhf	i4, a1(4)		; update the history 
#else	//EFFECT
		movhf	i2, a1(4)		; update the history
#endif	//EFFECT
filter_seq:

;**************************************
;***** enable interrupt mask **********
		movi	TrapReg, 0x24
;**************************************
;**************************************

		j		suite



;******* case key >=0, dec >ratio ************************************
key_pos:

		movh	r4, %Dec
		subi	r4,Ratio		; test case Dec=2*Ratio
		subi	r4,Ratio
#ifdef	EFFECT
		beq		increment
#else	//EFFECT
		bz		increment
#endif	//EFFECT
		addi	r4, Ratio+46	; set increment = dec-ratio+(24-1)*2
		mov		AGRInc0, r4
		j		filtstart
increment:
		movi	AGRInc0,46		; set increment = (24-1)*2 

filtstart:
		movi	r3, 0
		subi	r3, Ratio		; phase =-ratio

;**************************************
;***** desable interrupt mask *********
		movi    TrapReg, 0x0
		nop
		nop
;**************************************
;**************************************


		loop	256, filter_seq2
		tstsi	r3, 0x0
		bgte	update2
;****** filtering ****************************************************
#ifdef	EFFECT
		mulhf	r6, i4, a0(-2)	; first mult of the filtering
		loop	22, filter3
		maddhf	r6, i4, a0(-2)	; use the history
filter3:
		movhf	r5, a1(0)
		maddhf	r6, r5,i0		; use the new sample
		addh	r3, %Dec
		rndhf	i5,r6			; rounds and put back in memory
#else	//EFFECT
		mulhf	r6, i2, a0(-2)	; first mult of the filtering
		loop	22, filter3
		maddhf	r6, i2, a0(-2)	; use the history
filter3:
		movhf	r5, a1(0)
		maddhf	r6, r5,i0		; use the new sample
		addh	r3, %Dec
		rndhf	i3, r6			; rounds and put back in memory
#endif	//EFFECT
		
update2:
#ifdef	EFFECT
		movhf	i4, a1(4)		; update the history
#else	//EFFECT
		movhf	i2, a1(4)		; update the history
#endif	//EFFECT
		subi	r3, Ratio		; phase -= Ratio.
filter_seq2:

;**************************************
;***** enable interrupt mask **********
	    movi	TrapReg, 0x24

;**************************************
;**************************************


suite:
;****** suite du filtrage ********************************************
;****** save the pointer on history to filter next block *************
;		movi	StartAddrHigh, 0x7
		movi	StartAddrHigh, DataSeg	// 10-13-98
#ifdef	EFFECT
		mov	r2, AGRAdr4
#else	//EFFECT
		mov	r2, AGRAdr2
#endif	//EFFECT
		dshr	r2, r1			; save ptr on hist, r1=hist_point
;;		movh	%local_hist_point, r2
;;		movi	ByteLocal, local_hist_point
;;		movi	ByteSize, 0x2
;;		dmabwr	r1				; r1 = hist_point

;******* save the history of the filter in main memory * *************

#ifdef	EFFECT
		movi	DMASize, 11	; (23-1)*2=size of the history
		mov	LocalAddr,r20
		dmawr	r0				; r0=history
		WaitDma
#else	//EFFECT
		movi	ByteSize, 44	; (23-1)*2=size of the history
		movi	ByteLocal,localB_history	
		dmabwr	r0				; r0=history
#endif	//EFFECT

		j		r11			; go back to main routine






⌨️ 快捷键说明

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