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.

105 lines
3.2KB

  1. /*
  2. * copyright (c) 2001 Fabrice Bellard
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. /**
  19. * @file mpegaudio.h
  20. * mpeg audio declarations for both encoder and decoder.
  21. */
  22. /* max frame size, in samples */
  23. #define MPA_FRAME_SIZE 1152
  24. /* max compressed frame size */
  25. #define MPA_MAX_CODED_FRAME_SIZE 1792
  26. #define MPA_MAX_CHANNELS 2
  27. #define SBLIMIT 32 /* number of subbands */
  28. #define MPA_STEREO 0
  29. #define MPA_JSTEREO 1
  30. #define MPA_DUAL 2
  31. #define MPA_MONO 3
  32. /* header + layer + bitrate + freq + lsf/mpeg25 */
  33. #define SAME_HEADER_MASK \
  34. (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19))
  35. /* define USE_HIGHPRECISION to have a bit exact (but slower) mpeg
  36. audio decoder */
  37. #ifdef USE_HIGHPRECISION
  38. #define FRAC_BITS 23 /* fractional bits for sb_samples and dct */
  39. #define WFRAC_BITS 16 /* fractional bits for window */
  40. #else
  41. #define FRAC_BITS 15 /* fractional bits for sb_samples and dct */
  42. #define WFRAC_BITS 14 /* fractional bits for window */
  43. #endif
  44. #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
  45. typedef int32_t OUT_INT;
  46. #define OUT_MAX INT32_MAX
  47. #define OUT_MIN INT32_MIN
  48. #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31)
  49. #else
  50. typedef int16_t OUT_INT;
  51. #define OUT_MAX INT16_MAX
  52. #define OUT_MIN INT16_MIN
  53. #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
  54. #endif
  55. #if FRAC_BITS <= 15
  56. typedef int16_t MPA_INT;
  57. #else
  58. typedef int32_t MPA_INT;
  59. #endif
  60. int l2_select_table(int bitrate, int nb_channels, int freq, int lsf);
  61. int mpa_decode_header(AVCodecContext *avctx, uint32_t head);
  62. void ff_mpa_synth_init(MPA_INT *window);
  63. void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
  64. MPA_INT *window, int *dither_state,
  65. OUT_INT *samples, int incr,
  66. int32_t sb_samples[SBLIMIT]);
  67. extern const uint16_t mpa_bitrate_tab[2][3][15];
  68. extern const uint16_t mpa_freq_tab[3];
  69. extern const unsigned char *alloc_tables[5];
  70. extern const double enwindow[512];
  71. extern const int sblimit_table[5];
  72. extern const int quant_steps[17];
  73. extern const int quant_bits[17];
  74. extern const int32_t mpa_enwindow[257];
  75. /* fast header check for resync */
  76. static inline int ff_mpa_check_header(uint32_t header){
  77. /* header */
  78. if ((header & 0xffe00000) != 0xffe00000)
  79. return -1;
  80. /* layer check */
  81. if ((header & (3<<17)) == 0)
  82. return -1;
  83. /* bit rate */
  84. if ((header & (0xf<<12)) == 0xf<<12)
  85. return -1;
  86. /* frequency */
  87. if ((header & (3<<10)) == 3<<10)
  88. return -1;
  89. return 0;
  90. }