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.

81 lines
2.2KB

  1. /*
  2. * E-AC-3 decoder
  3. * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com>
  4. * Copyright (c) 2008 Justin Ruggles
  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. #include "avcodec.h"
  23. #include "ac3.h"
  24. #include "ac3_parser.h"
  25. #include "ac3dec.h"
  26. #include "ac3dec_data.h"
  27. /** gain adaptive quantization mode */
  28. typedef enum {
  29. EAC3_GAQ_NO =0,
  30. EAC3_GAQ_12,
  31. EAC3_GAQ_14,
  32. EAC3_GAQ_124
  33. } EAC3GaqMode;
  34. #define EAC3_SR_CODE_REDUCED 3
  35. /** lrint(M_SQRT2*cos(2*M_PI/12)*(1<<23)) */
  36. #define COEFF_0 10273905LL
  37. /** lrint(M_SQRT2*cos(0*M_PI/12)*(1<<23)) = lrint(M_SQRT2*(1<<23)) */
  38. #define COEFF_1 11863283LL
  39. /** lrint(M_SQRT2*cos(5*M_PI/12)*(1<<23)) */
  40. #define COEFF_2 3070444LL
  41. /**
  42. * Calculate 6-point IDCT of the pre-mantissas.
  43. * All calculations are 24-bit fixed-point.
  44. */
  45. static void idct6(int pre_mant[6])
  46. {
  47. int tmp;
  48. int even0, even1, even2, odd0, odd1, odd2;
  49. odd1 = pre_mant[1] - pre_mant[3] - pre_mant[5];
  50. even2 = ( pre_mant[2] * COEFF_0) >> 23;
  51. tmp = ( pre_mant[4] * COEFF_1) >> 23;
  52. odd0 = ((pre_mant[1] + pre_mant[5]) * COEFF_2) >> 23;
  53. even0 = pre_mant[0] + (tmp >> 1);
  54. even1 = pre_mant[0] - tmp;
  55. tmp = even0;
  56. even0 = tmp + even2;
  57. even2 = tmp - even2;
  58. tmp = odd0;
  59. odd0 = tmp + pre_mant[1] + pre_mant[3];
  60. odd2 = tmp + pre_mant[5] - pre_mant[3];
  61. pre_mant[0] = even0 + odd0;
  62. pre_mant[1] = even1 + odd1;
  63. pre_mant[2] = even2 + odd2;
  64. pre_mant[3] = even2 - odd2;
  65. pre_mant[4] = even1 - odd1;
  66. pre_mant[5] = even0 - odd0;
  67. }