From 56504de6ff0e33e3d375acb15ea31af9c83e3cb0 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 31 Mar 2011 03:06:21 +0300 Subject: demux_mkv: use generic packet handling code for subtitles Duration may now be set for packet types other than subtitles; as far as I can tell nothing should care. A check requiring valid duration values for subtitles is removed, because duration may not be properly set for all bitmap subtitle types; hopefully this doesn't make the behavior with (already broken) subtitles without duration worse. --- libmpdemux/demux_mkv.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'libmpdemux/demux_mkv.c') diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 58570855ae..85bea70780 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -1867,26 +1867,6 @@ static int demux_mkv_read_block_lacing(uint8_t *buffer, uint64_t *size, return 1; } -static void handle_subtitles(demuxer_t *demuxer, mkv_track_t *track, - char *block, int64_t size, - uint64_t block_duration, uint64_t timecode) -{ - demux_packet_t *dp; - - if (block_duration == 0) { - mp_msg(MSGT_DEMUX, MSGL_WARN, - "[mkv] Warning: No BlockDuration for subtitle track found.\n"); - return; - } - - sub_utf8 = 1; - dp = new_demux_packet(size); - memcpy(dp->buffer, block, size); - dp->pts = timecode / 1e9; - dp->duration = block_duration / 1e9; - ds_add_packet(demuxer->sub, dp); -} - static void handle_realvideo(demuxer_t *demuxer, mkv_track_t *track, uint8_t *buffer, uint32_t size, int64_t block_bref) { @@ -2101,15 +2081,12 @@ static int handle_block(demuxer_t *demuxer, uint8_t *block, uint64_t length, } else if (track->type == MATROSKA_TRACK_SUBTITLE && track->id == demuxer->sub->id) { ds = demuxer->sub; - if (track->subtitle_type != MATROSKA_SUBTYPE_VOBSUB) { - uint8_t *buffer; - int size = length; - demux_mkv_decode(track, block, &buffer, &size, 1); - handle_subtitles(demuxer, track, buffer, size, block_duration, tc); - if (buffer != block) - talloc_free(buffer); + if (laces > 1) { + mp_msg(MSGT_DEMUX, MSGL_WARN, "[mkv] Subtitles use Matroska " + "lacing. This is abnormal and not supported.\n"); use_this_block = 0; } + sub_utf8 = 1; // XXX this variable should be eventually removed } else use_this_block = 0; @@ -2142,6 +2119,7 @@ static int handle_block(demuxer_t *demuxer, uint8_t *block, uint64_t length, if (i == 0 || track->default_duration) dp->pts = mkv_d->last_pts + i * track->default_duration; + dp->duration = block_duration / 1e9; ds_add_packet(ds, dp); } } -- cgit v1.2.3