Mercurial > libavcodec.hg
comparison resample2.c @ 4694:f5fa13dfd3c8 libavcodec
remove dithering of filter coefficients, improves precision by 1-2 bits and
improves subjective sound quality on artificial sample (udial.wav resampling
to 32khz)
| author | michael |
|---|---|
| date | Wed, 21 Mar 2007 22:02:52 +0000 |
| parents | a96d905dcbaa |
| children | 8155dd60b50b |
comparison
equal
deleted
inserted
replaced
| 4693:86a2dfcc5eef | 4694:f5fa13dfd3c8 |
|---|---|
| 91 if (factor > 1.0) | 91 if (factor > 1.0) |
| 92 factor = 1.0; | 92 factor = 1.0; |
| 93 | 93 |
| 94 for(ph=0;ph<phase_count;ph++) { | 94 for(ph=0;ph<phase_count;ph++) { |
| 95 double norm = 0; | 95 double norm = 0; |
| 96 double e= 0; | |
| 97 for(i=0;i<tap_count;i++) { | 96 for(i=0;i<tap_count;i++) { |
| 98 x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor; | 97 x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor; |
| 99 if (x == 0) y = 1.0; | 98 if (x == 0) y = 1.0; |
| 100 else y = sin(x) / x; | 99 else y = sin(x) / x; |
| 101 switch(type){ | 100 switch(type){ |
| 119 norm += y; | 118 norm += y; |
| 120 } | 119 } |
| 121 | 120 |
| 122 /* normalize so that an uniform color remains the same */ | 121 /* normalize so that an uniform color remains the same */ |
| 123 for(i=0;i<tap_count;i++) { | 122 for(i=0;i<tap_count;i++) { |
| 124 v = av_clip(lrintf(tab[i] * scale / norm + e), FELEM_MIN, FELEM_MAX); | 123 v = av_clip(lrintf(tab[i] * scale / norm), FELEM_MIN, FELEM_MAX); |
| 125 filter[ph * tap_count + i] = v; | 124 filter[ph * tap_count + i] = v; |
| 126 e += tab[i] * scale / norm - v; | |
| 127 } | 125 } |
| 128 } | 126 } |
| 129 } | 127 } |
| 130 | 128 |
| 131 /** | 129 /** |
