| @@ -658,7 +658,9 @@ static int decode_spectrum_and_dequant_ac(AACDecContext *s, float coef[1024], · 657 unmodified lines |
| 658 | 658 | |
| 659 | 659 | static int decode_usac_stereo_cplx(AACDecContext *ac, AACUsacStereo *us, |
| 660 | 660 | ChannelElement *cpe, GetBitContext *gb, |
| 661 | | − int num_window_groups, int indep_flag) |
| 661 | + int num_window_groups, |
| 662 | + int prev_num_window_groups, |
| 663 | + int indep_flag) |
| 662 | 664 | { |
| 663 | 665 | int delta_code_time; |
| 664 | 666 | IndividualChannelStream *ics = &cpe->ch[0].ics; |
| @@ -696,15 +698,18 @@ static int decode_usac_stereo_cplx(AACDecContext *ac, AACUsacStereo *us, · 31 unmodified lines |
| 696 | 698 | float last_alpha_q_im = 0; |
| 697 | 699 | if (delta_code_time) { |
| 698 | 700 | if (g) { |
| 699 | | − last_alpha_q_re = us->prev_alpha_q_re[(g - 1)*cpe->max_sfb_ste + sfb]; |
| 700 | | − last_alpha_q_im = us->prev_alpha_q_im[(g - 1)*cpe->max_sfb_ste + sfb]; |
| 701 | | − } else if ((ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) && |
| 702 | | − ics->window_sequence[1] == EIGHT_SHORT_SEQUENCE || |
| 703 | | − ics->window_sequence[1] == EIGHT_SHORT_SEQUENCE) { |
| 701 | + /* Transient, after the first group - use the current frame, |
| 702 | + * previous window, alpha values. */ |
| 703 | + last_alpha_q_re = us->alpha_q_re[(g - 1)*cpe->max_sfb_ste + sfb]; |
| 704 | + last_alpha_q_im = us->alpha_q_im[(g - 1)*cpe->max_sfb_ste + sfb]; |
| 705 | + } else if (!g && |
| 706 | + (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) && |
| 707 | + (ics->window_sequence[1] == EIGHT_SHORT_SEQUENCE)) { |
| 704 | 708 | /* The spec doesn't explicitly mention this, but it doesn't make |
| 705 | 709 | * any other sense otherwise! */ |
| 706 | | − last_alpha_q_re = us->prev_alpha_q_re[7*cpe->max_sfb_ste + sfb]; |
| 707 | | − last_alpha_q_im = us->prev_alpha_q_im[7*cpe->max_sfb_ste + sfb]; |
| 710 | + const int wg = prev_num_window_groups - 1; |
| 711 | + last_alpha_q_re = us->prev_alpha_q_re[wg*cpe->max_sfb_ste + sfb]; |
| 712 | + last_alpha_q_im = us->prev_alpha_q_im[wg*cpe->max_sfb_ste + sfb]; |
| 708 | 713 | } else { |
| 709 | 714 | last_alpha_q_re = us->prev_alpha_q_re[g*cpe->max_sfb_ste + sfb]; |
| 710 | 715 | last_alpha_q_im = us->prev_alpha_q_im[g*cpe->max_sfb_ste + sfb]; |
| @@ -749,6 +754,7 @@ static int setup_sce(AACDecContext *ac, SingleChannelElement *sce, · 38 unmodified lines |
| 749 | 754 | IndividualChannelStream *ics = &sce->ics; |
| 750 | 755 | |
| 751 | 756 | /* Setup window parameters */ |
| 757 | + ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1); |
| 752 | 758 | if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { |
| 753 | 759 | if (usac->core_frame_len == 768) { |
| 754 | 760 | ics->swb_offset = ff_swb_offset_96[usac->rate_idx]; |
| @@ -869,7 +875,9 @@ static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, · 114 unmodified lines |
| 869 | 875 | memset(cpe->ms_mask, 0xFF, sizeof(cpe->ms_mask)); |
| 870 | 876 | } else if ((us->ms_mask_mode == 3) && !ec->stereo_config_index) { |
| 871 | 877 | ret = decode_usac_stereo_cplx(ac, us, cpe, gb, |
| 872 | | − ics1->num_window_groups, indep_flag); |
| 878 | + ics1->num_window_groups, |
| 879 | + ics1->prev_num_window_groups, |
| 880 | + indep_flag); |
| 873 | 881 | if (ret < 0) |
| 874 | 882 | return ret; |
| 875 | 883 | } |