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

📄 eid_io.c

📁 Reference Implementation of G.711 standard and other voice codecs
💻 C
📖 第 1 页 / 共 2 页
字号:
      sscanf(&ch[2], "%lx", &longary[i]);    }    else    {      sscanf(ch, "%ld", &longary[i]);    }  }  return (n);}/* ....................... End of READ_L() ....................... *//*  ============================================================================        long READ_lf (FILE *fp, long n, double *doubleary);        ~~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Read `n' doubles from an EID-state file onto an array.        Return value:        ~~~~~~~~~~~~~        Returns the number of doubles read.        Author: <hf@pkinbg.uucp>        ~~~~~~~        History:        ~~~~~~~~        28.Feb.92 v1.0 Release of 1st version <hf@pkinbg.uucp> ============================================================================*/long                READ_lf(fp, n, doubleary)  FILE           *fp;  long            n;  double         *doubleary;{  long            i, ic;  char            c;  char            ch[64];  while ((c = getc(fp)) != '=');  for (i = 0; i < n; i++)  {    while (((c = getc(fp)) == 32) || (c == 9));    ic = 0;    while ((c != 32) && (c != 9) && (c != '\n') && (ic < 63))    {      ch[ic++] = c;      c = getc(fp);    }    ch[ic] = (char) 0;    sscanf(ch, "%lf", &doubleary[i]);  }  return (n);}/* ....................... End of READ_lf() ....................... *//*  ============================================================================        long READ_c (FILE *fp, long n, char *chr);        ~~~~~~~~~~~        Description:        ~~~~~~~~~~~~        Read `n' doubles from an EID-state file onto an array.        Return value:        ~~~~~~~~~~~~~        Returns the number of chars read.        Author: <hf@pkinbg.uucp>        ~~~~~~~        History:        ~~~~~~~~        28.Feb.92 v1.0 Release of 1st version <hf@pkinbg.uucp> ============================================================================*/long                READ_c(fp, n, chr)  FILE           *fp;  long            n;  char           *chr;{  long            i;  char            c;  while ((c = getc(fp)) != '=');  for (i = 0; i < n; i++)  {    while (((c = getc(fp)) == 32) || (c == 9));    *chr = c;    while ((c = getc(fp)) != '\n');  }  return (n);}/* ....................... End of READ_c() ....................... *//*  ============================================================================  BURST_EID *recall_burst_eid_from_file (char *state_file, long index);  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  Description:  ~~~~~~~~~~~~  Recall burst eid state variable from a binary file (Bellcore model)  A magic number prevents that state variable files saved by other modes  of the EID be read. If a magic number is not found, the function  returns as having failed.  Formal Parameters:  ~~~~~~~~~~~~~~~~~~  state_file:          Data type:   char string          Access:      read only          Mechanism:   pointer          Description: Name of the burst eid state file         Return Value:  ~~~~~~~~~~~~~  Pointer to BURST_EID; NULL on error (couldn't find the file, or the  file did not have a valid magic number, or could not allocate memory  for the state variable).  Side Effects:  ~~~~~~~~~~~~~  None        History:  ~~~~~~~~  29.Jul.93 v1.0 Routine created <gerhard.schroeder@ites.itu.ch>  19.Apr.94 v1.1 Fixed error in declaration of local var. state_ptr, that                  has to be a pointer. <simao>  14.Aug.97 v1.2 Added magic number <simao.campos@comsat.com> ============================================================================*/BURST_EID *recall_burst_eid_from_file (state_file,index)    char *state_file;    long index;{    FILE       *state_ptr;    BURST_EID  *burst_eid,	       *eid_in;    long	items, magic;#if defined(VMS)    char mrs[15] = "mrs=512";#endif    /*	      **  Open BURST EID state file    **	Return a null pointer, if the file doesn't exists    */	      if ((state_ptr = fopen (state_file, RB)) == NULL)    	 return ((BURST_EID *) 0);    	     /*     ** Read Magic number for Burst EID State Files.    ** If it does not find the magic number, it returns 0    */    items = fread (&magic, 1, sizeof (long), state_ptr);    if (items != sizeof(long) || magic != MAGIC_BURST)    	return ((BURST_EID *) 0);    /*	      **  Allocate memory for the burst eid from file    */	      if ((eid_in = (BURST_EID *)malloc (sizeof (BURST_EID))) == 0L)	    return ((BURST_EID *) 0);    /*	      **  Read state from file    */	      items = fread (eid_in, 1, sizeof (BURST_EID),  state_ptr);    if (items != sizeof(BURST_EID))   	return ((BURST_EID *) 0);   	    /*	      **  Open internal eid    */	      if ((burst_eid = open_burst_eid(index)) == (BURST_EID *) 0)	{	    return ((BURST_EID *) 0);	} 		    /*	      **  Update burst eid    */	      if ((index-1) == eid_in->index)    {    	burst_eid->seedptr = eid_in->seedptr;	burst_eid->s_new   = eid_in->s_new;    }        /* Close and return */    fclose (state_ptr);    return (burst_eid);}/* ................ End of recall_burst_eid_from_file() ................. *//* ============================================================================  long save_burst_eid_to_file (BURST_EID *burst_eid, char *state_file);  ~~~~~~~~~~~~~~~~~~~~~~~~~~~  Description:  ~~~~~~~~~~~~  Save the burst eid state variable onto a binary file (Bellcore model).  A magic number is saved to prevent that other EID modes read this  state variable file as valid.  Formal Parameters:  ~~~~~~~~~~~~~~~~~~  burst_eid:          Data type:   BURST_EID          Access:      read only          Mechanism:   pointer          Description: Contains of the state variable         state_file:          Data type:   char string          Access:      read only          Mechanism:   pointer          Description: Name of the binary file which should get the state  Return Value:  ~~~~~~~~~~~~~  Return 1 if OK and 0 on failure (couldn't create or write to the file).  Side Effects:  ~~~~~~~~~~~~~  None        History:  ~~~~~~~~  29.Jul.93 v1.0 Routine created <gerhard.schroeder@ties.itu.ch>  19.Apr.94 v1.1 Fixed error in declaration of local var. state_ptr, that                  has to be a pointer. <simao>  14.Aug.97 v1.2 Added magic number <simao.campos@comsat.com> ============================================================================*/long save_burst_eid_to_file (burst_eid,state_file)    BURST_EID	*burst_eid;    char	*state_file;{#if defined(VMS)    char mrs[15] = "mrs=512";#endif    FILE	*state_ptr;    long	items, magic = MAGIC_BURST;    /*	      **  Open BURST EID state file    **	Return zero, if the file doesn't exist    */	      if ((state_ptr = fopen (state_file, WB)) == NULL)    	 return (0);    /*     ** Save Magic number into Burst EID State Files.    */    items = fwrite (&magic, 1, sizeof (long), state_ptr);    if (items != sizeof(long))    	return (0);    /*	      ** Write state to file    */	      items = fwrite (burst_eid, 1, sizeof (BURST_EID), state_ptr);    if (items != sizeof(BURST_EID))    	return (0);    /*	      **  Close state file    */	      fclose (state_ptr);    return(1); /* OK status */}/* ................ End of save_burst_eid_to_file() ................. *//* ********************************************************************* *//* ********************************************************************* *//* ************************* ADDED AFTER STL96 ************************* *//* ********************************************************************* *//* ********************************************************************* *//* ************************* END OF eid_io.c ************************* */

⌨️ 快捷键说明

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