/*1* Copyright (c) 2012 Justin Ruggles <[email protected]>2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920#ifndef AVRESAMPLE_AUDIO_CONVERT_H21#define AVRESAMPLE_AUDIO_CONVERT_H2223#include "libavutil/samplefmt.h"24#include "avresample.h"25#include "internal.h"26#include "audio_data.h"2728/**29* Set conversion function if the parameters match.30*31* This compares the parameters of the conversion function to the parameters32* in the AudioConvert context. If the parameters do not match, no changes are33* made to the active functions. If the parameters do match and the alignment34* is not constrained, the function is set as the generic conversion function.35* If the parameters match and the alignment is constrained, the function is36* set as the optimized conversion function.37*38* @param ac AudioConvert context39* @param out_fmt output sample format40* @param in_fmt input sample format41* @param channels number of channels, or 0 for any number of channels42* @param ptr_align buffer pointer alignment, in bytes43* @param samples_align buffer size alignment, in samples44* @param descr function type description (e.g. "C" or "SSE")45* @param conv conversion function pointer46*/47void ff_audio_convert_set_func(AudioConvert *ac, enum AVSampleFormat out_fmt,48enum AVSampleFormat in_fmt, int channels,49int ptr_align, int samples_align,50const char *descr, void *conv);5152/**53* Allocate and initialize AudioConvert context for sample format conversion.54*55* @param avr AVAudioResampleContext56* @param out_fmt output sample format57* @param in_fmt input sample format58* @param channels number of channels59* @param sample_rate sample rate (used for dithering)60* @param apply_map apply channel map during conversion61* @return newly-allocated AudioConvert context62*/63AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr,64enum AVSampleFormat out_fmt,65enum AVSampleFormat in_fmt,66int channels, int sample_rate,67int apply_map);6869/**70* Free AudioConvert.71*72* The AudioConvert must have been previously allocated with ff_audio_convert_alloc().73*74* @param ac AudioConvert struct75*/76void ff_audio_convert_free(AudioConvert **ac);7778/**79* Convert audio data from one sample format to another.80*81* For each call, the alignment of the input and output AudioData buffers are82* examined to determine whether to use the generic or optimized conversion83* function (when available).84*85* The number of samples to convert is determined by in->nb_samples. The output86* buffer must be large enough to handle this many samples. out->nb_samples is87* set by this function before a successful return.88*89* @param ac AudioConvert context90* @param out output audio data91* @param in input audio data92* @return 0 on success, negative AVERROR code on failure93*/94int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in);9596/* arch-specific initialization functions */9798void ff_audio_convert_init_aarch64(AudioConvert *ac);99void ff_audio_convert_init_arm(AudioConvert *ac);100void ff_audio_convert_init_x86(AudioConvert *ac);101102#endif /* AVRESAMPLE_AUDIO_CONVERT_H */103104105