[vlc-commits] [Git][videolan/vlc][3.0.x] 19 commits: demux: subtitle: use an integer for the mpsub factor

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Wed Mar 12 11:03:19 UTC 2025



Felix Paul Kühne pushed to branch 3.0.x at VideoLAN / VLC


Commits:
5e823c0c by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: use an integer for the mpsub factor

it's never a floating value

(cherry picked from commit 7572803a07fdd5ccfc5afb7e6ada724cb4277883)

- - - - -
86b93c7c by Steve Lhomme at 2025-03-12T10:05:48+00:00
vlc_tick: add helper macros to convert seconds to/from vlc_tick_t

(cherry picked from commit 58a6a21271f8d3db5f48418488c0dece09d94247) (edited)
edited:
- the file modified is vlc_mtime.h and not vlc_tick.h

- - - - -
6df317b6 by Steve Lhomme at 2025-03-12T10:05:48+00:00
vlc_tick: remove C++ long variant of vlc_tick_from_sec()

it collides with the int64_t variant on some platform

(cherry picked from commit 2d4a266663c225b137060b41e37fb7611fe63522) (edited)
edited:
- the file modified is vlc_mtime.h and not vlc_tick.h

- - - - -
05584003 by Hugo Beauzée-Luyssen at 2025-03-12T10:05:48+00:00
vlc_ticks: Simplify C++ integer variants of vlc_tick_from_sec

(cherry picked from commit af03afe3e17069728fac9458fb43ab3921042f82) (edited)
edited:
- the file modified is vlc_mtime.h and not vlc_tick.h

- - - - -
5749ca3d by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: adaptive: remove local variants of vlc_tick conversions

- - - - -
6639b101 by Steve Lhomme at 2025-03-12T10:05:48+00:00
modules: transform milliseconds value into vlc_tick_t with VLC_TICK_FROM_MS

(cherry picked from commit 25d7af9c59e3a9aac7174c1f4aff595d6808f03b) (edited)
edited:
- 3.0 uses mdate/msleep instead of the vlc_tick API

- - - - -
d6b72946 by Steve Lhomme at 2025-03-12T10:05:48+00:00
modules: transform vlc_tick_t value from seconds with vlc_tick_from_sec

(cherry picked from commit ca5fc95f6366d4c079ec574411934ac52ed8683e) (edited)
edited:
- CLOCK_FREQ was not used as 04db84cd9cdace60ce450d269414ac0923dc857f was
not backported

- - - - -
9a7f8217 by François Cartegnie at 2025-03-12T10:05:48+00:00
demux: subtitle: add missing TS_0 offset

(cherry picked from commit 6dc0701b983082cd8fc7155ca608a8ceff2a0af6) (rebased)
rebased:
- us_strtof has not been renamed to vlc_strtof_c

- - - - -
3b16df6e by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: only allocate internal psz_text when needed

(cherry picked from commit 3f110c9571560f07ef3ce543410cb5f800c8e84a)

- - - - -
7208fbbc by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: avoid using strcat when we know the string sizes

We're just concatenating the lines in psz_text.

(cherry picked from commit e8f7ac273de7ec0bf2e87dbc8c4cacf0800f9927)

- - - - -
390951f9 by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: keep the size of the concatenated string

No need to do a lengthy strlen() call each time the concatenated string grows.

(cherry picked from commit 1e03b716637ff7180a169454ccbf88a2a4f9f8f3)

- - - - -
72958083 by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: avoid allocating a dummy string

realloc works fine on NULL.
The pointer is set in p_subtitle->psz_text which is free'd later.
It's OK to free a NULL pointer if there wasn't any line to use.

(cherry picked from commit de7e5074734d39a6cfde69a0fe3212b61333a795)

- - - - -
a5a1f510 by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: only set the string terminator on loop exit

No need to set it on each iteration.

(cherry picked from commit 1f9b8484003d74e1b1a6e0bd4c8b738bafd8aa9d)

- - - - -
2d3548ee by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: check mpsub timing line early

Most of the time that's the first line we will get.
If not the line can contain different things other than a FORMAT setting.

And calling vlc_strtof_c without checking the lines contains 2 values
was bound to use 0 if the line did not actually contain numbers.

(cherry picked from commit dcb0dfcc32f12baaf4ca4b8e9969601d8c847763) (edited)
edited:
- us_strtof has not been renamed to vlc_strtof_c

- - - - -
66feed43 by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: skip mpsub comment and empty lines early

(cherry picked from commit 8e78d79215fefd3a34154504ff8dc4d3460d282e)

- - - - -
089a5c67 by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: check for the "FORMAT=" string once

(cherry picked from commit 5fa5916a60f5a61f483ca78c8793105686a90189) (rebased)
rebased:
- us_strtof has not been renamed to vlc_strtof_c

- - - - -
f79221ee by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: simplify "FORMAT=TIME*" check

(cherry picked from commit 3c4cff54b5b39b33a785036e746ea0502ac55c14)

- - - - -
8afa165d by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: don't break when using FPS in mpsub

We still need to look for the wait & duration values after that.

(cherry picked from commit 107de58d1786b47f2c2c7c5591b623140d5b4210) (rebased)
rebased:
- sub-original-fps is called sub-fps on 3.0

- - - - -
ce971ea7 by Steve Lhomme at 2025-03-12T10:05:48+00:00
demux: subtitle: check the FORMAT= value is a number in mpsub

We don't need vlc_strtof_c() since we already have the float value.
We also don't need to check what is after the number (a comment for example).
As long as it's a number it should be FPS. Anything else other than
"FORMAT=TIME" is bogus. So we don't need to get the remaining part of the string.

(cherry picked from commit a2c276959052b592fb37eeed0968ffeac02f0014) (edited)
edited:
- us_strtof has not been renamed to vlc_strtof_c
- sub-original-fps is called sub-fps on 3.0

