2
0

mpegaudiodec_fixed.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Fixed-point MPEG audio decoder
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "config.h"
  21. #include "libavutil/samplefmt.h"
  22. #define USE_FLOATS 0
  23. #include "mpegaudio.h"
  24. #define SHR(a,b) (((int)(a))>>(b))
  25. /* WARNING: only correct for positive numbers */
  26. #define FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5))
  27. #define FIXR(a) ((int)((a) * FRAC_ONE + 0.5))
  28. #define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5))
  29. #define MULH3(x, y, s) MULH((s)*(x), y)
  30. #define MULLx(x, y, s) MULL((int)(x),(y),s)
  31. #define RENAME(a) a ## _fixed
  32. #define OUT_FMT AV_SAMPLE_FMT_S16
  33. #define OUT_FMT_P AV_SAMPLE_FMT_S16P
  34. #include "mpegaudiodec_template.c"
  35. #if CONFIG_MP1_DECODER
  36. AVCodec ff_mp1_decoder = {
  37. .name = "mp1",
  38. .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
  39. .type = AVMEDIA_TYPE_AUDIO,
  40. .id = AV_CODEC_ID_MP1,
  41. .priv_data_size = sizeof(MPADecodeContext),
  42. .init = decode_init,
  43. .decode = decode_frame,
  44. .capabilities = AV_CODEC_CAP_DR1,
  45. .flush = flush,
  46. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
  47. AV_SAMPLE_FMT_S16,
  48. AV_SAMPLE_FMT_NONE },
  49. };
  50. #endif
  51. #if CONFIG_MP2_DECODER
  52. AVCodec ff_mp2_decoder = {
  53. .name = "mp2",
  54. .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
  55. .type = AVMEDIA_TYPE_AUDIO,
  56. .id = AV_CODEC_ID_MP2,
  57. .priv_data_size = sizeof(MPADecodeContext),
  58. .init = decode_init,
  59. .decode = decode_frame,
  60. .capabilities = AV_CODEC_CAP_DR1,
  61. .flush = flush,
  62. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
  63. AV_SAMPLE_FMT_S16,
  64. AV_SAMPLE_FMT_NONE },
  65. };
  66. #endif
  67. #if CONFIG_MP3_DECODER
  68. AVCodec ff_mp3_decoder = {
  69. .name = "mp3",
  70. .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
  71. .type = AVMEDIA_TYPE_AUDIO,
  72. .id = AV_CODEC_ID_MP3,
  73. .priv_data_size = sizeof(MPADecodeContext),
  74. .init = decode_init,
  75. .decode = decode_frame,
  76. .capabilities = AV_CODEC_CAP_DR1,
  77. .flush = flush,
  78. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
  79. AV_SAMPLE_FMT_S16,
  80. AV_SAMPLE_FMT_NONE },
  81. };
  82. #endif
  83. #if CONFIG_MP3ADU_DECODER
  84. AVCodec ff_mp3adu_decoder = {
  85. .name = "mp3adu",
  86. .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
  87. .type = AVMEDIA_TYPE_AUDIO,
  88. .id = AV_CODEC_ID_MP3ADU,
  89. .priv_data_size = sizeof(MPADecodeContext),
  90. .init = decode_init,
  91. .decode = decode_frame_adu,
  92. .capabilities = AV_CODEC_CAP_DR1,
  93. .flush = flush,
  94. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
  95. AV_SAMPLE_FMT_S16,
  96. AV_SAMPLE_FMT_NONE },
  97. };
  98. #endif
  99. #if CONFIG_MP3ON4_DECODER
  100. AVCodec ff_mp3on4_decoder = {
  101. .name = "mp3on4",
  102. .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
  103. .type = AVMEDIA_TYPE_AUDIO,
  104. .id = AV_CODEC_ID_MP3ON4,
  105. .priv_data_size = sizeof(MP3On4DecodeContext),
  106. .init = decode_init_mp3on4,
  107. .close = decode_close_mp3on4,
  108. .decode = decode_frame_mp3on4,
  109. .capabilities = AV_CODEC_CAP_DR1,
  110. .flush = flush_mp3on4,
  111. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
  112. AV_SAMPLE_FMT_NONE },
  113. };
  114. #endif