Mercurial > libavcodec.hg
comparison resample2.c @ 2405:21c5ef8a4ff7 libavcodec
faster and slightly less accurate nearest neighbor resampler
| author | michael |
|---|---|
| date | Fri, 31 Dec 2004 17:37:23 +0000 |
| parents | 6d53608cf2cf |
| children | 1ee03f2a6cd5 |
comparison
equal
deleted
inserted
replaced
| 2404:2e90350ff8bc | 2405:21c5ef8a4ff7 |
|---|---|
| 191 int index= c->index; | 191 int index= c->index; |
| 192 int frac= c->frac; | 192 int frac= c->frac; |
| 193 int dst_incr_frac= c->dst_incr % c->src_incr; | 193 int dst_incr_frac= c->dst_incr % c->src_incr; |
| 194 int dst_incr= c->dst_incr / c->src_incr; | 194 int dst_incr= c->dst_incr / c->src_incr; |
| 195 int compensation_distance= c->compensation_distance; | 195 int compensation_distance= c->compensation_distance; |
| 196 | 196 |
| 197 if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){ | 197 if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){ |
| 198 assert(index >= 0); | 198 int64_t index2= ((int64_t)index)<<32; |
| 199 int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr; | |
| 200 dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr); | |
| 201 | |
| 199 for(dst_index=0; dst_index < dst_size; dst_index++){ | 202 for(dst_index=0; dst_index < dst_size; dst_index++){ |
| 200 if(index < src_size) | 203 dst[dst_index] = src[index2>>32]; |
| 201 dst[dst_index] = src[index]; | 204 index2 += incr; |
| 202 else | 205 } |
| 203 break; | 206 frac += dst_index * dst_incr_frac; |
| 204 | 207 index += dst_index * dst_incr; |
| 205 frac += dst_incr_frac; | 208 index += frac / c->src_incr; |
| 206 index += dst_incr; | 209 frac %= c->src_incr; |
| 207 if(frac >= c->src_incr){ | |
| 208 frac -= c->src_incr; | |
| 209 index++; | |
| 210 } | |
| 211 } | |
| 212 }else{ | 210 }else{ |
| 213 for(dst_index=0; dst_index < dst_size; dst_index++){ | 211 for(dst_index=0; dst_index < dst_size; dst_index++){ |
| 214 FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); | 212 FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); |
| 215 int sample_index= index >> c->phase_shift; | 213 int sample_index= index >> c->phase_shift; |
| 216 FELEM2 val=0; | 214 FELEM2 val=0; |
