c2sa.sa
上传用户:csczyc
上传日期:2021-02-19
资源大小:1051k
文件大小:4k
源码类别:

语音压缩

开发平台:

C/C++

  1.           .def _envelope
  2. _envelope:.cproc    input,prev_in,output,npts
  3.           .reg      i,curr_abs,prev_abs,sign,CONST
  4.           .reg      x,input1,output1,output2
  5.           .reg      C1_Q14,C2_Q14
  6.           MVK       -15415,C2_Q14
  7.           MVK       31565,C1_Q14
  8.           ABS       prev_in,prev_abs
  9.           ZERO      i
  10. LOOP1:    LDH       *input++,input1
  11.           LDH       *--output,output1
  12.           LDH       *--output,output2
  13.           ADD       output,4,output
  14.           ABS       input1,curr_abs
  15.           SUB       curr_abs,prev_abs,x
  16.           SSHL      x,16,x
  17.           SHR       x,5,x
  18.           SMPY      output1,C1_Q14,output1
  19.           SMPY      output2,C2_Q14,output2
  20.           SADD      x,output1,x
  21.           SADD      x,output2,x
  22.           SSHL      x,1,x
  23.           MVK       -32768,CONST
  24.           MVKH      0x00008000,CONST
  25.           SADD      x,CONST,x
  26.           SHR       x,16,x
  27.           STH       x,*output++
  28.           MV        curr_abs,prev_abs
  29.           ADD       i,1,i
  30.           CMPLT     i,npts,sign
  31.     [sign]B         LOOP1
  32.           
  33.           .return
  34.           .endproc
  35. ;/*                                                              */
  36. ;/*      Subroutine iir_2nd_s: Second order IIR filter           */
  37. ;/*                            (Single precision)                */
  38. ;/*      Note: the output array can overlay the input.           */
  39. ;/*                                                              */
  40. ;/* Input scaled down by a factor of 2 to prevent overflow */
  41.             .def _iir_2nd_s
  42. _iir_2nd_s: .cproc        input,den,num,output,delin,delout,npts
  43.             .reg          i,temp,x,inputi,outputi,CONST,sign
  44.             .reg          delin0,delin1,num0,num1,num2,delout0,delout1,den1,den2
  45.     zero i
  46. LDH  *delin++,delin0
  47. LDH  *delin,delin1
  48. LDH  *delout++,delout0
  49. LDH  *delout,delout1
  50.            LDH  *num++,num0
  51. LDH  *num++,num1
  52. LDH  *num,num2
  53. LDH  *++den,den1           ;load den[1]
  54. LDH  *++den,den2           ;load den[2]
  55. LOOP2: LDH  *input++,inputi
  56. SMPY inputi,num0,temp      ;temp=input[i]*num[0]        
  57. SMPY delin0,num1,outputi   ;delin[0]*num[1]
  58. SADD temp,outputi,x       
  59. SMPY delin1,num2,outputi   ;delin[1]*num[2]
  60. SADD x,outputi,x
  61. SMPY delout0,den1,outputi  ;delout[0]*den[1]
  62. SADD x,outputi,x
  63. ; SUB  den,4,den
  64. SMPY delout1,den2,outputi  ;delout[1]*den[2]
  65. SADD x,outputi,x
  66.             SSHL x,2,x
  67. MV   delin0,delin1         ;updata delin
  68. MV   inputi,delin0
  69.       MVK  -32768,CONST          ;round(x)
  70. MVKH 0x00008000,CONST
  71. SADD x,CONST,x
  72. SHR  x,16,x
  73. STH  x,*output++
  74. MV   delout0,delout1       ;updata delout
  75. MV   x,delout0
  76. ADD  i,1,i
  77. CMPLT i,npts,sign
  78.       [sign]B   LOOP2
  79.         
  80. STH  delout1,*delout--
  81. STH  delout0,*delout
  82. STH  delin1,*delin--
  83. STH  delin0,*delin
  84. .return
  85. .endproc
  86. ;/***************************************************************************
  87. ; *
  88. ; *   FUNCTION NAME: L_v_magsq
  89. ; *
  90. ; *   PURPOSE:
  91. ; *
  92. ; *     Compute the sum of square magnitude of a 16 bit input vector
  93. ; *     with saturation and truncation.  Output is a 32 bit number.
  94. ; *
  95. ; *   INPUTS:
  96. ; *
  97. ; *     vec1            16 bit short signed integer (Shortword) whose value
  98. ; *                     falls in the range 0xffff 8000 <= vec1 <= 0x0000 7fff.
  99. ; *
  100. ; *     n               size of input vectors
  101. ; *
  102. ; *     qvec1           Q value of vec1
  103. ; *
  104. ; *     qout            Q value of output
  105. ; *   OUTPUTS:
  106. ; *
  107. ; *     none
  108. ; *
  109. ; *   RETURN VALUE:
  110. ; *
  111. ; *     L_magsq         32 bit long signed integer (Longword) whose value
  112. ; *                     falls in the range
  113. ; *                     0x8000 0000 <= L_magsq <= 0x7fff ffff.
  114. ; *
  115. ; *   IMPLEMENTATION:
  116. ; *
  117. ; *     Compute the sum of square magnitude of a 16 bit input vector.
  118. ; *     The output is a 32 bit number.
  119. ; *
  120. ; *   KEYWORDS: square magnitude
  121. ; *
  122. ; *************************************************************************/
  123.  
  124.