aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-06-30 14:15:31 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-06-30 14:15:31 +0000
commitb9d2085ba14aa733503ff02d966204992f46ff00 (patch)
tree81e862130f7a1dd0ddb4b17231d405937f3af62e /libavcodec
parent2d48edddf7b1f47bd9a8b807060170c6246b877c (diff)
downloadffmpeg-b9d2085ba14aa733503ff02d966204992f46ff00.tar.gz
various resampling fixes
Originally committed as revision 3271 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/resample.c2
-rw-r--r--libavcodec/resample2.c12
2 files changed, 8 insertions, 6 deletions
diff --git a/libavcodec/resample.c b/libavcodec/resample.c
index 56b7917444..63371b0a1d 100644
--- a/libavcodec/resample.c
+++ b/libavcodec/resample.c
@@ -175,7 +175,7 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl
short *buftmp2[2], *buftmp3[2];
int lenout;
- if (s->input_channels == s->output_channels && s->ratio == 1.0) {
+ if (s->input_channels == s->output_channels && s->ratio == 1.0 && 0) {
/* nothing to do */
memcpy(output, input, nb_samples * s->input_channels * sizeof(short));
return nb_samples;
diff --git a/libavcodec/resample2.c b/libavcodec/resample2.c
index e4115118a2..47eeb0a2d8 100644
--- a/libavcodec/resample2.c
+++ b/libavcodec/resample2.c
@@ -123,8 +123,8 @@ AVResampleContext *av_resample_init(int out_rate, int in_rate){
c->filter_length= ceil(16.0/factor);
c->filter_bank= av_mallocz(c->filter_length*(PHASE_COUNT+1)*sizeof(short));
av_build_filter(c->filter_bank, factor, c->filter_length, PHASE_COUNT, 1<<FILTER_SHIFT, 1);
- c->filter_bank[c->filter_length*PHASE_COUNT + (c->filter_length-1) + 1]= (1<<FILTER_SHIFT)-1;
- c->filter_bank[c->filter_length*PHASE_COUNT + (c->filter_length-1) + 2]= 1;
+ c->filter_bank[c->filter_length*PHASE_COUNT + (c->filter_length-1)/2 + 1]= (1<<FILTER_SHIFT)-1;
+ c->filter_bank[c->filter_length*PHASE_COUNT + (c->filter_length-1)/2 + 2]= 1;
c->src_incr= out_rate;
c->ideal_dst_incr= c->dst_incr= in_rate * PHASE_COUNT;
@@ -170,7 +170,7 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
if(sample_index < 0){
for(i=0; i<c->filter_length; i++)
- val += src[ABS(sample_index + i)] * filter[i];
+ val += src[ABS(sample_index + i) % src_size] * filter[i];
}else if(sample_index + c->filter_length > src_size){
break;
}else{
@@ -199,6 +199,9 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
index++;
}
}
+ *consumed= FFMAX(index, 0) >> PHASE_SHIFT;
+ index= FFMIN(index, 0);
+
if(update_ctx){
if(c->compensation_distance){
c->compensation_distance -= dst_index;
@@ -206,9 +209,8 @@ int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int
c->dst_incr= c->ideal_dst_incr;
}
c->frac= frac;
- c->index=0;
+ c->index= index;
}
- *consumed= index >> PHASE_SHIFT;
#if 0
if(update_ctx && !c->compensation_distance){
#undef rand