audioconvert.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 libavcodec/audioconvert.h
  26. * Audio format conversion routines
  27. */
  28. #include "avcodec.h"
  29. /**
  30. * Generate string corresponding to the sample format with
  31. * number sample_fmt, or a header if sample_fmt is negative.
  32. *
  33. * @param[in] buf the buffer where to write the string
  34. * @param[in] buf_size the size of buf
  35. * @param[in] sample_fmt the number of the sample format to print the corresponding info string, or
  36. * a negative value to print the corresponding header.
  37. * Meaningful values for obtaining a sample format info vary from 0 to SAMPLE_FMT_NB -1.
  38. */
  39. void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt);
  40. /**
  41. * @return NULL on error
  42. */
  43. const char *avcodec_get_sample_fmt_name(int sample_fmt);
  44. /**
  45. * @return SAMPLE_FMT_NONE on error
  46. */
  47. enum SampleFormat avcodec_get_sample_fmt(const char* name);
  48. /**
  49. * @return NULL on error
  50. */
  51. const char *avcodec_get_channel_name(int channel_id);
  52. /**
  53. * Return description of channel layout
  54. */
  55. void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
  56. /**
  57. * Guess the channel layout
  58. * @param nb_channels
  59. * @param codec_id Codec identifier, or CODEC_ID_NONE if unknown
  60. * @param fmt_name Format name, or NULL if unknown
  61. * @return Channel layout mask
  62. */
  63. int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
  64. struct AVAudioConvert;
  65. typedef struct AVAudioConvert AVAudioConvert;
  66. /**
  67. * Create an audio sample format converter context
  68. * @param out_fmt Output sample format
  69. * @param out_channels Number of output channels
  70. * @param in_fmt Input sample format
  71. * @param in_channels Number of input channels
  72. * @param[in] matrix Channel mixing matrix (of dimension in_channel*out_channels). Set to NULL to ignore.
  73. * @param flags See FF_MM_xx
  74. * @return NULL on error
  75. */
  76. AVAudioConvert *av_audio_convert_alloc(enum SampleFormat out_fmt, int out_channels,
  77. enum SampleFormat in_fmt, int in_channels,
  78. const float *matrix, int flags);
  79. /**
  80. * Free audio sample format converter context
  81. */
  82. void av_audio_convert_free(AVAudioConvert *ctx);
  83. /**
  84. * Convert between audio sample formats
  85. * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel.
  86. * @param[in] out_stride distance between consecutive input samples (measured in bytes)
  87. * @param[in] in array of input buffers for each channel
  88. * @param[in] in_stride distance between consecutive output samples (measured in bytes)
  89. * @param len length of audio frame size (measured in samples)
  90. */
  91. int av_audio_convert(AVAudioConvert *ctx,
  92. void * const out[6], const int out_stride[6],
  93. const void * const in[6], const int in_stride[6], int len);
  94. #endif /* AVCODEC_AUDIOCONVERT_H */