# HG changeset patch # User mosu # Date 1136376315 0 # Node ID 59452efe579ca3bb207060baef21ecb0858f5c8f # Parent d6983ae72e0e7352b7446bf5dc0442f2a8eafca9 Improved handling of text subs in Matroska files with adjacent newlines (\N) resulting in more than SUB_MAX_TEXT lines to display. Patch by Robert Henney (robh () rut ! org). diff -r d6983ae72e0e -r 59452efe579c libmpdemux/demux_mkv.c --- a/libmpdemux/demux_mkv.c Wed Jan 04 11:26:15 2006 +0000 +++ b/libmpdemux/demux_mkv.c Wed Jan 04 12:05:15 2006 +0000 @@ -2546,16 +2546,19 @@ ptr1++; /* Newline */ - if (*ptr1 == '\\' && ptr1+1-block < size && (*(ptr1+1)|0x20) == 'n') + while (*ptr1 == '\\' && ptr1+1-block < size && (*(ptr1+1)|0x20) == 'n') { mkv_d->clear_subs_at[mkv_d->subs.lines++] = timecode + block_duration; *ptr2 = '\0'; if (mkv_d->subs.lines >= SUB_MAX_TEXT) { - mp_msg (MSGT_DEMUX, MSGL_WARN, "[mkv] Warning: too many " - "sublines to render, skipping\n"); - return; + mp_msg (MSGT_DEMUX, MSGL_WARN, "\n[mkv] Warning: too many " + "sublines to render, skipping after first %i\n", + SUB_MAX_TEXT); + mkv_d->subs.lines--; + ptr1=block+size; + break; } ptr2 = mkv_d->subs.text[mkv_d->subs.lines]; ptr1 += 2; @@ -2568,7 +2571,7 @@ } else { - while (ptr1 - block != size) + while (ptr1 - block < size) { if (*ptr1 == '\n' || *ptr1 == '\r') { @@ -2579,9 +2582,12 @@ = timecode + block_duration; if (mkv_d->subs.lines >= SUB_MAX_TEXT) { - mp_msg (MSGT_DEMUX, MSGL_WARN, "[mkv] Warning: too many " - "sublines to render, skipping\n"); - return; + mp_msg (MSGT_DEMUX, MSGL_WARN, "\n[mkv] Warning: too many " + "sublines to render, skipping after first %i\n", + SUB_MAX_TEXT); + mkv_d->subs.lines--; + ptr1=block+size; + break; } ptr2 = mkv_d->subs.text[mkv_d->subs.lines]; state = 1; diff -r d6983ae72e0e -r 59452efe579c subreader.h --- a/subreader.h Wed Jan 04 11:26:15 2006 +0000 +++ b/subreader.h Wed Jan 04 12:05:15 2006 +0000 @@ -29,7 +29,7 @@ #define MAX_SUBTITLE_FILES 128 -#define SUB_MAX_TEXT 10 +#define SUB_MAX_TEXT 12 #define SUB_ALIGNMENT_BOTTOMLEFT 1 #define SUB_ALIGNMENT_BOTTOMCENTER 2 #define SUB_ALIGNMENT_BOTTOMRIGHT 3