diff libfaad2/huffman.c @ 12527:4a370c80fe5c

update to the 2.0 release of faad, patch by adland
author diego
date Wed, 02 Jun 2004 22:59:04 +0000
parents 3185f64f6350
children d81145997036
line wrap: on
line diff
--- a/libfaad2/huffman.c	Wed Jun 02 22:52:00 2004 +0000
+++ b/libfaad2/huffman.c	Wed Jun 02 22:59:04 2004 +0000
@@ -1,6 +1,6 @@
 /*
 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
-** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
+** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
 ** Commercial non-GPL licensing of this software is possible.
 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
 **
-** $Id: huffman.c,v 1.4 2003/09/09 18:12:00 menno Exp $
+** $Id: huffman.c,v 1.1 2003/10/03 22:23:26 alex Exp $
 **/
 
 #include "common.h"
@@ -38,6 +38,19 @@
 #include "codebook/hcb.h"
 
 
+/* static function declarations */
+static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len);
+static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp);
+static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_2step_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_quad(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_quad_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp);
+static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp);
+static int16_t huffman_codebook(uint8_t i);
+
 int8_t huffman_scale_factor(bitfile *ld)
 {
     uint16_t offset = 0;
@@ -107,7 +120,7 @@
 static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp)
 {
     uint8_t neg, i;
-    int16_t j;
+    int32_t j;
 	int32_t off;
 
     if (sp < 0)
@@ -116,7 +129,7 @@
             return sp;
         neg = 1;
     } else {
-        if(sp != 16)
+        if (sp != 16)
             return sp;
         neg = 0;
     }
@@ -133,7 +146,7 @@
     off = faad_getbits(ld, i
         DEBUGVAR(1,9,"huffman_getescape(): escape"));
 
-    j = off + (1<<i);
+    j = off | (1<<i);
     if (neg)
         j = -j;
 
@@ -216,7 +229,7 @@
     return 0;
 }
 
-static huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp)
+static uint8_t huffman_2step_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp)
 {
     uint8_t err = huffman_2step_pair(cb, ld, sp);
     huffman_sign_bits(ld, sp, PAIR_LEN);
@@ -319,7 +332,7 @@
     case 10:
         return huffman_2step_pair_sign(cb, ld, sp);
     case 12: {
-        uint8_t err = huffman_2step_quad(1, ld, sp);
+        uint8_t err = huffman_2step_pair(11, ld, sp);
         sp[0] = huffman_codebook(0); sp[1] = huffman_codebook(1); 
         return err; }
     case 11:
@@ -357,7 +370,6 @@
     uint16_t offset = 0;
     uint8_t extra_bits;
     uint8_t i;
-    uint8_t save_cb = cb;
 
 
     switch (cb)