[vlc-commits] modules: replace hardcoded CLOCK_FREQ multiples by VTICK_FROM_SEC()

Steve Lhomme git at videolan.org
Tue Jul 3 07:55:11 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jul  3 07:43:16 2018 +0200| [d5e794f8029f45fbe6ef5b2b98d102aa5a88f15a] | committer: Steve Lhomme

modules: replace hardcoded CLOCK_FREQ multiples by VTICK_FROM_SEC()

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

 modules/access/dvb/access.c                            |  2 +-
 modules/access/mms/mmstu.c                             |  2 +-
 modules/codec/zvbi.c                                   |  2 +-
 .../adaptive/logic/NearOptimalAdaptationLogic.cpp      |  4 ++--
 modules/demux/adaptive/playlist/AbstractPlaylist.cpp   |  2 +-
 modules/demux/flac.c                                   |  4 ++--
 modules/demux/hls/playlist/M3U8.cpp                    |  2 +-
 modules/demux/mp4/mp4.c                                |  2 +-
 modules/demux/smooth/playlist/Manifest.cpp             |  2 +-
 modules/gui/macosx/VLCBookmarksWindowController.m      |  6 +++---
 modules/gui/qt/dialogs/bookmarks.cpp                   |  6 +++---
 modules/lua/extension.h                                |  2 +-
 modules/packetizer/h264.c                              |  2 +-
 modules/services_discovery/mtp.c                       |  2 +-
 modules/spu/mosaic.c                                   |  2 +-
 modules/video_filter/oldmovie.c                        | 18 +++++++++---------
 modules/video_filter/vhs.c                             |  8 ++++----
 17 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/modules/access/dvb/access.c b/modules/access/dvb/access.c
index e8c0210272..80d8e072b6 100644
--- a/modules/access/dvb/access.c
+++ b/modules/access/dvb/access.c
@@ -107,7 +107,7 @@ static int Control( stream_t *, int, va_list );
 
 static block_t *BlockScan( stream_t *, bool * );
 
-#define DVB_SCAN_MAX_LOCK_TIME (2*CLOCK_FREQ)
+#define DVB_SCAN_MAX_LOCK_TIME VLC_TICK_FROM_SEC(2)
 
 static void FilterUnset( stream_t *, int i_max );
 static void FilterSet( stream_t *, int i_pid, int i_type );
diff --git a/modules/access/mms/mmstu.c b/modules/access/mms/mmstu.c
index db71b64630..63f8664287 100644
--- a/modules/access/mms/mmstu.c
+++ b/modules/access/mms/mmstu.c
@@ -1611,7 +1611,7 @@ noreturn static void *KeepAliveThread( void *p_data )
 
         vlc_restorecancel( canc );
 
-        vlc_tick_sleep( 10 * CLOCK_FREQ );
+        vlc_tick_sleep( VLC_TICK_FROM_SEC(10) );
     }
     vlc_assert_unreachable();
 }
diff --git a/modules/codec/zvbi.c b/modules/codec/zvbi.c
index f63f2792fc..1eb56f6e3e 100644
--- a/modules/codec/zvbi.c
+++ b/modules/codec/zvbi.c
@@ -559,7 +559,7 @@ static subpicture_t *Subpicture( decoder_t *p_dec, video_format_t *p_fmt,
     p_spu->p_region->i_y = 0;
 
     p_spu->i_start = i_pts;
-    p_spu->i_stop = b_text ? i_pts + (10*CLOCK_FREQ): 0;
+    p_spu->i_stop = b_text ? i_pts + VLC_TICK_FROM_SEC(10): 0;
     p_spu->b_ephemer = true;
     p_spu->b_absolute = b_text ? false : true;
 
diff --git a/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp b/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp
index 7a067abe50..096a2def5d 100644
--- a/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp
+++ b/modules/demux/adaptive/logic/NearOptimalAdaptationLogic.cpp
@@ -40,8 +40,8 @@ using namespace adaptive;
  * http://arxiv.org/abs/1601.06748
  */
 
-#define minimumBufferS (CLOCK_FREQ * 6)  /* Qmin */
-#define bufferTargetS  (CLOCK_FREQ * 30) /* Qmax */
+#define minimumBufferS VLC_TICK_FROM_SEC(6)  /* Qmin */
+#define bufferTargetS  VLC_TICK_FROM_SEC(30) /* Qmax */
 
 NearOptimalContext::NearOptimalContext()
     : buffering_min( minimumBufferS )
diff --git a/modules/demux/adaptive/playlist/AbstractPlaylist.cpp b/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
index e350b7eae7..fa89521272 100644
--- a/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
+++ b/modules/demux/adaptive/playlist/AbstractPlaylist.cpp
@@ -41,7 +41,7 @@ AbstractPlaylist::AbstractPlaylist (vlc_object_t *p_object_) :
     availabilityStartTime.Set( 0 );
     availabilityEndTime.Set( 0 );
     duration.Set( 0 );
-    minUpdatePeriod.Set( 2 * CLOCK_FREQ );
+    minUpdatePeriod.Set( VLC_TICK_FROM_SEC(2) );
     maxSegmentDuration.Set( 0 );
     minBufferTime = 0;
     timeShiftBufferDepth.Set( 0 );
diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index 1866da6c8d..ce70620a69 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -105,8 +105,8 @@ typedef struct
 } demux_sys_t;
 
 #define FLAC_PACKET_SIZE 16384
