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_INTERNAL_H yading@11: #define AVRESAMPLE_INTERNAL_H yading@11: yading@11: #include "libavutil/audio_fifo.h" yading@11: #include "libavutil/log.h" yading@11: #include "libavutil/opt.h" yading@11: #include "libavutil/samplefmt.h" yading@11: #include "avresample.h" yading@11: yading@11: typedef struct AudioData AudioData; yading@11: typedef struct AudioConvert AudioConvert; yading@11: typedef struct AudioMix AudioMix; yading@11: typedef struct ResampleContext ResampleContext; yading@11: yading@11: enum RemapPoint { yading@11: REMAP_NONE, yading@11: REMAP_IN_COPY, yading@11: REMAP_IN_CONVERT, yading@11: REMAP_OUT_COPY, yading@11: REMAP_OUT_CONVERT, yading@11: }; yading@11: yading@11: typedef struct ChannelMapInfo { yading@11: int channel_map[AVRESAMPLE_MAX_CHANNELS]; /**< source index of each output channel, -1 if not remapped */ yading@11: int do_remap; /**< remap needed */ yading@11: int channel_copy[AVRESAMPLE_MAX_CHANNELS]; /**< dest index to copy from */ yading@11: int do_copy; /**< copy needed */ yading@11: int channel_zero[AVRESAMPLE_MAX_CHANNELS]; /**< dest index to zero */ yading@11: int do_zero; /**< zeroing needed */ yading@11: int input_map[AVRESAMPLE_MAX_CHANNELS]; /**< dest index of each input channel */ yading@11: } ChannelMapInfo; yading@11: yading@11: struct AVAudioResampleContext { yading@11: const AVClass *av_class; /**< AVClass for logging and AVOptions */ yading@11: yading@11: uint64_t in_channel_layout; /**< input channel layout */ yading@11: enum AVSampleFormat in_sample_fmt; /**< input sample format */ yading@11: int in_sample_rate; /**< input sample rate */ yading@11: uint64_t out_channel_layout; /**< output channel layout */ yading@11: enum AVSampleFormat out_sample_fmt; /**< output sample format */ yading@11: int out_sample_rate; /**< output sample rate */ yading@11: enum AVSampleFormat internal_sample_fmt; /**< internal sample format */ yading@11: enum AVMixCoeffType mix_coeff_type; /**< mixing coefficient type */ yading@11: double center_mix_level; /**< center mix level */ yading@11: double surround_mix_level; /**< surround mix level */ yading@11: double lfe_mix_level; /**< lfe mix level */ yading@11: int normalize_mix_level; /**< enable mix level normalization */ yading@11: int force_resampling; /**< force resampling */ yading@11: int filter_size; /**< length of each FIR filter in the resampling filterbank relative to the cutoff frequency */ yading@11: int phase_shift; /**< log2 of the number of entries in the resampling polyphase filterbank */ yading@11: int linear_interp; /**< if 1 then the resampling FIR filter will be linearly interpolated */ yading@11: double cutoff; /**< resampling cutoff frequency. 1.0 corresponds to half the output sample rate */ yading@11: enum AVResampleFilterType filter_type; /**< resampling filter type */ yading@11: int kaiser_beta; /**< beta value for Kaiser window (only applicable if filter_type == AV_FILTER_TYPE_KAISER) */ yading@11: enum AVResampleDitherMethod dither_method; /**< dither method */ yading@11: yading@11: int in_channels; /**< number of input channels */ yading@11: int out_channels; /**< number of output channels */ yading@11: int resample_channels; /**< number of channels used for resampling */ yading@11: int downmix_needed; /**< downmixing is needed */ yading@11: int upmix_needed; /**< upmixing is needed */ yading@11: int mixing_needed; /**< either upmixing or downmixing is needed */ yading@11: int resample_needed; /**< resampling is needed */ yading@11: int in_convert_needed; /**< input sample format conversion is needed */ yading@11: int out_convert_needed; /**< output sample format conversion is needed */ yading@11: int in_copy_needed; /**< input data copy is needed */ yading@11: yading@11: AudioData *in_buffer; /**< buffer for converted input */ yading@11: AudioData *resample_out_buffer; /**< buffer for output from resampler */ yading@11: AudioData *out_buffer; /**< buffer for converted output */ yading@11: AVAudioFifo *out_fifo; /**< FIFO for output samples */ yading@11: yading@11: AudioConvert *ac_in; /**< input sample format conversion context */ yading@11: AudioConvert *ac_out; /**< output sample format conversion context */ yading@11: ResampleContext *resample; /**< resampling context */ yading@11: AudioMix *am; /**< channel mixing context */ yading@11: enum AVMatrixEncoding matrix_encoding; /**< matrixed stereo encoding */ yading@11: yading@11: /** yading@11: * mix matrix yading@11: * only used if avresample_set_matrix() is called before avresample_open() yading@11: */ yading@11: double *mix_matrix; yading@11: yading@11: int use_channel_map; yading@11: enum RemapPoint remap_point; yading@11: ChannelMapInfo ch_map_info; yading@11: }; yading@11: yading@11: #endif /* AVRESAMPLE_INTERNAL_H */