Subversion Repositories Kolibri OS

Rev

Rev 1905 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.         decode.h: common definitions for decode functions
  3.  
  4.         This file is strongly tied with optimize.h concerning the synth functions.
  5.         Perhaps one should restructure that a bit.
  6.  
  7.         copyright 2007-8 by the mpg123 project - free software under the terms of the LGPL 2.1
  8.         see COPYING and AUTHORS files in distribution or http://mpg123.org
  9.         initially written by Thomas Orgis, taking WRITE_SAMPLE from decode.c
  10. */
  11. #ifndef MPG123_DECODE_H
  12. #define MPG123_DECODE_H
  13.  
  14. /* Selection of class of output routines for basic format. */
  15. #ifndef REAL_IS_FIXED
  16. #define OUT_FORMATS 4 /* Basic output formats: 16bit, 8bit, real and s32 */
  17. #else
  18. #define OUT_FORMATS 2 /* Only up to 16bit */
  19. #endif
  20.  
  21. #define OUT_16 0
  22. #define OUT_8  1
  23. /* Those are defined but not supported for fixed point decoding! */
  24. #define OUT_REAL 2 /* Write a floating point sample (that is, one matching the internal real type). */
  25. #define OUT_S32 3
  26.  
  27. #ifdef NO_NTOM
  28. #define NTOM_MAX 1
  29. #else
  30. #define NTOM_MAX 8          /* maximum allowed factor for upsampling */
  31. #define NTOM_MAX_FREQ 96000 /* maximum frequency to upsample to / downsample from */
  32. #define NTOM_MUL (32768)
  33. void ntom_set_ntom(mpg123_handle *fr, off_t num);
  34. #endif
  35.  
  36. /* Let's collect all possible synth functions here, for an overview.
  37.    If they are actually defined and used depends on preprocessor machinery.
  38.    See synth.c and optimize.h for that, also some special C and assembler files. */
  39.  
  40. #ifndef NO_16BIT
  41. /* The signed-16bit-producing variants. */
  42. int synth_1to1            (real*, int, mpg123_handle*, int);
  43. int synth_1to1_dither     (real*, int, mpg123_handle*, int);
  44. int synth_1to1_i386       (real*, int, mpg123_handle*, int);
  45. int synth_1to1_i586       (real*, int, mpg123_handle*, int);
  46. int synth_1to1_i586_dither(real*, int, mpg123_handle*, int);
  47. int synth_1to1_mmx        (real*, int, mpg123_handle*, int);
  48. int synth_1to1_3dnow      (real*, int, mpg123_handle*, int);
  49. int synth_1to1_sse        (real*, int, mpg123_handle*, int);
  50. int synth_1to1_stereo_sse (real*, real*, mpg123_handle*);
  51. int synth_1to1_3dnowext   (real*, int, mpg123_handle*, int);
  52. int synth_1to1_altivec    (real*, int, mpg123_handle*, int);
  53. int synth_1to1_stereo_altivec(real*, real*, mpg123_handle*);
  54. int synth_1to1_x86_64     (real*, int, mpg123_handle*, int);
  55. int synth_1to1_stereo_x86_64(real*, real*, mpg123_handle*);
  56. int synth_1to1_arm        (real*, int, mpg123_handle*, int);
  57. int synth_1to1_neon       (real*, int, mpg123_handle*, int);
  58. int synth_1to1_stereo_neon(real*, real*, mpg123_handle*);
  59. /* This is different, special usage in layer3.c only.
  60.    Hence, the name... and now forget about it.
  61.    Never use it outside that special portion of code inside layer3.c! */
  62. int absynth_1to1_i486(real*, int, mpg123_handle*, int);
  63. /* These mono/stereo converters use one of the above for the grunt work. */
  64. int synth_1to1_mono       (real*, mpg123_handle*);
  65. int synth_1to1_m2s(real*, mpg123_handle*);
  66.  
  67. /* Sample rate decimation comes in less flavours. */
  68. #ifndef NO_DOWNSAMPLE
  69. int synth_2to1            (real*, int, mpg123_handle*, int);
  70. int synth_2to1_dither     (real*, int, mpg123_handle*, int);
  71. int synth_2to1_i386       (real*, int, mpg123_handle*, int);
  72. int synth_2to1_mono       (real*, mpg123_handle*);
  73. int synth_2to1_m2s(real*, mpg123_handle*);
  74. int synth_4to1            (real *,int, mpg123_handle*, int);
  75. int synth_4to1_dither     (real *,int, mpg123_handle*, int);
  76. int synth_4to1_i386       (real*, int, mpg123_handle*, int);
  77. int synth_4to1_mono       (real*, mpg123_handle*);
  78. int synth_4to1_m2s(real*, mpg123_handle*);
  79. #endif
  80. #ifndef NO_NTOM
  81. /* NtoM is really just one implementation. */
  82. int synth_ntom (real *,int, mpg123_handle*, int);
  83. int synth_ntom_mono (real *, mpg123_handle *);
  84. int synth_ntom_m2s (real *, mpg123_handle *);
  85. #endif
  86. #endif
  87.  
  88. #ifndef NO_8BIT
  89. /* The 8bit-producing variants. */
  90. /* There are direct 8-bit synths and wrappers over a possibly optimized 16bit one. */
  91. int synth_1to1_8bit            (real*, int, mpg123_handle*, int);
  92. int synth_1to1_8bit_i386       (real*, int, mpg123_handle*, int);
  93. #ifndef NO_16BIT
  94. int synth_1to1_8bit_wrap       (real*, int, mpg123_handle*, int);
  95. int synth_1to1_8bit_mono       (real*, mpg123_handle*);
  96. #endif
  97. int synth_1to1_8bit_m2s(real*, mpg123_handle*);
  98. #ifndef NO_16BIT
  99. int synth_1to1_8bit_wrap_mono       (real*, mpg123_handle*);
  100. int synth_1to1_8bit_wrap_m2s(real*, mpg123_handle*);
  101. #endif
  102. #ifndef NO_DOWNSAMPLE
  103. int synth_2to1_8bit            (real*, int, mpg123_handle*, int);
  104. int synth_2to1_8bit_i386       (real*, int, mpg123_handle*, int);
  105. int synth_2to1_8bit_mono       (real*, mpg123_handle*);
  106. int synth_2to1_8bit_m2s(real*, mpg123_handle*);
  107. int synth_4to1_8bit            (real*, int, mpg123_handle*, int);
  108. int synth_4to1_8bit_i386       (real*, int, mpg123_handle*, int);
  109. int synth_4to1_8bit_mono       (real*, mpg123_handle*);
  110. int synth_4to1_8bit_m2s(real*, mpg123_handle*);
  111. #endif
  112. #ifndef NO_NTOM
  113. int synth_ntom_8bit            (real*, int, mpg123_handle*, int);
  114. int synth_ntom_8bit_mono       (real*, mpg123_handle*);
  115. int synth_ntom_8bit_m2s(real*, mpg123_handle*);
  116. #endif
  117. #endif
  118.  
  119. #ifndef REAL_IS_FIXED
  120.  
  121. #ifndef NO_REAL
  122. /* The real-producing variants. */
  123. int synth_1to1_real            (real*, int, mpg123_handle*, int);
  124. int synth_1to1_real_i386       (real*, int, mpg123_handle*, int);
  125. int synth_1to1_real_sse        (real*, int, mpg123_handle*, int);
  126. int synth_1to1_real_stereo_sse (real*, real*, mpg123_handle*);
  127. int synth_1to1_real_x86_64     (real*, int, mpg123_handle*, int);
  128. int synth_1to1_real_stereo_x86_64(real*, real*, mpg123_handle*);
  129. int synth_1to1_real_altivec    (real*, int, mpg123_handle*, int);
  130. int synth_1to1_real_stereo_altivec(real*, real*, mpg123_handle*);
  131. int synth_1to1_real_neon       (real*, int, mpg123_handle*, int);
  132. int synth_1to1_real_stereo_neon(real*, real*, mpg123_handle*);
  133. int synth_1to1_real_mono       (real*, mpg123_handle*);
  134. int synth_1to1_real_m2s(real*, mpg123_handle*);
  135. #ifndef NO_DOWNSAMPLE
  136. int synth_2to1_real            (real*, int, mpg123_handle*, int);
  137. int synth_2to1_real_i386       (real*, int, mpg123_handle*, int);
  138. int synth_2to1_real_mono       (real*, mpg123_handle*);
  139. int synth_2to1_real_m2s(real*, mpg123_handle*);
  140. int synth_4to1_real            (real*, int, mpg123_handle*, int);
  141. int synth_4to1_real_i386       (real*, int, mpg123_handle*, int);
  142. int synth_4to1_real_mono       (real*, mpg123_handle*);
  143. int synth_4to1_real_m2s(real*, mpg123_handle*);
  144. #endif
  145. #ifndef NO_NTOM
  146. int synth_ntom_real            (real*, int, mpg123_handle*, int);
  147. int synth_ntom_real_mono       (real*, mpg123_handle*);
  148. int synth_ntom_real_m2s(real*, mpg123_handle*);
  149. #endif
  150. #endif
  151.  
  152. #ifndef NO_32BIT
  153. /* 32bit integer */
  154. int synth_1to1_s32            (real*, int, mpg123_handle*, int);
  155. int synth_1to1_s32_i386       (real*, int, mpg123_handle*, int);
  156. int synth_1to1_s32_sse        (real*, int, mpg123_handle*, int);
  157. int synth_1to1_s32_stereo_sse (real*, real*, mpg123_handle*);
  158. int synth_1to1_s32_x86_64     (real*, int, mpg123_handle*, int);
  159. int synth_1to1_s32_stereo_x86_64(real*, real*, mpg123_handle*);
  160. int synth_1to1_s32_altivec    (real*, int, mpg123_handle*, int);
  161. int synth_1to1_s32_stereo_altivec(real*, real*, mpg123_handle*);
  162. int synth_1to1_s32_neon       (real*, int, mpg123_handle*, int);
  163. int synth_1to1_s32_stereo_neon(real*, real*, mpg123_handle*);
  164. int synth_1to1_s32_mono       (real*, mpg123_handle*);
  165. int synth_1to1_s32_m2s(real*, mpg123_handle*);
  166. #ifndef NO_DOWNSAMPLE
  167. int synth_2to1_s32            (real*, int, mpg123_handle*, int);
  168. int synth_2to1_s32_i386       (real*, int, mpg123_handle*, int);
  169. int synth_2to1_s32_mono       (real*, mpg123_handle*);
  170. int synth_2to1_s32_m2s(real*, mpg123_handle*);
  171. int synth_4to1_s32            (real*, int, mpg123_handle*, int);
  172. int synth_4to1_s32_i386       (real*, int, mpg123_handle*, int);
  173. int synth_4to1_s32_mono       (real*, mpg123_handle*);
  174. int synth_4to1_s32_m2s(real*, mpg123_handle*);
  175. #endif
  176. #ifndef NO_NTOM
  177. int synth_ntom_s32            (real*, int, mpg123_handle*, int);
  178. int synth_ntom_s32_mono       (real*, mpg123_handle*);
  179. int synth_ntom_s32_m2s(real*, mpg123_handle*);
  180. #endif
  181. #endif
  182.  
  183. #endif /* FIXED */
  184.  
  185.  
  186. /* Inside these synth functions, some dct64 variants may be used.
  187.    The special optimized ones that only appear in assembler code are not mentioned here.
  188.    And, generally, these functions are only employed in a matching synth function. */
  189. void dct64        (real *,real *,real *);
  190. void dct64_i386   (real *,real *,real *);
  191. void dct64_altivec(real *,real *,real *);
  192. void dct64_i486(int*, int* , real*); /* Yeah, of no use outside of synth_i486.c .*/
  193.  
  194. /* This is used by the layer 3 decoder, one generic function and 3DNow variants. */
  195. void dct36         (real *,real *,real *,real *,real *);
  196. void dct36_3dnow   (real *,real *,real *,real *,real *);
  197. void dct36_3dnowext(real *,real *,real *,real *,real *);
  198.  
  199. /* Tools for NtoM resampling synth, defined in ntom.c . */
  200. int synth_ntom_set_step(mpg123_handle *fr); /* prepare ntom decoding */
  201. unsigned long ntom_val(mpg123_handle *fr, off_t frame); /* compute ntom_val for frame offset */
  202. /* Frame and sample offsets. */
  203. #ifndef NO_NTOM
  204. /*
  205.         Outsamples of _this_ frame.
  206.         To be exact: The samples to be expected from the next frame decode (using the current ntom_val). When you already decoded _this_ frame, this is the number of samples to be expected from the next one.
  207. */
  208. off_t ntom_frame_outsamples(mpg123_handle *fr);
  209. /* Total out/insample offset. */
  210. off_t ntom_frmouts(mpg123_handle *fr, off_t frame);
  211. off_t ntom_ins2outs(mpg123_handle *fr, off_t ins);
  212. off_t ntom_frameoff(mpg123_handle *fr, off_t soff);
  213. #endif
  214.  
  215. /* Initialization of any static data that majy be needed at runtime.
  216.    Make sure you call these once before it is too late. */
  217. #ifndef NO_LAYER3
  218. void init_layer3(void);
  219. real init_layer3_gainpow2(mpg123_handle *fr, int i);
  220. void init_layer3_stuff(mpg123_handle *fr, real (*gainpow2)(mpg123_handle *fr, int i));
  221. #endif
  222. #ifndef NO_LAYER12
  223. void  init_layer12(void);
  224. real* init_layer12_table(mpg123_handle *fr, real *table, int m);
  225. void  init_layer12_stuff(mpg123_handle *fr, real* (*init_table)(mpg123_handle *fr, real *table, int m));
  226. #endif
  227.  
  228. void prepare_decode_tables(void);
  229.  
  230. extern real *pnts[5]; /* tabinit provides, dct64 needs */
  231.  
  232. /* Runtime (re)init functions; needed more often. */
  233. void make_decode_tables(mpg123_handle *fr); /* For every volume change. */
  234. /* Stuff needed after updating synth setup (see set_synth_functions()). */
  235.  
  236. #ifdef OPT_MMXORSSE
  237. /* Special treatment for mmx-like decoders, these functions go into the slots below. */
  238. void make_decode_tables_mmx(mpg123_handle *fr);
  239. #ifndef NO_LAYER3
  240. real init_layer3_gainpow2_mmx(mpg123_handle *fr, int i);
  241. #endif
  242. #ifndef NO_LAYER12
  243. real* init_layer12_table_mmx(mpg123_handle *fr, real *table, int m);
  244. #endif
  245. #endif
  246.  
  247. #ifndef NO_8BIT
  248. /* Needed when switching to 8bit output. */
  249. int make_conv16to8_table(mpg123_handle *fr);
  250. #endif
  251.  
  252. /* These are the actual workers.
  253.    They operate on the parsed frame data and handle decompression to audio samples.
  254.    The synth functions defined above are called from inside the layer handlers. */
  255.  
  256. #ifndef NO_LAYER3
  257. int do_layer3(mpg123_handle *fr);
  258. #endif
  259. #ifndef NO_LAYER2
  260. int do_layer2(mpg123_handle *fr);
  261. #endif
  262. #ifndef NO_LAYER1
  263. int do_layer1(mpg123_handle *fr);
  264. #endif
  265. /* There's an 3DNow counterpart in asm. */
  266. void do_equalizer(real *bandPtr,int channel, real equalizer[2][32]);
  267.  
  268. #endif
  269.