Mercurial > libavcodec.hg
comparison resample2.c @ 4702:a8794f26ea98 libavcodec
AUDIOPHILE_KIDDY_MODE
author | michael |
---|---|
date | Thu, 22 Mar 2007 03:16:02 +0000 |
parents | 5fa551fb7640 |
children | 07f7ca450695 |
comparison
equal
deleted
inserted
replaced
4701:5fa551fb7640 | 4702:a8794f26ea98 |
---|---|
33 #ifndef CONFIG_RESAMPLE_HP | 33 #ifndef CONFIG_RESAMPLE_HP |
34 #define FILTER_SHIFT 15 | 34 #define FILTER_SHIFT 15 |
35 | 35 |
36 #define FELEM int16_t | 36 #define FELEM int16_t |
37 #define FELEM2 int32_t | 37 #define FELEM2 int32_t |
38 #define FELEML int64_t | |
38 #define FELEM_MAX INT16_MAX | 39 #define FELEM_MAX INT16_MAX |
39 #define FELEM_MIN INT16_MIN | 40 #define FELEM_MIN INT16_MIN |
40 #define WINDOW_TYPE 9 | 41 #define WINDOW_TYPE 9 |
41 #else | 42 #elif !defined(CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE) |
42 #define FILTER_SHIFT 30 | 43 #define FILTER_SHIFT 30 |
43 | 44 |
44 #define FELEM int32_t | 45 #define FELEM int32_t |
45 #define FELEM2 int64_t | 46 #define FELEM2 int64_t |
47 #define FELEML int64_t | |
46 #define FELEM_MAX INT32_MAX | 48 #define FELEM_MAX INT32_MAX |
47 #define FELEM_MIN INT32_MIN | 49 #define FELEM_MIN INT32_MIN |
48 #define WINDOW_TYPE 12 | 50 #define WINDOW_TYPE 12 |
51 #else | |
52 #define FILTER_SHIFT 0 | |
53 | |
54 #define FELEM long double | |
55 #define FELEM2 long double | |
56 #define FELEML long double | |
57 #define WINDOW_TYPE 24 | |
49 #endif | 58 #endif |
50 | 59 |
51 | 60 |
52 typedef struct AVResampleContext{ | 61 typedef struct AVResampleContext{ |
53 FELEM *filter_bank; | 62 FELEM *filter_bank; |
121 norm += y; | 130 norm += y; |
122 } | 131 } |
123 | 132 |
124 /* normalize so that an uniform color remains the same */ | 133 /* normalize so that an uniform color remains the same */ |
125 for(i=0;i<tap_count;i++) { | 134 for(i=0;i<tap_count;i++) { |
126 v = av_clip(lrintf(tab[i] * scale / norm), FELEM_MIN, FELEM_MAX); | 135 #ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE |
127 filter[ph * tap_count + i] = v; | 136 filter[ph * tap_count + i] = tab[i] / norm; |
137 #else | |
138 filter[ph * tap_count + i] = av_clip(lrintf(tab[i] * scale / norm), FELEM_MIN, FELEM_MAX); | |
139 #endif | |
128 } | 140 } |
129 } | 141 } |
130 #if 0 | 142 #if 0 |
131 { | 143 { |
132 #define LEN 1024 | 144 #define LEN 1024 |
154 maxff= FFMAX(maxff, ff); | 166 maxff= FFMAX(maxff, ff); |
155 minff= FFMIN(minff, ff); | 167 minff= FFMIN(minff, ff); |
156 maxsf= FFMAX(maxsf, sf); | 168 maxsf= FFMAX(maxsf, sf); |
157 minsf= FFMIN(minsf, sf); | 169 minsf= FFMIN(minsf, sf); |
158 if(i%11==0){ | 170 if(i%11==0){ |
159 av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%f-%f sf:%f-%f\n", i, ss, maxff, minff, maxsf, minsf); | 171 av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf); |
160 minff=minsf= 2; | 172 minff=minsf= 2; |
161 maxff=maxsf= -2; | 173 maxff=maxsf= -2; |
162 } | 174 } |
163 } | 175 } |
164 } | 176 } |
257 break; | 269 break; |
258 }else if(c->linear){ | 270 }else if(c->linear){ |
259 int64_t v=0; | 271 int64_t v=0; |
260 int sub_phase= (frac<<8) / c->src_incr; | 272 int sub_phase= (frac<<8) / c->src_incr; |
261 for(i=0; i<c->filter_length; i++){ | 273 for(i=0; i<c->filter_length; i++){ |
262 int64_t coeff= filter[i]*(256 - sub_phase) + filter[i + c->filter_length]*sub_phase; | 274 FELEML coeff= filter[i]*(256 - sub_phase) + filter[i + c->filter_length]*sub_phase; |
263 v += src[sample_index + i] * coeff; | 275 v += src[sample_index + i] * coeff; |
264 } | 276 } |
265 val= v>>8; | 277 val= v>>8; |
266 }else{ | 278 }else{ |
267 for(i=0; i<c->filter_length; i++){ | 279 for(i=0; i<c->filter_length; i++){ |
268 val += src[sample_index + i] * (FELEM2)filter[i]; | 280 val += src[sample_index + i] * (FELEM2)filter[i]; |
269 } | 281 } |
270 } | 282 } |
271 | 283 |
284 #ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE | |
285 dst[dst_index] = av_clip(lrintf(val), -32768, 32767); | |
286 #else | |
272 val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT; | 287 val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT; |
273 dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val; | 288 dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val; |
289 #endif | |
274 | 290 |
275 frac += dst_incr_frac; | 291 frac += dst_incr_frac; |
276 index += dst_incr; | 292 index += dst_incr; |
277 if(frac >= c->src_incr){ | 293 if(frac >= c->src_incr){ |
278 frac -= c->src_incr; | 294 frac -= c->src_incr; |