audioconvert.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. #if FF_API_OLD_SAMPLE_FMT
  31. /**
  32. * @deprecated Use av_get_sample_fmt_string() instead.
  33. */
  34. attribute_deprecated
  35. void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt);
  36. /**
  37. * @deprecated Use av_get_sample_fmt_name() instead.
  38. */
  39. attribute_deprecated
  40. const char *avcodec_get_sample_fmt_name(int sample_fmt);
  41. /**
  42. * @deprecated Use av_get_sample_fmt() instead.
  43. */
  44. attribute_deprecated
  45. enum AVSampleFormat avcodec_get_sample_fmt(const char* name);
  46. #endif
  47. #if FF_API_OLD_AUDIOCONVERT
  48. attribute_deprecated
  49. const char *avcodec_get_channel_name(int channel_id);
  50. /**
  51. * @deprecated Use av_get_channel_layout() instead.
  52. */
  53. attribute_deprecated
  54. int64_t avcodec_get_channel_layout(const char *name);
  55. /**
  56. * @deprecated Use av_get_channel_layout_string() instead.
  57. */
  58. attribute_deprecated
  59. void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
  60. /**
  61. * @deprecated Use av_get_channel_layout_nb_channels() instead.
  62. */
  63. attribute_deprecated
  64. int avcodec_channel_layout_num_channels(int64_t channel_layout);
  65. #endif
  66. /**
  67. * Guess the channel layout
  68. * @param nb_channels
  69. * @param codec_id Codec identifier, or CODEC_ID_NONE if unknown
  70. * @param fmt_name Format name, or NULL if unknown
  71. * @return Channel layout mask
  72. */
  73. int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
  74. struct AVAudioConvert;
  75. typedef struct AVAudioConvert AVAudioConvert;
  76. /**
  77. * Create an audio sample format converter context
  78. * @param out_fmt Output sample format
  79. * @param out_channels Number of output channels
  80. * @param in_fmt Input sample format
  81. * @param in_channels Number of input channels
  82. * @param[in] matrix Channel mixing matrix (of dimension in_channel*out_channels). Set to NULL to ignore.
  83. * @param flags See AV_CPU_FLAG_xx
  84. * @return NULL on error
  85. */
  86. AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
  87. enum AVSampleFormat in_fmt, int in_channels,
  88. const float *matrix, int flags);
  89. /**
  90. * Free audio sample format converter context
  91. */
  92. void av_audio_convert_free(AVAudioConvert *ctx);
  93. /**
  94. * Convert between audio sample formats
  95. * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel.
  96. * @param[in] out_stride distance between consecutive output samples (measured in bytes)
  97. * @param[in] in array of input buffers for each channel
  98. * @param[in] in_stride distance between consecutive input samples (measured in bytes)
  99. * @param len length of audio frame size (measured in samples)
  100. */
  101. int av_audio_convert(AVAudioConvert *ctx,
  102. void * const out[6], const int out_stride[6],
  103. const void * const in[6], const int in_stride[6], int len);
  104. #endif /* AVCODEC_AUDIOCONVERT_H */