[vlc-commits] modules: replace hardcoded CLOCK_FREQ fractions/multiples by VLC_TICK macros

Steve Lhomme git at videolan.org
Tue Jul 3 11:24:04 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jul  3 10:36:32 2018 +0200| [02231366217c6d93adff24bc0ad69068f3d4f16b] | committer: Steve Lhomme

modules: replace hardcoded CLOCK_FREQ fractions/multiples by VLC_TICK macros

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

 modules/codec/synchro.c                              | 4 ++--
 modules/codec/webvtt/webvtt.c                        | 8 ++++----
 modules/demux/adaptive/playlist/AbstractPlaylist.cpp | 4 ++--
 modules/demux/avformat/demux.c                       | 2 +-
 modules/demux/avi/avi.c                              | 4 ++--
 modules/demux/dash/DASHManager.cpp                   | 4 ++--
 modules/demux/hls/playlist/Representation.cpp        | 4 ++--
 modules/demux/mpeg/ps.c                              | 2 +-
 modules/demux/nsv.c                                  | 2 +-
 modules/demux/smooth/SmoothManager.cpp               | 4 ++--
 modules/gui/qt/input_manager.cpp                     | 2 +-
 modules/lua/libs/osd.c                               | 2 +-
 modules/misc/audioscrobbler.c                        | 2 +-
 modules/misc/inhibit/xdg.c                           | 2 +-
 modules/mux/mp4/libmp4mux.c                          | 2 +-
 modules/mux/mp4/mp4.c                                | 4 ++--
 modules/mux/mpeg/ps.c                                | 2 +-
 modules/mux/mpeg/ts.c                                | 8 ++++----
 modules/stream_out/record.c                          | 4 ++--
 modules/video_filter/oldmovie.c                      | 2 +-
 modules/video_filter/vhs.c                           | 2 +-
 modules/video_output/android/display.c               | 2 +-
 22 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/modules/codec/synchro.c b/modules/codec/synchro.c
index bc03fc2b48..63fb507100 100644
--- a/modules/codec/synchro.c
+++ b/modules/codec/synchro.c
@@ -150,8 +150,8 @@ struct decoder_synchro_t
 };
 
 /* Error margins */
-#define DELTA                   ((CLOCK_FREQ * 3) / 40)
-#define MAX_VALID_TAU           ((CLOCK_FREQ * 3) / 10)
+#define DELTA                   VLC_TICK_FROM_MS(75)  /* 3s/40 */
+#define MAX_VALID_TAU           VLC_TICK_FROM_MS(300)
 
 #define DEFAULT_NB_P            5
 #define DEFAULT_NB_B            1
diff --git a/modules/codec/webvtt/webvtt.c b/modules/codec/webvtt/webvtt.c
index b8d991f9d5..e9585e92a7 100644
--- a/modules/codec/webvtt/webvtt.c
+++ b/modules/codec/webvtt/webvtt.c
@@ -89,10 +89,10 @@ struct webvtt_text_parser_t
 
 static vlc_tick_t MakeTime( unsigned t[4] )
 {
-    return t[0] * 3600 * CLOCK_FREQ +
-           t[1] * 60 * CLOCK_FREQ +
-           t[2] * CLOCK_FREQ +
-           t[3] * 1000;
+    return VLC_TICK_FROM_SEC(t[0] * 3600)+
+           VLC_TICK_FROM_SEC(t[1] * 60)+
+           VLC_TICK_FROM_SEC(t[2]) +
+           VLC_TICK_FROM_MS(t[3]);
 }
 
 bool webvtt_scan_time( const char *psz, vlc_tick_t *p_time )
