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
1334 ics->use_kb_window[1] = ics->use_kb_window[0];1334 ics->use_kb_window[1] = ics->use_kb_window[0];
1335 ics->use_kb_window[0] = get_bits1(gb);1335 ics->use_kb_window[0] = get_bits1(gb);
1336 }1336 }
1337 ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1);
1337 ics->num_window_groups = 1;1338 ics->num_window_groups = 1;
1338 ics->group_len[0] = 1;1339 ics->group_len[0] = 1;
1339 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {1340 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
libavcodec/aac/aacdec.h+1−0
@@ -164,6 +164,7 @@ typedef struct IndividualChannelStream { · 163 unmodified lines
164 enum WindowSequence window_sequence[2];164 enum WindowSequence window_sequence[2];
165 uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sine window.165 uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sine window.
166 int num_window_groups;166 int num_window_groups;
167 int prev_num_window_groups; ///< Previous frame's number of window groups
167 uint8_t group_len[8];168 uint8_t group_len[8];
168 LongTermPrediction ltp;169 LongTermPrediction ltp;
169 const uint16_t *swb_offset; ///< table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular window170 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
658 658
659static int decode_usac_stereo_cplx(AACDecContext *ac, AACUsacStereo *us,659static int decode_usac_stereo_cplx(AACDecContext *ac, AACUsacStereo *us,
660 ChannelElement *cpe, GetBitContext *gb,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 int delta_code_time;665 int delta_code_time;
664 IndividualChannelStream *ics = &cpe->ch[0].ics;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 float last_alpha_q_im = 0;698 float last_alpha_q_im = 0;
697 if (delta_code_time) {699 if (delta_code_time) {
698 if (g) {700 if (g) {
699 last_alpha_q_re = us->prev_alpha_q_re[(g - 1)*cpe->max_sfb_ste + sfb];701 /* Transient, after the first group - use the current frame,
700 last_alpha_q_im = us->prev_alpha_q_im[(g - 1)*cpe->max_sfb_ste + sfb];702 * previous window, alpha values. */
701 } else if ((ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) &&703 last_alpha_q_re = us->alpha_q_re[(g - 1)*cpe->max_sfb_ste + sfb];
702 ics->window_sequence[1] == EIGHT_SHORT_SEQUENCE ||704 last_alpha_q_im = us->alpha_q_im[(g - 1)*cpe->max_sfb_ste + sfb];
703 ics->window_sequence[1] == EIGHT_SHORT_SEQUENCE) {705 } else if (!g &&
706 (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) &&
707 (ics->window_sequence[1] == EIGHT_SHORT_SEQUENCE)) {
704 /* The spec doesn't explicitly mention this, but it doesn't make708 /* The spec doesn't explicitly mention this, but it doesn't make
705 * any other sense otherwise! */709 * any other sense otherwise! */
706 last_alpha_q_re = us->prev_alpha_q_re[7*cpe->max_sfb_ste + sfb];710 const int wg = prev_num_window_groups - 1;
707 last_alpha_q_im = us->prev_alpha_q_im[7*cpe->max_sfb_ste + sfb];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 } else {713 } else {
709 last_alpha_q_re = us->prev_alpha_q_re[g*cpe->max_sfb_ste + sfb];714 last_alpha_q_re = us->prev_alpha_q_re[g*cpe->max_sfb_ste + sfb];
710 last_alpha_q_im = us->prev_alpha_q_im[g*cpe->max_sfb_ste + sfb];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 IndividualChannelStream *ics = &sce->ics;754 IndividualChannelStream *ics = &sce->ics;
750 755
751 /* Setup window parameters */756 /* Setup window parameters */
757 ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1);
752 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {758 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
753 if (usac->core_frame_len == 768) {759 if (usac->core_frame_len == 768) {
754 ics->swb_offset = ff_swb_offset_96[usac->rate_idx];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 memset(cpe->ms_mask, 0xFF, sizeof(cpe->ms_mask));875 memset(cpe->ms_mask, 0xFF, sizeof(cpe->ms_mask));
870 } else if ((us->ms_mask_mode == 3) && !ec->stereo_config_index) {876 } else if ((us->ms_mask_mode == 3) && !ec->stereo_config_index) {
871 ret = decode_usac_stereo_cplx(ac, us, cpe, gb,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 if (ret < 0)881 if (ret < 0)
874 return ret;882 return ret;
875 }883 }

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