Revision d3325d55 libavcodec/ac3enc.c

View differences:

libavcodec/ac3enc.c
575 575
 */
576 576
static void encode_exponents_blk_ch(uint8_t encoded_exp[AC3_MAX_COEFS],
577 577
                                    uint8_t exp[AC3_MAX_COEFS],
578
                                    int nb_exps, int exp_strategy)
578
                                    int nb_exps, int exp_strategy,
579
                                    uint8_t *num_exp_groups)
579 580
{
580 581
    int group_size, nb_groups, i, j, k, exp_min;
581 582
    uint8_t exp1[AC3_MAX_COEFS];
582 583

  
583 584
    group_size = exp_strategy + (exp_strategy == EXP_D45);
584
    nb_groups = ((nb_exps + (group_size * 3) - 4) / (3 * group_size)) * 3;
585
    *num_exp_groups = (nb_exps + (group_size * 3) - 4) / (3 * group_size);
586
    nb_groups = *num_exp_groups * 3;
585 587

  
586 588
    /* for each group, compute the minimum exponent */
587 589
    exp1[0] = exp[0]; /* DC exponent is handled separately */
......
628 630
static void encode_exponents(AC3EncodeContext *s,
629 631
                             uint8_t exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS],
630 632
                             uint8_t exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS],
633
                             uint8_t num_exp_groups[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS],
631 634
                             uint8_t encoded_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS])
632 635
{
633 636
    int blk, blk1, blk2, ch;
......
643 646
            }
644 647
            encode_exponents_blk_ch(encoded_exp[blk][ch],
645 648
                                                  exp[blk][ch], s->nb_coefs[ch],
646
                                                  exp_strategy[blk][ch]);
649
                                                  exp_strategy[blk][ch],
650
                                                  &num_exp_groups[blk][ch]);
647 651
            /* copy encoded exponents for reuse case */
648 652
            for (blk2 = blk+1; blk2 < blk1; blk2++) {
649 653
                memcpy(encoded_exp[blk2][ch], encoded_exp[blk][ch],
......
681 685
                continue;
682 686
            }
683 687
            group_size = exp_strategy[blk][ch] + (exp_strategy[blk][ch] == EXP_D45);
684
            num_exp_groups[blk][ch] = (s->nb_coefs[ch] + (group_size * 3) - 4) / (3 * group_size);
685 688
            bit_count += 4 + (num_exp_groups[blk][ch] * 7);
686 689
            p = encoded_exp[blk][ch];
687 690

  
......
735 738

  
736 739
    compute_exp_strategy(s, exp_strategy, exp);
737 740

  
738
    encode_exponents(s, exp, exp_strategy, encoded_exp);
741
    encode_exponents(s, exp, exp_strategy, num_exp_groups, encoded_exp);
739 742

  
740 743
    return group_exponents(s, encoded_exp, exp_strategy, num_exp_groups, grouped_exp);
741 744
}

Also available in: Unified diff