📄 plotmtv_interf.c
字号:
/********************************************************************** MPEG-4 Audio VM This software module was originally developed by Bodo Teichmann Fraunhofer Institute of Erlangen tmn@iis.fhg.de and edited by in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio standards. Those intending to use this software module in hardware or software products are advised that this use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-2 NBC/MPEG-4 Audio conforming products. The original developer retains full right to use the code for his/her own purpose, assign or donate the code to a third party and to inhibit third party from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice must be included in all copies or derivative works. Copyright (c) 1997. file: plotmtv_interv.c$Id: plotmtv_interf.c,v 1.9 1999/05/20 17:10:29 purnhage Exp $ Authors: tmn Bodo Teichmann tmn@iis.fhg.de HP Heiko Purnhagen purnhage@tnt.uni-hannover.de Changes: xx-apr-97 BT contributed to VM 22-may-97 HP added abs(real,imag) MTV_CPLXFLOAT plotDirect("",MTV_CPLXFLOAT,npts,re1,im1,re2,im2)**********************************************************************//* plotmtv_interf.c is just a C interface to the freeware program plotmtv, which *//* is a graphical data-display program for X-windows with a nice user interface. *//* with this C interface it can be used to display 1-dim arrays (eg. the mdct spectrum) *//* directly from the debugger while debugging with the gdb command 'call plotDirect("",MTV_DOUBLE,npts,array1,array2,array3,array4). *//* it is very very usefull for debugging; please do not remove the interface files from the VM frame work *//* i will sent an executable (sgi,linux,solaris,sunos) of plotmtv to everybody who wants to use it *//* the source is available from ftp://ftp.th-darmstadt.de/pub/X11/contrib/applications/Plotmtv1.4.1.tar.Z and other ftp sites */#include <stdio.h>#include <string.h>#include <unistd.h>#include <stdarg.h> /* variable artgument list */#include <stdlib.h>#include <sys/wait.h>#include <sys/stat.h>#include <fcntl.h>#include <math.h>#include "plotmtv.h"#include "common_m4a.h"/**** user changable options : *******************************/#define PRINTER_OPT "-Pml6" /* should be set to -Pprinter_name eg: -Pml6 */#define PLOTSET_PRAEF0 "/tmp/" /* 1st praefix for plotset files , should be /tmp/ */#define PLOTSET_PRAEF1 "/tmp/_"/* 2nd praefix for plotset files , should be /tmp/_ */#define BG_COLOR "black" /* background color */#define ERR_FNAME "plotmtv.err"#define LOG_FNAME "plotmtv.log"static char plotFileName[1024]="plotmtv.rc"; /* name of the control file, could be changed from commandline options of user programm */static int plotPaperPlot = 0; /* for colour plot set to 0, for monochrom set to 1 , than the lines are plotted with markers*/ int plotChannel = 0; /* channel number that shall be displayed , is used only in the user programm */static int enable_plotmtv = 0 ; /* if set to zero plotmtv is switched off */int firstFrame = 9999;int framePlot = 0; /* from user program , only used to display the frame and granule number *//* these defines set the window geometry: X-pixel x Y-pixel + X-offset + Y-offset */#define WIN_GEOM_1 "750x600+1+1" #define WIN_GEOM_2 "750x600+1+1"#define WIN_GEOM_3 "750x900+1+1"#if 0 #define WIN_GEOM_4 "1000x700+0+0"#define WIN_GEOM_5 "1000x700+0+0"#define WIN_GEOM_6 "1000x700+0+0"#else#define WIN_GEOM_4 "1100x600+1+1"#define WIN_GEOM_5 "1200x980+1+1"#define WIN_GEOM_6 "1200x980+1+1"#endif/**** user changable options end ******************************/static char errorFilename[]= ERR_FNAME ;static char logFilename[]= LOG_FNAME ;static char* plotsetPreafix = PLOTSET_PRAEF0;/* error handling : */#define ACTIV 1#define DELETED 0#define TRUE 1#define FALSE 0#define STRING_SIZE 1024#define DISAB_MESS 0x00001#define INIT_ERROR 0x00002#define INV_DATAFORMAT 0x00003#define FILE_MISSING 0x00004#define WRITE_BIN 0x00005#define FATAL_ERROR 0x00006#define FOR_TESTING 0x00012#define MESSAGE1 0x00013#define FORK_FAILED 0x00014#define PLOT_RC 0x00015/* static ERROR_MESSAGE err_mess[ ] = *//* { *//* {DISAB_MESS,"\n The resource file '%s' does not exist, plotmtv disabled "}, *//* {INIT_ERROR,"\n Initialisation error while reading resource file in mplot"}, *//* {INV_DATAFORMAT,"\n Invalid data format for plotmtv"}, *//* {FILE_MISSING ,"\n File %s missing for plotmtv"}, *//* {WRITE_BIN,"\n Error while writing binary datafile for plotmtv"}, *//* {FATAL_ERROR,"\n Fatal error in plotmtv"}, *//* {FORK_FAILED,"\n no childprocess could be created"}, *//* {PLOT_RC,"\n warning: syntax error in resource file"}, *//* {0xFF,""} end of list */ /* }; *//* ERRORHANDLER2(RECOVER, FOR_TESTING , _LOOPS_C, err_mess, "test", "west"); ERRORHANDLER(MESSAGE, MESSAGE1 , _LOOPS_C, err_mess, "test"); ERRORHANDLER(RECOVER, TEST , _LOOPS_C, err_mess, "test"); ERRORHANDLER(RESET, TEST , _LOOPS_C, err_mess, "test");*/#define SQR(a) ((a)*(a))static int plotsetCnt;static struct adressmodel { char plot_set[STRING_SIZE]; /* name of plot_set */ long fpos; /* file pos of add commands is recource file */ struct adressmodel *next; /* pointer to next dataset*/ } *adress_ptr = NULL, *amark_ptr = NULL; typedef struct location { FILE *fp; int current_lcolor, status; char bin_filename[32];} locationStruct; static struct filelist { locationStruct data; struct filelist *next;} *fbegin_ptr = NULL, *fnew_ptr = NULL;static struct filelist file_list_start={ {NULL,0x0,0x0,""},NULL};static struct adressmodel adress_list_start={"",0x0,NULL};static FILE *ControlScript=NULL;static void adrSave(char buffer[], int strpos, int length, long fpos){ int mark; char plot_set[STRING_SIZE]=""; for (mark = strpos; strpos < length; strpos++) plot_set[strpos-mark] = buffer[strpos]; adress_ptr = (struct adressmodel*)malloc (sizeof(struct adressmodel)); adress_ptr->fpos = fpos; strcpy(adress_ptr->plot_set,plot_set); adress_ptr->next = amark_ptr->next; amark_ptr->next = adress_ptr;}static int search(char plot_set[]){ int not_found ; char filename[STRING_SIZE]; not_found = 1 ; strcpy(filename, plotsetPreafix); strcat(filename,plot_set); if (fbegin_ptr->next != NULL) { fnew_ptr = fbegin_ptr->next; while (fnew_ptr != NULL) { not_found = strcmp(fnew_ptr->data.bin_filename, filename); /* 0 if equal */ if ( (not_found != 0) && (fnew_ptr->next != NULL) ) /* found */ fnew_ptr = fnew_ptr->next; else if ( (not_found == 0) || (fnew_ptr->next == NULL) ) break; } } return not_found;}int plotInit(int frameL){ char plot_set[STRING_SIZE], line[STRING_SIZE]; char tmpString[1024]; int counter; struct filelist *fdel_ptr; struct adressmodel *adel_ptr; if (frameL>firstFrame) enable_plotmtv=1; else enable_plotmtv=0; if (enable_plotmtv) { plotsetCnt=0; fbegin_ptr = &file_list_start; if (ControlScript!=0) fclose (ControlScript); /* don't forget to close !! */ if (( ControlScript = fopen(plotFileName, "r")) == NULL){ strcpy(tmpString,plotFileName); strcpy(plotFileName,"../"); strcat(plotFileName,tmpString); if (( ControlScript = fopen(plotFileName, "r")) == NULL) { enable_plotmtv = 0; /* ERRORHANDLER(MESSAGE,DISAB_MESS,_PLOTMTV_INTERF_C,err_mess,plotFileName); */ } } if (ControlScript != NULL) { /*delete filelist */ while (fbegin_ptr->next != NULL) { fdel_ptr = fbegin_ptr->next; fbegin_ptr->next = (fbegin_ptr->next)->next; free (fdel_ptr); } amark_ptr = &adress_list_start; while (amark_ptr->next != NULL) { adel_ptr = amark_ptr->next; amark_ptr->next = (amark_ptr->next)->next; free (adel_ptr); } /*to do: copy control script to a tempor. file to ensure that the file positions are not changed by editing */ while (!feof(ControlScript)) { fscanf(ControlScript, "%1024[^\n]\n", line); for (counter = 0; counter < (int)strlen(line); counter++) { if (line[counter] == '#') /* Die Kommandozeile ist ein Kommentar-> Abbruch */ break; if (line[counter] == ':') /* Name des Plotsets */ { counter++; sscanf(&(line[counter]),"%1024[^# \f\n\r\t\v]",plot_set); if (ftell(ControlScript) != -1L) { if (strlen(plot_set) < 2) CommonExit(-1,"\nplotmtv error");/* ERRORHANDLER(RESET,INIT_ERROR,_PLOTMTV_INTERF_C,err_mess," "); */ adrSave(plot_set, 0, strlen(plot_set), ftell(ControlScript)); break; } else if ( ftell(ControlScript) == -1L) {/* ERRORHANDLER(MESSAGE,INIT_ERROR,_PLOTMTV_INTERF_C,err_mess," "); */ } } } /* end of for */ } /* end of while */ rewind(ControlScript); /* statt fclose */ } } return 0;}int plotSend(char legend[], char plot_set[], enum DATA_TYPE dtype, long npts, const void *dataPtr, const void *dataPtr2){ char buffer[STRING_SIZE], line[STRING_SIZE],keyword[STRING_SIZE]; int found = FALSE, length,endFound; long counter; double *x, *y; if (enable_plotmtv){ if (npts > 0) { x = (double *)malloc(npts*sizeof(double)); y = (double *)malloc(npts*sizeof(double)); if (dtype==MTV_DOUBLE) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -