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