diff options
Diffstat (limited to 'src/libxineadec')
-rw-r--r-- | src/libxineadec/gsm610/long_term.c | 59 | ||||
-rw-r--r-- | src/libxineadec/gsm610/lpc.c | 41 | ||||
-rw-r--r-- | src/libxineadec/gsm610/rpe.c | 51 | ||||
-rw-r--r-- | src/libxineadec/gsm610/short_term.c | 7 |
4 files changed, 89 insertions, 69 deletions
diff --git a/src/libxineadec/gsm610/long_term.c b/src/libxineadec/gsm610/long_term.c index 932223738..c8564447d 100644 --- a/src/libxineadec/gsm610/long_term.c +++ b/src/libxineadec/gsm610/long_term.c @@ -4,10 +4,10 @@ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ -/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/long_term.c,v 1.1 2002/10/12 19:12:49 tmmm Exp $ */ +/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/long_term.c,v 1.2 2003/02/28 02:51:50 storri Exp $ */ #include <stdio.h> -#include <assert.h> +#include "xineutils.h" #include "private.h" @@ -40,7 +40,7 @@ * uncut one. (For a detailed explanation of why this is altogether * a bad idea, see Henry Spencer and Geoff Collyer, ``#ifdef Considered * Harmful''.) - */ +a */ #ifndef USE_FLOAT_MUL @@ -81,12 +81,13 @@ static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), temp = 0; if (dmax == 0) scal = 0; else { - assert(dmax > 0); + XINE_ASSERT(dmax > 0, "value 'dmax' is not > 0: %d", dmax); temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; - assert(scal >= 0); + + XINE_ASSERT(scal >= 0, "value 'scal' is not >= 0: %d", scal); /* Search for the maximum cross-correlation and coding of the LTP lag */ @@ -106,10 +107,10 @@ static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), /* Rescaling of L_max */ - assert(scal <= 100 && scal >= -100); + XINE_ASSERT((scal <= 100) && (scal >= -100), "value 'scal' is not within range -100 to 100: %d", scal); L_max = L_max >> (6 - scal); /* sub(6, scal) */ - assert( Nc <= 120 && Nc >= 40); + XINE_ASSERT( Nc <= 120 && Nc >= 40, "value 'Nc' is not within range 40 to 120: %d", Nc); /* Compute the power of the reconstructed short term residual * signal dp[..] @@ -181,14 +182,14 @@ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), temp = 0; if (dmax == 0) scal = 0; else { - assert(dmax > 0); + XINE_ASSERT(dmax > 0, "value 'dmax' is not > 0: %d", dmax); temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; - assert(scal >= 0); + XINE_ASSERT(scal >= 0, "value 'scal' is not >= 0: %d", scal); /* Initialization of a working array wt */ @@ -241,10 +242,10 @@ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), /* Rescaling of L_max */ - assert(scal <= 100 && scal >= -100); + XINE_ASSERT( (scal <= 100) && (scal >= -100), "value 'scal' is not within range -100 to 100: %d", scal); L_max = L_max >> (6 - scal); /* sub(6, scal) */ - assert( Nc <= 120 && Nc >= 40); + XINE_ASSERT( Nc <= 120 && Nc >= 40, "value 'Nc' is not within range 40 to 120: %d", Nc); /* Compute the power of the reconstructed short term residual * signal dp[..] @@ -322,14 +323,16 @@ static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), temp = 0; if (dmax == 0) scal = 0; else { - assert(dmax > 0); + XINE_ASSERT(dmax > 0, "value 'dmax' is not > 0: %d", dmax); + temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; - assert(scal >= 0); + XINE_ASSERT(scal >= 0, "value 'scal' is not >= 0: %d", scal); + ltp_cut = (longword)SASR(dmax, scal) * st->ltp_cut / 100; @@ -421,10 +424,11 @@ static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), /* Rescaling of L_max */ - assert(scal <= 100 && scal >= -100); + XINE_ASSERT( (scal <= 100) && (scal >= -100), "value 'scal' is not within range -100 to 100: %d", scal); + L_max = L_max >> (6 - scal); /* sub(6, scal) */ - assert( Nc <= 120 && Nc >= 40); + XINE_ASSERT( Nc <= 120 && Nc >= 40, "value 'Nc' is not within range 40 to 120: %d", Nc); /* Compute the power of the reconstructed short term residual * signal dp[..] @@ -498,14 +502,14 @@ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), temp = 0; if (dmax == 0) scal = 0; else { - assert(dmax > 0); + XINE_ASSERT(dmax > 0, "value 'dmax' is not > 0: %d", dmax); temp = gsm_norm( (longword)dmax << 16 ); } if (temp > 6) scal = 0; else scal = 6 - temp; - assert(scal >= 0); + XINE_ASSERT(scal >= 0, "value 'scal' is not >= 0: %d", scal); /* Initialization of a working array wt */ @@ -586,10 +590,13 @@ static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), /* Rescaling of L_max */ - assert(scal <= 100 && scal >= -100); + + XINE_ASSERT( (scal <= 100) && (scal >= -100), "value 'scal' is not within range -100 to 100: %d", scal); + L_max = L_max >> (6 - scal); /* sub(6, scal) */ - assert( Nc <= 120 && Nc >= 40); + XINE_ASSERT( Nc <= 120 && Nc >= 40, "value 'Nc' is not within range 40 to 120: %d", Nc); + /* Compute the power of the reconstructed short term residual * signal dp[..] @@ -659,7 +666,7 @@ static void Cut_Fast_Calculation_of_the_LTP_parameters P5((st, else if (-d[k] > wt_max) wt_max = -d[best_k = k]; } - assert(wt_max >= 0); + XINE_ASSERT(wt_max >= 0, "value 'wt_max' is not >= 0: %d", wt_max); wt_float = (float)wt_max; for (k = -120; k < 0; ++k) dp_float[k] = (float)dp[k]; @@ -877,8 +884,12 @@ void Gsm_Long_Term_Predictor P7((S,d,dp,e,dpp,Nc,bc), /* 4x for 160 samples */ word * bc /* gain factor OUT */ ) { - assert( d ); assert( dp ); assert( e ); - assert( dpp); assert( Nc ); assert( bc ); + XINE_ASSERT( d,"value 'd' is NULL"); + XINE_ASSERT( dp, "value 'dp' is NULL"); + XINE_ASSERT( e, "value 'e' is NULL"); + XINE_ASSERT( dpp, "value 'dpp' is NULL"); + XINE_ASSERT( Nc, "value 'Nc' is NULL"); + XINE_ASSERT( bc, "value 'bc' is NULL" ); #if defined(FAST) && defined(USE_FLOAT_MUL) if (S->fast) @@ -924,7 +935,7 @@ void Gsm_Long_Term_Synthesis_Filtering P5((S,Ncr,bcr,erp,drp), */ Nr = Ncr < 40 || Ncr > 120 ? S->nrp : Ncr; S->nrp = Nr; - assert(Nr >= 40 && Nr <= 120); + XINE_ASSERT(Nr >= 40 && Nr <= 120, "value 'Nr' is not within range of 40 to 120: %d", Nr); /* Decoding of the LTP gain bcr */ @@ -933,7 +944,7 @@ void Gsm_Long_Term_Synthesis_Filtering P5((S,Ncr,bcr,erp,drp), /* Computation of the reconstructed short term residual * signal drp[0..39] */ - assert(brp != MIN_WORD); + XINE_ASSERT(brp != MIN_WORD, "value 'brp' is equal to MIN_WORD"); for (k = 0; k <= 39; k++) { drpp = GSM_MULT_R( brp, drp[ k - Nr ] ); diff --git a/src/libxineadec/gsm610/lpc.c b/src/libxineadec/gsm610/lpc.c index 7795ca542..461f0b70f 100644 --- a/src/libxineadec/gsm610/lpc.c +++ b/src/libxineadec/gsm610/lpc.c @@ -4,10 +4,10 @@ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ -/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/lpc.c,v 1.1 2002/10/12 19:12:49 tmmm Exp $ */ +/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/lpc.c,v 1.2 2003/02/28 02:51:50 storri Exp $ */ #include <stdio.h> -#include <assert.h> +#include "xineutils.h" #include "private.h" @@ -54,7 +54,7 @@ static void Autocorrelation P2((s, L_ACF), */ if (smax == 0) scalauto = 0; else { - assert(smax > 0); + XINE_ASSERT(smax > 0, "Scale maximum (smax) is not greater than 0: %d", smax); scalauto = 4 - gsm_norm( (longword)smax << 16 );/* sub(4,..) */ } @@ -139,7 +139,7 @@ static void Autocorrelation P2((s, L_ACF), /* Rescaling of the array s[0..159] */ if (scalauto > 0) { - assert(scalauto <= 4); + XINE_ASSERT(scalauto <= 4, "scalauto is not <= 4: %d", scalauto); for (k = 160; k--; *s++ <<= scalauto) ; } } @@ -194,10 +194,10 @@ static void Reflection_coefficients P2( (L_ACF, r), return; } - assert( L_ACF[0] != 0 ); + XINE_ASSERT( L_ACF[0] != 0 , "L_ACF[0] is NULL"); temp = gsm_norm( L_ACF[0] ); - assert(temp >= 0 && temp < 32); + XINE_ASSERT(temp >= 0 && temp < 32, "temp is not within range 0 to 32: %d", temp); /* ? overflow ? */ for (i = 0; i <= 8; i++) ACF[i] = SASR( L_ACF[i] << temp, 16 ); @@ -221,9 +221,12 @@ static void Reflection_coefficients P2( (L_ACF, r), *r = gsm_div( temp, P[0] ); - assert(*r >= 0); + XINE_ASSERT(*r >= 0, "value 'r' is not >= 0: %d", *r); + if (P[1] > 0) *r = -*r; /* r[n] = sub(0, r[n]) */ - assert (*r != MIN_WORD); + + XINE_ASSERT (*r != MIN_WORD, "value 'r' is equal to MIN_WORD: %d", *r); + if (n == 8) return; /* Schur recursion @@ -264,21 +267,27 @@ static void Transformation_to_Log_Area_Ratios P1((r), temp = *r; temp = GSM_ABS(temp); - assert(temp >= 0); + + XINE_ASSERT(temp >= 0, "value 'temp' is not >= 0: %d", temp); if (temp < 22118) { temp >>= 1; } else if (temp < 31130) { - assert( temp >= 11059 ); + XINE_ASSERT(temp >= 11059, "value 'temp' is not >= 11059: %d", temp); temp -= 11059; } else { - assert( temp >= 26112 ); - temp -= 26112; - temp <<= 2; + XINE_ASSERT(temp >= 26112, "value 'temp' is not >= 26112: %d", temp); + temp -= 26112; + temp <<= 2; } - - *r = *r < 0 ? -temp : temp; - assert( *r != MIN_WORD ); + + if (*r < 0) { + *r = -temp; + } + else { + *r = temp; + } + XINE_ASSERT (*r != MIN_WORD, "value 'r' is equal to MIN_WORD: %d", *r); } } diff --git a/src/libxineadec/gsm610/rpe.c b/src/libxineadec/gsm610/rpe.c index f504573a6..4a9751cfa 100644 --- a/src/libxineadec/gsm610/rpe.c +++ b/src/libxineadec/gsm610/rpe.c @@ -4,11 +4,10 @@ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ -/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/rpe.c,v 1.1 2002/10/12 19:12:49 tmmm Exp $ */ +/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/rpe.c,v 1.2 2003/02/28 02:51:50 storri Exp $ */ #include <stdio.h> -#include <assert.h> - +#include "xineutils.h" #include "private.h" #include "gsm.h" @@ -142,7 +141,7 @@ static void RPE_grid_selection P3((x,xM,Mc_out), * * temp1 = SASR( x[m + 3*i], 2 ); * - * assert(temp1 != MIN_WORD); + * XINE_ASSERT(temp1 != MIN_WORD,"temp1 equals MIN_WORD"); * * L_temp = GSM_L_MULT( temp1, temp1 ); * L_result = GSM_L_ADD( L_temp, L_result ); @@ -246,8 +245,8 @@ static void APCM_quantization_xmaxc_to_exp_mant P3((xmaxc,exp_out,mant_out), mant -= 8; } - assert( exp >= -4 && exp <= 6 ); - assert( mant >= 0 && mant <= 7 ); + XINE_ASSERT( exp >= -4 && exp <= 6,"exp is not within range of -4 to 6: %d", exp ); + XINE_ASSERT( mant >= 0 && mant <= 7,"mant is not within range of 0 to 7: %d", mant ); *exp_out = exp; *mant_out = mant; @@ -290,14 +289,14 @@ static void APCM_quantization P5((xM,xMc,mant_out,exp_out,xmaxc_out), itest |= (temp <= 0); temp = SASR( temp, 1 ); - assert(exp <= 5); + XINE_ASSERT(exp <= 5, "exp is greater than 5: %d", exp); if (itest == 0) exp++; /* exp = add (exp, 1) */ } - assert(exp <= 6 && exp >= 0); + XINE_ASSERT(exp <= 6 && exp >= 0, "exp is not within range of 0 to 6: %d", exp); temp = exp + 5; - assert(temp <= 11 && temp >= 0); + XINE_ASSERT(temp <= 11 && temp >= 0, "temp is within range of 0 to 11: %d", temp); xmaxc = gsm_add( SASR(xmax, temp), exp << 3 ); /* Quantizing and coding of the xM[0..12] RPE sequence @@ -320,15 +319,15 @@ static void APCM_quantization P5((xM,xMc,mant_out,exp_out,xmaxc_out), /* Direct computation of xMc[0..12] using table 4.5 */ - assert( exp <= 4096 && exp >= -4096); - assert( mant >= 0 && mant <= 7 ); + XINE_ASSERT((exp <= 4096) && (exp >= -4096), "exp is not within range of -4069 to 4096: %d", exp ); + XINE_ASSERT((mant >= 0) && (mant <= 7), "mant is not within range of 0 to 7: %d", mant ); temp1 = 6 - exp; /* normalization by the exponent */ temp2 = gsm_NRFAC[ mant ]; /* inverse mantissa */ for (i = 0; i <= 12; i++) { - assert(temp1 >= 0 && temp1 < 16); + XINE_ASSERT(temp1 >= 0 && temp1 < 16, "temp1 is not within range of 0 to 15: %d", temp1); temp = xM[i] << temp1; temp = GSM_MULT( temp, temp2 ); @@ -361,24 +360,26 @@ static void APCM_inverse_quantization P4((xMc,mant,exp,xMp), word temp, temp1, temp2, temp3; longword ltmp; - assert( mant >= 0 && mant <= 7 ); + XINE_ASSERT((mant >= 0) && (mant <= 7), "mant is not within range of 0 to 7: %d", mant ); temp1 = gsm_FAC[ mant ]; /* see 4.2-15 for mant */ temp2 = gsm_sub( 6, exp ); /* see 4.2-15 for exp */ temp3 = gsm_asl( 1, gsm_sub( temp2, 1 )); for (i = 13; i--;) { - - assert( *xMc <= 7 && *xMc >= 0 ); /* 3 bit unsigned */ - - /* temp = gsm_sub( *xMc++ << 1, 7 ); */ - temp = (*xMc++ << 1) - 7; /* restore sign */ - assert( temp <= 7 && temp >= -7 ); /* 4 bit signed */ - - temp <<= 12; /* 16 bit signed */ - temp = GSM_MULT_R( temp1, temp ); - temp = GSM_ADD( temp, temp3 ); - *xMp++ = gsm_asr( temp, temp2 ); + XINE_ASSERT((mant >= 0) && (mant <= 7), "mant is not within range of 0 to 7: %d", mant ); + + XINE_ASSERT((*xMc <= 7) && (*xMc >= 0), "xMc is not 3 bit unsigned: %d", *xMc ); /* 3 bit unsigned */ + + /* temp = gsm_sub( *xMc++ << 1, 7 ); */ + temp = (*xMc++ << 1) - 7; /* restore sign */ + + XINE_ASSERT((temp <= 7) && (temp >= -7), "temp is not 4 bit signed: %d", temp); /* 4 bit signed */ + + temp <<= 12; /* 16 bit signed */ + temp = GSM_MULT_R( temp1, temp ); + temp = GSM_ADD( temp, temp3 ); + *xMp++ = gsm_asr( temp, temp2 ); } } @@ -399,7 +400,7 @@ static void RPE_grid_positioning P3((Mc,xMp,ep), { int i = 13; - assert(0 <= Mc && Mc <= 3); + XINE_ASSERT((0 <= Mc) && (Mc <= 3), "Mc is not within the range of 0 to 3: %d", Mc); switch (Mc) { case 3: *ep++ = 0; diff --git a/src/libxineadec/gsm610/short_term.c b/src/libxineadec/gsm610/short_term.c index 63392eca5..52ac623d2 100644 --- a/src/libxineadec/gsm610/short_term.c +++ b/src/libxineadec/gsm610/short_term.c @@ -4,11 +4,10 @@ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ -/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/short_term.c,v 1.1 2002/10/12 19:12:49 tmmm Exp $ */ +/* $Header: /nfshome/cvs/xine-lib/src/libxineadec/gsm610/short_term.c,v 1.2 2003/02/28 02:51:50 storri Exp $ */ #include <stdio.h> -#include <assert.h> - +#include "xineutils.h" #include "private.h" #include "gsm.h" @@ -43,7 +42,7 @@ static void Decoding_of_the_coded_Log_Area_Ratios P2((LARc,LARpp), * temp2 = *B << 1; * temp1 = GSM_SUB( temp1, temp2 ); * - * assert(*INVA != MIN_WORD); + * XINE_ASSERT(*INVA != MIN_WORD, "INVA table equlas MIN_WORD"); * * temp1 = GSM_MULT_R( *INVA, temp1 ); * *LARpp = GSM_ADD( temp1, temp1 ); |