- - - - -


24 changed files:

- include/vlc_mtime.h
- modules/access/dtv/bdagraph.cpp
- modules/access/dvb/linux_dvb.c
- modules/access_output/udp.c
- modules/audio_filter/audiobargraph_a.c
- modules/codec/avcodec/subtitle.c
- modules/codec/cea708.c
- modules/codec/spudec/parse.c
- modules/codec/ttml/ttml.c
- modules/demux/adaptive/test/playlist/M3U8.cpp
- modules/demux/adaptive/test/plumbing/CommandsQueue.cpp
- modules/demux/adaptive/test/tools/Conversions.cpp
- modules/demux/mpeg/es.c
- modules/demux/playlist/xspf.c
- modules/demux/real.c
- modules/demux/subtitle.c
- modules/demux/vobsub.c
- modules/demux/xiph_metadata.c
- modules/services_discovery/mtp.c
- modules/spu/logo.c
- modules/stream_out/bridge.c
- modules/stream_out/delay.c
- modules/stream_out/rtp.c
- src/stream_output/stream_output.c


Changes:

=====================================
include/vlc_mtime.h
=====================================
@@ -56,6 +56,52 @@
 #define MS_FROM_VLC_TICK(vtk) ((vtk) * 1000 / CLOCK_FREQ)
 #endif /* CLOCK_FREQ / 1000 */
 
