diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index 5c34e11c18..17d6232a44 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -215,20 +215,20 @@ int swr_rematrix_init(SwrContext *s){ s->matrix16[i][j]= lrintf(s->matrix[i][j] * 32768); } } - for(i=0; iout_ch_layout); i++){ - for(j=0; jin_ch_layout); j++){ - av_log(NULL, AV_LOG_DEBUG, "%f ", s->matrix[i][j]); - } - av_log(NULL, AV_LOG_DEBUG, "\n"); + for(i=0; iout_ch_layout); i++){ + for(j=0; jin_ch_layout); j++){ + av_log(NULL, AV_LOG_DEBUG, "%f ", s->matrix[i][j]); } + av_log(NULL, AV_LOG_DEBUG, "\n"); + } return 0; } int swr_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy){ int out_i, in_i, i, j; -av_assert0(out->ch_count == av_get_channel_layout_nb_channels(s->out_ch_layout)); -av_assert0(in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout)); + av_assert0(out->ch_count == av_get_channel_layout_nb_channels(s->out_ch_layout)); + av_assert0(in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout)); for(out_i=0; out_ich_count; out_i++){ switch(s->matrix_ch[out_i][0]){ diff --git a/libswresample/resample2.c b/libswresample/resample2.c index 8623877c7c..73f536fa26 100644 --- a/libswresample/resample2.c +++ b/libswresample/resample2.c @@ -259,7 +259,7 @@ int swr_resample(AVResampleContext *c, short *dst, short *src, int *consumed, in int dst_incr= c->dst_incr / c->src_incr; int compensation_distance= c->compensation_distance; - if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){ + if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){ int64_t index2= ((int64_t)index)<<32; int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr; dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr); @@ -272,51 +272,51 @@ int swr_resample(AVResampleContext *c, short *dst, short *src, int *consumed, in index += dst_index * dst_incr; index += frac / c->src_incr; frac %= c->src_incr; - }else{ - for(dst_index=0; dst_index < dst_size; dst_index++){ - FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); - int sample_index= index >> c->phase_shift; - FELEM2 val=0; + }else{ + for(dst_index=0; dst_index < dst_size; dst_index++){ + FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); + int sample_index= index >> c->phase_shift; + FELEM2 val=0; - if(sample_index < 0){ - for(i=0; ifilter_length; i++) - val += src[FFABS(sample_index + i) % src_size] * filter[i]; - }else if(sample_index + c->filter_length > src_size){ - break; - }else if(c->linear){ - FELEM2 v2=0; - for(i=0; ifilter_length; i++){ - val += src[sample_index + i] * (FELEM2)filter[i]; - v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length]; + if(sample_index < 0){ + for(i=0; ifilter_length; i++) + val += src[FFABS(sample_index + i) % src_size] * filter[i]; + }else if(sample_index + c->filter_length > src_size){ + break; + }else if(c->linear){ + FELEM2 v2=0; + for(i=0; ifilter_length; i++){ + val += src[sample_index + i] * (FELEM2)filter[i]; + v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length]; + } + val+=(v2-val)*(FELEML)frac / c->src_incr; + }else{ + for(i=0; ifilter_length; i++){ + val += src[sample_index + i] * (FELEM2)filter[i]; + } } - val+=(v2-val)*(FELEML)frac / c->src_incr; - }else{ - for(i=0; ifilter_length; i++){ - val += src[sample_index + i] * (FELEM2)filter[i]; - } - } #ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE - dst[dst_index] = av_clip_int16(lrintf(val)); + dst[dst_index] = av_clip_int16(lrintf(val)); #else - val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT; - dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val; + val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT; + dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val; #endif - frac += dst_incr_frac; - index += dst_incr; - if(frac >= c->src_incr){ - frac -= c->src_incr; - index++; - } + frac += dst_incr_frac; + index += dst_incr; + if(frac >= c->src_incr){ + frac -= c->src_incr; + index++; + } - if(dst_index + 1 == compensation_distance){ - compensation_distance= 0; - dst_incr_frac= c->ideal_dst_incr % c->src_incr; - dst_incr= c->ideal_dst_incr / c->src_incr; + if(dst_index + 1 == compensation_distance){ + compensation_distance= 0; + dst_incr_frac= c->ideal_dst_incr % c->src_incr; + dst_incr= c->ideal_dst_incr / c->src_incr; + } } } - } *consumed= FFMAX(index, 0) >> c->phase_shift; if(index>=0) index &= c->phase_mask;