if(!seq_found) continue;
if(!seq_found) { continue; printf("No sequence start yet, skipping..\n"); }
uint8_t dmx_indexer(char *mpeg,char *file,uint32_t preferedAudio,uint8_t autosync,uint32_t nbTracks,MPEG_TRACK *tracks){        DIA_progressIndexing *work;        dmx_demuxer *demuxer;        uint64_t syncAbs,syncRel;        uint64_t lastAbs,lastRel;        uint64_t pts,dts;        uint64_t olddts=ADM_NO_PTS;        uint8_t streamid;           uint32_t lastRefPic=0;                     char *realname=PathCanonize(mpeg);        FILE *out;                DMX_TYPE mpegType;        uint8_t  mpegTypeChar;        uint32_t update=0;                        mpegType=dmxIdentify(realname);        if(mpegType==DMX_MPG_UNKNOWN)        {                delete [] realname;                return 0;        }        switch(mpegType)        {                case DMX_MPG_ES:                                demuxer=new dmx_demuxerES;                                mpegTypeChar='E';                                break;                case DMX_MPG_PS:                		{                		dmx_demuxerPS *dmx;                                        dmx=new dmx_demuxerPS(nbTracks,tracks);                                        demuxer=dmx;                                        mpegTypeChar='P';                            }                                break;                default : ADM_assert(0);        }                demuxer->open(realname);        out=fopen(file,"wt");        if(!out)        {                        printf("\n Error : cannot open index !");                        delete demuxer;                        delete [] realname;                        return 0;        }        fprintf(out,"ADMX0003\n");        fprintf(out,"Type     : %c\n",mpegTypeChar); // ES for now        fprintf(out,"File     : %s\n",realname);        fprintf(out,"Image    : %c\n",'P'); // Progressive        fprintf(out,"Picture  : %04lu x %04lu %05lu fps\n",0,0,0); // width...        fprintf(out,"Nb Gop   : %05lu \n",0); // width...        fprintf(out,"Nb Images: %08lu \n",0); // width...        fprintf(out,"Nb Audio : %02lu\n",nbTracks-1);         fprintf(out,"Main aud : %02lu\n",preferedAudio);         fprintf(out,"Streams  : ");        for(int s=0;s<nbTracks;s++)        {                if(!s) fprintf(out,"V%04x:%04x ",tracks[0].pid,tracks[0].pes);                        else fprintf(out,"A%04x:%04x ",tracks[s].pid,tracks[s].pes);                        }        fprintf(out,"\n");        fprintf(out,"# NGop NImg nbImg type:abs:rel:size ...\n");         uint8_t  firstGop=1;        uint8_t  grabbing=0,seq_found=0;        uint32_t imageW=0, imageH=0, imageFps=0;        uint32_t total_frame=0,val;        uint32_t temporal_ref,ftype;        work=new DIA_progressIndexing(mpeg);        nbPushed=0;        nbGop=0;        nbImage=0;        grabbing=0;        printf("*********Indexing started***********\n");        while(1)        {                                if(!demuxer->sync(&streamid,&syncAbs,&syncRel,&pts,&dts)) break;                                   update++;                                if(update>100)                                        {                                               /* if(work->update(syncAbs>>16,demuxer->getSize()>>16))                                                {                                                        // abort;                                                        goto stop_found;                                                }*/                                                work->update(syncAbs>>16,demuxer->getSize()>>16,nbImage,                                                        lastStamp.hh,lastStamp.mm,lastStamp.ss);//uint32_t done,uint32_t total, uint32_t nbImage, uint32_t hh, uint32_t mm, uint32_t ss);                                                update=0;                                        }                                switch(streamid)                                        {                                        /* Useless apparently                                                        case 0xB9: // sequence end                                                        printf("\n End seq\n");                                                        goto stop_found;                                                        break;                                        */                                        case 0xB3: // sequence start                                                if(grabbing) continue;                                                grabbing=1;                                                                                                    gopDump(out,demuxer,syncAbs,syncRel,nbTracks);                                                                        if(seq_found)                                                {                                                        demuxer->forward(8);                                                        break;                                                }                                                seq_found=1;                                                val=demuxer->read32i();                                                imageW=val>>20;                                                imageW=((imageW+15)&~15);                                                imageH= (((val>>8) & 0xfff)+15)& ~15;                                                imageFps= FPS[val & 0xf];                                                demuxer->forward(4);                                                break;                                        case 0xb8: // GOP                                                //      printf("GOP\n");                                                uint32_t gop;                                                   if(!seq_found) continue;                                                if(grabbing)                                                 {                                                                 gopUpdate(demuxer);                                                                                                         continue;                                                }                                                gopDump(out,demuxer,syncAbs,syncRel,nbTracks);                                                                        gopUpdate(demuxer);                                                firstGop=0;                                                                                                break;                                        case 0x00 : // picture                                                                                               if(!seq_found) continue;                                                grabbing=0;                                                total_frame++;                                                val=demuxer->read16i();                                                temporal_ref=val>>6;                                                ftype=7 & (val>>3);                                                // skip illegal values                                                if(ftype<1 || ftype>3)                                                {                                                         printf("[Indexer]Met illegal pic at %llu + %llu\n",syncAbs,syncRel);                                                         continue;                                                }#define USING dts                                                if(USING!=ADM_NO_PTS)                                                {                                                        if(olddts!=ADM_NO_PTS )                                                        {                                                                                if(USING>=olddts)                                                                {                                                                uint64_t delta,deltaRef;                                                                        delta=USING-olddts;                                                                                                                                                delta/=90;                                                                      //  printf("Delta :%llu ms\n",delta);                                                                        // compute what we should be using                                                                        deltaRef=nbPushed+nbImage-lastRefPic;                                                                        // in ms                                                                        deltaRef=(deltaRef*1000*1000)/imageFps;                                                                        if(abs(delta-deltaRef)>MIN_DELTA_PTS)                                                                        {                                                                                printf("Discontinuity %llu %llu!\n",delta,deltaRef);                                                                        }                                                                }                                                         }                                                        olddts=USING;                                                        lastRefPic=nbPushed+nbImage;                                                }                                                                                                                                                Push(ftype,demuxer,syncAbs,syncRel);                                                                                             break;                                        default:                                           break;                                        }                }stop_found:          demuxer->getPos(&lastAbs,&lastRel);          if(nbPushed)  gopDump(out,demuxer,lastAbs,lastRel,nbTracks);          fseeko(out,0,SEEK_SET);        // Update if needed        uint32_t compfps,delta=computeTimeDifference(&firstStamp,&lastStamp);        delta=delta/1000; // in second        if(delta)        {                 compfps= (1000*nbImage)/delta;    // 3 Million images should be enough, no overflow                        }        else        {                compfps=imageFps;        }        // Detect film (i.e. NTSC with computed fps close to 24)        if(imageFps==29970 || imageFps==30000)        {                if(compfps>23800 && compfps < 24200) imageFps=23976;        }        // Detect interlaced vs progressive        // If field encoded, the average fps is about twice as theoritical fps        char type='P';        float err;        err=imageFps*2;        err-=compfps;        err*=100;        err/=imageFps*2;        if(err<0) err=-err;        printf("%lu :%lu / %lu , %f\n",imageFps,imageFps*2,compfps,err);        if(err<10)         {                type='I';                printf("Seems to be field encoded\n");        }        else        {                printf("Seems to be frame encoded\n");        }        // *****************Update header*************        fprintf(out,"ADMX0003\n");        fprintf(out,"Type     : %c\n",mpegTypeChar); // ES for now        fprintf(out,"File     : %s\n",realname);        fprintf(out,"Image    : %c\n",type); // Progressive        fprintf(out,"Picture  : %04lu x %04lu %05lu fps\n",imageW,imageH,imageFps); // width...        fprintf(out,"Nb Gop   : %05lu \n",nbGop); // width...        fprintf(out,"Nb Images: %08lu \n",nbImage); // width...        fclose(out);        delete work;          printf("*********Indexing stopped***********\n");        printf("Found       :%lu gop\n",nbGop);        printf("Found       :%lu image\n",nbImage);                        printf("Average fps :%lu /1000 fps\n",compfps);          delete demuxer;          delete [] realname;          return 1;}