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.

116 lines
4.1KB

  1. /*
  2. * a52_internal.h
  3. * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
  4. * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
  5. *
  6. * This file is part of a52dec, a free ATSC A-52 stream decoder.
  7. * See http://liba52.sourceforge.net/ for updates.
  8. *
  9. * a52dec is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * a52dec is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. typedef struct {
  24. uint8_t bai; /* fine SNR offset, fast gain */
  25. uint8_t deltbae; /* delta bit allocation exists */
  26. int8_t deltba[50]; /* per-band delta bit allocation */
  27. } ba_t;
  28. typedef struct {
  29. uint8_t exp[256]; /* decoded channel exponents */
  30. int8_t bap[256]; /* derived channel bit allocation */
  31. } expbap_t;
  32. struct a52_state_s {
  33. uint8_t fscod; /* sample rate */
  34. uint8_t halfrate; /* halfrate factor */
  35. uint8_t acmod; /* coded channels */
  36. uint8_t lfeon; /* coded lfe channel */
  37. sample_t clev; /* centre channel mix level */
  38. sample_t slev; /* surround channels mix level */
  39. int output; /* type of output */
  40. sample_t level; /* output level */
  41. sample_t bias; /* output bias */
  42. int dynrnge; /* apply dynamic range */
  43. sample_t dynrng; /* dynamic range */
  44. void * dynrngdata; /* dynamic range callback funtion and data */
  45. sample_t (* dynrngcall) (sample_t range, void * dynrngdata);
  46. uint8_t chincpl; /* channel coupled */
  47. uint8_t phsflginu; /* phase flags in use (stereo only) */
  48. uint8_t cplstrtmant; /* coupling channel start mantissa */
  49. uint8_t cplendmant; /* coupling channel end mantissa */
  50. uint32_t cplbndstrc; /* coupling band structure */
  51. sample_t cplco[5][18]; /* coupling coordinates */
  52. /* derived information */
  53. uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
  54. uint8_t ncplbnd; /* number of coupling bands */
  55. uint8_t rematflg; /* stereo rematrixing */
  56. uint8_t endmant[5]; /* channel end mantissa */
  57. uint16_t bai; /* bit allocation information */
  58. uint8_t csnroffst; /* coarse SNR offset */
  59. ba_t cplba; /* coupling bit allocation parameters */
  60. ba_t ba[5]; /* channel bit allocation parameters */
  61. ba_t lfeba; /* lfe bit allocation parameters */
  62. uint8_t cplfleak; /* coupling fast leak init */
  63. uint8_t cplsleak; /* coupling slow leak init */
  64. expbap_t cpl_expbap;
  65. expbap_t fbw_expbap[5];
  66. expbap_t lfe_expbap;
  67. sample_t * samples;
  68. int downmixed;
  69. };
  70. #define LEVEL_PLUS6DB 2.0
  71. #define LEVEL_PLUS3DB 1.4142135623730951
  72. #define LEVEL_3DB 0.7071067811865476
  73. #define LEVEL_45DB 0.5946035575013605
  74. #define LEVEL_6DB 0.5
  75. #define EXP_REUSE (0)
  76. #define EXP_D15 (1)
  77. #define EXP_D25 (2)
  78. #define EXP_D45 (3)
  79. #define DELTA_BIT_REUSE (0)
  80. #define DELTA_BIT_NEW (1)
  81. #define DELTA_BIT_NONE (2)
  82. #define DELTA_BIT_RESERVED (3)
  83. void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
  84. int start, int end, int fastleak, int slowleak,
  85. expbap_t * expbap);
  86. int a52_downmix_init (int input, int flags, sample_t * level,
  87. sample_t clev, sample_t slev);
  88. int a52_downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level,
  89. sample_t clev, sample_t slev);
  90. void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
  91. sample_t clev, sample_t slev);
  92. void a52_upmix (sample_t * samples, int acmod, int output);
  93. void a52_imdct_init (uint32_t mm_accel);
  94. void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias);
  95. void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias);