Mercurial > mplayer.hg
changeset 25655:e98ceb0190c1
Move all subtitle parsing from mkv demuxer to update_subtitles().
author | eugeni |
---|---|
date | Fri, 11 Jan 2008 21:45:17 +0000 |
parents | 0190aa38aae2 |
children | 00e4d59a0be4 |
files | libmpdemux/demux_mkv.c mpcommon.c |
diffstat | 2 files changed, 25 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c Fri Jan 11 21:45:15 2008 +0000 +++ b/libmpdemux/demux_mkv.c Fri Jan 11 21:45:17 2008 +0000 @@ -2702,8 +2702,6 @@ int64_t size, uint64_t block_duration, uint64_t timecode) { demux_packet_t *dp; - char *ptr1; - int i; if (block_duration == 0) { @@ -2712,28 +2710,9 @@ return; } -#ifdef USE_ASS - if (ass_enabled && track->subtitle_type == MATROSKA_SUBTYPE_SSA) { - ass_process_chunk(track->sh_sub->ass_track, block, size, (long long)timecode, (long long)block_duration); - return; - } -#endif - - ptr1 = block; - if (track->subtitle_type == MATROSKA_SUBTYPE_SSA) - { - /* Find text section. */ - for (i=0; i < 8 && *ptr1 != '\0'; ptr1++) - if (*ptr1 == ',') - i++; - if (*ptr1 == '\0') /* Broken line? */ - return; - } - sub_utf8 = 1; - size -= ptr1 - block; dp = new_demux_packet(size); - memcpy(dp->buffer, ptr1, size); + memcpy(dp->buffer, block, size); dp->pts = timecode / 1000.0f; dp->endpts = (timecode + block_duration) / 1000.0f; ds_add_packet(demuxer->sub, dp);
--- a/mpcommon.c Fri Jan 11 21:45:15 2008 +0000 +++ b/mpcommon.c Fri Jan 11 21:45:17 2008 +0000 @@ -28,11 +28,6 @@ int len; char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v'; static subtitle subs; - if (dvdsub_id >= 0 && type == 'a') -#ifdef USE_ASS - if (!ass_enabled) -#endif - type = 't'; if (reset) { sub_clear_text(&subs, MP_NOPTS_VALUE); if (vo_sub) { @@ -104,7 +99,7 @@ if (spudec_changed(vo_spudec)) vo_osd_changed(OSDTYPE_SPU); - } else if (dvdsub_id >= 0 && type == 't') { + } else if (dvdsub_id >= 0 && (type == 't' || type == 'a')) { double curpts = sh_video->pts + sub_delay; double endpts; vo_sub = &subs; @@ -115,7 +110,16 @@ endpts = d_dvdsub->first->endpts; len = ds_get_packet_sub(d_dvdsub, &packet); #ifdef USE_ASS - if (ass_enabled) { + if (type == 'a' && ass_enabled) { // ssa/ass subs with libass + sh_sub_t* sh = d_dvdsub->sh; + ass_track = sh ? sh->ass_track : NULL; + if (ass_track) + ass_process_chunk(ass_track, packet, len, + (long long)(pts*1000 + 0.5), + (long long)((endpts-pts)*1000 + 0.5)); + continue; + } + if (type == 't' && ass_enabled) { // plaintext subs with libass static ass_track_t *global_ass_track = NULL; if (!global_ass_track) global_ass_track = ass_default_track(ass_library); ass_track = global_ass_track; @@ -128,11 +132,23 @@ subs.end = endpts * 100; ass_process_subtitle(ass_track, &subs); } - } else + continue; + } #endif if (pts != MP_NOPTS_VALUE) { if (endpts == MP_NOPTS_VALUE) sub_clear_text(&subs, MP_NOPTS_VALUE); + if (type == 'a') { // ssa/ass subs without libass => convert to plaintext + int i; + unsigned char* p = packet; + for (i=0; i < 8 && *p != '\0'; p++) + if (*p == ',') + i++; + if (*p == '\0') /* Broken line? */ + continue; + len -= p - packet; + packet = p; + } sub_add_text(&subs, packet, len, endpts); vo_osd_changed(OSDTYPE_SUBTITLE); }