Revision 80e85288 libavcodec/resample2.c

View differences:

libavcodec/resample2.c
160 160
    int frac= c->frac;
161 161
    int dst_incr_frac= c->dst_incr % c->src_incr;
162 162
    int dst_incr=      c->dst_incr / c->src_incr;
163
    
164
    if(c->compensation_distance && c->compensation_distance < dst_size)
165
        dst_size= c->compensation_distance;
163
    int compensation_distance= c->compensation_distance;
166 164
    
167 165
    for(dst_index=0; dst_index < dst_size; dst_index++){
168 166
        short *filter= c->filter_bank + c->filter_length*(index & PHASE_MASK);
169 167
        int sample_index= index >> PHASE_SHIFT;
170 168
        int val=0;
171
        
169
                
172 170
        if(sample_index < 0){
173 171
            for(i=0; i<c->filter_length; i++)
174 172
                val += src[ABS(sample_index + i) % src_size] * filter[i];
......
199 197
            frac -= c->src_incr;
200 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 207
    *consumed= FFMAX(index, 0) >> PHASE_SHIFT;
204 208
    index= FFMIN(index, 0);
205 209

  
210
    if(compensation_distance){
211
        compensation_distance -= dst_index;
212
        assert(compensation_distance > 0);
213
    }
206 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 215
        c->frac= frac;
213 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 220
#if 0    
216 221
    if(update_ctx && !c->compensation_distance){

Also available in: Unified diff