00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SWR_INTERNAL_H
00022 #define SWR_INTERNAL_H
00023
00024 #include "swresample.h"
00025
00026 typedef void (mix_1_1_func_type)(void *out, const void *in, void *coeffp, int index, int len);
00027 typedef void (mix_2_1_func_type)(void *out, const void *in1, const void *in2, void *coeffp, int index1, int index2, int len);
00028
00029 typedef struct AudioData{
00030 uint8_t *ch[SWR_CH_MAX];
00031 uint8_t *data;
00032 int ch_count;
00033 int bps;
00034 int count;
00035 int planar;
00036 enum AVSampleFormat fmt;
00037 } AudioData;
00038
00039 struct SwrContext {
00040 const AVClass *av_class;
00041 int log_level_offset;
00042 void *log_ctx;
00043 enum AVSampleFormat in_sample_fmt;
00044 enum AVSampleFormat int_sample_fmt;
00045 enum AVSampleFormat out_sample_fmt;
00046 int64_t in_ch_layout;
00047 int64_t out_ch_layout;
00048 int in_sample_rate;
00049 int out_sample_rate;
00050 int flags;
00051 float slev;
00052 float clev;
00053 float lfe_mix_level;
00054 float rematrix_volume;
00055 const int *channel_map;
00056 int used_ch_count;
00057 enum SwrDitherType dither_method;
00058 int dither_pos;
00059 float dither_scale;
00060 int filter_size;
00061 int phase_shift;
00062 int linear_interp;
00063 double cutoff;
00065 float min_compensation;
00066 float min_hard_compensation;
00067 float soft_compensation_duration;
00068 float max_soft_compensation;
00069
00070 int resample_first;
00071 int rematrix;
00072 int rematrix_custom;
00073
00074 AudioData in;
00075 AudioData postin;
00076 AudioData midbuf;
00077 AudioData preout;
00078 AudioData out;
00079 AudioData in_buffer;
00080 AudioData dither;
00081 int in_buffer_index;
00082 int in_buffer_count;
00083 int resample_in_constraint;
00084 int flushed;
00085 int64_t outpts;
00086 int drop_output;
00087
00088 struct AudioConvert *in_convert;
00089 struct AudioConvert *out_convert;
00090 struct AudioConvert *full_convert;
00091 struct ResampleContext *resample;
00092
00093 float matrix[SWR_CH_MAX][SWR_CH_MAX];
00094 uint8_t *native_matrix;
00095 uint8_t *native_one;
00096 int32_t matrix32[SWR_CH_MAX][SWR_CH_MAX];
00097 uint8_t matrix_ch[SWR_CH_MAX][SWR_CH_MAX+1];
00098 mix_1_1_func_type *mix_1_1_f;
00099 mix_2_1_func_type *mix_2_1_f;
00100
00101
00102 };
00103
00104 struct ResampleContext *swri_resample_init(struct ResampleContext *, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff, enum AVSampleFormat);
00105 void swri_resample_free(struct ResampleContext **c);
00106 int swri_multiple_resample(struct ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed);
00107 void swri_resample_compensate(struct ResampleContext *c, int sample_delta, int compensation_distance);
00108 int swri_resample_int16(struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
00109 int swri_resample_int32(struct ResampleContext *c, int32_t *dst, const int32_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
00110 int swri_resample_float(struct ResampleContext *c, float *dst, const float *src, int *consumed, int src_size, int dst_size, int update_ctx);
00111 int swri_resample_double(struct ResampleContext *c,double *dst, const double *src, int *consumed, int src_size, int dst_size, int update_ctx);
00112
00113 int swri_rematrix_init(SwrContext *s);
00114 void swri_rematrix_free(SwrContext *s);
00115 int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy);
00116
00117 void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt);
00118
00119 void swri_audio_convert_init_x86(struct AudioConvert *ac,
00120 enum AVSampleFormat out_fmt,
00121 enum AVSampleFormat in_fmt,
00122 int channels);
00123 #endif