mpegaudiodec_float.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 CONFIG_FLOAT 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. .decode = decode_frame,
  44. .capabilities = CODEC_CAP_DR1,
  45. .flush = flush,
  46. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
  47. AV_SAMPLE_FMT_FLT,
  48. AV_SAMPLE_FMT_NONE },
  49. };
  50. #endif
  51. #if CONFIG_MP2FLOAT_DECODER
  52. AVCodec ff_mp2float_decoder = {
  53. .name = "mp2float",
  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 = CODEC_CAP_DR1,
  61. .flush = flush,
  62. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
  63. AV_SAMPLE_FMT_FLT,
  64. AV_SAMPLE_FMT_NONE },
  65. };
  66. #endif
  67. #if CONFIG_MP3FLOAT_DECODER
  68. AVCodec ff_mp3float_decoder = {
  69. .name = "mp3float",
  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 = CODEC_CAP_DR1,
  77. .flush = flush,
  78. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
  79. AV_SAMPLE_FMT_FLT,
  80. AV_SAMPLE_FMT_NONE },
  81. };
  82. #endif
  83. #if CONFIG_MP3ADUFLOAT_DECODER
  84. AVCodec ff_mp3adufloat_decoder = {
  85. .name = "mp3adufloat",
  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 = CODEC_CAP_DR1,
  93. .flush = flush,
  94. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
  95. AV_SAMPLE_FMT_FLT,
  96. AV_SAMPLE_FMT_NONE },
  97. };
  98. #endif
  99. #if CONFIG_MP3ON4FLOAT_DECODER
  100. AVCodec ff_mp3on4float_decoder = {
  101. .name = "mp3on4float",
  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 = CODEC_CAP_DR1,
  110. .flush = flush_mp3on4,
  111. .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
  112. AV_SAMPLE_FMT_NONE },
  113. };
  114. #endif