⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vselp_io.c

📁 TI的DSP C55X的应用程序
💻 C
字号:
/***********************************************************************************/
/*                      IS54 Baseband Simulation Software                          */
/*                                                                                 */
/*  File Description : VSELP Data File Input/Output                                */
/*  File Name        : vselp_io.c                                                  */
/*  Date             : 12/30/93                                                    */
/*                   : July, 20001 - Modified for TMS320C55x project               */
/*                                                                                 */
/*  This file contains utility routines which read and write VSELP parameters      */
/*  from data files.                                                               */
/*                                                                                 */
/*  Functions:                                                                     */
/*          vselpin()  : This function reads VSELP parameters in from a data array */
/*                                                                                 */
/*          vselpout() : This function writes VSELP parameters out to a data file. */
/*                                                                                 */
/***********************************************************************************/

/* Include Files */

#include "vselp.h"

/* Defines */

/* Function Prototypes */

void vselpin( unsigned int *, unsigned* );
void vselpout( unsigned int *, unsigned* );

/* External Functions */

/* Data */

/* External Data */

/* Code */

/************************************************************************/
/*                                                                      */
/* Function : vselpin()                                                 */
/*                                                                      */
/* Procedure :  This function reads in a line of ASCII-HEX speech data  */
/*              array representing a 159-bit stream of VSELP data.      */
/*              The VSELP data is then formatted into a VSELP parameter */
/*              array as defined in "vselp.h".                          */
/*                                                                      */
/* Inputs :                                                             */
/*      spinput:  Input speech data pointer. One line of ASCII_HEX      */
/*                data will be read from this array                     */
/*                                                                      */
/* Outputs :                                                            */
/*      vselp  :  Pointer to VSELP parameter array. The VSELP           */
/*                parameters are written with the data obtained         */
/*                from the input speech file.                           */
/*                                                                      */
/* Return Value :                                                       */
/*      NONE                                                            */
/*                                                                      */ 
/************************************************************************/

void vselpin( unsigned int *input, unsigned *vselp )
{
    int i;
    unsigned vselpin_inptdat[10];
    
 /* vselp parameters are read in from a packed stream of bits
    159 bits long.  msbs are read in first.  bits 1-16 are in word
    0, bits 17-32 in word 1, etc. */

   for( i = 0; i < 10; i++ )
     vselpin_inptdat[i] = *input++;
     
    vselp[ VSELP_LPC1    ] = vselpin_inptdat[0] >> 10;            /* bits 1-6 */
    vselp[ VSELP_LPC2    ] = (vselpin_inptdat[0] >> 5) & 0x001f;    /* bits 7-11*/
    vselp[ VSELP_LPC3    ] = vselpin_inptdat[0] & 0x001f;         /* bits 12-16 */
    vselp[ VSELP_LPC4    ] = vselpin_inptdat[1] >> 12;            /* bits 17-20 */
    vselp[ VSELP_LPC5    ] = (vselpin_inptdat[1] >> 8) & 0x000f;     /* bits 21-24 */
    vselp[ VSELP_LPC6    ] = (vselpin_inptdat[1] >> 5) & 0x0007;     /* bits 25-27 */
    vselp[ VSELP_LPC7    ] = (vselpin_inptdat[1] >> 2) & 0x0007;     /* bits 28-30 */
    vselp[ VSELP_LPC8    ] = ((vselpin_inptdat[1] & 0x0003) << 1) | (vselpin_inptdat[2] >> 15);  /* bits 31 - 33 */
    vselp[ VSELP_LPC9    ] = (vselpin_inptdat[2] >> 12) & 0x0007; /* bits 34-36 */
    vselp[ VSELP_LPC10   ] = (vselpin_inptdat[2] >> 10) & 0x0003; /* bits 37-38 */
    vselp[ VSELP_R0      ] = (vselpin_inptdat[2] >> 5 ) & 0x001f;  /* bits 39-43 */
    vselp[ VSELP_LAG_1   ] = ((vselpin_inptdat[2] & 0x001f) << 2) | (vselpin_inptdat[3] >> 14);  /* bits 44-50 */
    vselp[ VSELP_GSPO_1  ] = (vselpin_inptdat[3] >> 6 ) & 0x00ff;  /* bits 51-58 */
    vselp[ VSELP_CODE1_1 ] = ((vselpin_inptdat[3] & 0x003f) << 1) | (vselpin_inptdat[4] >> 15);  /* bits 59-65 */
    vselp[ VSELP_CODE2_1 ] = (vselpin_inptdat[4] >> 8 ) & 0x007f;  /* bits 66-72 */
    vselp[ VSELP_LAG_2   ] = (vselpin_inptdat[4] >> 1 ) & 0x007f;  /* bits 73-79 */
    vselp[ VSELP_GSPO_2  ] = ((vselpin_inptdat[4] & 0x0001) << 7) | (vselpin_inptdat[5] >> 9);  /* bits 80-87 */
    vselp[ VSELP_CODE1_2 ] = (vselpin_inptdat[5] >> 2 ) & 0x007f;  /* bits 88-94 */
    vselp[ VSELP_CODE2_2 ] = ((vselpin_inptdat[5] & 0x0003) << 5) | (vselpin_inptdat[6] >> 11);  /* bits 95-101 */
    vselp[ VSELP_LAG_3   ] = (vselpin_inptdat[6] >> 4 ) & 0x007f;  /* bits 102-108 */
    vselp[ VSELP_GSPO_3  ] = ((vselpin_inptdat[6] & 0x000f) << 4) | (vselpin_inptdat[7] >> 12);  /* bits 109-116 */
    vselp[ VSELP_CODE1_3 ] = (vselpin_inptdat[7] >> 5 ) & 0x007f;  /* bits 117-123 */
    vselp[ VSELP_CODE2_3 ] = ((vselpin_inptdat[7] & 0x001f) << 2) | (vselpin_inptdat[8] >> 14);  /* bits 124-130 */
    vselp[ VSELP_LAG_4   ] = (vselpin_inptdat[8] >> 7 ) & 0x007f;  /* bits 131-137 */
    vselp[ VSELP_GSPO_4  ] = ((vselpin_inptdat[8] & 0x007f) << 1) | (vselpin_inptdat[9] >> 15);  /* bits 138-145 */
    vselp[ VSELP_CODE1_4 ] = (vselpin_inptdat[9] >> 8 ) & 0x007f;  /* bits 146-152 */
    vselp[ VSELP_CODE2_4 ] = (vselpin_inptdat[9] >> 1 ) & 0x007f;  /* bits 153-159 */

    return;
} 

