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.

162 lines
3.9KB

  1. /*
  2. * Float MPEG Audio decoder
  3. * Copyright (c) 2010 Michael Niedermayer
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg 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. * FFmpeg 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 FFmpeg; 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. void ff_mpa_synth_filter_float(MPADecodeContext *s, float *synth_buf_ptr,
  24. int *synth_buf_offset,
  25. float *window, int *dither_state,
  26. float *samples, int incr,
  27. float sb_samples[SBLIMIT])
  28. {
  29. float *synth_buf;
  30. int offset;
  31. offset = *synth_buf_offset;
  32. synth_buf = synth_buf_ptr + offset;
  33. s->dct.dct32(synth_buf, sb_samples);
  34. s->apply_window_mp3(synth_buf, window, dither_state, samples, incr);
  35. offset = (offset - 32) & 511;
  36. *synth_buf_offset = offset;
  37. }
  38. static void compute_antialias_float(MPADecodeContext *s,
  39. GranuleDef *g)
  40. {
  41. float *ptr;
  42. int n, i;
  43. /* we antialias only "long" bands */
  44. if (g->block_type == 2) {
  45. if (!g->switch_point)
  46. return;
  47. /* XXX: check this for 8000Hz case */
  48. n = 1;
  49. } else {
  50. n = SBLIMIT - 1;
  51. }
  52. ptr = g->sb_hybrid + 18;
  53. for(i = n;i > 0;i--) {
  54. float tmp0, tmp1;
  55. float *csa = &csa_table_float[0][0];
  56. #define FLOAT_AA(j)\
  57. tmp0= ptr[-1-j];\
  58. tmp1= ptr[ j];\
  59. ptr[-1-j] = tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j];\
  60. ptr[ j] = tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j];
  61. FLOAT_AA(0)
  62. FLOAT_AA(1)
  63. FLOAT_AA(2)
  64. FLOAT_AA(3)
  65. FLOAT_AA(4)
  66. FLOAT_AA(5)
  67. FLOAT_AA(6)
  68. FLOAT_AA(7)
  69. ptr += 18;
  70. }
  71. }
  72. #if CONFIG_MP1FLOAT_DECODER
  73. AVCodec mp1float_decoder =
  74. {
  75. "mp1float",
  76. AVMEDIA_TYPE_AUDIO,
  77. CODEC_ID_MP1,
  78. sizeof(MPADecodeContext),
  79. decode_init,
  80. NULL,
  81. NULL,
  82. decode_frame,
  83. CODEC_CAP_PARSE_ONLY,
  84. .flush= flush,
  85. .long_name= NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
  86. };
  87. #endif
  88. #if CONFIG_MP2FLOAT_DECODER
  89. AVCodec mp2float_decoder =
  90. {
  91. "mp2float",
  92. AVMEDIA_TYPE_AUDIO,
  93. CODEC_ID_MP2,
  94. sizeof(MPADecodeContext),
  95. decode_init,
  96. NULL,
  97. NULL,
  98. decode_frame,
  99. CODEC_CAP_PARSE_ONLY,
  100. .flush= flush,
  101. .long_name= NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
  102. };
  103. #endif
  104. #if CONFIG_MP3FLOAT_DECODER
  105. AVCodec mp3float_decoder =
  106. {
  107. "mp3float",
  108. AVMEDIA_TYPE_AUDIO,
  109. CODEC_ID_MP3,
  110. sizeof(MPADecodeContext),
  111. decode_init,
  112. NULL,
  113. NULL,
  114. decode_frame,
  115. CODEC_CAP_PARSE_ONLY,
  116. .flush= flush,
  117. .long_name= NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
  118. };
  119. #endif
  120. #if CONFIG_MP3ADUFLOAT_DECODER
  121. AVCodec mp3adufloat_decoder =
  122. {
  123. "mp3adufloat",
  124. AVMEDIA_TYPE_AUDIO,
  125. CODEC_ID_MP3ADU,
  126. sizeof(MPADecodeContext),
  127. decode_init,
  128. NULL,
  129. NULL,
  130. decode_frame_adu,
  131. CODEC_CAP_PARSE_ONLY,
  132. .flush= flush,
  133. .long_name= NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
  134. };
  135. #endif
  136. #if CONFIG_MP3ON4FLOAT_DECODER
  137. AVCodec mp3on4float_decoder =
  138. {
  139. "mp3on4float",
  140. AVMEDIA_TYPE_AUDIO,
  141. CODEC_ID_MP3ON4,
  142. sizeof(MP3On4DecodeContext),
  143. decode_init_mp3on4,
  144. NULL,
  145. decode_close_mp3on4,
  146. decode_frame_mp3on4,
  147. .flush= flush,
  148. .long_name= NULL_IF_CONFIG_SMALL("MP3onMP4"),
  149. };
  150. #endif