[vlc-commits] modules: transform milliseconds value into vlc_tick_t with VLC_TICK_FROM_MS

Steve Lhomme git at videolan.org
Fri Jul 6 09:29:02 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon May  7 14:05:58 2018 +0200| [25d7af9c59e3a9aac7174c1f4aff595d6808f03b] | committer: Steve Lhomme

modules: transform milliseconds value into vlc_tick_t with VLC_TICK_FROM_MS

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=25d7af9c59e3a9aac7174c1f4aff595d6808f03b
---

 modules/access/dtv/bdagraph.cpp        |  2 +-
 modules/access/dvb/linux_dvb.c         |  2 +-
 modules/access_output/udp.c            |  4 +--
 modules/audio_filter/audiobargraph_a.c |  8 ++---
 modules/codec/avcodec/subtitle.c       |  4 +--
 modules/codec/cea708.c                 |  2 +-
 modules/codec/spudec/parse.c           |  2 +-
 modules/codec/ttml/ttml.c              |  2 +-
 modules/demux/mpeg/es.c                |  2 +-
 modules/demux/playlist/xspf.c          |  2 +-
 modules/demux/real.c                   |  2 +-
 modules/demux/subtitle.c               | 58 ++++++++++++----------------------
 modules/services_discovery/mtp.c       |  2 +-
 modules/spu/logo.c                     |  4 +--
 modules/stream_out/bridge.c            |  4 +--
 modules/stream_out/delay.c             |  2 +-
 modules/stream_out/rtp.c               |  2 +-
 src/stream_output/stream_output.c      |  2 +-
 18 files changed, 45 insertions(+), 61 deletions(-)

diff --git a/modules/access/dtv/bdagraph.cpp b/modules/access/dtv/bdagraph.cpp
index f80f39aad6..907e050294 100644
--- a/modules/access/dtv/bdagraph.cpp
+++ b/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 = vlc_tick_now() + ms * 1000;
+    vlc_tick_t i_deadline = vlc_tick_now() + VLC_TICK_FROM_MS( ms );
     while( !p_first )
     {
         if( vlc_cond_timedwait( &wait, &lock, i_deadline ) )
diff --git a/modules/access/dvb/linux_dvb.c b/modules/access/dvb/linux_dvb.c
index 2650a7213c..ad0112f376 100644
--- a/modules/access/dvb/linux_dvb.c
+++ b/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;
         }
 
-        vlc_tick_sleep(15000 + cmd.wait * 1000);
+        vlc_tick_sleep(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,
diff --git a/modules/access_output/udp.c b/modules/access_output/udp.c
index 401341308c..80dc4f690f 100644
--- a/modules/access_output/udp.c
+++ b/modules/access_output/udp.c
@@ -202,8 +202,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;
diff --git a/modules/audio_filter/audiobargraph_a.c b/modules/audio_filter/audiobargraph_a.c
index a6a842946f..a7ca7c6333 100644
--- a/modules/audio_filter/audiobargraph_a.c
+++ b/modules/audio_filter/audiobargraph_a.c
@@ -97,9 +97,9 @@ typedef struct
     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;
diff --git a/modules/codec/avcodec/subtitle.c b/modules/codec/avcodec/subtitle.c
index 86a09afc17..9103440676 100644
--- a/modules/codec/avcodec/subtitle.c
+++ b/modules/codec/avcodec/subtitle.c
@@ -322,8 +322,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  = p_sys->b_need_ephemer;
                     /* We only show subtitle for i_stop time only */
diff --git a/modules/codec/cea708.c b/modules/codec/cea708.c
index 0b8195bc84..4bf773fd9b 100644
--- a/modules/codec/cea708.c
+++ b/modules/codec/cea708.c
@@ -1377,7 +1377,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:
diff --git a/modules/codec/spudec/parse.c b/modules/codec/spudec/parse.c
index 5688d51e8d..4dfefdeb22 100644
--- a/modules/codec/spudec/parse.c
+++ b/modules/codec/spudec/parse.c
@@ -215,7 +215,7 @@ static int ParseControlSeq( decoder_t *p_dec, subpicture_t *p_spu,
             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;
diff --git a/modules/codec/ttml/ttml.c b/modules/codec/ttml/ttml.c
index fa8bf307ae..294b559671 100644
--- a/modules/codec/ttml/ttml.c
+++ b/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;
             }
diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index 303601049f..3c0f0d3288 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -876,7 +876,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;
diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index 94816075b6..19270291b5 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -526,7 +526,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"))
diff --git a/modules/demux/real.c b/modules/demux/real.c
index 4d748b1b5f..a9463595e1 100644
--- a/modules/demux/real.c
+++ b/modules/demux/real.c
@@ -305,7 +305,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++;
diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index c26515a25a..b62f83e86f 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -1133,10 +1133,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;
     }
