3 * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
4 * Copyright (c) 2008 Peter Ross
6 * This file is part of Libav.
8 * Libav 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.
13 * Libav 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.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Libav; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef AVCODEC_AUDIOCONVERT_H
24 #define AVCODEC_AUDIOCONVERT_H
28 * Audio format conversion routines
32 #include "libavutil/cpu.h"
34 #include "libavutil/audioconvert.h"
36 #if FF_API_OLD_SAMPLE_FMT
38 * @deprecated Use av_get_sample_fmt_string() instead.
41 void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt);
44 * @deprecated Use av_get_sample_fmt_name() instead.
47 const char *avcodec_get_sample_fmt_name(int sample_fmt);
50 * @deprecated Use av_get_sample_fmt() instead.
53 enum AVSampleFormat avcodec_get_sample_fmt(const char* name);
56 #if FF_API_OLD_AUDIOCONVERT
58 * @deprecated Use av_get_channel_layout() instead.
61 int64_t avcodec_get_channel_layout(const char *name);
64 * @deprecated Use av_get_channel_layout_string() instead.
67 void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
70 * @deprecated Use av_get_channel_layout_nb_channels() instead.
73 int avcodec_channel_layout_num_channels(int64_t channel_layout);
77 * Guess the channel layout
79 * @param codec_id Codec identifier, or CODEC_ID_NONE if unknown
80 * @param fmt_name Format name, or NULL if unknown
81 * @return Channel layout mask
83 int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
85 struct AVAudioConvert;
86 typedef struct AVAudioConvert AVAudioConvert;
89 * Create an audio sample format converter context
90 * @param out_fmt Output sample format
91 * @param out_channels Number of output channels
92 * @param in_fmt Input sample format
93 * @param in_channels Number of input channels
94 * @param[in] matrix Channel mixing matrix (of dimension in_channel*out_channels). Set to NULL to ignore.
95 * @param flags See AV_CPU_FLAG_xx
96 * @return NULL on error
98 AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
99 enum AVSampleFormat in_fmt, int in_channels,
100 const float *matrix, int flags);
103 * Free audio sample format converter context
105 void av_audio_convert_free(AVAudioConvert *ctx);
108 * Convert between audio sample formats
109 * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel.
110 * @param[in] out_stride distance between consecutive output samples (measured in bytes)
111 * @param[in] in array of input buffers for each channel
112 * @param[in] in_stride distance between consecutive input samples (measured in bytes)
113 * @param len length of audio frame size (measured in samples)
115 int av_audio_convert(AVAudioConvert *ctx,
116 void * const out[6], const int out_stride[6],
117 const void * const in[6], const int in_stride[6], int len);
119 #endif /* AVCODEC_AUDIOCONVERT_H */