csbtb.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. #pragma warning(disable:4206) // nonstandard extension used : translation unit is empty
  2. #ifdef COMPILE_ME
  3. /*____________________________________________________________________________
  4. FreeAmp - The Free MP3 Player
  5. MP3 Decoder originally Copyright (C) 1995-1997 Xing Technology
  6. Corp. http://www.xingtech.com
  7. Portions Copyright (C) 1998 EMusic.com
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. $Id: csbtb.c,v 1.2 1999/10/19 07:13:08 elrod Exp $
  20. ____________________________________________________________________________*/
  21. /**** csbtb.c ***************************************************
  22. include to csbt.c
  23. MPEG audio decoder, dct and window - byte (8 pcm bit output)
  24. portable C
  25. ******************************************************************/
  26. /*============================================================*/
  27. /*============================================================*/
  28. void windowB(float *vbuf, int vb_ptr, unsigned char *pcm);
  29. void windowB_dual(float *vbuf, int vb_ptr, unsigned char *pcm);
  30. void windowB16(float *vbuf, int vb_ptr, unsigned char *pcm);
  31. void windowB16_dual(float *vbuf, int vb_ptr, unsigned char *pcm);
  32. void windowB8(float *vbuf, int vb_ptr, unsigned char *pcm);
  33. void windowB8_dual(float *vbuf, int vb_ptr, unsigned char *pcm);
  34. /*============================================================*/
  35. void sbtB_mono(float *sample, unsigned char *pcm, int n)
  36. {
  37. int i;
  38. for (i = 0; i < n; i++)
  39. {
  40. fdct32(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  41. windowB(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  42. sample += 64;
  43. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511;
  44. pcm += 32;
  45. }
  46. }
  47. /*------------------------------------------------------------*/
  48. void sbtB_dual(float *sample, unsigned char *pcm, int n)
  49. {
  50. int i;
  51. for (i = 0; i < n; i++)
  52. {
  53. fdct32_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  54. fdct32_dual(sample + 1, pMP3Stream->vbuf2 + pMP3Stream->vb_ptr);
  55. windowB_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  56. windowB_dual(pMP3Stream->vbuf2, pMP3Stream->vb_ptr, pcm + 1);
  57. sample += 64;
  58. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511;
  59. pcm += 64;
  60. }
  61. }
  62. /*------------------------------------------------------------*/
  63. /* convert dual to mono */
  64. void sbtB_dual_mono(float *sample, unsigned char *pcm, int n)
  65. {
  66. int i;
  67. for (i = 0; i < n; i++)
  68. {
  69. fdct32_dual_mono(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  70. windowB(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  71. sample += 64;
  72. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511;
  73. pcm += 32;
  74. }
  75. }
  76. /*------------------------------------------------------------*/
  77. /* convert dual to left */
  78. void sbtB_dual_left(float *sample, unsigned char *pcm, int n)
  79. {
  80. int i;
  81. for (i = 0; i < n; i++)
  82. {
  83. fdct32_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  84. windowB(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  85. sample += 64;
  86. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511;
  87. pcm += 32;
  88. }
  89. }
  90. /*------------------------------------------------------------*/
  91. /* convert dual to right */
  92. void sbtB_dual_right(float *sample, unsigned char *pcm, int n)
  93. {
  94. int i;
  95. sample++; /* point to right chan */
  96. for (i = 0; i < n; i++)
  97. {
  98. fdct32_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  99. windowB(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  100. sample += 64;
  101. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 32) & 511;
  102. pcm += 32;
  103. }
  104. }
  105. /*------------------------------------------------------------*/
  106. /*---------------- 16 pt sbt's -------------------------------*/
  107. /*------------------------------------------------------------*/
  108. void sbtB16_mono(float *sample, unsigned char *pcm, int n)
  109. {
  110. int i;
  111. for (i = 0; i < n; i++)
  112. {
  113. fdct16(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  114. windowB16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  115. sample += 64;
  116. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255;
  117. pcm += 16;
  118. }
  119. }
  120. /*------------------------------------------------------------*/
  121. void sbtB16_dual(float *sample, unsigned char *pcm, int n)
  122. {
  123. int i;
  124. for (i = 0; i < n; i++)
  125. {
  126. fdct16_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  127. fdct16_dual(sample + 1, pMP3Stream->vbuf2 + pMP3Stream->vb_ptr);
  128. windowB16_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  129. windowB16_dual(pMP3Stream->vbuf2, pMP3Stream->vb_ptr, pcm + 1);
  130. sample += 64;
  131. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255;
  132. pcm += 32;
  133. }
  134. }
  135. /*------------------------------------------------------------*/
  136. void sbtB16_dual_mono(float *sample, unsigned char *pcm, int n)
  137. {
  138. int i;
  139. for (i = 0; i < n; i++)
  140. {
  141. fdct16_dual_mono(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  142. windowB16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  143. sample += 64;
  144. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255;
  145. pcm += 16;
  146. }
  147. }
  148. /*------------------------------------------------------------*/
  149. void sbtB16_dual_left(float *sample, unsigned char *pcm, int n)
  150. {
  151. int i;
  152. for (i = 0; i < n; i++)
  153. {
  154. fdct16_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  155. windowB16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  156. sample += 64;
  157. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255;
  158. pcm += 16;
  159. }
  160. }
  161. /*------------------------------------------------------------*/
  162. void sbtB16_dual_right(float *sample, unsigned char *pcm, int n)
  163. {
  164. int i;
  165. sample++;
  166. for (i = 0; i < n; i++)
  167. {
  168. fdct16_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  169. windowB16(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  170. sample += 64;
  171. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 16) & 255;
  172. pcm += 16;
  173. }
  174. }
  175. /*------------------------------------------------------------*/
  176. /*---------------- 8 pt sbt's -------------------------------*/
  177. /*------------------------------------------------------------*/
  178. void sbtB8_mono(float *sample, unsigned char *pcm, int n)
  179. {
  180. int i;
  181. for (i = 0; i < n; i++)
  182. {
  183. fdct8(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  184. windowB8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  185. sample += 64;
  186. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127;
  187. pcm += 8;
  188. }
  189. }
  190. /*------------------------------------------------------------*/
  191. void sbtB8_dual(float *sample, unsigned char *pcm, int n)
  192. {
  193. int i;
  194. for (i = 0; i < n; i++)
  195. {
  196. fdct8_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  197. fdct8_dual(sample + 1, pMP3Stream->vbuf2 + pMP3Stream->vb_ptr);
  198. windowB8_dual(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  199. windowB8_dual(pMP3Stream->vbuf2, pMP3Stream->vb_ptr, pcm + 1);
  200. sample += 64;
  201. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127;
  202. pcm += 16;
  203. }
  204. }
  205. /*------------------------------------------------------------*/
  206. void sbtB8_dual_mono(float *sample, unsigned char *pcm, int n)
  207. {
  208. int i;
  209. for (i = 0; i < n; i++)
  210. {
  211. fdct8_dual_mono(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  212. windowB8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  213. sample += 64;
  214. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127;
  215. pcm += 8;
  216. }
  217. }
  218. /*------------------------------------------------------------*/
  219. void sbtB8_dual_left(float *sample, unsigned char *pcm, int n)
  220. {
  221. int i;
  222. for (i = 0; i < n; i++)
  223. {
  224. fdct8_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  225. windowB8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  226. sample += 64;
  227. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127;
  228. pcm += 8;
  229. }
  230. }
  231. /*------------------------------------------------------------*/
  232. void sbtB8_dual_right(float *sample, unsigned char *pcm, int n)
  233. {
  234. int i;
  235. sample++;
  236. for (i = 0; i < n; i++)
  237. {
  238. fdct8_dual(sample, pMP3Stream->vbuf + pMP3Stream->vb_ptr);
  239. windowB8(pMP3Stream->vbuf, pMP3Stream->vb_ptr, pcm);
  240. sample += 64;
  241. pMP3Stream->vb_ptr = (pMP3Stream->vb_ptr - 8) & 127;
  242. pcm += 8;
  243. }
  244. }
  245. /*------------------------------------------------------------*/
  246. #endif // #ifdef COMPILE_ME