Revision 19b9c7cc

View differences:

libavcodec/flacenc.c
608 608
                             double *autoc)
609 609
{
610 610
    int i, j;
611
    double tmp[len + lag];
611
    double tmp[len + lag + 1];
612 612
    double *data1= tmp + lag;
613 613

  
614 614
    apply_welch_window(data, len, data1);
615 615

  
616 616
    for(j=0; j<lag; j++)
617 617
        data1[j-lag]= 0.0;
618
    data1[len] = 0.0;
618 619

  
619 620
    for(j=0; j<lag; j+=2){
620 621
        double sum0 = 1.0, sum1 = 1.0;
......
628 629

  
629 630
    if(j==lag){
630 631
        double sum = 1.0;
631
        for(i=0; i<len; i++)
632
            sum += data1[i] * data1[i-j];
632
        for(i=0; i<len; i+=2){
633
            sum += data1[i  ] * data1[i-j  ]
634
                 + data1[i+1] * data1[i-j+1];
635
        }
633 636
        autoc[j] = sum;
634 637
    }
635 638
}
......
757 760
    assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER);
758 761

  
759 762
    if(use_lpc == 1){
760
        compute_autocorr(samples, blocksize, max_order+1, autoc);
763
        compute_autocorr(samples, blocksize, max_order, autoc);
761 764

  
762 765
        compute_lpc_coefs(autoc, max_order, lpc, ref);
763 766
    }else{

Also available in: Unified diff