-#define FLAC_MAX_PREROLL      (CLOCK_FREQ * 4)
-#define FLAC_MAX_SLOW_PREROLL (CLOCK_FREQ * 45)
+#define FLAC_MAX_PREROLL      VLC_TICK_FROM_SEC(4)
+#define FLAC_MAX_SLOW_PREROLL VLC_TICK_FROM_SEC(45)
 
 /*****************************************************************************
  * Open: initializes ES structures
diff --git a/modules/demux/hls/playlist/M3U8.cpp b/modules/demux/hls/playlist/M3U8.cpp
index 830fefa657..622783bfee 100644
--- a/modules/demux/hls/playlist/M3U8.cpp
+++ b/modules/demux/hls/playlist/M3U8.cpp
@@ -37,7 +37,7 @@ M3U8::M3U8 (vlc_object_t *p_object, AuthStorage *auth_) :
     AbstractPlaylist(p_object)
 {
     auth = auth_;
-    minUpdatePeriod.Set( 5 * CLOCK_FREQ );
+    minUpdatePeriod.Set( VLC_TICK_FROM_SEC(5) );
     vlc_mutex_init(&keystore_lock);
 }
 
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index f31d7942e1..e4f562a8ad 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -144,7 +144,7 @@ typedef struct
 } demux_sys_t;
 
 #define DEMUX_INCREMENT (CLOCK_FREQ / 4) /* How far the pcr will go, each round */
-#define DEMUX_TRACK_MAX_PRELOAD (CLOCK_FREQ * 15) /* maximum preloading, to deal with interleaving */
+#define DEMUX_TRACK_MAX_PRELOAD VLC_TICK_FROM_SEC(15) /* maximum preloading, to deal with interleaving */
 
 #define VLC_DEMUXER_EOS (VLC_DEMUXER_EGENERIC - 1)
 #define VLC_DEMUXER_FATAL (VLC_DEMUXER_EGENERIC - 2)
diff --git a/modules/demux/smooth/playlist/Manifest.cpp b/modules/demux/smooth/playlist/Manifest.cpp
index 3d552d2c65..e1e38c77db 100644
--- a/modules/demux/smooth/playlist/Manifest.cpp
+++ b/modules/demux/smooth/playlist/Manifest.cpp
@@ -31,7 +31,7 @@ using namespace smooth::playlist;
 Manifest::Manifest (vlc_object_t *p_object) :
     AbstractPlaylist(p_object), TimescaleAble()
 {
-    minUpdatePeriod.Set( 5 * CLOCK_FREQ );
+    minUpdatePeriod.Set( VLC_TICK_FROM_SEC(5) );
     setTimescale( 10000000 );
     b_live = false;
 }
diff --git a/modules/gui/macosx/VLCBookmarksWindowController.m b/modules/gui/macosx/VLCBookmarksWindowController.m
index 19c831bb29..0d86211903 100644
--- a/modules/gui/macosx/VLCBookmarksWindowController.m
+++ b/modules/gui/macosx/VLCBookmarksWindowController.m
@@ -304,9 +304,9 @@ clear:
     assert(bookmark != NULL);
 
     vlc_tick_t total = bookmark->i_time_offset;
-    uint64_t hour = ( total / ( CLOCK_FREQ * 3600 ) );
-    uint64_t min = ( total % ( CLOCK_FREQ * 3600 ) ) / ( CLOCK_FREQ * 60 );
-    float    sec = ( total % ( CLOCK_FREQ * 60 ) ) / ( CLOCK_FREQ * 1. );
+    uint64_t hour = ( total / VLC_TICK_FROM_SEC(3600) );
+    uint64_t min = ( total % VLC_TICK_FROM_SEC(3600) ) / VLC_TICK_FROM_SEC(60);
+    float    sec = ( total % VLC_TICK_FROM_SEC(60) ) / ( CLOCK_FREQ * 1. );
 
     return [NSString stringWithFormat:@"%02llu:%02llu:%06.3f", hour, min, sec];
 }
