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

📄 compfile.c

📁 Reference Implementation of G.711 standard and other voice codecs
💻 C
📖 第 1 页 / 共 2 页
字号:
/*                                                          v2.2 - 04/Jan/1999  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       COMPFILE.C       Description:       ~~~~~~~~~~~~       Program for comparing two files and displaying the samples that       are different on the screen. Supported data types are short (in both       decimal and hex formats) and float.       Usage:       ~~~~~~       $ COMPFILE [-delay] [-h] [-d] [-float] [-double] [-short] [-long]                   file1 file2                  [BlockSize [1stBlock [NoOfBlocks [TypeOfDump [DataType]]]]]       where:        file1       is the first file name;        file2       is the second file name;        BlockSize   is the Block size, in samples;        1stBlock    is the stating block;        NoOfBlocks  the number of blocks to be displayed;        TypeOfDump  whether the dump is decimal [d] or hexa [H];        DataType    if the file contains integer [I] or real [R] data;       Options:	-q           operate quietly - only report total no.of differences	-delay d     is the number of samples to delay. If d>0, the first		     file should be delayed in relation to the second                     file (samples from file 1 should be skipped). If d<0,		     the 2nd file is delayed (i.e., samples are skipped).        -h           set dump in hex mode - valid for integer data types        -i           set dump in decimal mode for integer data types [default]        -float       display float numbers        -double      display double numbers	-short       display short numbers [default]        -long        display long numbers               Compilation:       ~~~~~~~~~~~~       Sun:  cc -o cf compfile.c # K&R C, or [ok]             acc -o cf compfile.c # ANSI C   [ok]             gcc -fno-builtin -o cf compfile.c # gnu impl.of the ANSI C [ok]       vaxc: cc compfile.c /obj=cf               !             link cf                             ! [ok]              cf:==$'f$environment("default")'cf  !       tcc:  tcc compfile.c       Original Author:       ~~~~~~~~~~~~~~~~       Simao Ferraz de Campos Neto       DDS/Pr11                      Tel: +55-192-39-1396       CPqD/Telebras                 Fax: +55-192-53-4754       13088-061 Campinas SP Brazil  E-mail: <simao@cpqd.ansp.br>       History:       ~~~~~~~~       08/Mar/1990  v1.0  Created       29/Dec/1993  v2.0  Added options and UGST header and support to float                          data files <simao>       22/Feb/1996  v2.1  Removed compilation warnings, included headers as                          suggested by Kirchherr (FI/DBP Telekom) to run under			  OpenVMS/AXP <simao@ctd.comsat.com>       06/Jan/1999  v2.2  Updated help message for delay option, corrected                           possibly wrong reported number of samples                          compared.  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/#include "ugstdemo.h"/* OS definition */#if defined(__MSDOS__) && !defined(MSDOS)#define MSDOS#endif/* includes in general */#include <ctype.h>#include <string.h>#include <stdio.h>#include <stdlib.h>#include <math.h>/* ... Includes for O.S. specific headers ... */#if defined(MSDOS)#include <fcntl.h>#include <io.h>         /* For read(), write(), lseek() */#include <sys\stat.h>#elif defined(VMS)#include <perror.h>#include <file.h>#include <stat.h>#include <unixio.h>     /* For read(), write(), lseek() */#else				/* Unix */#include <unistd.h>     /* For read(), write(), lseek() */#include <sys/stat.h>#endif/* definitions for the program itself */#define PRINT_RULE { int K; for (K=0;K<4;K++) printf("-------------------");}#define PRINT_RULE2 { int K; for (K=0;K<4;K++) printf("===================");}#define CR	   printf("\n");/* Function prototypes */void display_usage ARGS((void));long compare_floats ARGS((char *File1, char *File2, int fh1, int fh2,		      long N, long N1, long N2, char quiet));long compare_shorts ARGS((char *File1, char *File2, int fh1, int fh2,		      long N, long N1, long N2, char KindOfDump, char quiet));/* * -------------------------------------------------------------------------- * ... Display usage of program ... *     Simao 29.Dec.93 * -------------------------------------------------------------------------- */#define FP(x) fprintf(stderr, x)void            display_usage(){  FP("*********** compfile [cf] Version 2.2 of 05/Jan/1999 **********\n");  FP("Program for comparing two files and displaying the samples that\n");  FP("are different at the screen as integers or hex numbers; the\n");  FP("option for dumping float files has not been implemented yet.\n");  FP("\n");  FP("Usage:\n");  FP("$ cf [-q] [-delay] [-h] [-d] [-float] [-double] [-short] [-long] file1 \n");  FP("\tfile2 [BlockSize [1stBlock [NoOfBlocks [TypeOfDump [DataType]]]]]\n");  FP("Where:\n");  FP(" file1       is the first file name;\n");  FP(" file2       is the second file name;\n");  FP(" BlockSize   is the Block size, in samples;\n");  FP(" 1stBlock    is the stating block;\n");  FP(" NoOfBlocks  the number of blocks to be displayed;\n");  FP(" TypeOfDump  whether the dump is decimal [D] or hexa[H];\n");  FP(" DataType    [I] for short and [R] float data\n\n");  FP("Options:\n");  FP(" -q           operate quietly - only report total no.of differences\n");  FP(" -delay d     is the number of samples to delay. If d>0, the first\n");  FP("              file should be delayed in relation to the second \n");  FP("              file (samples from file 1 should be skipped). If d<0, \n");  FP("              the 2nd file is delayed (i.e., samples are skipped).\n");  FP(" -h           set dump in hex mode - valid for integer data types\n");  FP(" -d           set dump in decimal mode for integer data types [default]\n");  FP(" -float       display float numbers\n");  FP(" -double      display double numbers\n");  FP(" -short       display short numbers [default]\n");  FP(" -long        display long numbers\n");  /* Quit program */  exit(-128);}#undef FP/* ....................... end of display_usage() ...........................*//*  -------------------------------------------------------------------------  long compare_floats(char *File1, char *File2, int fh1, int fh2,		      long N, long N1, long N2, char quiet);  Compare float data from 2 files and print different samples indicating  block/sample no.  Return the number of different samples OR -1 on error  30.Dec.93  v1.0  Simao  --------------------------------------------------------------------------*/long compare_floats(File1,File2,fh1,fh2,N,N1,N2, quiet)char *File1, *File2;int fh1, fh2;long N,N1,N2;char quiet;{  long i,j,l,k,NrDiffs;  char c;  float *a, *b;  /* Allocate memory for data vectors */  if ((a=(float *)calloc(N,sizeof(float)))==NULL)    return -1;  if ((b=(float *)calloc(N,sizeof(float)))==NULL) {    free(a);    return -1;  }  /* Start loop */  for (c=0, NrDiffs= i = j = 0; i < N2; i++, j = 0)  {    if (!(c == 'Q' || c == 'X' || c == 27 || c == 'S'))    {      if ((l = read(fh1, a, sizeof(float) * N) / sizeof(float)) > 0 &&	  (k = read(fh2, b, sizeof(float) * N) / sizeof(float)) > 0)	while (j < l && j < k)	{	  if (a[j] != b[j])	  {	    if (!quiet)	    {	      if (NrDiffs++ % 22 == 0)	      {		CR;		PRINT_RULE;		printf("\n Float compare of %s and %s\n", File1, File2);		PRINT_RULE;	      }	      printf("\nBLOCK: %6ld, SAMPLE: %4ld ===>", i + N1, j + 1);	      printf("\t%12.6E\t%12.6E\t[Diff=%+5.2E]", a[j], b[j], a[j]-b[j]);	      if (NrDiffs % 22 == 0)		if ((c = toupper(getchar())) == 'Q' || c == 'X' ||		    c == 27 || c == 'S')		  break;	    }	    else	      NrDiffs++;	  }	  j++;	}      else      {	if (l < 0)	{	  KILL(File1, 5);	}	else if (k < 0)	{	  KILL(File2, 6);	}	else	  break;      }    }  }  if (NrDiffs > 0 && !quiet)    CR;    /* Release allocated memory */  free(a);  free(b);    /* Return the number of different samples */  return(NrDiffs);}/* ...................... end of compare_floats() ..........................*//*  -------------------------------------------------------------------------  long compare_doubles(char *File1, char *File2, int fh1, int fh2,		      long N, long N1, long N2, char quiet);  Compare double data from 2 files and print different samples indicating  block/sample no.  Return the number of different samples OR -1 on error  30.Dec.93  v1.0  Simao  --------------------------------------------------------------------------*/long compare_doubles(File1,File2,fh1,fh2,N,N1,N2, quiet)char *File1, *File2;int fh1, fh2;long N,N1,N2;char quiet;{  long i,j,l,k,NrDiffs;  char c;  double *a, *b;  /* Allocate memory for data vectors */  if ((a=(double *)calloc(N,sizeof(double)))==NULL)    return -1;  if ((b=(double *)calloc(N,sizeof(double)))==NULL) {    free(a);    return -1;  }  /* Start loop */  for (c=0, NrDiffs= i = j = 0; i < N2; i++, j = 0)  {    if (!(c == 'Q' || c == 'X' || c == 27 || c == 'S'))    {      if ((l = read(fh1, a, sizeof(double) * N) / sizeof(double)) > 0 &&	  (k = read(fh2, b, sizeof(double) * N) / sizeof(double)) > 0)	while (j < l && j < k)	{	  if (a[j] != b[j])	  {	    if (!quiet)	    {	      if (NrDiffs++ % 22 == 0)	      {		CR;		PRINT_RULE;		printf("\n Double compare of %s and %s\n", File1, File2);		PRINT_RULE;	      }	      printf("\nBLOCK: %6ld, SAMPLE: %4ld ===>", i + N1, j + 1);	      printf("\t%12.6E\t%12.6E\t[Diff=%+5.2E]", a[j], b[j], a[j]-b[j]);	      if (NrDiffs % 22 == 0)		if ((c = toupper(getchar())) == 'Q' || c == 'X' ||		    c == 27 || c == 'S')		  break;	    }	    else	      NrDiffs++;	  }	  j++;	}      else      {	if (l < 0)	{	  KILL(File1, 5);	}	else if (k < 0)	{	  KILL(File2, 6);	}	else	  break;      }    }  }  if (NrDiffs > 0 && !quiet)    CR;  /* Release allocated memory */  free(a);  free(b);  /* Return the number of different samples */  return(NrDiffs);}/* ...................... end of compare_doubles() ..........................*//*  -------------------------------------------------------------------------  long compare_shorts(char *File1, char *File2, int fh1, int fh2,		      long N, long N1, long N2, char KindOfDump, char quiet);  Compare short data from 2 files and print in decimal or hex format the  different samples, indicating block/sample no.  Return the number of different samples OR -1 on error  30.Dec.93  v1.0  Simao  --------------------------------------------------------------------------*/long compare_shorts(File1,File2,fh1,fh2,N,N1,N2,KindOfDump, quiet)char *File1, *File2,KindOfDump;int fh1, fh2;long N,N1,N2;char quiet;{  long i,j,l,k,NrDiffs;  char c;  short *a, *b;  /* Allocate memory for data vectors */  if ((a=(short *)calloc(N,sizeof(short)))==NULL)    return -1;  if ((b=(short *)calloc(N,sizeof(short)))==NULL) {    free(a);    return -1;  }  /* Start loop */  for (c=0, NrDiffs= i = j = 0; i < N2; i++, j = 0)  {    if (!(c == 'Q' || c == 'X' || c == 27 || c == 'S'))    {      if ((l = read(fh1, a, sizeof(short) * N) / sizeof(short)) > 0 &&	  (k = read(fh2, b, sizeof(short) * N) / sizeof(short)) > 0)	while (j < l && j < k)	{	  if (a[j] != b[j])	  {	    if (!quiet)	    {	      if (NrDiffs++ % 22 == 0)	      {

⌨️ 快捷键说明

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