[vlc-commits] [Git][videolan/vlc][master] demux: subtitle: add missing TS_0 offset

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Apr 5 11:05:40 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
6dc0701b by Francois Cartegnie at 2023-04-05T10:39:56+00:00
demux: subtitle: add missing TS_0 offset

- - - - -


1 changed file:

- modules/demux/subtitle.c


Changes:

=====================================
modules/demux/subtitle.c
=====================================
@@ -1028,8 +1028,8 @@ static int ParseMicroDvd( vlc_object_t *p_obj, subs_properties_t *p_props,
     }
 
     /* */
-    p_subtitle->i_start  = i_start * p_props->i_microsecperframe;
-    p_subtitle->i_stop   = i_stop >= 0 ? (i_stop  * p_props->i_microsecperframe) : -1;
+    p_subtitle->i_start  =  VLC_TICK_0 + i_start * p_props->i_microsecperframe;
+    p_subtitle->i_stop   = i_stop >= 0 ? (VLC_TICK_0 + i_stop  * p_props->i_microsecperframe) : -1;
     p_subtitle->psz_text = psz_text;
     return VLC_SUCCESS;
 }
@@ -1185,10 +1185,10 @@ static int subtitle_ParseSubViewerTiming( subtitle_t *p_subtitle,
                 &h1, &m1, &s1, &d1, &h2, &m2, &s2, &d2) == 8 )
     {
         p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1) +
-                              VLC_TICK_FROM_MS( d1 );
+                              VLC_TICK_FROM_MS( d1 ) + VLC_TICK_0;
 
         p_subtitle->i_stop  = vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 ) +
-                              VLC_TICK_FROM_MS( d2 );
+                              VLC_TICK_FROM_MS( d2 ) + VLC_TICK_0;
         return VLC_SUCCESS;
     }
     return VLC_EGENERIC;
@@ -1287,9 +1287,9 @@ static int  ParseSSA( vlc_object_t *p_obj, subs_properties_t *p_props,
             }
 
             p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 ) +
-                                  VLC_TICK_FROM_MS( c1 * 10 );
+                                  VLC_TICK_FROM_MS( c1 * 10 ) + VLC_TICK_0;
             p_subtitle->i_stop  = vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 ) +
-                                  VLC_TICK_FROM_MS( c2 * 10 );
+                                  VLC_TICK_FROM_MS( c2 * 10 ) + VLC_TICK_0;
             p_subtitle->psz_text = psz_text;
             return VLC_SUCCESS;
         }
@@ -1338,7 +1338,7 @@ static int ParseVplayer( vlc_object_t *p_obj, subs_properties_t *p_props,
         if( sscanf( s, "%d:%d:%d%*c%[^\r\n]",
                     &h1, &m1, &s1, psz_text ) == 4 )
         {
-            p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
+            p_subtitle->i_start = VLC_TICK_0 + vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
             p_subtitle->i_stop  = -1;
             break;
         }
@@ -1455,7 +1455,7 @@ static int ParseSami( vlc_object_t *p_obj, subs_properties_t *p_props,
         }
     }
 
-    p_subtitle->i_start = VLC_TICK_FROM_MS(i_start);
+    p_subtitle->i_start = VLC_TICK_0 + VLC_TICK_FROM_MS(i_start);
     p_subtitle->i_stop  = -1;
     p_subtitle->psz_text = strdup( text );
 
@@ -1500,7 +1500,7 @@ static int ParseDVDSubtitle(vlc_object_t *p_obj, subs_properties_t *p_props,
                     &h1, &m1, &s1, &c1 ) == 4 )
         {
             p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 ) +
-                                  VLC_TICK_FROM_MS( c1 * 10 );
+                                  VLC_TICK_FROM_MS( c1 * 10 ) + VLC_TICK_0;
             p_subtitle->i_stop = -1;
             break;
         }
