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

📄 mpa_drc.s

📁 samsung 9908DVD源代码,
💻 S
字号:
/*
 *  mpa_drc.s
 *
 *  MPEG/audio multichannel decoder.
 *	Copyright (C) 2003 Optical Player P/J, Samsung Electronics.
 *
 *	Description: Dynamic range control for MPEG audio in DVD.
 *	  The transmission of "dynamic_range_control" in MPEG audio is optional.
 *  When the DRC flag in the corresponding VMGM_AST_ATR, VTSM_AST_ATR or
 *  VTS_AST_ATR is set to '01b', 16-bit of ancillary data shall be used.
 *  In case of MPEG-1 streams or MPEG-2 streams without extension stream
 *  (MPEG audio format 1), ancillary data are placed at the end of each
 *  frame as defined in ISO/IEC 11172-3.
 *  In case of MPEG-2 streams with extension stream (MPEG audio format 2),
 *  ancillary data at the end of Main audio frame are used as defined in
 *  ISO/IEC DIS 13818-3: July, 1996.
 *
 *  The 8-bit "dynamic_range_control" word [b15 b14 b13 b12 b11 b10, b9, b8]
 *  leads to the following gain control value by considering the binary value
 *  of the upper 3 bits [b15 b14 b13] as unsigned integer X, and the binary
 *  value of the lower 5 bits [b12 b11 b10, b9, b8] as unsigned integer Y:
 *
 *                      4-(X+Y/30)
 *	      linear:  G = 2
 *                 (0 <= X <= 7, 0 <= Y <= 29)
 *
 *        in dB:   G = 24.082 - 6.0206X - 0.2007Y
 *                 (0 <= X <= 7, 0 <= Y <= 29)
 *
 *	When dynamic range control is temporally not applied, the value of
 *  "dynamic_range_control" is set to '1000 0000b' or
 *  "dynamic_range_control_on" is set to '0b'.
 *
 *  The dynamic range control value G is a recommended gain value to be
 *  applied to all audio samples decoded from the respective MPEG audio
 *  frame.
 */

.include	"mpa.h"

.if( _DECODER_TYPE != MPEG_1_AUDIO )

.secFILE_mpa_drc


/********************************************************************

 Function:		dynamic_range_control

 Description:

 Arguments:
				rp0:	
				rp1:	
				rp2:	
				rp3:	

				index registers:
				@bank0
						d1		d0		s1		s0
				---------------------------------------
				sd0: 	 x		 x		 x		 1
				sd1: 	 x		 1		 x		 x
				sd2: 	 x		 1		 x		 0
				sd3: 	 x		 x		 x		 0

********************************************************************/
dynamic_range_control::
				es			psh1
				es			usm
				es			opm
								
				er			xsd
				esd0		s0, #1
				esd1		d0, #1
				esd2		s0, #1
				esd3		s0, #0

check_drc_enable
;				ld			a11, #BS_MAIN
				ld			a11, #_buffer_ptr
				ldw			a11, @[a11+_BS_MAIN]

				eld			a, rpd1.frame_size
				esub		a, #2
				ecld		r0, a
				ldb			r1, @[a11+r0]
				add			r0, #1
				ldb			r2, @[a11+r0]
				slb			r1
				or			r1, r2
				ld			r2, r1
				and			r2, #0xFF
				cmp			eq, r2, #0x80
				brf			error__DRC_disable
				
; Get dynamic range control (DRC) gain
				srb			r1
				ecld		sr, r1
				eld			sa, #-5
				esft		sr, sa
				ecld		r0, sr
				and			r0, #0x07
				and			r1, #0x1F
				ecld		a, r0
				ecld		b, r1
				efz8		a
				efz8		b

				cmpu		gt, r0, #7
				brt			error__DRC_index
				cmpu		gt, r1, #29
				brt			error__DRC_index
				
/*	monitor DRC gain index */
.if( _DEBUG_DRC == TRUE )
				eld			c, rpd1.frameNo
				ecld		r2, c
				sl			r2
				ld			r3, r0
				slb			r3
				or			r3, r1
				ld			a11, #0x10000
				ldw			@[a11+r2], r3
.endif

				eld			rp3, #DRC_table
				erpn		rp3, a
				eld			a, @rp3
				eld			rp3, a
				erpn		rp3, b
				eld			c, @rp3+s0
				eld			d, rpd1.drc_gain	; previous gain value

