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).

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17309 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
mosu 2006-01-04 12:05:15 +00:00
parent de86b6190a
commit 2e40bfa136
2 changed files with 15 additions and 9 deletions

View File

@ -2546,16 +2546,19 @@ handle_subtitles(demuxer_t *demuxer, mkv_track_t *track, char *block,
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 @@ handle_subtitles(demuxer_t *demuxer, mkv_track_t *track, char *block,
}
else
{
while (ptr1 - block != size)
while (ptr1 - block < size)
{
if (*ptr1 == '\n' || *ptr1 == '\r')
{
@ -2579,9 +2582,12 @@ handle_subtitles(demuxer_t *demuxer, mkv_track_t *track, char *block,
= 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;

View File

@ -29,7 +29,7 @@ extern int sub_format;
#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