audioconvert.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * audio conversion
  3. * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
  4. * Copyright (c) 2008 Peter Ross
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVCODEC_AUDIOCONVERT_H
  23. #define AVCODEC_AUDIOCONVERT_H
  24. /**
  25. * @file
  26. * Audio format conversion routines
  27. */
  28. #include "libavutil/cpu.h"
  29. #include "avcodec.h"
  30. #include "libavutil/audioconvert.h"
  31. #if FF_API_OLD_SAMPLE_FMT
  32. /**
  33. * @deprecated Use av_get_sample_fmt_string() instead.
  34. */
  35. attribute_deprecated
  36. void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt);
  37. /**
  38. * @deprecated Use av_get_sample_fmt_name() instead.
  39. */
  40. attribute_deprecated
  41. const char *avcodec_get_sample_fmt_name(int sample_fmt);
  42. /**
  43. * @deprecated Use av_get_sample_fmt() instead.
  44. */
  45. attribute_deprecated
  46. enum AVSampleFormat avcodec_get_sample_fmt(const char* name);
  47. #endif
  48. #if FF_API_OLD_AUDIOCONVERT
  49. /**
  50. * @deprecated Use av_get_channel_layout() instead.
  51. */
  52. attribute_deprecated
  53. int64_t avcodec_get_channel_layout(const char *name);
  54. /**
  55. * @deprecated Use av_get_channel_layout_string() instead.
  56. */
  57. attribute_deprecated
  58. void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
  59. /**
  60. * @deprecated Use av_get_channel_layout_nb_channels() instead.
  61. */
  62. attribute_deprecated
  63. int avcodec_channel_layout_num_channels(int64_t channel_layout);
  64. #endif
  65. /**
  66. * Guess the channel layout
  67. * @param nb_channels
  68. * @param codec_id Codec identifier, or CODEC_ID_NONE if unknown
  69. * @param fmt_name Format name, or NULL if unknown
  70. * @return Channel layout mask
  71. */
  72. uint64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
  73. struct AVAudioConvert;
  74. typedef struct AVAudioConvert AVAudioConvert;
  75. /**
  76. * Create an audio sample format converter context
  77. * @param out_fmt Output sample format
  78. * @param out_channels Number of output channels
  79. * @param in_fmt Input sample format
  80. * @param in_channels Number of input channels
  81. * @param[in] matrix Channel mixing matrix (of dimension in_channel*out_channels). Set to NULL to ignore.
  82. * @param flags See AV_CPU_FLAG_xx
  83. * @return NULL on error
  84. */
  85. AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
  86. enum AVSampleFormat in_fmt, int in_channels,
  87. const float *matrix, int flags);
  88. /**
  89. * Free audio sample format converter context
  90. */
  91. void av_audio_convert_free(AVAudioConvert *ctx);
  92. /**
  93. * Convert between audio sample formats
  94. * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel.
  95. * @param[in] out_stride distance between consecutive output samples (measured in bytes)
  96. * @param[in] in array of input buffers for each channel
  97. * @param[in] in_stride distance between consecutive input samples (measured in bytes)
  98. * @param len length of audio frame size (measured in samples)
  99. */
  100. int av_audio_convert(AVAudioConvert *ctx,
  101. void * const out[6], const int out_stride[6],
  102. const void * const in[6], const int in_stride[6], int len);
  103. #endif /* AVCODEC_AUDIOCONVERT_H */