@@ -1570,8 +1570,8 @@ static int ParseMPL2(vlc_object_t *p_obj, subs_properties_t *p_props,
         if( sscanf( s, "[%d][] %[^\r\n]", &i_start, psz_text ) == 2 ||
             sscanf( s, "[%d][%d] %[^\r\n]", &i_start, &i_stop, psz_text ) == 3)
         {
-            p_subtitle->i_start = VLC_TICK_FROM_MS(i_start * 100);
-            p_subtitle->i_stop  = i_stop >= 0 ? VLC_TICK_FROM_MS(i_stop  * 100) : -1;
+            p_subtitle->i_start = VLC_TICK_0 + VLC_TICK_FROM_MS(i_start * 100);
+            p_subtitle->i_stop  = i_stop >= 0 ? VLC_TICK_0 + VLC_TICK_FROM_MS(i_stop  * 100) : -1;
             break;
         }
         free( psz_text );
@@ -1621,13 +1621,13 @@ static int ParseAQT(vlc_object_t *p_obj, subs_properties_t *p_props, text_t *txt
             /* Starting of a subtitle */
             if( i_firstline )
             {
-                p_subtitle->i_start = t * p_props->i_microsecperframe;
+                p_subtitle->i_start = VLC_TICK_0 + t * p_props->i_microsecperframe;
                 i_firstline = 0;
             }
             /* We have been too far: end of the subtitle, begin of next */
             else
             {
-                p_subtitle->i_stop  = t * p_props->i_microsecperframe;
+                p_subtitle->i_stop  = VLC_TICK_0 + t * p_props->i_microsecperframe;
                 break;
             }
         }
@@ -1674,8 +1674,8 @@ static int ParsePJS(vlc_object_t *p_obj, subs_properties_t *p_props,
         if( sscanf (s, "%d,%d,\"%[^\n\r]", &t1, &t2, psz_text ) == 3 )
         {
             /* 1/10th of second ? Frame based ? FIXME */
-            p_subtitle->i_start = 10 * t1;
-            p_subtitle->i_stop = 10 * t2;
+            p_subtitle->i_start = VLC_TICK_0 + 10 * t1;
+            p_subtitle->i_stop = VLC_TICK_0 + 10 * t2;
             /* Remove latest " */
             psz_text[ strlen(psz_text) - 1 ] = '\0';
 
@@ -1758,9 +1758,9 @@ static int ParseMPSub( vlc_object_t *p_obj, subs_properties_t *p_props,
         {
             float f2 = vlc_strtof_c( psz_temp, NULL );
             p_props->mpsub.f_total += f1 * p_props->mpsub.i_factor;
-            p_subtitle->i_start = llroundf(10000.f * p_props->mpsub.f_total);
+            p_subtitle->i_start = VLC_TICK_0 + llroundf(10000.f * p_props->mpsub.f_total);
             p_props->mpsub.f_total += f2 * p_props->mpsub.i_factor;
-            p_subtitle->i_stop = llroundf(10000.f * p_props->mpsub.f_total);
+            p_subtitle->i_stop = VLC_TICK_0 + llroundf(10000.f * p_props->mpsub.f_total);
             break;
         }
     }
@@ -1827,18 +1827,18 @@ static int ParseJSS( vlc_object_t *p_obj, subs_properties_t *p_props,
         if( sscanf( s, "%d:%d:%d.%d %d:%d:%d.%d %[^\n\r]",
                     &h1, &m1, &s1, &f1, &h2, &m2, &s2, &f2, psz_text ) == 9 )
         {
-            p_subtitle->i_start = vlc_tick_from_sec( ( h1 *3600 + m1 * 60 + s1 ) +
+            p_subtitle->i_start = VLC_TICK_0 + vlc_tick_from_sec( ( h1 *3600 + m1 * 60 + s1 ) +
                 (int64_t)( ( f1 +  p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution ) );
-            p_subtitle->i_stop = vlc_tick_from_sec( ( h2 *3600 + m2 * 60 + s2 ) +
+            p_subtitle->i_stop = VLC_TICK_0 + vlc_tick_from_sec( ( h2 *3600 + m2 * 60 + s2 ) +
                 (int64_t)( ( f2 +  p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution ) );
             break;
         }
         /* Short time lines */
         else if( sscanf( s, "@%d @%d %[^\n\r]", &f1, &f2, psz_text ) == 3 )
         {
-            p_subtitle->i_start =
+            p_subtitle->i_start = VLC_TICK_0 +
                     vlc_tick_from_sec( (f1 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution );
-            p_subtitle->i_stop =
+            p_subtitle->i_stop = VLC_TICK_0 +
                     vlc_tick_from_sec( (f2 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution );
             break;
         }
@@ -2064,8 +2064,8 @@ static int ParsePSB( vlc_object_t *p_obj, subs_properties_t *p_props,
         if( sscanf( s, "{%d:%d:%d}{%d:%d:%d}%[^\r\n]",
                     &h1, &m1, &s1, &h2, &m2, &s2, psz_text ) == 7 )
         {
-            p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
-            p_subtitle->i_stop  = vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 );
+            p_subtitle->i_start = VLC_TICK_0 + vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
+            p_subtitle->i_stop  = VLC_TICK_0 + vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 );
             break;
         }
         free( psz_text );
@@ -2139,10 +2139,10 @@ static int ParseRealText( vlc_object_t *p_obj, subs_properties_t *p_props,
 
             /* Get the times */
             int64_t i_time = ParseRealTime( psz_begin, &h1, &m1, &s1, &f1 );
-            p_subtitle->i_start = i_time >= 0 ? i_time : 0;
+            p_subtitle->i_start = VLC_TICK_0 + (i_time >= 0 ? i_time : 0);
 
             i_time = ParseRealTime( psz_end, &h2, &m2, &s2, &f2 );
-            p_subtitle->i_stop = i_time >= 0 ? i_time : -1;
+            p_subtitle->i_stop = VLC_TICK_0 + (i_time >= 0 ? i_time : -1);
             break;
         }
     }
@@ -2211,7 +2211,7 @@ static int ParseDKS( vlc_object_t *p_obj, subs_properties_t *p_props,
         if( sscanf( s, "[%d:%d:%d]%[^\r\n]",
                     &h1, &m1, &s1, psz_text ) == 4 )
         {
-            p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
+            p_subtitle->i_start = VLC_TICK_0 + vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
 
             s = TextGetLine( txt );
             if( !s )
@@ -2260,7 +2260,7 @@ static int ParseSubViewer1( vlc_object_t *p_obj, subs_properties_t *p_props,
 
         if( sscanf( s, "[%d:%d:%d]", &h1, &m1, &s1 ) == 3 )
         {
-            p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
+            p_subtitle->i_start = VLC_TICK_0 + vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
 
             s = TextGetLine( txt );
             if( !s )
@@ -2313,10 +2313,10 @@ static int ParseCommonSBV( vlc_object_t *p_obj, subs_properties_t *p_props,
                     &h2, &m2, &s2, &d2 ) == 8 )
         {
             p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 ) +
-                                  VLC_TICK_FROM_MS( d1 );
+                                  VLC_TICK_FROM_MS( d1 ) + VLC_TICK_0;
 
             p_subtitle->i_stop  = vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 ) +
-                                  VLC_TICK_FROM_MS( d2 );
+                                  VLC_TICK_FROM_MS( d2 ) + VLC_TICK_0;
             if( p_subtitle->i_start < p_subtitle->i_stop )
                 break;
         }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6dc0701b983082cd8fc7155ca608a8ceff2a0af6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6dc0701b983082cd8fc7155ca608a8ceff2a0af6
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list