Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6252 lines
160 KiB

  1. #ifdef _X86_
  2. void PassLow8(short *vin,short *vout,short *mem,short nech)
  3. {
  4. short low_a;
  5. _asm
  6. {
  7. MOV ESI,[vin] ; SI adress input samples
  8. MOV CX,[nech]
  9. BP_LOOP:
  10. MOV EBX,0
  11. MOV WORD PTR [low_a],0
  12. MOV EDI,[mem] ; DI adress mem vect.
  13. ADD EDI,14 ; point on mem(7)
  14. MOV AX,-3126 ; AX=c(8)
  15. IMUL WORD PTR [EDI] ; *=mem(7)
  16. SUB WORD PTR [low_a],AX ; accumulate in EBX:LOW_A
  17. MOVSX EAX,DX
  18. SBB EBX,EAX
  19. SUB EDI,2 ; mem--
  20. MOV AX,-22721 ; AX=c(7)
  21. MOV DX,WORD PTR [EDI]
  22. MOV WORD PTR [EDI+2],DX
  23. IMUL DX
  24. SUB WORD PTR [low_a],AX
  25. MOVSX EAX,DX
  26. SBB EBX,EAX
  27. SUB EDI,2
  28. MOV AX,-12233 ; AX=c(6)
  29. MOV DX,WORD PTR [EDI]
  30. MOV WORD PTR [EDI+2],DX
  31. IMUL DX
  32. SUB WORD PTR [low_a],AX
  33. MOVSX EAX,DX
  34. SBB EBX,EAX
  35. SUB EDI,2
  36. MOV AX,11718 ; AX=c(5)
  37. MOV DX,WORD PTR [EDI]
  38. MOV WORD PTR [EDI+2],DX
  39. IMUL DX
  40. SUB WORD PTR [low_a],AX
  41. MOVSX EAX,DX
  42. SBB EBX,EAX
  43. SUB EDI,2
  44. MOV AX,-13738 ; AX=c(4)
  45. IMUL WORD PTR [EDI]
  46. ADD WORD PTR [low_a],AX
  47. MOVSX EAX,DX
  48. ADC EBX,EAX
  49. SUB EDI,2
  50. MOV AX,-26425 ; AX=c(3)
  51. MOV DX,WORD PTR [EDI]
  52. MOV WORD PTR [EDI+2],DX
  53. IMUL DX
  54. ADD WORD PTR [low_a],AX
  55. MOVSX EAX,DX
  56. ADC EBX,EAX
  57. SUB EDI,2
  58. MOV DX,WORD PTR [EDI] ; c(2)=0 !
  59. MOV WORD PTR [EDI+2],DX
  60. SUB EDI,2
  61. MOV AX,26425 ; AX=c(1)
  62. MOV DX,WORD PTR [EDI]
  63. MOV WORD PTR [EDI+2],DX
  64. IMUL DX
  65. ADD WORD PTR [low_a],AX
  66. MOVSX EAX,DX
  67. ADC EBX,EAX
  68. MOV AX,13738 ; AX=c(0)
  69. MOV DX,WORD PTR [ESI] ; *=input !!!
  70. ADD ESI,2
  71. MOV WORD PTR [EDI],DX ; DI=mem(0)
  72. IMUL DX
  73. ADD WORD PTR [low_a],AX
  74. MOVSX EAX,DX
  75. ADC EBX,EAX
  76. SAL EBX,1
  77. MOV [EDI+8],BX
  78. MOV EDI,[vout]
  79. MOV [EDI],BX
  80. ADD DWORD PTR [vout],2 ; vout++
  81. DEC CX
  82. JNE BP_LOOP
  83. }
  84. }
  85. #else
  86. void PassLow8(short *vin,short *vout,short *mem,int nech)
  87. {
  88. int j,k;
  89. long X;
  90. for (j=nech;j>0;j--)
  91. {
  92. X = 0;
  93. X -= (((long)-3126*(long)mem[7])+
  94. ((long)-22721*(long)mem[6])+
  95. ((long)-12233*(long)mem[5])+
  96. ((long)11718*(long)mem[4]))>>1;
  97. X += (((long)-13738*(long)mem[3])+
  98. ((long)-26425*(long)mem[2])+
  99. ((long)26425*(long)mem[0])+
  100. ((long)13738*(long)(*vin)))>>1;
  101. mem[7]=mem[6];
  102. mem[6]=mem[5];
  103. mem[5]=mem[4];
  104. mem[4]=(int)(X>>14);
  105. mem[3]=mem[2];
  106. mem[2]=mem[1];
  107. mem[1]=mem[0];
  108. mem[0]=*vin++;
  109. *vout++=mem[4];
  110. }
  111. }
  112. #endif
  113. #if 0
  114. // PhilF: The following is never called!!!
  115. void PassLow11(short *vin,short *vout,short *mem,short nech)
  116. {
  117. short low_a;
  118. _asm
  119. {
  120. MOV ESI,[vin] ; ESI adress input samples
  121. MOV CX,[nech]
  122. BP11_LOOP:
  123. MOV EBX,0
  124. MOV WORD PTR [low_a],0
  125. MOV EDI,[mem] ; EDI adress mem vect.
  126. ADD EDI,14 ; point on mem(7)
  127. MOV AX,3782 ; AX=c(8)
  128. IMUL WORD PTR [EDI] ; *=mem(7)
  129. SUB WORD PTR [low_a],AX ; accumulate in EBX:low_a
  130. MOVSX EAX,DX
  131. SBB EBX,EAX
  132. SUB EDI,2 ; mem--
  133. MOV AX,-8436 ; AX=c(7)
  134. MOV DX,WORD PTR [EDI]
  135. MOV WORD PTR [EDI+2],DX
  136. IMUL DX
  137. SUB WORD PTR [low_a],AX
  138. MOVSX EAX,DX
  139. SBB EBX,EAX
  140. SUB EDI,2
  141. MOV AX,17092 ; AX=c(6)
  142. MOV DX,WORD PTR [EDI]
  143. MOV WORD PTR [EDI+2],DX
  144. IMUL DX
  145. SUB WORD PTR [low_a],AX
  146. MOVSX EAX,DX
  147. SBB EBX,EAX
  148. SUB EDI,2
  149. MOV AX,-10681 ; AX=c(5)
  150. MOV DX,WORD PTR [EDI]
  151. MOV WORD PTR [EDI+2],DX
  152. IMUL DX
  153. SUB WORD PTR [low_a],AX
  154. MOVSX EAX,DX
  155. SBB EBX,EAX
  156. SUB EDI,2
  157. MOV AX,1179 ; AX=c(4)
  158. IMUL WORD PTR [EDI]
  159. ADD WORD PTR [low_a],AX
  160. MOVSX EAX,DX
  161. ADC EBX,EAX
  162. SUB EDI,2
  163. MOV AX,4280 ; AX=c(3)
  164. MOV DX,WORD PTR [EDI]
  165. MOV WORD PTR [EDI+2],DX
  166. IMUL DX
  167. ADD WORD PTR [low_a],AX
  168. MOVSX EAX,DX
  169. ADC EBX,EAX
  170. SUB EDI,2
  171. MOV AX,6208 ; AX=c(3)
  172. MOV DX,WORD PTR [EDI]
  173. MOV WORD PTR [EDI+2],DX
  174. IMUL DX
  175. ADD WORD PTR [low_a],AX
  176. MOVSX EAX,DX
  177. ADC EBX,EAX
  178. SUB EDI,2
  179. MOV AX,4280 ; AX=c(1)
  180. MOV DX,WORD PTR [EDI]
  181. MOV WORD PTR [EDI+2],DX
  182. IMUL DX
  183. ADD WORD PTR [low_a],AX
  184. MOVSX EAX,DX
  185. ADC EBX,EAX
  186. MOV AX,1179 ; AX=c(0)
  187. MOV DX,WORD PTR [ESI] ; *=input !!!
  188. ADD ESI,2
  189. MOV WORD PTR [EDI],DX ; EDI=mem(0)
  190. IMUL DX
  191. ADD WORD PTR [low_a],AX
  192. MOVSX EAX,DX
  193. ADC EBX,EAX
  194. SAL EBX,2
  195. MOV [EDI+8],BX
  196. MOV EDI,[vout]
  197. MOV [EDI],BX
  198. ADD WORD PTR [vout],2 ; vout++
  199. DEC CX
  200. JNE BP11_LOOP
  201. }
  202. }
  203. #endif
  204. #if 0
  205. // PhilF: The following is never called!!!
  206. void PassHigh8(short *mem, short *Vin, short *Vout, short lfen)
  207. {
  208. _asm
  209. {
  210. MOV CX,[lfen] ;CX=cpteur
  211. MOV EDI,[mem]
  212. PH8_LOOP:
  213. MOV ESI,[Vin]
  214. MOV BX,WORD PTR [ESI] ;BX=Xin
  215. MOV AX,WORD PTR [EDI] ;AX=z(1)
  216. MOV WORD PTR [EDI],BX ;mise a jour memoire
  217. SUB BX,AX ;BX=Xin-z(1)
  218. ADD WORD PTR [Vin],2 ;pointer echant svt
  219. MOV AX,WORD PTR [EDI+2] ;AX=z(2)
  220. MOV DX,30483 ;DX=0.9608
  221. IMUL DX
  222. ADD AX,16384
  223. ADC DX,0 ;arrondi et dble signe
  224. SHLD DX,AX,1
  225. ADD DX,BX ;reponse=DX=tmp
  226. MOV WORD PTR [EDI+2],DX ;mise a jour memoire
  227. MOV ESI,[Vout]
  228. MOV WORD PTR [ESI],DX ;output=tmp
  229. ADD WORD PTR [Vout],2 ;pointer echant svt
  230. DEC CX
  231. JNE PH8_LOOP
  232. }
  233. }
  234. #endif
  235. #if 0
  236. // PhilF: The following is never called!!!
  237. void PassHigh11(short *mem, short *Vin, short *Vout, short lfen)
  238. {
  239. _asm
  240. {
  241. MOV CX,[lfen] ;CX=cpteur
  242. MOV EDI,[mem]
  243. PH11_LOOP:
  244. MOV ESI,[Vin]
  245. MOV BX,WORD PTR [ESI] ;BX=Xin
  246. MOV AX,WORD PTR [EDI] ;AX=z(1)
  247. MOV WORD PTR [EDI],BX ;mise a jour memoire
  248. SUB BX,AX ;BX=Xin-z(1)
  249. ADD WORD PTR [Vin],2 ;pointer echant svt
  250. MOV AX,WORD PTR [EDI+2] ;AX=z(2)
  251. MOV DX,30830 ;DX=0.9714
  252. IMUL DX
  253. ADD AX,16384
  254. ADC DX,0 ;arrondi et dble signe
  255. SHLD DX,AX,1
  256. ADD DX,BX ;reponse=DX=tmp
  257. MOV WORD PTR [EDI+2],DX ;mise a jour memoire
  258. MOV ESI,[Vout]
  259. MOV WORD PTR [ESI],DX ;output=tmp
  260. ADD WORD PTR [Vout],2 ;pointer echant svt
  261. DEC CX
  262. JNE PH11_LOOP
  263. }
  264. }
  265. #endif
  266. #if 0
  267. // PhilF: The following is never called!!!
  268. void Down11_8(short *Vin, short *Vout, short *mem)
  269. {
  270. short low_a, count;
  271. _asm
  272. {
  273. MOV WORD PTR [count],176
  274. MOV ESI,[Vin]
  275. MOV EDI,[Vout]
  276. MOV CX,[ESI] ; *mem=*in
  277. DOWN_LOOP:
  278. MOV [EDI],CX
  279. ADD EDI,2
  280. ADD ESI,2
  281. MOV AX,7040
  282. IMUL WORD PTR [ESI]
  283. MOV [low_a],AX
  284. MOV BX,DX
  285. MOV AX,2112
  286. IMUL WORD PTR [ESI+2]
  287. ADD [low_a],AX
  288. ADC BX,DX
  289. MOV AX,-960
  290. IMUL CX
  291. ADD [low_a],AX
  292. ADC BX,DX
  293. MOV AX,[low_a]
  294. SHRD AX,BX,13
  295. MOV [EDI],AX
  296. MOV CX,[ESI]
  297. ADD ESI,2
  298. ADD EDI,2
  299. MOV AX,3584
  300. IMUL WORD PTR [ESI]
  301. MOV [low_a],AX
  302. MOV BX,DX
  303. MOV AX,5376
  304. IMUL WORD PTR [ESI+2]
  305. ADD [low_a],AX
  306. ADC BX,DX
  307. MOV AX,-768
  308. IMUL CX
  309. ADD [low_a],AX
  310. ADC BX,DX
  311. MOV AX,[low_a]
  312. SHRD AX,BX,13
  313. MOV [EDI],AX
  314. ADD ESI,2
  315. MOV CX,[ESI]
  316. ADD ESI,2
  317. ADD EDI,2
  318. MOV AX,8064
  319. IMUL WORD PTR [ESI]
  320. MOV [low_a],AX
  321. MOV BX,DX
  322. MOV AX,576
  323. IMUL WORD PTR [ESI+2]
  324. ADD [low_a],AX
  325. ADC BX,DX
  326. MOV AX,-448
  327. IMUL CX
  328. ADD [low_a],AX
  329. ADC BX,DX
  330. MOV AX,[low_a]
  331. SHRD AX,BX,13
  332. MOV [EDI],AX
  333. MOV CX,[ESI]
  334. ADD ESI,2
  335. ADD EDI,2
  336. MOV AX,6144
  337. IMUL WORD PTR [ESI]
  338. MOV [low_a],AX
  339. MOV BX,DX
  340. MOV AX,3072
  341. IMUL WORD PTR [ESI+2]
  342. ADD [low_a],AX
  343. ADC BX,DX
  344. MOV AX,-1024
  345. IMUL CX
  346. ADD [low_a],AX
  347. ADC BX,DX
  348. MOV AX,[low_a]
  349. SHRD AX,BX,13
  350. MOV [EDI],AX
  351. MOV CX,[ESI]
  352. ADD ESI,2
  353. ADD EDI,2
  354. MOV AX,1920
  355. IMUL WORD PTR [ESI]
  356. MOV [low_a],AX
  357. MOV BX,DX
  358. MOV AX,6720
  359. IMUL WORD PTR [ESI+2]
  360. ADD [low_a],AX
  361. ADC BX,DX
  362. MOV AX,-448
  363. IMUL CX
  364. ADD [low_a],AX
  365. ADC BX,DX
  366. MOV AX,[low_a]
  367. SHRD AX,BX,13
  368. MOV [EDI],AX
  369. ADD ESI,2
  370. MOV CX,[ESI]
  371. ADD ESI,2
  372. ADD EDI,2
  373. MOV AX,7680
  374. IMUL WORD PTR [ESI]
  375. MOV [low_a],AX
  376. MOV BX,DX
  377. MOV AX,1280
  378. IMUL WORD PTR [ESI+2]
  379. ADD [low_a],AX
  380. ADC BX,DX
  381. MOV AX,-768
  382. IMUL CX
  383. ADD [low_a],AX
  384. ADC BX,DX
  385. MOV AX,[low_a]
  386. SHRD AX,BX,13
  387. MOV [EDI],AX
  388. MOV CX,[ESI]
  389. ADD ESI,2
  390. ADD EDI,2
  391. MOV AX,4992
  392. IMUL WORD PTR [ESI]
  393. MOV [low_a],AX
  394. MOV BX,DX
  395. MOV AX,4160
  396. IMUL WORD PTR [ESI+2]
  397. ADD [low_a],AX
  398. ADC BX,DX
  399. MOV AX,-960
  400. IMUL CX
  401. ADD [low_a],AX
  402. ADC BX,DX
  403. MOV AX,[low_a]
  404. SHRD AX,BX,13
  405. MOV [EDI],AX
  406. ADD ESI,4
  407. MOV CX,[ESI]
  408. ADD EDI,2
  409. SUB WORD PTR [count],11
  410. JNE DOWN_LOOP
  411. SUB ESI,2
  412. MOV EBX,[mem]
  413. MOV CX,[ESI]
  414. MOV [EBX],CX ; *memory=*(++ptr_in)
  415. }
  416. }
  417. #endif
  418. #if 0
  419. // PhilF: The following is never called!!!
  420. void Up8_11(short *Vin, short *Vout, short *mem1, short *mem2)
  421. {
  422. short low_a, count;
  423. _asm
  424. {
  425. MOV WORD PTR [count],128
  426. MOV ESI,[Vin]
  427. MOV EBX,[mem1]
  428. MOV CX,[EBX] ;CX=memo
  429. MOV EDI,[mem2]
  430. MOV AX,7582
  431. IMUL CX
  432. MOV [low_a],AX
  433. MOV BX,DX
  434. MOV AX,1421
  435. IMUL WORD PTR [ESI]
  436. ADD [low_a],AX
  437. ADC BX,DX
  438. MOV AX,-812
  439. IMUL WORD PTR [EDI]
  440. ADD [low_a],AX
  441. ADC BX,DX
  442. MOV AX,[low_a]
  443. SHRD AX,BX,13
  444. MOV EDI,[Vout]
  445. MOV [EDI],AX
  446. ADD EDI,2
  447. UP_LOOP:
  448. MOV AX,[ESI]
  449. MOV [EDI],AX
  450. ADD EDI,2
  451. MOV AX,3859
  452. IMUL WORD PTR [ESI]
  453. MOV [low_a],AX
  454. MOV BX,DX
  455. MOV AX,5145
  456. IMUL WORD PTR [ESI+2]
  457. ADD [low_a],AX
  458. ADC BX,DX
  459. MOV AX,-812
  460. IMUL CX
  461. ADD [low_a],AX
  462. ADC BX,DX
  463. MOV AX,[low_a]
  464. SHRD AX,BX,13
  465. MOV [EDI],AX
  466. MOV CX,[ESI]
  467. ADD ESI,2
  468. ADD EDI,2
  469. MOV AX,6499
  470. IMUL WORD PTR [ESI]
  471. MOV [low_a],AX
  472. MOV BX,DX
  473. MOV AX,2708
  474. IMUL WORD PTR [ESI+2]
  475. ADD [low_a],AX
  476. ADC BX,DX
  477. MOV AX,-1015
  478. IMUL CX
  479. ADD [low_a],AX
  480. ADC BX,DX
  481. MOV AX,[low_a]
  482. SHRD AX,BX,13
  483. MOV [EDI],AX
  484. MOV CX,[ESI]
  485. ADD ESI,2
  486. ADD EDI,2
  487. MOV AX,7921
  488. IMUL WORD PTR [ESI]
  489. MOV [low_a],AX
  490. MOV BX,DX
  491. MOV AX,880
  492. IMUL WORD PTR [ESI+2]
  493. ADD [low_a],AX
  494. ADC BX,DX
  495. MOV AX,-609
  496. IMUL CX
  497. ADD [low_a],AX
  498. ADC BX,DX
  499. MOV AX,[low_a]
  500. SHRD AX,BX,13
  501. MOV [EDI],AX
  502. ADD EDI,2
  503. MOV AX,1421
  504. IMUL WORD PTR [ESI]
  505. MOV [low_a],AX
  506. MOV BX,DX
  507. MOV AX,7108
  508. IMUL WORD PTR [ESI+2]
  509. ADD [low_a],AX
  510. ADC BX,DX
  511. MOV AX,-338
  512. IMUL CX
  513. ADD [low_a],AX
  514. ADC BX,DX
  515. MOV AX,[low_a]
  516. SHRD AX,BX,13
  517. MOV [EDI],AX
  518. MOV CX,[ESI]
  519. ADD ESI,2
  520. ADD EDI,2
  521. MOV AX,4874
  522. IMUL WORD PTR [ESI]
  523. MOV [low_a],AX
  524. MOV BX,DX
  525. MOV AX,4265
  526. IMUL WORD PTR [ESI+2]
  527. ADD [low_a],AX
  528. ADC BX,DX
  529. MOV AX,-947
  530. IMUL CX
  531. ADD [low_a],AX
  532. ADC BX,DX
  533. MOV AX,[low_a]
  534. SHRD AX,BX,13
  535. MOV [EDI],AX
  536. MOV CX,[ESI]
  537. ADD ESI,2
  538. ADD EDI,2
  539. MOV AX,7108
  540. IMUL WORD PTR [ESI]
  541. MOV [low_a],AX
  542. MOV BX,DX
  543. MOV AX,2031
  544. IMUL WORD PTR [ESI+2]
  545. ADD [low_a],AX
  546. ADC BX,DX
  547. MOV AX,-947
  548. IMUL CX
  549. ADD [low_a],AX
  550. ADC BX,DX
  551. MOV AX,[low_a]
  552. SHRD AX,BX,13
  553. MOV [EDI],AX
  554. MOV CX,[ESI]
  555. ADD ESI,2
  556. ADD EDI,2
  557. MOV AX,8124
  558. IMUL WORD PTR [ESI]
  559. MOV [low_a],AX
  560. MOV BX,DX
  561. MOV AX,406
  562. IMUL WORD PTR [ESI+2]
  563. ADD [low_a],AX
  564. ADC BX,DX
  565. MOV AX,-338
  566. IMUL CX
  567. ADD [low_a],AX
  568. ADC BX,DX
  569. MOV AX,[low_a]
  570. SHRD AX,BX,13
  571. MOV [EDI],AX
  572. ADD EDI,2
  573. MOV AX,2708
  574. IMUL WORD PTR [ESI]
  575. MOV [low_a],AX
  576. MOV BX,DX
  577. MOV AX,6093
  578. IMUL WORD PTR [ESI+2]
  579. ADD [low_a],AX
  580. ADC BX,DX
  581. MOV AX,-609
  582. IMUL CX
  583. ADD [low_a],AX
  584. ADC BX,DX
  585. MOV AX,[low_a]
  586. SHRD AX,BX,13
  587. MOV [EDI],AX
  588. MOV CX,[ESI]
  589. ADD ESI,2
  590. ADD EDI,2
  591. MOV AX,5754
  592. IMUL WORD PTR [ESI]
  593. MOV [low_a],AX
  594. MOV BX,DX
  595. MOV AX,3452
  596. IMUL WORD PTR [ESI+2]
  597. ADD [low_a],AX
  598. ADC BX,DX
  599. MOV AX,-1015
  600. IMUL CX
  601. ADD [low_a],AX
  602. ADC BX,DX
  603. MOV AX,[low_a]
  604. SHRD AX,BX,13
  605. MOV [EDI],AX
  606. MOV CX,[ESI]
  607. ADD ESI,2
  608. ADD EDI,2
  609. CMP WORD PTR [count],8
  610. JE END_OF_LOOP
  611. MOV AX,7582
  612. IMUL WORD PTR [ESI]
  613. MOV [low_a],AX
  614. MOV BX,DX
  615. MOV AX,1421
  616. IMUL WORD PTR [ESI+2]
  617. ADD [low_a],AX
  618. ADC BX,DX
  619. MOV AX,-812
  620. IMUL CX
  621. ADD [low_a],AX
  622. ADC BX,DX
  623. MOV AX,[low_a]
  624. SHRD AX,BX,13
  625. MOV [EDI],AX
  626. MOV CX,[ESI]
  627. ADD ESI,2
  628. ADD EDI,2
  629. END_OF_LOOP:
  630. SUB WORD PTR [count],8
  631. JNE UP_LOOP
  632. MOV EBX,[mem2]
  633. MOV CX,[ESI-2]
  634. MOV [EBX],CX ; *memory2=*(ptr_in-1)
  635. MOV EBX,[mem1]
  636. MOV CX,[ESI]
  637. MOV [EBX],CX ; *memory=*(ptr_in)
  638. }
  639. }
  640. #endif
  641. #ifdef _X86_
  642. void QMFilter(short *input,short *coef,short *out_low,short *out_high,
  643. short *mem,short lng)
  644. {
  645. long R1,R0;
  646. _asm
  647. {
  648. QMF_LOOP:
  649. MOV ESI,[input] ; ES:SI for input
  650. MOV EBX,[mem] ; DS:BX for memory
  651. MOV AX,WORD PTR [ESI] ; AX=*input
  652. MOV WORD PTR [EBX+16],AX ; *high_mem=*input
  653. ADD ESI,2 ; input++
  654. MOV AX,WORD PTR [ESI] ; AX=*input
  655. MOV WORD PTR [EBX],AX ; *low_mem=*input
  656. ADD DWORD PTR [input],4 ; input++
  657. MOV DWORD PTR [R1],0 ; initialize accumulation in R1
  658. MOV DWORD PTR [R0],0 ; initialize accumulation in R0
  659. MOV ESI,[coef] ; ES:SI for ptr1
  660. MOV EDI,ESI
  661. ADD EDI,14 ; ES:DI for ptr2
  662. ADD EBX,14 ; DS:BX for end of mem vector
  663. MOV CX,8 ; CX=count
  664. QMF_LOOP2:
  665. MOV AX,WORD PTR [ESI] ; AX=*ptr1
  666. ADD ESI,2 ; ptr1++
  667. IMUL WORD PTR [EBX+16] ; DX:AX *=(*high_mem)
  668. AND EAX,0000ffffH
  669. SAL EDX,16
  670. ADD EDX,EAX
  671. ADD DWORD PTR [R1],EDX
  672. MOV AX,WORD PTR [EDI] ; AX=*ptr0
  673. SUB EDI,2 ; ptr1--
  674. IMUL WORD PTR [EBX] ; DX:AX *=(*low_mem)
  675. AND EAX,0000ffffH
  676. SAL EDX,16
  677. ADD EDX,EAX
  678. ADD DWORD PTR [R0],EDX
  679. MOV AX,WORD PTR [EBX-2]
  680. MOV WORD PTR [EBX],AX ; *low_mem=*(low_mem-1)
  681. MOV AX,WORD PTR [EBX+14]
  682. MOV WORD PTR [EBX+16],AX ; *high_mem=*(high_mem-1)
  683. SUB EBX,2 ; *low_mem-- , *high_mem--
  684. DEC CX
  685. JNE QMF_LOOP2
  686. MOV EAX,DWORD PTR [R0]
  687. SUB EAX,DWORD PTR [R1]
  688. SAR EAX,15
  689. MOV EDI,[out_high]
  690. MOV WORD PTR [EDI],AX ; *high_out=R0-R1
  691. ADD DWORD PTR [out_high],2 ; high_low++
  692. MOV EAX,DWORD PTR [R0]
  693. ADD EAX,DWORD PTR [R1]
  694. SAR EAX,15
  695. MOV EDI,[out_low]
  696. MOV WORD PTR [EDI],AX ; *low_out=R0+R1
  697. ADD DWORD PTR [out_low],2 ; low_out++
  698. DEC WORD PTR [lng]
  699. JNE QMF_LOOP
  700. }
  701. }
  702. #else
  703. void QMFilter(short *in,short *coef,short *out_low,short *out_high,
  704. short *mem,short lng)
  705. {
  706. int i,j;
  707. long R1,R0;
  708. short *ptr0,*ptr1,*high_p,*low_p;
  709. for (j=lng; j>0; j--)
  710. {
  711. high_p = mem+8;
  712. low_p = mem;
  713. *high_p = *in++;
  714. *low_p = *in++;
  715. R1=R0=0;
  716. ptr0 = coef; ptr1 = coef+8-1;
  717. for (i=8; i>0; i--)
  718. {
  719. R1 += (long)(*ptr1--) * (long)(*high_p++);
  720. R0 += (long)(*ptr0++) * (long)(*low_p++);
  721. }
  722. *out_low++ = (short)((R0+R1)>>15);
  723. *out_high++ = (short)((R0-R1)>>15);
  724. for (i=8; i>0; i--)
  725. {
  726. high_p--; low_p--;
  727. *high_p = *(high_p-1); *low_p = *(low_p-1);
  728. }
  729. }
  730. }
  731. #endif
  732. #ifdef _X86_
  733. void QMInverse(short *in_low,short *in_high,short *coef,
  734. short *output,short *mem,short lng)
  735. {
  736. long R0,R1;
  737. _asm
  738. {
  739. QMI_LOOP:
  740. MOV ESI,[in_low] ; ES:SI for input low
  741. MOV EDI,[in_high] ; ES:DI for input high
  742. MOV EBX,[mem] ; DS:BX for memory
  743. MOV AX,WORD PTR [ESI]
  744. SUB AX,WORD PTR [EDI] ; AX=*in_low-*in_high
  745. MOV WORD PTR [EBX],AX ; *low_mem=*in_low-*in_high
  746. MOV AX,WORD PTR [ESI]
  747. ADD AX,WORD PTR [EDI] ; AX=*in_low+*in_high
  748. MOV WORD PTR [EBX+16],AX ; *high_mem=*in_low+*in_high
  749. ADD DWORD PTR [in_low],2 ; in_low++
  750. ADD DWORD PTR [in_high],2 ; in_high++
  751. MOV DWORD PTR [R0],0
  752. MOV DWORD PTR [R1],0
  753. MOV ESI,[coef] ; ES:SI for ptr1
  754. MOV EDI,ESI
  755. ADD EDI,14 ; ES:DI for ptr2
  756. ADD EBX,14 ; DS:BX for end of mem vector
  757. MOV CX,8 ; DX=count
  758. QMI_LOOP2:
  759. MOV AX,WORD PTR [ESI] ; AX=*ptr1
  760. ADD ESI,2 ; ptr1++
  761. IMUL WORD PTR [EBX+16] ; DX:AX*=(*high_mem)
  762. AND EAX,0000ffffH
  763. SAL EDX,16
  764. ADD EDX,EAX
  765. ADD DWORD PTR [R1],EDX ; Accumulate in R1
  766. MOV AX,WORD PTR [EDI] ; AX=*ptr0
  767. SUB EDI,2 ; ptr1--
  768. IMUL WORD PTR [EBX] ; DX:AX*=(*low_mem)
  769. AND EAX,0000ffffH
  770. SAL EDX,16
  771. ADD EDX,EAX
  772. ADD DWORD PTR [R0],EDX ; Accumulate in R0
  773. MOV AX,WORD PTR [EBX-2]
  774. MOV WORD PTR [EBX],AX ; *low_mem=*(low_mem-1)
  775. MOV AX,WORD PTR [EBX+14]
  776. MOV WORD PTR [EBX+16],AX ; *high_mem=*(high_mem-1)
  777. SUB EBX,2 ; *low_mem-- , *high_mem--
  778. DEC CX
  779. JNE QMI_LOOP2
  780. MOV EDI,[output]
  781. MOV EAX,DWORD PTR [R1]
  782. SAR EAX,15
  783. MOV WORD PTR [EDI+2],AX ; *(out+1)=R1
  784. MOV EAX,DWORD PTR [R0]
  785. SAR EAX,15
  786. MOV WORD PTR [EDI],AX ; *out=R0
  787. ADD DWORD PTR [output],4 ; out++,out++
  788. DEC WORD PTR [lng]
  789. JNE QMI_LOOP
  790. }
  791. }
  792. #else
  793. void QMInverse(short *in_low,short *in_high,short *coef,
  794. short *out,short *mem,short lng)
  795. {
  796. int i,j;
  797. long R1,R0;
  798. short *ptr0,*ptr1,*high_p,*low_p;
  799. for (j=0; j<lng; j++)
  800. {
  801. high_p = mem+8;
  802. low_p = mem;
  803. *high_p = *in_low + *in_high;
  804. *low_p = *in_low++ - *in_high++;
  805. R1 = R0 = 0;
  806. ptr0 = coef; ptr1 = coef+8-1;
  807. for (i=8; i>0; i--)
  808. {
  809. R1 += (long)(*ptr1--) * (long)(*high_p++);
  810. R0 += (long)(*ptr0++) * (long)(*low_p++);
  811. }
  812. *out++ = (short)(R0>>15);
  813. *out++ = (short)(R1>>15);
  814. for (i=8; i>0; i--)
  815. {
  816. high_p--; low_p--;
  817. *high_p = *(high_p-1); *low_p = *(low_p-1);
  818. }
  819. }
  820. }
  821. #endif
  822. #ifdef _X86_
  823. void iConvert64To8(short *input, short *output, short N, short *mem)
  824. {
  825. short LOW_A;
  826. _asm
  827. {
  828. MOV ESI,[input]
  829. MOV EDI,[output]
  830. MOV AX,[ESI]
  831. MOV [EDI],AX ; out[0]=in[0]
  832. MOV WORD PTR [LOW_A],0
  833. MOV AX,-3072
  834. MOV EBX,[mem] ; BX for memory
  835. IMUL word ptr [EBX]
  836. MOV EBX,0
  837. ADD [LOW_A],AX
  838. MOVSX EAX,DX
  839. ADC EBX,EAX
  840. MOV AX,14336
  841. IMUL word ptr [ESI]
  842. ADD [LOW_A],AX
  843. MOVSX EAX,DX
  844. ADC EBX,EAX
  845. MOV AX,21504
  846. IMUL word ptr [ESI+2]
  847. ADD [LOW_A],AX
  848. MOVSX EAX,DX
  849. ADC EBX,EAX
  850. SAL EBX,1
  851. MOV word ptr [EDI+2],BX ; out[1]
  852. MOV WORD PTR [LOW_A],0
  853. MOV EBX,0
  854. MOV AX,-4096
  855. IMUL word ptr [ESI]
  856. ADD [LOW_A],AX
  857. MOVSX EAX,DX
  858. ADC EBX,EAX
  859. MOV AX,24576
  860. IMUL word ptr [ESI+2]
  861. ADD [LOW_A],AX
  862. MOVSX EAX,DX
  863. ADC EBX,EAX
  864. MOV AX,12288
  865. IMUL word ptr [ESI+4]
  866. ADD [LOW_A],AX
  867. MOVSX EAX,DX
  868. ADC EBX,EAX
  869. SAL EBX,1
  870. MOV word ptr [EDI+4],BX ; out[2]
  871. MOV WORD PTR [LOW_A],0
  872. MOV EBX,0
  873. MOV AX,-3072
  874. IMUL word ptr [ESI+2]
  875. ADD [LOW_A],AX
  876. MOVSX EAX,DX
  877. ADC EBX,EAX
  878. MOV AX,30720
  879. IMUL word ptr [ESI+4]
  880. ADD [LOW_A],AX
  881. MOVSX EAX,DX
  882. ADC EBX,EAX
  883. MOV AX,5120
  884. IMUL word ptr [ESI+6]
  885. ADD [LOW_A],AX
  886. MOVSX EAX,DX
  887. ADC EBX,EAX
  888. SAL EBX,1
  889. MOV word ptr [EDI+6],BX ; out[3]
  890. MOV AX,[ESI+6]
  891. MOV [EDI+8],AX ; out[4]
  892. MOV CX,0
  893. iUPSAMP:
  894. ADD CX,4
  895. CMP CX,WORD PTR [N]
  896. JGE iEND_UPSAMP
  897. ADD ESI,8
  898. ADD EDI,10
  899. MOV AX,[ESI]
  900. MOV [EDI],AX ; out[0]=in[0]
  901. MOV WORD PTR [LOW_A],0
  902. MOV EBX,0
  903. MOV AX,-3072
  904. IMUL word ptr [ESI-2]
  905. ADD [LOW_A],AX
  906. MOVSX EAX,DX
  907. ADC EBX,EAX
  908. MOV AX,14336
  909. IMUL word ptr [ESI]
  910. ADD [LOW_A],AX
  911. MOVSX EAX,DX
  912. ADC EBX,EAX
  913. MOV AX,21504
  914. IMUL word ptr [ESI+2]
  915. ADD [LOW_A],AX
  916. MOVSX EAX,DX
  917. ADC EBX,EAX
  918. SAL EBX,1
  919. MOV word ptr [EDI+2],BX ; out[1]
  920. MOV WORD PTR [LOW_A],0
  921. MOV EBX,0
  922. MOV AX,-4096
  923. IMUL word ptr [ESI]
  924. ADD [LOW_A],AX
  925. MOVSX EAX,DX
  926. ADC EBX,EAX
  927. MOV AX,24576
  928. IMUL word ptr [ESI+2]
  929. ADD [LOW_A],AX
  930. MOVSX EAX,DX
  931. ADC EBX,EAX
  932. MOV AX,12288
  933. IMUL word ptr [ESI+4]
  934. ADD [LOW_A],AX
  935. MOVSX EAX,DX
  936. ADC EBX,EAX
  937. SAL EBX,1
  938. MOV word ptr [EDI+4],BX ; out[2]
  939. MOV WORD PTR [LOW_A],0
  940. MOV EBX,0
  941. MOV AX,-3072
  942. IMUL word ptr [ESI+2]
  943. ADD [LOW_A],AX
  944. MOVSX EAX,DX
  945. ADC EBX,EAX
  946. MOV AX,30720
  947. IMUL word ptr [ESI+4]
  948. ADD [LOW_A],AX
  949. MOVSX EAX,DX
  950. ADC EBX,EAX
  951. MOV AX,5120
  952. IMUL word ptr [ESI+6]
  953. ADD [LOW_A],AX
  954. MOVSX EAX,DX
  955. ADC EBX,EAX
  956. SAL EBX,1
  957. MOV word ptr [EDI+6],BX ; out[3]
  958. MOV AX,[ESI+6]
  959. MOV [EDI+8],AX ; out[4]
  960. JMP iUPSAMP
  961. iEND_UPSAMP:
  962. MOV EBX,[mem]
  963. MOV AX,[ESI+6]
  964. MOV [EBX],AX ; mem[0]=in[N-1]
  965. }
  966. }
  967. #else
  968. void iConvert64To8(short *input, /* Pointer to input buffer */
  969. short *output, /* Pointer to output buffer */
  970. short N, /* Number of input samples */
  971. short *mem) /* Pointer to two word temporary storage */
  972. {
  973. int i;
  974. /* This copies samples and replicates every 4th */
  975. /* (and leaves garbage at the end if not a multiple of 4 */
  976. for(i=0; i<N/4; i++) {
  977. short temp;
  978. *output++ = *input++;
  979. *output++ = *input++;
  980. *output++ = *input++;
  981. *output++ = temp = *input++;
  982. *output++ = temp;
  983. }
  984. }
  985. #endif
  986. #ifdef _X86_
  987. void iConvert8To64(short *input, short *output, short N, short *mem)
  988. {
  989. short LOW_A;
  990. _asm
  991. {
  992. MOV ESI,[input]
  993. MOV EDI,[output]
  994. MOV CX,0
  995. iDOWNSAMP:
  996. CMP CX,WORD PTR [N]
  997. JGE iEND_DOWNSAMP
  998. MOV AX,[ESI]
  999. MOV [EDI],AX ; out[0]=in[0]
  1000. MOV WORD PTR [LOW_A],0
  1001. MOV EBX,0
  1002. MOV AX,-3623
  1003. IMUL word ptr [ESI]
  1004. ADD [LOW_A],AX
  1005. MOVSX EAX,DX
  1006. ADC EBX,EAX
  1007. MOV AX,29200
  1008. IMUL word ptr [ESI+2]
  1009. ADD [LOW_A],AX
  1010. MOVSX EAX,DX
  1011. ADC EBX,EAX
  1012. MOV AX,7191
  1013. IMUL word ptr [ESI+4]
  1014. ADD [LOW_A],AX
  1015. MOVSX EAX,DX
  1016. ADC EBX,EAX
  1017. SAL EBX,1
  1018. MOV word ptr [EDI+2],BX ; out[1]
  1019. MOV WORD PTR [LOW_A],0
  1020. MOV EBX,0
  1021. MOV AX,-3677
  1022. IMUL word ptr [ESI+2]
  1023. ADD [LOW_A],AX
  1024. MOVSX EAX,DX
  1025. ADC EBX,EAX
  1026. MOV AX,18494
  1027. IMUL word ptr [ESI+4]
  1028. ADD [LOW_A],AX
  1029. MOVSX EAX,DX
  1030. ADC EBX,EAX
  1031. MOV AX,17950
  1032. IMUL word ptr [ESI+6]
  1033. ADD [LOW_A],AX
  1034. MOVSX EAX,DX
  1035. ADC EBX,EAX
  1036. SAL EBX,1
  1037. MOV word ptr [EDI+4],BX ; out[2]
  1038. MOV AX,[ESI+8]
  1039. MOV [EDI+6],AX ; out[3]=in[4]
  1040. ADD CX,5
  1041. ADD SI,10
  1042. ADD EDI,8
  1043. JMP iDOWNSAMP
  1044. iEND_DOWNSAMP:
  1045. }
  1046. }
  1047. #else
  1048. /* Resample 8 KHz to 6.4 KHz */
  1049. void iConvert8To64(short *input, /* Pointer to input sample buffer */
  1050. short *output, /* Pointer to output sample buffer */
  1051. short N, /* Count of input samples */
  1052. short *mem) /* Pointer to two word temporary storage */
  1053. {
  1054. int i;
  1055. /* This copies 4 of every 5 samples */
  1056. /* (and leaves garbage at the end if not a multiple of 5 */
  1057. for(i=0; i<N/5; i++) {
  1058. *output++ = *input++ >> 1;
  1059. *output++ = *input++ >> 1;
  1060. *output++ = *input++ >> 1;
  1061. *output++ = *input++ >> 1;
  1062. input++;
  1063. }
  1064. }
  1065. #endif
  1066. #ifdef _X86_
  1067. void fenetre(short *src,short *fen,short *dest,short lng)
  1068. {
  1069. _asm
  1070. {
  1071. MOV ESI,[src]
  1072. MOV EDI,[fen]
  1073. MOV EBX,[dest]
  1074. MOV CX,[lng] ; CX : compteur
  1075. fen_loop:
  1076. MOV AX,WORD PTR [ESI] ; AX = src
  1077. IMUL WORD PTR [EDI] ; DX:AX = src*fen
  1078. ADD AX,16384
  1079. ADC DX,0 ; arrondi
  1080. SHLD DX,AX,1
  1081. MOV WORD PTR [EBX],DX
  1082. ADD ESI,2
  1083. ADD EDI,2
  1084. ADD EBX,2
  1085. DEC CX
  1086. JNE fen_loop
  1087. }
  1088. }
  1089. #else
  1090. /* Window the data in buffer */
  1091. /* not tested - tfm */
  1092. void fenetre(short *src,short *fen,short *dest,short lng)
  1093. {
  1094. int i;
  1095. for(i=0; i<lng; i++) {
  1096. *dest++ = *src++ * *fen++;
  1097. }
  1098. }
  1099. #endif
  1100. #ifdef _X86_
  1101. void autocor(short *vech,long *ri,short nech,short ordre)
  1102. {
  1103. short low_a,compta;
  1104. _asm
  1105. {
  1106. MOV ESI,[vech] ;DS:SI adresse vect. echantillons
  1107. MOV BX,[nech]
  1108. MOV WORD PTR [low_a],0
  1109. MOV ECX,0
  1110. DYNAMIC:
  1111. MOV AX,WORD PTR [ESI] ;Charger lment vect. source
  1112. IMUL AX ; DX:AX = xi*xi
  1113. ADD [low_a],AX
  1114. MOVSX EAX,DX
  1115. ADC ECX,EAX ;accumuler sur 48 bits
  1116. ADD ESI,2 ;Pointer lmen suiv.
  1117. SUB BX,1
  1118. JG DYNAMIC
  1119. MOV EDI,[ri] ;ES:DI adresse vect. autocorr.
  1120. MOV EAX,ECX
  1121. SAR EAX,15
  1122. ADD AX,0
  1123. JZ FORMAT_OK
  1124. ;RISK_OV:
  1125. MOV AX,[low_a]
  1126. ADD AX,8
  1127. ADC ECX,0
  1128. SAR AX,4
  1129. AND AX,0FFFH
  1130. SAL ECX,12
  1131. OR CX,AX
  1132. MOV DWORD PTR [EDI],ECX ;Sauvegarder R(0)
  1133. MOVSX EAX,[ordre]
  1134. SAL EAX,2
  1135. ADD EDI,EAX ;Pointer dernier lment du vect. autoc.
  1136. ATCROV1:
  1137. MOV CX,[nech] ;Charger nombre de points vect. source
  1138. SUB CX,[ordre] ;Dcrmenter de l'ordre de corrlation
  1139. MOV [compta],CX
  1140. MOV ESI,[vech] ;DS:SI adresse vect. echantillons
  1141. MOVSX EBX,[ordre]
  1142. ADD EBX,EBX ;Dfinir un Deplacement d'adresse vect. source
  1143. MOV ECX,0
  1144. MOV WORD PTR [low_a],0 ; //SS:
  1145. ATCROV2:
  1146. MOV AX,WORD PTR [ESI] ;Charger lment vect. source
  1147. IMUL WORD PTR [ESI+EBX] ;Multiplier par l'lment dcal
  1148. ADD [low_a],AX
  1149. MOVSX EAX,DX
  1150. ADC ECX,EAX
  1151. ADD ESI,2 ;Pointer lmen suiv.
  1152. SUB WORD PTR [compta],1 ; //SS:
  1153. JG ATCROV2
  1154. MOV AX,[low_a]
  1155. ADD AX,8
  1156. ADC ECX,0
  1157. SAR AX,4
  1158. AND AX,0FFFH
  1159. SAL ECX,12
  1160. OR CX,AX
  1161. MOV DWORD PTR [EDI],ECX ;Sauvegarder rsultat
  1162. SUB EDI,4 ;Pointer autocor. prcdant
  1163. SUB WORD PTR [ordre],1 ;Test de fin de boucle //SS:
  1164. JG ATCROV1
  1165. JMP FIN_ATCR
  1166. FORMAT_OK:
  1167. SAL ECX,16
  1168. MOV CX,[low_a]
  1169. MOV DWORD PTR [EDI],ECX ;Sauvegarder R(0)
  1170. MOVSX EAX,WORD PTR [ordre]
  1171. SAL EAX,2
  1172. ADD EDI,EAX ;Pointer dernier lment du vect. autoc.
  1173. ATCR10:
  1174. MOV CX,[nech] ;Charger nombre de points vect. source
  1175. SUB CX,[ordre] ;Dcrmenter de l'ordre de corrlation
  1176. MOV [compta],CX
  1177. MOV ESI,[vech] ;DS:SI adresse vect. echantillons
  1178. MOVSX EBX,[ordre]
  1179. ADD EBX,EBX ;Dfinir un Deplacement d'adresse vect. source
  1180. MOV CX,0
  1181. MOV WORD PTR [low_a],0 ;//SS:
  1182. ATCR20:
  1183. MOV AX,WORD PTR [ESI] ;Charger lment vect. source
  1184. IMUL WORD PTR [ESI+EBX] ;Multiplier par l'lment dcal
  1185. ADD [low_a],AX
  1186. ADC CX,DX
  1187. ADD ESI,2 ;Pointer lmen suiv.
  1188. SUB WORD PTR [compta],1 ;//SS:
  1189. JG ATCR20
  1190. MOV AX,[low_a]
  1191. MOV WORD PTR [EDI],AX ;Sauvegarder rsultat
  1192. MOV WORD PTR [EDI+2],CX
  1193. SUB EDI,4 ;Pointer autocor. prcdant
  1194. SUB WORD PTR [ordre],1 ;Test de fin de boucle
  1195. JG ATCR10
  1196. FIN_ATCR:
  1197. } // _asm
  1198. }
  1199. #else
  1200. void autocor(short *vech,long *ri,short nech,short ordre)
  1201. {
  1202. // TODO: Fill this in
  1203. }
  1204. #endif
  1205. #ifdef _X86_
  1206. short max_autoc(short *vech,short nech,short debut,short fin)
  1207. {
  1208. short max_pos,max_l,compta;
  1209. long lmax_h;
  1210. _asm
  1211. {
  1212. MOV WORD PTR [max_pos],69
  1213. MOV DWORD PTR [lmax_h],-6969
  1214. MOV WORD PTR [max_l],69
  1215. M_ATCR1:
  1216. MOV CX,[nech] ;Charger nombre de points vect. source
  1217. MOVSX EBX,WORD PTR [fin]
  1218. SUB CX,BX ;Dcrmenter de l'ordre de corrlation
  1219. MOV [compta],CX
  1220. MOV ESI,[vech] ;DS:SI adresse vect. echantillons
  1221. ADD EBX,EBX ;Dfinir un Deplacement d'adresse vect. source
  1222. MOV ECX,0
  1223. MOV DI,0;
  1224. M_ATCR2:
  1225. MOV AX,WORD PTR [ESI] ;Charger lment vect. source
  1226. IMUL WORD PTR [ESI+EBX] ;Multiplier par l'lment dcal
  1227. ADD DI,AX
  1228. MOVSX EAX,DX
  1229. ADC ECX,EAX
  1230. ADD ESI,2 ;Pointer lmen suiv.
  1231. SUB WORD PTR [compta],1
  1232. JG M_ATCR2
  1233. MOV BX,[max_l]
  1234. SUB BX,DI
  1235. MOV EDX,[lmax_h]
  1236. SBB EDX,ECX
  1237. JGE NEXT_ITR
  1238. MOV [max_l],DI ;save max
  1239. MOV [lmax_h],ECX
  1240. MOV AX,[fin]
  1241. MOV [max_pos],AX
  1242. NEXT_ITR:
  1243. MOV CX,[fin] ;Test de fin de boucle
  1244. SUB CX,1
  1245. MOV [fin],CX
  1246. SUB CX,[debut]
  1247. JGE M_ATCR1
  1248. }
  1249. // MOV AX,[max_pos]
  1250. return max_pos;
  1251. }
  1252. #else
  1253. short max_autoc(short *vech,short nech,short debut,short fin)
  1254. {
  1255. // TODO need 64-bit
  1256. return 0;
  1257. }
  1258. #endif
  1259. #ifdef _X86_
  1260. #pragma warning(disable : 4035)
  1261. short max_vect(short *vech,short nech)
  1262. {
  1263. _asm
  1264. {
  1265. MOV CX,[nech] ;Charger nombre de points vect. source
  1266. MOV ESI,[vech] ;DS:SI adresse vect. echantillons
  1267. MOV AX,-32767 ; AX = maximum
  1268. L_M_VECT:
  1269. MOV BX,WORD PTR [ESI] ;Charger elem. vect.
  1270. ADD BX,0
  1271. JGE BX_POSIT
  1272. NEG BX
  1273. BX_POSIT:
  1274. CMP BX,AX
  1275. JLE NEXT_VALUE
  1276. MOV AX,BX
  1277. NEXT_VALUE:
  1278. ADD ESI,2
  1279. DEC CX
  1280. JNE L_M_VECT
  1281. }
  1282. }
  1283. #pragma warning(default : 4035)
  1284. void upd_max(long *corr_ene,long *vval,short pitch)
  1285. {
  1286. _asm
  1287. {
  1288. MOV ESI,[corr_ene] ; DS:SI adresse correlation et energie
  1289. MOV EDI,[vval] ; ES:DI maximum.
  1290. MOV EAX,DWORD PTR [ESI+8] ; AX = partie haute de ener
  1291. SAR EAX,15
  1292. ADD AX,0
  1293. JE FORMA32
  1294. MOV EAX,DWORD PTR [ESI] ;EAX = corr. high
  1295. MOV BX,WORD PTR [ESI+4]
  1296. ADD BX,8
  1297. ADC EAX,0
  1298. SAR BX,4
  1299. AND BX,0FFFH
  1300. SAL EAX,12
  1301. OR AX,BX
  1302. ADD EAX,0
  1303. JGE CORR_POSIT
  1304. NEG EAX
  1305. CORR_POSIT:
  1306. MOV DWORD PTR [ESI+16],EAX
  1307. MOV EBX,DWORD PTR [ESI+8]
  1308. MOV DX,WORD PTR [ESI+12]
  1309. ADD DX,8
  1310. ADC EBX,0
  1311. SAR DX,4
  1312. AND DX,0FFFH
  1313. SAL EBX,12
  1314. OR BX,DX
  1315. MOV DWORD PTR [ESI+20],EBX
  1316. MOV ECX,4
  1317. JMP DEB_COMP
  1318. FORMA32:
  1319. MOV ECX,0 ; init normalisat.
  1320. MOV AX,WORD PTR [ESI]
  1321. SAL EAX,16
  1322. MOV AX,WORD PTR [ESI+4]
  1323. ADD EAX,0
  1324. JGE CORR_POSIT2
  1325. NEG EAX
  1326. CORR_POSIT2:
  1327. MOV DWORD PTR [ESI+16],EAX
  1328. MOV BX,WORD PTR [ESI+8]
  1329. SAL EBX,16
  1330. MOV BX,WORD PTR [ESI+12]
  1331. MOV DWORD PTR [ESI+20],EBX
  1332. DEB_COMP:
  1333. ; EAX = correl.
  1334. ; EBX = ener
  1335. ADD EBX,0
  1336. JE ENER_NULL
  1337. MOV DX,WORD PTR [ESI+22]
  1338. ADD DX,WORD PTR [ESI+18]
  1339. JG GT16BIT
  1340. ;FORM_16:
  1341. SAL EBX,15
  1342. SAL EAX,15
  1343. SUB ECX,15
  1344. GT16BIT:
  1345. ADD EAX,0
  1346. JE ENER_NULL
  1347. CMP EBX,40000000H
  1348. JGE NO_E_NORMU
  1349. NORM_ENEU:
  1350. ADD EBX,EBX
  1351. INC ECX
  1352. CMP EBX,40000000H
  1353. JL NORM_ENEU
  1354. NO_E_NORMU:
  1355. CMP EAX,40000000H ; normaliser acc
  1356. JGE PAS_D_N_C
  1357. NORM_CORL:
  1358. ADD EAX,EAX
  1359. SUB ECX,2
  1360. CMP EAX,40000000H
  1361. JL NORM_CORL
  1362. PAS_D_N_C:
  1363. IMUL EAX ;EDX:EAX = produit
  1364. CMP EDX,20000000H
  1365. JLE MAKE_DIVU
  1366. SHRD EAX,EDX,1
  1367. SAR EDX,1
  1368. INC ECX
  1369. MAKE_DIVU:
  1370. IDIV EBX
  1371. CMP EAX,40000000H
  1372. JGE SAVE_RAPP
  1373. NORM_RAPP:
  1374. ADD EAX,EAX
  1375. DEC ECX
  1376. CMP EAX,40000000H
  1377. JLE NORM_RAPP
  1378. SAVE_RAPP:
  1379. MOV EBX,DWORD PTR [EDI+4]
  1380. CMP ECX,EBX
  1381. JG UPDATE_M
  1382. JL ENER_NULL
  1383. ;EBX_EQU_ECX:
  1384. MOV EBX,DWORD PTR [EDI]
  1385. CMP EAX,EBX
  1386. JLE ENER_NULL
  1387. UPDATE_M:
  1388. MOV DWORD PTR [EDI],EAX ; sauver mant. et exp. max
  1389. MOV DWORD PTR [EDI+4],ECX
  1390. MOV EAX,DWORD PTR [ESI+16]
  1391. MOV EDX,DWORD PTR [ESI]
  1392. ADD EDX,0
  1393. JGE SIGNE_OK
  1394. NEG EAX
  1395. SIGNE_OK:
  1396. MOV DWORD PTR [EDI+8],EAX
  1397. MOV EAX,DWORD PTR [ESI+20]
  1398. MOV DWORD PTR [EDI+12],EAX
  1399. MOVSX EAX,WORD PTR [pitch]
  1400. MOV DWORD PTR [EDI+16],EAX
  1401. ENER_NULL:
  1402. }
  1403. }
  1404. #pragma warning(disable : 4035)
  1405. short upd_max_d(long *corr_ene,long *vval)
  1406. {
  1407. _asm
  1408. {
  1409. MOV ESI,[corr_ene] ; DS:SI adresse correlation et energie
  1410. MOV EDI,[vval] ; ES:DI maximum.
  1411. MOV AX,0
  1412. MOV EBX,DWORD PTR [ESI+4] ;EBX = ener
  1413. ADD EBX,0
  1414. JE ENER_ZRO
  1415. MOV EAX,DWORD PTR [ESI] ; EAX = corr.
  1416. SAL EAX,10 ; 12 initialement
  1417. IMUL EAX ; EDX:EAX = corr*corr
  1418. IDIV EBX ; EAX = corr*corr/ener
  1419. MOV ECX,EAX
  1420. MOV AX,0
  1421. MOV EDX,DWORD PTR [EDI] ; EDX = GGmax
  1422. CMP ECX,EDX
  1423. JLE ENER_ZRO
  1424. MOV DWORD PTR [EDI],ECX ; save max
  1425. MOV DWORD PTR [EDI+8],EBX
  1426. MOV EAX,DWORD PTR [ESI] ; EAX = corr.
  1427. MOV DWORD PTR [EDI+4],EAX
  1428. MOV AX,7FFFH
  1429. ENER_ZRO:
  1430. }
  1431. }
  1432. #pragma warning(default : 4035)
  1433. void norm_corrl(long *corr,long *vval)
  1434. {
  1435. _asm
  1436. {
  1437. MOV ESI,[corr] ; DS:SI adresse vect. corr.
  1438. MOV EDI,[vval] ; ES:DI adresse acc et ener.
  1439. MOV EAX,DWORD PTR [EDI+8] ; AX = partie haute de ener
  1440. SAR EAX,15
  1441. ADD AX,0
  1442. JE FORM_32
  1443. MOV EAX,DWORD PTR [EDI]
  1444. MOV BX,WORD PTR [EDI+4]
  1445. ADD BX,32
  1446. ADC EAX,0
  1447. SAR BX,5
  1448. AND BX,07FFH
  1449. SAL EAX,11 ;
  1450. OR AX,BX
  1451. MOV DWORD PTR [EDI+16],EAX
  1452. MOV EBX,DWORD PTR [EDI+8]
  1453. MOV DX,WORD PTR [EDI+12]
  1454. ADD DX,32
  1455. ADC EBX,0
  1456. SAR DX,5
  1457. AND DX,07FFH
  1458. SAL EBX,11 ;
  1459. OR BX,DX
  1460. MOV DWORD PTR [EDI+20],EBX
  1461. MOV ECX,5
  1462. JMP DEB_PROC
  1463. FORM_32:
  1464. MOV ECX,0 ; init normalisation
  1465. MOV AX,WORD PTR [EDI]
  1466. SAL EAX,16
  1467. MOV AX,WORD PTR [EDI+4]
  1468. MOV DWORD PTR [EDI+16],EAX
  1469. MOV BX,WORD PTR [EDI+8]
  1470. SAL EBX,16
  1471. MOV BX,WORD PTR [EDI+12]
  1472. MOV DWORD PTR [EDI+20],EBX
  1473. DEB_PROC:
  1474. ADD EAX,0 ;EAX = acc
  1475. JLE CORR_LE_0
  1476. CMP EBX,40000000H
  1477. JGE NO_E_NORM
  1478. NORM_ENE:
  1479. ADD EBX,EBX
  1480. INC ECX
  1481. CMP EBX,40000000H
  1482. JL NORM_ENE
  1483. NO_E_NORM:
  1484. CMP EAX,40000000H ; normaliser acc
  1485. JGE PAS_D_NORM
  1486. NORM_ACC:
  1487. ADD EAX,EAX
  1488. SUB ECX,2
  1489. CMP EAX,40000000H
  1490. JL NORM_ACC
  1491. PAS_D_NORM:
  1492. IMUL EAX ;EDX:EAX = produit
  1493. CMP EDX,20000000H
  1494. JLE MAKE_DIV
  1495. SHRD EAX,EDX,1
  1496. SAR EDX,1
  1497. INC ECX
  1498. MAKE_DIV:
  1499. IDIV EBX
  1500. CMP EAX,40000000H
  1501. JL SAVE_CRR
  1502. SAR EAX,1
  1503. INC ECX
  1504. JMP SAVE_CRR
  1505. CORR_LE_0:
  1506. MOV EAX,0
  1507. MOV ECX,-69
  1508. SAVE_CRR:
  1509. MOV DWORD PTR [ESI],EAX
  1510. MOV DWORD PTR [ESI+4],ECX
  1511. }
  1512. }
  1513. void norm_corrr(long *corr,long *vval)
  1514. {
  1515. _asm
  1516. {
  1517. MOV ESI,[corr] ; DS:SI adresse vect. corr.
  1518. MOV EDI,[vval] ; ES:DI adresse acc et ener.
  1519. MOV EAX,DWORD PTR [EDI+8] ; AX = partie haute de ener
  1520. SAR EAX,15
  1521. ADD AX,0
  1522. JE FORM_32R
  1523. MOV EAX,DWORD PTR [EDI]
  1524. MOV BX,WORD PTR [EDI+4]
  1525. ADD BX,32
  1526. ADC EAX,0
  1527. SAR BX,5
  1528. AND BX,07FFH
  1529. SAL EAX,11 ;
  1530. OR AX,BX
  1531. MOV DWORD PTR [EDI+16],EAX
  1532. MOV EBX,DWORD PTR [EDI+8]
  1533. MOV DX,WORD PTR [EDI+12]
  1534. ADD DX,32
  1535. ADC EBX,0
  1536. SAR DX,5
  1537. AND DX,07FFH
  1538. SAL EBX,11 ;
  1539. OR BX,DX
  1540. MOV DWORD PTR [EDI+20],EBX
  1541. MOV ECX,5
  1542. JMP DEB_PROCR
  1543. FORM_32R:
  1544. MOV ECX,0 ; init normalisat.
  1545. MOV AX,WORD PTR [EDI]
  1546. SAL EAX,16
  1547. MOV AX,WORD PTR [EDI+4]
  1548. MOV DWORD PTR [EDI+16],EAX
  1549. MOV BX,WORD PTR [EDI+8]
  1550. SAL EBX,16
  1551. MOV BX,WORD PTR [EDI+12]
  1552. MOV DWORD PTR [EDI+20],EBX
  1553. DEB_PROCR:
  1554. ;EAX = acc
  1555. ADD EAX,0
  1556. JLE CORRR_LE_0
  1557. ;EBX = ener
  1558. CMP EBX,40000000H
  1559. JGE NO_E_NORMR
  1560. NORM_ENER:
  1561. ADD EBX,EBX
  1562. INC ECX
  1563. CMP EBX,40000000H
  1564. JL NORM_ENER
  1565. NO_E_NORMR:
  1566. CMP EAX,40000000H ; normaliser acc
  1567. JGE PAS_D_NORMR
  1568. NORM_ACCR:
  1569. ADD EAX,EAX
  1570. SUB ECX,2
  1571. CMP EAX,40000000H
  1572. JL NORM_ACCR
  1573. PAS_D_NORMR:
  1574. IMUL EAX ;EDX:EAX = produit
  1575. CMP EDX,20000000H
  1576. JLE MAKE_DIVR
  1577. SHRD EAX,EDX,1
  1578. SAR EDX,1
  1579. INC ECX
  1580. MAKE_DIVR:
  1581. IDIV EBX
  1582. CMP EAX,40000000H
  1583. JL SAVE_CRRR
  1584. SAR EAX,1
  1585. INC ECX
  1586. SAVE_CRRR:
  1587. MOV EBX,DWORD PTR [ESI+4]
  1588. CMP EBX,ECX
  1589. JL BX_LT_CX
  1590. JG BX_GT_CX
  1591. ;BX_EQU_CX:
  1592. ADD DWORD PTR [ESI],EAX
  1593. JMP CORRR_LE_0
  1594. BX_LT_CX:
  1595. MOV DWORD PTR [ESI+4],ECX ; sauver exp.
  1596. SUB CX,BX ;
  1597. MOV EDX,DWORD PTR [ESI]
  1598. SAR EDX,CL
  1599. ADD EAX,EDX
  1600. MOV DWORD PTR [ESI],EAX
  1601. JMP CORRR_LE_0
  1602. BX_GT_CX:
  1603. SUB BX,CX ;
  1604. MOV CL,BL
  1605. SAR EAX,CL
  1606. ADD DWORD PTR [ESI],EAX
  1607. CORRR_LE_0:
  1608. MOV EAX,DWORD PTR [ESI]
  1609. MOV ECX,DWORD PTR [ESI+4]
  1610. ADD EAX,0
  1611. JZ END_CRRR
  1612. CMP EAX,40000000H
  1613. JGE END_CRRR
  1614. NRM_RR:
  1615. ADD EAX,EAX
  1616. DEC ECX
  1617. CMP EAX,40000000H
  1618. JL NRM_RR
  1619. MOV DWORD PTR [ESI],EAX
  1620. MOV DWORD PTR [ESI+4],ECX
  1621. END_CRRR:
  1622. }
  1623. }
  1624. void energy(short *vech,long *ene,short lng)
  1625. {
  1626. _asm
  1627. {
  1628. MOV ESI,[vech] ; DS:SI adresse vect. echantillons
  1629. MOV CX,[lng] ;Initialiser le compteur
  1630. MOV EBX,0
  1631. MOV DI,0
  1632. L_ENERGY:
  1633. MOV AX,WORD PTR [ESI] ;Charger lment vect. source
  1634. IMUL AX ;Multiplier
  1635. ADD DI,AX
  1636. MOVSX EAX,DX
  1637. ADC EBX,EAX
  1638. ADD ESI,2 ;Pointer lmen suiv.
  1639. DEC CX
  1640. JNE L_ENERGY
  1641. MOV ESI,[ene] ; adresse result.
  1642. MOV DWORD PTR [ESI],EBX
  1643. MOV WORD PTR [ESI+4],DI
  1644. }
  1645. }
  1646. void venergy(short *vech,long *vene,short lng)
  1647. {
  1648. _asm
  1649. {
  1650. MOV ESI,[vech] ; DS:SI adresse vect. echantillons
  1651. MOV EDI,[vene] ; adresse result.
  1652. MOV EBX,0
  1653. MOV CX,0
  1654. L_VENERGY:
  1655. MOV AX,WORD PTR [ESI] ;Charger lment vect. source
  1656. IMUL AX ;Multiplier
  1657. ADD CX,AX
  1658. MOVSX EAX,DX
  1659. ADC EBX,EAX ; acc. en EBX:CX
  1660. ADD ESI,2 ;Pointer lmen suiv.
  1661. MOV EDX,EBX ; sauver EBX:CX>>5
  1662. MOV AX,CX ; mettre dans EDX:AX
  1663. ADD AX,16 ; arrondi
  1664. ADC EDX,0
  1665. SAL EDX,11 ; EDX<<11
  1666. SAR AX,5 ;
  1667. AND AX,07FFH
  1668. OR DX,AX ; EDX = (EBX:CX + 16) >> 5
  1669. MOV DWORD PTR [EDI],EDX
  1670. ADD EDI,4
  1671. SUB WORD PTR [lng],1
  1672. JG L_VENERGY
  1673. }
  1674. }
  1675. void energy2(short *vech,long *ene,short lng)
  1676. {
  1677. _asm
  1678. {
  1679. MOV ESI,[vech] ; DS:SI adresse vect. echantillons
  1680. MOV CX,[lng] ;Initialiser le compteur
  1681. MOV EBX,0
  1682. MOV DI,0
  1683. L_ENERGY2:
  1684. MOV AX,WORD PTR [ESI] ;Charger lment vect. source
  1685. IMUL AX ;Multiplier
  1686. ADD DI,AX
  1687. MOVSX EAX,DX
  1688. ADC EBX,EAX
  1689. ADD ESI,2 ;Pointer lmen suiv.
  1690. DEC CX
  1691. JNE L_ENERGY2
  1692. MOV ESI,[ene] ; adresse result.
  1693. ; sauver EBX:[LOW_A]>>5
  1694. ADD DI,16 ; arrondi
  1695. ADC EBX,0
  1696. SAL EBX,11 ; EBX<<11
  1697. SAR DI,5 ;
  1698. AND DI,07FFH
  1699. OR BX,DI ; EBX = (EBX:AX + 16) >> 5
  1700. MOV DWORD PTR [ESI],EBX
  1701. }
  1702. }
  1703. void upd_ene(long *ener,long *val)
  1704. {
  1705. _asm
  1706. {
  1707. MOV ESI,[ener] ; DS:SI adresse vect. corr.
  1708. MOV EDI,[val] ; ES:DI adresse acc et ener.
  1709. MOV EBX,DWORD PTR [ESI] ; EBX partie H ene
  1710. MOV AX,WORD PTR [ESI+4] ; AX = partie low
  1711. MOV CX,WORD PTR [EDI]
  1712. MOVSX EDX,WORD PTR [EDI+2] ; EDX:CX ajouter
  1713. ADD AX,CX
  1714. ADC EBX,EDX
  1715. MOV CX,WORD PTR [EDI+4]
  1716. MOVSX EDX,WORD PTR [EDI+6] ; EDX:CX retirer
  1717. SUB AX,CX
  1718. SBB EBX,EDX
  1719. MOV DWORD PTR [ESI],EBX
  1720. MOV WORD PTR [ESI+4],AX
  1721. }
  1722. }
  1723. #pragma warning(disable : 4035)
  1724. short max_posit(long *vcorr,long *maxval,short pitch,short lvect)
  1725. {
  1726. _asm
  1727. {
  1728. MOV ESI,[vcorr] ; DS:SI adresse vect. corr.
  1729. MOV EDI,[maxval] ; ES:DI adresse val max
  1730. MOV CX,[lvect] ; init compt
  1731. MOV EAX,DWORD PTR [ESI] ; init max
  1732. MOV EBX,DWORD PTR [ESI+4]
  1733. ADD ESI,8
  1734. MOV WORD PTR [EDI],CX
  1735. DEC CX
  1736. L_MAX_POS:
  1737. MOV EDX,DWORD PTR [ESI+4] ; EDX = exp. du candidat
  1738. CMP EDX,EBX
  1739. JG UPDT_MAX
  1740. JL NEXT_IND
  1741. MOV EDX,DWORD PTR [ESI] ; EDX = mantisse
  1742. CMP EDX,EAX
  1743. JLE NEXT_IND
  1744. UPDT_MAX:
  1745. MOV EAX,DWORD PTR [ESI]
  1746. MOV EBX,DWORD PTR [ESI+4]
  1747. MOV WORD PTR [EDI],CX
  1748. NEXT_IND:
  1749. ADD ESI,8
  1750. DEC CX
  1751. JNE L_MAX_POS
  1752. MOV CX,WORD PTR [EDI]
  1753. NEG CX
  1754. ADD CX,[lvect]
  1755. MOV DX,[lvect]
  1756. SAR DX,1
  1757. SUB CX,DX
  1758. ADD CX,[pitch]
  1759. MOV DWORD PTR [EDI],EAX
  1760. MOV DWORD PTR [EDI+4],EBX
  1761. MOV AX,CX
  1762. }
  1763. }
  1764. #pragma warning(default : 4035)
  1765. void correlation(short *vech,short *vech2,long *acc,short lng)
  1766. {
  1767. short low_a;
  1768. _asm
  1769. {
  1770. MOV ESI,[vech] ; DS:SI adresse vect. echantillons
  1771. MOV EDI,[vech2] ; ES:DI adresse 2d vect.
  1772. MOV CX,[lng] ;Initialiser le compteur
  1773. MOV EBX,0
  1774. MOV WORD PTR [low_a],0
  1775. L_CORREL:
  1776. MOV AX,WORD PTR [ESI] ;Charger lment vect. source
  1777. IMUL WORD PTR [EDI] ;Multiplier par l'lment dcal
  1778. ADD [low_a],AX
  1779. MOVSX EAX,DX
  1780. ADC EBX,EAX
  1781. ADD ESI,2 ;Pointer lmen suiv.
  1782. ADD EDI,2
  1783. DEC CX
  1784. JNE L_CORREL
  1785. MOV ESI,[acc] ; adresse result.
  1786. MOV DWORD PTR [ESI],EBX
  1787. MOV AX,[low_a]
  1788. MOV WORD PTR [ESI+4],AX
  1789. }
  1790. }
  1791. void schur(short *parcor,long *Ri,short netages)
  1792. {
  1793. short cmpt2;
  1794. _asm
  1795. {
  1796. MOV ESI,[Ri]
  1797. MOV EDI,ESI
  1798. ADD EDI,44 ; DS:DI for V
  1799. MOV EBX,DWORD PTR [ESI] ; EBX = R(0)
  1800. MOV CL,0
  1801. CMP EBX,40000000H ;normaliser R(0)
  1802. JGE OUT_N_R0
  1803. NORM_R0:
  1804. ADD EBX,EBX
  1805. INC CL
  1806. CMP EBX,40000000H
  1807. JL NORM_R0
  1808. OUT_N_R0:
  1809. MOV DWORD PTR [ESI],EBX
  1810. ;Initialisation de V = R1..Rp
  1811. MOV DX,[netages] ;Charger ordre p du LPC
  1812. ADD ESI,4 ;Pointer R1
  1813. INIT_V:
  1814. MOV EAX,DWORD PTR [ESI] ;EAX = Ri
  1815. SAL EAX,CL
  1816. MOV DWORD PTR [ESI],EAX ;Sauver dans U[i]
  1817. MOV DWORD PTR [EDI],EAX ;Sauver dans V[i]
  1818. ADD ESI,4 ;passer au suivant
  1819. ADD EDI,4
  1820. DEC DX
  1821. JG INIT_V
  1822. MOV WORD PTR [cmpt2],1 ;I=1
  1823. HANITRA:
  1824. MOV CX,[netages] ;CX = NETAGES
  1825. SUB CX,[cmpt2] ;CX = NETAGES-I
  1826. ADD WORD PTR [cmpt2],1
  1827. MOV ESI,[Ri] ;Charger vecteur U
  1828. MOV EDI,ESI
  1829. ADD EDI,44 ;Charger vect. V
  1830. MOV EDX,DWORD PTR [EDI] ; EDX = V(0)
  1831. MOV EAX,0
  1832. SHRD EAX,EDX,1
  1833. SAR EDX,1
  1834. MOV EBX,DWORD PTR [ESI] ; EBX = S(0)
  1835. NEG EBX
  1836. IDIV EBX
  1837. MOV EBX,EAX ; EBX = KI
  1838. MOV EAX,DWORD PTR [EDI] ; EAX =V(0)
  1839. IMUL EBX ; EDX:EAX = PARCOR*V[0]
  1840. SHLD EDX,EAX,1
  1841. ADD EDX,DWORD PTR [ESI] ; EDX = U[0]+V[0]*PARCOR
  1842. CMP CX,0
  1843. JE FINATCR
  1844. MOV DWORD PTR [ESI],EDX ;Sauver U[0]; EBX = KI
  1845. LALA:
  1846. ADD EDI,4 ;Incrementer les pointeurs
  1847. ADD ESI,4 ;
  1848. MOV EAX,DWORD PTR [ESI]
  1849. IMUL EBX ;EDX:EAX = PARCOR*U[I]
  1850. SHLD EDX,EAX,1
  1851. ADD EDX,DWORD PTR [EDI] ;EDX = V[I]+U[I]*PARCOR
  1852. MOV DWORD PTR [EDI-4],EDX ;Sauver V[I-1];
  1853. MOV EAX,DWORD PTR [EDI]
  1854. IMUL EBX ;EDX:EAX = PARCOR*V[I]
  1855. SHLD EDX,EAX,1
  1856. ADD EDX,DWORD PTR [ESI] ;EDX = U[I]+V[I]*PARCOR
  1857. MOV DWORD PTR [ESI],EDX ;Sauver U[I]; ST = KI
  1858. DEC CX
  1859. JNE LALA
  1860. MOV EDI,[parcor]
  1861. ADD EBX,32768
  1862. SAR EBX,16
  1863. MOV WORD PTR [EDI],BX ; sauver KI
  1864. ADD DWORD PTR [parcor],2 ;Next KI
  1865. JMP HANITRA
  1866. FINATCR:
  1867. ADD EBX,32768
  1868. SAR EBX,16
  1869. MOV EDI,[parcor]
  1870. MOV WORD PTR [EDI],BX ; sauver KI
  1871. }
  1872. }
  1873. void interpol(short *lsp1,short *lsp2,short *dest,short lng)
  1874. {
  1875. _asm
  1876. {
  1877. MOV ESI,[lsp1]
  1878. MOV EDI,[lsp2]
  1879. MOV EBX,[dest]
  1880. MOV CX,[lng] ; CX : compteur
  1881. interp_loop:
  1882. MOVSX EAX,WORD PTR [ESI] ; AX = lsp1
  1883. ADD ESI,2
  1884. ADD EAX,EAX ; EAX = 2*lsp1
  1885. MOVSX EDX,WORD PTR [EDI]
  1886. ADD EAX,EDX ; EAX = 2*lsp1+lsp2
  1887. ADD EDI,2
  1888. MOV EDX,21845 ; 21845 = 1/3
  1889. IMUL EDX ; EDX:EAX = AX/3
  1890. ADD EAX,32768
  1891. SAR EAX,16
  1892. MOV WORD PTR [EBX],AX
  1893. ADD EBX,2
  1894. DEC CX
  1895. JNE interp_loop
  1896. }
  1897. }
  1898. void add_sf_vect(short *y1,short *y2,short deb,short lng)
  1899. {
  1900. _asm
  1901. {
  1902. MOV ESI,[y1]
  1903. MOV EDI,[y2]
  1904. MOV CX,[lng]
  1905. MOVSX EBX,WORD PTR [deb]
  1906. SUB CX,BX ; CX : compteur
  1907. ADD BX,BX
  1908. ADD ESI,EBX
  1909. ADD_SHFT:
  1910. MOV AX,WORD PTR [EDI]
  1911. ADD WORD PTR [ESI],AX
  1912. ADD ESI,2
  1913. ADD EDI,2
  1914. DEC CX
  1915. JNE ADD_SHFT
  1916. }
  1917. }
  1918. void sub_sf_vect(short *y1,short *y2,short deb,short lng)
  1919. {
  1920. _asm
  1921. {
  1922. MOV ESI,[y1]
  1923. MOV EDI,[y2]
  1924. MOV CX,[lng]
  1925. MOVSX EBX,[deb]
  1926. SUB CX,BX ; CX : compteur
  1927. ADD BX,BX
  1928. ADD ESI,EBX
  1929. SUB_SHFT:
  1930. MOV AX,WORD PTR [EDI]
  1931. SUB WORD PTR [ESI],AX
  1932. ADD ESI,2
  1933. ADD EDI,2
  1934. DEC CX
  1935. JNE SUB_SHFT
  1936. }
  1937. }
  1938. void short_to_short(short *src,short *dest,short lng)
  1939. {
  1940. _asm
  1941. {
  1942. MOV ESI,[src]
  1943. MOV EDI,[dest]
  1944. MOV CX,[lng] ; CX : compteur
  1945. COPY_LOOP:
  1946. MOV AX,WORD PTR [ESI]
  1947. MOV WORD PTR [EDI],AX
  1948. ADD ESI,2
  1949. ADD EDI,2
  1950. DEC CX
  1951. JNE COPY_LOOP
  1952. }
  1953. }
  1954. void inver_v_int(short *src,short *dest,short lng)
  1955. {
  1956. _asm
  1957. {
  1958. MOV ESI,[src]
  1959. MOV EDI,[dest]
  1960. MOV CX,[lng] ; CX : compteur
  1961. MOVSX EBX,CX
  1962. DEC EBX
  1963. ADD EBX,EBX
  1964. ADD EDI,EBX
  1965. INVERS_LOOP:
  1966. MOV AX,WORD PTR [ESI]
  1967. MOV WORD PTR [EDI],AX
  1968. ADD ESI,2
  1969. SUB EDI,2
  1970. DEC CX
  1971. JNE INVERS_LOOP
  1972. }
  1973. }
  1974. void long_to_long(long *src,long *dest,short lng)
  1975. {
  1976. _asm
  1977. {
  1978. MOV ESI,[src]
  1979. MOV EDI,[dest]
  1980. MOV CX,[lng] ; CX : compteur
  1981. COPY_LOOP2:
  1982. MOV EAX,DWORD PTR [ESI]
  1983. MOV DWORD PTR [EDI],EAX
  1984. ADD ESI,4
  1985. ADD EDI,4
  1986. DEC CX
  1987. JNE COPY_LOOP2
  1988. }
  1989. }
  1990. void init_zero(short *src,short lng)
  1991. {
  1992. _asm
  1993. {
  1994. MOV ESI,[src]
  1995. MOV CX,[lng] ; CX : compteur
  1996. MOV AX,0
  1997. COPY_LOOP3:
  1998. MOV WORD PTR [ESI],AX
  1999. ADD ESI,2
  2000. DEC CX
  2001. JNE COPY_LOOP3
  2002. }
  2003. }
  2004. #if 0
  2005. // PhilF: The following is never called!!!
  2006. void update_dic(short *y1,short *y2,short hy[],short lng,short i0,short fact)
  2007. {
  2008. _asm
  2009. {
  2010. MOV ESI,[y1]
  2011. MOV EDI,[y2]
  2012. MOV CX,[i0] ; CX : compteur
  2013. MOV DX,CX
  2014. UPDAT_LOOP1:
  2015. MOV AX,WORD PTR [EDI] ; y1 = y2 for (i=0..i0-1)
  2016. MOV WORD PTR [ESI],AX
  2017. ADD ESI,2
  2018. ADD EDI,2
  2019. DEC CX
  2020. JNE UPDAT_LOOP1
  2021. MOV EBX,[hy]
  2022. MOV CX,[lng]
  2023. SUB CX,DX ; CX = lng-i0 = compteur
  2024. MOV AX,[fact]
  2025. ADD AX,0
  2026. JL FACT_NEG
  2027. UPDAT_LOOP2:
  2028. MOV AX,WORD PTR [EDI] ; AX = y2[i]
  2029. MOV DX,WORD PTR [EBX]
  2030. ADD AX,DX
  2031. ADD AX,DX ; AX = y2[i] + 2*hy[i]
  2032. MOV WORD PTR [ESI],AX
  2033. ADD ESI,2
  2034. ADD EDI,2
  2035. ADD EBX,2
  2036. DEC CX
  2037. JNE UPDAT_LOOP2
  2038. JMP FIN_UPDT
  2039. FACT_NEG:
  2040. MOV AX,WORD PTR [EDI] ; AX = y2[i]
  2041. MOV DX,WORD PTR [EBX]
  2042. SUB AX,DX
  2043. SUB AX,DX ; AX = y2[i] - 2*hy[i]
  2044. MOV WORD PTR [ESI],AX
  2045. ADD ESI,2
  2046. ADD EDI,2
  2047. ADD EBX,2
  2048. DEC CX
  2049. JNE FACT_NEG
  2050. FIN_UPDT:
  2051. }
  2052. }
  2053. #endif
  2054. void update_ltp(short *y1,short *y2,short hy[],short lng,short gdgrd,short fact)
  2055. {
  2056. short arrondi;
  2057. _asm
  2058. {
  2059. MOV ESI,[y1]
  2060. MOV EDI,[y2]
  2061. MOV BX,[fact]
  2062. MOV CX,[gdgrd] ; CX = bit de garde
  2063. ADD CX,0
  2064. JE BDG_NUL
  2065. DEC CL
  2066. SAR BX,CL
  2067. ADD BX,1
  2068. SAR BX,1
  2069. INC CL
  2070. BDG_NUL:
  2071. MOV WORD PTR [ESI],BX
  2072. ADD ESI,2
  2073. ADD CL,11
  2074. MOV AX,1
  2075. SAL AX,CL
  2076. MOV [arrondi],AX ; [BP-2] = arrondi
  2077. INC CL
  2078. SUB WORD PTR [lng],1
  2079. MOV BX,[fact]
  2080. UPDAT_LTP:
  2081. XCHG ESI,[hy]
  2082. MOV AX,WORD PTR [ESI] ; AX = hy[i]
  2083. IMUL BX ; DX:AX = fact*hy
  2084. ADD AX,[arrondi] ;arrondi
  2085. ADC DX,0
  2086. SHRD AX,DX,CL
  2087. ADD AX,WORD PTR [EDI]
  2088. ADD ESI,2 ; increm.
  2089. ADD EDI,2
  2090. XCHG ESI,[hy]
  2091. MOV WORD PTR [ESI],AX
  2092. ADD ESI,2
  2093. SUB WORD PTR [lng],1
  2094. JG UPDAT_LTP
  2095. }
  2096. }
  2097. void proc_gain2(long *corr_ene,long *gain,short bit_garde)
  2098. {
  2099. _asm
  2100. {
  2101. MOV ESI,[corr_ene] ; DS:SI adresse correlation et energie
  2102. MOV EAX,0
  2103. MOV EBX,DWORD PTR [ESI+4] ;EBX = ener
  2104. ADD EBX,0
  2105. JE G_ENER_NULL2
  2106. MOV CX,[bit_garde]
  2107. ADD CL,19
  2108. MOV EAX,DWORD PTR [ESI] ; EAX = corr
  2109. CDQ
  2110. SHLD EDX,EAX,CL ;
  2111. SAL EAX,CL
  2112. IDIV EBX
  2113. G_ENER_NULL2:
  2114. MOV ESI,[gain] ; DS:SI adresse resultat
  2115. MOV DWORD PTR [ESI],EAX
  2116. }
  2117. }
  2118. #if 0
  2119. void proc_gain(long *corr_ene,long *gain)
  2120. {
  2121. _asm
  2122. {
  2123. MOV ESI,[corr_ene] ; DS:SI adresse correlation et energie
  2124. MOV EAX,0
  2125. MOV EBX,DWORD PTR [ESI+4] ;EBX = ener
  2126. ADD EBX,0
  2127. JE G_ENER_NULL
  2128. MOV EAX,DWORD PTR [ESI] ; EAX = corr
  2129. CDQ
  2130. SHLD EDX,EAX,13
  2131. SAL EAX,13
  2132. IDIV EBX
  2133. G_ENER_NULL:
  2134. MOV ESI,[gain] ; DS:SI adresse resultat
  2135. MOV DWORD PTR [ESI],EAX
  2136. }
  2137. }
  2138. #else
  2139. void proc_gain(long *corr_ene,long gain)
  2140. {
  2141. _asm
  2142. {
  2143. MOV ESI,[corr_ene]
  2144. MOV EAX,0
  2145. MOV EBX,DWORD PTR [ESI+4] ;EBX = energy
  2146. ADD EBX,0
  2147. JLE G_ENER_NULL ; REPLACED JE BY JLE: ENERGY MUST BE POSITIVE
  2148. MOV EAX,DWORD PTR [ESI] ; EAX = correlation
  2149. CDQ
  2150. SHLD EDX,EAX,13
  2151. SAL EAX,13
  2152. ; ----------------------------------------------
  2153. ; AT THIS POINT, EDX:EAX contains the dividend, EBX the divisor. HERE IS THE ADDED CHECK
  2154. MOV ECX,EDX ; COPY EDX IN ECX
  2155. CMP ECX,0 ; CHECK SIGN OF ECX
  2156. JGE G_CORR_POS
  2157. NEG ECX ; IF ECX IS NEGATIVE, TAKE ABS(ECX)
  2158. SAL ECX,2 ; AND COMPARE ECX<<2 WITH EBX
  2159. CMP ECX,EBX ; IF (ECX<<2) >= EBX, THERE IS A RISK OF OVERFLOW,
  2160. JL G_NO_OVERFLOW ; IN THAT CASE WE SAVE A BIG VALUE IN EAX
  2161. MOV EAX,-2147483647 ; (NEGATIVE BECAUSE EDX<0)
  2162. JMP G_ENER_NULL ; AND WE EXIT
  2163. G_CORR_POS:
  2164. SAL ECX,2
  2165. CMP ECX,EBX ; THE SAME CHECKING FOR THE CASE EDX>0
  2166. JL G_NO_OVERFLOW ; BUT HERE WE SAVE A BIG POSITIVE VALUE
  2167. MOV EAX,2147483647 ; IN CASE OF OVERFLOW
  2168. JMP G_ENER_NULL
  2169. G_NO_OVERFLOW:
  2170. ; END OF ADDED CODE
  2171. ;-------------------------------------------------
  2172. IDIV EBX ; IF THERE IS NO RISK OF OVERFLOW, WE MAKE THE DIV
  2173. G_ENER_NULL:
  2174. MOV ESI,[gain]
  2175. MOV DWORD PTR [ESI],EAX
  2176. }
  2177. }
  2178. #endif
  2179. void decode_dic(short *code,short dic,short npuls)
  2180. {
  2181. _asm
  2182. {
  2183. MOV ESI,[code]
  2184. MOVSX ECX,[npuls]
  2185. DEC ECX
  2186. ADD ECX,ECX ; CX = deplacement
  2187. ADD ESI,ECX
  2188. MOV BX,[dic] ; BX = Dictionnaire
  2189. MOV AX,1 ; AX = Mask
  2190. MOV CX,[npuls] ; CX : compteur
  2191. DEC CX
  2192. dic_loop:
  2193. MOV DX,BX ; DX = dec
  2194. AND DX,AX ; Masquer
  2195. JNZ NO_NUL ; Saut si non null
  2196. MOV WORD PTR [ESI],-1
  2197. JMP NDAO
  2198. NO_NUL:
  2199. MOV WORD PTR [ESI],1
  2200. NDAO:
  2201. SUB ESI,2
  2202. ADD AX,AX
  2203. DEC CX
  2204. JNE dic_loop
  2205. }
  2206. }
  2207. void dsynthesis(long *z,short *coef,short *input,short *output,
  2208. short lng,short netages)
  2209. {
  2210. short depl,count;
  2211. _asm
  2212. {
  2213. MOV CX,[netages] ; CX = filter order
  2214. ADD CX,CX ;Dfinir un Deplacement d'adresse vect. source
  2215. MOV [depl],CX ; [BP-2] = deplacement
  2216. DSYNTH_GEN:
  2217. MOV EDI,[z]
  2218. MOV ESI,[input] ; FS:[SI] input
  2219. MOVSX EBX,WORD PTR [ESI] ; EBX = entre
  2220. NEG EBX
  2221. SAL EBX,16
  2222. ADD DWORD PTR [input],2 ; increm.
  2223. MOV DWORD PTR [EDI],EBX ; mise jour mmoire
  2224. MOV ESI,[coef]
  2225. MOVSX ECX,[depl]
  2226. ADD ESI,ECX
  2227. ADD EDI,ECX
  2228. ADD EDI,ECX
  2229. MOV CX,[netages] ;Charger ordre du filtre
  2230. MOV [count],CX
  2231. MOV EBX,0
  2232. MOV ECX,0
  2233. DSYNTHL:
  2234. MOV EAX,DWORD PTR [EDI] ;EAX = Zi
  2235. MOV DWORD PTR [EDI+4],EAX ;update memory
  2236. MOVSX EDX,WORD PTR [ESI] ;EDX = Ai
  2237. IMUL EDX ;EDX:EAX = Zi*Ai
  2238. SUB ECX,EAX
  2239. SBB EBX,EDX ;Acc en EBX:ECX
  2240. SUB EDI,4 ;Incrementer
  2241. SUB ESI,2 ;
  2242. SUB WORD PTR [count],1
  2243. JGE DSYNTHL
  2244. ADD ECX,512
  2245. ADC EBX,0
  2246. SHLD EBX,ECX,22
  2247. ADD EDI,8
  2248. MOV DWORD PTR [EDI],EBX ; mise jour mmoire
  2249. MOV ESI,[output]
  2250. ADD EBX,32768
  2251. SAR EBX,16
  2252. MOV WORD PTR [ESI],BX ; sauver output
  2253. ADD DWORD PTR [output],2
  2254. SUB WORD PTR [lng],1 ;decrem compt
  2255. JG DSYNTH_GEN
  2256. }
  2257. }
  2258. void synthesis(short *z,short *coef,short *input,short *output,
  2259. short lng,short netages,short bdgrd )
  2260. {
  2261. short depl,count,coeff;
  2262. _asm
  2263. {
  2264. MOV CX,[netages] ; CX = filter order
  2265. ADD CX,CX ;Dfinir un Deplacement d'adresse vect. source
  2266. MOV [depl],CX ; [BP-2] = deplacement
  2267. MOV ESI,[coef]
  2268. MOV AX,WORD PTR [ESI]
  2269. MOV [coeff],AX
  2270. MOV CX,[bdgrd]
  2271. SAR AX,CL
  2272. MOV WORD PTR [ESI],AX
  2273. SYNTH_GEN:
  2274. MOV EDI,[z]
  2275. MOV ESI,[input] ; FS:[SI] input
  2276. MOV BX,WORD PTR [ESI] ; BX = entre
  2277. NEG BX
  2278. ADD DWORD PTR [input],2 ; increm.
  2279. MOV WORD PTR [EDI],BX ; mise jour mmoire
  2280. MOV ESI,[coef]
  2281. ADD SI,[depl]
  2282. ADD DI,[depl]
  2283. MOV CX,[netages] ;Charger ordre du filtre
  2284. MOV [count],CX
  2285. MOV CX,0
  2286. MOV BX,0
  2287. SYNTHL:
  2288. MOV AX,WORD PTR [EDI] ;AX = Zi
  2289. MOV WORD PTR [EDI+2],AX ;update memory
  2290. MOV DX,WORD PTR [ESI] ;DX = Ai
  2291. IMUL DX ;DX:AX = Zi*Ai
  2292. SUB BX,AX
  2293. SBB CX,DX ;acc. en CX:BX
  2294. SUB EDI,2 ;Incrementer
  2295. SUB ESI,2 ;
  2296. SUB WORD PTR [count],1 ;Decrem. compt.
  2297. JGE SYNTHL
  2298. ADD BX,512 ;arrondi
  2299. ADC CX,0
  2300. SHRD BX,CX,10
  2301. ADD EDI,4
  2302. MOV WORD PTR [EDI],BX ; mise jour mmoire
  2303. MOV ESI,[output]
  2304. MOV WORD PTR [ESI],BX ; sauver output
  2305. ADD DWORD PTR [output],2
  2306. SUB WORD PTR [lng],1 ;Decrem. compt.
  2307. JG SYNTH_GEN
  2308. MOV ESI,[coef]
  2309. MOV AX,[coeff]
  2310. MOV WORD PTR [ESI],AX
  2311. }
  2312. }
  2313. void synthese(short *z,short *coef,short *input,short *output,
  2314. short lng,short netages)
  2315. {
  2316. short depl,count;
  2317. _asm
  2318. {
  2319. MOV CX,[netages] ; CX = filter order
  2320. ADD CX,CX ;Dfinir un Deplacement d'adresse vect. source
  2321. MOV [depl],CX ; [BP-2] = deplacement
  2322. SYNTH_GEN2:
  2323. MOV EDI,[z]
  2324. MOV ESI,[input] ; FS:[SI] input
  2325. MOV BX,WORD PTR [ESI] ; BX = entre
  2326. NEG BX
  2327. ADD DWORD PTR [input],2 ; increm.
  2328. MOV WORD PTR [EDI],BX ; mise jour mmoire
  2329. MOV ESI,[coef]
  2330. ADD SI,[depl]
  2331. ADD DI,[depl]
  2332. MOV CX,[netages] ;Charger ordre du filtre
  2333. MOV [count],CX
  2334. MOV CX,0
  2335. MOV BX,0
  2336. SYNTHL2:
  2337. MOV AX,WORD PTR [EDI] ;AX = Zi
  2338. MOV WORD PTR [EDI+2],AX ;update memory
  2339. MOV DX,WORD PTR [ESI] ;DX = Ai
  2340. IMUL DX ;DX:AX = Zi*Ai
  2341. SUB BX,AX
  2342. SBB CX,DX ;acc. en CX:BX
  2343. SUB EDI,2 ;Incrementer
  2344. SUB ESI,2 ;
  2345. SUB WORD PTR [count],1 ;Decrem. compt.
  2346. JGE SYNTHL2
  2347. ADD BX,512 ;arrondi
  2348. ADC CX,0
  2349. SHRD BX,CX,10
  2350. ADD EDI,4
  2351. MOV WORD PTR [EDI],BX ; mise jour mmoire
  2352. MOV ESI,[output]
  2353. MOV WORD PTR [ESI],BX ; sauver output
  2354. ADD DWORD PTR [output],2
  2355. SUB WORD PTR [lng],1 ;Decrem. compt.
  2356. JG SYNTH_GEN2
  2357. }
  2358. }
  2359. void f_inverse(short *z,short *coef,short *input,short *output,
  2360. short lng,short netages )
  2361. {
  2362. short depl,count;
  2363. _asm
  2364. {
  2365. MOV CX,[netages] ; CX = filter order
  2366. ADD CX,CX ; Dfinir un Deplacement d'adresse vect. source
  2367. MOV [depl],CX ; [BP-2] = deplacement
  2368. INVER_GEN:
  2369. MOV EDI,[z]
  2370. MOV ESI,[input] ; FS:[SI] input
  2371. MOV BX,WORD PTR [ESI] ; BX = entre
  2372. ADD DWORD PTR [input],2 ; increm.
  2373. MOV WORD PTR [EDI],BX ; mise jour mmoire
  2374. MOV ESI,[coef]
  2375. ADD SI,[depl]
  2376. ADD DI,[depl]
  2377. MOV CX,[netages] ;Charger ordre du filtre
  2378. MOV [count],CX ;BP-4 : compteur
  2379. MOV CX,0
  2380. MOV BX,0
  2381. INVERL:
  2382. MOV AX,WORD PTR [EDI] ;AX = Zi
  2383. MOV WORD PTR [EDI+2],AX ;update memory
  2384. MOV DX,WORD PTR [ESI] ;DX = Ai
  2385. IMUL DX ;DX:AX = Zi*Ai
  2386. ADD CX,AX
  2387. ADC BX,DX ; acc. en BX:CX
  2388. SUB EDI,2 ;Incrementer
  2389. SUB ESI,2 ;
  2390. SUB WORD PTR [count],1
  2391. JGE INVERL
  2392. MOV ESI,[output]
  2393. ADD CX,512 ;arrondi
  2394. ADC BX,0
  2395. SHRD CX,BX,10
  2396. MOV WORD PTR [ESI],CX ; sauver output
  2397. ADD DWORD PTR [output],2
  2398. SUB WORD PTR [lng],1 ;decrem.
  2399. JG INVER_GEN
  2400. }
  2401. }
  2402. void filt_iir(long *zx,long *ai,short *Vin,short *Vout,short lfen,short ordre)
  2403. {
  2404. long off_coef,off_mem,delta;
  2405. long acc_low;
  2406. _asm
  2407. {
  2408. MOVSX ECX,[ordre] ;ordre du filtre
  2409. SAL ECX,3 ;Dfinir un Deplacement d'adresse
  2410. MOV [off_coef],ECX ; [OFF_COEF] = deplacement pour coeff
  2411. ADD ECX,4
  2412. MOV [off_mem],ECX ; [OFF_MEM] = depl. pour mem.
  2413. ADD ECX,20
  2414. SAR ECX,1
  2415. MOV [delta],ECX
  2416. IIR_FIL:
  2417. MOV CX,[ordre] ;init compteur
  2418. MOV EBX,[Vin] ; BX = offset input
  2419. MOVSX EDX,WORD PTR [EBX] ; EDX = input avec extension de signe
  2420. ADD DWORD PTR [Vin],2 ; incrmenter l'offset de input
  2421. MOV ESI,[zx] ; DS:SI pointe zx
  2422. MOV DWORD PTR [ESI],EDX ; mettre jour zx
  2423. MOV EDI,[ai] ; ES:DI pointe coeff
  2424. ADD EDI,[off_coef]
  2425. ADD ESI,[off_mem]
  2426. MOV DWORD PTR [acc_low],0 ; initialiser ACC_LOW 0
  2427. SUB EBX,EBX ; init EBX = 0
  2428. F_IIR_Y:
  2429. MOV EAX,DWORD PTR [ESI] ;EAX = *zx
  2430. MOV DWORD PTR [ESI+4],EAX ;mettre jour zx
  2431. MOV EDX,DWORD PTR [EDI] ;EDX = coeff
  2432. IMUL EDX ;EDX:EAX = zx*coeff
  2433. SUB [acc_low],EAX ; accumuler les LSB
  2434. SBB EBX,EDX ; acc avec borrow les MSB
  2435. SUB EDI,4 ;Incrementer
  2436. SUB ESI,4 ;
  2437. DEC CX
  2438. JNE F_IIR_Y
  2439. SUB ESI,4
  2440. MOV CX,[ordre] ;Charger ordre du filtre
  2441. INC CX
  2442. F_IIR_X:
  2443. MOV EAX,DWORD PTR [ESI] ;EAX = *zy
  2444. MOV DWORD PTR [ESI+4],EAX ;update zy
  2445. MOV EDX,DWORD PTR [EDI] ;EDX = coeff
  2446. IMUL EDX ;EDS:EAX = zy*coeff
  2447. ADD [acc_low],EAX ;acc LSB
  2448. ADC EBX,EDX ;acc avec carry MSB
  2449. SUB EDI,4 ;Decrementer
  2450. SUB ESI,4 ;
  2451. DEC CX
  2452. JNE F_IIR_X
  2453. MOV EAX,[delta]
  2454. ADD ESI,EAX
  2455. MOV EAX,[acc_low] ; EAX = LSB de l'acc.
  2456. ADD EAX,8192 ; arrondi
  2457. ADC EBX,0
  2458. SHRD EAX,EBX,14 ; cadrer
  2459. MOV DWORD PTR [ESI],EAX ; mettre jour zy
  2460. SAR EAX,14 ; cadrer en x4.0
  2461. ; logique saturante
  2462. CMP EAX,32767
  2463. JG SATUR_POS ; jump if ov
  2464. CMP EAX,-32767
  2465. JL SATUR_NEG
  2466. JMP NEXT
  2467. SATUR_POS:
  2468. MOV AX,32767
  2469. JMP NEXT
  2470. SATUR_NEG:
  2471. MOV AX,-32767
  2472. JMP NEXT
  2473. NEXT:
  2474. MOV ESI,[Vout] ;di offset output
  2475. MOV WORD PTR [ESI],AX ;sauver output
  2476. ADD DWORD PTR [Vout],2 ;incrmenter offset
  2477. SUB WORD PTR [lfen],1
  2478. JNZ IIR_FIL
  2479. }
  2480. }
  2481. #if 0
  2482. // PhilF: The following is never called!!!
  2483. void filt_iir_a(long *zx,long *ai,short *Vin,short *Vout,short lfen,short ordre)
  2484. {
  2485. short off_coef,off_mem,delta;
  2486. long acc_low;
  2487. _asm
  2488. {
  2489. MOV CX,[ordre] ;ordre du filtre
  2490. SAL CX,3 ;Dfinir un Deplacement d'adresse
  2491. MOV [off_coef],CX ; [OFF_COEF] = deplacement pour coeff
  2492. ADD CX,4
  2493. MOV [off_mem],CX ; [OFF_MEM] = depl. pour mem.
  2494. ADD CX,20
  2495. SAR CX,1
  2496. MOV [delta],CX
  2497. A_IIR_FIL:
  2498. MOV CX,[ordre] ;init compteur
  2499. MOV EBX,[Vin] ; BX = offset input
  2500. MOVSX EDX,WORD PTR [EBX] ; EDX = input avec extension de signe
  2501. ADD WORD PTR [Vin],2 ; incrmenter l'offset de input
  2502. MOV ESI,[zx] ; DS:SI pointe zx
  2503. MOV DWORD PTR [ESI],EDX ; mettre jour zx
  2504. MOV EDI,[ai] ; ES:DI pointe coeff
  2505. ADD DI,[off_coef]
  2506. ADD SI,[off_mem]
  2507. MOV DWORD PTR [acc_low],0 ; initialiser ACC_LOW 0
  2508. SUB EBX,EBX ; init EBX = 0
  2509. F_IIR_Y_A:
  2510. MOV EAX,DWORD PTR [ESI] ;EAX = *zx
  2511. MOV DWORD PTR [ESI+4],EAX ;mettre jour zx
  2512. MOV EDX,DWORD PTR [EDI] ;EDX = coeff
  2513. IMUL EDX ;EDX:EAX = zx*coeff
  2514. SUB [acc_low],EAX ; accumuler les LSB
  2515. SBB EBX,EDX ; acc avec borrow les MSB
  2516. SUB EDI,4 ;Incrementer
  2517. SUB ESI,4 ;
  2518. DEC CX
  2519. JNE F_IIR_Y_A
  2520. SUB ESI,4
  2521. MOV CX,[ordre] ;Charger ordre du filtre
  2522. INC CX
  2523. F_IIR_X_A:
  2524. MOV EAX,DWORD PTR [ESI] ;EAX = *zy
  2525. MOV DWORD PTR [ESI+4],EAX ;update zy
  2526. MOV EDX,DWORD PTR [EDI] ;EDX = coeff
  2527. IMUL EDX ;EDS:EAX = zy*coeff
  2528. ADD [acc_low],EAX ;acc LSB
  2529. ADC EBX,EDX ;acc avec carry MSB
  2530. SUB EDI,4 ;Decrementer
  2531. SUB ESI,4 ;
  2532. DEC CX
  2533. JNE F_IIR_X_A
  2534. MOVSX EAX,[delta]
  2535. ADD ESI,EAX
  2536. MOV EAX,[acc_low] ; EAX = LSB de l'acc.
  2537. ADD EAX,8192 ; arrondi
  2538. ADC EBX,0
  2539. SHRD EAX,EBX,14 ; cadrer
  2540. MOV DWORD PTR [ESI],EAX ; mettre jour zy
  2541. ADD EAX,32768
  2542. SAR EAX,16 ; cadrer en x4.0
  2543. MOV ESI,[Vout] ;di offset output
  2544. MOV WORD PTR [ESI],AX ;sauver output
  2545. ADD WORD PTR [Vout],2 ;incrmenter offset
  2546. SUB WORD PTR [lfen],1
  2547. JNZ A_IIR_FIL
  2548. }
  2549. }
  2550. #endif
  2551. void mult_fact(short src[],short dest[],short fact,short lng)
  2552. {
  2553. _asm
  2554. {
  2555. MOV ESI,[src]
  2556. MOV EDI,[dest]
  2557. MOV BX,[fact] ; BX = Factor
  2558. MOV CX,[lng] ; init compteur
  2559. MULT_F:
  2560. MOV AX,WORD PTR [ESI] ; AX = src
  2561. IMUL BX ; DX:AX = src*fact
  2562. ADD AX,4096
  2563. ADC DX,0
  2564. SHRD AX,DX,13 ; cadrer
  2565. MOV WORD PTR [EDI],AX ;save
  2566. ADD ESI,2 ;incrmenter
  2567. ADD EDI,2
  2568. DEC CX
  2569. JNE MULT_F
  2570. }
  2571. }
  2572. void mult_f_acc(short src[],short dest[],short fact,short lng)
  2573. {
  2574. _asm
  2575. {
  2576. MOV EDI,[src]
  2577. MOV ESI,[dest]
  2578. MOV BX,[fact] ; BX = Factor
  2579. MOV CX,[lng] ; init compteur
  2580. MULT_F_A:
  2581. MOV AX,WORD PTR [EDI] ; AX = src
  2582. IMUL BX ; DX:AX = src*fact
  2583. ADD AX,4096
  2584. ADC DX,0
  2585. SHRD AX,DX,13 ; cadrer
  2586. ADD WORD PTR [ESI],AX ; Accumuler dest = dest + src*fact
  2587. ADD ESI,2 ;incrmenter
  2588. ADD EDI,2
  2589. DEC CX
  2590. JNE MULT_F_A
  2591. }
  2592. }
  2593. void dec_lsp(short *code,short *tablsp,short *nbit,short *bitdi,short *tabdi)
  2594. {
  2595. short compt;
  2596. long pointer;
  2597. _asm
  2598. {
  2599. MOV EDI,[tablsp]
  2600. MOV ESI,[code]
  2601. MOVSX EBX,WORD PTR [ESI] ; BX = depl.
  2602. ADD EBX,EBX
  2603. MOV AX,WORD PTR [EDI+EBX] ; AX = code[0];
  2604. MOV WORD PTR [ESI],AX ;
  2605. ADD ESI,4 ;
  2606. MOV CX,4 ; init compteur
  2607. LSP_PAIR:
  2608. MOV EBX,[nbit] ; lsptab += nbit[i]
  2609. MOVSX EAX,WORD PTR [EBX] ; AX = nbit[i]
  2610. ADD EAX,EAX
  2611. ADD EDI,EAX ;
  2612. ADD EBX,2 ; increm
  2613. MOV [nbit],EBX
  2614. MOVSX EBX,WORD PTR [ESI] ; BX = depl.
  2615. ADD EBX,EBX
  2616. MOV AX,WORD PTR [EDI+EBX] ; AX = code[i];
  2617. MOV WORD PTR [ESI],AX ;
  2618. ADD ESI,4
  2619. DEC CX
  2620. JNE LSP_PAIR
  2621. ADD DWORD PTR [nbit],2
  2622. MOV EDI,[tabdi]
  2623. SUB ESI,20 ; pointer code[0]
  2624. MOV WORD PTR [compt],5
  2625. REPEAT_DEC:
  2626. MOV EBX,[bitdi]
  2627. MOV CX,WORD PTR [EBX] ;
  2628. MOV BX,WORD PTR [ESI+4] ; BX = lsp[2*k+2]
  2629. SUB BX,WORD PTR [ESI] ; = lsp[2*k+2]-lsp[2*k] = delta
  2630. ; ne pas faire /2 --> pas de corr. signe *
  2631. MOV EAX,[nbit]
  2632. MOV [pointer],EAX
  2633. LOOP_DI1:
  2634. MOV AX,WORD PTR [EDI] ; AX = TABDI
  2635. ADD EDI,2
  2636. IMUL BX ; DX:AX = tabdi * delta
  2637. ADD AX,32768
  2638. ADC DX,0 ;arrondi
  2639. ADD DX,WORD PTR [ESI]
  2640. XCHG ESI,[pointer]
  2641. MOV WORD PTR [ESI],DX ; sauver
  2642. ADD ESI,2
  2643. XCHG ESI,[pointer]
  2644. DEC CX
  2645. JNE LOOP_DI1
  2646. MOV DX,BX
  2647. MOV EBX,[bitdi]
  2648. MOV CX,WORD PTR [EBX] ;
  2649. ADD ESI,4
  2650. SUB CX,2
  2651. JLE IALAO
  2652. MOV BX,DX
  2653. NEG BX
  2654. LOOP_DI2:
  2655. MOV AX,WORD PTR [EDI] ; AX = TABDI
  2656. ADD EDI,2
  2657. IMUL BX ; DX:AX = tabdi * delta
  2658. ADD DX,WORD PTR [ESI]
  2659. XCHG ESI,[pointer]
  2660. MOV WORD PTR [ESI],DX ; sauver
  2661. ADD ESI,2
  2662. XCHG ESI,[pointer]
  2663. DEC CX
  2664. JNE LOOP_DI2
  2665. IALAO:
  2666. ADD DWORD PTR [bitdi],2 ;
  2667. MOV EBX,[nbit] ; BX = adresse de veclsp
  2668. SUB ESI,2 ; pointer code[2*k+1]
  2669. MOVSX EAX,WORD PTR [ESI]
  2670. ADD EAX,EAX ; AX = depl.
  2671. ADD EBX,EAX
  2672. MOV AX,WORD PTR [EBX] ; AX = veclsp[code[2*k+1]
  2673. MOV WORD PTR [ESI],AX
  2674. ADD ESI,2
  2675. SUB WORD PTR [compt],1
  2676. JNZ REPEAT_DEC
  2677. }
  2678. }
  2679. void teta_to_cos(short *tabcos,short *lsp,short netages)
  2680. {
  2681. short norm,arrondi,ptm1,lts2;
  2682. _asm
  2683. {
  2684. MOV EDI,[lsp]
  2685. MOV CX,[netages] ;init compteur
  2686. TETA_LOOP:
  2687. MOV AX,WORD PTR [EDI] ; AX = lsp[i]
  2688. CMP AX,04000H ; comparer 4000h
  2689. JLE INIT_VAL ;
  2690. NEG AX
  2691. ADD AX,32767 ; prendre le complment
  2692. INIT_VAL:
  2693. MOV ESI,[tabcos]
  2694. CMP AX,0738H ; comparer
  2695. JG BIGTABLE
  2696. ;SMALLTAB:
  2697. ADD ESI,550 ; pointer tabteta2
  2698. MOV WORD PTR [ptm1],3
  2699. MOV WORD PTR [lts2],16
  2700. MOV WORD PTR [arrondi],512
  2701. MOV WORD PTR [norm],10
  2702. JMP DEBUT_LP
  2703. BIGTABLE:
  2704. ADD ESI,258 ; pointer tabteta1
  2705. MOV WORD PTR [ptm1],6
  2706. MOV WORD PTR [lts2],128
  2707. MOV WORD PTR [arrondi],64
  2708. MOV WORD PTR [norm],7
  2709. DEBUT_LP:
  2710. MOVSX EDX,[lts2] ; init incrment
  2711. ADD ESI,EDX ; SI = index
  2712. MOV CX,[ptm1]
  2713. LOCAL_L:
  2714. SAR EDX,1 ; increm >> 1
  2715. CMP AX,WORD PTR [ESI]
  2716. JG ADD_INCRM
  2717. SUB ESI,EDX
  2718. JMP AURORA
  2719. ADD_INCRM:
  2720. ADD ESI,EDX
  2721. AURORA:
  2722. DEC CX
  2723. JNE LOCAL_L
  2724. CMP AX,WORD PTR [ESI]
  2725. JG INTERP_V
  2726. SUB ESI,2
  2727. INTERP_V:
  2728. SUB AX,WORD PTR [ESI] ; AX = teta - tabteta[index]
  2729. MOV DX,AX
  2730. MOV AX,0
  2731. MOV CX,WORD PTR [ESI+2]
  2732. SUB CX,WORD PTR [ESI] ; CX = tabteta[index+1]-tabteta[index]
  2733. ADD CX,CX ; multiplier par 2 pour ne pas SHRD de DX:AX
  2734. DIV CX
  2735. ADD AX,[arrondi] ;
  2736. MOV CX,[norm] ; CX = normalisation
  2737. SAR AX,CL
  2738. NEG AX
  2739. CMP CX,7
  2740. JE GRAN_TAB
  2741. SUB ESI,34
  2742. ADD AX,WORD PTR [ESI] ;AX = tabcos[index]+delta
  2743. JMP ADD_SIGN
  2744. GRAN_TAB:
  2745. SUB ESI,258
  2746. ADD AX,WORD PTR [ESI] ;AX = tabcos[index]+delta
  2747. ADD_SIGN:
  2748. CMP WORD PTR [EDI],04000H
  2749. JLE END_LOOP
  2750. NEG AX
  2751. END_LOOP:
  2752. MOV WORD PTR [EDI],AX ; save cos
  2753. ADD EDI,2
  2754. SUB WORD PTR [netages],1
  2755. JG TETA_LOOP
  2756. }
  2757. }
  2758. void cos_to_teta(short *tabcos,short *lsp,short netages)
  2759. {
  2760. _asm
  2761. {
  2762. MOV EDI,[lsp]
  2763. MOV CX,[netages] ;init compteur
  2764. COS_LOOP:
  2765. MOV ESI,[tabcos]
  2766. ADD ESI,258
  2767. MOV AX,WORD PTR [EDI] ; AX = lsp[i]
  2768. ADD AX,0
  2769. JGE DEBUT_CS ; prendre ABS
  2770. NEG AX
  2771. DEBUT_CS:
  2772. CMP AX,07DFFH ; comparer 7DFFh
  2773. JGE TABLE2
  2774. ;TABLE1:
  2775. MOV BX,AX
  2776. AND BX,0FFH ; BX = cos & mask
  2777. MOV CL,8
  2778. SAR AX,CL
  2779. ADD AX,AX
  2780. MOV EDX,256 ; BX index
  2781. SUB DX,AX
  2782. ADD ESI,EDX
  2783. MOV AX,WORD PTR [ESI] ; AX=teta[index]
  2784. SUB AX,WORD PTR [ESI-2] ;
  2785. IMUL BX
  2786. ADD AX,128
  2787. ADC DX,0
  2788. SHRD AX,DX,8 ; cadrer
  2789. NEG AX
  2790. MOV BX,WORD PTR [ESI]
  2791. ADD AX,BX
  2792. MOV BX,WORD PTR [EDI] ; tester signe de lsp
  2793. ADD BX,0
  2794. JGE END_COS
  2795. NEG AX
  2796. ADD AX,07FFFH ; AX = 7fff-AX
  2797. JMP END_COS
  2798. TABLE2:
  2799. ADD ESI,292 ; pointer tabteta2
  2800. MOV BX,AX ; BX = AX
  2801. SUB AX,07DFFH ; retirer delta
  2802. MOV CL,5
  2803. SAR AX,CL
  2804. ADD AX,AX
  2805. MOV EDX,32 ; DX index
  2806. SUB DX,AX
  2807. ADD ESI,EDX
  2808. MOV AX,WORD PTR [ESI] ; AX=teta2[index]
  2809. CMP BX,AX
  2810. JGE NO_INCRM
  2811. ADD ESI,2
  2812. NO_INCRM:
  2813. MOV AX,WORD PTR [ESI] ; AX=teta2[index]
  2814. MOV CX,AX ; pour plus tard
  2815. SUB AX,WORD PTR [ESI-2] ;
  2816. SUB ESI,34 ; pointer tabcos2
  2817. SUB BX,WORD PTR [ESI] ;
  2818. IMUL BX
  2819. ADD AX,16
  2820. ADC DX,0
  2821. SHRD AX,DX,5 ; cadrer
  2822. NEG AX
  2823. ADD AX,CX ; AX = cos + delta
  2824. MOV BX,WORD PTR [EDI] ; tester signe de lsp
  2825. ADD BX,0
  2826. JGE END_COS
  2827. NEG AX
  2828. ADD AX,07FFFH ; AX = 7fff-AX
  2829. END_COS:
  2830. MOV WORD PTR [EDI],AX ;
  2831. ADD EDI,2
  2832. SUB WORD PTR [netages],1
  2833. JG COS_LOOP
  2834. }
  2835. }
  2836. void lsp_to_ai(short *ai_lsp,long *tmp,short netages)
  2837. {
  2838. short cmptr;
  2839. long index;
  2840. _asm
  2841. {
  2842. MOV ESI,[tmp]
  2843. MOV EBX,ESI
  2844. ADD EBX,4*11 ;DS:BX vect. Q
  2845. MOV EDI,[ai_lsp]
  2846. ;LSP_AI:
  2847. MOV DWORD PTR [ESI],0400000H ; P(0) = 1
  2848. MOV DWORD PTR [ESI+8],0400000H ; P(2) = 1
  2849. MOV DWORD PTR [EBX],0400000H ; Q(0) = 1
  2850. MOV DWORD PTR [EBX+8],0400000H ; Q(2) = 1
  2851. MOVSX EAX,WORD PTR [EDI] ; EAX = lsp(0)
  2852. SAL EAX,8
  2853. NEG EAX ; EAX = -lsp(0)>>8
  2854. MOV DWORD PTR [ESI+4],EAX ;P(1) = EAX
  2855. MOVSX EAX,WORD PTR [EDI+2] ; EAX = lsp(1)
  2856. SAL EAX,8
  2857. NEG EAX ; EAX = -lsp(1)>>8
  2858. MOV DWORD PTR [EBX+4],EAX ; Q(1) = EAX
  2859. MOV WORD PTR [cmptr],1 ;init compteur
  2860. SUB WORD PTR [netages],2
  2861. ADD EBX,8
  2862. MOV [index],EBX ; sauver BX = i
  2863. ADD ESI,8 ; DS:SI P(2)
  2864. ADD EDI,4 ; ES:DI lsp(2)
  2865. MOV CX,[netages]
  2866. GL_LOOP:
  2867. MOV [netages],CX
  2868. MOV DWORD PTR [ESI+8],0400000H ; P(i+2) = 1
  2869. MOVSX EAX,WORD PTR [EDI] ; EAX = lsp(i)
  2870. MOV EBX,EAX ; memoriser lsp(i)
  2871. SAL EAX,8
  2872. MOV ECX,DWORD PTR [ESI-4] ; ECX = P(i-1)
  2873. SUB ECX,EAX ; ECX = P(i-1) - lsp(i)<<8
  2874. MOV DWORD PTR [ESI+4],ECX ; P(i+1)=ECX
  2875. MOV CX,[cmptr] ;
  2876. LOCAL_P:
  2877. MOV EAX,DWORD PTR [ESI-4] ; EAX = P(j-1)
  2878. IMUL EBX ; EDX:EAX = P(j-1)*lsp(i)
  2879. ADD EAX,8192
  2880. ADC EDX,0
  2881. SHRD EAX,EDX,14 ; EAX = 2*P(j-1)*lsp(i)
  2882. SUB DWORD PTR [ESI],EAX ; P(j)=P(j)-EAX
  2883. MOV EAX,DWORD PTR [ESI-8] ; EAX = P(j-2)
  2884. ADD DWORD PTR [ESI],EAX ; P(j) += P(j-2)
  2885. SUB ESI,4
  2886. DEC CX
  2887. JNE LOCAL_P
  2888. ; DS:SI pointe P(1)
  2889. MOV EAX,DWORD PTR [ESI-4] ; EAX = P(0)
  2890. IMUL EBX ; EDX:EAX = P(0)*lsp(i)
  2891. ADD EAX,8192
  2892. ADC EDX,0
  2893. SHRD EAX,EDX,14 ; EAX = 2*P(0)*lsp(i)
  2894. SUB DWORD PTR [ESI],EAX ; P(1) = P(1)-2*P(0)*lsp(i)
  2895. XCHG ESI,[index] ; DS:SI pointe Q(j)
  2896. MOV DWORD PTR [ESI+8],0400000H ; Q(i+2) = 1
  2897. MOVSX EAX,WORD PTR [EDI+2] ; EAX = lsp(i+1)
  2898. MOV EBX,EAX ; memoriser lsp(i+1)
  2899. SAL EAX,8
  2900. MOV ECX,DWORD PTR [ESI-4] ; ECX = Q(i-1)
  2901. SUB ECX,EAX ; ECX = Q(i-1) - lsp(i+1)<<8
  2902. MOV DWORD PTR [ESI+4],ECX ; Q(i+1)=ECX
  2903. MOV CX,[cmptr] ;
  2904. LOCAL_Q:
  2905. MOV EAX,DWORD PTR [ESI-4] ; EAX = Q(j-1)
  2906. IMUL EBX ; EDX:EAX = Q(j-1)*lsp(i+1)
  2907. ADD EAX,8192
  2908. ADC EDX,0
  2909. SHRD EAX,EDX,14 ; EAX = 2*Q(j-1)*lsp(i+1)
  2910. SUB DWORD PTR [ESI],EAX ; Q(j)=Q(j)-EAX
  2911. MOV EAX,DWORD PTR [ESI-8] ; EAX = Q(j-2)
  2912. ADD DWORD PTR [ESI],EAX ; Q(j) += Q(j-2)
  2913. SUB ESI,4
  2914. DEC CX
  2915. JNE LOCAL_Q
  2916. ; DS:SI pointe Q(1)
  2917. MOV EAX,DWORD PTR [ESI-4] ; EAX = Q(0)
  2918. IMUL EBX ; EDX:EAX = Q(0)*lsp(i+1)
  2919. ADD EAX,8192
  2920. ADC EDX,0
  2921. SHRD EAX,EDX,14 ; EAX = 2*Q(0)*lsp(i+1)
  2922. SUB DWORD PTR [ESI],EAX ; Q(1) = Q(1)-2*Q(0)*lsp(i+1)
  2923. MOVSX ECX,[cmptr]
  2924. ADD CX,2
  2925. MOV [cmptr],CX
  2926. SAL ECX,2
  2927. ADD ESI,ECX ; increm. offset de Q
  2928. XCHG ESI,[index] ;
  2929. ADD ESI,ECX ; increm. offset de P
  2930. ADD EDI,4
  2931. MOV CX,[netages]
  2932. SUB CX,2
  2933. JG GL_LOOP
  2934. MOV ESI,[tmp] ;DS:SI vect P
  2935. MOV EBX,ESI
  2936. ADD EBX,4*11 ;DS:BX vect. Q
  2937. MOV EDI,[ai_lsp] ;ES:DI lsp et ai
  2938. MOV WORD PTR [EDI],0400H ; ai(0) = 1
  2939. ADD EDI,2
  2940. MOV CX,10 ; init compteur
  2941. ADD EBX,4 ;
  2942. ADD ESI,4
  2943. CALC_AI:
  2944. MOV EAX,DWORD PTR [ESI] ; EAX = P(i)
  2945. ADD EAX,DWORD PTR [ESI-4] ; +P(i-1)
  2946. ADD EAX,DWORD PTR [EBX] ; +Q(i)
  2947. SUB EAX,DWORD PTR [EBX-4] ; -Q(i-1)
  2948. ADD EAX,01000H ; arrondi
  2949. SAR EAX,13
  2950. MOV WORD PTR [EDI],AX ; save ai
  2951. ADD EDI,2
  2952. ADD ESI,4
  2953. ADD EBX,4
  2954. DEC CX
  2955. JNE CALC_AI
  2956. }
  2957. }
  2958. void ki_to_ai(short *ki,long *ai,short netages)
  2959. {
  2960. short cmptk;
  2961. long indam1,indexk,kiim1;
  2962. _asm
  2963. {
  2964. MOV ESI,[ai]
  2965. MOV EBX,ESI
  2966. ADD EBX,44 ; DS:BX vect. interm.
  2967. MOV EDI,[ki]
  2968. MOV DWORD PTR [ESI],0400000H ; ai(0) = 1
  2969. MOVSX EAX,WORD PTR [EDI] ; EAX = ki(0)
  2970. SAL EAX,7
  2971. MOV DWORD PTR [ESI+4],EAX ; ai(1) = EAX
  2972. ADD ESI,4 ; DS:SI ai(1)
  2973. ADD EBX,8
  2974. ADD EDI,2 ; ES:DI ki(1)
  2975. MOV WORD PTR [cmptk],1
  2976. MOV CX,[netages]
  2977. KI_AI_LP:
  2978. MOV [netages],CX
  2979. MOVSX EAX,WORD PTR [EDI] ; EAX = ki(i-1)
  2980. MOV [kiim1],EAX ; memoriser ki(i-1)
  2981. SAL EAX,7
  2982. MOV DWORD PTR [EBX],EAX ; tmp(i)=EAX
  2983. SUB EBX,4
  2984. MOV [indexk],EBX
  2985. MOVSX ECX,[cmptk] ;
  2986. MOV EBX,ECX
  2987. DEC EBX
  2988. SAL EBX,2 ; DI : deplacement
  2989. MOV [indam1],ESI
  2990. SUB ESI,EBX
  2991. MOV EBX,[indexk]
  2992. LOCAL_AI:
  2993. MOV EAX,DWORD PTR [ESI] ; EAX = ai(i-j)
  2994. IMUL DWORD PTR [kiim1] ; EDX:EAX = ai(i-j)*ki(i-1)
  2995. ADD EAX,16384
  2996. ADC EDX,0
  2997. SHRD EAX,EDX,15 ; EAX = ai(i-j)*ki(i-1)
  2998. ADD ESI,4
  2999. XCHG ESI,[indam1]
  3000. ADD EAX,DWORD PTR [ESI] ; + ai(j)
  3001. SUB ESI,4
  3002. XCHG ESI,[indam1]
  3003. MOV DWORD PTR [EBX],EAX ; tmp(j) = EAX
  3004. SUB EBX,4
  3005. DEC CX
  3006. JNE LOCAL_AI
  3007. XCHG ESI,[indam1]
  3008. MOV CX,[cmptk]
  3009. INC CX
  3010. MOV [cmptk],CX
  3011. ADD ESI,4
  3012. ADD EBX,4
  3013. L_COPY:
  3014. MOV EAX,DWORD PTR [EBX] ; EAX = tmp(i)
  3015. MOV DWORD PTR [ESI],EAX ; ai(i) = EAX
  3016. ADD EBX,4
  3017. ADD ESI,4
  3018. DEC CX
  3019. JNE L_COPY
  3020. ADD EDI,2 ; increm. i
  3021. SUB ESI,4
  3022. MOV CX,[netages]
  3023. DEC CX
  3024. JNE KI_AI_LP
  3025. }
  3026. }
  3027. void ai_to_pq(long *aip,short netages)
  3028. {
  3029. _asm
  3030. {
  3031. MOV ESI,[aip]
  3032. MOV EDI,ESI
  3033. ADD EDI,4*11 ;DS:DI vect. Q
  3034. MOV EDX,DWORD PTR [ESI] ; EAX = ai(0) = P(0)
  3035. MOV DWORD PTR [EDI],EDX ; Q(0) = ai(0)
  3036. MOV CX,[netages]
  3037. MOVSX EBX,CX
  3038. DEC EBX
  3039. SAL EBX,2 ; BX deplacement
  3040. ADD ESI,4
  3041. ADD EDI,4
  3042. SAR CX,1
  3043. AI_LSP1:
  3044. MOV EAX,DWORD PTR [ESI] ; EAX = ai(i) = P(i)
  3045. MOV EDX,EAX ; memoriser
  3046. ADD EAX,DWORD PTR [ESI+EBX] ; + ai(j)
  3047. SUB EAX,DWORD PTR [ESI-4] ; - P(i-1)
  3048. MOV DWORD PTR [ESI],EAX ; P(i)=EAX
  3049. SUB EDX,DWORD PTR [ESI+EBX] ; EDX = ai(i) - ai(j)
  3050. ADD EDX,DWORD PTR [EDI-4] ; - Q(i-1)
  3051. MOV DWORD PTR [EDI],EDX ; Q(i)=EDX
  3052. SUB EBX,8
  3053. ADD ESI,4
  3054. ADD EDI,4
  3055. DEC CX
  3056. JNE AI_LSP1
  3057. MOV ESI,[aip] ;DS:SI vect. PP = P
  3058. MOV EAX,DWORD PTR [ESI+20] ;EAX = P(5)
  3059. ADD EAX,1
  3060. SAR EAX,1
  3061. SUB EAX,DWORD PTR [ESI+12] ;EAX = P(5)/2 - P(3)
  3062. ADD EAX,DWORD PTR [ESI+4] ; + P(1)
  3063. XCHG DWORD PTR [ESI],EAX ; PP(0) = EAX et EAX = P(0)
  3064. MOV EBX,EAX ; save EBX = P(0)
  3065. SAL EAX,2 ; EAX = 2*P(0)
  3066. ADD EAX,EBX ; EAX = 5*P(0)
  3067. ADD EAX,DWORD PTR [ESI+16] ; + P(4)
  3068. MOV EDX,DWORD PTR [ESI+8] ; EDX = P(2)
  3069. ADD EDX,EDX ; *2
  3070. ADD EDX,DWORD PTR [ESI+8] ; EDX = 3*P(2)
  3071. SUB EAX,EDX ; EAX = P(4) - 3*P(2) + 5*P(0)
  3072. XCHG EAX,DWORD PTR [ESI+4] ; PP(1)=EAX et EAX = P(1)
  3073. MOV ECX,EAX ; ECX = P(1)
  3074. SAL EAX,3 ; *8
  3075. MOV DWORD PTR [ESI+16],EAX ; PP(4) = 8*P(1)
  3076. NEG EAX
  3077. MOV EDX,DWORD PTR [ESI+12] ; EDX = P(3)
  3078. ADD EDX,EDX ; * 2
  3079. ADD EAX,EDX ; EAX = 2*P(3) - 8*P(1)
  3080. XCHG EAX,DWORD PTR [ESI+8] ; PP(2) = EAX et EAX = P(2)
  3081. SAL EAX,2 ; EAX *= 4*P(2)
  3082. SAL EBX,2 ; EBX = 4*P0
  3083. MOV EDX,EBX ; EDX = 4*P(0)
  3084. SAL EDX,2 ; EDX = 16*P(0)
  3085. MOV DWORD PTR [ESI+20],EDX ; PP(5) = 16*P(0)
  3086. ADD EBX,EDX ; EDX = 20*P(0)
  3087. NEG EBX
  3088. ADD EAX,EBX
  3089. MOV DWORD PTR [ESI+12],EAX ; PP(3) = 4*P(2)-20*P(0)
  3090. MOV EDI,ESI
  3091. ADD ESI,4*11 ;DS:SI vect. Q
  3092. ADD EDI,4*6 ;DS:DI vect QQ
  3093. MOV EAX,DWORD PTR [ESI+20] ;EAX = Q(5)
  3094. ADD EAX,1
  3095. SAR EAX,1
  3096. SUB EAX,DWORD PTR [ESI+12] ;EAX = Q(5)/2 - Q(3)
  3097. ADD EAX,DWORD PTR [ESI+4] ; + Q(1)
  3098. MOV DWORD PTR [EDI],EAX ; QQ(0) = EAX
  3099. MOV EAX,DWORD PTR [ESI] ; EAX = Q(0)
  3100. MOV EBX,EAX
  3101. SAL EAX,2 ; EAX = 2*Q(0)
  3102. ADD EAX,DWORD PTR [ESI] ; EAX = 5*Q(0)
  3103. ADD EAX,DWORD PTR [ESI+16] ; + Q(4)
  3104. MOV EDX,DWORD PTR [ESI+8] ; EDX = Q(2)
  3105. ADD EDX,EDX ; *2
  3106. ADD EDX,DWORD PTR [ESI+8] ; EDX = 3*Q(2)
  3107. SUB EAX,EDX ; EAX = Q(4) - 3*Q(2) + 5*Q(0)
  3108. MOV DWORD PTR [EDI+4],EAX ; QQ(1)=EAX
  3109. MOV EAX,DWORD PTR [ESI+4] ; EAX = Q(1)
  3110. MOV ECX,EAX ; ECX = Q(1)
  3111. SAL EAX,3 ; *8
  3112. MOV DWORD PTR [EDI+16],EAX ; QQ(4) = 8*Q(1)
  3113. NEG EAX
  3114. MOV EDX,DWORD PTR [ESI+12] ; EDX = Q(3)
  3115. ADD EDX,EDX ; * 2
  3116. ADD EAX,EDX ; EAX = 2*Q(3) - 8*Q(1)
  3117. MOV DWORD PTR [EDI+8],EAX ; QQ(2) = EAX
  3118. MOV EAX,DWORD PTR [ESI+8] ; EAX = Q(2)
  3119. SAL EAX,2 ; EAX *= 4*Q(2)
  3120. SAL EBX,2 ; EBX = 4*Q0
  3121. MOV EDX,EBX ; EDX = 4*Q(0)
  3122. SAL EDX,2 ; EDX = 16*Q(0)
  3123. MOV DWORD PTR [EDI+20],EDX ; QQ(5) = 16*Q(0)
  3124. ADD EBX,EDX ; EDX = 20*Q(0)
  3125. NEG EBX
  3126. ADD EAX,EBX
  3127. MOV DWORD PTR [EDI+12],EAX ; QQ(3) = 4*Q(2)-20*Q(0)
  3128. }
  3129. }
  3130. void horner(long *P,long *T,long *a,short n,short s)
  3131. {
  3132. _asm
  3133. {
  3134. MOV ESI,[P]
  3135. MOV EDI,[T]
  3136. MOV CX,[n]
  3137. MOVSX EBX,CX
  3138. SAL EBX,2
  3139. ADD ESI,EBX ; SI : P(n)
  3140. SUB EBX,4
  3141. ADD EDI,EBX ; DI : Q(n-1)
  3142. MOV EAX,DWORD PTR [ESI] ; EAX = P(n)
  3143. MOV DWORD PTR [EDI],EAX ; Q(n-1) = P(n)
  3144. SUB ESI,4
  3145. DEC CX
  3146. MOVSX EBX,WORD PTR [s]
  3147. LOOP_HNR:
  3148. MOV EAX,DWORD PTR [EDI] ; EAX = Q(i)
  3149. IMUL EBX ; EDX:EAX = s*Q(i)
  3150. ADD EAX,16384 ;
  3151. ADC EDX,0
  3152. SHRD EAX,EDX,15 ; cadrer
  3153. SUB EDI,4
  3154. ADD EAX,DWORD PTR [ESI] ; EAX = Q(i) = P(i) + s*Q(i)
  3155. MOV DWORD PTR [EDI],EAX ;
  3156. SUB ESI,4
  3157. DEC CX
  3158. JNE LOOP_HNR
  3159. MOV EAX,DWORD PTR [EDI] ; EAX = Q(0)
  3160. IMUL EBX ; EDX:EAX = s*Q(0)
  3161. ADD EAX,16384 ;
  3162. ADC EDX,0
  3163. SHRD EAX,EDX,15 ; cadrer
  3164. ADD EAX,DWORD PTR [ESI] ; EAX = P(0) + s*Q(0)
  3165. MOV ESI,[a]
  3166. MOV DWORD PTR [ESI],EAX
  3167. }
  3168. }
  3169. #pragma warning(disable : 4035)
  3170. short calcul_s(long a,long b)
  3171. {
  3172. _asm
  3173. {
  3174. MOV EBX,[b]
  3175. ADD EBX,0
  3176. JGE B_POSIT
  3177. NEG EBX
  3178. B_POSIT:
  3179. MOV CL,0
  3180. CMP EBX,40000000H ;normaliser b
  3181. JGE OUT_NORM
  3182. NORM_B:
  3183. ADD EBX,EBX
  3184. INC CL
  3185. CMP EBX,40000000H ;
  3186. JGE OUT_NORM
  3187. JMP NORM_B
  3188. OUT_NORM:
  3189. ADD EBX,16384
  3190. SAR EBX,15
  3191. MOV EDX,[b]
  3192. ADD EDX,0
  3193. JGE PUT_SIGN
  3194. NEG EBX
  3195. PUT_SIGN:
  3196. MOV EAX,[a]
  3197. SAL EAX,CL ; shifter a de CL
  3198. CDQ
  3199. IDIV EBX ; AX = a/b
  3200. MOV BX,AX
  3201. IMUL BX ; DX:AX = sqr(a/b)
  3202. ADD AX,8192
  3203. ADC DX,0
  3204. SHRD AX,DX,14 ; AX = 2*sqr(a/b)
  3205. MOV DX,AX
  3206. ADD DX,1
  3207. SAR DX,1
  3208. ADD AX,DX ; AX = 3*sqr(a/b)
  3209. NEG AX
  3210. SUB AX,BX ; AX = -a/b - 3*sqr(a/b)
  3211. }
  3212. }
  3213. #pragma warning(default : 4035)
  3214. void binome(short *lsp,long *PP)
  3215. {
  3216. short inc_sq;
  3217. long sqr;
  3218. _asm
  3219. {
  3220. MOV EDI,[lsp]
  3221. MOV ESI,[PP]
  3222. MOV EBX,DWORD PTR [ESI+8] ;EBX = PP(2)
  3223. ADD EBX,0
  3224. JGE B_POSIT_P
  3225. NEG EBX
  3226. B_POSIT_P:
  3227. MOV CL,0
  3228. CMP EBX,40000000H ;normaliser PP(2)
  3229. JGE OUT_NORM_P
  3230. NORM_B_P:
  3231. ADD EBX,EBX
  3232. INC CL
  3233. CMP EBX,40000000H ;
  3234. JGE OUT_NORM_P
  3235. JMP NORM_B_P
  3236. OUT_NORM_P:
  3237. ADD EBX,16384
  3238. SAR EBX,15
  3239. MOV EDX,DWORD PTR [ESI+8]
  3240. ADD EDX,0
  3241. JGE PUT_SIGN_P
  3242. NEG EBX
  3243. PUT_SIGN_P: ; BX = PP(2)
  3244. MOV EAX,DWORD PTR [ESI] ; EAX = PP(0)
  3245. SAL EAX,CL ; shifter a de CL
  3246. CDQ
  3247. IDIV EBX ; AX = PP(0)/PP(2)
  3248. NEG AX
  3249. MOV WORD PTR [EDI],AX ; ES:[DI] = -PP(0)/PP(2)
  3250. MOV EAX,DWORD PTR [ESI+4] ; EAX = PP(1)
  3251. SAL EAX,CL ; shifter a de CL
  3252. SAR EAX,1
  3253. CDQ
  3254. IDIV EBX
  3255. NEG EAX ; va = AX = -PP(1)/2*PP(2)
  3256. MOV DWORD PTR [ESI],EAX
  3257. MOV CX,WORD PTR [EDI] ; vb = CX = -PP(0)/PP(2)
  3258. IMUL EAX ; EAX = va*va
  3259. MOVSX EBX,CX ; EAX = vb
  3260. SAL EBX,15 ; EAX = vb*32768
  3261. ADD EAX,EBX ; EBX = va*va + vb*32768
  3262. MOV [sqr],EAX
  3263. MOV CX,14 ; CX = compteur
  3264. MOV BX,0 ; BX = racine
  3265. MOV WORD PTR [inc_sq],4000H ;
  3266. SQRT_L:
  3267. ADD BX,[inc_sq] ; rac += incrm
  3268. MOVSX EAX,BX
  3269. IMUL EAX ; EAX = rac*rac
  3270. SUB EAX,[sqr] ; EAX = rac*rac - SQR
  3271. JZ VITA_SQ
  3272. JLE NEXTIT
  3273. SUB BX,[inc_sq] ; rac = rac - incrm
  3274. NEXTIT:
  3275. SAR WORD PTR [inc_sq],1 ; incrm >> 1
  3276. DEC CX
  3277. JNE SQRT_L
  3278. VITA_SQ:
  3279. MOV EAX,DWORD PTR [ESI] ; AX = b
  3280. MOV DX,AX
  3281. SUB AX,BX ; AX = b-sqrt()
  3282. MOV WORD PTR [EDI+4],AX ; sauver
  3283. ADD DX,BX ; DX = b+sqrt()
  3284. MOV WORD PTR [EDI],DX ; sauver
  3285. ; idem with QQ
  3286. ADD ESI,24 ;DS:SI QQ
  3287. MOV EBX,DWORD PTR [ESI+8] ;EBX = QQ(2)
  3288. ADD EBX,0
  3289. JGE B_POSIT_Q
  3290. NEG EBX
  3291. B_POSIT_Q:
  3292. MOV CL,0
  3293. CMP EBX,40000000H ;normaliser QQ(2)
  3294. JGE OUT_NORM_Q
  3295. NORM_B_Q:
  3296. ADD EBX,EBX
  3297. INC CL
  3298. CMP EBX,40000000H ;
  3299. JGE OUT_NORM_Q
  3300. JMP NORM_B_Q
  3301. OUT_NORM_Q:
  3302. ADD EBX,16384
  3303. SAR EBX,15
  3304. MOV EDX,DWORD PTR [ESI+8]
  3305. ADD EDX,0
  3306. JGE PUT_SIGN_Q
  3307. NEG EBX
  3308. PUT_SIGN_Q: ; BX = QQ(2)
  3309. MOV EAX,DWORD PTR [ESI] ; EAX = QQ(0)
  3310. SAL EAX,CL ; shifter a de CL
  3311. CDQ
  3312. IDIV EBX ; AX = QQ(0)/QQ(2)
  3313. NEG AX
  3314. MOV WORD PTR [EDI+2],AX ; ES:[DI+2] = -QQ(0)/QQ(2)
  3315. MOV EAX,DWORD PTR [ESI+4] ; EAX = QQ(1)
  3316. SAL EAX,CL ; shifter a de CL
  3317. SAR EAX,1
  3318. CDQ
  3319. IDIV EBX
  3320. NEG EAX ; va = AX = -QQ(1)/2*QQ(2)
  3321. MOV DWORD PTR [ESI],EAX
  3322. MOV CX,WORD PTR [EDI+2] ; vb = CX = -QQ(0)/QQ(2)
  3323. IMUL EAX ; EAX = va*va
  3324. MOVSX EBX,CX ; EAX = vb
  3325. SAL EBX,15 ; EAX = vb*32768
  3326. ADD EAX,EBX ; EBX = va*va + vb*32768
  3327. MOV [sqr],EAX
  3328. MOV CX,14 ; CX = compteur
  3329. MOV BX,0 ; BX = racine
  3330. MOV WORD PTR [inc_sq],4000H ;
  3331. SQRT_LQ:
  3332. ADD BX,[inc_sq] ; rac += incrm
  3333. MOVSX EAX,BX
  3334. IMUL EAX ; EAX = rac*rac
  3335. SUB EAX,[sqr] ; EAX = rac*rac - SQR
  3336. JZ VITA_SQ2
  3337. JLE NEXTITQ
  3338. SUB BX,[inc_sq] ; rac = rac - incrm
  3339. NEXTITQ:
  3340. SAR WORD PTR [inc_sq],1 ; incrm >> 1
  3341. DEC CX
  3342. JNE SQRT_LQ
  3343. VITA_SQ2:
  3344. MOV EAX,DWORD PTR [ESI] ; AX = b
  3345. MOV DX,AX
  3346. SUB AX,BX ; AX = b-sqrt()
  3347. MOV WORD PTR [EDI+6],AX ; sauver
  3348. ADD DX,BX ; DX = b+sqrt()
  3349. MOV WORD PTR [EDI+2],DX ; sauver
  3350. }
  3351. }
  3352. void deacc(short *src,short *dest,short fact,short lfen,short *last_out)
  3353. {
  3354. _asm
  3355. {
  3356. MOV ESI,[src]
  3357. MOV EDI,[dest]
  3358. MOV EBX,[last_out] ; FS:BX = last_out
  3359. MOV AX,WORD PTR [EBX] ; AX = last_out
  3360. MOV BX,[fact] ; BX = Fact
  3361. MOV CX,[lfen] ; init compteur
  3362. LOOP_DEAC:
  3363. IMUL BX ; DX:AX = fact * y(i-1)
  3364. ADD AX,16384
  3365. ADC DX,0 ; arrondi
  3366. SHLD DX,AX,1 ; DX = fact * x(i-1;
  3367. MOV AX,WORD PTR [ESI] ; AX = x(i)
  3368. ADD AX,DX ; DX = x(i) + fact*x(i-1)
  3369. MOV WORD PTR [EDI],AX ;Sauver Xout
  3370. ADD ESI,2 ;
  3371. ADD EDI,2 ;Pointer composantes suivantes
  3372. DEC CX
  3373. JNE LOOP_DEAC
  3374. MOV EBX,[last_out]
  3375. MOV WORD PTR [EBX],AX ;Sauver dernier chantillon
  3376. }
  3377. }
  3378. void filt_in(short *mem,short *Vin,short *Vout,short lfen)
  3379. {
  3380. _asm
  3381. {
  3382. MOV CX,[lfen] ;CX=cpteur
  3383. MOV EDI,[mem]
  3384. FIL_IN_LOOP:
  3385. MOV ESI,[Vin]
  3386. MOV BX,WORD PTR [ESI] ;BX=Xin
  3387. SAR BX,2 ;div par 4
  3388. MOV AX,WORD PTR [EDI] ;AX=z(1)
  3389. MOV WORD PTR [EDI],BX ;mise a jour memoire
  3390. SUB BX,AX ;BX=(Xin-z(1))/4
  3391. ADD DWORD PTR [Vin],2 ;pointer echant svt
  3392. MOV AX,WORD PTR [EDI+2] ;AX=z(2)
  3393. MOV DX,29491 ;DX=0.9
  3394. IMUL DX ;DX=0.9*z(2)
  3395. ADD AX,16384
  3396. ADC DX,0 ;arrondi et dble signe
  3397. SHLD DX,AX,1
  3398. ADD DX,BX ;reponse=DX=tmp
  3399. MOV WORD PTR [EDI+2],DX ;mise a jour memoire
  3400. MOV ESI,[Vout]
  3401. MOV WORD PTR [ESI],DX ;output=tmp/4
  3402. ADD DWORD PTR [Vout],2 ;pointer echant svt
  3403. DEC CX
  3404. JNE FIL_IN_LOOP
  3405. }
  3406. }
  3407. /*
  3408. void cal_dic1(short *y,short *sr,short *espopt,short *posit,short dec,
  3409. short esp,short SIGPI[],short SOULONG,long TLSP[],long VMAX[])
  3410. {
  3411. short ss,vene;
  3412. _asm
  3413. {
  3414. PUSH WORD PTR [INT_SOUL]
  3415. MOV SI,WORD PTR [INT_SIG]
  3416. ADD SI,300
  3417. PUSH SI
  3418. PUSH WORD PTR [INT_Y]
  3419. CALL near ptr venergy
  3420. ADD SP,6
  3421. MOV BX,WORD PTR [INT_SOUL]
  3422. SAL BX,2
  3423. ADD SI,BX
  3424. SUB SI,4
  3425. MOV WORD PTR [VENE],SI
  3426. MOV AX,WORD PTR [INT_SOUL]
  3427. MOV WORD PTR [INT_SS],AX
  3428. ADD AX,WORD PTR [INT_SR]
  3429. ADD WORD PTR [INT_SS],AX
  3430. MOV DI,0
  3431. MOV SI,WORD PTR [LG_TLSP]
  3432. PUSH WORD PTR [LG_VMAX]
  3433. PUSH SI
  3434. DEC1_LOOP: MOV BX,WORD PTR [INT_SR]
  3435. MOV EAX,0
  3436. MOV DWORD PTR [SI],EAX
  3437. ADD BX,DI
  3438. ADD BX,DI
  3439. DEC1_BCLE: MOVSX EAX,WORD PTR [BX]
  3440. ADD DWORD PTR [SI],EAX
  3441. MOV AX,WORD PTR [INT_ESP]
  3442. ADD BX,AX
  3443. ADD BX,AX
  3444. CMP BX,WORD PTR [INT_SS]
  3445. JL DEC1_BCLE
  3446. MOV BX,WORD PTR [VENE]
  3447. SAL DI,2
  3448. SUB BX,DI
  3449. SAR DI,2
  3450. MOV EAX,DWORD PTR [BX]
  3451. MOV DWORD PTR [SI+4],EAX
  3452. CALL upd_max_d
  3453. ADD AX,0
  3454. JE NO_LIMIT
  3455. MOV BX,WORD PTR [INT_POS]
  3456. MOV WORD PTR [BX],DI
  3457. MOV BX,WORD PTR [INT_EO]
  3458. MOV AX,WORD PTR [INT_ESP]
  3459. MOV WORD PTR [BX],AX
  3460. NO_LIMIT: INC DI
  3461. CMP DI,WORD PTR [INT_DEC]
  3462. JL DEC1_LOOP
  3463. ADD SP,4
  3464. POP DI
  3465. POP SI
  3466. MOV SP,BP
  3467. POP BP
  3468. RET
  3469. cal_dic1 ENDP
  3470. COMMENT #
  3471. COMMENT &
  3472. ___ void cal_dic2(int q,int espace,int phase,int *s_r,int *hy,int *b,
  3473. ___ int *vois,int *esp,int *qq,int *phas,int SIGPI[],
  3474. ___ int SOULONG,long TLSP[],long VMAX[],(int PITCH))
  3475. ___ |--->en option...
  3476. &
  3477. R11 EQU BP-4
  3478. Y1 EQU BP-6
  3479. Y2 EQU BP-8
  3480. IO EQU BP-10
  3481. ST_CC EQU BP-30
  3482. ST_SRC EQU BP-50
  3483. INT_Q EQU BP+6
  3484. ESPACE EQU BP+8
  3485. PHASE EQU BP+10
  3486. INT_SR EQU BP+12
  3487. S_INT_SR EQU BP+14
  3488. HY EQU BP+16
  3489. S_HY EQU BP+18
  3490. INT_B EQU BP+20
  3491. S_INT_B EQU BP+22
  3492. VOIS EQU BP+24
  3493. S_VOIS EQU BP+26
  3494. INT_ESP EQU BP+28
  3495. S_ESP EQU BP+30
  3496. QQ EQU BP+32
  3497. S_QQ EQU BP+34
  3498. PHAS EQU BP+36
  3499. S_PHAS EQU BP+38
  3500. SIGPI EQU BP+40
  3501. S_SIGPI EQU BP+42
  3502. SOULONG EQU BP+44
  3503. TLSP EQU BP+46
  3504. S_TLSP EQU BP+48
  3505. VMAX EQU BP+50
  3506. S_VMAX EQU BP+52
  3507. ;PITCH EQU BP+54
  3508. cal_dic2 PROC FAR
  3509. PUSH BP
  3510. MOV BP,SP
  3511. SUB SP,50
  3512. PUSH SI
  3513. PUSH DI
  3514. PUSH DS
  3515. ; PUSH ES
  3516. MOV DWORD PTR [R11],0
  3517. PUSH WORD PTR [SOULONG]
  3518. PUSH WORD PTR [S_SIGPI]
  3519. MOV SI,WORD PTR [SIGPI]
  3520. ADD SI,300
  3521. MOV WORD PTR [Y1],SI
  3522. SUB SI,150
  3523. MOV WORD PTR [Y2],SI
  3524. PUSH SI
  3525. CALL init_zero
  3526. ADD SP,6
  3527. MOV AX,WORD PTR [PHASE]
  3528. SUB AX,WORD PTR [ESPACE]
  3529. MOV WORD PTR [IO],AX
  3530. PUSH WORD PTR [SOULONG]
  3531. SUB SP,2
  3532. PUSH WORD PTR [S_HY]
  3533. PUSH WORD PTR [HY]
  3534. PUSH WORD PTR [S_SIGPI]
  3535. PUSH SI
  3536. ADD SP,10
  3537. MOV SI,0
  3538. MOV DS,WORD PTR [S_INT_SR]
  3539. CAL2_LOOP: MOV DI,WORD PTR [INT_SR]
  3540. MOV AX,WORD PTR [IO]
  3541. ADD AX,WORD PTR [ESPACE]
  3542. MOV WORD PTR [IO],AX
  3543. ADD DI,AX
  3544. ADD DI,AX
  3545. MOVSX EBX,WORD PTR DS:[DI]
  3546. ADD SI,SI
  3547. MOV WORD PTR SS:[ST_SRC+SI],BX
  3548. ADD EBX,0
  3549. JL SRC_NEG
  3550. MOV WORD PTR SS:[ST_CC+SI],1
  3551. ADD DWORD PTR [R11],EBX
  3552. PUSH AX
  3553. SUB SP,8
  3554. CALL add_sf_vect
  3555. ADD SP,10
  3556. JMP CAL2_SUITE
  3557. SRC_NEG: MOV WORD PTR SS:[ST_CC+SI],-1
  3558. SUB DWORD PTR [R11],EBX
  3559. PUSH AX
  3560. SUB SP,8
  3561. CALL sub_sf_vect
  3562. ADD SP,10
  3563. CAL2_SUITE: SAR SI,1
  3564. ADD SI,1
  3565. CMP SI,WORD PTR [INT_Q]
  3566. JL CAL2_LOOP
  3567. ADD SP,2
  3568. PUSH WORD PTR [SOULONG]
  3569. PUSH WORD PTR [S_TLSP]
  3570. MOV SI,WORD PTR [TLSP]
  3571. ADD SI,4
  3572. PUSH SI
  3573. PUSH WORD PTR [S_SIGPI]
  3574. PUSH WORD PTR [Y2]
  3575. CALL energy2
  3576. ADD SP,10
  3577. MOV DS,WORD PTR [S_TLSP]
  3578. MOV SI,WORD PTR [TLSP]
  3579. MOV EAX,DWORD PTR [R11]
  3580. MOV DS:[SI],EAX
  3581. PUSH WORD PTR [S_VMAX]
  3582. PUSH WORD PTR [VMAX]
  3583. PUSH DS
  3584. PUSH SI
  3585. CALL upd_max_d
  3586. ADD SP,8
  3587. ADD AX,0
  3588. JE UPD_NULL
  3589. PUSH WORD PTR [INT_Q]
  3590. PUSH WORD PTR [S_INT_B]
  3591. PUSH WORD PTR [INT_B]
  3592. PUSH SS
  3593. MOV AX,BP
  3594. SUB AX,30
  3595. PUSH AX
  3596. CALL int_to_int
  3597. ADD SP,10
  3598. MOV SI,WORD PTR [VOIS]
  3599. MOV DS,WORD PTR [S_VOIS]
  3600. MOV DS:[SI],WORD PTR 0
  3601. MOV DS,WORD PTR [S_ESP]
  3602. MOV SI,WORD PTR [INT_ESP]
  3603. MOV AX,WORD PTR [ESPACE]
  3604. MOV DS:[SI],AX
  3605. MOV DS,WORD PTR [S_QQ]
  3606. MOV SI,WORD PTR [QQ]
  3607. MOV AX,WORD PTR [INT_Q]
  3608. MOV DS:[SI],AX
  3609. MOV DS,WORD PTR [S_PHAS]
  3610. MOV SI,WORD PTR [PHAS]
  3611. MOV AX,WORD PTR [PHASE]
  3612. MOV DS:[SI],AX
  3613. UPD_NULL: ; CMP WORD PTR [PITCH],80
  3614. ; JG FINI
  3615. COMMENT &
  3616. MOV AX,WORD PTR [PHASE]
  3617. SUB AX,WORD PTR [ESPACE]
  3618. MOV WORD PTR [IO],AX
  3619. MOV SI,0
  3620. CAL2_LOOP2: ADD SI,SI
  3621. MOV AX,WORD PTR SS:[ST_CC+SI]
  3622. NEG AX
  3623. MOV WORD PTR SS:[ST_CC+SI],AX
  3624. MOV EDX,DWORD PTR [R11]
  3625. MOVSX EBX,WORD PTR SS:[ST_SRC+SI]
  3626. ADD AX,0
  3627. JL CC_NEG
  3628. ADD EDX,EBX
  3629. ADD EDX,EBX
  3630. JMP CC_NEXT
  3631. CC_NEG: SUB EDX,EBX
  3632. SUB EDX,EBX
  3633. CC_NEXT:
  3634. MOV DI,WORD PTR [TLSP]
  3635. MOV DS,WORD PTR [S_TLSP]
  3636. MOV DS:[DI],EDX
  3637. MOV AX,WORD PTR [IO]
  3638. ADD AX,WORD PTR [ESPACE]
  3639. MOV WORD PTR [IO],AX
  3640. MOV BX,WORD PTR SS:[ST_CC+SI]
  3641. ADD BX,BX
  3642. PUSH BX
  3643. PUSH AX
  3644. PUSH WORD PTR [SOULONG]
  3645. PUSH WORD PTR [S_HY]
  3646. PUSH WORD PTR [HY]
  3647. PUSH WORD PTR [S_SIGPI]
  3648. PUSH WORD PTR [Y2]
  3649. PUSH WORD PTR [S_SIGPI]
  3650. PUSH WORD PTR [Y1]
  3651. CALL update_dic
  3652. ADD SP,18
  3653. PUSH WORD PTR [SOULONG]
  3654. PUSH DS
  3655. MOV BX,WORD PTR [TLSP]
  3656. ADD BX,4
  3657. PUSH BX
  3658. PUSH WORD PTR [S_SIGPI]
  3659. PUSH WORD PTR [Y1]
  3660. CALL energy2
  3661. ADD SP,10
  3662. PUSH WORD PTR [S_VMAX]
  3663. PUSH WORD PTR [VMAX]
  3664. PUSH DS
  3665. PUSH WORD PTR [TLSP]
  3666. CALL upd_max_d
  3667. ADD SP,8
  3668. ADD AX,0
  3669. JE CAL2_END
  3670. PUSH WORD PTR [INT_Q]
  3671. PUSH WORD PTR [S_INT_B]
  3672. PUSH WORD PTR [INT_B]
  3673. PUSH SS
  3674. MOV AX,BP
  3675. SUB AX,30
  3676. PUSH AX
  3677. CALL int_to_int
  3678. ADD SP,10
  3679. MOV DI,WORD PTR [TLSP]
  3680. MOV EAX,DS:[DI]
  3681. MOV DWORD PTR [R11],EAX
  3682. MOV AX,WORD PTR [Y1]
  3683. XCHG AX,WORD PTR [Y2]
  3684. MOV WORD PTR [Y1],AX
  3685. MOV DI,WORD PTR [VOIS]
  3686. MOV DS,WORD PTR [S_VOIS]
  3687. MOV DS:[DI],WORD PTR 0
  3688. MOV DS,WORD PTR [S_ESP]
  3689. MOV DI,WORD PTR [INT_ESP]
  3690. MOV AX,WORD PTR [ESPACE]
  3691. MOV DS:[DI],AX
  3692. MOV DS,WORD PTR [S_QQ]
  3693. MOV DI,WORD PTR [QQ]
  3694. MOV AX,WORD PTR [INT_Q]
  3695. MOV DS:[DI],AX
  3696. MOV DS,WORD PTR [S_PHAS]
  3697. MOV DI,WORD PTR [PHAS]
  3698. MOV AX,WORD PTR [PHASE]
  3699. MOV DS:[DI],AX
  3700. JMP CAL2_OUT
  3701. CAL2_END: NEG WORD PTR SS:[ST_CC+SI]
  3702. CAL2_OUT: SAR SI,1
  3703. ADD SI,1
  3704. CMP SI,WORD PTR [INT_Q]
  3705. JL CAL2_LOOP2
  3706. FINI:
  3707. &
  3708. ; POP ES
  3709. POP DS
  3710. POP DI
  3711. POP SI
  3712. MOV SP,BP
  3713. POP BP
  3714. RET
  3715. cal_dic2 ENDP
  3716. #
  3717. COMMENT &
  3718. ___ void calc_p(int *p1,int *p2,int pitch,int lim_p1,int lim_p2,int no);
  3719. &
  3720. P1 EQU BP+4
  3721. P2 EQU BP+6
  3722. PITCH EQU BP+8
  3723. LIM_P1 EQU BP+10
  3724. LIM_P2 EQU BP+12
  3725. INT_NO EQU BP+14
  3726. calc_p PROC near
  3727. PUSH BP ; save contexte
  3728. MOV BP,SP ;
  3729. PUSH SI ; save C register
  3730. PUSH DI
  3731. MOV BX,WORD PTR [PITCH]
  3732. MOV SI,WORD PTR [P1]
  3733. MOV CX,WORD PTR [LIM_P1]
  3734. MOV AX,WORD PTR [INT_NO]
  3735. ADD AX,0
  3736. JE NUM_NULL
  3737. SUB BX,3
  3738. CMP BX,CX
  3739. JL P1_NEG1
  3740. MOV WORD PTR [SI],BX
  3741. JMP P1_SUITE1
  3742. P1_NEG1: MOV WORD PTR [SI],CX
  3743. P1_SUITE1: ADD BX,7
  3744. MOV CX,WORD PTR [LIM_P2]
  3745. MOV SI,WORD PTR [P2]
  3746. CMP BX,CX
  3747. JG P2_POS1
  3748. MOV WORD PTR [SI],BX
  3749. JMP P_FIN
  3750. P2_POS1: MOV WORD PTR [SI],CX
  3751. JMP P_FIN
  3752. NUM_NULL: SUB BX,5
  3753. CMP BX,CX
  3754. JL P1_NEG2
  3755. MOV WORD PTR [SI],BX
  3756. JMP P1_SUITE2
  3757. P1_NEG2: MOV WORD PTR [SI],CX
  3758. P1_SUITE2: ADD BX,10
  3759. MOV CX,WORD PTR [LIM_P2]
  3760. MOV SI,WORD PTR [P2]
  3761. CMP BX,CX
  3762. JG P2_POS2
  3763. MOV WORD PTR [SI],BX
  3764. JMP P_FIN
  3765. P2_POS2: MOV WORD PTR [SI],CX
  3766. P_FIN:
  3767. POP DI
  3768. POP SI
  3769. MOV SP,BP
  3770. POP BP
  3771. RET
  3772. calc_p ENDP
  3773. */
  3774. #pragma warning(disable : 4035)
  3775. short calc_gltp(short *gltp,short *bq,short *bv,long ttt)
  3776. {
  3777. _asm
  3778. {
  3779. MOV EBX,DWORD PTR [ttt]
  3780. CMP EBX,32767
  3781. JLE TEST2
  3782. MOV AX,32767
  3783. JMP OUT_TEST
  3784. TEST2:
  3785. CMP EBX,-32767
  3786. JGE TEST3
  3787. MOV AX,-32767
  3788. JMP OUT_TEST
  3789. TEST3:
  3790. MOV AX,BX
  3791. OUT_TEST:
  3792. MOV BX,AX ; BX=GLTP
  3793. ADD AX,0
  3794. JGE GLTP_POS
  3795. NEG AX ; AX=abs(GLTP)
  3796. GLTP_POS:
  3797. MOV CX,0
  3798. MOV ESI,[bq]
  3799. MOV EDI,[bv]
  3800. BOUCLER:
  3801. ADD CX,1
  3802. CMP CX,11
  3803. JE FIN_BOUCLER
  3804. ADD EDI,2
  3805. MOV DX,WORD PTR [ESI]
  3806. CMP AX,DX
  3807. JL BOUCLER
  3808. ADD ESI,2
  3809. MOV DX,WORD PTR [ESI]
  3810. CMP AX,DX
  3811. JGE BOUCLER
  3812. ADD BX,0
  3813. JLE GLTP_NEG
  3814. DEC CX ;CX=k
  3815. MOV BX,WORD PTR [EDI]
  3816. JMP FIN_BOUCLER
  3817. GLTP_NEG:
  3818. ADD CX,9
  3819. MOV BX,WORD PTR [EDI]
  3820. NEG BX
  3821. FIN_BOUCLER:
  3822. MOV ESI,[bq]
  3823. ADD ESI,20
  3824. MOV DX,WORD PTR [ESI]
  3825. CMP BX,DX
  3826. JL GLTP_P
  3827. MOV EDI,[bv]
  3828. ADD EDI,20
  3829. MOV BX,WORD PTR [EDI]
  3830. MOV CX,9
  3831. GLTP_P:
  3832. SUB ESI,8
  3833. MOV DX,WORD PTR [ESI]
  3834. NEG DX
  3835. CMP BX,DX
  3836. JGE GLTP_G
  3837. MOV EDI,[bv]
  3838. ADD EDI,12
  3839. MOV BX,WORD PTR [EDI]
  3840. NEG BX
  3841. MOV CX,15
  3842. GLTP_G:
  3843. MOV ESI,[gltp]
  3844. MOV WORD PTR [ESI],BX
  3845. MOV AX,CX
  3846. }
  3847. }
  3848. #pragma warning(default : 4035)
  3849. #pragma warning(disable : 4035)
  3850. short calc_garde(short MAX)
  3851. {
  3852. _asm
  3853. {
  3854. MOV AX,0
  3855. MOV BX,WORD PTR [MAX]
  3856. AND BX,0FE00H
  3857. JE STORE
  3858. SAR BX,9
  3859. BCLE_SAR:
  3860. INC AX
  3861. SAR BX,1
  3862. JE STORE
  3863. CMP AX,5
  3864. JNE BCLE_SAR
  3865. STORE:
  3866. }
  3867. }
  3868. #pragma warning(default : 4035)
  3869. #pragma warning(disable : 4035)
  3870. short calc_gopt(short *c,short *code,short *gq,short *gv,short voise,
  3871. short npopt,short pitch,short espopt,short depl,short position,
  3872. short soudecal,long vmax)
  3873. {
  3874. _asm
  3875. {
  3876. MOV EBX,DWORD PTR [vmax]
  3877. CMP EBX,32767
  3878. JLE COMP2
  3879. MOV AX,32767
  3880. JMP OUT_COMP
  3881. COMP2:
  3882. CMP EBX,-32767
  3883. JGE COMP3
  3884. MOV AX,-32767
  3885. JMP OUT_COMP
  3886. COMP3:
  3887. MOV AX,BX ;AX=Gopt
  3888. OUT_COMP:
  3889. MOV BX,WORD PTR [voise]
  3890. ADD BX,0
  3891. JNE VOIS_1
  3892. MOV ESI,[c]
  3893. MOV BX,WORD PTR [ESI]
  3894. CMP BX,-1
  3895. JNE CO_1
  3896. NEG AX
  3897. MOVSX ECX,WORD PTR [npopt]
  3898. ADD ESI,ECX
  3899. ADD ESI,ECX
  3900. CX_BCLE:
  3901. SUB ESI,2
  3902. NEG WORD PTR [ESI]
  3903. DEC CX
  3904. JNE CX_BCLE
  3905. CO_1:
  3906. MOV CX,WORD PTR [npopt]
  3907. CMP CX,8
  3908. JNE NPOPT_9
  3909. MOV DX,128
  3910. JMP NP_NEXT
  3911. NPOPT_9:
  3912. MOV DX,256 ;DX=cod
  3913. NP_NEXT:
  3914. MOV DI,1
  3915. MOV ESI,[c]
  3916. DEC CX
  3917. CJ_BCLE:
  3918. ADD ESI,2
  3919. DEC CX
  3920. MOV BX,WORD PTR [ESI]
  3921. SUB BX,1
  3922. JNE CJ_1
  3923. MOV BX,1
  3924. SAL BX,CL
  3925. ADD DX,BX
  3926. CJ_1:
  3927. INC DI
  3928. CMP DI,WORD PTR [npopt]
  3929. JL CJ_BCLE
  3930. JMP VOIS_0
  3931. VOIS_1:
  3932. MOV BX,WORD PTR [espopt]
  3933. MOV DX,WORD PTR [position]
  3934. CMP BX,WORD PTR [pitch]
  3935. JE VOIS_0
  3936. ADD DX,WORD PTR [soudecal]
  3937. VOIS_0:
  3938. MOVSX ESI,[depl]
  3939. ADD ESI,ESI
  3940. ADD ESI,24
  3941. ADD ESI,[c]
  3942. MOV WORD PTR [ESI],DX ; code[12+depl]=cod
  3943. ADD AX,0
  3944. JGE SIGN_0
  3945. NEG AX
  3946. MOV BX,1
  3947. JMP SIGN_1
  3948. SIGN_0:
  3949. MOV BX,0
  3950. SIGN_1:
  3951. MOV CX,0
  3952. MOV ESI,[gq]
  3953. MOV EDI,[gv]
  3954. BOUCLER2:
  3955. ADD CX,1
  3956. CMP CX,17
  3957. JE FIN_BOUCLER2
  3958. ADD EDI,2
  3959. MOV DX,WORD PTR [ESI]
  3960. CMP AX,DX
  3961. JL BOUCLER2
  3962. ADD ESI,2
  3963. MOV DX,WORD PTR [ESI]
  3964. CMP AX,DX
  3965. JGE BOUCLER2
  3966. DEC CX ;CX=cod
  3967. MOV AX,WORD PTR [EDI] ;AX=Gopt
  3968. FIN_BOUCLER2:
  3969. MOV ESI,[gq]
  3970. ADD ESI,32
  3971. MOV DX,WORD PTR [ESI]
  3972. CMP AX,DX
  3973. JL G_GQ
  3974. MOV EDI,[gv]
  3975. ADD EDI,32
  3976. MOV AX,WORD PTR [EDI]
  3977. MOV CX,15
  3978. G_GQ:
  3979. ADD BX,0
  3980. JE SIGN_NULL
  3981. NEG AX
  3982. ADD CX,16
  3983. SIGN_NULL:
  3984. MOVSX ESI,WORD PTR [depl]
  3985. ADD ESI,ESI
  3986. ADD ESI,26
  3987. ADD ESI,[c]
  3988. MOV WORD PTR [ESI],CX
  3989. }
  3990. }
  3991. #pragma warning(default : 4035)
  3992. void decimation(short *vin,short *vout,short nech)
  3993. {
  3994. _asm
  3995. {
  3996. MOV EDI,[vin]
  3997. MOV ESI,[vout]
  3998. DECIMATE:
  3999. MOV AX,WORD PTR [EDI]
  4000. MOV WORD PTR [ESI],AX
  4001. ADD EDI,8
  4002. ADD ESI,2
  4003. DEC WORD PTR [nech]
  4004. JNE DECIMATE
  4005. }
  4006. }
  4007. #else
  4008. void proc_gain(long *corr_ene,long gain)
  4009. {
  4010. // TODO need 64-bit
  4011. }
  4012. void inver_v_int(short *src,short *dest,short lng)
  4013. {
  4014. // TODO need 64-bit
  4015. }
  4016. short max_vect(short *vech,short nech)
  4017. {
  4018. // TODO need 64-bit
  4019. return 0;
  4020. }
  4021. void upd_max(long *corr_ene,long *vval,short pitch)
  4022. {
  4023. // TODO need 64-bit
  4024. }
  4025. short upd_max_d(long *corr_ene,long *vval)
  4026. {
  4027. // TODO need 64-bit
  4028. return 0;
  4029. }
  4030. void norm_corrl(long *corr,long *vval)
  4031. {
  4032. // TODO need 64-bit
  4033. }
  4034. void norm_corrr(long *corr,long *vval)
  4035. {
  4036. // TODO need 64-bit
  4037. }
  4038. void energy(short *vech,long *ene,short lng)
  4039. {
  4040. // TODO need 64-bit
  4041. }
  4042. void venergy(short *vech,long *vene,short lng)
  4043. {
  4044. // TODO need 64-bit
  4045. }
  4046. void energy2(short *vech,long *ene,short lng)
  4047. {
  4048. // TODO need 64-bit
  4049. }
  4050. void upd_ene(long *ener,long *val)
  4051. {
  4052. // TODO need 64-bit
  4053. }
  4054. short max_posit(long *vcorr,long *maxval,short pitch,short lvect)
  4055. {
  4056. // TODO need 64-bit
  4057. return 0;
  4058. }
  4059. void correlation(short *vech,short *vech2,long *acc,short lng)
  4060. {
  4061. // TODO need 64-bit
  4062. }
  4063. void schur(short *parcor,long *Ri,short netages)
  4064. {
  4065. // TODO need 64-bit
  4066. }
  4067. void interpol(short *lsp1,short *lsp2,short *dest,short lng)
  4068. {
  4069. // TODO need 64-bit
  4070. }
  4071. void add_sf_vect(short *y1,short *y2,short deb,short lng)
  4072. {
  4073. // TODO need 64-bit
  4074. }
  4075. void sub_sf_vect(short *y1,short *y2,short deb,short lng)
  4076. {
  4077. // TODO need 64-bit
  4078. }
  4079. void short_to_short(short *src,short *dest,short lng)
  4080. {
  4081. int i;
  4082. for(i=0; i<lng; i++)
  4083. *dest++ = *src++;
  4084. }
  4085. void long_to_long(long *src,long *dest,short lng)
  4086. {
  4087. // TODO need 64-bit
  4088. }
  4089. void init_zero(short *src,short lng)
  4090. {
  4091. // TODO need 64-bit
  4092. }
  4093. void update_ltp(short *y1,short *y2,short hy[],short lng,short gdgrd,short fact)
  4094. {
  4095. // TODO need 64-bit
  4096. }
  4097. void proc_gain2(long *corr_ene,long *gain,short bit_garde)
  4098. {
  4099. // TODO need 64-bit
  4100. }
  4101. void decode_dic(short *code,short dic,short npuls)
  4102. {
  4103. // TODO need 64-bit
  4104. }
  4105. void dsynthesis(long *z,short *coef,short *input,short *output,
  4106. short lng,short netages)
  4107. {
  4108. // TODO need 64-bit
  4109. }
  4110. void synthesis(short *z,short *coef,short *input,short *output,
  4111. short lng,short netages,short bdgrd )
  4112. {
  4113. // TODO need 64-bit
  4114. }
  4115. void synthese(short *z,short *coef,short *input,short *output,
  4116. short lng,short netages)
  4117. {
  4118. // TODO need 64-bit
  4119. }
  4120. void f_inverse(short *z,short *coef,short *input,short *output,
  4121. short lng,short netages )
  4122. {
  4123. // TODO need 64-bit
  4124. }
  4125. void filt_iir(long *zx,long *ai,short *Vin,short *Vout,short lfen,short ordre)
  4126. {
  4127. // TODO need 64-bit
  4128. }
  4129. void mult_fact(short src[],short dest[],short fact,short lng)
  4130. {
  4131. // TODO need 64-bit
  4132. }
  4133. void mult_f_acc(short src[],short dest[],short fact,short lng)
  4134. {
  4135. // TODO need 64-bit
  4136. }
  4137. void dec_lsp(short *code,short *tablsp,short *nbit,short *bitdi,short *tabdi)
  4138. {
  4139. // TODO need 64-bit
  4140. }
  4141. void teta_to_cos(short *tabcos,short *lsp,short netages)
  4142. {
  4143. // TODO need 64-bit
  4144. }
  4145. void cos_to_teta(short *tabcos,short *lsp,short netages)
  4146. {
  4147. // TODO need 64-bit
  4148. }
  4149. void lsp_to_ai(short *ai_lsp,long *tmp,short netages)
  4150. {
  4151. // TODO need 64-bit
  4152. }
  4153. void ki_to_ai(short *ki,long *ai,short netages)
  4154. {
  4155. // TODO need 64-bit
  4156. }
  4157. void ai_to_pq(long *aip,short netages)
  4158. {
  4159. // TODO need 64-bit
  4160. }
  4161. void horner(long *P,long *T,long *a,short n,short s)
  4162. {
  4163. // TODO need 64-bit
  4164. }
  4165. short calcul_s(long a,long b)
  4166. {
  4167. // TODO need 64-bit
  4168. return 0;
  4169. }
  4170. void binome(short *lsp,long *PP)
  4171. {
  4172. // TODO need 64-bit
  4173. }
  4174. void deacc(short *src,short *dest,short fact,short lfen,short *last_out)
  4175. {
  4176. // TODO need 64-bit
  4177. }
  4178. void filt_in(short *mem,short *Vin,short *Vout,short lfen)
  4179. {
  4180. // TODO need 64-bit
  4181. }
  4182. short calc_gltp(short *gltp,short *bq,short *bv,long ttt)
  4183. {
  4184. // TODO need 64-bit
  4185. return 0;
  4186. }
  4187. short calc_garde(short MAX)
  4188. {
  4189. // TODO need 64-bit
  4190. return 0;
  4191. }
  4192. short calc_gopt(short *c,short *code,short *gq,short *gv,short voise,
  4193. short npopt,short pitch,short espopt,short depl,short position,
  4194. short soudecal,long vmax)
  4195. {
  4196. // TODO need 64-bit
  4197. return 0;
  4198. }
  4199. void decimation(short *vin,short *vout,short nech)
  4200. {
  4201. // TODO need 64-bit
  4202. }
  4203. #endif
  4204. #ifndef _X86_
  4205. /**********************************************************************/
  4206. /**********************************************************************/
  4207. /* */
  4208. /* Function: DotProduct */
  4209. /* Author: Bill Hallahan */
  4210. /* Date: March 10, 1997 */
  4211. /* */
  4212. /* Abstract: */
  4213. /* */
  4214. /* This function returns the dot product of a set of two */
  4215. /* vectors. */
  4216. /* */
  4217. /* Inputs: */
  4218. /* */
  4219. /* pVector_0 A pointer of type T that points to the first */
  4220. /* input vector. */
  4221. /* */
  4222. /* pVector_1 A pointer of type T that points to the second */
  4223. /* input vector. */
  4224. /* */
  4225. /* uiLength The length of the input vectors. */
  4226. /* */
  4227. /* */
  4228. /* Outputs: */
  4229. /* */
  4230. /* The dot product of the two input vectors is calculated. The */
  4231. /* return value is a 64 bit Q30 number. */
  4232. /* */
  4233. /**********************************************************************/
  4234. /**********************************************************************/
  4235. /**********************************************************************/
  4236. /* Start of routine DotProduct(). */
  4237. /**********************************************************************/
  4238. _int64 DotProduct( int * piVector_0,
  4239. int * piVector_1,
  4240. unsigned int uiLength )
  4241. {
  4242. /********************************************************************/
  4243. /* Do the multiply-accumulates in groups of 8 values. */
  4244. /********************************************************************/
  4245. _int64 qSum = 0;
  4246. while ( uiLength >= 8 )
  4247. {
  4248. qSum += *piVector_0 * *piVector_1;
  4249. qSum += *(piVector_0+1) * *(piVector_1+1);
  4250. qSum += *(piVector_0+2) * *(piVector_1+2);
  4251. qSum += *(piVector_0+3) * *(piVector_1+3);
  4252. qSum += *(piVector_0+4) * *(piVector_1+4);
  4253. qSum += *(piVector_0+5) * *(piVector_1+5);
  4254. qSum += *(piVector_0+6) * *(piVector_1+6);
  4255. qSum += *(piVector_0+7) * *(piVector_1+7);
  4256. piVector_0 += 8;
  4257. piVector_1 += 8;
  4258. uiLength -= 8;
  4259. }
  4260. /********************************************************************/
  4261. /* Conditionally do a group of 4 multiply-accumulates. */
  4262. /********************************************************************/
  4263. if ( uiLength >= 4 )
  4264. {
  4265. qSum += *piVector_0 * *piVector_1;
  4266. qSum += *(piVector_0+1) * *(piVector_1+1);
  4267. qSum += *(piVector_0+2) * *(piVector_1+2);
  4268. qSum += *(piVector_0+3) * *(piVector_1+3);
  4269. piVector_0 += 4;
  4270. piVector_1 += 4;
  4271. uiLength -= 4;
  4272. }
  4273. /********************************************************************/
  4274. /* Conditionally do a group of 2 multiply-accumulates. */
  4275. /********************************************************************/
  4276. if ( uiLength >= 2 )
  4277. {
  4278. qSum += *piVector_0 * *piVector_1;
  4279. qSum += *(piVector_0+1) * *(piVector_1+1);
  4280. piVector_0 += 2;
  4281. piVector_1 += 2;
  4282. uiLength -= 2;
  4283. }
  4284. /********************************************************************/
  4285. /* Conditionally do a single multiply-accumulate. */
  4286. /********************************************************************/
  4287. if ( uiLength >= 1 )
  4288. {
  4289. qSum += *piVector_0 * *piVector_1;
  4290. }
  4291. return qSum;
  4292. }
  4293. /**********************************************************************/
  4294. /**********************************************************************/
  4295. /* */
  4296. /* Function: FirFilter */
  4297. /* Author: Bill Hallahan */
  4298. /* Date: March 10, 1997 */
  4299. /* */
  4300. /* Abstract: */
  4301. /* */
  4302. /* This function returns the dot product of a set of FIR */
  4303. /* filter coefficients and the data in a circular delay line. */
  4304. /* All of the input and output data has Q15 scaling. */
  4305. /* */
  4306. /* Inputs: */
  4307. /* */
  4308. /* piFilterCoefficients A pointer to the FIR filter */
  4309. /* coefficients which are in reverse time */
  4310. /* order. */
  4311. /* */
  4312. /* piFilterDelay A pointer to a delay line that contains the */
  4313. /* input samples. */
  4314. /* */
  4315. /* iDelayPosition An index into the filter delay line. */
  4316. /* */
  4317. /* iFilterLength The length of the filter impulse response. */
  4318. /* (Also the number of filter coefficients. */
  4319. /* */
  4320. /* */
  4321. /* Outputs: */
  4322. /* */
  4323. /* The dot product of the fir filter coefficients and the */
  4324. /* data in the circular delay line is returned. */
  4325. /* */
  4326. /**********************************************************************/
  4327. /**********************************************************************/
  4328. /**********************************************************************/
  4329. /* Start of routine FirFilter(). */
  4330. /**********************************************************************/
  4331. int FirFilter( int * piFilterCoefficients,
  4332. int * piFilterDelay,
  4333. unsigned int uiDelayPosition,
  4334. unsigned int uiFilterLength )
  4335. {
  4336. int iSum;
  4337. _int64 qSum;
  4338. unsigned int uiRemaining;
  4339. uiRemaining = uiFilterLength - uiDelayPosition;
  4340. qSum = DotProduct( piFilterCoefficients,
  4341. &piFilterDelay[uiDelayPosition],
  4342. uiRemaining );
  4343. qSum += DotProduct( piFilterCoefficients + uiRemaining,
  4344. &piFilterDelay[0],
  4345. uiDelayPosition );
  4346. /********************************************************************/
  4347. /* Scale the Q30 number to be a Q15 number. */
  4348. /********************************************************************/
  4349. iSum = (int)( qSum >> 15 );
  4350. return iSum;
  4351. }
  4352. /**********************************************************************/
  4353. /**********************************************************************/
  4354. /* */
  4355. /* Function: SampleRate6400To8000 */
  4356. /* Author: Bill Hallahan */
  4357. /* Date: March 8, 1997 */
  4358. /* */
  4359. /* Abstract: */
  4360. /* */
  4361. /* This function converts a block of audio samples from an */
  4362. /* 6400 Hz. sample rate to an 8000 Hz. sample rate. This is done */
  4363. /* using a set of polyphase filters that can interpolate up to a */
  4364. /* 32000 Hz. rate ( 32000 is the LCM of 8000 and 6400.) */
  4365. /* */
  4366. /* Only the 32000 Hz. samples that correspond to an 8000 Hz. */
  4367. /* sample rate are calculated. The input 6400 Hz. rate corresponds */
  4368. /* to every 5th (32000/6400) sample at the 32000 Hz. rate. The */
  4369. /* output 8000 Hz. rate corresponds to every 4th (32000/8000) */
  4370. /* sample at the 32000 Hz. rate. Since the LCM of 4 and 5 is 20, */
  4371. /* then the pattern of sample insertion and polyphase filter */
  4372. /* selection will repeat every 20 output samples. */
  4373. /* */
  4374. /* */
  4375. /* Inputs: */
  4376. /* */
  4377. /* pwInputBuffer A pointer to an input buffer of samples */
  4378. /* that are sampled at an 6400 Hz. rate. The */
  4379. /* samples are in Q15 format and must be */
  4380. /* in the range of ( 1 - 2^-15) to -1. */
  4381. /* */
  4382. /* pwOutputBuffer A buffer that returns the output data */
  4383. /* which is the input buffer data resampled */
  4384. /* at 8000 Hz. */
  4385. /* */
  4386. /* The output bufer length MUST be large */
  4387. /* enough to accept all of the output data. */
  4388. /* The minimum length of the output buffer */
  4389. /* is 5/4 times the number of samples in the */
  4390. /* input buffer. ( 8000/6400 = 5/4 ) */
  4391. /* */
  4392. /* uiInputLength The number of samples in the input buffer. */
  4393. /* */
  4394. /* */
  4395. /* THE FOLLOWING INPUT VARIABLES ARE USED */
  4396. /* TO MAINTAIN STATE INFORMATION BETWEEN */
  4397. /* CALLS TO THIS ROUTINE. */
  4398. /* */
  4399. /* */
  4400. /* piFilterDelay A pointer to a delay line that is used */
  4401. /* for FIR filtering. This must be the */
  4402. /* length of the polyphase filter's impulse */
  4403. /* response. For this routine this is 56. */
  4404. /* This buffer should be initialized to zero */
  4405. /* once at system initialization. */
  4406. /* */
  4407. /* puiDelayPosition A pointer to an index into the filter */
  4408. /* delay line. This index value should be */
  4409. /* initialized to zero at system startup */
  4410. /* */
  4411. /* piInputSampleTime A pointer to the input sample time. */
  4412. /* This time is reset to zero by this routine */
  4413. /* when is reaches the value STEP_PRODUCT. */
  4414. /* This time is used to track the input */
  4415. /* stream time relative to the output stream */
  4416. /* time. This time difference is used to */
  4417. /* determine whether a new input sample */
  4418. /* should be put into the filter delay line. */
  4419. /* This should be initialized to zero once */
  4420. /* at system initialization. */
  4421. /* */
  4422. /* piOutputSampleTime A pointer to the output sample time. */
  4423. /* This time is reset to zero by this routine */
  4424. /* when is reaches the value STEP_PRODUCT. */
  4425. /* This time is used to determine if a new */
  4426. /* polyphase filter should be applied to the */
  4427. /* input sample stream. This is also used to */
  4428. /* select the particular polyphase filter */
  4429. /* that is applied. */
  4430. /* */
  4431. /* Outputs: */
  4432. /* */
  4433. /* This function returns an unsigned integer that is the number */
  4434. /* of samples in the output buffer. If the number of input samples */
  4435. /* is exactly a multiple of RU_INPUT_SAMPLE_STEP ( 4 ) then this */
  4436. /* routine will always return the same value. This value will */
  4437. /* then be 5/4 times the number of input samples. */
  4438. /* */
  4439. /* When this function returns the output buffer contains an array */
  4440. /* of integers at the new sample rate. */
  4441. /* */
  4442. /* */
  4443. /* Filter Information: */
  4444. /* */
  4445. /* The 6400 Hz. -> 32000 Hz. interpolation filter design */
  4446. /* is shown here. */
  4447. /* */
  4448. /* H( 1) = -0.38306729E-03 = H(280) */
  4449. /* H( 2) = 0.49756566E-03 = H(279) */
  4450. /* H( 3) = 0.13501500E-02 = H(278) */
  4451. /* H( 4) = 0.27531907E-02 = H(277) */
  4452. /* H( 5) = 0.46118572E-02 = H(276) */
  4453. /* H( 6) = 0.67112772E-02 = H(275) */
  4454. /* H( 7) = 0.87157665E-02 = H(274) */
  4455. /* H( 8) = 0.10221261E-01 = H(273) */
  4456. /* H( 9) = 0.10843582E-01 = H(272) */
  4457. /* H( 10) = 0.10320566E-01 = H(271) */
  4458. /* H( 11) = 0.85992115E-02 = H(270) */
  4459. /* H( 12) = 0.58815549E-02 = H(269) */
  4460. /* H( 13) = 0.26067111E-02 = H(268) */
  4461. /* H( 14) = -0.63367974E-03 = H(267) */
  4462. /* H( 15) = -0.32284572E-02 = H(266) */
  4463. /* H( 16) = -0.46942858E-02 = H(265) */
  4464. /* H( 17) = -0.48050000E-02 = H(264) */
  4465. /* H( 18) = -0.36581988E-02 = H(263) */
  4466. /* H( 19) = -0.16504158E-02 = H(262) */
  4467. /* H( 20) = 0.61691226E-03 = H(261) */
  4468. /* H( 21) = 0.25050722E-02 = H(260) */
  4469. /* H( 22) = 0.35073524E-02 = H(259) */
  4470. /* H( 23) = 0.33904186E-02 = H(258) */
  4471. /* H( 24) = 0.22536262E-02 = H(257) */
  4472. /* H( 25) = 0.49328664E-03 = H(256) */
  4473. /* H( 26) = -0.13216439E-02 = H(255) */
  4474. /* H( 27) = -0.26241955E-02 = H(254) */
  4475. /* H( 28) = -0.30239364E-02 = H(253) */
  4476. /* H( 29) = -0.24250194E-02 = H(252) */
  4477. /* H( 30) = -0.10513559E-02 = H(251) */
  4478. /* H( 31) = 0.62918884E-03 = H(250) */
  4479. /* H( 32) = 0.20572424E-02 = H(249) */
  4480. /* H( 33) = 0.27652446E-02 = H(248) */
  4481. /* H( 34) = 0.25287948E-02 = H(247) */
  4482. /* H( 35) = 0.14388775E-02 = H(246) */
  4483. /* H( 36) = -0.12839703E-03 = H(245) */
  4484. /* H( 37) = -0.16392219E-02 = H(244) */
  4485. /* H( 38) = -0.25793985E-02 = H(243) */
  4486. /* H( 39) = -0.26292247E-02 = H(242) */
  4487. /* H( 40) = -0.17717101E-02 = H(241) */
  4488. /* H( 41) = -0.30041003E-03 = H(240) */
  4489. /* H( 42) = 0.12788962E-02 = H(239) */
  4490. /* H( 43) = 0.24192522E-02 = H(238) */
  4491. /* H( 44) = 0.27206307E-02 = H(237) */
  4492. /* H( 45) = 0.20694542E-02 = H(236) */
  4493. /* H( 46) = 0.68163598E-03 = H(235) */
  4494. /* H( 47) = -0.96732663E-03 = H(234) */
  4495. /* H( 48) = -0.23031780E-02 = H(233) */
  4496. /* H( 49) = -0.28516089E-02 = H(232) */
  4497. /* H( 50) = -0.24051941E-02 = H(231) */
  4498. /* H( 51) = -0.11016324E-02 = H(230) */
  4499. /* H( 52) = 0.61728584E-03 = H(229) */
  4500. /* H( 53) = 0.21542138E-02 = H(228) */
  4501. /* H( 54) = 0.29617085E-02 = H(227) */
  4502. /* H( 55) = 0.27367356E-02 = H(226) */
  4503. /* H( 56) = 0.15328785E-02 = H(225) */
  4504. /* H( 57) = -0.24891639E-03 = H(224) */
  4505. /* H( 58) = -0.19927153E-02 = H(223) */
  4506. /* H( 59) = -0.30787138E-02 = H(222) */
  4507. /* H( 60) = -0.31024679E-02 = H(221) */
  4508. /* H( 61) = -0.20239211E-02 = H(220) */
  4509. /* H( 62) = -0.19259547E-03 = H(219) */
  4510. /* H( 63) = 0.17642577E-02 = H(218) */
  4511. /* H( 64) = 0.31550473E-02 = H(217) */
  4512. /* H( 65) = 0.34669666E-02 = H(216) */
  4513. /* H( 66) = 0.25533440E-02 = H(215) */
  4514. /* H( 67) = 0.69819519E-03 = H(214) */
  4515. /* H( 68) = -0.14703817E-02 = H(213) */
  4516. /* H( 69) = -0.31912178E-02 = H(212) */
  4517. /* H( 70) = -0.38355463E-02 = H(211) */
  4518. /* H( 71) = -0.31353715E-02 = H(210) */
  4519. /* H( 72) = -0.12912996E-02 = H(209) */
  4520. /* H( 73) = 0.10815051E-02 = H(208) */
  4521. /* H( 74) = 0.31569856E-02 = H(207) */
  4522. /* H( 75) = 0.41838423E-02 = H(206) */
  4523. /* H( 76) = 0.37558281E-02 = H(205) */
  4524. /* H( 77) = 0.19692746E-02 = H(204) */
  4525. /* H( 78) = -0.59148070E-03 = H(203) */
  4526. /* H( 79) = -0.30430311E-02 = H(202) */
  4527. /* H( 80) = -0.45054569E-02 = H(201) */
  4528. /* H( 81) = -0.44158362E-02 = H(200) */
  4529. /* H( 82) = -0.27416693E-02 = H(199) */
  4530. /* H( 83) = -0.14716905E-04 = H(198) */
  4531. /* H( 84) = 0.28351138E-02 = H(197) */
  4532. /* H( 85) = 0.47940183E-02 = H(196) */
  4533. /* H( 86) = 0.51221889E-02 = H(195) */
  4534. /* H( 87) = 0.36296796E-02 = H(194) */
  4535. /* H( 88) = 0.76842826E-03 = H(193) */
  4536. /* H( 89) = -0.24999138E-02 = H(192) */
  4537. /* H( 90) = -0.50239447E-02 = H(191) */
  4538. /* H( 91) = -0.58644302E-02 = H(190) */
  4539. /* H( 92) = -0.46395971E-02 = H(189) */
  4540. /* H( 93) = -0.16878319E-02 = H(188) */
  4541. /* H( 94) = 0.20179905E-02 = H(187) */
  4542. /* H( 95) = 0.51868116E-02 = H(186) */
  4543. /* H( 96) = 0.66543561E-02 = H(185) */
  4544. /* H( 97) = 0.58053876E-02 = H(184) */
  4545. /* H( 98) = 0.28218545E-02 = H(183) */
  4546. /* H( 99) = -0.13399328E-02 = H(182) */
  4547. /* H(100) = -0.52496092E-02 = H(181) */
  4548. /* H(101) = -0.74876603E-02 = H(180) */
  4549. /* H(102) = -0.71534920E-02 = H(179) */
  4550. /* H(103) = -0.42167297E-02 = H(178) */
  4551. /* H(104) = 0.42133522E-03 = H(177) */
  4552. /* H(105) = 0.51945718E-02 = H(176) */
  4553. /* H(106) = 0.83916243E-02 = H(175) */
  4554. /* H(107) = 0.87586977E-02 = H(174) */
  4555. /* H(108) = 0.59769331E-02 = H(173) */
  4556. /* H(109) = 0.83726482E-03 = H(172) */
  4557. /* H(110) = -0.49680225E-02 = H(171) */
  4558. /* H(111) = -0.93886480E-02 = H(170) */
  4559. /* H(112) = -0.10723907E-01 = H(169) */
  4560. /* H(113) = -0.82560331E-02 = H(168) */
  4561. /* H(114) = -0.25802210E-02 = H(167) */
  4562. /* H(115) = 0.45066439E-02 = H(166) */
  4563. /* H(116) = 0.10552152E-01 = H(165) */
  4564. /* H(117) = 0.13269756E-01 = H(164) */
  4565. /* H(118) = 0.11369097E-01 = H(163) */
  4566. /* H(119) = 0.51042791E-02 = H(162) */
  4567. /* H(120) = -0.36742561E-02 = H(161) */
  4568. /* H(121) = -0.12025163E-01 = H(160) */
  4569. /* H(122) = -0.16852396E-01 = H(159) */
  4570. /* H(123) = -0.15987474E-01 = H(158) */
  4571. /* H(124) = -0.90587810E-02 = H(157) */
  4572. /* H(125) = 0.21703094E-02 = H(156) */
  4573. /* H(126) = 0.14162681E-01 = H(155) */
  4574. /* H(127) = 0.22618638E-01 = H(154) */
  4575. /* H(128) = 0.23867993E-01 = H(153) */
  4576. /* H(129) = 0.16226372E-01 = H(152) */
  4577. /* H(130) = 0.87251863E-03 = H(151) */
  4578. /* H(131) = -0.18082183E-01 = H(150) */
  4579. /* H(132) = -0.34435309E-01 = H(149) */
  4580. /* H(133) = -0.41475002E-01 = H(148) */
  4581. /* H(134) = -0.33891901E-01 = H(147) */
  4582. /* H(135) = -0.94815092E-02 = H(146) */
  4583. /* H(136) = 0.29874707E-01 = H(145) */
  4584. /* H(137) = 0.78281499E-01 = H(144) */
  4585. /* H(138) = 0.12699878E+00 = H(143) */
  4586. /* H(139) = 0.16643921E+00 = H(142) */
  4587. /* H(140) = 0.18848117E+00 = H(141) */
  4588. /* */
  4589. /* BAND 1 BAND 2 */
  4590. /* LOWER BAND EDGE 0.0000000 0.1000000 */
  4591. /* UPPER BAND EDGE 0.0937500 0.5000000 */
  4592. /* DESIRED VALUE 1.0000000 0.0000000 */
  4593. /* WEIGHTING 0.0080000 1.0000000 */
  4594. /* DEVIATION 0.1223457 0.0009788 */
  4595. /* DEVIATION IN DB 1.0025328 -60.1864281 */
  4596. /* */
  4597. /* EXTREMAL FREQUENCIES--MAXIMA OF THE ERROR CURVE */
  4598. /* 0.0000000 0.0037946 0.0075893 0.0113839 0.0149554 */
  4599. /* 0.0187500 0.0225446 0.0263393 0.0301339 0.0339286 */
  4600. /* 0.0377232 0.0415179 0.0450894 0.0488840 0.0526787 */
  4601. /* 0.0566966 0.0604912 0.0642859 0.0680805 0.0718751 */
  4602. /* 0.0758929 0.0796875 0.0837053 0.0877231 0.0915177 */
  4603. /* 0.0937500 0.1000000 0.1006696 0.1024553 0.1049107 */
  4604. /* 0.1075892 0.1107142 0.1138391 0.1169641 0.1203123 */
  4605. /* 0.1236605 0.1270087 0.1305802 0.1339285 0.1372768 */
  4606. /* 0.1408483 0.1444198 0.1477681 0.1513396 0.1549111 */
  4607. /* 0.1584826 0.1618309 0.1654024 0.1689740 0.1725455 */
  4608. /* 0.1761170 0.1796885 0.1832600 0.1868315 0.1901798 */
  4609. /* 0.1937513 0.1973228 0.2008943 0.2044658 0.2080373 */
  4610. /* 0.2116089 0.2151804 0.2187519 0.2223234 0.2258949 */
  4611. /* 0.2294664 0.2330379 0.2366094 0.2401809 0.2437524 */
  4612. /* 0.2473240 0.2508955 0.2544670 0.2580385 0.2616100 */
  4613. /* 0.2651815 0.2687530 0.2723245 0.2761193 0.2796908 */
  4614. /* 0.2832623 0.2868338 0.2904053 0.2939768 0.2975483 */
  4615. /* 0.3011198 0.3046913 0.3082629 0.3118344 0.3154059 */
  4616. /* 0.3189774 0.3225489 0.3261204 0.3296919 0.3332634 */
  4617. /* 0.3368349 0.3404064 0.3439780 0.3475495 0.3511210 */
  4618. /* 0.3549157 0.3584872 0.3620587 0.3656302 0.3692017 */
  4619. /* 0.3727733 0.3763448 0.3799163 0.3834878 0.3870593 */
  4620. /* 0.3906308 0.3942023 0.3977738 0.4013453 0.4049169 */
  4621. /* 0.4084884 0.4120599 0.4158546 0.4194261 0.4229976 */
  4622. /* 0.4265691 0.4301406 0.4337122 0.4372837 0.4408552 */
  4623. /* 0.4444267 0.4479982 0.4515697 0.4551412 0.4587127 */
  4624. /* 0.4622842 0.4658557 0.4694273 0.4732220 0.4767935 */
  4625. /* 0.4803650 0.4839365 0.4875080 0.4910795 0.4946510 */
  4626. /* 0.4982226 */
  4627. /* */
  4628. /**********************************************************************/
  4629. /**********************************************************************/
  4630. /**********************************************************************/
  4631. /* Symbol Definitions. */
  4632. /**********************************************************************/
  4633. #define RU_INPUT_SAMPLE_STEP 5
  4634. #define RU_OUTPUT_SAMPLE_STEP 4
  4635. #define RU_STEP_PRODUCT ( RU_INPUT_SAMPLE_STEP * RU_OUTPUT_SAMPLE_STEP )
  4636. #define RU_POLYPHASE_FILTER_LENGTH 56
  4637. /**********************************************************************/
  4638. /* Start of SampleRate6400To8000 routine */
  4639. /**********************************************************************/
  4640. unsigned int SampleRate6400To8000( short * pwInputBuffer,
  4641. short * pwOutputBuffer,
  4642. unsigned int uiInputBufferLength,
  4643. int * piFilterDelay,
  4644. unsigned int * puiDelayPosition,
  4645. int * piInputSampleTime,
  4646. int * piOutputSampleTime )
  4647. {
  4648. static int iPolyphaseFilter_0[56] =
  4649. {
  4650. 755,
  4651. 1690,
  4652. -528,
  4653. 101,
  4654. 80,
  4655. -172,
  4656. 235,
  4657. -290,
  4658. 339,
  4659. -394,
  4660. 448,
  4661. -508,
  4662. 568,
  4663. -628,
  4664. 685,
  4665. -738,
  4666. 785,
  4667. -823,
  4668. 849,
  4669. -860,
  4670. 851,
  4671. -813,
  4672. 738,
  4673. -601,
  4674. 355,
  4675. 142,
  4676. -1553,
  4677. 30880,
  4678. 4894,
  4679. -2962,
  4680. 2320,
  4681. -1970,
  4682. 1728,
  4683. -1538,
  4684. 1374,
  4685. -1226,
  4686. 1090,
  4687. -960,
  4688. 839,
  4689. -723,
  4690. 615,
  4691. -513,
  4692. 418,
  4693. -331,
  4694. 251,
  4695. -180,
  4696. 111,
  4697. -49,
  4698. -21,
  4699. 103,
  4700. -216,
  4701. 410,
  4702. -769,
  4703. 1408,
  4704. 1099,
  4705. -62
  4706. };
  4707. static int iPolyphaseFilter_1[56] =
  4708. {
  4709. 451,
  4710. 1776,
  4711. -103,
  4712. -270,
  4713. 369,
  4714. -397,
  4715. 414,
  4716. -430,
  4717. 445,
  4718. -467,
  4719. 485,
  4720. -504,
  4721. 516,
  4722. -522,
  4723. 517,
  4724. -498,
  4725. 464,
  4726. -409,
  4727. 330,
  4728. -219,
  4729. 69,
  4730. 137,
  4731. -422,
  4732. 836,
  4733. -1484,
  4734. 2658,
  4735. -5552,
  4736. 27269,
  4737. 12825,
  4738. -5641,
  4739. 3705,
  4740. -2761,
  4741. 2174,
  4742. -1757,
  4743. 1435,
  4744. -1172,
  4745. 951,
  4746. -760,
  4747. 594,
  4748. -449,
  4749. 322,
  4750. -211,
  4751. 114,
  4752. -31,
  4753. -40,
  4754. 101,
  4755. -158,
  4756. 209,
  4757. -268,
  4758. 337,
  4759. -429,
  4760. 574,
  4761. -787,
  4762. 963,
  4763. 1427,
  4764. 81
  4765. };
  4766. static int iPolyphaseFilter_2[56] =
  4767. {
  4768. 221,
  4769. 1674,
  4770. 427,
  4771. -599,
  4772. 555,
  4773. -495,
  4774. 453,
  4775. -422,
  4776. 396,
  4777. -377,
  4778. 352,
  4779. -326,
  4780. 289,
  4781. -240,
  4782. 177,
  4783. -96,
  4784. -2,
  4785. 125,
  4786. -276,
  4787. 462,
  4788. -690,
  4789. 979,
  4790. -1352,
  4791. 1862,
  4792. -2619,
  4793. 3910,
  4794. -6795,
  4795. 20807,
  4796. 20807,
  4797. -6795,
  4798. 3910,
  4799. -2619,
  4800. 1862,
  4801. -1352,
  4802. 979,
  4803. -690,
  4804. 462,
  4805. -276,
  4806. 125,
  4807. -2,
  4808. -96,
  4809. 177,
  4810. -240,
  4811. 289,
  4812. -326,
  4813. 352,
  4814. -377,
  4815. 396,
  4816. -422,
  4817. 453,
  4818. -495,
  4819. 555,
  4820. -599,
  4821. 427,
  4822. 1674,
  4823. 221
  4824. };
  4825. static int iPolyphaseFilter_3[56] =
  4826. {
  4827. 81,
  4828. 1427,
  4829. 963,
  4830. -787,
  4831. 574,
  4832. -429,
  4833. 337,
  4834. -268,
  4835. 209,
  4836. -158,
  4837. 101,
  4838. -40,
  4839. -31,
  4840. 114,
  4841. -211,
  4842. 322,
  4843. -449,
  4844. 594,
  4845. -760,
  4846. 951,
  4847. -1172,
  4848. 1435,
  4849. -1757,
  4850. 2174,
  4851. -2761,
  4852. 3705,
  4853. -5641,
  4854. 12825,
  4855. 27269,
  4856. -5552,
  4857. 2658,
  4858. -1484,
  4859. 836,
  4860. -422,
  4861. 137,
  4862. 69,
  4863. -219,
  4864. 330,
  4865. -409,
  4866. 464,
  4867. -498,
  4868. 517,
  4869. -522,
  4870. 516,
  4871. -504,
  4872. 485,
  4873. -467,
  4874. 445,
  4875. -430,
  4876. 414,
  4877. -397,
  4878. 369,
  4879. -270,
  4880. -103,
  4881. 1776,
  4882. 451
  4883. };
  4884. static int iPolyphaseFilter_4[56] =
  4885. {
  4886. -62,
  4887. 1099,
  4888. 1408,
  4889. -769,
  4890. 410,
  4891. -216,
  4892. 103,
  4893. -21,
  4894. -49,
  4895. 111,
  4896. -180,
  4897. 251,
  4898. -331,
  4899. 418,
  4900. -513,
  4901. 615,
  4902. -723,
  4903. 839,
  4904. -960,
  4905. 1090,
  4906. -1226,
  4907. 1374,
  4908. -1538,
  4909. 1728,
  4910. -1970,
  4911. 2320,
  4912. -2962,
  4913. 4894,
  4914. 30880,
  4915. -1553,
  4916. 142,
  4917. 355,
  4918. -601,
  4919. 738,
  4920. -813,
  4921. 851,
  4922. -860,
  4923. 849,
  4924. -823,
  4925. 785,
  4926. -738,
  4927. 685,
  4928. -628,
  4929. 568,
  4930. -508,
  4931. 448,
  4932. -394,
  4933. 339,
  4934. -290,
  4935. 235,
  4936. -172,
  4937. 80,
  4938. 101,
  4939. -528,
  4940. 1690,
  4941. 755
  4942. };
  4943. static int * ppiPolyphaseFilter[5] =
  4944. {
  4945. &iPolyphaseFilter_0[0],
  4946. &iPolyphaseFilter_1[0],
  4947. &iPolyphaseFilter_2[0],
  4948. &iPolyphaseFilter_3[0],
  4949. &iPolyphaseFilter_4[0]
  4950. };
  4951. register int * piFilterCoefficients;
  4952. register int iFilterIndex;
  4953. register unsigned int uiDelayPosition;
  4954. register int iInputSampleTime;
  4955. register int iOutputSampleTime;
  4956. register unsigned int uiInputIndex = 0;
  4957. register unsigned int uiOutputIndex = 0;
  4958. /********************************************************************/
  4959. /* Get the input filter state parameters. */
  4960. /********************************************************************/
  4961. uiDelayPosition = *puiDelayPosition;
  4962. iInputSampleTime = *piInputSampleTime;
  4963. iOutputSampleTime = *piOutputSampleTime;
  4964. /********************************************************************/
  4965. /* Loop and process all of the input samples. */
  4966. /********************************************************************/
  4967. while ( uiInputIndex < uiInputBufferLength )
  4968. {
  4969. /******************************************************************/
  4970. /* Put input samples in interpolator delay buffer until we */
  4971. /* catch up to the next output sample time index. */
  4972. /******************************************************************/
  4973. while (( iInputSampleTime <= iOutputSampleTime )
  4974. && ( uiInputIndex < uiInputBufferLength ))
  4975. {
  4976. /****************************************************************/
  4977. /* Put a new imput sample in the polyphase filter delay line. */
  4978. /****************************************************************/
  4979. piFilterDelay[uiDelayPosition++] = (int)pwInputBuffer[uiInputIndex++];
  4980. if ( uiDelayPosition >= RU_POLYPHASE_FILTER_LENGTH )
  4981. {
  4982. uiDelayPosition = 0;
  4983. }
  4984. /****************************************************************/
  4985. /* Increment the input sample time index. */
  4986. /****************************************************************/
  4987. iInputSampleTime += RU_INPUT_SAMPLE_STEP;
  4988. }
  4989. /******************************************************************/
  4990. /* Calculate output samples using the interpolator until we */
  4991. /* reach the next input sample time. */
  4992. /******************************************************************/
  4993. while ( iOutputSampleTime < iInputSampleTime )
  4994. {
  4995. /****************************************************************/
  4996. /* Calculate the polyphase filter index that corresponds to */
  4997. /* the next output sample. */
  4998. /****************************************************************/
  4999. iFilterIndex = iOutputSampleTime;
  5000. while ( iFilterIndex >= RU_INPUT_SAMPLE_STEP )
  5001. {
  5002. iFilterIndex = iFilterIndex - RU_INPUT_SAMPLE_STEP;
  5003. }
  5004. /****************************************************************/
  5005. /* Get the polyphase filter coefficients. */
  5006. /****************************************************************/
  5007. piFilterCoefficients = ppiPolyphaseFilter[iFilterIndex];
  5008. /****************************************************************/
  5009. /* Apply the polyphase filter. */
  5010. /****************************************************************/
  5011. pwOutputBuffer[uiOutputIndex++] =
  5012. (short)FirFilter( piFilterCoefficients,
  5013. piFilterDelay,
  5014. uiDelayPosition,
  5015. RU_POLYPHASE_FILTER_LENGTH );
  5016. /****************************************************************/
  5017. /* Increment the output sample time index. */
  5018. /****************************************************************/
  5019. iOutputSampleTime += RU_OUTPUT_SAMPLE_STEP;
  5020. }
  5021. /******************************************************************/
  5022. /* Wrap the input and output times indices so they don't */
  5023. /* overflow and go back to process more of the input block. */
  5024. /******************************************************************/
  5025. if ( iInputSampleTime >= RU_STEP_PRODUCT )
  5026. {
  5027. iInputSampleTime -= RU_STEP_PRODUCT;
  5028. iOutputSampleTime -= RU_STEP_PRODUCT;
  5029. }
  5030. }
  5031. /********************************************************************/
  5032. /* Save the input filter state parameters. */
  5033. /********************************************************************/
  5034. *puiDelayPosition = uiDelayPosition;
  5035. *piInputSampleTime = iInputSampleTime;
  5036. *piOutputSampleTime = iOutputSampleTime;
  5037. /********************************************************************/
  5038. /* Return the number of samples in the output buffer. */
  5039. /********************************************************************/
  5040. return uiOutputIndex;
  5041. }
  5042. /**********************************************************************/
  5043. /**********************************************************************/
  5044. /* */
  5045. /* Function: SampleRate8000To6400 */
  5046. /* Author: Bill Hallahan */
  5047. /* Date: March 8, 1997 */
  5048. /* */
  5049. /* Abstract: */
  5050. /* */
  5051. /* This function converts a block of audio samples from an */
  5052. /* 8000 Hz. sample rate to a 6400 Hz. sample rate. This is done */
  5053. /* using a set of polyphase filters that can interpolate up to a */
  5054. /* 32000 Hz. rate ( 32000 is the LCM of 8000 and 6400.) */
  5055. /* */
  5056. /* Only the 32000 Hz. samples that correspond to a 6400 Hz. */
  5057. /* sample rate are calculated. The input 8000 Hz. rate corresponds */
  5058. /* to every 4th (32000/8000) sample at the 32000 Hz. rate. The */
  5059. /* output 6400 Hz. rate corresponds to every 5th (32000/6400) */
  5060. /* sample at the 32000 Hz. rate. Since the LCM of 4 and 5 is 20, */
  5061. /* then the pattern of sample insertion and polyphase filter */
  5062. /* selection will repeat every 20 output samples. */
  5063. /* */
  5064. /* */
  5065. /* Inputs: */
  5066. /* */
  5067. /* pwInputBuffer A pointer to an input buffer of samples */
  5068. /* that are sampled at an 8000 Hz. rate. The */
  5069. /* samples are in Q15 format and must be */
  5070. /* in the range of ( 1 - 2^-15) to -1. */
  5071. /* */
  5072. /* pwOutputBuffer A buffer that returns the output data */
  5073. /* which is the input buffer data resampled */
  5074. /* at 6400 Hz. Since this is a lower sample */
  5075. /* rate than the input rate the data is also */
  5076. /* low pass filtered during the conversion */
  5077. /* process. The low pass filter cutoff */
  5078. /* frequency is at 3000 Hz. All alias */
  5079. /* products are down at least 60 dB. past */
  5080. /* 3100 Hz. */
  5081. /* */
  5082. /* The output bufer length MUST be large */
  5083. /* enough to accept all of the output data. */
  5084. /* The minimum length of the output buffer */
  5085. /* is 4/5 times the number of samples in the */
  5086. /* input buffer. ( 6400/8000 = 4/5 ) */
  5087. /* */
  5088. /* uiInputLength The number of samples in the input buffer. */
  5089. /* */
  5090. /* */
  5091. /* THE FOLLOWING INPUT VARIABLES ARE USED */
  5092. /* TO MAINTAIN STATE INFORMATION BETWEEN */
  5093. /* CALLS TO THIS ROUTINE. */
  5094. /* */
  5095. /* */
  5096. /* piFilterDelay A pointer to a delay line that is used */
  5097. /* for FIR filtering. This must be the */
  5098. /* length of the polyphase filter's impulse */
  5099. /* response. For this routine this is 23. */
  5100. /* This buffer should be initialized to zero */
  5101. /* once at system initialization. */
  5102. /* */
  5103. /* puiDelayPosition A pointer to an index into the filter */
  5104. /* delay line. This index value should be */
  5105. /* initialized to zero at system startup */
  5106. /* */
  5107. /* piInputSampleTime A pointer to the input sample time. */
  5108. /* This time is reset to zero by this routine */
  5109. /* when is reaches the value STEP_PRODUCT. */
  5110. /* This time is used to track the input */
  5111. /* stream time relative to the output stream */
  5112. /* time. This time difference is used to */
  5113. /* determine whether a new input sample */
  5114. /* should be put into the filter delay line. */
  5115. /* This should be initialized to zero once */
  5116. /* at system initialization. */
  5117. /* */
  5118. /* piOutputSampleTime A pointer to the output sample time. */
  5119. /* This time is reset to zero by this routine */
  5120. /* when is reaches the value STEP_PRODUCT. */
  5121. /* This time is used to determine if a new */
  5122. /* polyphase filter should be applied to the */
  5123. /* input sample stream. This is also used to */
  5124. /* select the particular polyphase filter */
  5125. /* that is applied. */
  5126. /* */
  5127. /* Outputs: */
  5128. /* */
  5129. /* This function returns an unsigned integer that is the number */
  5130. /* of samples in the output buffer. If the number of input samples */
  5131. /* is exactly a multiple of RD_INPUT_SAMPLE_STEP ( 5 ) then this */
  5132. /* routine will always return the same value. This value will */
  5133. /* then be 4/5 times the number of input samples. */
  5134. /* */
  5135. /* When this function returns the output buffer contains an array */
  5136. /* of integers at the new sample rate. */
  5137. /* */
  5138. /* */
  5139. /* Filter Information: */
  5140. /* */
  5141. /* The 8000 Hz. -> 32000 Hz. interpolation filter design */
  5142. /* is shown here. */
  5143. /* */
  5144. /* FINITE IMPULSE RESPONSE (FIR) */
  5145. /* LINEAR PHASE DIGITAL FILTER DESIGN */
  5146. /* REMEZ EXCHANGE ALGORITHM */
  5147. /* */
  5148. /* BANDPASS FILTER */
  5149. /* */
  5150. /* FILTER LENGTH = 92 */
  5151. /* */
  5152. /* ***** IMPULSE RESPONSE ***** */
  5153. /* H( 1) = -0.77523338E-03 = H( 92) */
  5154. /* H( 2) = -0.56140189E-03 = H( 91) */
  5155. /* H( 3) = -0.26485065E-03 = H( 90) */
  5156. /* H( 4) = 0.48529240E-03 = H( 89) */
  5157. /* H( 5) = 0.15506579E-02 = H( 88) */
  5158. /* H( 6) = 0.25692214E-02 = H( 87) */
  5159. /* H( 7) = 0.30662031E-02 = H( 86) */
  5160. /* H( 8) = 0.26577783E-02 = H( 85) */
  5161. /* H( 9) = 0.12834022E-02 = H( 84) */
  5162. /* H( 10) = -0.67870057E-03 = H( 83) */
  5163. /* H( 11) = -0.24781306E-02 = H( 82) */
  5164. /* H( 12) = -0.32756536E-02 = H( 81) */
  5165. /* H( 13) = -0.25334368E-02 = H( 80) */
  5166. /* H( 14) = -0.34487492E-03 = H( 79) */
  5167. /* H( 15) = 0.24779409E-02 = H( 78) */
  5168. /* H( 16) = 0.46604010E-02 = H( 77) */
  5169. /* H( 17) = 0.50008399E-02 = H( 76) */
  5170. /* H( 18) = 0.29790259E-02 = H( 75) */
  5171. /* H( 19) = -0.85979374E-03 = H( 74) */
  5172. /* H( 20) = -0.49750470E-02 = H( 73) */
  5173. /* H( 21) = -0.74064843E-02 = H( 72) */
  5174. /* H( 22) = -0.66624931E-02 = H( 71) */
  5175. /* H( 23) = -0.25365327E-02 = H( 70) */
  5176. /* H( 24) = 0.35602755E-02 = H( 69) */
  5177. /* H( 25) = 0.90023531E-02 = H( 68) */
  5178. /* H( 26) = 0.11015911E-01 = H( 67) */
  5179. /* H( 27) = 0.80042975E-02 = H( 66) */
  5180. /* H( 28) = 0.53222617E-03 = H( 65) */
  5181. /* H( 29) = -0.85644918E-02 = H( 64) */
  5182. /* H( 30) = -0.15142974E-01 = H( 63) */
  5183. /* H( 31) = -0.15514131E-01 = H( 62) */
  5184. /* H( 32) = -0.82975281E-02 = H( 61) */
  5185. /* H( 33) = 0.44855666E-02 = H( 60) */
  5186. /* H( 34) = 0.17722420E-01 = H( 59) */
  5187. /* H( 35) = 0.25017589E-01 = H( 58) */
  5188. /* H( 36) = 0.21431517E-01 = H( 57) */
  5189. /* H( 37) = 0.60814521E-02 = H( 56) */
  5190. /* H( 38) = -0.16557660E-01 = H( 55) */
  5191. /* H( 39) = -0.37409518E-01 = H( 54) */
  5192. /* H( 40) = -0.45595154E-01 = H( 53) */
  5193. /* H( 41) = -0.32403238E-01 = H( 52) */
  5194. /* H( 42) = 0.50128344E-02 = H( 51) */
  5195. /* H( 43) = 0.61689958E-01 = H( 50) */
  5196. /* H( 44) = 0.12557802E+00 = H( 49) */
  5197. /* H( 45) = 0.18087465E+00 = H( 48) */
  5198. /* H( 46) = 0.21291447E+00 = H( 47) */
  5199. /* */
  5200. /* BAND 1 BAND 2 */
  5201. /* LOWER BAND EDGE 0.0000000 0.1250000 */
  5202. /* UPPER BAND EDGE 0.0968750 0.5000000 */
  5203. /* DESIRED VALUE 1.0000000 0.0000000 */
  5204. /* WEIGHTING 0.0700000 1.0000000 */
  5205. /* DEVIATION 0.0136339 0.0009544 */
  5206. /* DEVIATION IN DB 0.1176231 -60.4056206 */
  5207. /* */
  5208. /* EXTREMAL FREQUENCIES--MAXIMA OF THE ERROR CURVE */
  5209. /* 0.0000000 0.0129076 0.0251359 0.0380435 0.0495924 */
  5210. /* 0.0618206 0.0733696 0.0842392 0.0930708 0.0968750 */
  5211. /* 0.1250000 0.1270380 0.1331521 0.1413043 0.1501357 */
  5212. /* 0.1596465 0.1698367 0.1800269 0.1908964 0.2010865 */
  5213. /* 0.2119560 0.2228255 0.2330157 0.2438852 0.2547547 */
  5214. /* 0.2656242 0.2764937 0.2873632 0.2982327 0.3091022 */
  5215. /* 0.3199717 0.3308412 0.3417107 0.3525802 0.3634497 */
  5216. /* 0.3743192 0.3851887 0.3960582 0.4069277 0.4177972 */
  5217. /* 0.4293461 0.4402156 0.4510851 0.4619546 0.4728241 */
  5218. /* 0.4836936 0.4945631 */
  5219. /* */
  5220. /**********************************************************************/
  5221. /**********************************************************************/
  5222. /**********************************************************************/
  5223. /* Symbol Definitions. */
  5224. /**********************************************************************/
  5225. #define RD_INPUT_SAMPLE_STEP 4
  5226. #define RD_OUTPUT_SAMPLE_STEP 5
  5227. #define RD_STEP_PRODUCT ( RD_INPUT_SAMPLE_STEP * RD_OUTPUT_SAMPLE_STEP )
  5228. #define RD_POLYPHASE_FILTER_LENGTH 23
  5229. /**********************************************************************/
  5230. /* Start of SampleRate8000To6400 routine */
  5231. /**********************************************************************/
  5232. unsigned int SampleRate8000To6400( short * pwInputBuffer,
  5233. short * pwOutputBuffer,
  5234. unsigned int uiInputBufferLength,
  5235. int * piFilterDelay,
  5236. unsigned int * puiDelayPosition,
  5237. int * piInputSampleTime,
  5238. int * piOutputSampleTime )
  5239. {
  5240. static int iPolyphaseFilter_0[23] =
  5241. {
  5242. 62,
  5243. 344,
  5244. -424,
  5245. 604,
  5246. -644,
  5247. 461,
  5248. 68,
  5249. -1075,
  5250. 2778,
  5251. -5910,
  5252. 16277,
  5253. 23445,
  5254. -4200,
  5255. 788,
  5256. 581,
  5257. -1110,
  5258. 1166,
  5259. -960,
  5260. 648,
  5261. -328,
  5262. 166,
  5263. 201,
  5264. -100
  5265. };
  5266. static int iPolyphaseFilter_1[23] =
  5267. {
  5268. -34,
  5269. 397,
  5270. -321,
  5271. 321,
  5272. -111,
  5273. -328,
  5274. 1037,
  5275. -2011,
  5276. 3242,
  5277. -4849,
  5278. 7996,
  5279. 27598,
  5280. 649,
  5281. -2146,
  5282. 2297,
  5283. -1962,
  5284. 1427,
  5285. -863,
  5286. 386,
  5287. -44,
  5288. -87,
  5289. 333,
  5290. -72
  5291. };
  5292. static int iPolyphaseFilter_2[23] =
  5293. {
  5294. -72,
  5295. 333,
  5296. -87,
  5297. -44,
  5298. 386,
  5299. -863,
  5300. 1427,
  5301. -1962,
  5302. 2297,
  5303. -2146,
  5304. 649,
  5305. 27598,
  5306. 7996,
  5307. -4849,
  5308. 3242,
  5309. -2011,
  5310. 1037,
  5311. -328,
  5312. -111,
  5313. 321,
  5314. -321,
  5315. 397,
  5316. -34
  5317. };
  5318. static int iPolyphaseFilter_3[23] =
  5319. {
  5320. -100,
  5321. 201,
  5322. 166,
  5323. -328,
  5324. 648,
  5325. -960,
  5326. 1166,
  5327. -1110,
  5328. 581,
  5329. 788,
  5330. -4200,
  5331. 23445,
  5332. 16277,
  5333. -5910,
  5334. 2778,
  5335. -1075,
  5336. 68,
  5337. 461,
  5338. -644,
  5339. 604,
  5340. -424,
  5341. 344,
  5342. 62
  5343. };
  5344. static int * ppiPolyphaseFilter[4] =
  5345. {
  5346. &iPolyphaseFilter_0[0],
  5347. &iPolyphaseFilter_1[0],
  5348. &iPolyphaseFilter_2[0],
  5349. &iPolyphaseFilter_3[0]
  5350. };
  5351. register int * piFilterCoefficients;
  5352. register int iFilterIndex;
  5353. register unsigned int uiDelayPosition;
  5354. register int iInputSampleTime;
  5355. register int iOutputSampleTime;
  5356. register unsigned int uiInputIndex = 0;
  5357. register unsigned int uiOutputIndex = 0;
  5358. /********************************************************************/
  5359. /* Get the input filter state parameters. */
  5360. /********************************************************************/
  5361. uiDelayPosition = *puiDelayPosition;
  5362. iInputSampleTime = *piInputSampleTime;
  5363. iOutputSampleTime = *piOutputSampleTime;
  5364. /********************************************************************/
  5365. /* Loop and process all of the input samples. */
  5366. /********************************************************************/
  5367. while ( uiInputIndex < uiInputBufferLength )
  5368. {
  5369. /******************************************************************/
  5370. /* Put input samples in interpolator delay buffer until we */
  5371. /* catch up to the next output sample time index. */
  5372. /******************************************************************/
  5373. while (( iInputSampleTime <= iOutputSampleTime )
  5374. && ( uiInputIndex < uiInputBufferLength ))
  5375. {
  5376. /****************************************************************/
  5377. /* Put a new imput sample in the polyphase filter delay line. */
  5378. /****************************************************************/
  5379. piFilterDelay[uiDelayPosition++] = (int)pwInputBuffer[uiInputIndex++];
  5380. if ( uiDelayPosition >= RD_POLYPHASE_FILTER_LENGTH )
  5381. {
  5382. uiDelayPosition = 0;
  5383. }
  5384. /****************************************************************/
  5385. /* Increment the input sample time index. */
  5386. /****************************************************************/
  5387. iInputSampleTime += RD_INPUT_SAMPLE_STEP;
  5388. }
  5389. /******************************************************************/
  5390. /* Calculate output samples using the interpolator until we */
  5391. /* reach the next input sample time. */
  5392. /******************************************************************/
  5393. while ( iOutputSampleTime < iInputSampleTime )
  5394. {
  5395. /****************************************************************/
  5396. /* Calculate the polyphase filter index that corresponds to */
  5397. /* the next output sample. */
  5398. /****************************************************************/
  5399. iFilterIndex = iOutputSampleTime;
  5400. while ( iFilterIndex >= RD_INPUT_SAMPLE_STEP )
  5401. {
  5402. iFilterIndex = iFilterIndex - RD_INPUT_SAMPLE_STEP;
  5403. }
  5404. /****************************************************************/
  5405. /* Get the polyphase filter coefficients. */
  5406. /****************************************************************/
  5407. piFilterCoefficients = ppiPolyphaseFilter[iFilterIndex];
  5408. /****************************************************************/
  5409. /* Apply the polyphase filter. */
  5410. /****************************************************************/
  5411. pwOutputBuffer[uiOutputIndex++] =
  5412. (short)FirFilter( piFilterCoefficients,
  5413. piFilterDelay,
  5414. uiDelayPosition,
  5415. RD_POLYPHASE_FILTER_LENGTH );
  5416. /****************************************************************/
  5417. /* Increment the output sample time index. */
  5418. /****************************************************************/
  5419. iOutputSampleTime += RD_OUTPUT_SAMPLE_STEP;
  5420. }
  5421. /******************************************************************/
  5422. /* Wrap the input and output times indices so they don't */
  5423. /* overflow and go back to process more of the input block. */
  5424. /******************************************************************/
  5425. if ( iInputSampleTime >= RD_STEP_PRODUCT )
  5426. {
  5427. iInputSampleTime -= RD_STEP_PRODUCT;
  5428. iOutputSampleTime -= RD_STEP_PRODUCT;
  5429. }
  5430. }
  5431. /********************************************************************/
  5432. /* Save the input filter state parameters. */
  5433. /********************************************************************/
  5434. *puiDelayPosition = uiDelayPosition;
  5435. *piInputSampleTime = iInputSampleTime;
  5436. *piOutputSampleTime = iOutputSampleTime;
  5437. /********************************************************************/
  5438. /* Return the number of samples in the output buffer. */
  5439. /********************************************************************/
  5440. return uiOutputIndex;
  5441. }
  5442. #endif