From ba65efaad16ddd1347de7af98f9494cee7a39419 Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Sun, 11 Jan 2004 15:44:04 +0000 Subject: the faad project accepted a huge compiler warning patch I sent them, merging their CVS back to our copy everyone please check, if your AAC samples still work CVS patchset: 6024 CVS date: 2004/01/11 15:44:04 --- src/libfaad/huffman.c | 49 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) (limited to 'src/libfaad/huffman.c') diff --git a/src/libfaad/huffman.c b/src/libfaad/huffman.c index 5ec920976..9986e1472 100644 --- a/src/libfaad/huffman.c +++ b/src/libfaad/huffman.c @@ -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.1 2003/12/30 02:00:10 miguelfreitas Exp $ +** $Id: huffman.c,v 1.2 2004/01/11 15:44:05 mroi Exp $ **/ #include "common.h" @@ -38,6 +38,20 @@ #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; @@ -104,10 +118,20 @@ static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len) } } +#ifdef _WIN32 +static INLINE uint32_t bsr(uint32_t bits) +{ + __asm + { + bsr eax, dword ptr [bits] + } +} +#endif + 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,11 +140,12 @@ static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp) return sp; neg = 1; } else { - if(sp != 16) + if (sp != 16) return sp; neg = 0; } +#ifndef _WIN32 for (i = 4; ; i++) { if (faad_get1bit(ld @@ -129,11 +154,22 @@ static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp) break; } } +#else + /* maximum quantised value is 8192, + * so the maximum number of bits for 1 value is log[2](8192)=13 + * minimum bits used when escape is present is 4 bits + * this leaves a maximum of 9 bits to be read at this point + */ + j = faad_showbits(ld, 9) | 0xFFFFFE00; + i = 12 - bsr(~j); + faad_getbits(ld, i-3 + DEBUGVAR(1,6,"huffman_getescape(): escape size")); +#endif off = faad_getbits(ld, i DEBUGVAR(1,9,"huffman_getescape(): escape")); - j = off + (1<