shithub: aacdec

Download patch

ref: 58d9ce79f10730277bb79db6c07d68451c6baacf
parent: 302034653eeac5500edad16484ac199b9d282389
author: menno <menno>
date: Sun Dec 22 14:58:31 EST 2002

Changes from latest MPEG corrigendum

--- a/libfaad/data.c
+++ b/libfaad/data.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: data.c,v 1.5 2002/09/15 22:02:30 menno Exp $
+** $Id: data.c,v 1.6 2002/12/22 19:58:31 menno Exp $
 **/
 
 #include "common.h"
@@ -32,6 +32,11 @@
     0, 0, 0, 35, 35, 37, 30, 30, 0, 0, 0, 0
 };
 #endif
+
+extern uint8_t num_swb_960_window[] =
+{
+    40, 40, 45, 49, 49, 49, 46, 46, 42, 42, 42, 40
+};
 
 extern uint8_t num_swb_1024_window[] =
 {
--- a/libfaad/data.h
+++ b/libfaad/data.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: data.h,v 1.5 2002/09/15 22:02:30 menno Exp $
+** $Id: data.h,v 1.6 2002/12/22 19:58:31 menno Exp $
 **/
 
 #ifndef __DATA_H__
@@ -27,6 +27,7 @@
 #endif
 
 extern uint8_t num_swb_1024_window[];
+extern uint8_t num_swb_960_window[];
 #ifdef LD_DEC
 extern uint8_t num_swb_512_window[];
 extern uint8_t num_swb_480_window[];
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: decoder.c,v 1.45 2002/12/11 11:36:13 menno Exp $
+** $Id: decoder.c,v 1.46 2002/12/22 19:58:31 menno Exp $
 **/
 
 #include "common.h"
@@ -149,6 +149,7 @@
             hDecoder->adif_header_present = 1;
 
             get_adif_header(&adif, &ld);
+            faad_byte_align(&ld);
 
             hDecoder->sf_index = adif.pce.sf_index;
             hDecoder->object_type = adif.pce.object_type;
@@ -420,7 +421,6 @@
 
 
     /* no more bit reading after this */
-    faad_byte_align(ld);
     hInfo->bytesconsumed = bit2byte(faad_get_processed_bits(ld));
     faad_endbits(ld);
     if (ld) free(ld);
--- a/libfaad/pns.c
+++ b/libfaad/pns.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: pns.c,v 1.19 2002/11/28 18:48:30 menno Exp $
+** $Id: pns.c,v 1.20 2002/12/22 19:58:31 menno Exp $
 **/
 
 #include "common.h"
@@ -193,22 +193,10 @@
                 {
                     if (is_noise(ics_right, g, sfb))
                     {
-                        if (ics_left->ms_mask_present == 1)
+                        if (((ics_left->ms_mask_present == 1) &&
+                            (ics_left->ms_used[g][sfb])) ||
+                            (ics_left->ms_mask_present == 2))
                         {
-                            if (ics_left->ms_used[g][sfb])
-                            {
-                                uint16_t c;
-
-                                offs = ics_right->swb_offset[sfb];
-                                size = ics_right->swb_offset[sfb+1] - offs;
-
-                                for (c = 0; c < size; c++)
-                                {
-                                    spec_right[(group*nshort) + offs + c] =
-                                        spec_left[(group*nshort) + offs + c];
-                                }
-                            }
-                        } else if (ics_left->ms_mask_present == 2) {
                             uint16_t c;
 
                             offs = ics_right->swb_offset[sfb];
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: specrec.c,v 1.17 2002/11/28 18:48:30 menno Exp $
+** $Id: specrec.c,v 1.18 2002/12/22 19:58:31 menno Exp $
 **/
 
 /*
@@ -73,7 +73,10 @@
                 ics->num_swb = num_swb_480_window[sf_index];
         } else {
 #endif
-            ics->num_swb = num_swb_1024_window[sf_index];
+            if (hDecoder->frameLength == 1024)
+                ics->num_swb = num_swb_1024_window[sf_index];
+            else /* if (hDecoder->frameLength == 960) */
+                ics->num_swb = num_swb_960_window[sf_index];
 #ifdef LD_DEC
         }
 #endif
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -16,15 +16,11 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: syntax.c,v 1.36 2002/12/10 19:45:36 menno Exp $
+** $Id: syntax.c,v 1.37 2002/12/22 19:58:31 menno Exp $
 **/
 
 /*
    Reads the AAC bitstream as defined in 14496-3 (MPEG-4 Audio)
-
-   (Note that there are some differences with 13818-7 (MPEG2), these
-   are also read correctly when the MPEG ID is known (can be found in
-   an ADTS header)).
 */
 
 #include "common.h"
@@ -449,6 +445,9 @@
     }
 #endif
 
+    /* new in corrigendum 14496-3:2002 */
+    faad_byte_align(ld);
+
     return elements;
 }
 
@@ -1269,10 +1268,6 @@
 
 #ifdef LTP_DEC
 /* Table 4.4.28 */
-/*
-   The limit MAX_LTP_SFB is not defined in 14496-3, this is a bug in the document
-   and will be corrected in one of the corrigenda.
-*/
 static void ltp_data(faacDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld)
 {
     uint8_t sfb, w;
@@ -1389,7 +1384,10 @@
 /* Table 4.4.30 */
 static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count)
 {
-    uint16_t i, n;
+    uint16_t i, n, dataElementLength;
+    uint8_t dataElementLengthPart;
+    uint8_t align = 4, data_element_version, loopCounter;
+
     uint8_t extension_type = (uint8_t)faad_getbits(ld, 4
         DEBUGVAR(1,87,"extension_payload(): extension_type"));
 
@@ -1408,13 +1406,38 @@
                 DEBUGVAR(1,88,"extension_payload(): fill_byte")); /* must be �10100101� */
         }
         return count;
