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.

109 lines
3.5KB

  1. /*
  2. * ac3.h
  3. *
  4. * Copyright (C) Aaron Holtzman - May 1999
  5. *
  6. * This file is part of ac3dec, a free Dolby AC-3 stream decoder.
  7. *
  8. * ac3dec 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, or (at your option)
  11. * any later version.
  12. *
  13. * ac3dec 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
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with GNU Make; see the file COPYING. If not, write to
  20. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21. *
  22. *
  23. */
  24. typedef struct ac3_ba_s {
  25. uint16_t fsnroffst; // fine SNR offset
  26. uint16_t fgaincod; // fast gain
  27. uint16_t deltbae; // delta bit allocation exists
  28. int8_t deltba[50]; // per-band delta bit allocation
  29. } ac3_ba_t;
  30. typedef struct ac3_state_s {
  31. uint8_t fscod; // sample rate
  32. uint8_t halfrate; // halfrate factor
  33. uint8_t acmod; // coded channels
  34. float clev; // centre channel mix level
  35. float slev; // surround channels mix level
  36. uint8_t lfeon; // coded lfe channel
  37. int output; // type of output
  38. float level; // output level
  39. float bias; // output bias
  40. uint16_t cplinu; // coupling in use
  41. uint16_t chincpl[5]; // channel coupled
  42. uint16_t phsflginu; // phase flags in use (stereo only)
  43. uint16_t cplbndstrc[18]; // coupling band structure
  44. uint16_t cplstrtmant; // coupling channel start mantissa
  45. uint16_t cplendmant; // coupling channel end mantissa
  46. float cplco[5][18]; // coupling coordinates
  47. // derived information
  48. uint16_t cplstrtbnd; // coupling start band (for bit allocation)
  49. uint16_t ncplbnd; // number of coupling bands
  50. uint16_t rematflg[4]; // stereo rematrixing
  51. uint16_t endmant[5]; // channel end mantissa
  52. uint8_t cpl_exp[256]; // decoded coupling channel exponents
  53. uint8_t fbw_exp[5][256]; // decoded channel exponents
  54. uint8_t lfe_exp[7]; // decoded lfe channel exponents
  55. uint16_t sdcycod; // slow decay
  56. uint16_t fdcycod; // fast decay
  57. uint16_t sgaincod; // slow gain
  58. uint16_t dbpbcod; // dB per bit - encodes the dbknee value
  59. uint16_t floorcod; // masking floor
  60. uint16_t csnroffst; // coarse SNR offset
  61. ac3_ba_t cplba; // coupling bit allocation parameters
  62. ac3_ba_t ba[5]; // channel bit allocation parameters
  63. ac3_ba_t lfeba; // lfe bit allocation parameters
  64. uint16_t cplfleak; // coupling fast leak init
  65. uint16_t cplsleak; // coupling slow leak init
  66. // derived bit allocation information
  67. int8_t fbw_bap[5][256];
  68. int8_t cpl_bap[256];
  69. int8_t lfe_bap[7];
  70. } ac3_state_t;
  71. /* samples work structure */
  72. typedef float stream_samples_t[6][256];
  73. #define AC3_CHANNEL 0
  74. #define AC3_MONO 1
  75. #define AC3_STEREO 2
  76. #define AC3_3F 3
  77. #define AC3_2F1R 4
  78. #define AC3_3F1R 5
  79. #define AC3_2F2R 6
  80. #define AC3_3F2R 7
  81. #define AC3_CHANNEL1 8
  82. #define AC3_CHANNEL2 9
  83. #define AC3_DOLBY 10
  84. #define AC3_CHANNEL_MASK 15
  85. #define AC3_LFE 16
  86. #define AC3_ADJUST_LEVEL 32
  87. void ac3_init (void);
  88. int ac3_syncinfo (uint8_t * buf, int * flags,
  89. int * sample_rate, int * bit_rate);
  90. int ac3_frame (ac3_state_t * state, uint8_t * buf, int * flags,
  91. float * level, float bias);
  92. int ac3_block (ac3_state_t * state);