code.c

Go to the documentation of this file.
00001 /*
00002  * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
00003  * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
00004  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
00005  */
00006 
00007 /* $Header$ */
00008 
00009 #include "config.h"
00010 
00011 #ifdef   HAS_STRING_H
00012 #include <string.h>
00013 #else
00014 #  include "proto.h"
00015    extern char * memcpy P((char *, char *, int));
00016 #endif
00017 
00018 #include "private.h"
00019 #include "gsm.h"
00020 #include "proto.h"
00021 
00022 /* 
00023  *  4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER 
00024  */
00025 
00026 void Gsm_Coder P8((S,s,LARc,Nc,bc,Mc,xmaxc,xMc),
00027 
00028    struct gsm_state  * S,
00029 
00030    word  * s,  /* [0..159] samples        IN */
00031 
00032 /*
00033  * The RPE-LTD coder works on a frame by frame basis.  The length of
00034  * the frame is equal to 160 samples.  Some computations are done
00035  * once per frame to produce at the output of the coder the
00036  * LARc[1..8] parameters which are the coded LAR coefficients and 
00037  * also to realize the inverse filtering operation for the entire
00038  * frame (160 samples of signal d[0..159]).  These parts produce at
00039  * the output of the coder:
00040  */
00041 
00042    word  * LARc,  /* [0..7] LAR coefficients    OUT   */
00043 
00044 /*
00045  * Procedure 4.2.11 to 4.2.18 are to be executed four times per
00046  * frame.  That means once for each sub-segment RPE-LTP analysis of
00047  * 40 samples.  These parts produce at the output of the coder:
00048  */
00049 
00050    word  * Nc, /* [0..3] LTP lag       OUT   */
00051    word  * bc, /* [0..3] coded LTP gain      OUT   */
00052    word  * Mc, /* [0..3] RPE grid selection     OUT     */
00053    word  * xmaxc,/* [0..3] Coded maximum amplitude OUT   */
00054    word  * xMc /* [13*4] normalized RPE samples OUT   */
00055 )
00056 {
00057    int   k;
00058    word  * dp  = S->dp0 + 120;   /* [ -120...-1 ] */
00059    word  * dpp = dp;    /* [ 0...39 ]   */
00060 
00061    word  e[50];
00062 
00063    word  so[160];
00064 
00065    memset(e,0,sizeof e);
00066    Gsm_Preprocess       (S, s, so);
00067    Gsm_LPC_Analysis     (S, so, LARc);
00068    Gsm_Short_Term_Analysis_Filter   (S, LARc, so);
00069 
00070    for (k = 0; k <= 3; k++, xMc += 13) {
00071 
00072       Gsm_Long_Term_Predictor ( S,
00073                 so+k*40, /* d      [0..39] IN   */
00074                 dp,    /* dp  [-120..-1] IN  */
00075                e + 5,     /* e      [0..39] OUT */
00076                dpp,    /* dpp    [0..39] OUT */
00077                 Nc++,
00078                 bc++);
00079 
00080       Gsm_RPE_Encoding  ( S,
00081                e + 5,   /* e    ][0..39][ IN/OUT */
00082                  xmaxc++, Mc++, xMc );
00083       /*
00084        * Gsm_Update_of_reconstructed_short_time_residual_signal
00085        *       ( dpp, e + 5, dp );
00086        */
00087 
00088       { register int i;
00089         for (i = 0; i <= 39; i++)
00090          dp[ i ] = GSM_ADD( e[5 + i], dpp[i] );
00091       }
00092       dp  += 40;
00093       dpp += 40;
00094 
00095    }
00096    (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160),
00097       120 * sizeof(*S->dp0) );
00098 }

Generated on Thu Apr 16 06:27:30 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6