Revision e4a50e6d libavcodec/adpcm.c

View differences:

libavcodec/adpcm.c
692 692

  
693 693
static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
694 694
{
695
    int predictor;
696 695
    int sign, delta, diff;
697 696
    int new_step;
698 697

  
......
702 701
     * the reference ADPCM implementation since modern CPUs can do the mults
703 702
     * quickly enough */
704 703
    diff = ((2 * delta + 1) * c->step) >> 3;
705
    predictor = c->predictor;
706 704
    /* predictor update is not so trivial: predictor is multiplied on 254/256 before updating */
707
    if(sign)
708
        predictor = ((predictor * 254) >> 8) - diff;
709
    else
710
            predictor = ((predictor * 254) >> 8) + diff;
705
    c->predictor = ((c->predictor * 254) >> 8) + (sign ? -diff : diff);
706
    c->predictor = av_clip_int16(c->predictor);
711 707
    /* calculate new step and clamp it to range 511..32767 */
712 708
    new_step = (ct_adpcm_table[nibble & 7] * c->step) >> 8;
713 709
    c->step = new_step;
......
716 712
    if(c->step > 32767)
717 713
        c->step = 32767;
718 714

  
719
    c->predictor = av_clip_int16(predictor);
720 715
    return (short)c->predictor;
721 716
}
722 717

  

Also available in: Unified diff