Пример #1
0
int32_t SegmentMerger::merge() {
	int32_t value = mergeFields();
	mergeTerms();
	mergeNorms();

	if (fieldInfos->hasVectors())
		mergeVectors();

	return value;
}
Пример #2
0
int32_t SegmentMerger::merge(bool mergeDocStores) {
  this->mergeDocStores = mergeDocStores;

  // NOTE: it's important to add calls to
  // checkAbort.work(...) if you make any changes to this
  // method that will spend alot of time.  The frequency
  // of this check impacts how long
  // IndexWriter.close(false) takes to actually stop the
  // threads.

  mergedDocs = mergeFields();

	mergeTerms();
	mergeNorms();

	if (mergeDocStores && fieldInfos->hasVectors())
		mergeVectors();

	return mergedDocs;
}
Пример #3
0
uint8_t                 dmxHeader::open(char *name)
{
                FILE *file;
        
                uint32_t w=720,h=576,fps=0;
                uint8_t  type,progressif;
                char     realname[1024];
                uint32_t dummy;
                uint32_t vPid,vTsId;
                
                char string[MAX_LINE+1]; //,str[1024];;
                uint8_t interlac=0;
                int multi;
                        
                printf("\n  opening d2v file : %s\n",name);
                file=fopen(name,"rt");
                if(!file) 
                        {
                                printf("\n Error !!\n");
                                return 0;
                        }
                
                fgets(string,MAX_LINE,file);        // File header
                if(strncmp(string,"ADMX",4))
                {
                        fclose(file);
                        printf("This is not a mpeg index G2\n");
                         return 0;
                }
        
                
                fgets(string,MAX_LINE,file);
                sscanf(string,"Type     : %c\n",&type); // ES for now
                

                fgets(string,MAX_LINE,file);
              //  sscanf(string,"File     : %s\n",realname);
char *start;
 
                 start=strstr(string,":");
                ADM_assert(start);
                strcpy(realname,start+2);
                int l=strlen(realname)-1;
                while(l&&(realname[l]==0x0a || realname[l]==0x0d))
                {
                        realname[l]=0;
                        l--;
                }
                

                
                fgets (string, MAX_LINE, file);
                sscanf(string,"Append   : %d\n",&multi);

                fgets(string,MAX_LINE,file);
                sscanf(string,"Image    : %c\n",&progressif); // Progressive
                if(progressif=='I') _fieldEncoded=1;
                fgets(string,MAX_LINE,file);
                sscanf(string,"Picture  : %u x %u %u fps\n",&w,&h,&fps); // width...

                fgets(string,MAX_LINE,file);
                sscanf(string,"Nb Gop   : %u \n",&_nbGop); // width...

                fgets(string,MAX_LINE,file);
                sscanf(string,"Nb Images: %u \n",&_nbFrames); // width...

                fgets(string,MAX_LINE,file);
                //fscanf(string,"Nb Audio : %u\n",0); 

                fgets(string,MAX_LINE,file);
                //fprintf(out,"Main aud : %u\n",preferedAudio); 

                fgets(string,MAX_LINE,file);
                sscanf(string,"Streams  : V%X:%X \n",&vTsId,&vPid); 

                printf("For file :%s\n",realname);                
                printf("Pic      :%dx%d, %d fps\n",w,h,fps);
                printf("#Gop     :%lu\n",_nbGop);
                printf("#Img     :%lu\n",_nbFrames);

                
                switch(type)
                {
                        case 'M':
                                {
                                  MPEG_TRACK track;
                                  track.pid=vTsId;
                                  track.pes=vPid;
                                  demuxer=new dmx_demuxerMSDVR(1,&track,0);
                                  break;
                                }
                        case 'T' :
                                {
                                        MPEG_TRACK track;
                                        track.pid=vTsId;
                                        track.pes=vPid;
                                        demuxer=new dmx_demuxerTS(1,&track,0);
                                        break;

                                }
                        case 'P':
                                {
                                        MPEG_TRACK track;
                                        track.pid=0;
                                        track.pes=vPid;
                                        demuxer=new dmx_demuxerPS(1,&track,multi);
                                        break;
                                }
                        case 'E':
                                demuxer=new dmx_demuxerES();
                                break;
                        default:
                                ADM_assert(0);
                }


                if(!demuxer->open(realname))
                {
                                printf("\n cannot open mpeg >%s<\n",realname);
                                delete demuxer;
                                demuxer=NULL;
                                fclose(file);
                                return 0;
                }
                
                _index=new dmxIndex[_nbFrames+1];
                if(!_index)
                        {
                          GUI_Error_HIG(_("Out of memory"), NULL);
                                        ADM_assert(0);
                        }
                memset(_index,0,_nbFrames*sizeof(dmxIndex));
                
                // -------------- Read the file (video)---------------------
                uint32_t read=0;
                uint32_t currentImage=0;
                uint32_t gop,imageStart,imageNb;
                uint64_t abs,rel;
                uint8_t  imgtype;
                uint32_t imgsize;
                uint64_t imgrel,imgabs;
                char *str,*needle;
                
                DIA_working *work=new DIA_working("Opening mpeg..");
                while(read<_nbGop)
                {
                        if(!fgets(string,MAX_LINE,file)) break;
                        if(string[0]!='V') continue;
                        //printf("%s\n",string);
                        // # NGop NImg nbImg Pos rel type:size type:size
                        sscanf(string,"V %u %u %u ",&gop,&imageStart,&imageNb);
                                ADM_assert(read==gop);
                                if(currentImage!=imageStart)
				{
					printf("At gop :%u read:%u, expected image %u, got %u,imagenb:%u\n",gop,read,currentImage,imageStart,imageNb);
					printf("String :%s\n",string);
					ADM_assert(0);
				}
                        
                                
                                // now split the image
                                needle=strstr(string,":");
                                ADM_assert(needle);
                                needle--;
                                // 
                                
                                for(uint32_t i=currentImage;i<currentImage+imageNb;i++)
                                {
                                        str=strstr(needle,":"); 
                                        if(!str)
                                        {
                                                printf("****** Error reading index, index damaged ?****\n");
                                                printf("Gop: %d/%d\n",read,_nbGop);
                                                printf("Img: %d/%d/%d\n",i,i-currentImage,imageNb);
                                                printf("Str:%s\n",string);
                                                printf("****** Error reading index, index damaged ?****\n");
                                                ADM_assert(0);
                                        }
                                        str--;
#ifdef CYG_MANGLING                                        
                                        sscanf(str,"%c:%I64x,%I64x,%x",&imgtype,&imgabs,&imgrel,&imgsize);
#else                                      
                                        sscanf(str,"%c:%llx,%llx,%x",&imgtype,&imgabs,&imgrel,&imgsize);
#endif                                          
                                        if(i>=_nbFrames)         
                                        {
                                                printf("Max frame exceeded :%d/%d\n",i,_nbFrames);
                                                ADM_assert(i<_nbFrames);
                                        }
                                        
                                        _index[i].type=imgtype;
                                        _index[i].size=imgsize;
                                       
                                       
                                        _index[i].absolute=imgabs;
                                        _index[i].relative=imgrel;
                                        

                                        str[1]=' '; // remove :
                                }
                                currentImage+=imageNb;
                                read++;
	                        work->update(  read,_nbGop)   ;
                }
                delete work;
                fclose(file);
                if(!_nbFrames)
                {
                  printf("No image!\n");
                  return 0; 
                }
                        // Drop the last P/B frames as we won't be able to decode them
                        // (last frame must be an I frame for decodeGop to work)
                        uint32_t dropped=0;
                        for(uint32_t y=_nbFrames-1;y>0;y--)
                        {
                                        if(_index[y].type!='B') break;
                                        _nbFrames--;
                                        dropped++;
                        }
                        printf("Dropping %d last B/P frames\n",dropped);                        
                        printf(" Creating start sequence (%llu)..\n",_index[0].absolute);
                        
                        //
                        
                        uint32_t scancode=0;
                        uint32_t count=0,found=0;
                        uint32_t firstPic=_index[0].size;
                        uint8_t *tmp=new uint8_t[firstPic];
                        

                        
                        demuxer->setPos(_index[0].absolute,
                                        _index[0].relative);
                        
                        
                        demuxer->read(tmp,firstPic);
                        _extraDataLen=0;
                        _extraData=NULL;
                        // lookup up gop start
                        while(count<firstPic)
                        {
                                scancode<<=8;
                                scancode+=tmp[count];
                                count++;
                                if(scancode==0x000001b8 || scancode==0x00000100)
                                {
                                        found=1;
                                        break;
                                }                                                       
                        }
                        if(found && count>4)
                        {
                                
                                _extraDataLen=count-4;
                                _extraData=new uint8_t[_extraDataLen];
                                memcpy(_extraData,tmp,_extraDataLen);
                                mixDump(tmp,50);
                                printf("\n");
                                printf("Image :%d, seqLen : %u seq %x %x %x %x\n",
                                        firstPic,
                                        _extraDataLen, _extraData[0],
                                                        _extraData[1],
                                                        _extraData[2],
                                                        _extraData[3]);                                          
                        }
                        else
                        {
                                printf("Mmm cound not find a gop start.....\n");
                        }
                        delete [] tmp;                                                
                   
                         demuxer->setPos(_index[0].absolute,
                                        _index[0].relative);

                                                 
                        if(_fieldEncoded) 
                        {
                                printf("This is field encoded...\n");
                                mergeFields();
                        }
                        _isaudiopresent=0; 
                        _isvideopresent=1; 
                        _videostream.dwScale=1000;
                        _videostream.dwRate=fps;
    
                        _mainaviheader.dwMicroSecPerFrame=(uint32_t)floor(50);;     
                        _videostream.fccType=fourCC::get((uint8_t *)"vids");
                        _video_bih.biBitCount=24;
      
                        _videostream.fccHandler=_video_bih.biCompression=fourCC::get((uint8_t *)"MPEG");;
      
                        _videostream.dwInitialFrames= 0;
                        _videostream.dwStart= 0;
                        _video_bih.biWidth=_mainaviheader.dwWidth=w ;
                        _video_bih.biHeight=_mainaviheader.dwHeight=h;
     
                        _lastFrame=0xffffffff;

                       _videostream.dwLength= _mainaviheader.dwTotalFrames=_nbFrames;     
                       // Dump();                      
                        
                        // switch DTS->PTS
                        if(!renumber())
                        {
                          GUI_Error_HIG(_("MPEG renumbering error"), NULL);
                                return 0;
                        }
                        //Dump();
                        if(type=='P' || type=='T' || type=='M')
                        {
                                // We have potentially some audio
                                // Try to get it
                                dmxAudioStream *tmp;
                                tmp=new dmxAudioStream;
                                if(!tmp->open(name)) delete tmp;
                                else
                                {
                                        _audioStream=tmp;
                                }

                        }
                        
     printf("Mpeg index file successfully read\n");         
     return 1; 
}