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.

163 lines
6.3KB

  1. /*
  2. * AAC definitions and structures
  3. * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
  4. * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file aac.h
  24. * AAC definitions and structures
  25. * @author Oded Shimon ( ods15 ods15 dyndns org )
  26. * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
  27. */
  28. #ifndef FFMPEG_AAC_H
  29. #define FFMPEG_AAC_H
  30. #include "avcodec.h"
  31. #include "dsputil.h"
  32. #include "mpeg4audio.h"
  33. #include <stdint.h>
  34. #define AAC_INIT_VLC_STATIC(num, size) \
  35. INIT_VLC_STATIC(&vlc_spectral[num], 6, ff_aac_spectral_sizes[num], \
  36. ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \
  37. ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \
  38. size);
  39. #define MAX_CHANNELS 64
  40. #define IVQUANT_SIZE 1024
  41. enum AudioObjectType {
  42. AOT_NULL,
  43. // Support? Name
  44. AOT_AAC_MAIN, ///< Y Main
  45. AOT_AAC_LC, ///< Y Low Complexity
  46. AOT_AAC_SSR, ///< N (code in SoC repo) Scalable Sample Rate
  47. AOT_AAC_LTP, ///< N (code in SoC repo) Long Term Prediction
  48. AOT_SBR, ///< N (in progress) Spectral Band Replication
  49. AOT_AAC_SCALABLE, ///< N Scalable
  50. AOT_TWINVQ, ///< N Twin Vector Quantizer
  51. AOT_CELP, ///< N Code Excited Linear Prediction
  52. AOT_HVXC, ///< N Harmonic Vector eXcitation Coding
  53. AOT_TTSI = 12, ///< N Text-To-Speech Interface
  54. AOT_MAINSYNTH, ///< N Main Synthesis
  55. AOT_WAVESYNTH, ///< N Wavetable Synthesis
  56. AOT_MIDI, ///< N General MIDI
  57. AOT_SAFX, ///< N Algorithmic Synthesis and Audio Effects
  58. AOT_ER_AAC_LC, ///< N Error Resilient Low Complexity
  59. AOT_ER_AAC_LTP = 19, ///< N Error Resilient Long Term Prediction
  60. AOT_ER_AAC_SCALABLE, ///< N Error Resilient Scalable
  61. AOT_ER_TWINVQ, ///< N Error Resilient Twin Vector Quantizer
  62. AOT_ER_BSAC, ///< N Error Resilient Bit-Sliced Arithmetic Coding
  63. AOT_ER_AAC_LD, ///< N Error Resilient Low Delay
  64. AOT_ER_CELP, ///< N Error Resilient Code Excited Linear Prediction
  65. AOT_ER_HVXC, ///< N Error Resilient Harmonic Vector eXcitation Coding
  66. AOT_ER_HILN, ///< N Error Resilient Harmonic and Individual Lines plus Noise
  67. AOT_ER_PARAM, ///< N Error Resilient Parametric
  68. AOT_SSC, ///< N SinuSoidal Coding
  69. };
  70. enum ExtensionPayloadID {
  71. EXT_FILL,
  72. EXT_FILL_DATA,
  73. EXT_DATA_ELEMENT,
  74. EXT_DYNAMIC_RANGE = 0xb,
  75. EXT_SBR_DATA = 0xd,
  76. EXT_SBR_DATA_CRC = 0xe,
  77. };
  78. enum WindowSequence {
  79. ONLY_LONG_SEQUENCE,
  80. LONG_START_SEQUENCE,
  81. EIGHT_SHORT_SEQUENCE,
  82. LONG_STOP_SEQUENCE,
  83. };
  84. enum BandType {
  85. ZERO_BT = 0, ///< Scalefactors and spectral data are all zero.
  86. FIRST_PAIR_BT = 5, ///< This and later band types encode two values (rather than four) with one code word.
  87. ESC_BT = 11, ///< Spectral data are coded with an escape sequence.
  88. NOISE_BT = 13, ///< Spectral data are scaled white noise not coded in the bitstream.
  89. INTENSITY_BT2 = 14, ///< Scalefactor data are intensity stereo positions.
  90. INTENSITY_BT = 15, ///< Scalefactor data are intensity stereo positions.
  91. };
  92. #define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
  93. enum ChannelPosition {
  94. AAC_CHANNEL_FRONT = 1,
  95. AAC_CHANNEL_SIDE = 2,
  96. AAC_CHANNEL_BACK = 3,
  97. AAC_CHANNEL_LFE = 4,
  98. AAC_CHANNEL_CC = 5,
  99. };
  100. typedef struct {
  101. int num_pulse;
  102. int start;
  103. int offset[4];
  104. int amp[4];
  105. } Pulse;
  106. /**
  107. * coupling parameters
  108. */
  109. typedef struct {
  110. /**
  111. * main AAC context
  112. */
  113. typedef struct {
  114. AVCodecContext * avccontext;
  115. MPEG4AudioConfig m4ac;
  116. int is_saved; ///< Set if elements have stored overlap from previous frame.
  117. DynamicRangeControl che_drc;
  118. enum ChannelPosition che_pos[4][MAX_ELEM_ID]; /**< channel element channel mapping with the
  119. * first index as the first 4 raw data block types
  120. */
  121. /**
  122. * @defgroup tables Computed / set up during initialization.
  123. * @{
  124. */
  125. MDCTContext mdct;
  126. MDCTContext mdct_small;
  127. DSPContext dsp;
  128. /** @} */
  129. /**
  130. * @defgroup output Members used for output interleaving.
  131. * @{
  132. */
  133. float *output_data[MAX_CHANNELS]; ///< Points to each element's 'ret' buffer (PCM output).
  134. float add_bias; ///< offset for dsp.float_to_int16
  135. float sf_scale; ///< Pre-scale for correct IMDCT and dsp.float_to_int16.
  136. int sf_offset; ///< offset into pow2sf_tab as appropriate for dsp.float_to_int16
  137. /** @} */
  138. } AACContext;
  139. #endif /* FFMPEG_AAC_H */