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_MIX_H yading@11: #define AVRESAMPLE_AUDIO_MIX_H yading@11: yading@11: #include 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: typedef void (mix_func)(uint8_t **src, void **matrix, int len, int out_ch, yading@11: int in_ch); yading@11: yading@11: /** yading@11: * Set mixing function if the parameters match. yading@11: * yading@11: * This compares the parameters of the mixing function to the parameters in the yading@11: * AudioMix context. If the parameters do not match, no changes are made to the yading@11: * active functions. If the parameters do match and the alignment is not yading@11: * constrained, the function is set as the generic mixing function. If the yading@11: * parameters match and the alignment is constrained, the function is set as yading@11: * the optimized mixing function. yading@11: * yading@11: * @param am AudioMix context yading@11: * @param fmt input/output sample format yading@11: * @param coeff_type mixing coefficient type yading@11: * @param in_channels number of input channels, or 0 for any number of channels yading@11: * @param out_channels number of output 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 mix_func mixing function pointer yading@11: */ yading@11: void ff_audio_mix_set_func(AudioMix *am, enum AVSampleFormat fmt, yading@11: enum AVMixCoeffType coeff_type, int in_channels, yading@11: int out_channels, int ptr_align, int samples_align, yading@11: const char *descr, void *mix_func); yading@11: yading@11: /** yading@11: * Allocate and initialize an AudioMix context. yading@11: * yading@11: * The parameters in the AVAudioResampleContext are used to initialize the yading@11: * AudioMix context. yading@11: * yading@11: * @param avr AVAudioResampleContext yading@11: * @return newly-allocated AudioMix context. yading@11: */ yading@11: AudioMix *ff_audio_mix_alloc(AVAudioResampleContext *avr); yading@11: yading@11: /** yading@11: * Free an AudioMix context. yading@11: */ yading@11: void ff_audio_mix_free(AudioMix **am); yading@11: yading@11: /** yading@11: * Apply channel mixing to audio data using the current mixing matrix. yading@11: */ yading@11: int ff_audio_mix(AudioMix *am, AudioData *src); yading@11: yading@11: /** yading@11: * Get the current mixing matrix. yading@11: */ yading@11: int ff_audio_mix_get_matrix(AudioMix *am, double *matrix, int stride); yading@11: yading@11: /** yading@11: * Set the current mixing matrix. yading@11: */ yading@11: int ff_audio_mix_set_matrix(AudioMix *am, const double *matrix, int stride); yading@11: yading@11: /* arch-specific initialization functions */ yading@11: yading@11: void ff_audio_mix_init_x86(AudioMix *am); yading@11: yading@11: #endif /* AVRESAMPLE_AUDIO_MIX_H */