Mercurial > libavcodec.hg
comparison resample2.c @ 2277:b88e05b9b445 libavcodec
dont just resample half of the data sometimes
| author | michael |
|---|---|
| date | Tue, 28 Sep 2004 21:11:09 +0000 |
| parents | 3f52c129d00f |
| children | e1caca4f3261 |
comparison
equal
deleted
inserted
replaced
| 2276:185f3b18ec1f | 2277:b88e05b9b445 |
|---|---|
| 158 int dst_index, i; | 158 int dst_index, i; |
| 159 int index= c->index; | 159 int index= c->index; |
| 160 int frac= c->frac; | 160 int frac= c->frac; |
| 161 int dst_incr_frac= c->dst_incr % c->src_incr; | 161 int dst_incr_frac= c->dst_incr % c->src_incr; |
| 162 int dst_incr= c->dst_incr / c->src_incr; | 162 int dst_incr= c->dst_incr / c->src_incr; |
| 163 | 163 int compensation_distance= c->compensation_distance; |
| 164 if(c->compensation_distance && c->compensation_distance < dst_size) | |
| 165 dst_size= c->compensation_distance; | |
| 166 | 164 |
| 167 for(dst_index=0; dst_index < dst_size; dst_index++){ | 165 for(dst_index=0; dst_index < dst_size; dst_index++){ |
| 168 short *filter= c->filter_bank + c->filter_length*(index & PHASE_MASK); | 166 short *filter= c->filter_bank + c->filter_length*(index & PHASE_MASK); |
| 169 int sample_index= index >> PHASE_SHIFT; | 167 int sample_index= index >> PHASE_SHIFT; |
| 170 int val=0; | 168 int val=0; |
| 171 | 169 |
| 172 if(sample_index < 0){ | 170 if(sample_index < 0){ |
| 173 for(i=0; i<c->filter_length; i++) | 171 for(i=0; i<c->filter_length; i++) |
| 174 val += src[ABS(sample_index + i) % src_size] * filter[i]; | 172 val += src[ABS(sample_index + i) % src_size] * filter[i]; |
| 175 }else if(sample_index + c->filter_length > src_size){ | 173 }else if(sample_index + c->filter_length > src_size){ |
| 176 break; | 174 break; |
| 197 index += dst_incr; | 195 index += dst_incr; |
| 198 if(frac >= c->src_incr){ | 196 if(frac >= c->src_incr){ |
| 199 frac -= c->src_incr; | 197 frac -= c->src_incr; |
| 200 index++; | 198 index++; |
| 201 } | 199 } |
| 200 | |
| 201 if(dst_index + 1 == compensation_distance){ | |
| 202 compensation_distance= 0; | |
| 203 dst_incr_frac= c->ideal_dst_incr % c->src_incr; | |
| 204 dst_incr= c->ideal_dst_incr / c->src_incr; | |
| 205 } | |
| 202 } | 206 } |
| 203 *consumed= FFMAX(index, 0) >> PHASE_SHIFT; | 207 *consumed= FFMAX(index, 0) >> PHASE_SHIFT; |
| 204 index= FFMIN(index, 0); | 208 index= FFMIN(index, 0); |
| 205 | 209 |
| 210 if(compensation_distance){ | |
| 211 compensation_distance -= dst_index; | |
| 212 assert(compensation_distance > 0); | |
| 213 } | |
| 206 if(update_ctx){ | 214 if(update_ctx){ |
| 207 if(c->compensation_distance){ | |
| 208 c->compensation_distance -= dst_index; | |
| 209 if(!c->compensation_distance) | |
| 210 c->dst_incr= c->ideal_dst_incr; | |
| 211 } | |
| 212 c->frac= frac; | 215 c->frac= frac; |
| 213 c->index= index; | 216 c->index= index; |
| 217 c->dst_incr= dst_incr_frac + c->src_incr*dst_incr; | |
| 218 c->compensation_distance= compensation_distance; | |
| 214 } | 219 } |
| 215 #if 0 | 220 #if 0 |
| 216 if(update_ctx && !c->compensation_distance){ | 221 if(update_ctx && !c->compensation_distance){ |
| 217 #undef rand | 222 #undef rand |
| 218 av_resample_compensate(c, rand() % (8000*2) - 8000, 8000*2); | 223 av_resample_compensate(c, rand() % (8000*2) - 8000, 8000*2); |