diff --git a/modules/gui/qt/dialogs/bookmarks.cpp b/modules/gui/qt/dialogs/bookmarks.cpp
index 329eddac6e..d8b5f6c530 100644
--- a/modules/gui/qt/dialogs/bookmarks.cpp
+++ b/modules/gui/qt/dialogs/bookmarks.cpp
@@ -139,9 +139,9 @@ void BookmarksDialog::update()
     for( int i = 0; i < i_bookmarks; i++ )
     {
         vlc_tick_t total = pp_bookmarks[i]->i_time_offset;
-        unsigned hours   = ( total / ( CLOCK_FREQ * 3600 ) );
-        unsigned minutes = ( total % ( CLOCK_FREQ * 3600 ) ) / ( CLOCK_FREQ * 60 );
-        float    seconds = ( total % ( CLOCK_FREQ * 60 ) ) / ( CLOCK_FREQ * 1. );
+        unsigned hours   = ( total / VLC_TICK_FROM_SEC(3600) );
+        unsigned minutes = ( total % VLC_TICK_FROM_SEC(3600) ) / VLC_TICK_FROM_SEC(60);
+        float    seconds = ( total % VLC_TICK_FROM_SEC(60) ) / ( CLOCK_FREQ * 1. );
 
         QStringList row;
         row << QString( qfu( pp_bookmarks[i]->psz_name ) );
diff --git a/modules/lua/extension.h b/modules/lua/extension.h
index 2897991297..c79037858f 100644
--- a/modules/lua/extension.h
+++ b/modules/lua/extension.h
@@ -28,7 +28,7 @@
 #include <vlc_arrays.h>
 #include <vlc_dialog.h>
 
-#define WATCH_TIMER_PERIOD    (10 * CLOCK_FREQ) ///< 10s period for the timer
+#define WATCH_TIMER_PERIOD    VLC_TICK_FROM_SEC(10) ///< 10s period for the timer
 
 /* List of available commands */
 typedef enum
diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index d459bc3935..b6c97ca24b 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -970,7 +970,7 @@ static block_t *OutputPicture( decoder_t *p_dec )
                     tFOC, bFOC, PictureOrderCount,
                     p_sys->slice.type, p_sys->b_recovered, p_pic->i_flags,
                     p_sys->slice.i_nal_ref_idc, p_sys->slice.i_frame_num, p_sys->slice.i_field_pic_flag,
-                    p_pic->i_pts - p_pic->i_dts, p_pic->i_pts % (100*CLOCK_FREQ), p_pic->i_length);
+                    p_pic->i_pts - p_pic->i_dts, p_pic->i_pts % VLC_TICK_FROM_SEC(100), p_pic->i_length);
 #endif
 
     /* save for next pic fixups */
diff --git a/modules/services_discovery/mtp.c b/modules/services_discovery/mtp.c
index 5892a81d72..8831ec1b31 100644
--- a/modules/services_discovery/mtp.c
+++ b/modules/services_discovery/mtp.c
@@ -166,7 +166,7 @@ static void *Run( void *data )
         vlc_restorecancel(canc);
         if( i_status == 2 )
         {
-            vlc_tick_sleep( 5*CLOCK_FREQ );
+            vlc_tick_sleep( VLC_TICK_FROM_SEC(5) );
             i_status = 0;
         }
         else
diff --git a/modules/spu/mosaic.c b/modules/spu/mosaic.c
index 7276a42ea0..e08ae7794f 100644
--- a/modules/spu/mosaic.c
+++ b/modules/spu/mosaic.c
@@ -40,7 +40,7 @@
 
 #include "mosaic.h"
 
-#define BLANK_DELAY  (1*CLOCK_FREQ)
+#define BLANK_DELAY  VLC_TICK_FROM_SEC(1)
 
 /*****************************************************************************
  * Local prototypes
diff --git a/modules/video_filter/oldmovie.c b/modules/video_filter/oldmovie.c
index 2286ad2d3f..92606c4ea8 100644
--- a/modules/video_filter/oldmovie.c
+++ b/modules/video_filter/oldmovie.c
@@ -401,7 +401,7 @@ static int oldmovie_sliding_offset_effect( filter_t *p_filter, picture_t *p_pic_
     * one shot offset section
     */
 