+
+/*
+ * vlc_tick_t <> seconds (sec) conversions
+ */
+#define VLC_TICK_FROM_SEC(sec)   (CLOCK_FREQ * (sec))
+#define SEC_FROM_VLC_TICK(vtk)   ((vtk) / CLOCK_FREQ)
+
+#ifdef __cplusplus
+#include <type_traits>
+
+template <typename T>
+static inline auto vlc_tick_from_sec(T sec)
+    -> typename std::enable_if<std::is_integral<T>::value, vlc_tick_t>::type
+{
+    return CLOCK_FREQ * sec;
+}
+
+/* seconds in floating point */
+static inline vlc_tick_t vlc_tick_from_sec(double secf)
+{
+    return (vlc_tick_t)(CLOCK_FREQ * secf); /* TODO use llround ? */
+}
+#else /* !__cplusplus */
+static inline vlc_tick_t vlc_tick_from_seci(int64_t sec)
+{
+    return CLOCK_FREQ * sec;
+}
+/* seconds in floating point */
+static inline vlc_tick_t vlc_tick_from_secf(double secf)
+{
+    return (vlc_tick_t)(CLOCK_FREQ * secf); /* TODO use llround ? */
+}
+
+#define vlc_tick_from_sec(sec) _Generic((sec), \
+        double:  vlc_tick_from_secf(sec), \
+        float:   vlc_tick_from_secf(sec), \
+        default: vlc_tick_from_seci(sec) )
+#endif /* !__cplusplus */
+
+/* seconds in floating point from vlc_tick_t */
+static inline double secf_from_vlc_tick(vlc_tick_t vtk)
+{
+    return (double)vtk / (double)CLOCK_FREQ;
+}
+
+
 /*****************************************************************************
  * MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
  *****************************************************************************


=====================================
modules/access/dtv/bdagraph.cpp
=====================================
@@ -340,7 +340,7 @@ ssize_t BDAOutput::Pop(void *buf, size_t len, int ms)
 
     vlc_mutex_locker l( &lock );
 
-    vlc_tick_t i_deadline = mdate() + ms * 1000;
+    vlc_tick_t i_deadline = mdate() + VLC_TICK_FROM_MS( ms );
     while( !p_first )
     {
         if( vlc_cond_timedwait( &wait, &lock, i_deadline ) )


=====================================
modules/access/dvb/linux_dvb.c
=====================================
@@ -713,7 +713,7 @@ static int DoDiseqc( vlc_object_t *p_access, dvb_sys_t *p_sys )
             return VLC_EGENERIC;
         }
 
-        msleep(15000 + cmd.wait * 1000);
+        msleep(VLC_TICK_FROM_MS(15 + cmd.wait));
 
         /* A or B simple diseqc ("diseqc-compatible") */
         if( ioctl( p_sys->i_frontend_handle, FE_DISEQC_SEND_BURST,


=====================================
modules/access_output/udp.c
=====================================
@@ -204,8 +204,8 @@ static int Open( vlc_object_t *p_this )
     }
     shutdown( i_handle, SHUT_RD );
 
-    p_sys->i_caching = UINT64_C(1000)
-                     * var_GetInteger( p_access, SOUT_CFG_PREFIX "caching");
+    p_sys->i_caching = VLC_TICK_FROM_MS(
+                     var_GetInteger( p_access, SOUT_CFG_PREFIX "caching") );
     p_sys->i_handle = i_handle;
     p_sys->i_mtu = var_CreateGetInteger( p_this, "mtu" );
     p_sys->b_mtu_warning = false;


=====================================
modules/audio_filter/audiobargraph_a.c
=====================================
@@ -97,9 +97,9 @@ struct filter_sys_t
     bool            bargraph;
     int             bargraph_repetition;
     bool            silence;
-    int64_t         time_window;
+    vlc_tick_t      time_window;
     float           alarm_threshold;
-    int64_t         repetition_time;
+    vlc_tick_t      repetition_time;
     int             counter;
     ValueDate_t*    first;
     ValueDate_t*    last;
@@ -126,9 +126,9 @@ static int Open( vlc_object_t *p_this )
     p_sys->bargraph = !!var_CreateGetInteger(p_filter, CFG_PREFIX "bargraph");
     p_sys->bargraph_repetition = var_CreateGetInteger(p_filter, CFG_PREFIX "bargraph_repetition");
     p_sys->silence = !!var_CreateGetInteger(p_filter, CFG_PREFIX "silence");
-    p_sys->time_window = var_CreateGetInteger(p_filter, CFG_PREFIX "time_window") * 1000;
+    p_sys->time_window = VLC_TICK_FROM_MS( var_CreateGetInteger(p_filter, CFG_PREFIX "time_window") );
     p_sys->alarm_threshold = var_CreateGetFloat(p_filter, CFG_PREFIX "alarm_threshold");
-    p_sys->repetition_time = var_CreateGetInteger(p_filter, CFG_PREFIX "repetition_time") * 1000;
+    p_sys->repetition_time = VLC_TICK_FROM_MS( var_CreateGetInteger(p_filter, CFG_PREFIX "repetition_time") );
     p_sys->counter = 0;
     p_sys->first = NULL;
     p_sys->last = NULL;


=====================================
modules/codec/avcodec/subtitle.c
=====================================
@@ -297,8 +297,8 @@ static subpicture_t *ConvertSubtitle(decoder_t *dec, AVSubtitle *ffsub, vlc_tick
 
     //msg_Err(dec, "%lld %d %d",
     //        pts, ffsub->start_display_time, ffsub->end_display_time);
-    spu->i_start    = pts + ffsub->start_display_time * INT64_C(1000);
-    spu->i_stop     = pts + ffsub->end_display_time * INT64_C(1000);
+    spu->i_start    = pts + VLC_TICK_FROM_MS(ffsub->start_display_time);
+    spu->i_stop     = pts + VLC_TICK_FROM_MS(ffsub->end_display_time);
     spu->b_absolute = true; /* We have offset and size for subtitle */
     spu->b_ephemer  = dec->p_sys->b_need_ephemer;
                     /* We only show subtitle for i_stop time only */


=====================================
modules/codec/cea708.c
=====================================
@@ -1375,7 +1375,7 @@ static int CEA708_Decode_C1( uint8_t code, cea708_t *p_cea708 )
         case CEA708_C1_DLY:
             REQUIRE_ARGS_AND_POP_COMMAND(1);
             p_cea708->suspended_deadline = p_cea708->i_clock +
-                    cea708_input_buffer_get( ib ) * 100 * 1000;
+                    VLC_TICK_FROM_MS( cea708_input_buffer_get( ib ) * 100 );
             Debug(printf("[DLY]"));
             break;
         case CEA708_C1_DLC:


=====================================
modules/codec/spudec/parse.c
=====================================
@@ -390,7 +390,7 @@ static int ParseControlSeq( decoder_t *p_dec, vlc_tick_t i_pts,
             b_cmd_offset = false;
             b_cmd_alpha = false;
             /* Get the control sequence date */
-            date = (vlc_tick_t)GetWBE( &p_sys->buffer[i_index] ) * 11000;
+            date = VLC_TICK_FROM_MS(GetWBE( &p_sys->buffer[i_index] ) * 11);
 
             /* Next offset */
             i_cur_seq = i_index;


=====================================
modules/codec/ttml/ttml.c
=====================================
@@ -114,7 +114,7 @@ static tt_time_t tt_ParseTime( const char *s )
             if( *psz_end == 'm' )
             {
                 if( *(psz_end + 1) == 's' )
-                    t.base = 1000 * v;
+                    t.base = VLC_TICK_FROM_MS(v);
                 else
                     t.base = CLOCK_FREQ * 60 * v;
             }


=====================================
modules/demux/adaptive/test/playlist/M3U8.cpp
=====================================
@@ -45,9 +45,6 @@ using namespace adaptive;
 using namespace adaptive::playlist;
 using namespace hls::playlist;
 
-#define vlc_tick_from_sec(a) (CLOCK_FREQ * (a))
-#define SEC_FROM_VLC_TICK(a) ((a)/CLOCK_FREQ)
-
 static M3U8 * ParseM3U8(vlc_object_t *obj, const char *psz, size_t isz)
 {
     M3U8Parser parser(nullptr);


=====================================
modules/demux/adaptive/test/plumbing/CommandsQueue.cpp
=====================================
@@ -37,8 +37,6 @@ using namespace adaptive;
 
 using OutputVal = std::pair<const AbstractFakeESOutID *, block_t *>;
 
-#define vlc_tick_from_sec(a) (CLOCK_FREQ * (a))
-
 class TestEsOut : public AbstractFakeEsOut
 {
     public:


=====================================
modules/demux/adaptive/test/tools/Conversions.cpp
=====================================
@@ -26,8 +26,6 @@
 #include "../test.hpp"
 
 #include <limits>
-#define vlc_tick_from_sec(a) (CLOCK_FREQ * (a))
-#define VLC_TICK_FROM_MS(a) (1000 * (a))
 
 int Conversions_test()
 {


=====================================
modules/demux/mpeg/es.c
=====================================
@@ -872,7 +872,7 @@ static uint64_t SeekByMlltTable( demux_t *p_demux, vlc_tick_t *pi_time )
     {
         const uint32_t i_bytesdev = bs_read(&p_cur->br, p_sys->mllt.i_bits_per_bytes_dev);
         const uint32_t i_msdev = bs_read(&p_cur->br, p_sys->mllt.i_bits_per_ms_dev);
-        const vlc_tick_t i_deltatime = (p_sys->mllt.i_ms_btw_refs + i_msdev) * INT64_C(1000);
+        const vlc_tick_t i_deltatime = VLC_TICK_FROM_MS(p_sys->mllt.i_ms_btw_refs + i_msdev);
         if( p_cur->i_time + i_deltatime > *pi_time )
             break;
         p_cur->i_time += i_deltatime;


=====================================
modules/demux/playlist/xspf.c
=====================================
@@ -525,7 +525,7 @@ static bool set_item_info SIMPLE_INTERFACE
     else if (!strcmp(psz_name, "trackNum"))
         input_item_SetTrackNum(p_input, psz_value);
     else if (!strcmp(psz_name, "duration"))
-        p_input->i_duration = atol(psz_value) * INT64_C(1000);
+        p_input->i_duration = VLC_TICK_FROM_MS(atol(psz_value));
     else if (!strcmp(psz_name, "annotation"))
         input_item_SetDescription(p_input, psz_value);
     else if (!strcmp(psz_name, "info"))


=====================================
modules/demux/real.c
=====================================
@@ -306,7 +306,7 @@ static int Demux( demux_t *p_demux )
     //const int i_version = GetWBE( &header[0] );
     const size_t  i_size = GetWBE( &header[2] ) - 12;
     const int     i_id   = GetWBE( &header[4] );
-    const int64_t i_pts  = VLC_TICK_0 + 1000 * GetDWBE( &header[6] );
+    const vlc_tick_t i_pts  = VLC_TICK_0 + VLC_TICK_FROM_MS(GetDWBE( &header[6] ));
     const int     i_flags= header[11]; /* flags 0x02 -> keyframe */
 
     p_sys->i_data_packets++;


=====================================
modules/demux/subtitle.c
=====================================
@@ -157,7 +157,7 @@ typedef struct
         bool  b_inited;
 
         float f_total;
-        float f_factor;
+        int i_factor;
     } mpsub;
 
     struct
@@ -255,6 +255,9 @@ static char * get_language_from_filename( const char * );
 
 static block_t *ToTextBlock( const subtitle_t *p_subtitle )
 {
+    if ( p_subtitle->psz_text == NULL )
+        return NULL;
+
     block_t *p_block;
     size_t i_len = strlen( p_subtitle->psz_text ) + 1;
 
@@ -268,6 +271,9 @@ static block_t *ToTextBlock( const subtitle_t *p_subtitle )
 
 static block_t *ToEIA608Block( const subtitle_t *p_subtitle )
 {
+    if ( p_subtitle->psz_text == NULL )
+        return NULL;
+
     block_t *p_block;
     const size_t i_len = strlen( p_subtitle->psz_text );
     const size_t i_block = (1 + i_len / 5) * 3;
@@ -1028,8 +1034,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;
 }
@@ -1074,31 +1080,29 @@ static int ParseSubRipSubViewer( vlc_object_t *p_obj, subs_properties_t *p_props
     }
 
     /* Now read text until an empty line */
-    psz_text = strdup("");
-    if( !psz_text )
-        return VLC_ENOMEM;
-
+    size_t i_old = 0;
+    psz_text = NULL;
     for( ;; )
     {
         const char *s = TextGetLine( txt );
         size_t i_len;
-        size_t i_old;
 
         i_len = s ? strlen( s ) : 0;
         if( i_len <= 0 )
         {
+            if (psz_text)
+                psz_text[i_old] = '\0';
             p_subtitle->psz_text = psz_text;
             return VLC_SUCCESS;
         }
 
-        i_old = strlen( psz_text );
         psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
         if( !psz_text )
-        {
             return VLC_ENOMEM;
-        }
-        strcat( psz_text, s );
-        strcat( psz_text, "\n" );
+
+        memcpy( &psz_text[i_old], s, i_len );
+        psz_text[i_old + i_len + 0] = '\n';
+        i_old += i_len + 1;
 
         /* replace [br] by \n */
         if( b_replace_br )
@@ -1109,6 +1113,7 @@ static int ParseSubRipSubViewer( vlc_object_t *p_obj, subs_properties_t *p_props
             {
                 *p++ = '\n';
                 memmove( p, &p[3], strlen(&p[3])+1 );
+                i_old -= 3;
             }
         }
     }
@@ -1129,10 +1134,8 @@ static int subtitle_ParseSubRipTimingValue(int64_t *timing_value,
          sscanf( s, "%d:%d:%d",
                  &h1, &m1, &s1) == 3 )
     {
-        (*timing_value) = ( (int64_t)h1 * 3600 * 1000 +
-                            (int64_t)m1 * 60 * 1000 +
-                            (int64_t)s1 * 1000 +
-                            (int64_t)d1 ) * 1000;
+        (*timing_value) = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1) +
+                          VLC_TICK_FROM_MS( d1 );
 
         return VLC_SUCCESS;
     }
@@ -1186,15 +1189,11 @@ static int subtitle_ParseSubViewerTiming( subtitle_t *p_subtitle,
     if( sscanf( s, "%d:%d:%d.%d,%d:%d:%d.%d",
                 &h1, &m1, &s1, &d1, &h2, &m2, &s2, &d2) == 8 )
     {
-        p_subtitle->i_start = ( (int64_t)h1 * 3600*1000 +
-                                (int64_t)m1 * 60*1000 +
-                                (int64_t)s1 * 1000 +
-                                (int64_t)d1 ) * 1000;
+        p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1) +
+                              VLC_TICK_FROM_MS( d1 ) + VLC_TICK_0;
 
-        p_subtitle->i_stop  = ( (int64_t)h2 * 3600*1000 +
-                                (int64_t)m2 * 60*1000 +
-                                (int64_t)s2 * 1000 +
-                                (int64_t)d2 ) * 1000;
+        p_subtitle->i_stop  = vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 ) +
+                              VLC_TICK_FROM_MS( d2 ) + VLC_TICK_0;
         return VLC_SUCCESS;
     }
     return VLC_EGENERIC;
@@ -1279,14 +1278,10 @@ static int  ParseSSA( vlc_object_t *p_obj, subs_properties_t *p_props,
                 psz_text = psz_temp;
             }
 
-            p_subtitle->i_start = ( (int64_t)h1 * 3600*1000 +
-                                    (int64_t)m1 * 60*1000 +
-                                    (int64_t)s1 * 1000 +
-                                    (int64_t)c1 * 10 ) * 1000;
-            p_subtitle->i_stop  = ( (int64_t)h2 * 3600*1000 +
-                                    (int64_t)m2 * 60*1000 +
-                                    (int64_t)s2 * 1000 +
-                                    (int64_t)c2 * 10 ) * 1000;
+            p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 ) +
+                                  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_0;
             p_subtitle->psz_text = psz_text;
             return VLC_SUCCESS;
         }
@@ -1335,9 +1330,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 = ( (int64_t)h1 * 3600*1000 +
-                                    (int64_t)m1 * 60*1000 +
-                                    (int64_t)s1 * 1000 ) * 1000;
+            p_subtitle->i_start = VLC_TICK_0 + vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
             p_subtitle->i_stop  = -1;
             break;
         }
@@ -1454,7 +1447,7 @@ static int ParseSami( vlc_object_t *p_obj, subs_properties_t *p_props,
         }
     }
 
-    p_subtitle->i_start = i_start * 1000;
+    p_subtitle->i_start = VLC_TICK_0 + VLC_TICK_FROM_MS(i_start);
     p_subtitle->i_stop  = -1;
     p_subtitle->psz_text = strdup( text );
 
@@ -1498,24 +1491,20 @@ static int ParseDVDSubtitle(vlc_object_t *p_obj, subs_properties_t *p_props,
                     "{T %d:%d:%d:%d",
                     &h1, &m1, &s1, &c1 ) == 4 )
         {
-            p_subtitle->i_start = ( (int64_t)h1 * 3600*1000 +
-                                    (int64_t)m1 * 60*1000 +
-                                    (int64_t)s1 * 1000 +
-                                    (int64_t)c1 * 10) * 1000;
+            p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 ) +
+                                  VLC_TICK_FROM_MS( c1 * 10 ) + VLC_TICK_0;
             p_subtitle->i_stop = -1;
             break;
         }
     }
 
     /* Now read text until a line containing "}" */
