yading@11: /* yading@11: * audio conversion yading@11: * Copyright (c) 2006 Michael Niedermayer yading@11: * Copyright (c) 2008 Peter Ross yading@11: * yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg 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: * FFmpeg 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 FFmpeg; 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 SWR_AUDIOCONVERT_H yading@11: #define SWR_AUDIOCONVERT_H yading@11: yading@11: /** yading@11: * @file yading@11: * Audio format conversion routines yading@11: */ yading@11: yading@11: yading@11: #include "swresample_internal.h" yading@11: #include "libavutil/cpu.h" yading@11: yading@11: yading@11: typedef void (conv_func_type)(uint8_t *po, const uint8_t *pi, int is, int os, uint8_t *end); yading@11: typedef void (simd_func_type)(uint8_t **dst, const uint8_t **src, int len); yading@11: yading@11: typedef struct AudioConvert { yading@11: int channels; yading@11: int in_simd_align_mask; yading@11: int out_simd_align_mask; yading@11: conv_func_type *conv_f; yading@11: simd_func_type *simd_f; yading@11: const int *ch_map; yading@11: uint8_t silence[8]; ///< silence input sample yading@11: }AudioConvert; yading@11: yading@11: /** yading@11: * Create an audio sample format converter context 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 flags See AV_CPU_FLAG_xx yading@11: * @param ch_map list of the channels id to pick from the source stream, NULL yading@11: * if all channels must be selected yading@11: * @return NULL on error yading@11: */ yading@11: AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, yading@11: enum AVSampleFormat in_fmt, yading@11: int channels, const int *ch_map, yading@11: int flags); yading@11: yading@11: /** yading@11: * Free audio sample format converter context. yading@11: * and set the pointer to NULL yading@11: */ yading@11: void swri_audio_convert_free(AudioConvert **ctx); yading@11: yading@11: /** yading@11: * Convert between audio sample formats yading@11: * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel. yading@11: * @param[in] in array of input buffers for each channel yading@11: * @param len length of audio frame size (measured in samples) yading@11: */ yading@11: int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len); yading@11: yading@11: #endif /* AUDIOCONVERT_H */