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.

169 lines
4.1KB

  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. static av_cold int decode_end(AVCodecContext * avctx)
  73. {
  74. MPADecodeContext *s = avctx->priv_data;
  75. ff_dct_end(&s->dct);
  76. return 0;
  77. }
  78. #if CONFIG_MP1FLOAT_DECODER
  79. AVCodec ff_mp1float_decoder =
  80. {
  81. "mp1float",
  82. AVMEDIA_TYPE_AUDIO,
  83. CODEC_ID_MP1,
  84. sizeof(MPADecodeContext),
  85. decode_init,
  86. NULL,
  87. decode_end,
  88. decode_frame,
  89. CODEC_CAP_PARSE_ONLY,
  90. .flush= flush,
  91. .long_name= NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
  92. };
  93. #endif
  94. #if CONFIG_MP2FLOAT_DECODER
  95. AVCodec ff_mp2float_decoder =
  96. {
  97. "mp2float",
  98. AVMEDIA_TYPE_AUDIO,
  99. CODEC_ID_MP2,
  100. sizeof(MPADecodeContext),
  101. decode_init,
  102. NULL,
  103. decode_end,
  104. decode_frame,
  105. CODEC_CAP_PARSE_ONLY,
  106. .flush= flush,
  107. .long_name= NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
  108. };
  109. #endif
  110. #if CONFIG_MP3FLOAT_DECODER
  111. AVCodec ff_mp3float_decoder =
  112. {
  113. "mp3float",
  114. AVMEDIA_TYPE_AUDIO,
  115. CODEC_ID_MP3,
  116. sizeof(MPADecodeContext),
  117. decode_init,
  118. NULL,
  119. decode_end,
  120. decode_frame,
  121. CODEC_CAP_PARSE_ONLY,
  122. .flush= flush,
  123. .long_name= NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
  124. };
  125. #endif
  126. #if CONFIG_MP3ADUFLOAT_DECODER
  127. AVCodec ff_mp3adufloat_decoder =
  128. {
  129. "mp3adufloat",
  130. AVMEDIA_TYPE_AUDIO,
  131. CODEC_ID_MP3ADU,
  132. sizeof(MPADecodeContext),
  133. decode_init,
  134. NULL,
  135. decode_end,
  136. decode_frame_adu,
  137. CODEC_CAP_PARSE_ONLY,
  138. .flush= flush,
  139. .long_name= NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
  140. };
  141. #endif
  142. #if CONFIG_MP3ON4FLOAT_DECODER
  143. AVCodec ff_mp3on4float_decoder =
  144. {
  145. "mp3on4float",
  146. AVMEDIA_TYPE_AUDIO,
  147. CODEC_ID_MP3ON4,
  148. sizeof(MP3On4DecodeContext),
  149. decode_init_mp3on4,
  150. NULL,
  151. decode_close_mp3on4,
  152. decode_frame_mp3on4,
  153. .flush= flush,
  154. .long_name= NULL_IF_CONFIG_SMALL("MP3onMP4"),
  155. };
  156. #endif