Revision f66e4f5f libavcodec/adpcm.c
libavcodec/adpcm.c | ||
---|---|---|
209 | 209 |
int nibble = FFMIN(7, abs(delta)*4/step_table[c->step_index]) + (delta<0)*8; |
210 | 210 |
c->prev_sample = c->prev_sample + ((step_table[c->step_index] * yamaha_difflookup[nibble]) / 8); |
211 | 211 |
CLAMP_TO_SHORT(c->prev_sample); |
212 |
c->step_index = clip(c->step_index + index_table[nibble], 0, 88); |
|
212 |
c->step_index = av_clip(c->step_index + index_table[nibble], 0, 88);
|
|
213 | 213 |
return nibble; |
214 | 214 |
} |
215 | 215 |
|
... | ... | |
224 | 224 |
else bias=-c->idelta/2; |
225 | 225 |
|
226 | 226 |
nibble= (nibble + bias) / c->idelta; |
227 |
nibble= clip(nibble, -8, 7)&0x0F; |
|
227 |
nibble= av_clip(nibble, -8, 7)&0x0F;
|
|
228 | 228 |
|
229 | 229 |
predictor += (signed)((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta; |
230 | 230 |
CLAMP_TO_SHORT(predictor); |
... | ... | |
254 | 254 |
c->predictor = c->predictor + ((c->step * yamaha_difflookup[nibble]) / 8); |
255 | 255 |
CLAMP_TO_SHORT(c->predictor); |
256 | 256 |
c->step = (c->step * yamaha_indexscale[nibble]) >> 8; |
257 |
c->step = clip(c->step, 127, 24567); |
|
257 |
c->step = av_clip(c->step, 127, 24567);
|
|
258 | 258 |
|
259 | 259 |
return nibble; |
260 | 260 |
} |
... | ... | |
324 | 324 |
if(version == CODEC_ID_ADPCM_MS) { |
325 | 325 |
const int predictor = ((nodes[j]->sample1 * c->coeff1) + (nodes[j]->sample2 * c->coeff2)) / 256; |
326 | 326 |
const int div = (sample - predictor) / step; |
327 |
const int nmin = clip(div-range, -8, 6); |
|
328 |
const int nmax = clip(div+range, -7, 7); |
|
327 |
const int nmin = av_clip(div-range, -8, 6);
|
|
328 |
const int nmax = av_clip(div+range, -7, 7);
|
|
329 | 329 |
for(nidx=nmin; nidx<=nmax; nidx++) { |
330 | 330 |
const int nibble = nidx & 0xf; |
331 | 331 |
int dec_sample = predictor + nidx * step; |
... | ... | |
372 | 372 |
#define LOOP_NODES(NAME, STEP_TABLE, STEP_INDEX)\ |
373 | 373 |
const int predictor = nodes[j]->sample1;\ |
374 | 374 |
const int div = (sample - predictor) * 4 / STEP_TABLE;\ |
375 |
int nmin = clip(div-range, -7, 6);\ |
|
376 |
int nmax = clip(div+range, -6, 7);\ |
|
375 |
int nmin = av_clip(div-range, -7, 6);\
|
|
376 |
int nmax = av_clip(div+range, -6, 7);\
|
|
377 | 377 |
if(nmin<=0) nmin--; /* distinguish -0 from +0 */\ |
378 | 378 |
if(nmax<0) nmax--;\ |
379 | 379 |
for(nidx=nmin; nidx<=nmax; nidx++) {\ |
... | ... | |
381 | 381 |
int dec_sample = predictor + (STEP_TABLE * yamaha_difflookup[nibble]) / 8;\ |
382 | 382 |
STORE_NODE(NAME, STEP_INDEX);\ |
383 | 383 |
} |
384 |
LOOP_NODES(ima, step_table[step], clip(step + index_table[nibble], 0, 88)); |
|
384 |
LOOP_NODES(ima, step_table[step], av_clip(step + index_table[nibble], 0, 88));
|
|
385 | 385 |
} else { //CODEC_ID_ADPCM_YAMAHA |
386 |
LOOP_NODES(yamaha, step, clip((step * yamaha_indexscale[nibble]) >> 8, 127, 24567)); |
|
386 |
LOOP_NODES(yamaha, step, av_clip((step * yamaha_indexscale[nibble]) >> 8, 127, 24567));
|
|
387 | 387 |
#undef LOOP_NODES |
388 | 388 |
#undef STORE_NODE |
389 | 389 |
} |
... | ... | |
734 | 734 |
c->predictor += (c->step * yamaha_difflookup[nibble]) / 8; |
735 | 735 |
CLAMP_TO_SHORT(c->predictor); |
736 | 736 |
c->step = (c->step * yamaha_indexscale[nibble]) >> 8; |
737 |
c->step = clip(c->step, 127, 24567); |
|
737 |
c->step = av_clip(c->step, 127, 24567);
|
|
738 | 738 |
return c->predictor; |
739 | 739 |
} |
740 | 740 |
|
... | ... | |
974 | 974 |
n = buf_size - 7 * avctx->channels; |
975 | 975 |
if (n < 0) |
976 | 976 |
return -1; |
977 |
block_predictor[0] = clip(*src++, 0, 7); |
|
977 |
block_predictor[0] = av_clip(*src++, 0, 7);
|
|
978 | 978 |
block_predictor[1] = 0; |
979 | 979 |
if (st) |
980 |
block_predictor[1] = clip(*src++, 0, 7); |
|
980 |
block_predictor[1] = av_clip(*src++, 0, 7);
|
|
981 | 981 |
c->status[0].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); |
982 | 982 |
src+=2; |
983 | 983 |
if (st){ |
... | ... | |
1299 | 1299 |
|
1300 | 1300 |
c->status[i].step_index += table[delta & (~signmask)]; |
1301 | 1301 |
|
1302 |
c->status[i].step_index = clip(c->status[i].step_index, 0, 88); |
|
1303 |
c->status[i].predictor = clip(c->status[i].predictor, -32768, 32767); |
|
1302 |
c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
|
|
1303 |
c->status[i].predictor = av_clip(c->status[i].predictor, -32768, 32767);
|
|
1304 | 1304 |
|
1305 | 1305 |
*samples++ = c->status[i].predictor; |
1306 | 1306 |
} |
Also available in: Unified diff