[vlc-devel] [PATCH 12/15] modules: replace hardcoded CLOCK_FREQ multiples by VTICK_FROM_SEC()
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jun 15 17:09:23 CEST 2018
---
modules/access/dvb/access.c | 2 +-
modules/access/mms/mmstu.c | 2 +-
modules/codec/zvbi.c | 2 +-
.../logic/NearOptimalAdaptationLogic.cpp | 4 ++--
.../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 +-
.../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 9a1acc91afe..1bd1d786d74 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 VTICK_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 16c99d16092..ea30f59ea8c 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 );
- msleep( 10 * CLOCK_FREQ );
+ msleep( VTICK_FROM_SEC(10) );
}
vlc_assert_unreachable();
}
diff --git a/modules/codec/zvbi.c b/modules/codec/zvbi.c
index 4c5147df42d..ccc71b35114 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 + VTICK_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 a8f91439912..2628e085489 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 VTICK_FROM_SEC(6) /* Qmin */
+#define bufferTargetS VTICK_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 c89527addc0..0f9bacc46bf 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( VTICK_FROM_SEC(2) );
maxSegmentDuration.Set( 0 );
minBufferTime = 0;
timeShiftBufferDepth.Set( 0 );
diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index 0373e10403d..590d3e2fc6a 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 VTICK_FROM_SEC(4)
+#define FLAC_MAX_SLOW_PREROLL VTICK_FROM_SEC(45)
/*****************************************************************************
* Open: initializes ES structures
diff --git a/modules/demux/hls/playlist/M3U8.cpp b/modules/demux/hls/playlist/M3U8.cpp
index 830fefa6571..2b7676c8fa2 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( VTICK_FROM_SEC(5) );
vlc_mutex_init(&keystore_lock);
}
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 5982605c0ac..eb6db258e68 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 VTICK_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 3d552d2c652..7c9bcde9f3a 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( VTICK_FROM_SEC(5) );
setTimescale( 10000000 );
b_live = false;
}
diff --git a/modules/gui/macosx/VLCBookmarksWindowController.m b/modules/gui/macosx/VLCBookmarksWindowController.m
index 5606361c637..c90fba0fefb 100644
--- a/modules/gui/macosx/VLCBookmarksWindowController.m
+++ b/modules/gui/macosx/VLCBookmarksWindowController.m
@@ -304,9 +304,9 @@ clear:
assert(bookmark != NULL);
mtime_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 / VTICK_FROM_SEC(3600) );
+ uint64_t min = ( total % VTICK_FROM_SEC(3600) ) / VTICK_FROM_SEC(60);
+ float sec = ( total % VTICK_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 740c44bd3de..7cc7c10803a 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++ )
{
mtime_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 / VTICK_FROM_SEC(3600) );
+ unsigned minutes = ( total % VTICK_FROM_SEC(3600) ) / VTICK_FROM_SEC(60);
+ float seconds = ( total % VTICK_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 28979912976..6c35ea78e3b 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 VTICK_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 4f8a97d0f60..a721d0a15a3 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 % VTICK_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 8f52d318098..03a788a77ec 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 )
{
- msleep( 5*CLOCK_FREQ );
+ msleep( VTICK_FROM_SEC(5) );
i_status = 0;
}
else
diff --git a/modules/spu/mosaic.c b/modules/spu/mosaic.c
index 99884fc533f..40abdab4016 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 VTICK_FROM_SEC(1)
/*****************************************************************************
* Local prototypes
diff --git a/modules/video_filter/oldmovie.c b/modules/video_filter/oldmovie.c
index 04d2dca31c0..fb6fc5db15f 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 VTICK_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 VTICK_FROM_SEC(20)
+#define SLIDING_AVERAGE_DURATION VTICK_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 VTICK_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 VTICK_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 VTICK_FROM_SEC(50)
+#define HAIR_DURATION VTICK_FROM_SEC(50)
+#define DUST_GENERATOR_PERIOD VTICK_FROM_SEC(100)
+#define DUST_DURATION VTICK_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 c9fe7d01df3..67afe7335bc 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 VTICK_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 VTICK_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 VTICK_FROM_SEC(20)
+#define SLIDING_AVERAGE_DURATION VTICK_FROM_SEC(3)
/* start trigger to be (re)initialized */
if ( ( p_sys->i_sliding_stop_trig == 0 ) &&
--
2.17.0
More information about the vlc-devel
mailing list