mpegaudiodec_float.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #include "config.h"
  22. #include "libavutil/samplefmt.h"
  23. #define USE_FLOATS 1
  24. #include "mpegaudio.h"
  25. #define SHR(a,b) ((a)*(1.0f/(1<<(b))))
  26. #define FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5))
  27. #define FIXR(x) ((float)(x))
  28. #define FIXHR(x) ((float)(x))
  29. #define MULH3(x, y, s) ((s)*(y)*(x))
  30. #define MULLx(x, y, s) ((y)*(x))
  31. #define RENAME(a) a ## _float
  32. #define OUT_FMT AV_SAMPLE_FMT_FLT
  33. #define OUT_FMT_P AV_SAMPLE_FMT_FLTP
  34. #include "mpegaudiodec_template.c"
  35. #if CONFIG_MP1FLOAT_DECODER
  36. AVCodec ff_mp1float_decoder = {
  37. .name = "mp1float",
  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. .close = decode_close,
  44. .decode = decode_frame,
  45. .capabilities = AV_CODEC_CAP_DR1,
  46. .flush = flush,
  47. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
  48. AV_SAMPLE_FMT_FLT,
  49. AV_SAMPLE_FMT_NONE },
  50. };
  51. #endif
  52. #if CONFIG_MP2FLOAT_DECODER
  53. AVCodec ff_mp2float_decoder = {
  54. .name = "mp2float",
  55. .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
  56. .type = AVMEDIA_TYPE_AUDIO,
  57. .id = AV_CODEC_ID_MP2,
  58. .priv_data_size = sizeof(MPADecodeContext),
  59. .init = decode_init,
  60. .decode = decode_frame,
  61. .close = decode_close,
  62. .capabilities = AV_CODEC_CAP_DR1,
  63. .flush = flush,
  64. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
  65. AV_SAMPLE_FMT_FLT,
  66. AV_SAMPLE_FMT_NONE },
  67. };
  68. #endif
  69. #if CONFIG_MP3FLOAT_DECODER
  70. AVCodec ff_mp3float_decoder = {
  71. .name = "mp3float",
  72. .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
  73. .type = AVMEDIA_TYPE_AUDIO,
  74. .id = AV_CODEC_ID_MP3,
  75. .priv_data_size = sizeof(MPADecodeContext),
  76. .init = decode_init,
  77. .close = decode_close,
  78. .decode = decode_frame,
  79. .capabilities = AV_CODEC_CAP_DR1,
  80. .flush = flush,
  81. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
  82. AV_SAMPLE_FMT_FLT,
  83. AV_SAMPLE_FMT_NONE },
  84. };
  85. #endif
  86. #if CONFIG_MP3ADUFLOAT_DECODER
  87. AVCodec ff_mp3adufloat_decoder = {
  88. .name = "mp3adufloat",
  89. .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
  90. .type = AVMEDIA_TYPE_AUDIO,
  91. .id = AV_CODEC_ID_MP3ADU,
  92. .priv_data_size = sizeof(MPADecodeContext),
  93. .init = decode_init,
  94. .close = decode_close,
  95. .decode = decode_frame_adu,
  96. .capabilities = AV_CODEC_CAP_DR1,
  97. .flush = flush,
  98. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
  99. AV_SAMPLE_FMT_FLT,
  100. AV_SAMPLE_FMT_NONE },
  101. };
  102. #endif
  103. #if CONFIG_MP3ON4FLOAT_DECODER
  104. AVCodec ff_mp3on4float_decoder = {
  105. .name = "mp3on4float",
  106. .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
  107. .type = AVMEDIA_TYPE_AUDIO,
  108. .id = AV_CODEC_ID_MP3ON4,
  109. .priv_data_size = sizeof(MP3On4DecodeContext),
  110. .init = decode_init_mp3on4,
  111. .close = decode_close_mp3on4,
  112. .decode = decode_frame_mp3on4,
  113. .capabilities = AV_CODEC_CAP_DR1,
  114. .flush = flush_mp3on4,
  115. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
  116. AV_SAMPLE_FMT_NONE },
  117. };
  118. #endif