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