Commit afc9d70d authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Fixed bugs in parsing SSA lines. Turns out we are currently parsing within demuxers.

  The parsing of lines should of course be moved to the decoder level.
parent a90eb78d
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer * mkv.cpp : matroska demuxer
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: mkv.cpp,v 1.32 2003/10/31 15:54:52 hartman Exp $ * $Id: mkv.cpp,v 1.33 2003/11/02 01:41:12 hartman Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -1636,7 +1636,7 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts ...@@ -1636,7 +1636,7 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
if( p_pes->p_first && p_pes->i_pes_size > 0 ) if( p_pes->p_first && p_pes->i_pes_size > 0 )
{ {
p_pes->p_first->p_payload_end[-1] = '\0'; p_pes->p_first->p_payload_end[0] = '\0';
} }
if( !strcmp( tk.psz_codec, "S_TEXT/SSA" ) || if( !strcmp( tk.psz_codec, "S_TEXT/SSA" ) ||
!strcmp( tk.psz_codec, "S_SSA" ) || !strcmp( tk.psz_codec, "S_SSA" ) ||
...@@ -1656,29 +1656,30 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts ...@@ -1656,29 +1656,30 @@ static void BlockDecode( input_thread_t *p_input, KaxBlock *block, mtime_t i_pts
} }
memmove( p_pes->p_first->p_payload_start, start, memmove( p_pes->p_first->p_payload_start, start,
strlen( start) + 1 ); strlen( start) + 1 );
/* remove all {\... } stuff */
/* Fix the SSA string */
src = dst = (char*)p_pes->p_first->p_payload_start; src = dst = (char*)p_pes->p_first->p_payload_start;
for( ;; ) while( *src )
{ {
if( src[0] == '{' && src[1] == '\\' ) if( src[0] == '\\' && ( src[1] == 'n' || src[1] == 'N' ) )
{ {
while( *src ) dst[0] = '\n'; dst++; src += 2;
}
else if( src[0] == '{' && src[1] == '\\' )
{
while( *src && src[0] != '}' )
{ {
if( *src == '}' )
{
src++;
break;
}
src++; src++;
} }
src++;
} }
if( *src == '\0' ) else
{ {
break; dst[0] = src[0]; dst++; src++;
} }
*dst++ = *src++;
} }
*dst++ = '\0'; dst++;
dst[0] = '\0';
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sub.c * sub.c
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2003 VideoLAN * Copyright (C) 1999-2003 VideoLAN
* $Id: sub.c,v 1.31 2003/10/31 22:46:19 hartman Exp $ * $Id: sub.c,v 1.32 2003/11/02 01:41:12 hartman Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -837,29 +837,31 @@ static int sub_SSARead( text_t *txt, subtitle_t *p_subtitle, mtime_t i_microsec ...@@ -837,29 +837,31 @@ static int sub_SSARead( text_t *txt, subtitle_t *p_subtitle, mtime_t i_microsec
} }
p_subtitle->psz_text = malloc( strlen( p_buffer_text ) + 1); p_subtitle->psz_text = malloc( strlen( p_buffer_text ) + 1);
i_text = 0; i_text = 0;
while( *p_buffer_text ) while( p_buffer_text[0] != '\0' )
{ {
if( *p_buffer_text == '\\' && ( *p_buffer_text =='n' || *p_buffer_text =='N' ) ) if( p_buffer_text[0] == '\\' && ( p_buffer_text[1] =='n' || p_buffer_text[1] =='N' ) )
{ {
p_subtitle->psz_text[i_text] = '\n'; p_subtitle->psz_text[i_text] = '\n';
i_text++; i_text++;
p_buffer_text += 2; p_buffer_text += 2;
} }
else if( *p_buffer_text == '{' && *p_buffer_text == '\\') else if( p_buffer_text[0] == '{' && p_buffer_text[1] == '\\' )
{ {
while( *p_buffer_text && *p_buffer_text != '}' ) /* SSA control code */
while( p_buffer_text[0] != '\0' && p_buffer_text[0] != '}' )
{ {
p_buffer_text++; p_buffer_text++;
} }
p_buffer_text++;
} }
else else
{ {
p_subtitle->psz_text[i_text] = *p_buffer_text; p_subtitle->psz_text[i_text] = p_buffer_text[0];
i_text++; i_text++;
p_buffer_text++; p_buffer_text++;
} }
} }
p_subtitle->psz_text[i_text] = '\0'; p_subtitle->psz_text[++i_text] = '\0';
p_subtitle->i_start = i_start; p_subtitle->i_start = i_start;
p_subtitle->i_stop = i_stop; p_subtitle->i_stop = i_stop;
return( 0 ); return( 0 );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment