You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
4.0KB

  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. /**
  31. * Generate string corresponding to the sample format with
  32. * number sample_fmt, or a header if sample_fmt is negative.
  33. *
  34. * @param[in] buf the buffer where to write the string
  35. * @param[in] buf_size the size of buf
  36. * @param[in] sample_fmt the number of the sample format to print the corresponding info string, or
  37. * a negative value to print the corresponding header.
  38. * Meaningful values for obtaining a sample format info vary from 0 to SAMPLE_FMT_NB -1.
  39. */
  40. void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt);
  41. /**
  42. * @return NULL on error
  43. */
  44. const char *avcodec_get_sample_fmt_name(int sample_fmt);
  45. /**
  46. * @return SAMPLE_FMT_NONE on error
  47. */
  48. enum SampleFormat avcodec_get_sample_fmt(const char* name);
  49. /**
  50. * @return NULL on error
  51. */
  52. const char *avcodec_get_channel_name(int channel_id);
  53. /**
  54. * @return channel layout that matches name, 0 if no match
  55. */
  56. int64_t avcodec_get_channel_layout(const char *name);
  57. /**
  58. * Return description of channel layout
  59. */
  60. void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
  61. /**
  62. * Guess the channel layout
  63. * @param nb_channels
  64. * @param codec_id Codec identifier, or CODEC_ID_NONE if unknown
  65. * @param fmt_name Format name, or NULL if unknown
  66. * @return Channel layout mask
  67. */
  68. int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
  69. /**
  70. * @return the number of channels in the channel layout.
  71. */
  72. int avcodec_channel_layout_num_channels(int64_t channel_layout);
  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 SampleFormat out_fmt, int out_channels,
  86. enum SampleFormat 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 */