Mercurial > mplayer.hg
comparison mplayer.c @ 21827:b0bc0d81f91b
Subtitle handling cleanup: factor out code for parsing embedded subtitles
and adding and removing of lines in subtitle struct into subreader.c.
author | reimar |
---|---|
date | Sat, 06 Jan 2007 19:07:58 +0000 |
parents | fa9422a466e5 |
children | b36abbbca01e |
comparison
equal
deleted
inserted
replaced
21826:d4dbadf11019 | 21827:b0bc0d81f91b |
---|---|
2891 audio_out->get_delay(); | 2891 audio_out->get_delay(); |
2892 } | 2892 } |
2893 | 2893 |
2894 static void update_subtitles(void) | 2894 static void update_subtitles(void) |
2895 { | 2895 { |
2896 unsigned char *packet=NULL; | |
2897 int len; | |
2898 char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v'; | |
2896 // find sub | 2899 // find sub |
2897 if (subdata) { | 2900 if (subdata) { |
2898 double pts = sh_video->pts; | 2901 double pts = sh_video->pts; |
2899 if (sub_fps==0) sub_fps = sh_video->fps; | 2902 if (sub_fps==0) sub_fps = sh_video->fps; |
2900 current_module = "find_sub"; | 2903 current_module = "find_sub"; |
2906 sub_last_pts = pts; | 2909 sub_last_pts = pts; |
2907 } | 2910 } |
2908 } | 2911 } |
2909 | 2912 |
2910 // DVD sub: | 2913 // DVD sub: |
2911 if (vo_config_count && vo_spudec) { | 2914 if (vo_config_count && vo_spudec && type == 'v') { |
2912 unsigned char* packet=NULL; | 2915 int timestamp; |
2913 int len, timestamp; | |
2914 current_module = "spudec"; | 2916 current_module = "spudec"; |
2915 spudec_heartbeat(vo_spudec, 90000*sh_video->timer); | 2917 spudec_heartbeat(vo_spudec, 90000*sh_video->timer); |
2916 /* Get a sub packet from the DVD or a vobsub and make a timestamp | 2918 /* Get a sub packet from the DVD or a vobsub and make a timestamp |
2917 * relative to sh_video->timer */ | 2919 * relative to sh_video->timer */ |
2918 while(1) { | 2920 while(1) { |
2951 spudec_assemble(vo_spudec, packet, len, timestamp); | 2953 spudec_assemble(vo_spudec, packet, len, timestamp); |
2952 } | 2954 } |
2953 | 2955 |
2954 if (spudec_changed(vo_spudec)) | 2956 if (spudec_changed(vo_spudec)) |
2955 vo_osd_changed(OSDTYPE_SPU); | 2957 vo_osd_changed(OSDTYPE_SPU); |
2958 } else if (dvdsub_id >= 0 && type == 't') { | |
2959 double pts = MP_NOPTS_VALUE; | |
2960 while (d_dvdsub->first) { | |
2961 double nextpts = ds_get_next_pts(d_dvdsub); | |
2962 if (nextpts == MP_NOPTS_VALUE || nextpts - sub_delay > sh_video->pts) | |
2963 break; | |
2964 len = ds_get_packet_sub(d_dvdsub, &packet); | |
2965 pts = nextpts - sub_delay; | |
2966 } | |
2967 if (pts != MP_NOPTS_VALUE) { | |
2968 static subtitle subs; | |
2969 sub_clear_text(&subs, MP_NOPTS_VALUE); | |
2970 sub_add_text(&subs, packet, len, MP_NOPTS_VALUE); | |
2971 vo_sub = &subs; | |
2972 vo_osd_changed(OSDTYPE_SUBTITLE); | |
2973 } | |
2956 } | 2974 } |
2957 current_module=NULL; | 2975 current_module=NULL; |
2958 } | 2976 } |
2959 | 2977 |
2960 static int generate_video_frame(sh_video_t *sh_video, demux_stream_t *d_video) | 2978 static int generate_video_frame(sh_video_t *sh_video, demux_stream_t *d_video) |