]> git.sesse.net Git - ffmpeg/blob - libavcodec/audioconvert.h
aacenc: fix typo in sync extension constant in 8ae0fa2
[ffmpeg] / libavcodec / audioconvert.h
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
23 #ifndef AVCODEC_AUDIOCONVERT_H
24 #define AVCODEC_AUDIOCONVERT_H
25
26 /**
27  * @file
28  * Audio format conversion routines
29  */
30
31
32 #include "libavutil/cpu.h"
33 #include "avcodec.h"
34
35 #if FF_API_OLD_SAMPLE_FMT
36 /**
37  * @deprecated Use av_get_sample_fmt_string() instead.
38  */
39 attribute_deprecated
40 void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt);
41
42 /**
43  * @deprecated Use av_get_sample_fmt_name() instead.
44  */
45 attribute_deprecated
46 const char *avcodec_get_sample_fmt_name(int sample_fmt);
47
48 /**
49  * @deprecated Use av_get_sample_fmt() instead.
50  */
51 attribute_deprecated
52 enum AVSampleFormat avcodec_get_sample_fmt(const char* name);
53 #endif
54
55 #if FF_API_OLD_AUDIOCONVERT
56 /**
57  * @deprecated Use av_get_channel_layout() instead.
58  */
59 attribute_deprecated
60 int64_t avcodec_get_channel_layout(const char *name);
61
62 /**
63  * @deprecated Use av_get_channel_layout_string() instead.
64  */
65 attribute_deprecated
66 void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
67
68 /**
69  * @deprecated Use av_get_channel_layout_nb_channels() instead.
70  */
71 attribute_deprecated
72 int avcodec_channel_layout_num_channels(int64_t channel_layout);
73 #endif
74
75 /**
76  * Guess the channel layout
77  * @param nb_channels
78  * @param codec_id Codec identifier, or CODEC_ID_NONE if unknown
79  * @param fmt_name Format name, or NULL if unknown
80  * @return Channel layout mask
81  */
82 int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
83
84 struct AVAudioConvert;
85 typedef struct AVAudioConvert AVAudioConvert;
86
87 /**
88  * Create an audio sample format converter context
89  * @param out_fmt Output sample format
90  * @param out_channels Number of output channels
91  * @param in_fmt Input sample format
92  * @param in_channels Number of input channels
93  * @param[in] matrix Channel mixing matrix (of dimension in_channel*out_channels). Set to NULL to ignore.
94  * @param flags See AV_CPU_FLAG_xx
95  * @return NULL on error
96  */
97 AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
98                                        enum AVSampleFormat in_fmt, int in_channels,
99                                        const float *matrix, int flags);
100
101 /**
102  * Free audio sample format converter context
103  */
104 void av_audio_convert_free(AVAudioConvert *ctx);
105
106 /**
107  * Convert between audio sample formats
108  * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel.
109  * @param[in] out_stride distance between consecutive output samples (measured in bytes)
110  * @param[in] in array of input buffers for each channel
111  * @param[in] in_stride distance between consecutive input samples (measured in bytes)
112  * @param len length of audio frame size (measured in samples)
113  */
114 int av_audio_convert(AVAudioConvert *ctx,
115                            void * const out[6], const int out_stride[6],
116                      const void * const  in[6], const int  in_stride[6], int len);
117
118 #endif /* AVCODEC_AUDIOCONVERT_H */