/************************************************************************/
/*                                                                      */
/* Function : vselpout()                                                */
/*                                                                      */
/* Procedure :  This function takes an array of VSELP parameters        */
/*              (as defined in "vselp.h"), and an ASCII-HEX 159-bit     */
/*              stream of VSELP data is constructed and written to an   */
/*              output speech file.                                     */
/*                                                                      */
/* Inputs :                                                             */
/*      vselp   :  Pointer to VSELP parameter array. The VSELP          */
/*                 parameters are used to construct an ASCII_HEX        */
/*                 bit stream of VSELP data.                            */
/*                                                                      */
/* Outputs :                                                            */
/*      *outdat :  Output speech array pointer. One line of ASCII_HEX   */
/*                 VSELP data will be written to this array.            */
/*                                                                      */
/* Return Value :                                                       */
/*      NONE                                                            */
/*                                                                      */ 
/************************************************************************/

void vselpout( unsigned int *outdat, unsigned *vselp )
{
 /* vselp parameters are packed into a stream of bits
    159 bits long.  msbs are stored to the left. bits 1-16 are in word
    0, bits 17-32 in word 1, etc. */

    *outdat++ = ( vselp[ VSELP_LPC1 ]    << 10 )    | 
                ( vselp[ VSELP_LPC2 ]    << 5  )    | 
                ( vselp[ VSELP_LPC3 ]          );   
                
    *outdat++ = ( vselp[ VSELP_LPC4 ]    << 12 )    |
                ( vselp[ VSELP_LPC5 ]    << 8  )    | 
                ( vselp[ VSELP_LPC6 ]    << 5  )    |
                ( vselp[ VSELP_LPC7 ]    << 2  )    | 
                ( vselp[ VSELP_LPC8 ]    >> 1  );
                
    *outdat++ = ( vselp[ VSELP_LPC8 ]    << 15 )    | 
                ( vselp[ VSELP_LPC9 ]    << 12 )    |
                ( vselp[ VSELP_LPC10 ]   << 10 )    | 
                ( vselp[ VSELP_R0 ]      << 5  )    |
                ( vselp[ VSELP_LAG_1 ]   >> 2  ); 
                
    *outdat++ = ( vselp[ VSELP_LAG_1 ]   << 14 )    |
                ( vselp[ VSELP_GSPO_1 ]  << 6  )    | 
                ( vselp[ VSELP_CODE1_1 ] >> 1  );
                
    *outdat++ = ( vselp[ VSELP_CODE1_1 ] << 15 )    |
                ( vselp[ VSELP_CODE2_1 ] << 8  )    |
                ( vselp[ VSELP_LAG_2 ]   << 1  )    | 
                ( vselp[ VSELP_GSPO_2 ]  >> 7  );
                
    *outdat++ = ( vselp[ VSELP_GSPO_2 ]  << 9  )    | 
                ( vselp[ VSELP_CODE1_2 ] << 2  )    |
                ( vselp[ VSELP_CODE2_2 ] >> 5  );
                
    *outdat++ = ( vselp[ VSELP_CODE2_2 ] << 11 )    |
                ( vselp[ VSELP_LAG_3 ]   << 4  )    |
                ( vselp[ VSELP_GSPO_3 ]  >> 4  );
                
    *outdat++ = ( vselp[ VSELP_GSPO_3 ]  << 12 )    | 
                ( vselp[ VSELP_CODE1_3 ] << 5  )    |
                ( vselp[ VSELP_CODE2_3 ] >> 2  );
                
    *outdat++ = ( vselp[ VSELP_CODE2_3 ] << 14 )    | 
                ( vselp[ VSELP_LAG_4 ]   << 7  )    |
                ( vselp[ VSELP_GSPO_4 ]  >> 1  );
                
    *outdat++ = ( vselp[ VSELP_GSPO_4 ]  << 15 )    |
                ( vselp[ VSELP_CODE1_4 ] << 8  )    |
                ( vselp[ VSELP_CODE2_4 ] << 1  );

    return;
}
 



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -