Revision 88e2d588

View differences:

libavcodec/adpcm.c
706 706
    c->predictor = av_clip_int16(c->predictor);
707 707
    /* calculate new step and clamp it to range 511..32767 */
708 708
    new_step = (ct_adpcm_table[nibble & 7] * c->step) >> 8;
709
    c->step = new_step;
710
    if(c->step < 511)
711
        c->step = 511;
712
    if(c->step > 32767)
713
        c->step = 32767;
709
    c->step = av_clip(new_step, 511, 32767);
714 710

  
715 711
    return (short)c->predictor;
716 712
}
......
723 719
    delta = nibble & ((1<<(size-1))-1);
724 720
    diff = delta << (7 + c->step + shift);
725 721

  
726
    if (sign)
727
        c->predictor -= diff;
728
    else
729
        c->predictor += diff;
730

  
731 722
    /* clamp result */
732
    if (c->predictor > 16256)
733
        c->predictor = 16256;
734
    else if (c->predictor < -16384)
735
        c->predictor = -16384;
723
    c->predictor = av_clip(c->predictor + (sign ? -diff : diff), -16384,16256);
736 724

  
737 725
    /* calculate new step */
738 726
    if (delta >= (2*size - 3) && c->step < 3)

Also available in: Unified diff