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

📄 amf_lineartodecibels_render.asm

📁 ADI SHARC DSP 音频算法标准模块库
💻 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_LinearToDecibels_Render.asm#3 $ 
// Part of : VisualAudio V2.5.0 
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $



//    Module Name     : AMF_LinearToDecibels.asm 
//    DSP Processor   : ADSP21161
//    Original Author : Sami Saab, converted to VisualAudio module by Tim Stilson
//    Date               : 1/20/04 (conversion)
//====================================================================================
// Processor resources used:
//     31 words pmem INTERNAL
//     5 words dmem INTERNAL
//   725 cycles, tickSize=128 (21 + 11*tickSize/2)
//====================================================================================

//====================================================================================
// Discussion
//
// This module is based on code by Sami Saab, and calculates 20*log10(x)
// using a 3rd-order minimax-designed polynomial to approximate the log
// for each octave (also designed to not have discontinuities across 
// octave boundaries).  This algorithm achieves a worst-case error of 0.0053
// (i.e. better than 7-bit accuracy)
//====================================================================================
 
#if 1
 
#include <processor.h>
#include "AMF_LinearToDecibels.h"
#include "asm_sprt.h"

.global    _AMF_LinearToDecibels_Render;            ;

.section/dm SEG_MOD_FAST_CONST;
// 10Log10 coefs (8.5 bits accuracy)
//.var AMF_LinearToDecibels_decibel_coeff[5] = -6.5146456, 3.0102999, 9.2253513, -3.1899662, 0.47926363;
// 20Log10 coefs (7.5 bits accuracy, i.e. 2x error of 10Log10)
.var AMF_LinearToDecibels_decibel_coeff[5] = -13.02933012, 6.0205998, 18.45079582, -6.37999972, 0.9585429025;

.segment /pm SEG_MOD_FAST_CODE;
_AMF_LinearToDecibels_Render:

//====================================================================================
    entry;   
    
//module entry arguments passed in registers: 
//  r4  = instance    (AMF_LinearToDecibels * restrict)
//  r8  = * buffers (float * restrict)
//  r12 = int tickSize

    puts=mode1;
    r0=i1; puts=r0;
    r0=i2; puts=r0;

    r2 = lshift r12 by -1;            // ticksize/2 (SIMD in time dimension)

    m4=2;                            // SIMD loop increment
    
    i4=r8;                            //i4->*buffers
    bit set mode1 PEYEN | BDCST1;    // Enable SIMD and Broadcast loads from i1

    i2=dm(1,i4);                    // i2=float *out
    i4=dm(0,i4);                    // i4=float *in
    i1 = AMF_LinearToDecibels_decibel_coeff;// i1 = *coeffs

        f4 = dm(i4,m4);                                // f4 = in
        r0  = logb f4;                                 // extract exponent
    LCNTR=r2, DO AMF_LinearToDecibels_Render_loop_end UNTIL LCE;
        r12 = -r0,                    f8 = dm(0,i1);   // negate exponent, load offset
        f4  = scalb f4 by r12,        f12= dm(1,i1);   // reduce exponent to zero, load 10*log(2)
        
        f0  = float r0,               f1 = f4;         // convert exponent to float, copy mantissa
        f12 = f12 * f0,               f0 = dm(2,i1);   // calculate linear term of exponent
        
        f12 = f0 * f4, f8 = f8 + f12, f0 = dm(3,i1);   // calculate linear term of mantissa
        f4  = f1 * f4, f8 = f8 + f12;                  // square mantissa
        f12 = f0 * f4,                f0 = dm(4,i1);   // calculate quadratic term of mantissa
        f4  = f1 * f4, f8 = f8 + f12;                  // cube mantissa
        f12 = f0 * f4,                f4 = dm(i4,m4);  // calculate cubic term of mantissa, get next input
        f0  = f8 + f12;
AMF_LinearToDecibels_Render_loop_end: 
        r0  = logb f4,                dm(i2,m4) = f0;  // extract exponent for next iter, write out
        
    bit clr mode1 PEYEN | BDCST1;    // Disable SIMD
        
//====================================================================================

    i2=gets(1);
    i1=gets(2);
    mode1=gets(3);
    alter(3);

//------------------------------------------------------------------------------------
_AMF_LinearToDecibels_Render.END:
    leaf_exit; // C-rth requires this instead of rts
//------------------------------------------------------------------------------------
.endseg;
#endif    

⌨️ 快捷键说明

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