shithub: aacdec

Download patch

ref: f04dced0c0331caf7c6e1dbfb3297221e48d0f06
parent: 80ea6d589cb94b4259f441a6e8733c3918f13c73
parent: e48c2c82a5f9192622a29b052122ef594da891c5
author: Sigrid Haflínudóttir <[email protected]>
date: Tue Oct 6 05:41:17 EDT 2020

Merge remote-tracking branch 'upstream/master' into master

--- a/libfaad/mp4.c
+++ b/libfaad/mp4.c
@@ -104,7 +104,11 @@
     0, /* 27 ER Parametric */
 #endif
     0, /* 28 (Reserved) */
-    0, /* 29 (Reserved) */
+#ifdef PS_DEC
+    1, /* 29 AAC LC + SBR + PS */
+#else
+    0, /* 29 AAC LC + SBR + PS */
+#endif
     0, /* 30 (Reserved) */
     0  /* 31 (Reserved) */
 };
@@ -171,7 +175,7 @@
 
 #ifdef SBR_DEC
     mp4ASC->sbr_present_flag = -1;
-    if (mp4ASC->objectTypeIndex == 5)
+    if (mp4ASC->objectTypeIndex == 5 || mp4ASC->objectTypeIndex == 29)
     {
         uint8_t tmp;
 
@@ -228,7 +232,7 @@
     else
 		bits_to_decode = (int8_t)(buffer_size*8 - (startpos-faad_get_processed_bits(ld)));
 
-    if ((mp4ASC->objectTypeIndex != 5) && (bits_to_decode >= 16))
+    if ((mp4ASC->objectTypeIndex != 5 && mp4ASC->objectTypeIndex != 29) && (bits_to_decode >= 16))
     {
         int16_t syncExtensionType = (int16_t)faad_getbits(ld, 11
             DEBUGVAR(1,9,"parse_audio_decoder_specific_info(): syncExtensionType"));
--- a/libfaad/pns.c
+++ b/libfaad/pns.c
@@ -236,7 +236,17 @@
                 if ((ics_right != NULL)
                     && is_noise(ics_right, g, sfb))
                 {
-                    if (channel_pair &&
+#ifdef LTP_DEC
+                    /* See comment above. */
+                    ics_right->ltp.long_used[sfb] = 0;
+                    ics_right->ltp2.long_used[sfb] = 0;
+#endif
+#ifdef MAIN_DEC
+                    /* See comment above. */
+                    ics_right->pred.prediction_used[sfb] = 0;
+#endif
+
+                    if (channel_pair && is_noise(ics_left, g, sfb) &&
                         (((ics_left->ms_mask_present == 1) &&
                         (ics_left->ms_used[g][sfb])) ||
                         (ics_left->ms_mask_present == 2)))
@@ -251,14 +261,6 @@
                             ics_right->scale_factors[g][sfb], size, sub, &r1_dep, &r2_dep);
 
                     } else /*if (ics_left->ms_mask_present == 0)*/ {
-
-#ifdef LTP_DEC
-                        ics_right->ltp.long_used[sfb] = 0;
-                        ics_right->ltp2.long_used[sfb] = 0;
-#endif
-#ifdef MAIN_DEC
-                        ics_right->pred.prediction_used[sfb] = 0;
-#endif
 
                         offs = ics_right->swb_offset[sfb];
                         size = min(ics_right->swb_offset[sfb+1], ics_right->swb_offset_max) - offs;
--- a/libfaad/sbr_dec.c
+++ b/libfaad/sbr_dec.c
@@ -94,9 +94,16 @@
     {
         sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960;
         sbr->numTimeSlots = NO_TIME_SLOTS_960;
-    } else {
+    }
+    else if (framelength == 1024)
+    {
         sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS;
         sbr->numTimeSlots = NO_TIME_SLOTS;
+    }
+    else
+    {
+        faad_free(sbr);
+        return NULL;
     }
 
     sbr->GQ_ringbuf_index[0] = 0;
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.c
@@ -1054,6 +1054,8 @@
 #endif
                 );
         }
+        if (!hDecoder->sbr[ele])
+            return 19;
 
         if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
             hDecoder->sbr[ele]->maxAACLine = 8*min(sce->ics1.swb_offset[max((int)sce->ics1.max_sfb-1, 0)], sce->ics1.swb_offset_max);
@@ -1310,6 +1312,8 @@
 #endif
                 );
         }
+        if (!hDecoder->sbr[ele])
+            return 19;
 
         if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE)
             hDecoder->sbr[ele]->maxAACLine = 8*min(cpe->ics1.swb_offset[max((int)cpe->ics1.max_sfb-1, 0)], cpe->ics1.swb_offset_max);
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -879,7 +879,10 @@
                     if ((ics->ltp.data_present = faad_get1bit(ld
                         DEBUGVAR(1,50,"ics_info(): ltp.data_present"))) & 1)
                     {
-                        ltp_data(hDecoder, ics, &(ics->ltp), ld);
+                        if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0)
+                        {
+                            return retval;
+                        }
                     }
                 }
 #endif
@@ -1086,6 +1089,8 @@
 #endif
                     );
             }
+            if (!hDecoder->sbr[sbr_ele])
+                return 19;
 
             hDecoder->sbr_present_flag = 1;
 
@@ -1354,6 +1359,11 @@
         {
             hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, hDecoder->element_id[0],
                 2*get_sample_rate(hDecoder->sf_index), 0 /* ds SBR */, 1);
+        }
+        if (!hDecoder->sbr[0])
+        {
+            hInfo->error = 19;
+            return;
         }
 
         /* Reverse bit reading of SBR data in DRM audio frame */