void init_vo_spudec(struct stream *stream, struct sh_video *sh_video, struct sh_sub *sh_sub) { unsigned width, height; spudec_free(vo_spudec); vo_spudec = NULL; // we currently can't work without video stream if (!sh_video) return; if (spudec_ifo) { unsigned int palette[16]; current_module = "spudec_init_vobsub"; if (vobsub_parse_ifo(NULL, spudec_ifo, palette, &width, &height, 1, -1, NULL) >= 0) vo_spudec = spudec_new_scaled(palette, width, height, NULL, 0); } width = sh_video->disp_w; height = sh_video->disp_h; #ifdef CONFIG_DVDREAD if (vo_spudec == NULL && stream->type == STREAMTYPE_DVD) { current_module = "spudec_init_dvdread"; vo_spudec = spudec_new_scaled(((dvd_priv_t *)(stream->priv))->cur_pgc->palette, width, height, NULL, 0); } #endif #ifdef CONFIG_DVDNAV if (vo_spudec == NULL && stream->type == STREAMTYPE_DVDNAV) { unsigned int *palette = mp_dvdnav_get_spu_clut(stream); current_module = "spudec_init_dvdnav"; vo_spudec = spudec_new_scaled(palette, width, height, NULL, 0); } #endif if (vo_spudec == NULL) { current_module = "spudec_init_normal"; vo_spudec = spudec_new_scaled(NULL, width, height, sh_sub ? sh_sub->extradata : NULL, sh_sub ? sh_sub->extradata_len : 0); spudec_set_font_factor(vo_spudec, font_factor); } if (vo_spudec) spudec_set_forced_subs_only(vo_spudec, forced_subs_only); }
//********************************************** uint8_t ADM_vob2vobsub(char *nameVob, char *nameVobSub, char *nameIfo) { dmx_demuxerPS *demuxer=NULL; DIA_working *working=NULL; MPEG_TRACK track; FILE *indexFile=NULL; FILE *indexSub=NULL; uint32_t palette[16],width,height; uint64_t abs,rel,size,pts; int blockSize; uint8_t *data,stream; char *subname; double percent; uint32_t packetLen,usedLen,read; OneTrack allIndex[MAX_LANGUAGE]; char language[MAX_LANGUAGE*4]; #ifdef TEST_V2V nameIfo="d:/Crime/VTS_01_0.IFO"; nameVobSub="toto.idx"; #endif printf("v2v: Ifo:%s Vob:%s Vsub:%s\n",nameIfo,nameVob,nameVobSub); memset(language,0,sizeof(language)); memset(palette,0,sizeof(uint32_t)*16); if(!vobsub_parse_ifo(nameIfo,palette,&width,&height,language)) { GUI_Error_HIG(QT_TR_NOOP("Ifo error"),QT_TR_NOOP("Error reading ifo file, aborting.")); return 0; } printf("Ifo: %d x %d\n",width,height); indexFile=fopen(nameVobSub,"wt"); if(!indexFile) { GUI_Error_HIG(QT_TR_NOOP("Cannot write .idx"),NULL); return 0; } subname=ADM_strdup(nameVobSub); size=strlen(subname); subname[size-3]='s'; subname[size-2]='u'; subname[size-1]='b'; indexSub=fopen(subname,"wb"); ADM_dealloc(subname); if(!indexSub) { fclose(indexFile); GUI_Error_HIG(QT_TR_NOOP("Cannot write .sub"),NULL); return 0; } for(int i=0;i<MAX_LANGUAGE;i++) { allIndex[i].setLang(language+i*3); } track.pes=0x20; track.pid=track.pes; demuxer=new dmx_demuxerPS(1,&track,1); if(!demuxer->open(nameVob)) { GUI_Error_HIG(QT_TR_NOOP("Problem opening the mpeg files"),NULL); delete demuxer; fclose(indexFile); fclose(indexSub); return 0; } size=demuxer->getSize(); int display=0; dumpHeader(indexFile,0,width,height,palette); working=new DIA_working(QT_TR_NOOP("Generating VobSub file")); //*** Main Loop *** uint32_t startPts=0,lastPts=0; uint16_t hh,mm,ss,ms; uint32_t timestamp; while(1) { if(!demuxer->forceRefill(&stream)) goto _abt; demuxer->getPos(&abs,&rel); display++; if(display>20) { working->update(abs>>10,size>>10); display=0; } #ifdef TEST_V2V //if(abs>200*1024*1024) break; #endif if(stream>=0x20 && stream<0x20+MAX_LANGUAGE) { demuxer->getPacketInfo(&data,&packetLen,&usedLen,&pts); if(pts!=ADM_NO_PTS) { // Wrap around ? if(lastPts) { if(pts<lastPts) { if(lastPts-pts>MIN_WRAP_VALUE) { printf("Wrapping at %u ",lastPts); startPts+=lastPts; timestamp=startPts/90; ms2time(timestamp,&hh,&mm,&ss,&ms); printf("%02d:%02d:%02d \n",hh,mm,ss); } } } lastPts=pts; pts+=startPts; } #if 0 if(pts!=ADM_NO_PTS) { timestamp=pts/90; ms2time(timestamp,&hh,&mm,&ss,&ms); printf("%02d:%02d:%02d \n",hh,mm,ss); } #endif blockSize=demuxer->read16i(); allIndex[stream-0x20].run(blockSize,data,packetLen,usedLen, pts) ; } }