-    psz_text = strdup("");
-    if( !psz_text )
-        return VLC_ENOMEM;
+    size_t i_old = 0;
+    psz_text = NULL;
     for( ;; )
     {
         const char *s = TextGetLine( txt );
-        int i_len;
-        int i_old;
+        size_t i_len;
 
         if( !s )
         {
@@ -1526,16 +1515,19 @@ static int ParseDVDSubtitle(vlc_object_t *p_obj, subs_properties_t *p_props,
         i_len = strlen( s );
         if( i_len == 1 && s[0] == '}')
         {
+            if (psz_text)
+                psz_text[i_old] = '\0';
             p_subtitle->psz_text = psz_text;
             return VLC_SUCCESS;
         }
 
-        i_old = strlen( psz_text );
         psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
         if( !psz_text )
             return VLC_ENOMEM;
-        strcat( psz_text, s );
-        strcat( psz_text, "\n" );
+
+        memcpy( &psz_text[i_old], s, i_len );
+        psz_text[i_old + i_len + 0] = '\n';
+        i_old += i_len + 1;
     }
 }
 
@@ -1571,8 +1563,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 = (int64_t)i_start * 100000;
-            p_subtitle->i_stop  = i_stop >= 0 ? ((int64_t)i_stop  * 100000) : -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 );
@@ -1600,8 +1592,9 @@ static int ParseAQT(vlc_object_t *p_obj, subs_properties_t *p_props, text_t *txt
     VLC_UNUSED(p_props);
     VLC_UNUSED( i_idx );
 
-    char *psz_text = strdup( "" );
-    int i_old = 0;
+    char *psz_text = NULL;
+    size_t i_old = 0;
+    size_t i_len;
     int i_firstline = 1;
 
     for( ;; )
@@ -1622,29 +1615,33 @@ 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;
             }
         }
         /* Text Lines */
         else
         {
-            i_old = strlen( psz_text ) + 1;
-            psz_text = realloc_or_free( psz_text, i_old + strlen( s ) + 1 );
+            i_len = strlen( s );
+            psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
             if( !psz_text )
                  return VLC_ENOMEM;
-            strcat( psz_text, s );
-            strcat( psz_text, "\n" );
+
+            memcpy( &psz_text[i_old], s, i_len );
+            psz_text[i_old + i_len + 0] = '\n';
+            i_old += i_len + 1;
             if( txt->i_line == txt->i_line_count )
                 break;
         }
     }
