diff mbox series

[FFmpeg-devel,1/6] aacdec_usac: apply specification fix M55715

Message ID 20240616085454.2560973-1-dev@lynne.ee
State New
Headers show
Series [FFmpeg-devel,1/6] aacdec_usac: apply specification fix M55715 | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Lynne June 16, 2024, 8:54 a.m. UTC
---
 libavcodec/aac/aacdec_usac.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c
index 98e8c1c0bc..065bc869d9 100644
--- a/libavcodec/aac/aacdec_usac.c
+++ b/libavcodec/aac/aacdec_usac.c
@@ -835,6 +835,11 @@  static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac,
     tns_active = get_bits1(gb);
     us->common_window = get_bits1(gb);
 
+    if (!us->common_window || indep_flag) {
+        memset(us->prev_alpha_q_re, 0, sizeof(us->prev_alpha_q_re));
+        memset(us->prev_alpha_q_im, 0, sizeof(us->prev_alpha_q_im));
+    }
+
     if (us->common_window) {
         /* ics_info() */
         ics1->window_sequence[1] = ics1->window_sequence[0];
@@ -845,6 +850,20 @@  static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac,
         ics2->use_kb_window[1] = ics2->use_kb_window[0];
         ics1->use_kb_window[0] = ics2->use_kb_window[0] = get_bits1(gb);
 
+        /* If there's a change in the transform sequence, zero out last frame's
+         * stereo prediction coefficients */
+        if ((ics1->window_sequence[0] == EIGHT_SHORT_SEQUENCE &&
+             ics1->window_sequence[1] != EIGHT_SHORT_SEQUENCE) ||
+            (ics1->window_sequence[1] == EIGHT_SHORT_SEQUENCE &&
+             ics1->window_sequence[0] != EIGHT_SHORT_SEQUENCE) ||
+            (ics2->window_sequence[0] == EIGHT_SHORT_SEQUENCE &&
+             ics2->window_sequence[1] != EIGHT_SHORT_SEQUENCE) ||
+            (ics2->window_sequence[1] == EIGHT_SHORT_SEQUENCE &&
+             ics2->window_sequence[0] != EIGHT_SHORT_SEQUENCE)) {
+            memset(us->prev_alpha_q_re, 0, sizeof(us->prev_alpha_q_re));
+            memset(us->prev_alpha_q_im, 0, sizeof(us->prev_alpha_q_im));
+        }
+
         if (ics1->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
             ics1->max_sfb = ics2->max_sfb = get_bits(gb, 4);
             ue1->scale_factor_grouping = ue2->scale_factor_grouping = get_bits(gb, 7);