.if( _DRC_SCALEDOWN == TRUE )
				ecp			c, d
				ebra		ec0, mul_drc_gain
				eld			ma0, #0
				eld			a, c
				eld			b, d
				eadd		b, ma0
				eslc		b
				ecp			b, a
				ebra		ec2, down_scale
				eadd		c, ma0
				eslc		c
				ecp			c, d
				ebra		ec2, up_scale
				
				brad		mul_drc_gain
				eld			c, rpd1.drc_gain

down_scale
				esub		a, d
				eadd		a, ma0
				esrc		a
				esub		c, a
				bra			mul_drc_gain

up_scale		esub		d, a
				esrc		d
				eadd		a, d
				eld			c, a
				bra			mul_drc_gain
.endif


; Dynamic Range Control process
; Multiply gain to all samples of each channel
mul_drc_gain
				eld			rpd1.drc_gain, c
				eld			y1, c
				ld			r6, #SAMPLES_PER_FRAME-1
				eld			rp0, #pcm_ch_buffer
				eld			rp1, rp0
				eld			           x0, @rp0+s0
				emul		     x0y1, x0, @rp0+s0
%1				emld		ma0, x0y1, x0, @rp0+s0
				emld		ma1, x0y1, x0, @rp0+s0
				esla		ma0
				esla		ma0
				esla		ma0
				esla		ma1
				esla		ma1
				esla		ma1
				eld			@rp1+d0, ma0
				eld			@rp1+d0, ma1
				emld		ma0, x0y1, x0, @rp0+s0
				emld		ma1, x0y1, x0, @rp0+s0
				esla		ma0
				esla		ma0
				esla		ma0
				esla		ma1
				esla		ma1
				esla		ma1
				eld			@rp1+d0, ma0
				eld			@rp1+d0, ma1
				emld		ma0, x0y1, x0, @rp0+s0
				emld		ma1, x0y1, x0, @rp0+s0
				esla		ma0
				esla		ma0
				esla		ma0
				esla		ma1
				esla		ma1
				esla		ma1
				eld			@rp1+d0, ma0
				eld			@rp1+d0, ma1
				emld		ma0, x0y1, x0, @rp0+s0
				esla		ma0
				esla		ma0
				esla		ma0
				bnzd		r6, %b1
				eld			@rp1+d0, ma0

; downmix channel 
.if( 0 )
				ld			r6, #SAMPLES_PER_FRAME-1
				eld			rp0, #pcm_dm_buffer
				eld			rp1, rp0
				eld			           x0, @rp0+s0
				emul		     x0y1, x0, @rp0+s0
%2				emld		ma0, x0y1, x0, @rp0+s0
				emld		ma1, x0y1, x0, @rp0+s0
				esla		ma0
				esla		ma0
				esla		ma0
				esla		ma1
				esla		ma1
				esla		ma1
				eld			@rp1+d0, ma0
				bnzd		r6, %b2
				eld			@rp1+d0, ma1
.endif
				
; LFE channel 
				eld			a, rpd0.lfe
				ecp			a, #TRUE
				ebra		ec1, end__DRC_process
				
				eld			rp2, #pcm_lfe_buffer
				eld			rp1, rp2
				ld			r6, #SAMPLES_PER_FRAME-1
				eld			           x0, @rp2+s0
				emul		     x0y1, x0, @rp2+s0
%3				emld		ma0, x0y1, x0, @rp2+s0
				esla		ma0
				esla		ma0
				esla		ma0
				bnzd		r6, %b3
				eld			@rp1+d0, ma0

end__DRC_process
				mRETURN(_DECODE_OK)
				er			usm
				er			psh1
				er			opm
				ret

error__DRC_disable
.ifdef _DEBUG_
/** debug **/	bra			$
.endif
				mRETURN(_NO_DRC_INFO_IN_STREAM)
				er			usm
				er			psh1
				er			opm
				ret

error__DRC_index
.ifdef _DEBUG_
/** debug **/	bra			$
.endif
				mRETURN(_INVALID_DRC_GAIN)
				er			usm
				er			psh1
				er			opm
				ret

.endif /* .if( _DECODER_TYPE != MPEG_1_AUDIO ) */

.end

⌨️ 快捷键说明

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