📄 amf_decibelstolinear_s_render.asm
字号:
// Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved.
// This software is proprietary and confidential to Analog Devices, Inc. and its licensors.
// File : $Id: //depot/development/visualaudio/modules/2.5.0/SHARC/Source/AMF_DecibelsToLinear_S_Render.asm#3 $
// Part of : VisualAudio V2.5.0
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $
// Module Name : AMF_DecibelsToLinear_S.asm
// DSP Processor : ADSP21161
// Original Author : Sami Saab, converted to VisualAudio module by Tim Stilson
// Date : 1/22/04 (conversion and loop-related optimization)
//====================================================================================
// Processor resources used:
// 39 words pmem INTERNAL
// 5 words dmem INTERNAL
// 1310 cycles, tickSize=128 (30 + 10*tickSize)
//====================================================================================
//====================================================================================
// Discussion
//
// This module is based on code by Sami Saab, and calculates 10^(x/20)
// using a 3rd-order minimax-designed polynomial to approximate 2^x
// for each octave (also designed to not have discontinuities across
// octave boundaries). This algorithm achieves a worst-case relative error
// (desired-actual)/desired of 2^(-12.8) (i.e. almost 13-bit accuracy)
//====================================================================================
#if 1
#include <processor.h>
#include "AMF_DecibelsToLinear_S.h"
#include "asm_sprt.h"
.global _AMF_DecibelsToLinear_S_Render;
.section/dm SEG_MOD_FAST_CONST;
// 10^(x/10) coefs (nearly 13 bits relative accuracy (12.8 bits))
//.var AMF_DecibelsToLinear_linear_coeff[5] = 0.33219281, 0.9999998881, 0.6958913465, 0.2248649487, 0.07924369357;
// 10^(x/20) coefs (nearly 13 bits relative accuracy (12.8 bits))
.var AMF_DecibelsToLinear_linear_coeff[5] = 0.1660964047, 0.9999998881, 0.6958913465, 0.2248649487, 0.07924369357;
.segment /pm SEG_MOD_FAST_CODE;
_AMF_DecibelsToLinear_S_Render:
//====================================================================================
entry;
//module entry arguments passed in registers:
// r4 = instance (AMF_DecibelsToLinear_S * restrict)
// r8 = * buffers (float * restrict)
// r12 = int tickSize
puts=mode1;
puts=r5;
puts=r9;
r0=i1; puts=r0;
r0=i2; puts=r0;
r5 = r12; // ticksize
m4=2; // SIMD loop increment
i4=r8; //i4->*buffers
bit set mode1 PEYEN | BDCST1 | TRUNCATE; // Enable SIMD, Broadcast loads from i1, and make sure rounding mode is towards -inf
i2=dm(1,i4); // i2=float *out
i4=dm(0,i4); // i4=float *in
i1 = AMF_DecibelsToLinear_linear_coeff;// i1 = *coeffs
r9 = 1;
f4 = dm(i4,m4); // load input
f2 = dm(0,i1); // load 1/(20*log10(2))
f4 = f2 * f4; // calculate exponent
r12 = fix f4; // truncate exponent towards -inf
f1 = float r9 by r12, f8 = dm(1,i1); // calculate integer term of power, load offset
f0 = float r12, f2 = dm(2,i1); // convert integer term of exponent to float
LCNTR=r5, DO AMF_DecibelsToLinear_S_Render_loop_end UNTIL LCE;
f4 = f4 - f0, f0 = dm(3,i1); // calculate fractional term of exponent
f12 = f2 * f4, f2 = f4; // calculate linear term of fractional power, copy fractional exponent
f4 = f2 * f4, f8 = f8 + f12; // square fractional exponent
f12 = f0 * f4, f0 = dm(4,i1); // calculate quadratic term of fractional power
f4 = f2 * f4, f8 = f8 + f12, f2 = dm(0,i1); // cube fractional exponent, load 1/(20*log10(2))
f12 = f0 * f4, f4 = dm(i4,m4); // calculate cubic term of fractional power, load next input
f4 = f2 * f4, f5 = f8 + f12; // calculate exponent for next iter, finalize polynomial
r12 = fix f4, f2 = dm(2,i1); // truncate exponent for next iter
f0 = f1 * f5, f1=float r9 by r12, f8 = dm(1,i1); // multiply integer and fractional powers, load offset for next iter
AMF_DecibelsToLinear_S_Render_loop_end:
f0 = float r12, dm(i2,m4) = f0; // convert int exponent back to fp, write output
bit clr mode1 PEYEN; // Disable SIMD
//====================================================================================
i2=gets(1);
i1=gets(2);
r9=gets(3);
r5=gets(4);
mode1=gets(5);
alter(5);
//------------------------------------------------------------------------------------
_AMF_DecibelsToLinear_S_Render.END:
leaf_exit; // C-rth requires this instead of rts
//------------------------------------------------------------------------------------
.endseg;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -