]> git.sesse.net Git - casparcg/blob - ffmpeg 0.8/include/libswresample/swresample.h
05c4f6dc011c52fc3bf3abfe170a784600a744eb
[casparcg] / ffmpeg 0.8 / include / libswresample / swresample.h
1 /*
2  * Copyright (C) 2011 Michael Niedermayer (michaelni@gmx.at)
3  *
4  * This file is part of libswresample
5  *
6  * libswresample is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * libswresample is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with libswresample; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef SWR_H
22 #define SWR_H
23
24 #include <inttypes.h>
25 #include "libavutil/samplefmt.h"
26
27 #define LIBSWRESAMPLE_VERSION_MAJOR 0
28 #define LIBSWRESAMPLE_VERSION_MINOR 0
29 #define LIBSWRESAMPLE_VERSION_MICRO 0
30
31 #define SWR_CH_MAX 16
32
33 #define SWR_FLAG_RESAMPLE 1///< Force resampling even if equal sample rate
34 //TODO use int resample ?
35 //long term TODO can we enable this dynamically?
36
37
38 struct SwrContext;
39
40 /**
41  * Allocate SwrContext.
42  * @see swr_init(),swr_free()
43  * @return NULL on error
44  */
45 struct SwrContext *swr_alloc(void);
46
47 /**
48  * Initialize context after user parameters have been set.
49  * @return negativo n error
50  */
51 int swr_init(struct SwrContext *s);
52
53 /**
54  * Allocate SwrContext.
55  * @see swr_init(),swr_free()
56  * @return NULL on error
57  */
58 struct SwrContext *swr_alloc2(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,
59                               int64_t  in_ch_layout, enum AVSampleFormat  in_sample_fmt, int  in_sample_rate,
60                               int log_offset, void *log_ctx);
61
62 /**
63  * Free the given SwrContext.
64  * And set the pointer to NULL
65  */
66 void swr_free(struct SwrContext **s);
67
68 /**
69  * Convert audio.
70  * @param  in_count Number of input samples available in one channel.
71  * @param out_count Amount of space available for output in samples per channel.
72  * @return number of samples output per channel
73  */
74 int swr_convert(struct SwrContext *s, uint8_t *out[SWR_CH_MAX], int out_count,
75                                 const uint8_t *in [SWR_CH_MAX], int in_count);
76
77 void swr_compensate(struct SwrContext *s, int sample_delta, int compensation_distance);
78
79 #endif