History

aacdec_usac: fix stereo alpha values for transients

Typo. Also added comments and fixed the branch underneath.

Lynne committed 2 years ago

Commit c2d459c1 parent 72235233 files · +19 −9Browse files

Unified · Split

3 files
  1. libavcodec/aac/aacdec.c +1 −0
  2. libavcodec/aac/aacdec.h +1 −0
  3. libavcodec/aac/aacdec_usac.c +17 −9
libavcodec/aac/aacdec.c+1−0
@@ -1334,6 +1334,7 @@ static int decode_ics_info(AACDecContext *ac, IndividualChannelStream *ics, · 1333 unmodified lines
13341334 ics->use_kb_window[1] = ics->use_kb_window[0];
13351335 ics->use_kb_window[0] = get_bits1(gb);
13361336 }
1337+ ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1);
13371338 ics->num_window_groups = 1;
13381339 ics->group_len[0] = 1;
13391340 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
libavcodec/aac/aacdec.h+1−0
@@ -164,6 +164,7 @@ typedef struct IndividualChannelStream { · 163 unmodified lines
164164 enum WindowSequence window_sequence[2];
165165 uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sine window.
166166 int num_window_groups;
167+ int prev_num_window_groups; ///< Previous frame's number of window groups
167168 uint8_t group_len[8];
168169 LongTermPrediction ltp;
169170 const uint16_t *swb_offset; ///< table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular window
libavcodec/aac/aacdec_usac.c+17−9
@@ -658,7 +658,9 @@ static int decode_spectrum_and_dequant_ac(AACDecContext *s, float coef[1024], · 657 unmodified lines
658658
659659 static int decode_usac_stereo_cplx(AACDecContext *ac, AACUsacStereo *us,
660660 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)
662664 {
663665 int delta_code_time;
664666 IndividualChannelStream *ics = &cpe->ch[0].ics;
@@ -696,15 +698,18 @@ static int decode_usac_stereo_cplx(AACDecContext *ac, AACUsacStereo *us, · 31 unmodified lines
696698 float last_alpha_q_im = 0;
697699 if (delta_code_time) {
698700 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)) {
704708 /* The spec doesn't explicitly mention this, but it doesn't make
705709 * 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];
708713 } else {
709714 last_alpha_q_re = us->prev_alpha_q_re[g*cpe->max_sfb_ste + sfb];
710715 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
749754 IndividualChannelStream *ics = &sce->ics;
750755
751756 /* Setup window parameters */
757+ ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1);
752758 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
753759 if (usac->core_frame_len == 768) {
754760 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
869875 memset(cpe->ms_mask, 0xFF, sizeof(cpe->ms_mask));
870876 } else if ((us->ms_mask_mode == 3) && !ec->stereo_config_index) {
871877 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);
873881 if (ret < 0)
874882 return ret;
875883 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t