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

📄 plotmtv_interf.c

📁 C写的MPEG4音频源代码(G.723/G.729)
💻 C
📖 第 1 页 / 共 2 页
字号:
          for (counter = 0; counter < npts; counter++)            y[counter] = ((double*)dataPtr)[counter];          }            else if (dtype==MTV_DOUBLE_SQA)        {          for (counter = 0; counter < npts; counter++)            y[counter] = ((double*)dataPtr)[counter]*((double*)dataPtr)[counter];          }            else if (dtype==MTV_FLOAT)        {          for (counter = 0; counter < npts; counter++)            y[counter] = (double) (((float*)dataPtr)[counter]);          }      else if (dtype==MTV_ABSFLOAT)        {          for (counter = 0; counter < npts; counter++)            if (((float*)dataPtr)[counter]>=0)              y[counter] = (double) (((float*)dataPtr)[counter]);              else              y[counter] = (double) -(((float*)dataPtr)[counter]);          }      else if (dtype==MTV_CPLXFLOAT)        {          for (counter = 0; counter < npts; counter++)	    y[counter] = (double) sqrt(SQR(((float*)dataPtr)[counter])+				       SQR(((float*)dataPtr2)[counter]));          }      else if (dtype==MTV_SHORT)        {          for (counter = 0; counter < npts; counter++)            y[counter] = (double) (((short*)dataPtr)[counter]);          }      else if (dtype==MTV_INT)        {                        for (counter = 0; counter < npts; counter++)            y[counter] = (double) (((int*)dataPtr)[counter]);                             }       else if (dtype==MTV_INT_SQA)        {                        for (counter = 0; counter < npts; counter++)            y[counter] = (double) (((int*)dataPtr)[counter])*(double) (((int*)dataPtr)[counter]);                             } else {	  CommonExit(-1,"\nplotmtv error");          /* ERRORHANDLER(RESET,INV_DATAFORMAT,_PLOTMTV_INTERF_C,err_mess," "); */        }      for (counter = 0; counter < npts; counter++)        x[counter] = counter ;        /* search adresslist for the plot_set */      adress_ptr = amark_ptr->next;       found = FALSE;      while (adress_ptr != NULL) /* last set */        {          if (strcmp(adress_ptr->plot_set, plot_set) == 0)             {              fseek(ControlScript, adress_ptr->fpos, SEEK_SET);              found = TRUE;              break;            }          else                      adress_ptr = adress_ptr->next;               }            if (found == TRUE)        {                                            if (search(plot_set) != 0)             {              /* das Plotset ist zum 1. Mal da -> Option w */	      plotsetCnt++;              fnew_ptr = (struct filelist *) malloc(sizeof(struct filelist));              fnew_ptr->next = fbegin_ptr->next;              fnew_ptr->data.current_lcolor = 1;                fbegin_ptr->next = fnew_ptr;              strcpy(fnew_ptr->data.bin_filename, plotsetPreafix);                       strcat(fnew_ptr->data.bin_filename, plot_set);                       /* open file  */              if ((fnew_ptr->data.fp = fopen(fnew_ptr->data.bin_filename,"w")) == NULL)                {                  CommonExit(-1,"\nplotmtv error");                  /* ERRORHANDLER(RESET,FILE_MISSING,_PLOTMTV_INTERF_C,err_mess, fnew_ptr->data.bin_filename); */                }              else                fnew_ptr->data.status = ACTIV;                       /* Parameter-Kopf */              fprintf(fnew_ptr->data.fp,"$ DATA=CURVE2D\n");            }          else              {              /* open file for append  */              if ((fnew_ptr->data.fp = fopen(fnew_ptr->data.bin_filename,"a")) == NULL)                {                  CommonExit(-1,"\nplotmtv error");                  /* ERRORHANDLER(RESET,FILE_MISSING,_PLOTMTV_INTERF_C,err_mess, fnew_ptr->data.bin_filename); */                }              fnew_ptr->data.current_lcolor = fnew_ptr->data.current_lcolor + 1;             }          /* weitere Parameter... */          fprintf(fnew_ptr->data.fp,"%% linecolor = %d\n",fnew_ptr->data.current_lcolor);          if (plotPaperPlot == 1) {            fprintf(fnew_ptr->data.fp,"%% linetype = %d\n",(fnew_ptr->data.current_lcolor));            fprintf(fnew_ptr->data.fp,"%% markertype = %d\n",(fnew_ptr->data.current_lcolor)+1);          }          fprintf(fnew_ptr->data.fp,"%% linelabel =  \" %s \" \n",legend);               fprintf(fnew_ptr->data.fp,"%% toplabel = \" %s fr%d gr%d\"\n",plot_set,framePlot,0);                 	  endFound=0;          while (!feof(ControlScript)) {             fscanf (ControlScript, "%1024[^\n]\n", line);            sscanf (line,"%1024[^#]",buffer);            sscanf (buffer,"%s",keyword);            keyword[3] = '\000';            if ((strcmp(keyword,"END") == 0)                ||(strcmp(keyword,"EOF") == 0)                ||(strcmp(keyword,"end") == 0)                ||(strcmp(keyword,"End") == 0)) {              endFound=1;              break;            }  else  {              length = strlen(buffer);              fprintf(fnew_ptr->data.fp,"%s\n",buffer);                             }          }	  /* if (endFound == 0) { */          /*   ERRORHANDLER(MESSAGE,PLOT_RC,_PLOTMTV_INTERF_C,err_mess, ControlScript); */	  /* } */	              rewind(ControlScript);                      /* write the binary data to plot file */          fprintf(fnew_ptr->data.fp,"%% binary=True npts=%ld\n",npts);          if (fwrite((char *)x, sizeof(double), npts, fnew_ptr->data.fp) != (size_t)npts)            {              CommonExit(-1,"\nplotmtv error");              /* ERRORHANDLER(RESET,WRITE_BIN,_PLOTMTV_INTERF_C,err_mess, fnew_ptr->data.bin_filename); */            }          if (fwrite((char *)y, sizeof(double), npts, fnew_ptr->data.fp) != (size_t)npts)            {              CommonExit(-1,"\nplotmtv error");              /* ERRORHANDLER(RESET,WRITE_BIN,_PLOTMTV_INTERF_C,err_mess, fnew_ptr->data.bin_filename); */            }            fprintf(fnew_ptr->data.fp,"\n");           fclose(fnew_ptr->data.fp);             } /* found == TRUE */      else#if DEBUG_MTV        CommonWarning("warning: the plot_set '%s' is not available in the resource file. Command 'plotPlot' was not executed. \n",                plot_set); #endif       free (x);      free (y);    }   }  return 0;}static pid_t   childProcessId=-1;void plotDisplay(int noWait){  int     i;  pid_t   termPid;  int     termStatus;  char *  argvP0[1024];  int     argCount;  int     errorFile;  int     logFile;  if (enable_plotmtv) {    /* kill childProcessId for future extension */    /* if (termPid == childProcessId) { */    /*   strcpy (command, "kill -9 " ); */    /*   sprintf(pidString,"%9d",childProcessId); */    /*   strcat (command,pidString); */    /*   printf("\n kill chld 0 command: %s \n",command); */    /*   system (command);	 */    /* }  */    termPid=0;    if (!noWait) {      while ( (termPid!=childProcessId) ) {        termPid = waitpid ((pid_t) -1, &termStatus,0); /* wait on termiation of any child */      }    }    childProcessId=-1;    /* call plotmtv --> one instance of plotmtv is created */    if (fbegin_ptr != NULL) {      if (fbegin_ptr->next != NULL) {         fnew_ptr = fbegin_ptr->next;        /* first instance of plotmtv */        i=0;        argCount=0;        argvP0[argCount++]="plotmtv";        argvP0[argCount++]="-mult";        argvP0[argCount++]="-bg";        argvP0[argCount++]=BG_COLOR;        argvP0[argCount++]=PRINTER_OPT;        argvP0[argCount++]="-clobber";        while (fnew_ptr != NULL ) {          argvP0[argCount]= fnew_ptr->data.bin_filename;          fnew_ptr = fnew_ptr->next;          i++;          argCount++;        }        argvP0[argCount++]="-geometry";        switch (i)          {          case 1 :	                 argvP0[argCount++]= WIN_GEOM_1 ;             break;          case 2 :            argvP0[argCount++]= WIN_GEOM_2;             break;          case 3 :            argvP0[argCount++]= WIN_GEOM_3;             break;          case 4 :            argvP0[argCount++]= WIN_GEOM_4 ;             break;          case 5 :          case 6 :          case 7 :          case 8 :            argvP0[argCount++]= WIN_GEOM_5 ;             break;          default:            argvP0[argCount++]= WIN_GEOM_6 ;           }        argvP0[argCount++]=NULL;        if ( i>0  )   {          childProcessId=fork();                /* first child */          if (childProcessId== 0 ) {            /******************** child **********************/            /* redirect stdout and stderr befor exec plotmtv */            logFile = (open (logFilename, O_RDWR | O_CREAT ,S_IWUSR | S_IRUSR ));             if (logFile != -1 ){              dup2 (logFile, STDOUT_FILENO);              (close (logFile));            } else {              /* ERRORHANDLER(MESSAGE, FORK_FAILED ,  _PLOTMTV_INTERF_C,  */              /*              err_mess, " Logfile for plotmtv could not be opened "); */            }            errorFile = (open (errorFilename, O_RDWR | O_CREAT ,S_IWUSR | S_IRUSR ));             if (errorFile != -1 ){              dup2 (errorFile, STDERR_FILENO);              (close (errorFile));            } else {              /* ERRORHANDLER(MESSAGE, FORK_FAILED ,  _PLOTMTV_INTERF_C,  */              /* 		  err_mess, " Error file for plotmtv could not be opened "); */            }	                  execvp("plotmtv",argvP0); /* this never returns if success */            exit (-1);           } else if (childProcessId == -1) {            /************************ parent *******************/	                  /* ERRORHANDLER(MESSAGE, FORK_FAILED ,  _PLOTMTV_INTERF_C,  */            /* 		err_mess, " fork failed "); */          } 	              /* for the next run use the other praefix for the plotset filenames              else plotmtv would drop some files */          sleep(1); /* give processor time to plotmtv */          if  ( strcmp(plotsetPreafix,PLOTSET_PRAEF1) == 0) {            plotsetPreafix=PLOTSET_PRAEF0;          } else {            plotsetPreafix=PLOTSET_PRAEF1;          }        }	        }    }  }  }void plotDirect(char           *label,                enum DATA_TYPE dtype,                long           npts,                void           *vector1,                void           *vector2,                void           *vector3,                void           *vector4){  int save_enable_plotmtv;  int noWait=1; /* for plotDirect, plotDisplay shall not wait for dead of previous plot window */  label = label;  save_enable_plotmtv  = enable_plotmtv;  enable_plotmtv=1;    plotInit(100000);  if (dtype==MTV_CPLXFLOAT) {    plotSend("vector1+2","direct1",dtype,npts,vector1,vector2);    if (vector3 !=NULL)      plotSend("vector3+4","direct1",dtype,npts,vector3,vector4);  }  else {    plotSend("vector1","direct1",dtype,npts,vector1,NULL);    if (vector2 !=NULL)      plotSend("vector2","direct1",dtype,npts,vector2,NULL);    if (vector3 !=NULL)      plotSend("vector3","direct2",dtype,npts,vector3,NULL);    if (vector4 !=NULL)      plotSend("vector4","direct2",dtype,npts,vector4,NULL);  }  plotDisplay(noWait);   enable_plotmtv = save_enable_plotmtv;}

⌨️ 快捷键说明

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