+    case EXT_DATA_ELEMENT:
+        data_element_version = faad_getbits(ld, 4
+            DEBUGVAR(1,400,"extension_payload(): data_element_version"));
+        switch (data_element_version)
+        {
+        case ANC_DATA:
+            loopCounter = 0;
+            dataElementLength = 0;
+            do {
+                dataElementLengthPart = faad_getbits(ld, 8
+                    DEBUGVAR(1,401,"extension_payload(): dataElementLengthPart"));
+                dataElementLength += dataElementLengthPart;
+                loopCounter++;
+            } while (dataElementLengthPart == 255);
+
+            for (i = 0; i < dataElementLength; i++)
+            {
+                /* data_element_byte[i] = */ faad_getbits(ld, 8
+                    DEBUGVAR(1,402,"extension_payload(): data_element_byte"));
+                return (dataElementLength+loopCounter+1);
+            }
+        default:
+            align = 0;
+        }
+    case EXT_FIL:
     default:
-        faad_getbits(ld, 4
-            DEBUGVAR(1,137,"extension_payload(): fill_nibble"));
+        faad_getbits(ld, align
+            DEBUGVAR(1,88,"extension_payload(): fill_nibble"));
         for (i = 0; i < count-1; i++)
         {
             /* other_bits[i] = */ faad_getbits(ld, 8
-               DEBUGVAR(1,89,"extension_payload(): fill_byte"));
+               DEBUGVAR(1,89,"extension_payload(): fill_bit"));
         }
         return count;
     }
@@ -1550,16 +1573,16 @@
     adif->num_program_config_elements = (uint8_t)faad_getbits(ld, 4
         DEBUGVAR(1,116,"get_adif_header(): num_program_config_elements"));
 
-    for (i = 0; i < adif->num_program_config_elements + 1; i++)
+    if(adif->bitstream_type == 0)
     {
-        if(adif->bitstream_type == 0)
-        {
-            adif->adif_buffer_fullness = faad_getbits(ld, 20
-                DEBUGVAR(1,117,"get_adif_header(): adif_buffer_fullness"));
-        } else {
-            adif->adif_buffer_fullness = 0;
-        }
+        adif->adif_buffer_fullness = faad_getbits(ld, 20
+            DEBUGVAR(1,117,"get_adif_header(): adif_buffer_fullness"));
+    } else {
+        adif->adif_buffer_fullness = 0;
+    }
 
+    for (i = 0; i < adif->num_program_config_elements + 1; i++)
+    {
         program_config_element(&adif->pce, ld);
     }
 }
@@ -1618,11 +1641,13 @@
         DEBUGVAR(1,126,"adts_fixed_header(): original"));
     adts->home = faad_get1bit(ld
         DEBUGVAR(1,127,"adts_fixed_header(): home"));
+/* Removed in corrigendum 14496-3:2002
     if (adts->id == 0)
     {
         adts->emphasis = (uint8_t)faad_getbits(ld, 2
             DEBUGVAR(1,128,"adts_fixed_header(): emphasis"));
     }
+*/
 
     return 0;
 }
--- a/libfaad/syntax.h
+++ b/libfaad/syntax.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: syntax.h,v 1.23 2002/11/28 18:48:30 menno Exp $
+** $Id: syntax.h,v 1.24 2002/12/22 19:58:31 menno Exp $
 **/
 
 #ifndef __SYNTAX_H__
@@ -49,8 +49,11 @@
 #define LEN_TAG   4
 #define LEN_BYTE  8
 
-#define EXT_FILL_DATA     1
+#define EXT_FIL            0
+#define EXT_FILL_DATA      1
+#define EXT_DATA_ELEMENT   2
 #define EXT_DYNAMIC_RANGE 11
+#define ANC_DATA           0
 
 /* Syntax elements */
 #define ID_SCE 0x0