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

📄 eid.c

📁 Reference Implementation of G.711 standard and other voice codecs
💻 C
📖 第 1 页 / 共 5 页
字号:
        Parameters:            ~~~~~~~~~~~          EID: ............. (In) Pointer to EID-struct         threshold: ....... (In) threshold         current_state: ... (In) current state ('G' or 'B')         next_state: ...... (In) next state ('G' or 'B')         Return value:    none.        ~~~~~~~~~~~~~        Author: <hf@pkinbg.uucp>        ~~~~~~~        History:        ~~~~~~~~        28.Feb.92 v1.0 Release of 1st version <hf@pkinbg.uucp> ============================================================================*/void set_GEC_matrix(EID,threshold,current_state,next_state)SCD_EID *EID;double threshold;int /* char */ current_state;int /* char */ next_state;{  int icurr,inext;  if (toupper(current_state)=='G')    icurr = 0;  else    icurr = 1;  if (toupper(next_state)=='G')    inext = 0;  else    inext = 1;  EID->matrix[icurr][inext] = threshold;}/* ....................... End of set_GEC_matrix() ....................... *//*  ==========================================================================         double get_GEC_matrix (SCD_EID *EID, int current_state, int        ~~~~~~~~~~~~~~~~~~~~~  next_state);                Description:        ~~~~~~~~~~~~        Auxiliary function to support saving of channel states.        Get the state of the Transition Matrix of GEC-model.        Parameters:            ~~~~~~~~~~~          EID: ............. (In) Pointer to EID-struct         current_state: ... (In) current state ('G' or 'B')         next_state: ...... (In) next state ('G' or 'B')         Return value:        ~~~~~~~~~~~~~        Returns the threshold as a double.        Author: <hf@pkinbg.uucp>        ~~~~~~~        History:        ~~~~~~~~        20.Apr.92 v1.0 Release of 1st version <hf@pkinbg.uucp> ============================================================================*/double get_GEC_matrix(EID,current_state,next_state)SCD_EID *EID;int /* char */ current_state;int /* char */ next_state;{   int icurr,inext;   if (toupper(current_state)=='G')     icurr = 0;   else     icurr = 1;   if (toupper(next_state)=='G')     inext = 0;   else     inext = 1;   return(EID->matrix[icurr][inext]);}/* ....................... End of get_GEC_matrix() ....................... *//*  ==========================================================================         void set_GEC_current_state (SCD_EID *EID, int current_state);        ~~~~~~~~~~~~~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Auxiliary function to support setting the current channel state.        Parameters:            ~~~~~~~~~~~          EID: ............. (In) Pointer to EID-struct         current_state: ... (In) current state ('G' or 'B')         Return value:     none.        ~~~~~~~~~~~~~        Author: <hf@pkinbg.uucp>        ~~~~~~~        History:        ~~~~~~~~        20.Apr.92 v1.0 Release of 1st version <hf@pkinbg.uucp> ============================================================================*/void set_GEC_current_state(EID,current_state)SCD_EID *EID;int /* char */ current_state;{  if (toupper(current_state)=='G')    EID->current_state = 0L;  else    EID->current_state = 1L;}/* ................... End of set_GEC_current_state() ................... *//*  ==========================================================================         char get_GEC_current_state (SCD_EID *EID);         ~~~~~~~~~~~~~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Function to get the channel current state.        Parameters:            ~~~~~~~~~~~          EID: ..... pointer to state variable;        Return value:        ~~~~~~~~~~~~~        Return the current state (Good or Bad).        Author: <hf@pkinbg.uucp>        ~~~~~~~        History:        ~~~~~~~~        20.Apr.92 v1.0 Release of 1st version <hf@pkinbg.uucp> ============================================================================ */char get_GEC_current_state(EID)SCD_EID *EID; {  if (EID->current_state==0L)    return('G');  else    return('B');}/* .................... End of get_GEC_current_state() .................... *//*  ============================================================================         BURST_EID *open_burst_eid (long index);        ~~~~~~~~~~~~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Allocate memory for BURST_EID struct and setup the transition        matrix according the selected bit error rate.        Parameters:          ~~~~~~~~~~~        index: ..... (In) Index for model vector parameter			    1 = 1%, 3=3%, 5=5%         Return value:        ~~~~~~~~~~~~~        Returns a pointer to struct BURST_EID;        Author:         ~~~~~~~	Cliff Halevi        Bellcore, NVC 5F 319	Phone: +1-908-758-5839        100 Schultz Drive	Fax:   +1-908-758-4502        Red Bank, NJ 07701.	email: chh2@cc.bellcore.com        Vijay Varma        Bellcore NVC 3X-325	Phone: +1-908-758-2811        331 Newman Springs Road	Fax:   +1-908-758-4371        Red Bank, NJ 07701.	email: varma@nyquist.bellcore.com	Gerhard Schroeder .....        History:        ~~~~~~~~        04/Aug/93 v.1.0 Created ============================================================================*/BURST_EID   *open_burst_eid (index)long index;{  BURST_EID *burst_eid;  time_t t1;  long i;  /* Allocate EID structure */   if ((burst_eid=(BURST_EID *)malloc(sizeof(BURST_EID)))==0L) 	    return((BURST_EID *)0);  /* Preset of the random generator seed with current system time */#ifdef PORT_TEST    t1 = 314159265;#else    time(&t1);#endif    burst_eid->seedptr = (unsigned long) t1;    for (i=0;  i<MODEL_SIZE;  i++)    {      burst_eid->internal[i] = 0;    }    burst_eid->s_new = 0;        switch (index)    {    	case 1:	    burst_eid->index = 0;	    break;    	case 3:	    burst_eid->index = 1;	    break;    	case 5:	    burst_eid->index = 2;	    break;    	case 10:	    burst_eid->index = 3;	    break;    	case 15:	    burst_eid->index = 4;	    break;    	default:	    fprintf(stderr, " Using default error rate of 1 %%\n");	    burst_eid->index = 0;	    break;    }    #ifdef DEBUG    /*	     **  Print out the selected coefficient vector    */	     for (i=0;  i< MODEL_SIZE;  i++)    {      printf ("p[%2d]=%f\n", i,prob[burst_eid->index][i]);    }#endif   /* Return BURST_EID structure */    return (burst_eid);}/* .................... End of open_burst_eid() .................... *//*  ============================================================================         double FER_generator_burst (BURST_EID *state);        ~~~~~~~~~~~~~~~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Generate a double indicating whether the current frame should be        considered good or bad..        Parameters:          ~~~~~~~~~~~        state: ..... (In/Out) State variable describing the channel.        Return value:        ~~~~~~~~~~~~~        Returns 0 on a good-frame indication and 1 if the current frame        is to be considered a bad frame.        Author:         ~~~~~~~	Gerhard Schroeder	FI-DBP Telekom            Tel: 	+49-6151-83-3973	Am Kavalleriesand 3       Fax: 	+49-6151-89-5234	D-64295 Darmstadt         E-mail: gerhard.schroeder@fz13.fz.dbp.de	GERMANY        History:        ~~~~~~~~        04/Aug/93 v1.0 Created	26.Jan.98 v3.0 Corrected bug for 64-bit operating systems (where                        longs have 64, not 32 bits). Implemented by                       <simao.campos@comsat.com>, after bug reported                       by <claude.lamblin@cnet.francetelecom.fr> ============================================================================*/double FER_generator_burst (state)BURST_EID *state;{  long    in;  double  ran, aux;   /* Size in bits (=size in bytes * 8) for long variables*/  static double bits_in_long = sizeof(long) * 8;  /* UGST Random number generator */  state->seedptr = ((unsigned long)69069L * (state->seedptr) +1L);  /* Return random number as a double in range [0...1] */#ifdef WAS  ran = (pow((double)2.0, (double)-32.0) * (double)(state->seedptr));#else  ran = (pow((double)2.0, -bits_in_long) * (double)(state->seedptr));#endif  aux = prob[state->index][state->s_new];  in = floor(ran + aux);	/* in = 0 indicates good frame */                                /* in = 1 indicates bad frame */  if (in == 0)                    /* If frame is good, */  {    /* increment frame counter for state */    state->internal[state->s_new]++;    if (state->s_new != 0) state->internal[0]++;    state->s_new = 0;  }  else    state->s_new++;      /* Else, if frame is bad, increment state */  return((double) in);}/* .................... End of FER_generator_burst() .................... *//* ********************************************************************* *//* ********************************************************************* *//* ************************* ADDED AFTER STL96 ************************* *//* ********************************************************************* *//* ********************************************************************* *//*    -------------------------------------------------------------------------   void reset_burst_eid (BURST_EID *burst_eid);   ~~~~~~~~~~~~~~~~~~~~   Reset a BURST_EID structure. By default, only counters are reset;   if the symbol RESET_SEED_AS_WELL is defined at compilation time,   the seed is also reset. However, this is not recommended.   Parameter:   ~~~~~~~~~~   burst_eid: .... BURST_EID structure (previously initialized by                    open_burst_eid) to be reset.   Return value: None.   ~~~~~~~~~~~~~   Original author: <simao.campos@comsat.com>   ~~~~~~~~~~~~~~~~   History:   ~~~~~~~~   15.Aug.97  v.1.0  Created.   ---------------------------------------------------------------------

⌨️ 快捷键说明

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