+    if (psz_text)
+        psz_text[i_old] = '\0';
     p_subtitle->psz_text = psz_text;
     return VLC_SUCCESS;
 }
@@ -1675,8 +1672,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';
 
@@ -1702,70 +1699,62 @@ static int ParseMPSub( vlc_object_t *p_obj, subs_properties_t *p_props,
 {
     VLC_UNUSED( i_idx );
 
-    char *psz_text = strdup( "" );
-
     if( !p_props->mpsub.b_inited )
     {
         p_props->mpsub.f_total = 0.0;
-        p_props->mpsub.f_factor = 0.0;
+        p_props->mpsub.i_factor = 0;
 
         p_props->mpsub.b_inited = true;
     }
 
     for( ;; )
     {
-        char p_dummy;
-        char *psz_temp;
-
         const char *s = TextGetLine( txt );
         if( !s )
         {
-            free( psz_text );
             return VLC_EGENERIC;
         }
 
-        if( strstr( s, "FORMAT" ) )
+        if ( *s =='#' || *s == '\0' )
+            continue;
+
+        /* Data Lines */
+        float wait, duration;
+        if( sscanf( s, "%f %f", &wait, &duration ) == 2 )
         {
-            if( sscanf (s, "FORMAT=TIM%c", &p_dummy ) == 1 && p_dummy == 'E')
-            {
-                p_props->mpsub.f_factor = 100.0;
-                break;
-            }
+            float f1 = wait;
+            float f2 = duration;
+            p_props->mpsub.f_total += f1 * p_props->mpsub.i_factor;
+            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 = VLC_TICK_0 + llroundf(10000.f * p_props->mpsub.f_total);
+            break;
+        }
 
-            psz_temp = malloc( strlen(s) );
-            if( !psz_temp )
+        if( !strncmp( s, "FORMAT=", strlen("FORMAT=") ) )
+        {
+            const char *psz_format = s + strlen( "FORMAT=" );
+            if( !strncmp( psz_format, "TIME", strlen("TIME") ) && (psz_format[4] == '\0' || psz_format[4] == ' ') )
             {
-                free( psz_text );
-                return VLC_ENOMEM;
+                // FORMAT=TIME may be followed by a comment
+                p_props->mpsub.i_factor = 100;
             }
-
-            if( sscanf( s, "FORMAT=%[^\r\n]", psz_temp ) )
+            else
             {
-                float f_fps = us_strtof( psz_temp, NULL );
-
-                if( f_fps > 0.f && var_GetFloat( p_obj, "sub-fps" ) <= 0.f )
-                    var_SetFloat( p_obj, "sub-fps", f_fps );
+                float f_fps;
+                if( sscanf( psz_format, "%f", &f_fps ) == 1 )
+                {
+                    if( f_fps > 0.f && var_GetFloat( p_obj, "sub-fps" ) <= 0.f )
+                        var_SetFloat( p_obj, "sub-fps", f_fps );
 
-                p_props->mpsub.f_factor = 1.f;
-                free( psz_temp );
-                break;
+                    p_props->mpsub.i_factor = 1;
+                }
             }
-            free( psz_temp );
-        }
-
-        /* Data Lines */
-        float f1 = us_strtof( s, &psz_temp );
-        if( *psz_temp )
-        {
-            float f2 = us_strtof( psz_temp, NULL );
-            p_props->mpsub.f_total += f1 * p_props->mpsub.f_factor;
-            p_subtitle->i_start = llroundf(10000.f * p_props->mpsub.f_total);
-            p_props->mpsub.f_total += f2 * p_props->mpsub.f_factor;
-            p_subtitle->i_stop = llroundf(10000.f * p_props->mpsub.f_total);
-            break;
         }
     }
 
+    char *psz_text = NULL;
+    size_t i_old = 0;
     for( ;; )
     {
         const char *s = TextGetLine( txt );
@@ -1780,16 +1769,17 @@ static int ParseMPSub( vlc_object_t *p_obj, subs_properties_t *p_props,
         if( i_len == 0 )
             break;
 
-        size_t i_old = strlen( psz_text );
-
         psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
         if( !psz_text )
              return VLC_ENOMEM;
 
-        strcat( psz_text, s );
-        strcat( psz_text, "\n" );
+        memcpy( &psz_text[i_old], s, i_len );
+        psz_text[i_old + i_len + 0] = '\n';
+        i_old += i_len + 1;
     }
 
+    if (psz_text)
+        psz_text[i_old] = '\0';
     p_subtitle->psz_text = psz_text;
     return VLC_SUCCESS;
 }
@@ -1828,21 +1818,19 @@ 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 = ( ( (int64_t) h1 *3600 + m1 * 60 + s1 ) +
-                (int64_t)( ( f1 +  p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution ) )
-                * 1000000;
-            p_subtitle->i_stop = ( ( (int64_t) h2 *3600 + m2 * 60 + s2 ) +
-                (int64_t)( ( f2 +  p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution ) )
-                * 1000000;
+            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_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 = ((int64_t)
-                    ( f1 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution * 1000000.0 );
-            p_subtitle->i_stop = ((int64_t)
-                    ( f2 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution * 1000000.0 );
+            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 = VLC_TICK_0 +
+                    vlc_tick_from_sec( (f2 + p_props->jss.i_time_shift ) / p_props->jss.i_time_resolution );
             break;
         }
         /* General Directive lines */
@@ -2067,12 +2055,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 = ( (int64_t)h1 * 3600*1000 +
-                                    (int64_t)m1 * 60*1000 +
-                                    (int64_t)s1 * 1000 ) * 1000;
-            p_subtitle->i_stop  = ( (int64_t)h2 * 3600*1000 +
-                                    (int64_t)m2 * 60*1000 +
-                                    (int64_t)s2 * 1000 ) * 1000;
+            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 );
@@ -2097,8 +2081,8 @@ static int64_t ParseRealTime( char *psz, int *h, int *m, int *s, int *f )
             sscanf( psz, "%d:%d", m, s ) == 2 ||
             sscanf( psz, "%d", s ) == 1 )
     {
-        return (int64_t)((( *h * 60 + *m ) * 60 ) + *s ) * 1000 * 1000
-               + (int64_t)*f * 10 * 1000;
+        return vlc_tick_from_sec((( *h * 60 + *m ) * 60 ) + *s )
+               + VLC_TICK_FROM_MS(*f * 10);
     }
     else return VLC_EGENERIC;
 }
@@ -2146,15 +2130,16 @@ 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;
         }
     }
 
     /* Get the following Lines */
