]> git.sesse.net Git - ffmpeg/blob - libavcodec/audioconvert.h
remove impossible condition from msrle_decode_pal4()
[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
36 /**
37  * Generate string corresponding to the sample format with
38  * number sample_fmt, or a header if sample_fmt is negative.
39  *
40  * @param[in] buf the buffer where to write the string
41  * @param[in] buf_size the size of buf
42  * @param[in] sample_fmt the number of the sample format to print the corresponding info string, or
43  * a negative value to print the corresponding header.
44  * Meaningful values for obtaining a sample format info vary from 0 to SAMPLE_FMT_NB -1.
45  */
46 void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt);
47
48 /**
49  * @return NULL on error
50  */
51 const char *avcodec_get_sample_fmt_name(int sample_fmt);
52
53 /**
54  * @return SAMPLE_FMT_NONE on error
55  */
56 enum SampleFormat avcodec_get_sample_fmt(const char* name);
57
58 /**
59  * @return NULL on error
60  */
61 const char *avcodec_get_channel_name(int channel_id);
62
63 /**
64  * @return channel layout that matches name, 0 if no match
65  */
66 int64_t avcodec_get_channel_layout(const char *name);
67
68 /**
69  * Return description of channel layout
70  */
71 void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
72
73 /**
74  * Guess the channel layout
75  * @param nb_channels
76  * @param codec_id Codec identifier, or CODEC_ID_NONE if unknown
77  * @param fmt_name Format name, or NULL if unknown
78  * @return Channel layout mask
79  */
80 int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
81
82 /**
83  * @return the number of channels in the channel layout.
84  */
85 int avcodec_channel_layout_num_channels(int64_t channel_layout);
86
87 struct AVAudioConvert;
88 typedef struct AVAudioConvert AVAudioConvert;
89
90 /**
91  * Create an audio sample format converter context
92  * @param out_fmt Output sample format
93  * @param out_channels Number of output channels
94  * @param in_fmt Input sample format
95  * @param in_channels Number of input channels
96  * @param[in] matrix Channel mixing matrix (of dimension in_channel*out_channels). Set to NULL to ignore.
97  * @param flags See AV_CPU_FLAG_xx
98  * @return NULL on error
99  */
100 AVAudioConvert *av_audio_convert_alloc(enum SampleFormat out_fmt, int out_channels,
101                                        enum SampleFormat in_fmt, int in_channels,
102                                        const float *matrix, int flags);
103
104 /**
105  * Free audio sample format converter context
106  */
107 void av_audio_convert_free(AVAudioConvert *ctx);
108
109 /**
110  * Convert between audio sample formats
111  * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel.
112  * @param[in] out_stride distance between consecutive output samples (measured in bytes)
113  * @param[in] in array of input buffers for each channel
114  * @param[in] in_stride distance between consecutive input samples (measured in bytes)
115  * @param len length of audio frame size (measured in samples)
116  */
117 int av_audio_convert(AVAudioConvert *ctx,
118                            void * const out[6], const int out_stride[6],
119                      const void * const  in[6], const int  in_stride[6], int len);
120
121 #endif /* AVCODEC_AUDIOCONVERT_H */