yading@11: /* yading@11: * Copyright (c) 2012 Justin Ruggles yading@11: * yading@11: * This file is part of Libav. yading@11: * yading@11: * Libav is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * Libav is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with Libav; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: yading@11: #ifndef AVRESAMPLE_AUDIO_CONVERT_H yading@11: #define AVRESAMPLE_AUDIO_CONVERT_H yading@11: yading@11: #include "libavutil/samplefmt.h" yading@11: #include "avresample.h" yading@11: #include "internal.h" yading@11: #include "audio_data.h" yading@11: yading@11: /** yading@11: * Set conversion function if the parameters match. yading@11: * yading@11: * This compares the parameters of the conversion function to the parameters yading@11: * in the AudioConvert context. If the parameters do not match, no changes are yading@11: * made to the active functions. If the parameters do match and the alignment yading@11: * is not constrained, the function is set as the generic conversion function. yading@11: * If the parameters match and the alignment is constrained, the function is yading@11: * set as the optimized conversion function. yading@11: * yading@11: * @param ac AudioConvert context yading@11: * @param out_fmt output sample format yading@11: * @param in_fmt input sample format yading@11: * @param channels number of channels, or 0 for any number of channels yading@11: * @param ptr_align buffer pointer alignment, in bytes yading@11: * @param samples_align buffer size alignment, in samples yading@11: * @param descr function type description (e.g. "C" or "SSE") yading@11: * @param conv conversion function pointer yading@11: */ yading@11: void ff_audio_convert_set_func(AudioConvert *ac, enum AVSampleFormat out_fmt, yading@11: enum AVSampleFormat in_fmt, int channels, yading@11: int ptr_align, int samples_align, yading@11: const char *descr, void *conv); yading@11: yading@11: /** yading@11: * Allocate and initialize AudioConvert context for sample format conversion. yading@11: * yading@11: * @param avr AVAudioResampleContext yading@11: * @param out_fmt output sample format yading@11: * @param in_fmt input sample format yading@11: * @param channels number of channels yading@11: * @param sample_rate sample rate (used for dithering) yading@11: * @param apply_map apply channel map during conversion yading@11: * @return newly-allocated AudioConvert context yading@11: */ yading@11: AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, yading@11: enum AVSampleFormat out_fmt, yading@11: enum AVSampleFormat in_fmt, yading@11: int channels, int sample_rate, yading@11: int apply_map); yading@11: yading@11: /** yading@11: * Free AudioConvert. yading@11: * yading@11: * The AudioConvert must have been previously allocated with ff_audio_convert_alloc(). yading@11: * yading@11: * @param ac AudioConvert struct yading@11: */ yading@11: void ff_audio_convert_free(AudioConvert **ac); yading@11: yading@11: /** yading@11: * Convert audio data from one sample format to another. yading@11: * yading@11: * For each call, the alignment of the input and output AudioData buffers are yading@11: * examined to determine whether to use the generic or optimized conversion yading@11: * function (when available). yading@11: * yading@11: * The number of samples to convert is determined by in->nb_samples. The output yading@11: * buffer must be large enough to handle this many samples. out->nb_samples is yading@11: * set by this function before a successful return. yading@11: * yading@11: * @param ac AudioConvert context yading@11: * @param out output audio data yading@11: * @param in input audio data yading@11: * @return 0 on success, negative AVERROR code on failure yading@11: */ yading@11: int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in); yading@11: yading@11: /* arch-specific initialization functions */ yading@11: yading@11: void ff_audio_convert_init_arm(AudioConvert *ac); yading@11: void ff_audio_convert_init_x86(AudioConvert *ac); yading@11: yading@11: #endif /* AVRESAMPLE_AUDIO_CONVERT_H */