is.c

00001 /*
00002 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
00003 ** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
00004 **  
00005 ** This program is free software; you can redistribute it and/or modify
00006 ** it under the terms of the GNU General Public License as published by
00007 ** the Free Software Foundation; either version 2 of the License, or
00008 ** (at your option) any later version.
00009 ** 
00010 ** This program is distributed in the hope that it will be useful,
00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 ** GNU General Public License for more details.
00014 ** 
00015 ** You should have received a copy of the GNU General Public License
00016 ** along with this program; if not, write to the Free Software 
00017 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 **
00019 ** Any non-GPL usage of this software or parts of this software is strictly
00020 ** forbidden.
00021 **
00022 ** Software using this code must display the following message visibly in the
00023 ** software:
00024 ** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
00025 ** in, for example, the about-box or help/startup screen.
00026 **
00027 ** Commercial non-GPL licensing of this software is possible.
00028 ** For more info contact Ahead Software through [email protected].
00029 **
00030 ** $Id: is.c,v 1.2 2005/11/01 21:41:43 gabest Exp $
00031 **/
00032 
00033 #include "common.h"
00034 #include "structs.h"
00035 
00036 #include "syntax.h"
00037 #include "is.h"
00038 
00039 #ifdef FIXED_POINT
00040 static real_t pow05_table[] = {
00041     COEF_CONST(1.68179283050743), /* 0.5^(-3/4) */
00042     COEF_CONST(1.41421356237310), /* 0.5^(-2/4) */
00043     COEF_CONST(1.18920711500272), /* 0.5^(-1/4) */
00044     COEF_CONST(1.0),              /* 0.5^( 0/4) */
00045     COEF_CONST(0.84089641525371), /* 0.5^(+1/4) */
00046     COEF_CONST(0.70710678118655), /* 0.5^(+2/4) */
00047     COEF_CONST(0.59460355750136)  /* 0.5^(+3/4) */
00048 };
00049 #endif
00050 
00051 void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec,
00052                uint16_t frame_len)
00053 {
00054     uint8_t g, sfb, b;
00055     uint16_t i;
00056 #ifndef FIXED_POINT
00057     real_t scale;
00058 #else
00059     int32_t exp, frac;
00060 #endif
00061 
00062     uint16_t nshort = frame_len/8;
00063     uint8_t group = 0;
00064 
00065     for (g = 0; g < icsr->num_window_groups; g++)
00066     {
00067         /* Do intensity stereo decoding */
00068         for (b = 0; b < icsr->window_group_length[g]; b++)
00069         {
00070             for (sfb = 0; sfb < icsr->max_sfb; sfb++)
00071             {
00072                 if (is_intensity(icsr, g, sfb))
00073                 {
00074 #ifdef MAIN_DEC
00075                     /* For scalefactor bands coded in intensity stereo the
00076                        corresponding predictors in the right channel are
00077                        switched to "off".
00078                      */
00079                     ics->pred.prediction_used[sfb] = 0;
00080                     icsr->pred.prediction_used[sfb] = 0;
00081 #endif
00082 
00083 #ifndef FIXED_POINT
00084                     scale = (real_t)pow(0.5, (0.25*icsr->scale_factors[g][sfb]));
00085 #else
00086                     exp = icsr->scale_factors[g][sfb] >> 2;
00087                     frac = icsr->scale_factors[g][sfb] & 3;
00088 #endif
00089 
00090                     /* Scale from left to right channel,
00091                        do not touch left channel */
00092                     for (i = icsr->swb_offset[sfb]; i < icsr->swb_offset[sfb+1]; i++)
00093                     {
00094 #ifndef FIXED_POINT
00095                         r_spec[(group*nshort)+i] = MUL_R(l_spec[(group*nshort)+i], scale);
00096 #else
00097                         if (exp < 0)
00098                             r_spec[(group*nshort)+i] = l_spec[(group*nshort)+i] << -exp;
00099                         else
00100                             r_spec[(group*nshort)+i] = l_spec[(group*nshort)+i] >> exp;
00101                         r_spec[(group*nshort)+i] = MUL_C(r_spec[(group*nshort)+i], pow05_table[frac + 3]);
00102 #endif
00103                         if (is_intensity(icsr, g, sfb) != invert_intensity(ics, g, sfb))
00104                             r_spec[(group*nshort)+i] = -r_spec[(group*nshort)+i];
00105                     }
00106                 }
00107             }
00108             group++;
00109         }
00110     }
00111 }

Generated on Tue Dec 13 14:47:40 2005 for guliverkli by  doxygen 1.4.5