+    size_t i_old = strlen( psz_text );
     for( ;; )
     {
         const char *s = TextGetLine( txt );
@@ -2175,16 +2160,16 @@ static int ParseRealText( vlc_object_t *p_obj, subs_properties_t *p_props,
             break;
         }
 
-        size_t i_old = strlen( psz_text );
-
         psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
         if( !psz_text )
             return VLC_ENOMEM;
 
-        strcat( psz_text, s );
-        strcat( psz_text, "\n" );
+        memcpy( &psz_text[i_old], s, i_len );
+        psz_text[i_old + i_len + 0] = '\n';
+        i_old += i_len + 1;
     }
 
+    psz_text[i_old] = '\0';
     /* Remove the starting ">" that remained after the sscanf */
     memmove( &psz_text[0], &psz_text[1], strlen( psz_text ) );
 
@@ -2218,9 +2203,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 = ( (int64_t)h1 * 3600*1000 +
-                                    (int64_t)m1 * 60*1000 +
-                                    (int64_t)s1 * 1000 ) * 1000;
+            p_subtitle->i_start = VLC_TICK_0 + vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
 
             s = TextGetLine( txt );
             if( !s )
@@ -2230,9 +2213,7 @@ static int ParseDKS( vlc_object_t *p_obj, subs_properties_t *p_props,
             }
 
             if( sscanf( s, "[%d:%d:%d]", &h2, &m2, &s2 ) == 3 )