diff --git a/modules/demux/adaptive/playlist/AbstractPlaylist.cpp b/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
index fa89521272..7945928f20 100644
--- a/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
+++ b/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
@@ -86,13 +86,13 @@ void AbstractPlaylist::setMinBuffering( vlc_tick_t min )
 
 vlc_tick_t AbstractPlaylist::getMinBuffering() const
 {
-    return std::max(minBufferTime, 6*CLOCK_FREQ);
+    return std::max(minBufferTime, VLC_TICK_FROM_SEC(6));
 }
 
 vlc_tick_t AbstractPlaylist::getMaxBuffering() const
 {
     const vlc_tick_t minbuf = getMinBuffering();
-    return std::max(minbuf, 60 * CLOCK_FREQ);
+    return std::max(minbuf, VLC_TICK_FROM_SEC(60));
 }
 
 Url AbstractPlaylist::getUrlSegment() const
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index f24729557b..ed15b4f08d 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -885,7 +885,7 @@ static int Demux( demux_t *p_demux )
     {
         if( p_sys->tracks[i].p_es != NULL &&
                 p_sys->tracks[i].i_pcr != VLC_TICK_INVALID &&
-                p_sys->tracks[i].i_pcr + 10 * CLOCK_FREQ >= i_ts_max )
+                p_sys->tracks[i].i_pcr + VLC_TICK_FROM_SEC(10)>= i_ts_max )
             i_ts_min = __MIN( i_ts_min, p_sys->tracks[i].i_pcr );
     }
     if( i_ts_min >= p_sys->i_pcr && likely(i_ts_min != INT64_MAX) )
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 8eabe1c718..a3d46accde 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -97,8 +97,8 @@ static char *FromACP( const char *str )
 }
 
 #define IGNORE_ES DATA_ES
-#define READ_LENGTH (25 * 1000) // 25ms
-#define READ_LENGTH_NONINTERLEAVED (CLOCK_FREQ * 3 / 2)
+#define READ_LENGTH                VLC_TICK_FROM_MS(25)
+#define READ_LENGTH_NONINTERLEAVED VLC_TICK_FROM_MS(1500)
 
 //#define AVI_DEBUG
 
diff --git a/modules/demux/dash/DASHManager.cpp b/modules/demux/dash/DASHManager.cpp
index 284890a2e6..9d68aba8b4 100644
--- a/modules/demux/dash/DASHManager.cpp
+++ b/modules/demux/dash/DASHManager.cpp
@@ -80,8 +80,8 @@ void DASHManager::scheduleNextUpdate()
     if(playlist->minUpdatePeriod.Get() > minbuffer)
         minbuffer = playlist->minUpdatePeriod.Get();
 
-    if(minbuffer < 5 * CLOCK_FREQ)
-        minbuffer = 5 * CLOCK_FREQ;
+    if(minbuffer < VLC_TICK_FROM_SEC(5))
+        minbuffer = VLC_TICK_FROM_SEC(5);
 
     nextPlaylistupdate = now + minbuffer / CLOCK_FREQ;
 
diff --git a/modules/demux/hls/playlist/Representation.cpp b/modules/demux/hls/playlist/Representation.cpp
index 9a685d9216..25f561f710 100644
--- a/modules/demux/hls/playlist/Representation.cpp
+++ b/modules/demux/hls/playlist/Representation.cpp
@@ -118,8 +118,8 @@ void Representation::scheduleNextUpdate(uint64_t number)
     }
     else
     {
-        if(minbuffer < 10 * CLOCK_FREQ)
-            minbuffer = 4 * CLOCK_FREQ;
+        if(minbuffer < VLC_TICK_FROM_SEC(10))
+            minbuffer = VLC_TICK_FROM_SEC(4);
         else
             minbuffer /= 2;
     }