-#define OFFSET_AVERAGE_PERIOD   (10 * CLOCK_FREQ)
+#define OFFSET_AVERAGE_PERIOD   VLC_TICK_FROM_SEC(10)
 
     /* start trigger to be (re)initialized */
     if ( p_sys->i_offset_trigger == 0
@@ -424,8 +424,8 @@ static int oldmovie_sliding_offset_effect( filter_t *p_filter, picture_t *p_pic_
     * sliding section
     */
 
-#define SLIDING_AVERAGE_PERIOD   (20 * CLOCK_FREQ)
-#define SLIDING_AVERAGE_DURATION ( 3 * CLOCK_FREQ)
+#define SLIDING_AVERAGE_PERIOD   VLC_TICK_FROM_SEC(20)
+#define SLIDING_AVERAGE_DURATION VLC_TICK_FROM_SEC(3)
 
     /* start trigger to be (re)initialized */
     if (    ( p_sys->i_sliding_stop_trig  == 0 )
@@ -575,7 +575,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 ( CLOCK_FREQ * 2 )
+#define SCRATCH_GENERATOR_PERIOD VLC_TICK_FROM_SEC(2)
 #define SCRATCH_DURATION         ( CLOCK_FREQ * 1 / 2)
 
     /* generate new scratch */
@@ -636,7 +636,7 @@ static void oldmovie_film_blotch_effect( filter_t *p_filter, picture_t *p_pic_ou
 {
     filter_sys_t *p_sys = p_filter->p_sys;
 
-#define BLOTCH_GENERATOR_PERIOD ( CLOCK_FREQ * 5 )
+#define BLOTCH_GENERATOR_PERIOD VLC_TICK_FROM_SEC(5)
 
     /* generate blotch */
     if ( p_sys->i_blotch_trigger <= p_sys->i_cur_time ) {
@@ -693,10 +693,10 @@ static void oldmovie_film_dust_effect( filter_t *p_filter, picture_t *p_pic_out
  * Hair and dust on projector lens
  *
  */
-#define HAIR_GENERATOR_PERIOD ( CLOCK_FREQ * 50  )
-#define HAIR_DURATION         ( CLOCK_FREQ * 50  )
-#define DUST_GENERATOR_PERIOD ( CLOCK_FREQ * 100 )
-#define DUST_DURATION         ( CLOCK_FREQ * 4   )
+#define HAIR_GENERATOR_PERIOD VLC_TICK_FROM_SEC(50)
+#define HAIR_DURATION         VLC_TICK_FROM_SEC(50)
+#define DUST_GENERATOR_PERIOD VLC_TICK_FROM_SEC(100)
+#define DUST_DURATION         VLC_TICK_FROM_SEC(4)
 
 /**
  * Define hair location on the lens and timeout
diff --git a/modules/video_filter/vhs.c b/modules/video_filter/vhs.c
index 67a310992c..4e63a7ba72 100644
--- a/modules/video_filter/vhs.c
+++ b/modules/video_filter/vhs.c
@@ -263,7 +263,7 @@ static void vhs_free_allocated_data( filter_t *p_filter ) {
 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 ( CLOCK_FREQ * 50 )
+#define BR_LINES_GENERATOR_PERIOD VLC_TICK_FROM_SEC(50)
 #define BR_LINES_DURATION         ( CLOCK_FREQ * 1/50 )
 
     /* generate new blue or red lines */
@@ -394,7 +394,7 @@ static int vhs_sliding_effect( filter_t *p_filter, picture_t *p_pic_out ) {
     * one shot offset section
     */
 
-#define OFFSET_AVERAGE_PERIOD   (10 * CLOCK_FREQ)
+#define OFFSET_AVERAGE_PERIOD   VLC_TICK_FROM_SEC(10)
 
     /* start trigger to be (re)initialized */
     if ( p_sys->i_offset_trigger == 0
@@ -432,8 +432,8 @@ static int vhs_sliding_effect( filter_t *p_filter, picture_t *p_pic_out ) {
     * sliding section
     */
 
-#define SLIDING_AVERAGE_PERIOD   (20 * CLOCK_FREQ)
-#define SLIDING_AVERAGE_DURATION ( 3 * CLOCK_FREQ)
+#define SLIDING_AVERAGE_PERIOD   VLC_TICK_FROM_SEC(20)
+#define SLIDING_AVERAGE_DURATION VLC_TICK_FROM_SEC(3)
 
     /* start trigger to be (re)initialized */
     if ( ( p_sys->i_sliding_stop_trig  == 0 ) &&



More information about the vlc-commits mailing list