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 #include "libavutil/audioconvert.h"
00026
00027 #define SQRT3_2 1.22474487139158904909
00028
00029 typedef void (mix_1_1_func_type)(void *out, const void *in, void *coeffp, int index, int len);
00030 typedef void (mix_2_1_func_type)(void *out, const void *in1, const void *in2, void *coeffp, int index1, int index2, int len);
00031
00032 typedef void (mix_any_func_type)(uint8_t **out, const uint8_t **in1, void *coeffp, int len);
00033
00034 typedef struct AudioData{
00035 uint8_t *ch[SWR_CH_MAX];
00036 uint8_t *data;
00037 int ch_count;
00038 int bps;
00039 int count;
00040 int planar;
00041 enum AVSampleFormat fmt;
00042 } AudioData;
00043
00044 struct SwrContext {
00045 const AVClass *av_class;
00046 int log_level_offset;
00047 void *log_ctx;
00048 enum AVSampleFormat in_sample_fmt;
00049 enum AVSampleFormat int_sample_fmt;
00050 enum AVSampleFormat out_sample_fmt;
00051 int64_t in_ch_layout;
00052 int64_t out_ch_layout;
00053 int in_sample_rate;
00054 int out_sample_rate;
00055 int flags;
00056 float slev;
00057 float clev;
00058 float lfe_mix_level;
00059 float rematrix_volume;
00060 enum AVMatrixEncoding matrix_encoding;
00061 const int *channel_map;
00062 int used_ch_count;
00063 enum SwrDitherType dither_method;
00064 int dither_pos;
00065 float dither_scale;
00066 int filter_size;
00067 int phase_shift;
00068 int linear_interp;
00069 double cutoff;
00070 enum SwrFilterType filter_type;
00071 int kaiser_beta;
00073 float min_compensation;
00074 float min_hard_compensation;
00075 float soft_compensation_duration;
00076 float max_soft_compensation;
00077
00078 int resample_first;
00079 int rematrix;
00080 int rematrix_custom;
00081
00082 AudioData in;
00083 AudioData postin;
00084 AudioData midbuf;
00085 AudioData preout;
00086 AudioData out;
00087 AudioData in_buffer;
00088 AudioData dither;
00089 int in_buffer_index;
00090 int in_buffer_count;
00091 int resample_in_constraint;
00092 int flushed;
00093 int64_t outpts;
00094 int drop_output;
00095
00096 struct AudioConvert *in_convert;
00097 struct AudioConvert *out_convert;
00098 struct AudioConvert *full_convert;
00099 struct ResampleContext *resample;
00100
00101 float matrix[SWR_CH_MAX][SWR_CH_MAX];
00102 uint8_t *native_matrix;
00103 uint8_t *native_one;
00104 uint8_t *native_simd_matrix;
00105 int32_t matrix32[SWR_CH_MAX][SWR_CH_MAX];
00106 uint8_t matrix_ch[SWR_CH_MAX][SWR_CH_MAX+1];
00107 mix_1_1_func_type *mix_1_1_f;
00108 mix_1_1_func_type *mix_1_1_simd;
00109
00110 mix_2_1_func_type *mix_2_1_f;
00111 mix_2_1_func_type *mix_2_1_simd;
00112
00113 mix_any_func_type *mix_any_f;
00114
00115
00116 };
00117
00118 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, enum SwrFilterType, int kaiser_beta);
00119 void swri_resample_free(struct ResampleContext **c);
00120 int swri_multiple_resample(struct ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed);
00121 void swri_resample_compensate(struct ResampleContext *c, int sample_delta, int compensation_distance);
00122 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);
00123 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);
00124 int swri_resample_float(struct ResampleContext *c, float *dst, const float *src, int *consumed, int src_size, int dst_size, int update_ctx);
00125 int swri_resample_double(struct ResampleContext *c,double *dst, const double *src, int *consumed, int src_size, int dst_size, int update_ctx);
00126
00127 int swri_rematrix_init(SwrContext *s);
00128 void swri_rematrix_free(SwrContext *s);
00129 int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy);
00130 void swri_rematrix_init_x86(struct SwrContext *s);
00131
00132 void swri_get_dither(SwrContext *s, void *dst, int len, unsigned seed, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt);
00133
00134 void swri_audio_convert_init_arm(struct AudioConvert *ac,
00135 enum AVSampleFormat out_fmt,
00136 enum AVSampleFormat in_fmt,
00137 int channels);
00138 void swri_audio_convert_init_x86(struct AudioConvert *ac,
00139 enum AVSampleFormat out_fmt,
00140 enum AVSampleFormat in_fmt,
00141 int channels);
00142 #endif