yading@11
|
1 /*
|
yading@11
|
2 * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
yading@11
|
3 *
|
yading@11
|
4 * This file is part of Libav.
|
yading@11
|
5 *
|
yading@11
|
6 * Libav is free software; you can redistribute it and/or
|
yading@11
|
7 * modify it under the terms of the GNU Lesser General Public
|
yading@11
|
8 * License as published by the Free Software Foundation; either
|
yading@11
|
9 * version 2.1 of the License, or (at your option) any later version.
|
yading@11
|
10 *
|
yading@11
|
11 * Libav is distributed in the hope that it will be useful,
|
yading@11
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@11
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@11
|
14 * Lesser General Public License for more details.
|
yading@11
|
15 *
|
yading@11
|
16 * You should have received a copy of the GNU Lesser General Public
|
yading@11
|
17 * License along with Libav; if not, write to the Free Software
|
yading@11
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@11
|
19 */
|
yading@11
|
20
|
yading@11
|
21 #ifndef AVRESAMPLE_AUDIO_CONVERT_H
|
yading@11
|
22 #define AVRESAMPLE_AUDIO_CONVERT_H
|
yading@11
|
23
|
yading@11
|
24 #include "libavutil/samplefmt.h"
|
yading@11
|
25 #include "avresample.h"
|
yading@11
|
26 #include "internal.h"
|
yading@11
|
27 #include "audio_data.h"
|
yading@11
|
28
|
yading@11
|
29 /**
|
yading@11
|
30 * Set conversion function if the parameters match.
|
yading@11
|
31 *
|
yading@11
|
32 * This compares the parameters of the conversion function to the parameters
|
yading@11
|
33 * in the AudioConvert context. If the parameters do not match, no changes are
|
yading@11
|
34 * made to the active functions. If the parameters do match and the alignment
|
yading@11
|
35 * is not constrained, the function is set as the generic conversion function.
|
yading@11
|
36 * If the parameters match and the alignment is constrained, the function is
|
yading@11
|
37 * set as the optimized conversion function.
|
yading@11
|
38 *
|
yading@11
|
39 * @param ac AudioConvert context
|
yading@11
|
40 * @param out_fmt output sample format
|
yading@11
|
41 * @param in_fmt input sample format
|
yading@11
|
42 * @param channels number of channels, or 0 for any number of channels
|
yading@11
|
43 * @param ptr_align buffer pointer alignment, in bytes
|
yading@11
|
44 * @param samples_align buffer size alignment, in samples
|
yading@11
|
45 * @param descr function type description (e.g. "C" or "SSE")
|
yading@11
|
46 * @param conv conversion function pointer
|
yading@11
|
47 */
|
yading@11
|
48 void ff_audio_convert_set_func(AudioConvert *ac, enum AVSampleFormat out_fmt,
|
yading@11
|
49 enum AVSampleFormat in_fmt, int channels,
|
yading@11
|
50 int ptr_align, int samples_align,
|
yading@11
|
51 const char *descr, void *conv);
|
yading@11
|
52
|
yading@11
|
53 /**
|
yading@11
|
54 * Allocate and initialize AudioConvert context for sample format conversion.
|
yading@11
|
55 *
|
yading@11
|
56 * @param avr AVAudioResampleContext
|
yading@11
|
57 * @param out_fmt output sample format
|
yading@11
|
58 * @param in_fmt input sample format
|
yading@11
|
59 * @param channels number of channels
|
yading@11
|
60 * @param sample_rate sample rate (used for dithering)
|
yading@11
|
61 * @param apply_map apply channel map during conversion
|
yading@11
|
62 * @return newly-allocated AudioConvert context
|
yading@11
|
63 */
|
yading@11
|
64 AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr,
|
yading@11
|
65 enum AVSampleFormat out_fmt,
|
yading@11
|
66 enum AVSampleFormat in_fmt,
|
yading@11
|
67 int channels, int sample_rate,
|
yading@11
|
68 int apply_map);
|
yading@11
|
69
|
yading@11
|
70 /**
|
yading@11
|
71 * Free AudioConvert.
|
yading@11
|
72 *
|
yading@11
|
73 * The AudioConvert must have been previously allocated with ff_audio_convert_alloc().
|
yading@11
|
74 *
|
yading@11
|
75 * @param ac AudioConvert struct
|
yading@11
|
76 */
|
yading@11
|
77 void ff_audio_convert_free(AudioConvert **ac);
|
yading@11
|
78
|
yading@11
|
79 /**
|
yading@11
|
80 * Convert audio data from one sample format to another.
|
yading@11
|
81 *
|
yading@11
|
82 * For each call, the alignment of the input and output AudioData buffers are
|
yading@11
|
83 * examined to determine whether to use the generic or optimized conversion
|
yading@11
|
84 * function (when available).
|
yading@11
|
85 *
|
yading@11
|
86 * The number of samples to convert is determined by in->nb_samples. The output
|
yading@11
|
87 * buffer must be large enough to handle this many samples. out->nb_samples is
|
yading@11
|
88 * set by this function before a successful return.
|
yading@11
|
89 *
|
yading@11
|
90 * @param ac AudioConvert context
|
yading@11
|
91 * @param out output audio data
|
yading@11
|
92 * @param in input audio data
|
yading@11
|
93 * @return 0 on success, negative AVERROR code on failure
|
yading@11
|
94 */
|
yading@11
|
95 int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in);
|
yading@11
|
96
|
yading@11
|
97 /* arch-specific initialization functions */
|
yading@11
|
98
|
yading@11
|
99 void ff_audio_convert_init_arm(AudioConvert *ac);
|
yading@11
|
100 void ff_audio_convert_init_x86(AudioConvert *ac);
|
yading@11
|
101
|
yading@11
|
102 #endif /* AVRESAMPLE_AUDIO_CONVERT_H */
|