OSDN Git Service

LinGui: fix library list for mingw with gstreamer enabled
[handbrake-jp/handbrake-jp-git.git] / libhb / decsrtsub.c
index bf35c9e..fa3b9c4 100644 (file)
@@ -89,7 +89,12 @@ static int utf8_fill( hb_work_private_t * pv )
             pv->pos = 0;
             pv->end = bytes;
             if( bytes == 0 )
-                return 0;
+            {
+                if( conversion )
+                    return 1;
+                else
+                    return 0;
+            }
         }
 
         p = pv->buf + pv->pos;
@@ -232,7 +237,8 @@ static hb_buffer_t *srt_read( hb_work_private_t *pv )
                 if( *pv->current_entry.text )
                 {
                     long length;
-                    char *p;
+                    char *p, *q;
+                    int  line = 1;
                     uint64_t start_time = ( pv->current_entry.start + 
                                             pv->subtitle->config.offset ) * 90;
                     uint64_t stop_time = ( pv->current_entry.stop + 
@@ -249,13 +255,32 @@ static hb_buffer_t *srt_read( hb_work_private_t *pv )
 
                     length = strlen( pv->current_entry.text );
 
-                    for( p = pv->current_entry.text; *p; p++)
+                    for( q = p = pv->current_entry.text; *p; p++)
                     {
-                        if( *p == '\n' || *p == '\r' )
+                        if( *p == '\n' )
+                        {
+                            if ( line == 1 )
+                            {
+                                *q = *p;
+                                line = 2;
+                            }
+                            else
+                            {
+                                *q = ' ';
+                            }
+                            q++;
+                        }
+                        else if( *p != '\r' )
+                        {
+                            *q = *p;
+                            q++;
+                        }
+                        else
                         {
-                            *p = ' ';
+                            length--;
                         }
                     }
+                    *q = '\0';
 
                     buffer = hb_buffer_init( length + 1 );