Revision 834550ea

View differences:

libavcodec/ac3enc.c
610 610
                                    int nb_exps, int exp_strategy,
611 611
                                    uint8_t *num_exp_groups)
612 612
{
613
    int group_size, nb_groups, i, j, k, exp_min;
613
    int group_size, nb_groups, i, k;
614 614

  
615 615
    group_size = exp_strategy + (exp_strategy == EXP_D45);
616 616
    *num_exp_groups = (nb_exps + (group_size * 3) - 4) / (3 * group_size);
617 617
    nb_groups = *num_exp_groups * 3;
618 618

  
619 619
    /* for each group, compute the minimum exponent */
620
    if (exp_strategy > EXP_D15) {
621
    k = 1;
622
    for (i = 1; i <= nb_groups; i++) {
623
        exp_min = exp[k];
624
        assert(exp_min >= 0 && exp_min <= 24);
625
        for (j = 1; j < group_size; j++) {
626
            if (exp[k+j] < exp_min)
627
                exp_min = exp[k+j];
620
    switch(exp_strategy) {
621
    case EXP_D25:
622
        for (i = 1, k = 1; i <= nb_groups; i++) {
623
            uint8_t exp_min = exp[k];
624
            if (exp[k+1] < exp_min)
625
                exp_min = exp[k+1];
626
            exp[i] = exp_min;
627
            k += 2;
628 628
        }
629
        exp[i] = exp_min;
630
        k += group_size;
631
    }
629
        break;
630
    case EXP_D45:
631
        for (i = 1, k = 1; i <= nb_groups; i++) {
632
            uint8_t exp_min = exp[k];
633
            if (exp[k+1] < exp_min)
634
                exp_min = exp[k+1];
635
            if (exp[k+2] < exp_min)
636
                exp_min = exp[k+2];
637
            if (exp[k+3] < exp_min)
638
                exp_min = exp[k+3];
639
            exp[i] = exp_min;
640
            k += 4;
641
        }
642
        break;
632 643
    }
633 644

  
634 645
    /* constraint for DC exponent */
......
644 655
        exp[i] = FFMIN(exp[i], exp[i+1] + 2);
645 656

  
646 657
    /* now we have the exponent values the decoder will see */
647
    if (exp_strategy > EXP_D15) {
648
    k = nb_groups * group_size;
649
    for (i = nb_groups; i > 0; i--) {
650
        for (j = 0; j < group_size; j++)
651
            exp[k-j] = exp[i];
652
        k -= group_size;
653
    }
658
    switch (exp_strategy) {
659
    case EXP_D25:
660
        for (i = nb_groups, k = nb_groups * 2; i > 0; i--) {
661
            uint8_t exp1 = exp[i];
662
            exp[k--] = exp1;
663
            exp[k--] = exp1;
664
        }
665
        break;
666
    case EXP_D45:
667
        for (i = nb_groups, k = nb_groups * 4; i > 0; i--) {
668
            exp[k] = exp[k-1] = exp[k-2] = exp[k-3] = exp[i];
669
            k -= 4;
670
        }
671
        break;
654 672
    }
655 673
}
656 674

  

Also available in: Unified diff