@@ -1190,15 +1188,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 );
 
-        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 );
         return VLC_SUCCESS;
     }
     return VLC_EGENERIC;
@@ -1283,14 +1277,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 );
+            p_subtitle->i_stop  = vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 ) +
+                                  VLC_TICK_FROM_MS( c2 * 10 );
             p_subtitle->psz_text = psz_text;
             return VLC_SUCCESS;
         }
@@ -1458,7 +1448,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_FROM_MS(i_start);
     p_subtitle->i_stop  = -1;
     p_subtitle->psz_text = strdup( text );
 
@@ -1502,10 +1492,8 @@ 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 );
             p_subtitle->i_stop = -1;
             break;
         }
@@ -1575,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_FROM_MS(i_start * 100);
+            p_subtitle->i_stop  = i_stop >= 0 ? VLC_TICK_FROM_MS(i_stop  * 100) : -1;
             break;
         }
         free( psz_text );
@@ -2104,7 +2092,7 @@ static int64_t ParseRealTime( char *psz, int *h, int *m, int *s, int *f )
             sscanf( psz, "%d", s ) == 1 )
     {
         return (int64_t)((( *h * 60 + *m ) * 60 ) + *s ) * 1000 * 1000
-               + (int64_t)*f * 10 * 1000;
+               + VLC_TICK_FROM_MS(*f * 10);
     }
     else return VLC_EGENERIC;
 }
@@ -2333,15 +2321,11 @@ 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 );
+
+            p_subtitle->i_stop  = vlc_tick_from_sec( h2 * 3600 + m2 * 60 + s2 ) +
+                                  VLC_TICK_FROM_MS( d2 );
             if( p_subtitle->i_start < p_subtitle->i_stop )
                 break;
         }
diff --git a/modules/services_discovery/mtp.c b/modules/services_discovery/mtp.c
index 5f4f9d472a..8a51707711 100644
--- a/modules/services_discovery/mtp.c
+++ b/modules/services_discovery/mtp.c
@@ -270,7 +270,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_sys->pp_items[p_sys->i_count++] = p_input;
 }
diff --git a/modules/spu/logo.c b/modules/spu/logo.c
index 91b785c8f8..fb062f3414 100644
--- a/modules/spu/logo.c
+++ b/modules/spu/logo.c
@@ -736,8 +736,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;
 }
 /**
diff --git a/modules/stream_out/bridge.c b/modules/stream_out/bridge.c
index a4964c67be..ea221d4993 100644
--- a/modules/stream_out/bridge.c
+++ b/modules/stream_out/bridge.c
@@ -397,7 +397,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 )
@@ -417,7 +417,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;
diff --git a/modules/stream_out/delay.c b/modules/stream_out/delay.c
index 38a454555b..6e76264a09 100644
--- a/modules/stream_out/delay.c
+++ b/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;
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index cbc8dd371d..71e4d8fc0a 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -978,7 +978,7 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
 
     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));
diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c
index 27bbc34bf0..904fcc51a6 100644
--- a/src/stream_output/stream_output.c
+++ b/src/stream_output/stream_output.c
@@ -545,7 +545,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 == VLC_TICK_INVALID )
             p_mux->i_add_stream_start = i_dts;



More information about the vlc-commits mailing list