decoder_annex.s 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. /**************************************************************************
  2. *
  3. * ITU-T SOFTWARE TOOLS' GENERAL PUBLIC LICENSE
  4. *
  5. * This "General Public License" is published in the Annex 1 of the
  6. * ITU-T Recommendation on "SOFTWARE TOOLS FOR HOMOGENITY OF RESULTS
  7. * IN THE STANDARDIZATION PROCESS OF SPEECH AND AUDIO CODERS",
  8. * approved in Geneva, 2000.
  9. *
  10. * TERMS AND CONDITIONS
  11. *
  12. * 1. This License Agreement applies to any module or other work
  13. * related to the ITU-T Software Tool Library, and developed by the
  14. * User's Group on Software Tools. The "Module", below, refers to any
  15. * such module or work, and a "work based on the Module" means either
  16. * the Module or any work containing the Module or a portion of it,
  17. * either verbatim or with modifications. Each licensee is addressed
  18. * as "you".
  19. *
  20. * 2. You may copy and distribute verbatim copies of the Module's
  21. * source code as you receive it, in any medium, provided that you:
  22. * - conspicuously and appropriately publish on each copy an appropriate
  23. * copyright notice and disclaimer of warranty;
  24. * - keep intact all the notices that refer to this General Public
  25. * License and to the absence of any warranty; and
  26. * - give any other recipients of the Module a copy of this General
  27. * Public License along with the Module.
  28. * You may charge a fee for the physical act of transferring a copy.
  29. *
  30. * 3. You may modify your copy or copies of the Module or any portion
  31. * of it, and copy and distribute such modifications under the terms
  32. * of Paragraph 1 above, provided that you also do the following:
  33. *
  34. * o cause the modified files to carry prominent notices stating
  35. * that you changed the files and the date of any change; and
  36. *
  37. * o cause the whole of any work that you distribute or publish,
  38. * that in whole or in part contains the Module or any part
  39. * thereof, either with or without modifications, to be licensed
  40. * at no charge to all third parties under the terms of this
  41. * General Public License (except that you may choose to grant
  42. * warranty protection to some or all third parties, at your
  43. * option).
  44. *
  45. * o If the modified module normally reads commands interactively
  46. * when run, you must cause it, when started running for such
  47. * interactive use in the simplest and most usual way, to print or
  48. * display an announcement including an appropriate copyright
  49. * notice and a notice that there is no warranty (or else, saying
  50. * that you provide a warranty) and that users may redistribute
  51. * the module under these conditions, and telling the user how to
  52. * view a copy of this General Public License.
  53. *
  54. * You may charge a fee for the physical act of transferring a copy,
  55. * and you may at your option offer warranty protection in exchange
  56. * for a fee.
  57. *
  58. * Mere aggregation of another independent work with the Module (or
  59. * its derivative) on a volume of a storage or distribution medium
  60. * does not bring the other work under the scope of these terms.
  61. *
  62. * 4. You may copy and distribute the Module (or a portion or
  63. * derivative of it, under Paragraph 2) in object code or executable
  64. * form under the terms of Paragraphs 1 and 2 above provided that you
  65. * also do one of the following:
  66. *
  67. * o accompany it with the complete corresponding machine-
  68. * readable source code, which must be distributed under the terms
  69. * of Paragraphs 1 and 2 above; or,
  70. *
  71. * o accompany it with a written offer, valid for at least three
  72. * years, to give any third party free (except for a nominal
  73. * charge for the cost of distribution) a complete machine-
  74. * readable copy of the corresponding source code, to be
  75. * distributed under the terms of Paragraphs 1 and 2 above; or,
  76. *
  77. * o accompany it with the information you received as to where
  78. * the corresponding source code may be obtained. (This
  79. * alternative is allowed only for noncommercial distribution and
  80. * only if you received the module in object code or executable
  81. * form alone.)
  82. *
  83. * Source code for a work means the preferred form of the work for
  84. * making modifications to it. For an executable file, complete
  85. * source code means all the source code for all modules it contains;
  86. * but, as a special exception, it need not include source code for
  87. * modules which are standard libraries that accompany the operating
  88. * system on which the executable file runs, or for standard header
  89. * files or definitions files that accompany that operating system.
  90. *
  91. * 5. You may not copy, modify, sublicense, distribute or transfer
  92. * the Module except as expressly provided under this General Public
  93. * License. Any attempt otherwise to copy, modify, sublicense,
  94. * distribute or transfer the Module is void, and will automatically
  95. * terminate your rights to use the Module under this License.
  96. * However, parties who have received copies, or rights to use copies,
  97. * from you under this General Public License will not have their
  98. * licenses terminated so long as such parties remain in full
  99. * compliance.
  100. *
  101. * 6. By copying, distributing or modifying the Module (or any work
  102. * based on the Module) you indicate your acceptance of this license
  103. * to do so, and all its terms and conditions.
  104. *
  105. * 7. Each time you redistribute the Module (or any work based on the
  106. * Module), the recipient automatically receives a license from the
  107. * original licensor to copy, distribute or modify the Module subject
  108. * to these terms and conditions. You may not impose any further
  109. * restrictions on the recipients' exercise of the rights granted
  110. * herein.
  111. *
  112. * 8. The ITU-T may publish revised and/or new versions of this
  113. * General Public License from time to time. Such new versions will
  114. * be similar in spirit to the present version, but may differ in
  115. * detail to address new problems or concerns.
  116. *
  117. * Each version is given a distinguishing version number. If the
  118. * Module specifies a version number of the license which applies to
  119. * it and "any later version", you have the option of following the
  120. * terms and conditions either of that version or of any later version
  121. * published by the ITU-T. If the Module does not specify a version
  122. * number of the license, you may choose any version ever published by
  123. * the ITU-T.
  124. *
  125. * 9. If you wish to incorporate parts of the Module into other free
  126. * modules whose distribution conditions are different, write to the
  127. * author to ask for permission. For software which is copyrighted by
  128. * the ITU-T, write to the ITU-T Secretariat; exceptions may be made
  129. * for this. This decision will be guided by the two goals of
  130. * preserving the free status of all derivatives of this free software
  131. * and of promoting the sharing and reuse of software generally.
  132. *
  133. *
  134. * NO WARRANTY
  135. *
  136. * 10. BECAUSE THE MODULE IS LICENSED FREE OF CHARGE, THERE IS NO
  137. * WARRANTY FOR THE MODULE, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
  138. * EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS
  139. * AND/OR OTHER PARTIES PROVIDE THE MODULE "AS IS" WITHOUT WARRANTY OF
  140. * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED
  141. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  142. * PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
  143. * PERFORMANCE OF THE MODULE IS WITH YOU. SHOULD THE MODULE PROVE
  144. * DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR
  145. * OR CORRECTION.
  146. *
  147. * 11. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  148. * WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
  149. * MODIFY AND/OR REDISTRIBUTE THE MODULE AS PERMITTED ABOVE, BE LIABLE
  150. * TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
  151. * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
  152. * THE MODULE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
  153. * RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR
  154. * A FAILURE OF THE MODULE TO OPERATE WITH ANY OTHER MODULES), EVEN IF
  155. * SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
  156. * SUCH DAMAGES.
  157. *
  158. * END OF TERMS AND CONDITIONS
  159. ***************************************************************************/
  160. ;----------------------------------------------------------------------
  161. .equ G726_A_U_LAW, 0 ;1->if A/Mu-law inputs, 0-Otherwise ;Adeptte
  162. ;------------------------------------------------------------------------------
  163. ;Global Declarations:
  164. ;------------------------------------------------------------------------------
  165. .global _G726ADecode
  166. ;------------------------------------------------------------------------------
  167. ;Code Section in Program Memory
  168. ;------------------------------------------------------------------------------
  169. .section libg726a, code
  170. /******************************************************************************
  171. *
  172. * Function Name: G726_decode
  173. *
  174. * System: RISC
  175. *
  176. * Platform: dsPIC33F
  177. *
  178. * Description: Initializes the codec state
  179. *
  180. * Cycle Count: 235836-for 2nd block
  181. *
  182. * Input Parameters: w0 - Pointer to input buffer
  183. * w1 - Pointer to output buffer
  184. * w2 - Sample count
  185. * w3 - Law
  186. * w4 - Bit Rate
  187. * w5 - Pointer to Decoder State
  188. *
  189. * Output Parameters: None
  190. *
  191. * History:
  192. *
  193. * Date | By | Remarks
  194. * ---------------+-------------------+----------------------------------
  195. * Oct-27-2005 Sharanabasava M. Created.
  196. * Nov-18-2005 Sharanabasava M. Modified for G.726a
  197. * jan-2010 Sankaralingam & Thiyagarajan Modified for G.726a
  198. ******************************************************************************/
  199. .text
  200. _G726ADecode:
  201. push w8
  202. push w9
  203. push w10
  204. push w11
  205. push w12
  206. push w13
  207. mov w1,w10 ;input buffer
  208. mov w2,w11 ;outbut buffer
  209. add w0,#30,w13
  210. add w13,#30,w1
  211. add w1,#8,w1
  212. mov [w1++],w3 ;rate ;Adeptte
  213. mov [w1],w2
  214. dec w2,w12 ;w12-counter
  215. lnk #42
  216. mov w3,[w14+20]
  217. clr w2
  218. mov w2,[w14+30] ;idq = 0
  219. mov w2,[w14+38]
  220. mov w2,[w14+40] ;iyl = 0
  221. mov #38,w2
  222. add w14,w2,w2
  223. mov w2,[w14+16] ;&iyl
  224. add w14,#30,w2
  225. mov w2,[w14+18] ;&idq
  226. do w12,DECODE
  227. mov w14,w2
  228. add w13,#6,w0
  229. sub w13,#30,w1
  230. call _G726_fmult_b
  231. mov [w13 + 4],w0
  232. mov [w13 + 2],w1
  233. sub w13,#6,w2
  234. add w14,#14,w3
  235. dec2 w3,w4
  236. mov w14,w8
  237. call _G726_fmult
  238. mov [w8++],w5
  239. add w5,[w8++],w5 ;w5-sezi
  240. add w5,[w8++],w5
  241. add w5,[w8++],w5
  242. add w5,[w8++],w5
  243. add w5,[w8++],w5
  244. add w5,[w8++],w6
  245. add w6,[w8],w6 ;w6-sei
  246. asr w5,w3
  247. mov w3,[w14+36] ;isez ;Adeptte
  248. asr w6,w3
  249. mov w3,[w14+32] ;ise ;Adeptte
  250. mov [w14+16],w4 ;iyl ;Adeptte
  251. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  252. mov [w13 + 24],w8
  253. mov #256,w6
  254. cp w8,w6
  255. bra ge,SIXFOUR
  256. asr w8,#2,w8
  257. bra LOG
  258. SIXFOUR:
  259. mov #64,w8 ;w8-al
  260. LOG:
  261. mov [w13 + 32],w0
  262. mov [w13 + 34],w1
  263. mov.d w0,[w4]
  264. mov [w13 + 18],w0
  265. mov.d [w4],w2
  266. mov w8,w1 ;last
  267. call _G726_mix
  268. mov w0,[w14+22] ;iy ;Adeptte
  269. mov [w14+22],w5
  270. mov w14,w0
  271. .if G726_A_U_LAW ;Adeptte
  272. ze [w10],w2 ;i = input[j]
  273. .else
  274. ze [w10++],w2 ;i = input[j]
  275. .endif
  276. mov w2,[w0++]
  277. mov w5,[w0++]
  278. mov [w13 + 20],w2
  279. mov w2,[w0++]
  280. mov [w13 + 22],w2
  281. mov w2,[w0++]
  282. mov [w14+20],w2 ;irate ;Adeptte
  283. mov w2,[w0]
  284. mov w14,w0
  285. mov [w14+18],w1 ;idq ;Adeptte
  286. add w13,#18,w2
  287. add w13,#30,w3
  288. inc2 w3,w3
  289. mov [w13+42],w4
  290. call _G726_iaq_spd1_scale1
  291. mov [w13 + 26],w0
  292. mov [w14+16],w4 ;iyl ;Adeptte
  293. mov [w14+30],w1 ;idq ;Adeptte
  294. mov.d [w4],w2
  295. call _G726_trans
  296. mov w0,[w14+26] ;itr ;Adeptte
  297. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  298. mov [w13 + 30],w1
  299. mov w1,[w14+34] ;ipk2 ;Adeptte
  300. mov [w13 + 28],w1
  301. mov w1,[w13 + 30]
  302. mov [w14+30],w2 ;idq ;Adeptte
  303. cp0 w2
  304. bra ge,DQISTR
  305. mov #0x8000,w3
  306. sub w3,w2,w4
  307. bra DQSEZSTR
  308. DQISTR:
  309. mov w2,w4 ;w4-dqi
  310. DQSEZSTR:
  311. mov [w14+36],w3 ;isez ;Adeptte
  312. add w4,w3,w5 ;w5-dqsez
  313. mov #0xffff,w3
  314. btss w5,#15
  315. mov #1,w3
  316. mov w3,[w13 + 28] ;state->pk0
  317. clr w3
  318. cp0 w5
  319. bra z,SIGPK
  320. mov #1,w3 ;w3-sigpk
  321. SIGPK:
  322. mov w3,[w14+28] ;isigpk ;Adeptte
  323. mov [w14+32],w8 ;ise ;Adeptte
  324. add w4,w8,w0 ;w0-sr=dqi+se
  325. mov w0,[w14+24] ;isr ;Adeptte
  326. ;--------------------- sankar ;Adeptte --------------------;
  327. .if G726_A_U_LAW
  328. mov w0,w1 ;sr
  329. ze [w10++],w0 ;inp
  330. mov w8,w2 ;se
  331. mov [w13+38],w3
  332. mov [w14+22],w4 ;y
  333. mov w11,w5 ;*out
  334. call _G711_process
  335. inc2 w11,w11
  336. .else
  337. ;-----------------------------------------------------------;
  338. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  339. ;-----G.726A----;
  340. btsc w0,#15
  341. bra NEGCHK
  342. mov #8191,w1
  343. cp w0,w1
  344. bra le,MASK
  345. mov w1,w0
  346. bra ENDLIMO
  347. NEGCHK:
  348. mov #0xE000,w1
  349. cp w0,w1
  350. bra le,NEGSAT
  351. bra ENDLIMO
  352. MASK:
  353. mov #16383,w2
  354. and w0,w2,w0
  355. bra ENDLIMO
  356. NEGSAT:
  357. mov w1,w0
  358. ENDLIMO:
  359. mov w0,[w11++]
  360. .endif
  361. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  362. mov w14,w8
  363. mov [w14+28],w3 ;isigpk ;Adeptte
  364. mov w3,[w8++]
  365. mov [w13 + 28],w1 ;state-pk0
  366. mov [w13 + 30],w4 ;state-pk1
  367. mul.uu w1,w4,w2
  368. mov w2,[w8++]
  369. mov [w14+34],w4 ;ipk2 ;Adeptte
  370. mul.uu w1,w4,w2
  371. add w13,#2,w3
  372. mov w2,[w8++]
  373. add w13,#4,w2
  374. mov [w3],[w8++]
  375. mov [w2],[w8++]
  376. mov [w14+26],w4 ;itr ;Adeptte
  377. mov w4,[w8++]
  378. mov w14,w0
  379. mov w8,w1
  380. call _G726_agen
  381. mov #0xd200,w2
  382. mov #1,w3 ;w3-tdp
  383. cp w2,[w8]
  384. bra gt,TONE
  385. clr w3
  386. TONE:
  387. add w13,#26,w2
  388. clr [w2] ;state->tdr
  389. mov [w14+26],w4 ;itr ;Adeptte
  390. cp0 w4
  391. bra nz,TRIGB
  392. mov w3,[w2] ;state->tdr=tdp
  393. TRIGB:
  394. mov [w13 + 20],w0
  395. mov [w13 + 22],w1
  396. mov [w14+22],w2 ;iy ;Adeptte
  397. mov [w14+26],w4 ;itr ;Adeptte
  398. mov [w13 + 24],w5
  399. call _G726_speedcon_blk3
  400. mov w0,[w13 + 24]
  401. mov w14,w7
  402. mov [w13 + 36],w0
  403. mov w0,[w7++]
  404. mov [w14+30],w0 ;idq ;Adeptte
  405. mov w0,[w7++]
  406. mov [w14+26],w0 ;itr ;Adeptte
  407. mov w0,[w7]
  408. mov w14,w0
  409. sub w13,#30,w1
  410. add w13,#6,w2
  411. call _G726_bgen
  412. sub w13,#4,w2
  413. mov w13,w3
  414. mov [w2--],[w3--]
  415. mov [w2],[w3]
  416. sub w13,#12,w4
  417. sub w13,#8,w5
  418. mov [w4--],[w5--]
  419. mov [w4--],[w5--]
  420. mov [w4--],[w5--]
  421. mov [w4--],[w5--]
  422. mov [w4--],[w5--]
  423. mov [w4--],[w5--]
  424. mov [w4--],[w5--]
  425. mov [w4--],[w5--]
  426. mov [w4--],[w5--]
  427. mov [w4],[w5]
  428. mov [w14+24],w0 ;isr ;Adeptte
  429. mov [w14+30],w1 ;idq ;Adeptte
  430. mov w4,w3
  431. call _G726_float_ab
  432. DECODE:
  433. nop
  434. ulnk
  435. pop w13
  436. pop w12
  437. pop w11
  438. pop w10
  439. pop w9
  440. pop w8
  441. return
  442. ;--------End of All Code Sections ---------------------------------------------
  443. .end ;End of program code in this file