Exemplo n.º 1
0
void setkeystar(unsigned char *bits)
{
	int i,j;

	for (i=0;i<28;i++)
		CCC[0][i]=bits[pc_1_c[i]-1];
	for (i=0;i<28;i++)
		D[0][i]=bits[pc_1_d[i]-1];
	for (j=0;j<16;j++)
	{
		LS(CCC[j],CCC[j+1],ls_count[j]);
		LS(D[j],D[j+1],ls_count[j]);
		son(CCC[j+1],D[j+1],K[j+1]);
	}
}
Exemplo n.º 2
0
Arquivo: exec.c Projeto: Vuldo/42sh
int             my_exec(t_sh *sh, char *path)
{
  pid_t         pid;

  if (sh->actual->parent != NULL
      && (sh->actual->parent->fd[0] < 0 || sh->actual->parent->fd[1] < 0))
    return (0);
  pid = fork();
  if (pid == 0)
    son(sh, path);
  else if (pid > 0)
    dad(sh, pid);
  else
    my_printf("%s: Fork failed\n", sh->av[0]);
  return (0);
}
double C45PruneableClassifierTree::getTrainingErrors()
{
	double errors = 0;
	int i;

	if (m_isLeaf)
	{
		return localModel()->distribution()->numIncorrect();
	}
	else{
		for (i=0;i<m_sonsLength;i++)
		{
			errors = errors+son(i)->getTrainingErrors();
		}
		return errors;
	}
}
/**
      \fn    LookupMainAtoms
      \brief Search main atoms to ease job for other part
*/
uint8_t     MP4Header::lookupMainAtoms(void *ztom)
{
  
  adm_atom *tom=(adm_atom *)ztom;
  adm_atom *moov;
  ADMAtoms id;
  uint32_t container;
  printf("Analyzing file and atoms\n");
  if(!ADM_mp4SimpleSearchAtom(tom, ADM_MP4_MOOV,&moov))
  {
       adm_printf(ADM_PRINT_ERROR,"Cannot locate moov atom\n");
       return 0;
  }
  ADM_assert(moov);
  while(!moov->isDone())
  {
    adm_atom son(moov);
    if(!ADM_mp4SearchAtomName(son.getFCC(), &id,&container))
    {
      adm_printf(ADM_PRINT_DEBUG,"Found atom %s unknown\n",fourCC::tostringBE(son.getFCC()));
    }
    else
    {
      switch( id)
      {
        case ADM_MP4_MVHD: parseMvhd(&son);break; 
        case ADM_MP4_TRACK: 
            if(!parseTrack(&son))
            {
                printf("Parse Track failed\n");
            } ;
            break;
        default : 
                adm_printf(ADM_PRINT_DEBUG,"atom %s not handled\n",fourCC::tostringBE(son.getFCC()));
                break;
      }
      
      
    }
    son.skipAtom();
  }
  delete moov;
  printf("Done finding main atoms\n");
  return 1;
}
void C45PruneableClassifierTree::collapse()
{
	double errorsOfSubtree;
	double errorsOfTree;
	int i;

	if (!m_isLeaf)
	{
		errorsOfSubtree = getTrainingErrors();
		errorsOfTree = localModel()->distribution()->numIncorrect();
		if (errorsOfSubtree >= errorsOfTree-1E-3){

			// Free adjacent trees
			clearSubtrees();
			m_isLeaf = true;

			// Get NoSplit Model for tree.
			m_localModel = new NoSplit(localModel()->distribution());
		}else{
			for (i=0;i<m_sonsLength;i++)
				son(i)->collapse();
		}
	}
}
Exemplo n.º 6
0
/*
 * Parse a configuration file and return a linked list of all the logs
 * to process
 */