diff --git a/modules/demux/mpeg/ps.c b/modules/demux/mpeg/ps.c
index aaa2425f91..198ef364cc 100644
--- a/modules/demux/mpeg/ps.c
+++ b/modules/demux/mpeg/ps.c
@@ -581,7 +581,7 @@ static int Demux( demux_t *p_demux )
             if( p_sys->i_pack_scr >= 0 && !p_sys->b_bad_scr )
             {
                 if( (tk->fmt.i_cat == AUDIO_ES || tk->fmt.i_cat == VIDEO_ES) &&
-                    tk->i_first_pts != VLC_TICK_INVALID && tk->i_first_pts - p_sys->i_pack_scr > 2 * CLOCK_FREQ )
+                    tk->i_first_pts != VLC_TICK_INVALID && tk->i_first_pts - p_sys->i_pack_scr > VLC_TICK_FROM_SEC(2))
                 {
                     msg_Warn( p_demux, "Incorrect SCR timing offset by of %"PRId64 "ms, disabling",
                                        tk->i_first_pts - p_sys->i_pack_scr / 1000 );
diff --git a/modules/demux/nsv.c b/modules/demux/nsv.c
index 5ce4653840..6110750c8a 100644
--- a/modules/demux/nsv.c
+++ b/modules/demux/nsv.c
@@ -258,7 +258,7 @@ static int Demux( demux_t *p_demux )
 
                     /* Skip the first part (it is the language name) */
                     p_frame->i_pts = VLC_TICK_0 + p_sys->i_pcr;
-                    p_frame->i_dts = VLC_TICK_0 + p_sys->i_pcr + 4 * CLOCK_FREQ;
+                    p_frame->i_dts = VLC_TICK_0 + p_sys->i_pcr + VLC_TICK_FROM_SEC(4);
 
                     if( p_sys->p_sub )
                         es_out_Send( p_demux->out, p_sys->p_sub, p_frame );
diff --git a/modules/demux/smooth/SmoothManager.cpp b/modules/demux/smooth/SmoothManager.cpp
index 365c4cd6eb..7251efd199 100644
--- a/modules/demux/smooth/SmoothManager.cpp
+++ b/modules/demux/smooth/SmoothManager.cpp
@@ -135,8 +135,8 @@ void SmoothManager::scheduleNextUpdate()
     if(playlist->minUpdatePeriod.Get() > minbuffer)
         minbuffer = playlist->minUpdatePeriod.Get();
 
-    if(minbuffer < 5 * CLOCK_FREQ)
-        minbuffer = 5 * CLOCK_FREQ;
+    if(minbuffer < VLC_TICK_FROM_SEC(5))
+        minbuffer = VLC_TICK_FROM_SEC(5);
 
     nextPlaylistupdate = now + minbuffer / CLOCK_FREQ;
 
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index 4c28933395..ed0e65e353 100644
--- a/modules/gui/qt/input_manager.cpp
+++ b/modules/gui/qt/input_manager.cpp
@@ -165,7 +165,7 @@ void InputManager::delInput()
         int64_t i_time = -1;
 
         if( f_pos >= 0.05f && f_pos <= 0.95f
-         && var_GetInteger( p_input, "length" ) >= 60 * CLOCK_FREQ )
+         && var_GetInteger( p_input, "length" ) >= VLC_TICK_FROM_SEC(60))
             i_time = var_GetInteger( p_input, "time");
 
         RecentsMRL::getInstance( p_intf )->setTime( qfu(uri), i_time );
diff --git a/modules/lua/libs/osd.c b/modules/lua/libs/osd.c
index dec851b368..bc59ac9470 100644
--- a/modules/lua/libs/osd.c
+++ b/modules/lua/libs/osd.c
@@ -116,7 +116,7 @@ static int vlclua_osd_message( lua_State *L )
     const char *psz_message = luaL_checkstring( L, 1 );
     int i_chan = (int)luaL_optinteger( L, 2, VOUT_SPU_CHANNEL_OSD );
     const char *psz_position = luaL_optstring( L, 3, "top-right" );
-    vlc_tick_t duration = (vlc_tick_t)luaL_optinteger( L, 4, 1*CLOCK_FREQ );
+    vlc_tick_t duration = (vlc_tick_t)luaL_optinteger( L, 4, VLC_TICK_FROM_SEC(1));
 
     input_thread_t *p_input = vlclua_get_input_internal( L );
     if( p_input )
diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c
index 46cc60049a..8ffe075a14 100644
--- a/modules/misc/audioscrobbler.c
+++ b/modules/misc/audioscrobbler.c
@@ -660,7 +660,7 @@ static void HandleInterval(vlc_tick_t *next, unsigned int *i_interval)
         if (*i_interval > 120)
             *i_interval = 120;
     }
