mpegaudiodec_float.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Float MPEG Audio decoder
  3. * Copyright (c) 2010 Michael Niedermayer
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * Libav is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #define CONFIG_FLOAT 1
  22. #include "mpegaudiodec.c"
  23. static void compute_antialias_float(MPADecodeContext *s,
  24. GranuleDef *g)
  25. {
  26. float *ptr;
  27. int n, i;
  28. /* we antialias only "long" bands */
  29. if (g->block_type == 2) {
  30. if (!g->switch_point)
  31. return;
  32. /* XXX: check this for 8000Hz case */
  33. n = 1;
  34. } else {
  35. n = SBLIMIT - 1;
  36. }
  37. ptr = g->sb_hybrid + 18;
  38. for(i = n;i > 0;i--) {
  39. float tmp0, tmp1;
  40. float *csa = &csa_table_float[0][0];
  41. #define FLOAT_AA(j)\
  42. tmp0= ptr[-1-j];\
  43. tmp1= ptr[ j];\
  44. ptr[-1-j] = tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j];\
  45. ptr[ j] = tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j];
  46. FLOAT_AA(0)
  47. FLOAT_AA(1)
  48. FLOAT_AA(2)
  49. FLOAT_AA(3)
  50. FLOAT_AA(4)
  51. FLOAT_AA(5)
  52. FLOAT_AA(6)
  53. FLOAT_AA(7)
  54. ptr += 18;
  55. }
  56. }
  57. #if CONFIG_MP1FLOAT_DECODER
  58. AVCodec ff_mp1float_decoder =
  59. {
  60. "mp1float",
  61. AVMEDIA_TYPE_AUDIO,
  62. CODEC_ID_MP1,
  63. sizeof(MPADecodeContext),
  64. decode_init,
  65. NULL,
  66. .close = NULL,
  67. decode_frame,
  68. CODEC_CAP_PARSE_ONLY,
  69. .flush= flush,
  70. .long_name= NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
  71. };
  72. #endif
  73. #if CONFIG_MP2FLOAT_DECODER
  74. AVCodec ff_mp2float_decoder =
  75. {
  76. "mp2float",
  77. AVMEDIA_TYPE_AUDIO,
  78. CODEC_ID_MP2,
  79. sizeof(MPADecodeContext),
  80. decode_init,
  81. NULL,
  82. .close = NULL,
  83. decode_frame,
  84. CODEC_CAP_PARSE_ONLY,
  85. .flush= flush,
  86. .long_name= NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
  87. };
  88. #endif
  89. #if CONFIG_MP3FLOAT_DECODER
  90. AVCodec ff_mp3float_decoder =
  91. {
  92. "mp3float",
  93. AVMEDIA_TYPE_AUDIO,
  94. CODEC_ID_MP3,
  95. sizeof(MPADecodeContext),
  96. decode_init,
  97. NULL,
  98. .close = NULL,
  99. decode_frame,
  100. CODEC_CAP_PARSE_ONLY,
  101. .flush= flush,
  102. .long_name= NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
  103. };
  104. #endif
  105. #if CONFIG_MP3ADUFLOAT_DECODER
  106. AVCodec ff_mp3adufloat_decoder =
  107. {
  108. "mp3adufloat",
  109. AVMEDIA_TYPE_AUDIO,
  110. CODEC_ID_MP3ADU,
  111. sizeof(MPADecodeContext),
  112. decode_init,
  113. NULL,
  114. .close = NULL,
  115. decode_frame_adu,
  116. CODEC_CAP_PARSE_ONLY,
  117. .flush= flush,
  118. .long_name= NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
  119. };
  120. #endif
  121. #if CONFIG_MP3ON4FLOAT_DECODER
  122. AVCodec ff_mp3on4float_decoder =
  123. {
  124. "mp3on4float",
  125. AVMEDIA_TYPE_AUDIO,
  126. CODEC_ID_MP3ON4,
  127. sizeof(MP3On4DecodeContext),
  128. decode_init_mp3on4,
  129. NULL,
  130. decode_close_mp3on4,
  131. decode_frame_mp3on4,
  132. .flush= flush,
  133. .long_name= NULL_IF_CONFIG_SMALL("MP3onMP4"),
  134. };
  135. #endif