]> granicus.if.org Git - handbrake/commitdiff
allow srt and cc subtitles to be up to 2 lines high.
authorjstebbins <jstebbins.hb@gmail.com>
Wed, 28 Oct 2009 16:43:48 +0000 (16:43 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Wed, 28 Oct 2009 16:43:48 +0000 (16:43 +0000)
any additional lines after 2 are merged into 2nd line

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2897 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/deccc608sub.c
libhb/decsrtsub.c

index 5f1e8a14fbf36ea0b00eeeb744ec3b56d5883721..2f137494305fc8dad4fe929f2d556a86c13a2790 100644 (file)
@@ -1637,7 +1637,8 @@ int write_cc_buffer_as_srt (struct eia608_screen *data, struct s_write *wb)
             } else {
                 if (line == 2) {
                     wb->enc_buffer_used += encode_line (wb->enc_buffer+wb->enc_buffer_used,
-                                                        (unsigned char *) " ");
+                                                        (unsigned char *) "\n");
+                    line = 3;
                 } else {
                     wb->enc_buffer_used += encode_line (wb->enc_buffer+wb->enc_buffer_used,
                                                         (unsigned char *) " "); 
index 1bb540aa076e240286be2fc8a5c011af46232516..fa3b9c4689e6e3f4965136ad83947e92466fb1ab 100644 (file)
@@ -237,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 + 
@@ -254,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' )
                         {
-                            *p = ' ';
+                            if ( line == 1 )
+                            {
+                                *q = *p;
+                                line = 2;
+                            }
+                            else
+                            {
+                                *q = ' ';
+                            }
+                            q++;
+                        }
+                        else if( *p != '\r' )
+                        {
+                            *q = *p;
+                            q++;
+                        }
+                        else
+                        {
+                            length--;
                         }
                     }
+                    *q = '\0';
 
                     buffer = hb_buffer_init( length + 1 );