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

📄 pf_alloc.c

📁 LastWave
💻 C
📖 第 1 页 / 共 3 页
字号:
  if(lwpf->nRef > 0) return;  PFDelete(lwpf->pf);#ifdef DEBUGALLOC  DebugType = "Pf";#endif  Free(lwpf);}/* * Make some desallocation on a partition function. * * Doesn't do anything yet: the corresponding  * modification as to be done in pf_lib.c */ void ClearPartitionFunction(LWPARTFUNC lwpf){  }	    /***************************************************************************** * *  Misc functions on LWPARTFUNC * *****************************************************************************//* * Copy a LWPARTFUNC into another  */LWPARTFUNC CopyPartitionFunction(LWPARTFUNC in,LWPARTFUNC out){  /* Tests*/  if (in == NULL) return(NULL);  if (out == NULL) out = NewPartitionFunction();  if (in == out) return(out);  PFDelete(out->pf);  out->pf = PFCopy(in->pf);  if(out->pf == NULL) {    SetErrorf("CopyPartitionFunction(): "	      "You must have tried to copy a non initialized PF.");    return(NULL);  }    return(out);}/* * 'method' field */static char *methodDoc ="{[= <method>]} ""{Sets/Gets the method of a partition function i.e. the type of  wavelet ""transform that was originally performed.\n""(This field is used to avoid adding two pfs computed using different ""wavelets.)}";/* Manu : Comment dois je gerer l'allocation memoire de methode pour les   get/set suivant ?*/static void *GetMethodPFV(VALUE val, void **arg){  static char method[PFMETHODSIZE+1];  /* Documentation */  if (val == NULL)     return(methodDoc);        PFGetMethod( ((LWPARTFUNC) val)->pf, method );    return( GetStrField(method,arg) );}static void * SetMethodPFV(VALUE val, void **arg){  LWPARTFUNC lwpf = (LWPARTFUNC) val;  char *method;  void *setRes;  int res;  /* doc */  if (val == NULL)    return(methodDoc);  method = CharAlloc(PFMETHODSIZE+1);  PFGetMethod( ((LWPARTFUNC) val)->pf, method );  if( (setRes = SetStrField(&(method),arg)) == NULL ) {    Free(method);    return(NULL);  }    res = PFSetMethod(lwpf->pf,method);  Free(method);  if(res != PFYes) {    SetErrorf("Problem while writing (%s), maybe string is to long",method);    return(NULL);  }  return(setRes);}/* * 'amin' field */static char *aminDoc = "{[= <amin>]} ""{Sets/Gets the smallest scale of the partition function.}";static void * GetAminPFV(VALUE val, void **arg){  /* Documentation */  if (val == NULL)    return(aminDoc);    return(GetFloatField(		  (LWFLOAT) PFGetAMin( ((LWPARTFUNC) val)->pf )		  ,arg)	 );}static void * SetAminPFV(VALUE val, void **arg){  LWFLOAT amin;  int res;  void *setRes;  /* Documentation */  if (val == NULL)    return(aminDoc);  amin = PFGetAMin( ((LWPARTFUNC) val)->pf );  if( (setRes = SetFloatField(&amin,arg,FieldSPositive)) == NULL )    return(NULL);  res = PFSetAMin( ((LWPARTFUNC) val)->pf,amin);  if(res != PFYes) {    SetErrorf("weird: Problem while writing aMin, maybe it was <= 0");    return(NULL);  }  return(setRes);}/* * 'noct' field */static char *noctDoc ="{} {Gets the number of octaves of a partition function.\n""(Your are not allowed to modify the octave number.)}";static void * GetNOctPFV(VALUE val, void **arg){  /* Documentation */  if (val == NULL)    return(noctDoc);    return(GetIntField( 		PFGetOctaveNumber( ((LWPARTFUNC) val)->pf )		,arg		)	 );}/* * 'nvoice' field */static char *nvoiceDoc ="{} {Gets the number of voices per octave of a partition function.\n""(Your are not allowed to modify the voice number.)}";static void * GetNVoicePFV(VALUE val, void **arg){  /* Documentation */  if (val == NULL)    return(nvoiceDoc);    return(GetIntField( 		PFGetVoiceNumber( ((LWPARTFUNC) val)->pf )		,arg		)	 );}/* * 'nscale' field */static char *nscaleDoc ="{} {Gets the number of computed scales of the partition function.\n""(Your are not allowed to modify this field.)}";static void * GetNScalePFV(VALUE val, void **arg){  /* Documentation */  if (val == NULL)    return(nscaleDoc);    return(GetIntField( 		PFGetIndexMax( ((LWPARTFUNC) val)->pf ) + 1		,arg		)	 );}/* * 'sigsize' field */static char *sigsizeDoc ="{[= <signal size>]} ""{Sets/Gets the size of the original signals"" on which were computed the partition functions.\n""(In the case you used the non standard addition, it is the sum of these ""fields. So, if you use the non standard addition on pfs that were the ""result of standard addition this field is not correct).} ";static void * GetSigSizePFV(VALUE val, void **arg){  /* Documentation */  if (val == NULL)    return(sigsizeDoc);    return(GetIntField( 		PFGetSignalSize( ((LWPARTFUNC) val)->pf )		,arg		)	 );}static void * SetSigSizePFV(VALUE val, void **arg){  int sigsize;  int res;  void *setRes;  /* Documentation */  if (val == NULL)    return(sigsizeDoc);  sigsize = PFGetSignalSize( ((LWPARTFUNC) val)->pf );  if( (setRes = SetIntField(&sigsize,arg,FieldSPositive)) == NULL )    return(NULL);  res = PFSetSignalSize( ((LWPARTFUNC) val)->pf,sigsize);  if(res != PFYes) {    SetErrorf("weird: Problem while writing sigzize, maybe it was <= 0");    return(NULL);  }  return(setRes);}/* * 'signum' field */static char *signumDoc ="{} ""{Gets the number of signals that were used to compute the partition ""functions.\n""(Your are not allowed to modify this field.)}";static void * GetSigNumPFV(VALUE val, void **arg){  /* Documentation */  if (val == NULL)    return(signumDoc);    return(GetIntField( 		PFGetSignalNumber( ((LWPARTFUNC) val)->pf )		,arg		)	 );}/* * 'qnumber' field */static char *qnumberDoc ="{} {Gets the number of q on which were computed the partition functions.\n""(Your are not allowed to modify this field.)}";static void * GetQNumberPFV(VALUE val, void **arg){  /* Documentation */  if (val == NULL)    return(qnumberDoc);    return(GetIntField( 		PFGetQNumber( ((LWPARTFUNC) val)->pf )		,arg		)	 );}/* * 'qlist' field */static char *qlistDoc ="{[= <listv of q values>]} {Sets/Gets the qList for which the partition ""functions have been computed.\n""WARNING: when you set a new qList it erases all the previous results.}";static void * GetQListPFV(VALUE val, void **arg){  LISTV lvq;    /* Documentation */  if (val == NULL)    return(qlistDoc);    if( ( lvq = PF2ListvQ((LWPARTFUNC) val) ) == NULL )    return(NULL);  return(GetValueField(lvq,arg));}static void * SetQListPFV(VALUE val, void **arg){  LISTV lvq;  int res;  void *setRes;  double *qArray;  /* Documentation */  if (val == NULL)    return(qlistDoc);  if( ( lvq = PF2ListvQ((LWPARTFUNC) val) ) == NULL ) {    return(NULL);  }  if( (setRes = SetListvField(&lvq,arg)) == NULL ) {    return(NULL);  }  if( (qArray = PFListv2QArray(lvq)) == NULL ) {    return(NULL);  }  res = PFSetQList( ((LWPARTFUNC) val)->pf,		    lvq->length,qArray);  if(res != PFYes) {    SetErrorf("Problem while writing new qlist, "	      "it is very likely that either two q values where equal "	      "that the PF has not been initialized.");    return(NULL);  }  return(setRes);}/* * 'dim' field */static char *dimDoc ="{[= <dimension>]} ""{Sets/Gets the dimension of the original data (1 for signal 2 for images) ""on which were computed the partition functions.}";static void * GetDimPFV(VALUE val, void **arg){  /* Documentation */  if (val == NULL)    return(dimDoc);    return(GetIntField( 		PFGetDimension( ((LWPARTFUNC) val)->pf )		,arg		)	 );}static void * SetDimPFV(VALUE val, void **arg){  int dim;  int res;  void *setRes;  /* Documentation */  if (val == NULL)    return(dimDoc);  dim = PFGetDimension( ((LWPARTFUNC) val)->pf );  if( (setRes = SetIntField(&dim,arg,FieldSPositive)) == NULL )    return(NULL);  res = PFSetDimension( ((LWPARTFUNC) val)->pf,dim);  if(res != PFYes) {    SetErrorf("Problem while writing dimension, maybe it was <= 0 "	      "or lwpf->pf was NULL (that would be weird!).");    return(NULL);  }  return(setRes);}/**************************************************************************** * *  partition function and variables * ****************************************************************************//* * Various actions on partition_function */ void C_Pf(char **argv){  char *action;  argv = ParseArgv(argv,tWORD,&action,-1);    if (!strcmp(action,"init"))    {      LWPARTFUNC lwpf;      LISTV lv;      char *method;      double *qArray;      LWFLOAT aMin;      int octaveNumber,voiceNumber,size,res;            argv = ParseArgv(argv,tPF,&lwpf,tSTR,&method,		       tFLOAT,&aMin,tINT,&octaveNumber,tINT,&voiceNumber,		       tINT,&size,tLISTV,&lv,0);            if( (qArray = PFListv2QArray(lv)) == NULL )	Errorf1("");            res = PFInit(lwpf->pf,method,		   aMin,octaveNumber,voiceNumber,		   size,1,lv->length,qArray);            switch(res)	{	case PFYes:	  SetResultInt(res);	  break;	case PFNotValid:	  Errorf("One of the parameter isn\'t valid");	  break;	default:	  Errorf("serious error. (maybe the pointer lwpf->pf was NULL)");	  }    }  /* 'do1Scale' action */  else if (!strcmp(action,"do1Scale"))    {      LWPARTFUNC lwpf;      SIGNAL signal;      LWFLOAT *Y;      int octaveNumber,voiceNumber,scale,res,size;      int flagMinimalSort;      char opt;      argv = ParseArgv(argv,tPF,&lwpf,tSIGNALI,&signal,		       tINT_,-999,&octaveNumber,-1);      if(octaveNumber != -999)	{	  argv = ParseArgv(argv,tINT,&voiceNumber,-1);	  if( !INRANGE(1,octaveNumber,PFGetOctaveNumber(lwpf->pf)) )	    Errorf("Bad range for oct");	  if(!INRANGE(0,voiceNumber,PFGetVoiceNumber(lwpf->pf)-1) )	    Errorf("Bad range for voice");	  	  scale = (octaveNumber -1)*PFGetVoiceNumber(lwpf->pf) + voiceNumber;	}      else

⌨️ 快捷键说明

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