-    *next = vlc_tick_now() + (*i_interval * CLOCK_FREQ * 60);
+    *next = vlc_tick_now() + (*i_interval * VLC_TICK_FROM_SEC(60));
 }
 
 /*****************************************************************************
diff --git a/modules/misc/inhibit/xdg.c b/modules/misc/inhibit/xdg.c
index b2fe26947e..75f0c1e747 100644
--- a/modules/misc/inhibit/xdg.c
+++ b/modules/misc/inhibit/xdg.c
@@ -76,7 +76,7 @@ static void Inhibit (vlc_inhibit_t *ih, unsigned mask)
 {
     vlc_inhibit_sys_t *sys = ih->p_sys;
     bool suspend = (mask & VLC_INHIBIT_DISPLAY) != 0;
-    vlc_tick_t delay = suspend ? 30 * CLOCK_FREQ : INT64_C(0);
+    vlc_tick_t delay = suspend ? VLC_TICK_FROM_SEC(30): INT64_C(0);
 
     vlc_timer_schedule (sys->timer, false, delay, delay);
 }
diff --git a/modules/mux/mp4/libmp4mux.c b/modules/mux/mp4/libmp4mux.c
index 9ed5feaca3..6f31fe32cf 100644
--- a/modules/mux/mp4/libmp4mux.c
+++ b/modules/mux/mp4/libmp4mux.c
@@ -1350,7 +1350,7 @@ static bo_t *GetStblBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
             if ( i_interval != -1 )
             {
                 i_interval += p_track->entry[i].i_length + p_track->entry[i].i_pts_dts;
-                if ( i_interval < CLOCK_FREQ * 2 )
+                if ( i_interval < VLC_TICK_FROM_SEC(2) )
                     continue;
             }
 
diff --git a/modules/mux/mp4/mp4.c b/modules/mux/mp4/mp4.c
index 1c50223c0d..0d5b2a4c72 100644
--- a/modules/mux/mp4/mp4.c
+++ b/modules/mux/mp4/mp4.c
@@ -848,7 +848,7 @@ static void box_send(sout_mux_t *p_mux,  bo_t *box)
 /***************************************************************************
     MP4 Live submodule
 ****************************************************************************/
