Revision 793bbf95

View differences:

libavcodec/ac3enc.c
745 745

  
746 746

  
747 747
/**
748
 * Initialize bit allocation.
749
 * Set default parameter codes and calculate parameter values.
750
 */
751
static void bit_alloc_init(AC3EncodeContext *s)
752
{
753
    int ch;
754

  
755
    /* init default parameters */
756
    s->slow_decay_code = 2;
757
    s->fast_decay_code = 1;
758
    s->slow_gain_code  = 1;
759
    s->db_per_bit_code = 2;
760
    s->floor_code      = 4;
761
    for (ch = 0; ch < s->channels; ch++)
762
        s->fast_gain_code[ch] = 4;
763

  
764
    /* initial snr offset */
765
    s->coarse_snr_offset = 40;
766

  
767
    /* compute real values */
768
    /* currently none of these values change during encoding, so we can just
769
       set them once at initialization */
770
    s->bit_alloc.slow_decay = ff_ac3_slow_decay_tab[s->slow_decay_code] >> s->bit_alloc.sr_shift;
771
    s->bit_alloc.fast_decay = ff_ac3_fast_decay_tab[s->fast_decay_code] >> s->bit_alloc.sr_shift;
772
    s->bit_alloc.slow_gain  = ff_ac3_slow_gain_tab[s->slow_gain_code];
773
    s->bit_alloc.db_per_bit = ff_ac3_db_per_bit_tab[s->db_per_bit_code];
774
    s->bit_alloc.floor      = ff_ac3_floor_tab[s->floor_code];
775
}
776

  
777

  
778
/**
748 779
 * Count the bits used to encode the frame, minus exponents and mantissas.
749 780
 * @return bit count
750 781
 */
......
936 967
    int16_t psd[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];
937 968
    int16_t mask[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS];
938 969

  
939
    /* init default parameters */
940
    s->slow_decay_code = 2;
941
    s->fast_decay_code = 1;
942
    s->slow_gain_code  = 1;
943
    s->db_per_bit_code = 2;
944
    s->floor_code      = 4;
945
    for (ch = 0; ch < s->channels; ch++)
946
        s->fast_gain_code[ch] = 4;
947

  
948
    /* compute real values */
949
    s->bit_alloc.slow_decay = ff_ac3_slow_decay_tab[s->slow_decay_code] >> s->bit_alloc.sr_shift;
950
    s->bit_alloc.fast_decay = ff_ac3_fast_decay_tab[s->fast_decay_code] >> s->bit_alloc.sr_shift;
951
    s->bit_alloc.slow_gain  = ff_ac3_slow_gain_tab[s->slow_gain_code];
952
    s->bit_alloc.db_per_bit = ff_ac3_db_per_bit_tab[s->db_per_bit_code];
953
    s->bit_alloc.floor      = ff_ac3_floor_tab[s->floor_code];
954

  
955 970
    /* count frame bits other than exponents and mantissas */
956 971
    frame_bits += count_frame_bits(s, exp_strategy);
957 972

  
......
1615 1630

  
1616 1631
    set_bandwidth(s, avctx->cutoff);
1617 1632

  
1618
    /* initial snr offset */
1619
    s->coarse_snr_offset = 40;
1633
    bit_alloc_init(s);
1620 1634

  
1621 1635
    mdct_init(9);
1622 1636

  

Also available in: Unified diff