| | 493 | //==================== Open VOB-Sub ============================ |
| | 494 | if (vobsub_name){ |
| | 495 | vo_vobsub=vobsub_open(vobsub_name,spudec_ifo,1,&vo_spudec); |
| | 496 | if(vo_vobsub==NULL) |
| | 497 | mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,vobsub_name); |
| | 498 | }else if(sub_auto && filename && (strlen(filename)>=5)){ |
| | 499 | /* try to autodetect vobsub from movie filename ::atmos */ |
| | 500 | char *buf = malloc((strlen(filename)-3) * sizeof(char)); |
| | 501 | memset(buf,0,strlen(filename)-3); // make sure string is terminated |
| | 502 | strncpy(buf, filename, strlen(filename)-4); |
| | 503 | vo_vobsub=vobsub_open(buf,spudec_ifo,0,&vo_spudec); |
| | 504 | free(buf); |
| | 505 | } |
| | 506 | |
| | 507 | if(vo_vobsub){ |
| | 508 | sub_auto=0; // don't do autosub for textsubs if vobsub found |
| | 509 | // inited_flags|=INITED_VOBSUB; |
| | 510 | vobsub_set_from_lang(vo_vobsub, dvdsub_lang); |
| | 511 | // check if vobsub requested only to display forced subtitles |
| | 512 | forced_subs_only=vobsub_get_forced_subs_flag(vo_vobsub); |
| | 513 | } |
| | 514 | |
| 1551 | | int len; |
| 1552 | | while((len=ds_get_packet_sub(d_dvdsub,&packet))>0){ |
| 1553 | | mp_msg(MSGT_MENCODER,MSGL_V,"\rDVD sub: len=%d v_pts=%5.3f s_pts=%5.3f \n",len,sh_video->pts,d_dvdsub->pts); |
| 1554 | | if (vo_spudec) |
| 1555 | | spudec_assemble(vo_spudec,packet,len,90000*d_dvdsub->pts); |
| 1556 | | if (vobsub_writer) |
| 1557 | | vobsub_out_output(vobsub_writer,packet,len,mux_v->timer + d_dvdsub->pts - sh_video->pts); |
| 1558 | | } |
| | 1578 | int len, timestamp; |
| | 1579 | // Get a sub packet from the dvd or a vobsub and make a timestamp relative to sh_video->timer |
| | 1580 | while(1) { |
| | 1581 | // FIXME: messed up timer and pts????????? |
| | 1582 | // Vobsub |
| | 1583 | if(vo_vobsub) { |
| | 1584 | if(sh_video->pts+sub_delay>=0) { |
| | 1585 | len = vobsub_get_packet(vo_vobsub,sh_video->pts+sub_delay,(void**)&packet,×tamp); |
| | 1586 | if(len > 0) { |
| | 1587 | timestamp -= (sh_video->pts + sub_delay - sh_video->timer)*90000; |
| | 1588 | mp_dbg(MSGT_CPLAYER,MSGL_V,"\rVOB sub: len=%d v_pts=%5.3f v_timer=%5.3f sub=%5.3f ts=%d \n",len,sh_video->pts,sh_video->timer,timestamp / 90000.0,timestamp); |
| | 1589 | } |
| | 1590 | } |
| | 1591 | } else { |
| | 1592 | // DVD sub |
| | 1593 | len=ds_get_packet_sub(d_dvdsub,&packet); |
| | 1594 | if(len > 0) { |
| | 1595 | float x = d_dvdsub->pts - sh_video->pts; |
| | 1596 | if (x < -10 || x > 10) // prevent missing subs on pts reset |
| | 1597 | timestamp = 90000*(sh_video->timer + d_dvdsub->pts + sub_delay - sh_video->pts); |
| | 1598 | else |
| | 1599 | timestamp = 90000*(sh_video->timer + sub_delay); |
| | 1600 | |
| | 1601 | mp_msg(MSGT_MENCODER,MSGL_V,"\rDVD sub: len=%d v_pts=%5.3f s_pts=%5.3f ts=%d \n",len,sh_video->pts,d_dvdsub->pts,timestamp); |
| | 1602 | } |
| | 1603 | } |
| | 1604 | if (len <= 0 || !packet) break; |
| | 1605 | if (timestamp < 0) timestamp = 0; |
| | 1606 | else{ |
| | 1607 | if (vo_spudec) |
| | 1608 | spudec_assemble(vo_spudec,packet,len,timestamp); |
| | 1609 | if (vobsub_writer) |
| | 1610 | vobsub_out_output(vobsub_writer,packet,len,mux_v->timer + d_dvdsub->pts - sh_video->pts); |
| | 1611 | } |
| | 1612 | } |