-                p_subtitle->i_stop  = ( (int64_t)h2 * 3600*1000 +
-                                        (int64_t)m2 * 60*1000 +
-                                        (int64_t)s2 * 1000 ) * 1000;
+                p_subtitle->i_stop  = vlc_tick_from_sec(h2 * 3600 + m2 * 60 + s2 );
             else
                 p_subtitle->i_stop  = -1;
             break;
@@ -2271,9 +2252,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 = ( (int64_t)h1 * 3600*1000 +
-                                    (int64_t)m1 * 60*1000 +
-                                    (int64_t)s1 * 1000 ) * 1000;
+            p_subtitle->i_start = VLC_TICK_0 + vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 );
 
             s = TextGetLine( txt );
             if( !s )
@@ -2291,9 +2270,7 @@ static int ParseSubViewer1( vlc_object_t *p_obj, subs_properties_t *p_props,
             }
 
             if( sscanf( s, "[%d:%d:%d]", &h2, &m2, &s2 ) == 3 )
-                p_subtitle->i_stop  = ( (int64_t)h2 * 3600*1000 +
-                                        (int64_t)m2 * 60*1000 +
-                                        (int64_t)s2 * 1000 ) * 1000;
+                p_subtitle->i_stop  = vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 );
             else
                 p_subtitle->i_stop  = -1;
 
@@ -2327,45 +2304,40 @@ static int ParseCommonSBV( vlc_object_t *p_obj, subs_properties_t *p_props,
                     &h1, &m1, &s1, &d1,
                     &h2, &m2, &s2, &d2 ) == 8 )
         {
-            p_subtitle->i_start = ( (int64_t)h1 * 3600 * 1000 +
-                                    (int64_t)m1 * 60 * 1000 +
-                                    (int64_t)s1 * 1000 +
-                                    (int64_t)d1 ) * 1000;
-
-            p_subtitle->i_stop  = ( (int64_t)h2 * 3600 * 1000 +
-                                    (int64_t)m2 * 60 * 1000 +
-                                    (int64_t)s2 * 1000 +
-                                    (int64_t)d2 ) * 1000;
+            p_subtitle->i_start = vlc_tick_from_sec( h1 * 3600 + m1 * 60 + s1 ) +
+                                  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_0;
             if( p_subtitle->i_start < p_subtitle->i_stop )
                 break;
         }
     }
 
     /* Now read text until an empty line */
-    psz_text = strdup("");
-    if( !psz_text )
-        return VLC_ENOMEM;
-
+    size_t i_old = 0;
+    psz_text = NULL;
     for( ;; )
     {
         const char *s = TextGetLine( txt );
         size_t i_len;
-        size_t i_old;
 
         i_len = s ? strlen( s ) : 0;
         if( i_len <= 0 )
         {
+            if (psz_text)
+                psz_text[i_old] = '\0';
             p_subtitle->psz_text = psz_text;
             return VLC_SUCCESS;
         }
 
-        i_old = strlen( psz_text );
         psz_text = realloc_or_free( psz_text, i_old + i_len + 1 + 1 );
         if( !psz_text )
             return VLC_ENOMEM;
 
-        strcat( psz_text, s );
-        strcat( psz_text, "\n" );
+        memcpy( &psz_text[i_old], s, i_len );
+        psz_text[i_old + i_len + 0] = '\n';
+        i_old += i_len + 1;
     }
 }
 
@@ -2418,7 +2390,7 @@ static int ParseSCC( vlc_object_t *p_obj, subs_properties_t *p_props,
             continue;
 
         /* convert everything to seconds */
-        vlc_tick_t i_frames = h * 3600 + m * 60 + s;
+        uint64_t i_frames = h * 3600 + m * 60 + s;
 
         if( c == ';' && p_rate->b_drop_allowed ) /* dropframe */
         {
@@ -2433,7 +2405,7 @@ static int ParseSCC( vlc_object_t *p_obj, subs_properties_t *p_props,
             /* convert to frame # at 29.97 */
             i_frames = i_frames * framerates[3].rate.num / framerates[3].rate.den + f;
         }
-        p_subtitle->i_start = VLC_TICK_0 + i_frames * CLOCK_FREQ *
+        p_subtitle->i_start = VLC_TICK_0 + vlc_tick_from_sec(i_frames)*
                                          p_rate->rate.den / p_rate->rate.num;
         p_subtitle->i_stop = -1;
 


=====================================
modules/demux/vobsub.c
=====================================
@@ -590,10 +590,7 @@ static int ParseVobSubIDX( demux_t *p_demux )
                     i_sign = -1;
                     h = -h;
                 }
-                i_start = (int64_t) ( h * 3600*1000 +
-                            m * 60*1000 +
-                            s * 1000 +
-                            ms ) * 1000;
+                i_start = vlc_tick_from_sec( h * 3600 + m * 60 + s ) + VLC_TICK_FROM_MS( ms );
                 i_location = loc;
 
                 current_tk->i_subtitles++;
@@ -630,10 +627,7 @@ static int ParseVobSubIDX( demux_t *p_demux )
                     i_sign = -1;
                     h = -h;
                 }