struct conf_entry *
parse_file(int *nentries)
{
	char line[BUFSIZ], *parse, *q, *errline, *group, *tmp, *ep;
	struct conf_entry *working = NULL, *first = NULL;
	struct passwd *pwd;
	struct group *grp;
	struct stat sb;
	int lineno;
	FILE *f;
	long l;

	if (strcmp(conf, "-") == 0)
		f = stdin;
	else if ((f = fopen(conf, "r")) == NULL)
		err(1, "can't open %s", conf);

	*nentries = 0;
	for (lineno = 1; fgets(line, sizeof(line), f); lineno++) {
		tmp = sob(line);
		if (*tmp == '\0' || *tmp == '#')
			continue;
		errline = strdup(tmp);
		if (errline == NULL)
			err(1, "strdup");
		(*nentries)++;
		if (!first) {
			working = malloc(sizeof(struct conf_entry));
			if (working == NULL)
				err(1, "malloc");
			first = working;
		} else {
			working->next = malloc(sizeof(struct conf_entry));
			if (working->next == NULL)
				err(1, "malloc");
			working = working->next;
		}

		q = parse = missing_field(sob(line), errline, lineno);
		*(parse = son(line)) = '\0';
		working->log = strdup(q);
		if (working->log == NULL)
			err(1, "strdup");

		if ((working->logbase = strrchr(working->log, '/')) != NULL)
			working->logbase++;

		q = parse = missing_field(sob(++parse), errline, lineno);
		*(parse = son(parse)) = '\0';
		if ((group = strchr(q, ':')) != NULL ||
		    (group = strrchr(q, '.')) != NULL)  {
			*group++ = '\0';
			if (*q) {
				if (!(isnumberstr(q))) {
					if ((pwd = getpwnam(q)) == NULL)
						errx(1, "%s:%d: unknown user: %s",
						    conf, lineno, q);
					working->uid = pwd->pw_uid;
				} else
					working->uid = atoi(q);
			} else
				working->uid = (uid_t)-1;
			
			q = group;
			if (*q) {
				if (!(isnumberstr(q))) {
					if ((grp = getgrnam(q)) == NULL)
						errx(1, "%s:%d: unknown group: %s",
						    conf, lineno, q);
					working->gid = grp->gr_gid;
				} else
					working->gid = atoi(q);
			} else
				working->gid = (gid_t)-1;
			
			q = parse = missing_field(sob(++parse), errline, lineno);
			*(parse = son(parse)) = '\0';
		} else {
			working->uid = (uid_t)-1;
			working->gid = (gid_t)-1;
		}

		l = strtol(q, &ep, 8);
		if (*ep != '\0' || l < 0 || l > ALLPERMS)
			errx(1, "%s:%d: bad permissions: %s", conf, lineno, q);
		working->permissions = (mode_t)l;

		q = parse = missing_field(sob(++parse), errline, lineno);
		*(parse = son(parse)) = '\0';
		l = strtol(q, &ep, 10);
		if (*ep != '\0' || l < 0 || l >= INT_MAX)
			errx(1, "%s:%d: bad number: %s", conf, lineno, q);
		working->numlogs = (int)l;

		q = parse = missing_field(sob(++parse), errline, lineno);
		*(parse = son(parse)) = '\0';
		if (isdigit(*q))
			working->size = atoi(q) * 1024;
		else
			working->size = -1;
		
		working->flags = 0;
		q = parse = missing_field(sob(++parse), errline, lineno);
		*(parse = son(parse)) = '\0';
		l = strtol(q, &ep, 10);
		if (l < 0 || l >= INT_MAX)
			errx(1, "%s:%d: interval out of range: %s", conf,
			    lineno, q);
		working->hours = (int)l;
		switch (*ep) {
		case '\0':
			break;
		case '@':
			working->trim_at = parse8601(ep + 1);
			if (working->trim_at == (time_t) - 1)
				errx(1, "%s:%d: bad time: %s", conf, lineno, q);
			working->flags |= CE_TRIMAT;
			break;
		case '$':
			working->trim_at = parseDWM(ep + 1);
			if (working->trim_at == (time_t) - 1)
				errx(1, "%s:%d: bad time: %s", conf, lineno, q);
			working->flags |= CE_TRIMAT;
			break;
		case '*':
			if (q == ep)
				break;
			/* FALLTHROUGH */
		default:
			errx(1, "%s:%d: bad interval/at: %s", conf, lineno, q);
			break;
		}

		q = sob(++parse);	/* Optional field */
		if (*q == 'Z' || *q == 'z' || *q == 'B' || *q == 'b' ||
		    *q == 'M' || *q == 'm') {
			*(parse = son(q)) = '\0';
			while (*q) {
				switch (*q) {
				case 'Z':
				case 'z':
					working->flags |= CE_COMPACT;
					break;
				case 'B':
				case 'b':
					working->flags |= CE_BINARY;
					break;
				case 'M':
				case 'm':
					working->flags |= CE_MONITOR;
					break;
				case 'F':
				case 'f':
					working->flags |= CE_FOLLOW;
					break;
				default:
					errx(1, "%s:%d: illegal flag: `%c'",
					    conf, lineno, *q);
					break;
				}
				q++;
			}
		} else
			parse--;	/* no flags so undo */

		working->pidfile = PIDFILE;
		working->signal = SIGHUP;
		working->runcmd = NULL;
		working->whom = NULL;
		for (;;) {
			q = parse = sob(++parse);	/* Optional field */
			if (q == NULL || *q == '\0')
				break;
			if (*q == '/') {
				*(parse = son(parse)) = '\0';
				if (strlen(q) >= MAXPATHLEN)
					errx(1, "%s:%d: pathname too long: %s",
					    conf, lineno, q);
				working->pidfile = strdup(q);
				if (working->pidfile == NULL)
					err(1, "strdup");
			} else if (*q == '"' && (tmp = strchr(q + 1, '"'))) {
				*(parse = tmp) = '\0';
				if (*++q != '\0') {
					working->runcmd = strdup(q);
					if (working->runcmd == NULL)
						err(1, "strdup");
				}
				working->pidfile = NULL;
				working->signal = -1;
			} else if (strncmp(q, "SIG", 3) == 0) {
				int i;

				*(parse = son(parse)) = '\0';
				for (i = 1; i < NSIG; i++) {
					if (!strcmp(sys_signame[i], q + 3)) {
						working->signal = i;
						break;
					}
				}
				if (i == NSIG)
					errx(1, "%s:%d: unknown signal: %s",
					    conf, lineno, q);
			} else if (working->flags & CE_MONITOR) {
				*(parse = son(parse)) = '\0';
				working->whom = strdup(q);
				if (working->whom == NULL)
					err(1, "strdup");
			} else
				errx(1, "%s:%d: unrecognized field: %s",
				    conf, lineno, q);
		}
		free(errline);

		if ((working->flags & CE_MONITOR) && working->whom == NULL)
			errx(1, "%s:%d: missing monitor notification field",
			    conf, lineno);

		/* If there is an arcdir, set working->backdir. */
		if (arcdir != NULL && working->logbase != NULL) {
			if (*arcdir == '/') {
				/* Fully qualified arcdir */
				working->backdir = arcdir;
			} else {
				/* arcdir is relative to log's parent dir */
				*(working->logbase - 1) = '\0';
				if ((asprintf(&working->backdir, "%s/%s",
				    working->log, arcdir)) == -1)
					err(1, "malloc");
				*(working->logbase - 1) = '/';
			}
			/* Ignore arcdir if it doesn't exist. */
			if (stat(working->backdir, &sb) != 0 ||
			    !S_ISDIR(sb.st_mode)) {
				if (working->backdir != arcdir)
					free(working->backdir);
				working->backdir = NULL;
			}
		} else
			working->backdir = NULL;

		/* Make sure we can't oflow MAXPATHLEN */
		if (working->backdir != NULL) {
			if (snprintf(line, sizeof(line), "%s/%s.%d%s",
			    working->backdir, working->logbase,
			    working->numlogs, COMPRESS_POSTFIX) >= MAXPATHLEN)
				errx(1, "%s:%d: pathname too long: %s",
				    conf, lineno, q);
		} else {
			if (snprintf(line, sizeof(line), "%s.%d%s",
			    working->log, working->numlogs, COMPRESS_POSTFIX)
			    >= MAXPATHLEN)
				errx(1, "%s:%d: pathname too long: %s",
				    conf, lineno, working->log);
		}
	}
	if (working)
		working->next = NULL;
	(void)fclose(f);
	return (first);
}
/**
        \fn parseStbl
        \brief parse sample table. this is the most important function.
*/
uint8_t       MP4Header::parseStbl(void *ztom,uint32_t trackType,uint32_t w,uint32_t h,uint32_t trackScale)
{
  adm_atom *tom=(adm_atom *)ztom;
  ADMAtoms id;
  uint32_t container;
  MPsampleinfo  info;
  
  
  memset(&info,0,sizeof(info));

  
  printf("<<Parsing Stbl>>\n");
  while(!tom->isDone())
  {
     adm_atom son(tom);
     if(!ADM_mp4SearchAtomName(son.getFCC(), &id,&container))
     {
       adm_printf(ADM_PRINT_DEBUG,"[STBL]Found atom %s unknown\n",fourCC::tostringBE(son.getFCC()));
       son.skipAtom();
       continue;
     }
     switch(id)
     {
       case ADM_MP4_STSS:  // Sync sample atom (i.e. keyframes)
       {
          son.read32();
          info.nbSync=son.read32();
          printf("Stss:%u\n",info.nbSync);
          if(info.nbSync)
          {
                  info.Sync=new uint32_t[info.nbSync];
                  for(int i=0;i<info.nbSync;i++)
                  {
                          info.Sync[i]=son.read32();
                  }
          }
          break;
         
       }
       case ADM_MP4_STTS: 
            {
                printf("stts:%lu\n",son.read32()); // version & flags
                info.nbStts=son.read32();
                printf("Time stts atom found (%lu)\n",info.nbStts);
                printf("Using myscale %lu\n",trackScale);
                info.SttsN=new uint32_t[info.nbStts];
                info.SttsC=new uint32_t[info.nbStts];
                double dur;
                for(int i=0;i<info.nbStts;i++)
                {
                        
                        info.SttsN[i]=son.read32();
                        info.SttsC[i]=son.read32();
                        adm_printf(ADM_PRINT_VERY_VERBOSE,"stts: count:%u size:%u (unscaled)\n",info.SttsN[i],info.SttsC[i]);	
                        //dur*=1000.*1000.;; // us
                        //dur/=myScale;
                }                
            }
            break;
       case ADM_MP4_STSC:
            {
                son.read32();
                info.nbSc=son.read32();
                info.Sc=new uint32_t[info.nbSc];
                info.Sn=new uint32_t[info.nbSc];
                for(int j=0;j<info.nbSc;j++)
                {

                        info.Sc[j]=son.read32();
                        info.Sn[j]=son.read32();
                        son.read32();
                        adm_printf(ADM_PRINT_VERY_VERBOSE,"\t sc  %d : sc start:%u sc count: %u\n",j,info.Sc[j],info.Sn[j]);
                }

            }
            break;
       case ADM_MP4_STSZ:
          {
            uint32_t n;
              son.read32();
              n=son.read32();
              info.nbSz=son.read32();
              info.SzIndentical=0;
              printf("%lu frames /%lu nbsz..\n",n,info.nbSz);
              if(n)
                      {
                            adm_printf(ADM_PRINT_VERY_VERBOSE,"\t\t%lu frames of the same size %lu , n=%lu\n",
                                info.nbSz,info.SzIndentical,n);
                            info.SzIndentical=n;
                            info.Sz=NULL;
                      }
              else
              {
                      info.Sz=new uint32_t[info.nbSz];
                      for(int j=0;j<info.nbSz;j++)
                      {
                                      info.Sz[j]=son.read32();
                      }
              }
          }
          break;
           case ADM_MP4_CTTS: // Composition time to sample             
            {
                uint32_t n,i,j,k,v;
                
                  printf("ctts:%lu\n",son.read32()); // version & flags
                  n=son.read32();
                  if(n==1) // all the same , ignore
                  {
                    break;
                  }
                uint32_t *values=new uint32_t [n];
                uint32_t *count=new uint32_t [n];
                for(i=0;i<n;i++)
                {
                    count[i]=son.read32();
                    values[i]=son.read32();
                }
                uint32_t sum=0;
                for(i=0;i<n;i++)
                {
                    sum+=count[i];
                }
                info.Ctts=new uint32_t[sum+1]; // keep a safe margin
                
                for(i=0;i<n;i++)
                {
                    if(i<20)
                    {
                        adm_printf(ADM_PRINT_VERY_VERBOSE,"Ctts: nb: %u (%x) val:%u (%x)\n",count[i],count[i],values[i],values[i]);   
                    }
                    for(k=0;k<count[i];k++)
                    {
                        info.Ctts[info.nbCtts++]=values[i];
                    }
                }
                delete [] values;
                delete [] count;
                if(!info.nbCtts)
                {
                    delete [] info.Ctts;
                    info.Ctts=NULL;
                    printf("Destroying Ctts, seems invalid\n");
                }
                ADM_assert(info.nbCtts<sum+1);
                printf("Found %u elements\n",info.nbCtts);
            }
            break;  
       case ADM_MP4_STCO:
       {
          son.read32();
          info.nbCo=son.read32();
          printf("\t\tnbCo:%u\n",info.nbCo);
          info.Co=new uint32_t[info.nbCo];
          for(int j=0;j< info.nbCo;j++)
          {
                  info.Co[j]=son.read32();
                  adm_printf(ADM_PRINT_VERY_VERBOSE,"Chunk offset : %u / %u  : %u\n",  j,info.nbCo,info.Co[j]);
          }

       }
       break;
       case ADM_MP4_STCO64:
       {
         printf("Incomplete support for 64 bits quicktime!!\n");
          son.read32();
          info.nbCo=son.read32();
          printf("\t\tnbCo:%u\n",info.nbCo);
          info.Co=new uint32_t[info.nbCo];
          for(int j=0;j< info.nbCo;j++)
          {
                  son.read32(); // Ignore MSB
                  info.Co[j]=son.read32();
                  adm_printf(ADM_PRINT_VERY_VERBOSE,"Chunk offset : %u / %u  : %lu\n",  j,info.nbCo,info.Co[j]);
          }

       }
       break;
       case ADM_MP4_STSD:
       {
                son.read32(); // flags & version
                int nbEntries=son.read32();
                int left;
                adm_printf(ADM_PRINT_DEBUG,"[STSD]Found %d entries\n",nbEntries);
                for(int i=0;i<nbEntries;i++)
                {
                   int entrySize=son.read32();
                   int entryName=son.read32();
                   left=entrySize-8;
                   if(i || (trackType==TRACK_VIDEO && _videoFound) || (trackType==TRACK_OTHER))
                   {
                    son.skipBytes(left); 
                    printf("[STSD] ignoring %s, size %u\n",fourCC::tostringBE(entryName),entrySize);
                    if(trackType==TRACK_OTHER) printf("[STSD] because track=other\n");
                    continue;
                   }
                   switch(trackType)
                   {
                     case TRACK_VIDEO:
                     {
                          uint32_t lw=0,lh=0;
                                printf("[STSD] VIDEO %s, size %u\n",fourCC::tostringBE(entryName),entrySize);
                                son.skipBytes(8);  // reserved etc..
                                left-=8;
                                son.read32(); // version/revision
                                left-=4;
                                printf("[STSD] vendor %s\n",fourCC::tostringBE(son.read32()));
                                left-=4;
                                
                                son.skipBytes(8); // spatial qual etc..
                                left-=8;
                                
                                printf("[STSD] width :%u\n",lw=son.read16());
                                printf("[STSD] height :%u\n",lh=son.read16());
                                left-=4;
                                
                                son.skipBytes(8); // Resolution
                                left-=8;
                                
                                printf("[STSD] datasize :%u\n",son.read32());
                                left-=4;
                     
                                printf("[STSD] FrameCount :%u\n",son.read16());
                                left-=4;
                                
                                // Codec name
                                uint32_t u32=son.read();
                                if(u32>31) u32=31;
                                printf("Codec string :%d <",u32);
                                for(int i=0;i<u32;i++) printf("%c",son.read());
                                printf(">\n");
                                son.skipBytes(32-1-u32);
                                left-=32;
                                // 
                                son.read32();
                                left-=4; //Depth & color Id
                                //
                                printf("LEFT:%d\n",left);
                                
                                if(left>8)
                                {
//                                  decodeVideoAtom(&son); 
                                }
                                //
#define commonPart(x)             _videostream.fccHandler=_video_bih.biCompression=fourCC::get((uint8_t *)#x);
                      

                                 _video_bih.biWidth=_mainaviheader.dwWidth=lw ; 
                                  _video_bih.biHeight=_mainaviheader.dwHeight=lh; 
                                  _video_bih.biCompression=_videostream.fccHandler;

                                //
                                switch(entryName)
                                {
                                  case MKFCCR('m','j','p','b'):  //mjpegb
                                  {
                                        commonPart(MJPB);
                                        left=0;
                                  }
                                  break;
                                case MKFCCR('s','2','6','3'):  //s263 d263
                                  {
                                        commonPart(H263);
                                         adm_atom d263(&son);
                                         printf("Reading s253, got %s\n",fourCC::tostringBE(d263.getFCC()));
                                          left=0;
                                  }
                                  break;
                                   case MKFCCR('m','p','4','v'):  //mp4v
                                  {
                                        commonPart(DIVX);
                                         adm_atom esds(&son);
                                         printf("Reading esds, got %s\n",fourCC::tostringBE(esds.getFCC()));
                                         if(esds.getFCC()==MKFCCR('e','s','d','s'))
                                              decodeEsds(&esds,TRACK_VIDEO);
                                          left=0;
                                  }
                                        break;
                                  case MKFCCR('S','V','Q','3'):
                                  {//'SVQ3':
                                    // For SVQ3, the codec needs it to begin by SVQ3
                                    // We go back by 4 bytes to get the 4CC
                                            printf("SVQ3 atom found\n");
                                            VDEO.extraDataSize=left+4;
                                            VDEO.extraData=new uint8_t[ VDEO.extraDataSize ];
                                            if(!son.readPayload(VDEO.extraData+4,VDEO.extraDataSize-4 ))
                                            {
                                              GUI_Error_HIG(QT_TR_NOOP("Problem reading SVQ3 headers"), NULL);
                                            }
                                            VDEO.extraData[0]='S';
                                            VDEO.extraData[1]='V';
                                            VDEO.extraData[2]='Q';
                                            VDEO.extraData[3]='3';
                                            printf("SVQ3 Header size : %lu",_videoExtraLen);
                                            commonPart(SVQ3);
                                            left=0;
                                  }
                                            break;
                                  case MKFCCR('d','v','c',' ') : //'dvc ':
                                  case MKFCCR('d','v','c','p'): //'dvcp':
                                          commonPart(DVDS);
                                          break;
                                  case MKFCCR('c','v','i','d'): //'cvid'
                                          commonPart(cvid);
                                          break;
                                  case MKFCCR('h','2','6','3'): //'dv':
                                          commonPart(H263);
                                          break;
                                  case MKFCCR('M','J','P','G'): //'jpeg':
                                  case MKFCCR('j','p','e','g'): //'jpeg':
                                  case MKFCCR('A','V','D','J'): //'jpeg':
                                          commonPart(MJPG);
                                          break;
                                  case MKFCCR('a','v','c','1'): // avc1
                                          {
                                          commonPart(H264);
                                          // There is a avcC atom just after
                                          // configuration data for h264
                                          adm_atom avcc(&son);
                                          printf("Reading avcC, got %s\n",fourCC::tostringBE(avcc.getFCC()));
                                          int len,offset;
                                          VDEO.extraDataSize=avcc.getRemainingSize();
                                          VDEO.extraData=new uint8_t [VDEO.extraDataSize];
                                          avcc.readPayload(VDEO.extraData,VDEO.extraDataSize);
                                          printf("avcC size:%d\n",VDEO.extraDataSize);
                                    // Dump some info
                                        #define MKD8(x) VDEO.extraData[x]
                                        #define MKD16(x) ((MKD8(x)<<8)+MKD8(x+1))
                                        #define MKD32(x) ((MKD16(x)<<16)+MKD16(x+2))

                                            printf("avcC Revision             :%x\n", MKD8(0));
                                            printf("avcC AVCProfileIndication :%x\n", MKD8(1));
                                            printf("avcC profile_compatibility:%x\n", MKD8(2));
                                            printf("avcC AVCLevelIndication   :%x\n", MKD8(3));
        
                                            printf("avcC lengthSizeMinusOne   :%x\n", MKD8(4));
                                            printf("avcC NumSeq               :%x\n", MKD8(5));
                                            len=MKD16(6);
                                            printf("avcC sequenceParSetLen    :%x ",len );
                                            offset=8;
                                            mixDump(VDEO.extraData+offset,len);
        
                                            offset=8+len;
                                            printf("\navcC numOfPictureParSets  :%x\n", MKD8(offset++));
                                            len=MKD16(offset++);
                                            printf("avcC Pic len              :%x\n",len);
                                            mixDump(VDEO.extraData+offset,len);
                                            left=0;
                                            }
                                            break;
                                  default:
                                            if(left>10)
                                            {
                                                adm_atom avcc(&son);
                                                printf("Reading , got %s\n",fourCC::tostringBE(avcc.getFCC()));
                                                left=0;
                                                
                                            }
                                            break;
                                } // Entry name
                     }
                     break;
                     case TRACK_AUDIO:
                     {
                        uint32_t channels,bpp,encoding,fq,packSize;
                        
                                // Put some defaults
                                ADIO.encoding=1234;
                                ADIO.frequency=44100;
                                ADIO.byterate=128000>>3;
                                ADIO.channels=2;
                                ADIO.bitspersample=16;
                        
                                printf("[STSD] AUDIO <%s>, 0x%08x, size %u\n",fourCC::tostringBE(entryName),entryName,entrySize);
                                son.skipBytes(8);  // reserved etc..
                                left-=8;
                                
                                int atomVersion=son.read16();  // version
                                left-=2;
                                printf("[STSD]Revision       :%d\n",atomVersion);
                                son.skipBytes(2);  // revision
                                left-=2;
                                
                                printf("[STSD]Vendor         : %s\n",fourCC::tostringBE(son.read32()));
                                left-=4;
                                
                                ADIO.channels=channels=son.read16(); // Channel
                                left-=2;
                                printf("[STSD]Channels       :%d\n",ADIO.channels);
                                ADIO.bitspersample=bpp=son.read16(); // version/revision
                                left-=2;
                                printf("[STSD]Bit per sample :%d\n",bpp);
                                
                                encoding=son.read16(); // version/revision
                                left-=2;
                                printf("[STSD]Encoding       :%d\n",encoding);

                                packSize=son.read16(); // Packet Size
                                left-=2;
                                printf("[STSD]Packet size    :%d\n",encoding);
                                
                              
                                fq=ADIO.frequency=son.read16();
                                printf("[STSD]Fq:%u\n",fq);
                                if(ADIO.frequency<6000) ADIO.frequency=48000;
                                printf("[STSD]Fq       :%d\n",ADIO.frequency); // Bps
                                        son.skipBytes(2); // Fixed point
                                left-=4;
                                if(atomVersion)
                                {
                                    info.samplePerPacket=son.read32();
                                    info.bytePerPacket=son.read32();
                                    info.bytePerFrame=son.read32();
                                    printf("[STSD] Sample per packet %u\n",info.samplePerPacket);
                                    printf("[STSD] Bytes per packet  %u\n",info.bytePerPacket);
                                    printf("[STSD] Bytes per frame   %u\n",info.bytePerFrame);
                                    printf("[STSD] Bytes per sample   %u\n",son.read32());
                                    left-=16;
                                }else
                                {
                                  info.samplePerPacket=1;
                                  info.bytePerPacket=1;
                                  info.bytePerFrame=1;
                                }
                                switch(atomVersion)
                                {
                                  case 0:break;
                                  case 1: break;
                                  case 2:
                                          ADIO.frequency=44100; // FIXME
                                          ADIO.channels=son.read32();
                                          printf("Channels            :%d\n",ADIO.channels); // Channels
                                          printf("Tak(7F000)          :%x\n",son.read32()); // Channels
                                          printf("Bits  per channel   :%d\n",son.read32());  // Vendor
                                          printf("Format specific     :%x\n",son.read32());  // Vendor
                                          printf("Byte per audio packe:%x\n",son.read32());  // Vendor
                                          printf("LPCM                :%x\n",son.read32());  // Vendor
                                          left-=(5*4+4+16);
                                          break;
                                }
                                printf("[STSD] chan:%u bpp:%u encoding:%u fq:%u (left %u)\n",channels,bpp,encoding,fq,left);
#define audioCodec(x) ADIO.encoding=WAV_##x;
                                switch(entryName)
                                {
                                    
                                    case MKFCCR('t','w','o','s'):
                                            audioCodec(LPCM);
                                            ADIO.byterate=ADIO.frequency*ADIO.bitspersample*ADIO.channels/8;
                                            break;
                                                
                                    case MKFCCR('u','l','a','w'):
                                            audioCodec(ULAW);
                                            ADIO.byterate=ADIO.frequency;
                                            break;
                                    case MKFCCR('s','o','w','t'):
                                            audioCodec(PCM);
                                            ADIO.byterate=ADIO.frequency*ADIO.bitspersample*ADIO.channels/8;
                                            break;
                                    case MKFCCR('.','m','p','3'): //.mp3
                                            audioCodec(MP3);
                                            ADIO.byterate=128000>>3;
                                            break;
                                    case MKFCCR('r','a','w',' '):
                                            audioCodec(8BITS_UNSIGNED);
                                            ADIO.byterate=ADIO.frequency*ADIO.channels;
                                            break;
                                    case MKFCCR('s','a','m','r'):
                                    {
                                            audioCodec(AMRNB);
                                            ADIO.frequency=8000;
                                            ADIO.channels=1;
                                            ADIO.bitspersample=16;
                                            ADIO.byterate=12000/8;
                                            if(left>10)
                                            {
                                               adm_atom amr(&son);
                                              printf("Reading wave, got %s\n",fourCC::tostringBE(amr.getFCC()));
                                              left=0;
                                            }
                                    }
                                            break;
                                    case MKFCCR('Q','D','M','2'):
                                        {
                                            uint32_t sz;
                                              audioCodec(QDM2);
                                              sz=son.getRemainingSize();
                                              _tracks[1+nbAudioTrack].extraDataSize=sz;
                                              _tracks[1+nbAudioTrack].extraData=new uint8_t[sz];
                                              son.readPayload(_tracks[1+nbAudioTrack].extraData,sz);
                                              left=0;
                                        }
                                        break;
                                    case MKFCCR('m','s',0,0x55): // why 55 ???
                                    case MKFCCR('m','p','4','a'):
                                    {
                                              audioCodec(AAC);
                                            if(left>10)
                                            {
                                              adm_atom wave(&son);
                                              printf("Reading wave, got %s\n",fourCC::tostringBE(wave.getFCC()));
                                              if(MKFCCR('w','a','v','e')==wave.getFCC())
                                              {
                                                 // mp4a
                                                 //   wave
                                                 //     frma
                                                 //     mp4a
                                                 //     esds
                                                 while(!wave.isDone())
                                                 {
                                                     adm_atom item(&wave);
                                                     printf("parsing wave, got %s,0x%x\n",fourCC::tostringBE(item.getFCC()),
                                                                  item.getFCC());
                                                     switch(item.getFCC())
                                                     {
                                                       case MKFCCR('f','r','m','a'):
                                                          {
                                                          uint32_t codecid=item.read32();
                                                          printf("frma Codec Id :%s\n",fourCC::tostringBE(codecid));
                                                          }
                                                          break;
                                                       case MKFCCR('m','s',0,0x55):
                                                        {
                                                          // We have a waveformat here
                                                          printf("[STSD]Found MS audio header:\n");
                                                          ADIO.encoding=ADM_swap16(item.read16());
                                                          ADIO.channels=ADM_swap16(item.read16());
                                                          ADIO.frequency=ADM_swap32(item.read32());
                                                          ADIO.byterate=ADM_swap32(item.read32());
                                                          ADIO.blockalign=ADM_swap16(item.read16());
                                                          ADIO.bitspersample=ADM_swap16(item.read16());
                                                          printWavHeader(&(ADIO));
                                                          
                                                        }
                                                       break;
                                                        case MKFCCR('m','p','4','a'):
                                                          break; 
                                                        case MKFCCR('e','s','d','s'):
                                                          {
                                                               decodeEsds(&item,TRACK_AUDIO);
                                                          goto foundit; // FIXME!!!
                                                          }
                                                          break;
                                                       default:
                                                         break;
                                                     }

                                                     item.skipAtom();
                                                   
                                                 }  // Wave iddone
                                                 left=0;
                                              }  // if ==wave
                                              else
                                              {
                                                if(wave.getFCC()==MKFCCR('e','s','d','s'))
                                                          {
                                                               decodeEsds(&wave,TRACK_AUDIO);
                                                               goto foundit; // FIXME!!!
                                                          } 
                                                else
                                                {
                                                  printf("UNHANDLED ATOM : %s\n",fourCC::tostringBE(wave.getFCC())); 
                                                }
                                              }
                                            } // if left > 10
foundit: // HACK FIXME     
                                            left=0;
                                    }       
                                            break; // mp4a
                                  
                                }
                     }
                          break;
                     default:
                          ADM_assert(0);
                   }
                   son.skipBytes(left); 
                }
       }
              break;
       default:
          printf("[STBL]Skipping atom %s\n",fourCC::tostringBE(son.getFCC()));
     }
     son.skipAtom();
  }
  uint8_t r=0;
  uint32_t nbo=0;
  switch(trackType)
  {
    case TRACK_VIDEO:
        {
          if(_tracks[0].index)
          {
              printf("Already got a video track\n");
              return 1;
          }
          r=indexify(&(_tracks[0]),trackScale,&info,0,&nbo);
          
          _videostream.dwLength= _mainaviheader.dwTotalFrames=_tracks[0].nbIndex;
          // update fps
          float f=_videostream.dwLength;
          if(_movieDuration) f=1000000.*f/_movieDuration;
              else  f=25000;
          _videostream.dwRate=(uint32_t)floor(f);
           _mainaviheader.dwMicroSecPerFrame=ADM_UsecFromFps1000(_videostream.dwRate);
          // if we have a sync atom ???
          if(info.nbSync)
          {
            // Mark keyframes
            for(int i=0;i<info.nbSync;i++)
            {
              int sync=info.Sync[i];
              if(sync) sync--;
              _tracks[0].index[sync].intra=AVI_KEY_FRAME;
            }
          }
          else
          { // All frames are kf
            for(int i=0;i<_tracks[0].nbIndex;i++)
            {
              _tracks[0].index[i].intra=AVI_KEY_FRAME;
            }
          }
          // Now do the CTTS thing
          if(info.Ctts)
          {
            updateCtts(&info);
          }

          
           VDEO.index[0].intra=AVI_KEY_FRAME;
        }
          break;
    case TRACK_AUDIO:
          printf("Cur audio track :%u\n",nbAudioTrack);
          if(info.SzIndentical ==1 && (ADIO.encoding==WAV_LPCM || ADIO.encoding==WAV_PCM ))
            {
              printf("Overriding size %lu -> %lu\n", info.SzIndentical,info.SzIndentical*2*ADIO.channels);
              info.SzIndentical=info.SzIndentical*2*ADIO.channels;
            }
            r=indexify(&(_tracks[1+nbAudioTrack]),trackScale,&info,1,&nbo);
            printf("Indexed audio, nb blocks:%u\n",nbo);
            if(r)
            {
                nbo=_tracks[1+nbAudioTrack].nbIndex;
                if(nbo)
                    _tracks[1+nbAudioTrack].nbIndex=nbo;
                else
                    _tracks[1+nbAudioTrack].nbIndex=info.nbSz;
                printf("Indexed audio, nb blocks:%u (final)\n",_tracks[1+nbAudioTrack].nbIndex);
                _tracks[1+nbAudioTrack].scale=trackScale;
                nbAudioTrack++;
            }
            
            break;
    case TRACK_OTHER:
        r=1;
        break;
  }
  return r;
}
/**
      \fn parseMdia
      \brief Parse mdia header
*/
uint8_t MP4Header::parseMdia(void *ztom,uint32_t *trackType,uint32_t w, uint32_t h)
{
  adm_atom *tom=(adm_atom *)ztom;
  ADMAtoms id;
  uint32_t container;
  uint32_t trackScale=_videoScale;
  uint32_t trackDuration;
  *trackType=TRACK_OTHER;
  uint8_t r=0;
  printf("<<Parsing Mdia>>\n");
  while(!tom->isDone())
  {
     adm_atom son(tom);
     if(!ADM_mp4SearchAtomName(son.getFCC(), &id,&container))
     {
       adm_printf(ADM_PRINT_DEBUG,"[MDIA]Found atom %s unknown\n",fourCC::tostringBE(son.getFCC()));
       son.skipAtom();
       continue;
     }
     switch(id)
     {
       case ADM_MP4_MDHD:  
       {
                uint32_t version=son.read(),duration;
                son.skipBytes(3); // flags + version
                son.skipBytes(4); // creation time
                son.skipBytes(4); // mod time
                if(version==1) son.skipBytes(8);
                trackScale=son.read32(); //
                adm_printf(ADM_PRINT_DEBUG,"MDHD,Trackscale in mdhd:%u\n",trackScale);
                if(!trackScale) trackScale=600; // default
                duration=son.read32();
                adm_printf(ADM_PRINT_DEBUG,"MDHD,duration in mdhd:%u (unscaled)\n",duration);
                duration=(uint32_t)((duration*1000.)/trackScale);
                adm_printf(ADM_PRINT_DEBUG,"MDHD,duration in mdhd:%u (scaled ms)\n",duration);
                trackDuration=duration;
                printf("MDHD,Track duration :%s, trackScale :%u\n",ms2timedisplay((1000*duration)/trackScale),trackScale);
                break;
       }
       case ADM_MP4_HDLR:  
       {
            uint32_t type;
            
                son.read32();
                son.read32();
                type=son.read32();
                printf("[HDLR]\n");
                switch(type)
                {	
                case MKFCCR('v','i','d','e')://'vide':
                        *trackType=TRACK_VIDEO;
                        printf("hdlr video found \n ");
                        _movieDuration=trackDuration;
                        _videoScale=trackScale;
                        break;
                case MKFCCR('s','o','u','n'): //'soun':
                        *trackType=TRACK_AUDIO;
                        printf("hdlr audio found \n ");
                        break;
                case MKFCCR('u','r','l',' ')://'url ':
                    {
                        int s;
                        son.read32();
                        son.read32();
                        son.read32();
                        s=son.read();
                        char str[s+1];
                        son.readPayload((uint8_t *)str,s);
                        str[s]=0;
                        printf("Url : <%s>\n",str);
                      }
                      break;
                 
                }
                break;
       } 
       case ADM_MP4_MINF:  
       {
            // We are only interested in stbl
            
            while(!son.isDone())
            {
              adm_atom grandson(&son);
              if(!ADM_mp4SearchAtomName(grandson.getFCC(), &id,&container))
              {
                adm_printf(ADM_PRINT_DEBUG,"[MINF]Found atom %s unknown\n",fourCC::tostringBE(son.getFCC()));
                grandson.skipAtom();
                continue;
              }
              if(id==ADM_MP4_STBL)
              {
                   if(! parseStbl(&grandson,*trackType, w, h,trackScale))
                   {
                      printf("STBL failed\n");
                      return 0; 
                   }
                   r=1;
              }
              grandson.skipAtom();
        }
       }
       break;
        default:
            adm_printf(ADM_PRINT_DEBUG,"** atom  NOT HANDLED [%s] \n",fourCC::tostringBE(son.getFCC()));
     }
     
     son.skipAtom();
  }
  return r;
}
Exemplo n.º 9
0
void ADM_mkvWalk(ADM_ebml_file *working, uint32_t size)
{
  uint64_t id,len;
  ADM_MKV_TYPE type;
  const char *ss;
  static int recurse=0;
  uint64_t pos; 
  
  recurse++;
   ADM_ebml_file son(working,size);
   while(!son.finished())
   {
      pos=son.tell();
      son.readElemId(&id,&len);
      if(!ADM_searchMkvTag( (MKV_ELEM_ID)id,&ss,&type))
      {
        recTab();printf("[MKV] Tag 0x%x not found\n",id);
        son.skip(len);
        continue;
      }
      recTab();printf("at 0x%llx, Found Tag : %x (%s) type %d (%s) size %d, start at 0x%x end at 0x%x\n",pos,id,ss,type,ADM_mkvTypeAsString(type),len,working->tell(),working->tell()+len);
      uint32_t val;
      switch(type)
      {
        case ADM_MKV_TYPE_CONTAINER:
                  //if(id!=MKV_CLUSTER)
                  if(len)
                    ADM_mkvWalk(&son,len);
                    else
                    {
                                printf("******************************* WARNING ZERO SIZE ******************\n");
                    }

                  //else
                  //    son.skip(len);
                  break;
        case ADM_MKV_TYPE_UINTEGER:
                  val=son.readUnsignedInt(len);
                  recTab();printf("\tval uint: %llu (0x%llx) \n",val,val);
                  break;
        case ADM_MKV_TYPE_UTF8:
        {
                  char string[len+1];
                  string[0]=0;
                  son.readString(string,len);
                  recTab();printf("\tval utf8 as string: <%s> \n",string);
        }
                  break;
                  
        case ADM_MKV_TYPE_FLOAT:
                  recTab();printf("\tval float: %f \n",son.readFloat(len));
                  break;
        case ADM_MKV_TYPE_INTEGER:
                  recTab();printf("\tval int: %lld \n",son.readSignedInt(len));
                  break;
        case ADM_MKV_TYPE_STRING:
        {
                  char string[len+1];
                  string[0]=0;
                  son.readString(string,len);
                  recTab();printf("\tval string: <%s> \n",string);
                  break;
        }
        default:
                if(id==MKV_BLOCK)
                {
                        recTab();printf("\t\tTrack :%u",son.readu8()-128); // Assume 1 byte code
                        //printf(" Timecode:%d",son.reads16());
                        son.skip(2);
                        int lacing=son.readu8();
                        printf(" Lacing :%x ");
                        if(lacing&1) printf(" keyframe ");
                        lacing=(lacing>>1)&3;
                        switch(lacing)
                        {
                                       case 0:printf("No lacing\n");break;
                                       case 1:printf("Xiph lacing\n");break;
                                       case 3:printf("Ebml lacing\n");break;
                                       case 2:printf("Fixed lacing :%u remaining:%u\n",son.readu8()+1,len-5);len--;break;

                        }
                        son.skip(len-4);

                }
                else
                {
                        recTab();printf("Skipping %s\n",ss);
                        son.skip(len);
                }
                break;
      }
Exemplo n.º 10
0
        Problem_Representation_Type const 
        operator()( Chromosome_Args ... ch_args )  
        {
            //initialize first generation randomly
            for ( std::size_t i = 0; i != population_per_generation; ++i )
                current_population.push_back( chromosome_type( ch_args... ) );

            //std::cerr << "\ninitialized " << population_per_generation << " chromosomes.\n";


            std::size_t debug_counter = 0;
            best_fitness = std::numeric_limits<Fitness_Type>::max();
            srand ( unsigned ( time (NULL) ) ); //for random_shuffle
            Fitness_Type total_fit;

            Problem_Representation_Type pr_0;
            Problem_Representation_Type pr_1;
            Problem_Representation_Type pr_2;
            Problem_Representation_Type pr_3;

            std::ofstream elite_out( "elite.dat" );
            std::ofstream elite_fit( "elite_fit.dat");
            
            for (;;)
            {
            //evaluate
                //feng::for_each( current_population.begin(), current_population.end(), [](chromosome_type& chrom) { Evaluation_Method()(Chromosome_Problem_Translation_Method()(chrom)); });
                //std::cerr << "\nevaluating........";

#if 0
                for ( auto& ch : current_population )
                    if ( ch.modification_after_last_evaluation_flag )
                    {
                        Chromosome_Problem_Translation_Method()( *(ch.chrom), pr );
                        ch.fit = Evaluation_Method()(pr);
                        //Evaluation_Method()(Chromosome_Problem_Translation_Method()(ch));
                        ch.modification_after_last_evaluation_flag = false;
                    }
#endif
#if 1
                std::thread t0( parallel_evaluator(), current_population.begin(), current_population.begin()+(current_population.size()/4), &pr_0 );
                std::thread t1( parallel_evaluator(), current_population.begin()+(current_population.size()/4), current_population.begin()+(current_population.size()/2), &pr_1 );
                std::thread t2( parallel_evaluator(), current_population.begin()+(current_population.size()/2), current_population.begin()+(current_population.size()*3/4), &pr_2 );
                std::thread t3( parallel_evaluator(), current_population.begin()+(current_population.size()*3/4), current_population.end(), &pr_3 );
                //parallel_evaluator()( current_population.begin()+(current_population.size()*3/4), current_population.end(), &pr_3 );
                t0.join();
                t1.join();
                t2.join();
                t3.join();
#endif

                //using nth_element?
                //mutate duplicated chromosome?
                std::sort( current_population.begin(), current_population.end() );

                auto const elite_one = *(current_population.begin());
                Chromosome_Problem_Translation_Method()( *(elite_one.chrom), pr );

                //keep the best individual of the current generation
                if ( elite_one.fit < best_fitness )
                {
                    debug_counter++;

                    best_fitness = elite_one.fit;
                    best_one = pr;
                    
                    elite_out << best_one;
                    elite_fit << best_fitness;


                    if ( debug_counter & 0xf )
                    {
                        elite_out << "\n";
                        elite_fit << "\n";
                    }
                    else
                    {
                        elite_out << std::endl;
                        elite_fit << std::endl;
                    }
                }

                current_population.resize( std::distance( current_population.begin(), std::unique( current_population.begin(), current_population.end() )) );
                if ( current_population.size() < population_per_generation )
                {
                    //generate someone randomly and evaluate
                    for ( std::size_t i = current_population.size(); i != population_per_generation; ++i )
                    {
                        auto ch = chromosome_type( ch_args...);
                        Chromosome_Problem_Translation_Method()( *(ch.chrom), pr );
                        ch.fit = Evaluation_Method()(pr);
                        ch.modification_after_last_evaluation_flag = false;
                        current_population.push_back( ch );
                    }
                }
                else
                {
                    //shuffle the resize
                    std::random_shuffle( current_population.begin(), current_population.end() );
                    current_population.resize( population_per_generation );
                }
    
                std::sort( current_population.begin(), current_population.end() );

                //total_fit = 0;
                //for( auto& ch : current_population )
                //    total_fit += ch.fit;
                //std::cout.precision(20);
                //std::cout << total_fit << "\n";

                //if timeout, return output elite
                auto& t_manager = feng::singleton<time_manager>::instance();
                if ( t_manager.is_timeout() )
                {
                    std::cerr << "\nthe residual for the best individual is " << best_fitness;

                    elite_out.close();
                    elite_fit.close();

                    return best_one;
                    //return pr;
                }

                //std::cerr << "\nElite of " << debug_counter++ << " is \n" << pr;
                //std::cerr << "\nElite of " << debug_counter << " is \n" << *(elite_one.chrom);


            //select 
                auto& xpm = feng::singleton<xover_probability_manager<>>::instance();
                std::size_t const selection_number = xpm(population_per_generation);
                //selected_population_for_xover_father.resize(selection_number);
                //selected_population_for_xover_mother.resize(selection_number);
                selected_population_for_xover_father.clear();
                selected_population_for_xover_mother.clear();

                //std::cerr << "\nselecting............." << selection_number;

                auto& xs_manager = feng::singleton<xover_selection_manager>::instance();
                for ( std::size_t i = 0; i != selection_number; ++i )
                {
                    //selected_population_for_xover_father[i] = current_population[xs_manager()];
                    //selected_population_for_xover_mother[i] = current_population[xs_manager()];
                    
                    const std::size_t select1 = xs_manager();
                    const std::size_t select2 = xs_manager();

                    //selected_population_for_xover_father.push_back(current_population[xs_manager()]);
                    //selected_population_for_xover_mother.push_back(current_population[xs_manager()]);
                    selected_population_for_xover_father.push_back(current_population[select1]);
                    selected_population_for_xover_mother.push_back(current_population[select2]);
                }

                //std::cerr << "\nselectedted";
            //xover
#if 0
                //not working as selected population for xover are pure reference of current populaiton
                for ( std::size_t i = 0; i != selection_number; ++i )
                    feng::for_each( selected_population_for_xover_father[i].begin(), selected_population_for_xover_father[i].end(), 
                                    selected_population_for_xover_mother[i].begin(), Chromosome_Xover_Method() );

                current_population.reserve( population_per_generation + selection_number + selection_number );
                //append newly generated genes into current population
                current_population.insert( current_population.begin()+population_per_generation, selected_population_for_xover_father.begin(), selected_population_for_xover_father.end() );
                current_population.insert( current_population.begin()+population_per_generation+selection_number, selected_population_for_xover_mother.begin(), selected_population_for_xover_mother.end() );
#endif
                //std::cerr << "\nxover.............";
                
                for ( std::size_t i = 0; i != selection_number; ++i )
                {
                    chromosome_type son( ch_args... ); 
                    chromosome_type daughter( ch_args... ); 

                    feng::for_each( selected_population_for_xover_father[i].begin(), selected_population_for_xover_father[i].end(), selected_population_for_xover_mother[i].begin(), son.begin(), daughter.begin(), Chromosome_Xover_Method() );

                    current_population.push_back( son ); 
                    current_population.push_back( daughter ); 
                }
                //mark new generation not evaluated
                feng::for_each( current_population.begin()+population_per_generation, current_population.end(), [](chromosome_type& ch) { ch.modification_after_last_evaluation_flag = true; } );

                //std::cerr << "\nxovered";

            //mutate
                //std::cerr << "\nmutating";

                auto& mpm = feng::singleton<mutation_probability_manager<>>::instance();
                mpm.reset();
                for ( auto& chromosome : current_population )
                    if ( mpm.should_mutate_current_gene() )
                    {
                        for ( auto& gene : chromosome )
                            Chromosome_Mutation_Method()(gene);
                        //makr muated ones as not evaluated
                        chromosome.modification_after_last_evaluation_flag = true;
                    }

                //std::cerr << "\nmutated";

            //goto evaluate



            }

            assert( !"Should never reach here!!" );

            return Problem_Representation_Type();
                


        }