shithub: aacdec

Download patch

ref: 91c3d6d0e3f82f9ffddd3fd2e95ea7fafb403111
parent: 84bff2c915145927daac490b6c93bb83ebd3b530
author: menno <menno>
date: Sat Sep 28 17:57:37 EDT 2002

Reverse bitstream reading works

--- a/libfaad/bits.c
+++ b/libfaad/bits.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: bits.c,v 1.10 2002/09/28 14:03:07 menno Exp $
+** $Id: bits.c,v 1.11 2002/09/28 21:57:37 menno Exp $
 **/
 
 #include "common.h"
@@ -97,17 +97,18 @@
     uint32_t tmp, index;
 
     index = (bits_in_buffer+31)/32;
+    index--;
 
     ld->start = (uint32_t*)buffer + index - 2;
 
     tmp = *((uint32_t*)buffer + index);
-#ifdef ARCH_IS_BIG_ENDIAN
+#ifndef ARCH_IS_BIG_ENDIAN
     BSWAP(tmp);
 #endif
     ld->bufa = tmp;
 
     tmp = *((uint32_t*)buffer + index - 1);
-#ifdef ARCH_IS_BIG_ENDIAN
+#ifndef ARCH_IS_BIG_ENDIAN
     BSWAP(tmp);
 #endif
     ld->bufb = tmp;
@@ -115,4 +116,6 @@
     ld->tail = (uint32_t*)buffer + index;
 
     ld->bits_left = bits_in_buffer % 32;
+    if (ld->bits_left == 0)
+        ld->bits_left = 32;
 }
--- a/libfaad/bits.h
+++ b/libfaad/bits.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: bits.h,v 1.9 2002/09/28 14:03:07 menno Exp $
+** $Id: bits.h,v 1.10 2002/09/28 21:57:37 menno Exp $
 **/
 
 #ifndef __BITS_H__
@@ -63,6 +63,8 @@
 };
 
 void faad_initbits(bitfile *ld, void *buffer);
+void faad_initbits_rev(bitfile *ld, void *buffer,
+                       uint32_t bits_in_buffer);
 uint8_t faad_byte_align(bitfile *ld);
 uint32_t faad_get_processed_bits(bitfile *ld);
 uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
@@ -147,6 +149,7 @@
             if (ld->bufb & (1 << (i + (32-ld->bits_left))))
                 B |= (1 << (bits - ld->bits_left - i - 1));
         }
+        return B;
     }
 }
 
@@ -160,7 +163,7 @@
 
         ld->bufa = ld->bufb;
         tmp = *(uint32_t*)ld->start;
-#ifdef ARCH_IS_BIG_ENDIAN
+#ifndef ARCH_IS_BIG_ENDIAN
         BSWAP(tmp);
 #endif
         ld->bufb = tmp;