Revision 134b8cbb

View differences:

libavcodec/aacsbr.c
618 618
                         GetBitContext *gb, SBRData *ch_data)
619 619
{
620 620
    int i;
621
    unsigned bs_pointer;
621
    unsigned bs_pointer = 0;
622 622
    // frameLengthFlag ? 15 : 16; 960 sample length frames unsupported; this value is numTimeSlots
623 623
    int abs_bord_trail = 16;
624 624
    int num_rel_lead, num_rel_trail;
......
630 630

  
631 631
    switch (ch_data->bs_frame_class = get_bits(gb, 2)) {
632 632
    case FIXFIX:
633
        ch_data->bs_num_env    = 1 << get_bits(gb, 2);
634
        num_rel_lead           = ch_data->bs_num_env - 1;
633
        ch_data->bs_num_env                 = 1 << get_bits(gb, 2);
634
        num_rel_lead                        = ch_data->bs_num_env - 1;
635 635
        if (ch_data->bs_num_env == 1)
636 636
            ch_data->bs_amp_res = 0;
637 637

  
......
650 650
        for (i = 0; i < num_rel_lead; i++)
651 651
            ch_data->t_env[i + 1] = ch_data->t_env[i] + abs_bord_trail;
652 652

  
653
        bs_pointer = 0;
654

  
655 653
        ch_data->bs_freq_res[1] = get_bits1(gb);
656 654
        for (i = 1; i < ch_data->bs_num_env; i++)
657 655
            ch_data->bs_freq_res[i + 1] = ch_data->bs_freq_res[1];
658 656
        break;
659 657
    case FIXVAR:
660
        abs_bord_trail         += get_bits(gb, 2);
661
        num_rel_trail           = get_bits(gb, 2);
662
        num_rel_lead            = 0;
663
        ch_data->bs_num_env     = num_rel_trail + 1;
664
        ch_data->t_env[0]       = 0;
658
        abs_bord_trail                     += get_bits(gb, 2);
659
        num_rel_trail                       = get_bits(gb, 2);
660
        ch_data->bs_num_env                 = num_rel_trail + 1;
661
        ch_data->t_env[0]                   = 0;
665 662
        ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail;
666 663

  
667 664
        for (i = 0; i < num_rel_trail; i++)
668
            ch_data->t_env[ch_data->bs_num_env - 1 - i] = ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2;
665
            ch_data->t_env[ch_data->bs_num_env - 1 - i] =
666
                ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2;
669 667

  
670 668
        bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]);
671 669

  
......
673 671
            ch_data->bs_freq_res[ch_data->bs_num_env - i] = get_bits1(gb);
674 672
        break;
675 673
    case VARFIX:
676
        ch_data->t_env[0]       = get_bits(gb, 2);
677
        num_rel_lead            = get_bits(gb, 2);
678
        ch_data->bs_num_env     = num_rel_lead + 1;
674
        ch_data->t_env[0]                   = get_bits(gb, 2);
675
        num_rel_lead                        = get_bits(gb, 2);
676
        ch_data->bs_num_env                 = num_rel_lead + 1;
679 677
        ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail;
680 678

  
681 679
        for (i = 0; i < num_rel_lead; i++)
......
686 684
        get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env);
687 685
        break;
688 686
    case VARVAR:
689
        ch_data->t_env[0]       = get_bits(gb, 2);
690
        abs_bord_trail         += get_bits(gb, 2);
691
        num_rel_lead            = get_bits(gb, 2);
692
        num_rel_trail           = get_bits(gb, 2);
693
        ch_data->bs_num_env     = num_rel_lead + num_rel_trail + 1;
687
        ch_data->t_env[0]                   = get_bits(gb, 2);
688
        abs_bord_trail                     += get_bits(gb, 2);
689
        num_rel_lead                        = get_bits(gb, 2);
690
        num_rel_trail                       = get_bits(gb, 2);
691
        ch_data->bs_num_env                 = num_rel_lead + num_rel_trail + 1;
694 692
        ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail;
695 693

  
696 694
        if (ch_data->bs_num_env > 5) {
......
703 701
        for (i = 0; i < num_rel_lead; i++)
704 702
            ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2;
705 703
        for (i = 0; i < num_rel_trail; i++)
706
            ch_data->t_env[ch_data->bs_num_env - 1 - i] = ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2;
704
            ch_data->t_env[ch_data->bs_num_env - 1 - i] =
705
                ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2;
707 706

  
708 707
        bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]);
709 708

  
......
720 719

  
721 720
    ch_data->bs_num_noise = (ch_data->bs_num_env > 1) + 1;
722 721

  
723
    ch_data->t_q[0] = ch_data->t_env[0];
722
    ch_data->t_q[0]                     = ch_data->t_env[0];
724 723
    ch_data->t_q[ch_data->bs_num_noise] = ch_data->t_env[ch_data->bs_num_env];
725 724
    if (ch_data->bs_num_noise > 1) {
726 725
        unsigned int idx;
......
751 750

  
752 751
static void copy_sbr_grid(SBRData *dst, const SBRData *src) {
753 752
    //These variables are saved from the previous frame rather than copied
754
    dst->bs_freq_res[0] = dst->bs_freq_res[dst->bs_num_env];
753
    dst->bs_freq_res[0]    = dst->bs_freq_res[dst->bs_num_env];
755 754
    dst->t_env_num_env_old = dst->t_env[dst->bs_num_env];
756
    dst->e_a[0]         = -(dst->e_a[1] != dst->bs_num_env);
755
    dst->e_a[0]            = -(dst->e_a[1] != dst->bs_num_env);
757 756

  
758 757
    //These variables are read from the bitstream and therefore copied
759 758
    memcpy(dst->bs_freq_res+1, src->bs_freq_res+1, sizeof(dst->bs_freq_res)-sizeof(*dst->bs_freq_res));
760 759
    memcpy(dst->t_env,         src->t_env,         sizeof(dst->t_env));
761 760
    memcpy(dst->t_q,           src->t_q,           sizeof(dst->t_q));
762
    dst->bs_num_env     = src->bs_num_env;
763
    dst->bs_amp_res     = src->bs_amp_res;
764
    dst->bs_num_noise   = src->bs_num_noise;
765
    dst->bs_frame_class = src->bs_frame_class;
766
    dst->e_a[1]         = src->e_a[1];
761
    dst->bs_num_env        = src->bs_num_env;
762
    dst->bs_amp_res        = src->bs_amp_res;
763
    dst->bs_num_noise      = src->bs_num_noise;
764
    dst->bs_frame_class    = src->bs_frame_class;
765
    dst->e_a[1]            = src->e_a[1];
767 766
}
768 767

  
769 768
/// Read how the envelope and noise floor data is delta coded

Also available in: Unified diff