Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include "bstream.h"
  2. #include "mp3dec.h"
  3. #include <math.h>
  4.  
  5. extern MPEG_DECODE_OPTION m_option;
  6. extern int m_frequency;
  7.  
  8. extern float m_sample[2304];
  9. extern int m_nsb_limit;
  10. extern int m_max_sb;
  11. extern int m_stereo_sb;
  12. extern SBT_PROC m_sbt_proc;
  13.  
  14. extern float m_look_c_valueL1[18];
  15. extern int m_nbatL1;
  16.  
  17. //extern "sbt.c"
  18. void sbt_mono(float *sample, signed short *pcm, int ch);
  19. void sbt_dual(float *sample, signed short *pcm, int ch);
  20. void sbt16_mono(float *sample, signed short *pcm, int ch);
  21. void sbt16_dual(float *sample, signed short *pcm, int ch);
  22. void sbt8_mono(float *sample, signed short *pcm, int ch);
  23. void sbt8_dual(float *sample, signed short *pcm, int ch);
  24. void sbtB_mono(float *sample, unsigned char *pcm, int ch);
  25. void sbtB_dual(float *sample, unsigned char *pcm, int ch);
  26. void sbtB16_mono(float *sample, unsigned char *pcm, int ch);
  27. void sbtB16_dual(float *sample, unsigned char *pcm, int ch);
  28. void sbtB8_mono(float *sample, unsigned char *pcm, int ch);
  29. void sbtB8_dual(float *sample, unsigned char *pcm, int ch);
  30.  
  31. static const SBT_PROC sbt_table[2][3][2] =
  32. {
  33.         sbt_mono,
  34.         sbt_dual,
  35.         sbt16_mono,
  36.         sbt16_dual,
  37.         sbt8_mono,
  38.         sbt8_dual,
  39.         sbtB_mono,
  40.         sbtB_dual,
  41.         sbtB16_mono,
  42.         sbtB16_dual,
  43.         sbtB8_mono,
  44.         sbtB8_dual,
  45. };
  46.  
  47. void L1table_init()
  48. {
  49.         int i, stepL1;
  50.  
  51.         for (stepL1 = 4, i = 1; i < 16; i++, stepL1 <<= 1) {
  52.                 m_look_c_valueL1[i] = (float) (2.0 / (stepL1 - 1));
  53.         }
  54. }
  55.  
  56. int L1decode_start(MPEG_HEADER* h)
  57. {
  58.         int i, k, bit_code, limit;
  59.  
  60. /*- caller limit -*/
  61.         m_nbatL1 = 32;
  62.         m_max_sb = m_nbatL1;
  63.         m_nsb_limit = (m_option.freqLimit * 64L + m_frequency / 2) / m_frequency;
  64. /*---- limit = 0.94*(32>>reduction_code);  ----*/
  65.         limit = (32 >> m_option.reduction);
  66.         if (limit > 8)
  67.                 limit--;
  68.         if (m_nsb_limit > limit)
  69.                 m_nsb_limit = limit;
  70.         if (m_nsb_limit > m_max_sb)
  71.                 m_nsb_limit = m_max_sb;
  72.  
  73.         if (h->mode != 3) { /* adjust for 2 channel modes */
  74.                 m_nbatL1 *= 2;
  75.                 m_max_sb *= 2;
  76.                 m_nsb_limit *= 2;
  77.         }
  78. /* set sbt function */
  79.         bit_code = (m_option.convert & 8) ? 1 : 0;
  80.         k = (h->mode == 3) ? 0 : (1 + m_option.convert);
  81.         m_sbt_proc = sbt_table[bit_code][m_option.reduction][k];//[2][3][2]
  82.  
  83.         for (i = 0; i < 768; i++)
  84.                 m_sample[i] = 0.0F;
  85.         return 1;
  86. }
  87.  
  88.