-#define FRAGMENT_LENGTH  (CLOCK_FREQ * 3/2)
+#define FRAGMENT_LENGTH  VLC_TICK_FROM_MS(1500)
 
 #define ENQUEUE_ENTRY(object, entry) \
     do {\
@@ -890,7 +890,7 @@ static void AddKeyframeEntry(mp4_stream_t *p_stream, const uint64_t i_moof_pos,
     else
         i_last_entry_time = 0;
 
-    if (p_entries && i_time - i_last_entry_time >= CLOCK_FREQ * 2)
+    if (p_entries && i_time - i_last_entry_time >= VLC_TICK_FROM_SEC(2))
     {
         mp4_fragindex_t *p_indexentry = &p_stream->p_indexentries[p_stream->i_indexentries];
         p_indexentry->i_time = i_time;
diff --git a/modules/mux/mpeg/ps.c b/modules/mux/mpeg/ps.c
index adb83f5243..8db448bc17 100644
--- a/modules/mux/mpeg/ps.c
+++ b/modules/mux/mpeg/ps.c
@@ -492,7 +492,7 @@ static int Mux( sout_mux_t *p_mux )
             {
                 /* Update the instant bitrate every second or so */
                 if( p_sys->i_instant_size &&
-                    i_dts - p_sys->i_instant_dts > 1*CLOCK_FREQ )
+                    i_dts - p_sys->i_instant_dts > VLC_TICK_FROM_SEC(1))
                 {
                     int64_t i_instant_bitrate = p_sys->i_instant_size * 8000000 /
                             ( i_dts - p_sys->i_instant_dts );
diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index e3c4fd8cd9..465737ac8c 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -1252,10 +1252,10 @@ static bool MuxStreams(sout_mux_t *p_mux )
 
                 int64_t i_spu_delay = p_spu->i_dts - p_pcr_stream->state.i_pes_dts;
                 if( ( i_spu_delay > i_shaping_delay ) &&
-                    ( i_spu_delay < 100 * CLOCK_FREQ ) )
+                    ( i_spu_delay < VLC_TICK_FROM_SEC(100)) )
                     continue;
 
-                if ( ( i_spu_delay >= 100 * CLOCK_FREQ ) ||
+                if ( ( i_spu_delay >= VLC_TICK_FROM_SEC(100)) ||
                      ( i_spu_delay < VLC_TICK_FROM_MS(10) ) )
                 {
                     BufferChainClean( &p_stream->state.chain_pes );
@@ -1314,12 +1314,12 @@ static bool MuxStreams(sout_mux_t *p_mux )
         }
 
         if( ( p_pcr_stream->state.i_pes_dts > 0 &&
-              p_data->i_dts - 10 * CLOCK_FREQ > p_pcr_stream->state.i_pes_dts +
+              p_data->i_dts - VLC_TICK_FROM_SEC(10)> p_pcr_stream->state.i_pes_dts +
               p_pcr_stream->state.i_pes_length ) ||
             p_data->i_dts + i_shaping_delay < p_stream->state.i_pes_dts ||
             ( p_stream->state.i_pes_dts > 0 &&
               p_input->p_fmt->i_cat != SPU_ES &&
-              p_data->i_dts - 10 * CLOCK_FREQ > p_stream->state.i_pes_dts +
+              p_data->i_dts - VLC_TICK_FROM_SEC(10)> p_stream->state.i_pes_dts +
               p_stream->state.i_pes_length ) )
         {
             msg_Warn( p_mux, "packet with too strange dts on pid %d (%4.4s)"
diff --git a/modules/stream_out/record.c b/modules/stream_out/record.c
index 8e18a208d1..84ce815811 100644
--- a/modules/stream_out/record.c
+++ b/modules/stream_out/record.c
@@ -148,10 +148,10 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_date_start = -1;
     p_sys->i_size = 0;
 #ifdef OPTIMIZE_MEMORY
-    p_sys->i_max_wait = 5*CLOCK_FREQ; /* 5s */
+    p_sys->i_max_wait = VLC_TICK_FROM_SEC(5);
     p_sys->i_max_size = 1*1024*1024; /* 1 MiB */
 #else
-    p_sys->i_max_wait = 30*CLOCK_FREQ; /* 30s */
+    p_sys->i_max_wait = VLC_TICK_FROM_SEC(30);
     p_sys->i_max_size = 20*1024*1024; /* 20 MiB */
 #endif
     p_sys->b_drop = false;
diff --git a/modules/video_filter/oldmovie.c b/modules/video_filter/oldmovie.c
index 92606c4ea8..7fbff857de 100644
--- a/modules/video_filter/oldmovie.c
+++ b/modules/video_filter/oldmovie.c
@@ -576,7 +576,7 @@ static int oldmovie_film_scratch_effect( filter_t *p_filter, picture_t *p_pic_ou
     filter_sys_t *p_sys = p_filter->p_sys;
 
 #define SCRATCH_GENERATOR_PERIOD VLC_TICK_FROM_SEC(2)
-#define SCRATCH_DURATION         ( CLOCK_FREQ * 1 / 2)
+#define SCRATCH_DURATION         VLC_TICK_FROM_MS(500)
 
     /* generate new scratch */
     if ( p_sys->i_scratch_trigger <= p_sys->i_cur_time ) {
diff --git a/modules/video_filter/vhs.c b/modules/video_filter/vhs.c
index 4e63a7ba72..13c97d05fa 100644
--- a/modules/video_filter/vhs.c
+++ b/modules/video_filter/vhs.c
@@ -264,7 +264,7 @@ static int vhs_blue_red_line_effect( filter_t *p_filter, picture_t *p_pic_out )
     filter_sys_t *p_sys = p_filter->p_sys;
 
 #define BR_LINES_GENERATOR_PERIOD VLC_TICK_FROM_SEC(50)
-#define BR_LINES_DURATION         ( CLOCK_FREQ * 1/50 )
+#define BR_LINES_DURATION         VLC_TICK_FROM_MS(20)
 
     /* generate new blue or red lines */
     if ( p_sys->i_BR_line_trigger <= p_sys->i_cur_time ) {
diff --git a/modules/video_output/android/display.c b/modules/video_output/android/display.c
index ee24e31c5c..79e7144877 100644
--- a/modules/video_output/android/display.c
+++ b/modules/video_output/android/display.c
@@ -991,7 +991,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
         vlc_tick_t now = vlc_tick_now();
         if (date > now)
         {
-            if (date - now <= 1*CLOCK_FREQ)
+            if (date - now <= VLC_TICK_FROM_SEC(1))
                 AndroidOpaquePicture_ReleaseAtTime(picture->p_sys, date);
             else /* The picture will be displayed from the Display callback */
                 msg_Warn(vd, "picture way too early to release at time");



More information about the vlc-commits mailing list