-                i_gap = (int64_t) ( h * 3600*1000 +
-                            m * 60*1000 +
-                            s * 1000 +
-                            ms ) * 1000;
+                i_gap = vlc_tick_from_sec( h * 3600 + m * 60 + s ) + VLC_TICK_FROM_MS( ms );
 
                 current_tk->i_delay = current_tk->i_delay + (i_gap * i_sign);
                 msg_Dbg( p_demux, "sign: %+d gap: %+"PRId64" global delay: %+"PRId64"",


=====================================
modules/demux/xiph_metadata.c
=====================================
@@ -539,8 +539,7 @@ void vorbis_ParseComment( es_format_t *p_fmt, vlc_meta_t **pp_meta,
                 {
                     p_seekpoint = getChapterEntry( i_chapt, &chapters_array );
                     if ( ! p_seekpoint ) goto next_comment;
-                    p_seekpoint->i_time_offset =
-                      (((int64_t)h * 3600 + (int64_t)m * 60 + (int64_t)s) * 1000 + ms) * 1000;
+                    p_seekpoint->i_time_offset = vlc_tick_from_sec(h * 3600 + m * 60 + s) + VLC_TICK_FROM_MS(ms);
                 }
             }
         }


=====================================
modules/services_discovery/mtp.c
=====================================
@@ -267,7 +267,7 @@ static void AddTrack( services_discovery_t *p_sd, LIBMTP_track_t *p_track )
         free( psz_string );
     }
     input_item_SetDate( p_input, p_track->date );
-    p_input->i_duration = p_track->duration * INT64_C(1000);
+    p_input->i_duration = VLC_TICK_FROM_MS(p_track->duration);
     services_discovery_AddItem( p_sd, p_input );
     p_sd->p_sys->pp_items[p_sd->p_sys->i_count++] = p_input;
 }


=====================================
modules/spu/logo.c
=====================================
@@ -740,8 +740,8 @@ static logo_t *LogoListNext( logo_list_t *p_list, vlc_tick_t i_date )
 
     logo_t *p_logo = LogoListCurrent( p_list );
 
-    p_list->i_next_pic = i_date + ( p_logo->i_delay != -1 ?
-                          p_logo->i_delay : p_list->i_delay ) * 1000;
+    p_list->i_next_pic = i_date + VLC_TICK_FROM_MS( p_logo->i_delay != -1 ?
+                          p_logo->i_delay : p_list->i_delay );
     return p_logo;
 }
 /**


=====================================
modules/stream_out/bridge.c
=====================================
@@ -396,7 +396,7 @@ static int OpenIn( vlc_object_t *p_this )
     p_sys->i_id_offset = val.i_int;
 
     var_Get( p_stream, SOUT_CFG_PREFIX_IN "delay", &val );
-    p_sys->i_delay = (vlc_tick_t)val.i_int * 1000;
+    p_sys->i_delay = VLC_TICK_FROM_MS(val.i_int);
 
     var_Get( p_stream, SOUT_CFG_PREFIX_IN "name", &val );
     if( asprintf( &p_sys->psz_name, "bridge-struct-%s", val.psz_string )<0 )
@@ -416,7 +416,7 @@ static int OpenIn( vlc_object_t *p_this )
     p_sys->i_state = placeholder_on;
 
     var_Get( p_stream, SOUT_CFG_PREFIX_IN "placeholder-delay", &val );
-    p_sys->i_placeholder_delay = (vlc_tick_t)val.i_int * 1000;
+    p_sys->i_placeholder_delay = VLC_TICK_FROM_MS(val.i_int);
 
     p_sys->i_last_video = VLC_TICK_INVALID;
     p_sys->i_last_audio = VLC_TICK_INVALID;


=====================================
modules/stream_out/delay.c
=====================================
@@ -106,7 +106,7 @@ static int Open( vlc_object_t *p_this )
                    p_stream->p_cfg );
 
     p_sys->i_id = var_GetInteger( p_stream, SOUT_CFG_PREFIX "id" );
-    p_sys->i_delay = 1000 * var_GetInteger( p_stream, SOUT_CFG_PREFIX "delay" );
+    p_sys->i_delay = VLC_TICK_FROM_MS(var_GetInteger( p_stream, SOUT_CFG_PREFIX "delay" ));
 
     p_stream->pf_add    = Add;
     p_stream->pf_del    = Del;


=====================================
modules/stream_out/rtp.c
=====================================
@@ -981,7 +981,7 @@ static sout_stream_id_sys_t *Add( sout_stream_t *p_stream,
 
     id->b_first_packet = true;
     id->i_caching =
-        (int64_t)1000 * var_GetInteger( p_stream, SOUT_CFG_PREFIX "caching");
+        VLC_TICK_FROM_MS(var_GetInteger( p_stream, SOUT_CFG_PREFIX "caching"));
 
     vlc_rand_bytes (&id->i_sequence, sizeof (id->i_sequence));
     vlc_rand_bytes (id->ssrc, sizeof (id->ssrc));


=====================================
src/stream_output/stream_output.c
=====================================
@@ -536,7 +536,7 @@ int sout_MuxSendBuffer( sout_mux_t *p_mux, sout_input_t *p_input,
 
     if( p_mux->b_waiting_stream )
     {
-        const int64_t i_caching = var_GetInteger( p_mux->p_sout, "sout-mux-caching" ) * INT64_C(1000);
+        const vlc_tick_t i_caching = VLC_TICK_FROM_MS(var_GetInteger( p_mux->p_sout, "sout-mux-caching" ));
 
         if( p_mux->i_add_stream_start < 0 )
             p_mux->i_add_stream_start = i_dts;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fed25a62527e02fe6b7cfdbb4f36e19a4a9ae0b4...ce971ea70a7dad794490ed39ceea28498e706516

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fed25a62527e02fe6b7cfdbb4f36e19a4a9ae0b4...ce971ea70a7dad794490ed39ceea28498e706516
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