[vlc-devel] [PATCH 2/2] replace some usage of 1000000 by CLOCK_FREQ

Steve Lhomme robux4 at videolabs.io
Thu Apr 13 16:48:23 CEST 2017


anything related to mtime_t and the frame rate
---
 modules/access/dtv/en50221.c                               |  2 +-
 modules/access/linsys/linsys_hdsdi.c                       |  4 ++--
 modules/access/linsys/linsys_sdi.c                         |  2 +-
 modules/access/live555.cpp                                 |  6 +++---
 modules/audio_filter/resampler/ugly.c                      |  2 +-
 modules/codec/dvbsub.c                                     |  4 ++--
 modules/codec/flac.c                                       |  4 ++--
 modules/codec/kate.c                                       |  4 ++--
 modules/codec/shine.c                                      |  4 ++--
 modules/codec/speex.c                                      |  4 ++--
 modules/codec/twolame.c                                    |  2 +-
 modules/codec/vorbis.c                                     |  4 ++--
 modules/control/oldrc.c                                    |  2 +-
 modules/demux/aiff.c                                       |  6 +++---
 modules/demux/asf/asf.c                                    |  4 ++--
 modules/demux/au.c                                         |  2 +-
 modules/demux/avformat/demux.c                             | 14 +++++++-------
 modules/demux/avi/avi.c                                    |  4 ++--
 modules/demux/mpeg/es.c                                    |  2 +-
 modules/demux/ogg.c                                        |  4 ++--
 modules/demux/playlist/asx.c                               |  6 +++---
 modules/demux/playlist/podcast.c                           |  4 ++--
 modules/demux/pva.c                                        |  4 ++--
 modules/gui/macosx/VLCFSPanelController.m                  |  4 ++--
 modules/gui/macosx/VLCMainWindow.m                         |  2 +-
 modules/gui/macosx/VLCPLModel.m                            |  2 +-
 modules/gui/macosx/VLCPlaylist.m                           |  4 ++--
 modules/gui/macosx/VLCStatusBarIcon.m                      |  2 +-
 modules/gui/macosx/VLCStringUtility.m                      |  2 +-
 .../gui/macosx/VLCTrackSynchronizationWindowController.m   |  8 ++++----
 modules/gui/qt/adapters/chromaprint.cpp                    |  2 +-
 modules/gui/qt/components/playlist/selector.cpp            |  2 +-
 modules/gui/qt/components/playlist/sorting.h               |  2 +-
 modules/hw/mmal/deinterlace.c                              |  2 +-
 modules/hw/mmal/vout.c                                     |  2 +-
 modules/lua/libs/input.c                                   |  2 +-
 modules/lua/libs/osd.c                                     |  2 +-
 modules/misc/audioscrobbler.c                              |  6 +++---
 modules/misc/playlist/html.c                               |  4 ++--
 modules/mux/avi.c                                          |  6 +++---
 modules/mux/mpeg/ps.c                                      |  2 +-
 modules/mux/ogg.c                                          |  4 ++--
 modules/packetizer/dirac.c                                 |  2 +-
 modules/services_discovery/sap.c                           |  2 +-
 modules/spu/rss.c                                          |  3 +--
 modules/stream_out/chromecast/chromecast_ctrl.cpp          |  4 ++--
 modules/stream_out/record.c                                |  2 +-
 modules/video_filter/blendbench.c                          |  6 +++---
 src/input/decoder_synchro.c                                |  2 +-
 src/input/es_out.c                                         |  4 ++--
 src/input/input.c                                          |  6 +++---
 src/input/vlmshell.c                                       |  2 +-
 src/os2/thread.c                                           |  2 +-
 src/video_output/video_text.c                              |  2 +-
 src/win32/thread.c                                         |  2 +-
 55 files changed, 96 insertions(+), 97 deletions(-)

diff --git a/modules/access/dtv/en50221.c b/modules/access/dtv/en50221.c
index 9976a2d273..a1b4c8cee5 100644
--- a/modules/access/dtv/en50221.c
+++ b/modules/access/dtv/en50221.c
@@ -1488,7 +1488,7 @@ static void DateTimeManage( cam_t * p_cam, int i_session_id )
         (date_time_t *)p_cam->p_sessions[i_session_id - 1].p_sys;
 
     if ( p_date->i_interval
-          && mdate() > p_date->i_last + (mtime_t)p_date->i_interval * 1000000 )
+          && mdate() > p_date->i_last + p_date->i_interval * CLOCK_FREQ )
     {
         DateTimeSend( p_cam, i_session_id );
     }
diff --git a/modules/access/linsys/linsys_hdsdi.c b/modules/access/linsys/linsys_hdsdi.c
index 2033d6c50e..8065540ef5 100644
--- a/modules/access/linsys/linsys_hdsdi.c
+++ b/modules/access/linsys/linsys_hdsdi.c
@@ -501,7 +501,7 @@ static int InitVideo( demux_t *p_demux )
     }
 
     p_sys->i_next_vdate = START_DATE;
-    p_sys->i_incr = 1000000 * p_sys->i_frame_rate_base / p_sys->i_frame_rate;
+    p_sys->i_incr = CLOCK_FREQ * p_sys->i_frame_rate_base / p_sys->i_frame_rate;
     p_sys->i_vblock_size = p_sys->i_width * p_sys->i_height * 3 / 2
                             + sizeof(struct block_extension_t);
 
@@ -551,7 +551,7 @@ static int InitAudio( demux_t *p_demux )
 
     p_sys->i_next_adate = START_DATE;
     p_sys->i_ablock_size = p_sys->i_sample_rate * 4 * p_sys->i_frame_rate_base / p_sys->i_frame_rate;
-    p_sys->i_aincr = 1000000. * p_sys->i_ablock_size / p_sys->i_sample_rate / 4;
+    p_sys->i_aincr = CLOCK_FREQ * p_sys->i_ablock_size / p_sys->i_sample_rate / 4;
 
     return VLC_SUCCESS;
 }
diff --git a/modules/access/linsys/linsys_sdi.c b/modules/access/linsys/linsys_sdi.c
index 84ca291cfd..903c6e8dd7 100644
--- a/modules/access/linsys/linsys_sdi.c
+++ b/modules/access/linsys/linsys_sdi.c
@@ -433,7 +433,7 @@ static int StartDecode( demux_t *p_demux )
     char *psz_parser;
 
     p_sys->i_next_date = START_DATE;
-    p_sys->i_incr = 1000000 * p_sys->i_frame_rate_base / p_sys->i_frame_rate;
+    p_sys->i_incr = CLOCK_FREQ * p_sys->i_frame_rate_base / p_sys->i_frame_rate;
     p_sys->i_block_size = p_sys->i_width * p_sys->i_height * 3 / 2
                            + sizeof(struct block_extension_t);
     if( NewFrame( p_demux ) != VLC_SUCCESS )
diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index 1651ada390..83695fd074 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -1445,7 +1445,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             pi64 = (int64_t*)va_arg( args, int64_t * );
             if( p_sys->f_npt > 0 )
             {
-                *pi64 = (int64_t)(p_sys->f_npt * 1000000.);
+                *pi64 = (int64_t)(p_sys->f_npt * CLOCK_FREQ);
                 return VLC_SUCCESS;
             }
             return VLC_EGENERIC;
@@ -1454,7 +1454,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             pi64 = (int64_t*)va_arg( args, int64_t * );
             if( p_sys->f_npt_length > 0 )
             {
-                double d_length = p_sys->f_npt_length * 1000000.0;
+                double d_length = p_sys->f_npt_length * CLOCK_FREQ;
                 if( d_length >= INT64_MAX )
                     *pi64 = INT64_MAX;
                 else
@@ -1481,7 +1481,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 if( (i_query == DEMUX_SET_TIME) && (p_sys->f_npt > 0) )
                 {
                     i64 = (int64_t)va_arg( args, int64_t );
-                    time = (float)(i64 / 1000000.0); /* in second */
+                    time = (float)(i64 / CLOCK_FREQ); /* in second */
                 }
                 else if( i_query == DEMUX_SET_TIME )
                     return VLC_EGENERIC;
diff --git a/modules/audio_filter/resampler/ugly.c b/modules/audio_filter/resampler/ugly.c
index d7a9657368..1b454fe543 100644
--- a/modules/audio_filter/resampler/ugly.c
+++ b/modules/audio_filter/resampler/ugly.c
@@ -115,7 +115,7 @@ static block_t *DoWork( filter_t * p_filter, block_t * p_in_buf )
     p_out_buf->i_buffer = i_out_nb * framesize;
     p_out_buf->i_pts = p_in_buf->i_pts;
     p_out_buf->i_length = p_out_buf->i_nb_samples *
-        1000000 / p_filter->fmt_out.audio.i_rate;
+        CLOCK_FREQ / p_filter->fmt_out.audio.i_rate;
 
     while( i_out_nb )
     {
diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c
index 00a31edb04..dd36318528 100644
--- a/modules/codec/dvbsub.c
+++ b/modules/codec/dvbsub.c
@@ -1510,7 +1510,7 @@ static subpicture_t *render( decoder_t *p_dec )
     //p_spu->i_stop = (mtime_t) 0;
     p_spu->b_ephemer = true;
     //p_spu->b_fade = true;
-    //p_spu->i_stop = p_spu->i_start + (mtime_t) (i_timeout * 1000000);
+    //p_spu->i_stop = p_spu->i_start + i_timeout * CLOCK_FREQ;
     p_spu->b_subtitle = true;
 
     /* Correct positioning of SPU */
@@ -2128,7 +2128,7 @@ static void encode_page_composition( encoder_t *p_enc, bs_t *s,
     if( p_subpic && !p_subpic->b_ephemer &&
         ( p_subpic->i_stop > p_subpic->i_start ) )
     {
-        i_timeout = (p_subpic->i_stop - p_subpic->i_start) / 1000000;
+        i_timeout = (p_subpic->i_stop - p_subpic->i_start) / CLOCK_FREQ;
     }
 
     bs_write( s, 8, i_timeout ); /* Timeout */
diff --git a/modules/codec/flac.c b/modules/codec/flac.c
index 9d2d19bb7d..76fa2651ed 100644
--- a/modules/codec/flac.c
+++ b/modules/codec/flac.c
@@ -740,7 +740,7 @@ EncoderWriteCallback( const FLAC__StreamEncoder *encoder,
 
     p_sys->i_samples_delay -= samples;
 
-    p_block->i_length = (mtime_t)1000000 *
+    p_block->i_length = CLOCK_FREQ *
         (mtime_t)samples / (mtime_t)p_enc->fmt_in.audio.i_rate;
 
     /* Update pts */
@@ -850,7 +850,7 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
     if( unlikely( !p_aout_buf ) ) return NULL;
 
     p_sys->i_pts = p_aout_buf->i_pts -
-                (mtime_t)1000000 * (mtime_t)p_sys->i_samples_delay /
+                CLOCK_FREQ * (mtime_t)p_sys->i_samples_delay /
                 (mtime_t)p_enc->fmt_in.audio.i_rate;
 
     p_sys->i_samples_delay += p_aout_buf->i_nb_samples;
diff --git a/modules/codec/kate.c b/modules/codec/kate.c
index 10ea65fc74..2d45dc618c 100644
--- a/modules/codec/kate.c
+++ b/modules/codec/kate.c
@@ -824,7 +824,7 @@ static int TigerValidateSubpicture( subpicture_t *p_subpic,
     PROFILE_START( TigerValidateSubpicture );
 
     /* time in seconds from the start of the stream */
-    kate_float t = (p_subpic->updater.p_sys->i_start + ts - p_subpic->i_start ) / 1000000.0f;
+    kate_float t = (kate_float)(p_subpic->updater.p_sys->i_start + ts - p_subpic->i_start ) / CLOCK_FREQ;
 
     /* it is likely that the current region (if any) can be kept as is; test for this */
     vlc_mutex_lock( &p_sys->lock );
@@ -864,7 +864,7 @@ static void TigerUpdateSubpicture( subpicture_t *p_subpic,
 
 
     /* time in seconds from the start of the stream */
-    t = (p_subpic->updater.p_sys->i_start + ts - p_subpic->i_start ) / 1000000.0f;
+    t = (kate_float)(p_subpic->updater.p_sys->i_start + ts - p_subpic->i_start ) / CLOCK_FREQ;
 
     PROFILE_START( TigerUpdateSubpicture );
 
diff --git a/modules/codec/shine.c b/modules/codec/shine.c
index 0b46c8c57c..1790ab0791 100644
--- a/modules/codec/shine.c
+++ b/modules/codec/shine.c
@@ -228,7 +228,7 @@ static block_t *EncodeFrame( encoder_t *p_enc, block_t *p_block )
     block_t *p_chain = NULL;
     unsigned int i_samples = p_block->i_buffer >> 2 /* s16l stereo */;
     mtime_t start_date = p_block->i_pts;
-    start_date -= (mtime_t)i_samples * (mtime_t)1000000 / (mtime_t)p_enc->fmt_out.audio.i_rate;
+    start_date -= (mtime_t)i_samples * CLOCK_FREQ / (mtime_t)p_enc->fmt_out.audio.i_rate;
 
     VLC_UNUSED(p_enc);
 
@@ -260,7 +260,7 @@ static block_t *EncodeFrame( encoder_t *p_enc, block_t *p_block )
         memcpy( p_mp3_block->p_buffer, buf, written );
 
         /* date management */
-        p_mp3_block->i_length = p_sys->samples_per_frame * 1000000 /
+        p_mp3_block->i_length = p_sys->samples_per_frame * CLOCK_FREQ /
             p_enc->fmt_out.audio.i_rate;
 
         start_date += p_mp3_block->i_length;
diff --git a/modules/codec/speex.c b/modules/codec/speex.c
index 6cec5696d4..8049f72356 100644
--- a/modules/codec/speex.c
+++ b/modules/codec/speex.c
@@ -1107,7 +1107,7 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
     int i_samples_delay = p_sys->i_samples_delay;
 
     mtime_t i_pts = p_aout_buf->i_pts -
-                (mtime_t)1000000 * (mtime_t)p_sys->i_samples_delay /
+                CLOCK_FREQ * (mtime_t)p_sys->i_samples_delay /
                 (mtime_t)p_enc->fmt_in.audio.i_rate;
 
     p_sys->i_samples_delay += i_samples;
@@ -1166,7 +1166,7 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
         p_block = block_Alloc( i_out );
         memcpy( p_block->p_buffer, p_sys->p_buffer_out, i_out );
 
-        p_block->i_length = (mtime_t)1000000 *
+        p_block->i_length = CLOCK_FREQ *
             (mtime_t)p_sys->i_frame_length * p_sys->header.frames_per_packet /
             (mtime_t)p_enc->fmt_in.audio.i_rate;
 
diff --git a/modules/codec/twolame.c b/modules/codec/twolame.c
index 6fdad1164c..0692dfdb03 100644
--- a/modules/codec/twolame.c
+++ b/modules/codec/twolame.c
@@ -301,7 +301,7 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
     int i_nb_samples = p_aout_buf->i_nb_samples;
 
     p_sys->i_pts = p_aout_buf->i_pts -
-                (mtime_t)1000000 * (mtime_t)p_sys->i_nb_samples /
+                CLOCK_FREQ * (mtime_t)p_sys->i_nb_samples /
                 (mtime_t)p_enc->fmt_out.audio.i_rate;
 
     while ( p_sys->i_nb_samples + i_nb_samples >= MPEG_FRAME_SIZE )
diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c
index 6f6ed8ba54..08dbe776c0 100644
--- a/modules/codec/vorbis.c
+++ b/modules/codec/vorbis.c
@@ -892,7 +892,7 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
     if( unlikely( !p_aout_buf ) ) return NULL;
 
     mtime_t i_pts = p_aout_buf->i_pts -
-                (mtime_t)1000000 * (mtime_t)p_sys->i_samples_delay /
+                CLOCK_FREQ * (mtime_t)p_sys->i_samples_delay /
                 (mtime_t)p_enc->fmt_in.audio.i_rate;
 
     p_sys->i_samples_delay += p_aout_buf->i_nb_samples;
@@ -930,7 +930,7 @@ static block_t *Encode( encoder_t *p_enc, block_t *p_aout_buf )
             i_samples = ( p_sys->i_last_block_size + i_block_size ) >> 2;
             p_sys->i_last_block_size = i_block_size;
 
-            p_block->i_length = (mtime_t)1000000 *
+            p_block->i_length = CLOCK_FREQ *
                 (mtime_t)i_samples / (mtime_t)p_enc->fmt_in.audio.i_rate;
 
             p_block->i_dts = p_block->i_pts = i_pts;
diff --git a/modules/control/oldrc.c b/modules/control/oldrc.c
index d33a74c62c..77083ed280 100644
--- a/modules/control/oldrc.c
+++ b/modules/control/oldrc.c
@@ -1147,7 +1147,7 @@ static void print_playlist( intf_thread_t *p_intf, playlist_item_t *p_item, int
     {
         if( p_item->pp_children[i]->p_input->i_duration != -1 )
         {
-            secstotimestr( psz_buffer, p_item->pp_children[i]->p_input->i_duration / 1000000 );
+            secstotimestr( psz_buffer, p_item->pp_children[i]->p_input->i_duration / CLOCK_FREQ );
             msg_rc( "|%*s- %s (%s)", 2 * i_level, "", p_item->pp_children[i]->p_input->psz_name, psz_buffer );
         }
         else
diff --git a/modules/demux/aiff.c b/modules/demux/aiff.c
index 678db64664..e0992fe410 100644
--- a/modules/demux/aiff.c
+++ b/modules/demux/aiff.c
@@ -263,7 +263,7 @@ static int Demux( demux_t *p_demux )
     p_block->i_dts =
     p_block->i_pts = VLC_TS_0 + p_sys->i_time;
 
-    p_sys->i_time += (int64_t)1000000 *
+    p_sys->i_time += CLOCK_FREQ *
                      p_block->i_buffer /
                      p_sys->i_ssnd_fsize /
                      p_sys->fmt.audio.i_rate;
@@ -319,7 +319,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 {
                     return VLC_EGENERIC;
                 }
-                p_sys->i_time = (int64_t)1000000 * i_frame / p_sys->fmt.audio.i_rate;
+                p_sys->i_time = CLOCK_FREQ * i_frame / p_sys->fmt.audio.i_rate;
                 return VLC_SUCCESS;
             }
             return VLC_EGENERIC;
@@ -337,7 +337,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             pi64 = (int64_t*)va_arg( args, int64_t * );
             if( p_sys->i_ssnd_start < i_end )
             {
-                *pi64 = (int64_t)1000000 * ( i_end - p_sys->i_ssnd_start ) / p_sys->i_ssnd_fsize / p_sys->fmt.audio.i_rate;
+                *pi64 = CLOCK_FREQ * ( i_end - p_sys->i_ssnd_start ) / p_sys->i_ssnd_fsize / p_sys->fmt.audio.i_rate;
                 return VLC_SUCCESS;
             }
             return VLC_EGENERIC;
diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 9b042ed567..e1940d058e 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -356,7 +356,7 @@ static int SeekIndex( demux_t *p_demux, mtime_t i_date, float f_pos )
     asf_object_index_t *p_index;
 
     msg_Dbg( p_demux, "seek with index: %i seconds, position %f",
-             i_date >= 0 ? (int)(i_date/1000000) : -1, f_pos );
+             i_date >= 0 ? (int)(i_date/CLOCK_FREQ) : -1, f_pos );
 
     if( i_date < 0 )
         i_date = p_sys->i_length * f_pos;
@@ -1246,7 +1246,7 @@ static int DemuxInit( demux_t *p_demux )
 
         if( p_sys->i_length > 0 )
         {
-            p_sys->i_bitrate = 8 * i_size * 1000000 / p_sys->i_length;
+            p_sys->i_bitrate = 8 * i_size * CLOCK_FREQ / p_sys->i_length;
         }
     }
 
diff --git a/modules/demux/au.c b/modules/demux/au.c
index f9d2b4f6b5..659aaa2357 100644
--- a/modules/demux/au.c
+++ b/modules/demux/au.c
@@ -288,7 +288,7 @@ static int Open( vlc_object_t *p_this )
             p_sys->i_frame_size += p_sys->fmt.audio.i_blockalign - mod;
         }
     }
-    p_sys->i_frame_length = (mtime_t)1000000 *
+    p_sys->i_frame_length = CLOCK_FREQ *
                             (mtime_t)i_samples /
                             (mtime_t)p_sys->fmt.audio.i_rate;
 
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 0c1a67e67a..7706c3a319 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -647,7 +647,7 @@ int OpenDemux( vlc_object_t *p_this )
     p_sys->tk_pcr = xcalloc( p_sys->i_tk, sizeof(*p_sys->tk_pcr) );
 
     if( p_sys->ic->start_time != (int64_t)AV_NOPTS_VALUE )
-        i_start_time = p_sys->ic->start_time * 1000000 / AV_TIME_BASE;
+        i_start_time = p_sys->ic->start_time * CLOCK_FREQ / AV_TIME_BASE;
 
     msg_Dbg( p_demux, "AVFormat supported stream" );
     msg_Dbg( p_demux, "    - format = %s (%s)",
@@ -655,12 +655,12 @@ int OpenDemux( vlc_object_t *p_this )
     msg_Dbg( p_demux, "    - start time = %"PRId64, i_start_time );
     msg_Dbg( p_demux, "    - duration = %"PRId64,
              ( p_sys->ic->duration != (int64_t)AV_NOPTS_VALUE ) ?
-             p_sys->ic->duration * 1000000 / AV_TIME_BASE : -1 );
+             p_sys->ic->duration * CLOCK_FREQ / AV_TIME_BASE : -1 );
 
     if( p_sys->ic->nb_chapters > 0 )
     {
         p_sys->p_title = vlc_input_title_New();
-        p_sys->p_title->i_length = p_sys->ic->duration * 1000000 / AV_TIME_BASE;
+        p_sys->p_title->i_length = p_sys->ic->duration * CLOCK_FREQ / AV_TIME_BASE;
     }
 
     for( i = 0; i < p_sys->ic->nb_chapters; i++ )
@@ -674,7 +674,7 @@ int OpenDemux( vlc_object_t *p_this )
             EnsureUTF8( s->psz_name );
             msg_Dbg( p_demux, "    - chapter %d: %s", i, s->psz_name );
         }
-        s->i_time_offset = p_sys->ic->chapters[i]->start * 1000000 *
+        s->i_time_offset = p_sys->ic->chapters[i]->start * CLOCK_FREQ *
             p_sys->ic->chapters[i]->time_base.num /
             p_sys->ic->chapters[i]->time_base.den -
             (i_start_time != -1 ? i_start_time : 0 );
@@ -1000,7 +1000,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         case DEMUX_GET_LENGTH:
             pi64 = (int64_t*)va_arg( args, int64_t * );
             if( p_sys->ic->duration != (int64_t)AV_NOPTS_VALUE )
-                *pi64 = p_sys->ic->duration * 1000000 / AV_TIME_BASE;
+                *pi64 = p_sys->ic->duration * CLOCK_FREQ / AV_TIME_BASE;
             else
                 *pi64 = 0;
             return VLC_SUCCESS;
@@ -1013,7 +1013,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         case DEMUX_SET_TIME:
         {
             i64 = (int64_t)va_arg( args, int64_t );
-            i64 = i64 *AV_TIME_BASE / 1000000 + i_start_time;
+            i64 = i64 *AV_TIME_BASE / CLOCK_FREQ + i_start_time;
 
             msg_Warn( p_demux, "DEMUX_SET_TIME: %"PRId64, i64 );
 
@@ -1118,7 +1118,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 return VLC_EGENERIC;
 
             i64 = p_sys->p_title->seekpoint[i_seekpoint]->i_time_offset *
-                  AV_TIME_BASE / 1000000 + i_start_time;
+                  AV_TIME_BASE / CLOCK_FREQ + i_start_time;
 
             msg_Warn( p_demux, "DEMUX_SET_SEEKPOINT: %"PRId64, i64 );
 
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index ddde3b1576..3e339e33bb 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -1768,7 +1768,7 @@ static mtime_t AVI_PTSToByte( avi_track_t *tk, mtime_t i_pts )
     return (mtime_t)((int64_t)i_pts *
                      (int64_t)tk->i_rate /
                      (int64_t)tk->i_scale /
-                     (int64_t)1000000 *
+                     CLOCK_FREQ *
                      (int64_t)tk->i_samplesize );
 }
 
@@ -1779,7 +1779,7 @@ static mtime_t AVI_GetDPTS( avi_track_t *tk, int64_t i_count )
     if( !tk->i_rate )
         return i_dpts;
 
-    i_dpts = (mtime_t)( (int64_t)1000000 *
+    i_dpts = (mtime_t)( CLOCK_FREQ *
                         (int64_t)i_count *
                         (int64_t)tk->i_scale /
                         (int64_t)tk->i_rate );
diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index 2b329b7c14..ed7949a74a 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -333,7 +333,7 @@ static int Demux( demux_t *p_demux )
         {
             if( p_block_out->i_pts <= VLC_TS_INVALID &&
                 p_block_out->i_dts <= VLC_TS_INVALID )
-                p_block_out->i_dts = VLC_TS_0 + p_sys->i_pts + 1000000 / p_sys->f_fps;
+                p_block_out->i_dts = VLC_TS_0 + p_sys->i_pts + CLOCK_FREQ / p_sys->f_fps;
             if( p_block_out->i_dts > VLC_TS_INVALID )
                 p_sys->i_pts = p_block_out->i_dts - VLC_TS_0;
         }
diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c
index 40f116046f..77151f747a 100644
--- a/modules/demux/ogg.c
+++ b/modules/demux/ogg.c
@@ -808,7 +808,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             if( p_sys->i_length > 0 )
             {
                 *pf =  (double) p_sys->i_pcr /
-                       (double) ( p_sys->i_length * (mtime_t)1000000 );
+                       (double) ( p_sys->i_length * CLOCK_FREQ );
             }
             else if( stream_Size( p_demux->s ) > 0 )
             {
@@ -862,7 +862,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 return demux_vaControlHelper( p_demux->s, 0, -1, p_sys->i_bitrate,
                                               1, i_query, args );
             pi64 = (int64_t*)va_arg( args, int64_t * );
-            *pi64 = p_sys->i_length * 1000000;
+            *pi64 = p_sys->i_length * CLOCK_FREQ;
             return VLC_SUCCESS;
 
         case DEMUX_GET_TITLE_INFO:
diff --git a/modules/demux/playlist/asx.c b/modules/demux/playlist/asx.c
index 7d7863e8f7..e3f5aae661 100644
--- a/modules/demux/playlist/asx.c
+++ b/modules/demux/playlist/asx.c
@@ -105,7 +105,7 @@ static mtime_t ParseTime(xml_reader_t *p_xml_reader)
         i_subresult = i_subresult * 10;
         i_subfractions++;
     }
-    i_result = i_result * 1000000;
+    i_result = i_result * CLOCK_FREQ;
     if( i_subfractions != -1)
         i_result += i_subresult;
 
@@ -256,13 +256,13 @@ static void ProcessEntry( int *pi_n_entry, xml_reader_t *p_xml_reader,
                 i_options = 0;
                 if( i_start )
                 {
-                    if( asprintf( ppsz_options, ":start-time=%d" ,(int) i_start/1000000 ) != -1)
+                    if( asprintf( ppsz_options, ":start-time=%d" ,(int) i_start/CLOCK_FREQ ) != -1)
                         i_options++;
                 }
                 if( i_duration)
                 {
                     if( asprintf( ppsz_options + i_options, ":stop-time=%d",
-                                (int) (i_start+i_duration)/1000000 ) != -1)
+                                (int) (i_start+i_duration)/CLOCK_FREQ ) != -1)
                         i_options++;
                 }
 
diff --git a/modules/demux/playlist/podcast.c b/modules/demux/playlist/podcast.c
index 7d21575eb1..b30031a8de 100644
--- a/modules/demux/playlist/podcast.c
+++ b/modules/demux/playlist/podcast.c
@@ -352,9 +352,9 @@ static mtime_t strTimeToMTime( const char *psz )
     switch( sscanf( psz, "%u:%u:%u", &h, &m, &s ) )
     {
     case 3:
-        return (mtime_t)( ( h*60 + m )*60 + s ) * 1000000;
+        return (mtime_t)( ( h*60 + m )*60 + s ) * CLOCK_FREQ;
     case 2:
-        return (mtime_t)( h*60 + m ) * 1000000;
+        return (mtime_t)( h*60 + m ) * CLOCK_FREQ;
     default:
         return -1;
     }
diff --git a/modules/demux/pva.c b/modules/demux/pva.c
index c00e43cebd..733acd6acd 100644
--- a/modules/demux/pva.c
+++ b/modules/demux/pva.c
@@ -329,7 +329,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             pi64 = (int64_t*)va_arg( args, int64_t * );
             if( p_sys->i_mux_rate > 0 )
             {
-                *pi64 = (int64_t)1000000 * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
+                *pi64 = CLOCK_FREQ * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
                 return VLC_SUCCESS;
             }
             *pi64 = 0;
@@ -338,7 +338,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 #endif
         case DEMUX_GET_FPS:
             pf = (double*)va_arg( args, double * );
-            *pf = (double)1000000.0 / (double)p_sys->i_pcr_inc;
+            *pf = (double)CLOCK_FREQ / (double)p_sys->i_pcr_inc;
             return VLC_SUCCESS;
 #endif
         case DEMUX_SET_TIME:
diff --git a/modules/gui/macosx/VLCFSPanelController.m b/modules/gui/macosx/VLCFSPanelController.m
index e3ed64fbfd..a9d80521b6 100644
--- a/modules/gui/macosx/VLCFSPanelController.m
+++ b/modules/gui/macosx/VLCFSPanelController.m
@@ -270,9 +270,9 @@ static NSString *kAssociatedFullscreenRect = @"VLCFullscreenAssociatedWindowRect
             mtime_t remaining = 0;
             if (dur > t)
                 remaining = dur - t;
-            totalTime = [NSString stringWithFormat:@"-%s", secstotimestr(psz_time, (remaining / 1000000))];
+            totalTime = [NSString stringWithFormat:@"-%s", secstotimestr(psz_time, (remaining / CLOCK_FREQ))];
         } else {
-            totalTime = toNSStr(secstotimestr(psz_time, (dur / 1000000)));
+            totalTime = toNSStr(secstotimestr(psz_time, (dur / CLOCK_FREQ)));
         }
         [_remainingOrTotalTime setStringValue:totalTime];
     }
diff --git a/modules/gui/macosx/VLCMainWindow.m b/modules/gui/macosx/VLCMainWindow.m
index fa6f247602..ea61fea7a3 100644
--- a/modules/gui/macosx/VLCMainWindow.m
+++ b/modules/gui/macosx/VLCMainWindow.m
@@ -971,7 +971,7 @@ static const float f_min_window_height = 307.;
     if (mt_duration < 1)
         return @"";
 
-    mt_duration = mt_duration / 1000000;
+    mt_duration = mt_duration / CLOCK_FREQ;
 
     NSDate *date = [NSDate dateWithTimeIntervalSince1970:mt_duration];
     NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
diff --git a/modules/gui/macosx/VLCPLModel.m b/modules/gui/macosx/VLCPLModel.m
index dc3b7c872c..68b397ccaa 100644
--- a/modules/gui/macosx/VLCPLModel.m
+++ b/modules/gui/macosx/VLCPLModel.m
@@ -520,7 +520,7 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
         char psz_duration[MSTRTIME_MAX_SIZE];
         mtime_t dur = input_item_GetDuration(p_input);
         if (dur != -1) {
-            secstotimestr(psz_duration, dur/1000000);
+            secstotimestr(psz_duration, dur/CLOCK_FREQ);
             o_value = toNSStr(psz_duration);
         }
         else
diff --git a/modules/gui/macosx/VLCPlaylist.m b/modules/gui/macosx/VLCPlaylist.m
index 70170fdfee..7461d3c756 100644
--- a/modules/gui/macosx/VLCPlaylist.m
+++ b/modules/gui/macosx/VLCPlaylist.m
@@ -849,7 +849,7 @@
         if (result == RESUME_RESTART)
             return;
 
-        mtime_t lastPos = (mtime_t)lastPosition.intValue * 1000000;
+        mtime_t lastPos = (mtime_t)lastPosition.intValue * CLOCK_FREQ;
         msg_Dbg(getIntf(), "continuing playback at %lld", lastPos);
         var_SetInteger(p_input_thread, "time", lastPos);
     };
@@ -888,7 +888,7 @@
 
     float relativePos = var_GetFloat(p_input_thread, "position");
     mtime_t pos = var_GetInteger(p_input_thread, "time") / CLOCK_FREQ;
-    mtime_t dur = input_item_GetDuration(p_item) / 1000000;
+    mtime_t dur = input_item_GetDuration(p_item) / CLOCK_FREQ;
 
     NSMutableArray *mediaList = [[defaults objectForKey:@"recentlyPlayedMediaList"] mutableCopy];
 
diff --git a/modules/gui/macosx/VLCStatusBarIcon.m b/modules/gui/macosx/VLCStatusBarIcon.m
index 09f34740c0..a4e57d2bc2 100644
--- a/modules/gui/macosx/VLCStatusBarIcon.m
+++ b/modules/gui/macosx/VLCStatusBarIcon.m
@@ -266,7 +266,7 @@
             [totalField setStringValue:@"∞"];
         } else {
             /* Not unknown, update displayed duration */
-            totalTime = [[VLCStringUtility sharedInstance] stringForTime:(dur/1000000)];
+            totalTime = [[VLCStringUtility sharedInstance] stringForTime:(dur/CLOCK_FREQ)];
             [progressField setStringValue:(showTimeElapsed) ? elapsedTime : remainingTime];
             [totalField setStringValue:totalTime];
         }
diff --git a/modules/gui/macosx/VLCStringUtility.m b/modules/gui/macosx/VLCStringUtility.m
index 561b2e60a2..edd2f66a32 100644
--- a/modules/gui/macosx/VLCStringUtility.m
+++ b/modules/gui/macosx/VLCStringUtility.m
@@ -132,7 +132,7 @@ NSString *const kVLCMediaUnknown = @"Unknown";
         mtime_t remaining = 0;
         if (dur > t)
             remaining = dur - t;
-        return [NSString stringWithFormat: @"-%s", secstotimestr(psz_time, (remaining / 1000000))];
+        return [NSString stringWithFormat: @"-%s", secstotimestr(psz_time, (remaining / CLOCK_FREQ))];
     } else
         return toNSStr(secstotimestr(psz_time, t / CLOCK_FREQ ));
 }
diff --git a/modules/gui/macosx/VLCTrackSynchronizationWindowController.m b/modules/gui/macosx/VLCTrackSynchronizationWindowController.m
index 2293019405..01eedbbe83 100644
--- a/modules/gui/macosx/VLCTrackSynchronizationWindowController.m
+++ b/modules/gui/macosx/VLCTrackSynchronizationWindowController.m
@@ -131,8 +131,8 @@
     input_thread_t * p_input = pl_CurrentInput(getIntf());
 
     if (p_input) {
-        [_av_advanceTextField setDoubleValue: var_GetInteger(p_input, "audio-delay") / 1000000.];
-        [_sv_advanceTextField setDoubleValue: var_GetInteger(p_input, "spu-delay") / 1000000.];
+        [_av_advanceTextField setDoubleValue: var_GetInteger(p_input, "audio-delay") / CLOCK_FREQ];
+        [_sv_advanceTextField setDoubleValue: var_GetInteger(p_input, "spu-delay") / CLOCK_FREQ];
         [_sv_speedTextField setFloatValue: var_GetFloat(p_input, "sub-fps")];
         vlc_object_release(p_input);
     }
@@ -151,7 +151,7 @@
     input_thread_t * p_input = pl_CurrentInput(getIntf());
 
     if (p_input) {
-        var_SetInteger(p_input, "audio-delay", [_av_advanceTextField doubleValue] * 1000000.);
+        var_SetInteger(p_input, "audio-delay", [_av_advanceTextField doubleValue] * CLOCK_FREQ);
         vlc_object_release(p_input);
     }
 }
@@ -166,7 +166,7 @@
     input_thread_t * p_input = pl_CurrentInput(getIntf());
 
     if (p_input) {
-        var_SetInteger(p_input, "spu-delay", [_sv_advanceTextField doubleValue] * 1000000.);
+        var_SetInteger(p_input, "spu-delay", [_sv_advanceTextField doubleValue] * CLOCK_FREQ);
         vlc_object_release(p_input);
     }
 }
diff --git a/modules/gui/qt/adapters/chromaprint.cpp b/modules/gui/qt/adapters/chromaprint.cpp
index f4b19c4d25..7ea80d0ddf 100644
--- a/modules/gui/qt/adapters/chromaprint.cpp
+++ b/modules/gui/qt/adapters/chromaprint.cpp
@@ -57,7 +57,7 @@ bool Chromaprint::enqueue( input_item_t *p_item )
     fingerprint_request_t *p_r = fingerprint_request_New( p_item );
     if ( ! p_r ) return false;
     mtime_t t = input_item_GetDuration( p_item );
-    if ( t ) p_r->i_duration = (unsigned int) ( t / 1000000 );
+    if ( t ) p_r->i_duration = (unsigned int) ( t / CLOCK_FREQ );
     p_fingerprinter->pf_enqueue( p_fingerprinter, p_r );
     return true;
 }
diff --git a/modules/gui/qt/components/playlist/selector.cpp b/modules/gui/qt/components/playlist/selector.cpp
index c02a024b24..b12976d585 100644
--- a/modules/gui/qt/components/playlist/selector.cpp
+++ b/modules/gui/qt/components/playlist/selector.cpp
@@ -210,7 +210,7 @@ void PLSelector::updateTotalDuration( PLSelItem* item, const char* prefix )
     /* Formatting time */
     QString qs_timeLabel( prefix );
 
-    int i_seconds = mt_duration / 1000000;
+    int i_seconds = mt_duration / CLOCK_FREQ;
     int i_minutes = i_seconds / 60;
     i_seconds = i_seconds % 60;
     if( i_minutes >= 60 )
diff --git a/modules/gui/qt/components/playlist/sorting.h b/modules/gui/qt/components/playlist/sorting.h
index 6c1e93514a..3b81ea32ad 100644
--- a/modules/gui/qt/components/playlist/sorting.h
+++ b/modules/gui/qt/components/playlist/sorting.h
@@ -86,7 +86,7 @@ static inline char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
     case COLUMN_TITLE:
         return input_item_GetTitleFbName( p_item );
     case COLUMN_DURATION:
-        i_duration = input_item_GetDuration( p_item ) / 1000000;
+        i_duration = input_item_GetDuration( p_item ) / CLOCK_FREQ;
         if( i_duration == 0 ) return NULL;
         secstotimestr( psz_duration, i_duration );
         return strdup( psz_duration );
diff --git a/modules/hw/mmal/deinterlace.c b/modules/hw/mmal/deinterlace.c
index cb3148398a..6b8cc97aba 100644
--- a/modules/hw/mmal/deinterlace.c
+++ b/modules/hw/mmal/deinterlace.c
@@ -82,7 +82,7 @@ static void flush(filter_t *filter);
 static int Open(filter_t *filter)
 {
     int32_t frame_duration = filter->fmt_in.video.i_frame_rate != 0 ?
-            (int64_t)1000000 * filter->fmt_in.video.i_frame_rate_base /
+            CLOCK_FREQ * filter->fmt_in.video.i_frame_rate_base /
             filter->fmt_in.video.i_frame_rate : 0;
 
     MMAL_PARAMETER_IMAGEFX_PARAMETERS_T imfx_param = {
diff --git a/modules/hw/mmal/vout.c b/modules/hw/mmal/vout.c
index 4043f73d31..86b12b06a9 100644
--- a/modules/hw/mmal/vout.c
+++ b/modules/hw/mmal/vout.c
@@ -967,7 +967,7 @@ static void maintain_phase_sync(vout_display_t *vd)
     MMAL_PARAMETER_VIDEO_RENDER_STATS_T render_stats = {
         .hdr = { MMAL_PARAMETER_VIDEO_RENDER_STATS, sizeof(render_stats) },
     };
-    int32_t frame_duration = 1000000 /
+    int32_t frame_duration = CLOCK_FREQ /
         ((double)vd->sys->i_frame_rate /
         vd->sys->i_frame_rate_base);
     vout_display_sys_t *sys = vd->sys;
diff --git a/modules/lua/libs/input.c b/modules/lua/libs/input.c
index b5ca73ab4c..80ba7ae5d7 100644
--- a/modules/lua/libs/input.c
+++ b/modules/lua/libs/input.c
@@ -317,7 +317,7 @@ static int vlclua_input_item_name( lua_State *L )
 static int vlclua_input_item_duration( lua_State *L )
 {
     mtime_t duration = input_item_GetDuration( vlclua_input_item_get_internal( L ) );
-    lua_pushnumber( L, ((double)duration)/1000000. );
+    lua_pushnumber( L, ((double)duration)/CLOCK_FREQ );
     return 1;
 }
 
diff --git a/modules/lua/libs/osd.c b/modules/lua/libs/osd.c
index 9a4e0ae858..83a11c6337 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, SPU_DEFAULT_CHANNEL );
     const char *psz_position = luaL_optstring( L, 3, "top-right" );
-    mtime_t duration = (mtime_t)luaL_optinteger( L, 4, 1000000 );
+    mtime_t duration = (mtime_t)luaL_optinteger( L, 4, CLOCK_FREQ );
 
     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 133829a0e9..f78472911f 100644
--- a/modules/misc/audioscrobbler.c
+++ b/modules/misc/audioscrobbler.c
@@ -199,7 +199,7 @@ static void ReadMetaData(intf_thread_t *p_this, input_thread_t *p_input)
     ALLOC_ITEM_META(p_sys->p_current_song.psz_m, TrackID);
     ALLOC_ITEM_META(p_sys->p_current_song.psz_n, TrackNum);
 
-    p_sys->p_current_song.i_l = input_item_GetDuration(p_item) / 1000000;
+    p_sys->p_current_song.i_l = input_item_GetDuration(p_item) / CLOCK_FREQ;
 
 #undef ALLOC_ITEM_META
 
@@ -228,7 +228,7 @@ static void AddToQueue (intf_thread_t *p_this)
     /* wait for the user to listen enough before submitting */
     played_time = mdate() - p_sys->p_current_song.i_start -
                             p_sys->time_total_pauses;
-    played_time /= 1000000; /* µs → s */
+    played_time /= CLOCK_FREQ; /* µs → s */
 
     /*HACK: it seam that the preparsing sometime fail,
             so use the playing time as the song length */
@@ -662,7 +662,7 @@ static void HandleInterval(mtime_t *next, unsigned int *i_interval)
         if (*i_interval > 120)
             *i_interval = 120;
     }
-    *next = mdate() + (*i_interval * 1000000 * 60);
+    *next = mdate() + (*i_interval * CLOCK_FREQ * 60);
 }
 
 /*****************************************************************************
diff --git a/modules/misc/playlist/html.c b/modules/misc/playlist/html.c
index 1aa6dce457..8f3ed3c5dd 100644
--- a/modules/misc/playlist/html.c
+++ b/modules/misc/playlist/html.c
@@ -71,8 +71,8 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root )
             free( psz_tmp );
 
             mtime_t i_duration = input_item_GetDuration( p_current->p_input );
-            int min = ( i_duration / 1000000 ) / 60;
-            int sec = ( i_duration / 1000000 ) - min * 60;
+            int min = ( i_duration / CLOCK_FREQ ) / 60;
+            int sec = ( i_duration / CLOCK_FREQ ) - min * 60;
 
             // Print the artist if we have one
             if( psz_artist && *psz_artist )
diff --git a/modules/mux/avi.c b/modules/mux/avi.c
index 86e91c416b..625846ab0e 100644
--- a/modules/mux/avi.c
+++ b/modules/mux/avi.c
@@ -229,20 +229,20 @@ static void Close( vlc_object_t * p_this )
         {
             p_stream->f_fps = (float)p_stream->i_frames /
                               ( (float)p_stream->i_duration /
-                                (float)1000000 );
+                                (float)CLOCK_FREQ );
         }
         p_stream->i_bitrate = 128 * 1024;
         if( p_stream->i_duration > 0 )
         {
             p_stream->i_bitrate =
-                8 * (uint64_t)1000000 *
+                8 * CLOCK_FREQ *
                     (uint64_t)p_stream->i_totalsize /
                     (uint64_t)p_stream->i_duration;
         }
         msg_Info( p_mux, "stream[%d] duration:%"PRId64" totalsize:%"PRId64
                   " frames:%d fps:%f KiB/s:%d",
                   i_stream,
-                  (int64_t)p_stream->i_duration / (int64_t)1000000,
+                  (int64_t)p_stream->i_duration / CLOCK_FREQ,
                   p_stream->i_totalsize,
                   p_stream->i_frames,
                   p_stream->f_fps, p_stream->i_bitrate/1024 );
diff --git a/modules/mux/mpeg/ps.c b/modules/mux/mpeg/ps.c
index 41d040078f..9f92a5ec3c 100644
--- a/modules/mux/mpeg/ps.c
+++ b/modules/mux/mpeg/ps.c
@@ -471,7 +471,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 > 1000000 )
+                i_dts - p_sys->i_instant_dts > CLOCK_FREQ )
             {
                 int64_t i_instant_bitrate = p_sys->i_instant_size * 8000000 /
                     ( i_dts - p_sys->i_instant_dts );
diff --git a/modules/mux/ogg.c b/modules/mux/ogg.c
index 03789b7054..7743de43d9 100644
--- a/modules/mux/ogg.c
+++ b/modules/mux/ogg.c
@@ -719,7 +719,7 @@ static void OggGetSkeletonIndex( uint8_t **pp_buffer, long *pi_size, ogg_stream_
     memcpy( p_buffer, "index", 6 );
     SetDWLE( &p_buffer[6], p_stream->i_serial_no );
     SetQWLE( &p_buffer[10], p_stream->skeleton.i_index_count ); /* num keypoints */
-    SetQWLE( &p_buffer[18], 1000000 );
+    SetQWLE( &p_buffer[18], CLOCK_FREQ );
     SetQWLE( &p_buffer[34], p_stream->i_length );
     memcpy( p_buffer + INDEX_BASE_SIZE, p_stream->skeleton.p_index, p_stream->skeleton.i_index_payload );
     *pi_size = INDEX_BASE_SIZE + p_stream->skeleton.i_index_size;
@@ -1444,7 +1444,7 @@ static bool AllocateIndex( sout_mux_t *p_mux, sout_input_t *p_input )
         /* estimate length of pos value */
         if ( p_input->p_fmt->i_bitrate )
         {
-            i = i_interval * p_input->p_fmt->i_bitrate / 1000000;
+            i = i_interval * p_input->p_fmt->i_bitrate / CLOCK_FREQ;
             while ( i <<= 1 ) i_tuple_size++;
         }
         else
diff --git a/modules/packetizer/dirac.c b/modules/packetizer/dirac.c
index 359a046739..4eb183eac8 100644
--- a/modules/packetizer/dirac.c
+++ b/modules/packetizer/dirac.c
@@ -917,7 +917,7 @@ static int dirac_InspectDataUnit( decoder_t *p_dec, block_t **pp_block, block_t
 
         /* TODO: set p_sys->reorder_buf.u_size_max */
         p_sys->i_pts_offset = p_sys->reorder_buf.u_size_max
-                            * 1000000
+                            * CLOCK_FREQ
                             * p_es->video.i_frame_rate_base / p_es->video.i_frame_rate + 1;
 
         /* stash a copy of the seqhdr
diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index 6fc5971daf..422440f3ca 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -578,7 +578,7 @@ static void *Run( void *data )
         /* Check for items that need deletion */
         for( i = 0; i < p_sd->p_sys->i_announces; i++ )
         {
-            mtime_t i_timeout = ( mtime_t ) 1000000 * p_sd->p_sys->i_timeout;
+            mtime_t i_timeout = CLOCK_FREQ * p_sd->p_sys->i_timeout;
             sap_announce_t * p_announce = p_sd->p_sys->pp_announces[i];
             mtime_t i_last_period = now - p_announce->i_last;
 
diff --git a/modules/spu/rss.c b/modules/spu/rss.c
index 751bba8889..9cdbd46e40 100644
--- a/modules/spu/rss.c
+++ b/modules/spu/rss.c
@@ -314,8 +314,7 @@ static int CreateFilter( vlc_object_t *p_this )
         vlc_mutex_destroy( &p_sys->lock );
         goto error;
     }
-    vlc_timer_schedule( p_sys->timer, false, 1,
-                        (mtime_t)(i_ttl)*1000000 );
+    vlc_timer_schedule( p_sys->timer, false, 1, CLOCK_FREQ * i_ttl );
 
     free( psz_urls );
     return VLC_SUCCESS;
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index eac3e99dcb..26b3772797 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -42,7 +42,7 @@
 #define PING_WAIT_TIME 6000
 #define PING_WAIT_RETRIES 1
 
-static const mtime_t SEEK_FORWARD_OFFSET = 1000000;
+static const mtime_t SEEK_FORWARD_OFFSET = (1*CLOCK_FREQ);
 
 static const char* StateToStr( States s )
 {
@@ -605,7 +605,7 @@ void intf_sys_t::requestPlayerSeek(mtime_t pos)
         m_ts_local_start = pos;
     char current_time[32];
     mtime_t seek_request_time = mdate() + SEEK_FORWARD_OFFSET;
-    if( snprintf( current_time, sizeof(current_time), "%.3f", double( seek_request_time ) / 1000000.0 ) >= (int)sizeof(current_time) )
+    if( snprintf( current_time, sizeof(current_time), "%.3f", double( seek_request_time ) / CLOCK_FREQ ) >= (int)sizeof(current_time) )
     {
         msg_Err( m_module, "snprintf() truncated string for mediaSessionId" );
         current_time[sizeof(current_time) - 1] = '\0';
diff --git a/modules/stream_out/record.c b/modules/stream_out/record.c
index 5dd03424f8..2b15c5041a 100644
--- a/modules/stream_out/record.c
+++ b/modules/stream_out/record.c
@@ -240,7 +240,7 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
           p_sys->i_size > p_sys->i_max_size ) )
     {
         msg_Dbg( p_stream, "Starting recording, waited %ds and %dbyte",
-                 (int)((mdate() - p_sys->i_date_start)/1000000), (int)p_sys->i_size );
+                 (int)((mdate() - p_sys->i_date_start)/CLOCK_FREQ), (int)p_sys->i_size );
         OutputStart( p_stream );
     }
 
diff --git a/modules/video_filter/blendbench.c b/modules/video_filter/blendbench.c
index d33fc3cb87..feb6e62f28 100644
--- a/modules/video_filter/blendbench.c
+++ b/modules/video_filter/blendbench.c
@@ -261,10 +261,10 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
     time = mdate() - time;
 
     msg_Info( p_filter, "Blended %d images in %f sec", p_sys->i_loops,
-              time / 1000000.0f );
+              (float) time / CLOCK_FREQ );
     msg_Info( p_filter, "Speed is: %f images/second, %f pixels/second",
-              (float) p_sys->i_loops / time * 1000000,
-              (float) p_sys->i_loops / time * 1000000 *
+              (float) p_sys->i_loops / time * CLOCK_FREQ,
+              (float) p_sys->i_loops / time * CLOCK_FREQ *
                   p_sys->p_blend_image->p[Y_PLANE].i_visible_pitch *
                   p_sys->p_blend_image->p[Y_PLANE].i_visible_lines );
 
diff --git a/src/input/decoder_synchro.c b/src/input/decoder_synchro.c
index 00b3e0fd6d..739c319ea7 100644
--- a/src/input/decoder_synchro.c
+++ b/src/input/decoder_synchro.c
@@ -407,7 +407,7 @@ void decoder_SynchroNewPicture( decoder_synchro_t * p_synchro, int i_coding_type
                                 int i_repeat_field, mtime_t next_pts,
                                 mtime_t next_dts, bool b_low_delay )
 {
-    mtime_t         period = 1000000 * 1001 / p_synchro->i_frame_rate;
+    mtime_t         period = CLOCK_FREQ * 1001 / p_synchro->i_frame_rate;
 #if 0
     mtime_t         now = mdate();
 #endif
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 697452a807..20d118ccff 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -3073,8 +3073,8 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
            fmt->video.i_frame_rate_base > 0 )
        {
            div = lldiv( (float)fmt->video.i_frame_rate /
-                               fmt->video.i_frame_rate_base * 1000000,
-                               1000000 );
+                               fmt->video.i_frame_rate_base * CLOCK_FREQ,
+                               CLOCK_FREQ );
            if( div.rem > 0 )
                info_category_AddInfo( p_cat, _("Frame rate"), "%"PRId64".%06u",
                                       div.quot, (unsigned int )div.rem );
diff --git a/src/input/input.c b/src/input/input.c
index 26d13a53d9..3d17488e6d 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -907,13 +907,13 @@ static void StartTitle( input_thread_t * p_input )
         input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &val );
 
     /* Start/stop/run time */
-    priv->i_start = llroundf(1000000.f
+    priv->i_start = llroundf(CLOCK_FREQ
                                      * var_GetFloat( p_input, "start-time" ));
-    priv->i_stop  = llroundf(1000000.f
+    priv->i_stop  = llroundf(CLOCK_FREQ
                                      * var_GetFloat( p_input, "stop-time" ));
     if( priv->i_stop <= 0 )
     {
-        priv->i_stop = llroundf(1000000.f
+        priv->i_stop = llroundf(CLOCK_FREQ
                                      * var_GetFloat( p_input, "run-time" ));
         if( priv->i_stop < 0 )
         {
diff --git a/src/input/vlmshell.c b/src/input/vlmshell.c
index 6c12b3ec2f..0e4337b01d 100644
--- a/src/input/vlmshell.c
+++ b/src/input/vlmshell.c
@@ -427,7 +427,7 @@ static int ExecuteControl( vlm_t *p_vlm, const char *psz_name, const int i_arg,
                 if( strstr( psz_argument, "ms" ) )
                     i_new_time =  1000 * (int64_t)atoi( psz_argument );
                 else
-                    i_new_time = 1000000 * (int64_t)atoi( psz_argument );
+                    i_new_time = CLOCK_FREQ * atoi( psz_argument );
 
                 if( b_relative )
                 {
diff --git a/src/os2/thread.c b/src/os2/thread.c
index 20f7ccd79c..a6fa99d7fd 100644
--- a/src/os2/thread.c
+++ b/src/os2/thread.c
@@ -881,7 +881,7 @@ mtime_t mdate (void)
     /* We need to split the division to avoid 63-bits overflow */
     lldiv_t d = lldiv (Q2LL(counter), freq);
 
-    return (d.quot * 1000000) + ((d.rem * 1000000) / freq);
+    return (d.quot * CLOCK_FREQ) + ((d.rem * CLOCK_FREQ) / freq);
 }
 
 #undef mwait
diff --git a/src/video_output/video_text.c b/src/video_output/video_text.c
index eb20c9a0b9..dc26936bc2 100644
--- a/src/video_output/video_text.c
+++ b/src/video_output/video_text.c
@@ -146,7 +146,7 @@ void vout_OSDMessage(vout_thread_t *vout, int channel, const char *format, ...)
     char *string;
     if (vasprintf(&string, format, args) != -1) {
         vout_OSDText(vout, channel,
-                     SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_RIGHT, 1000000,
+                     SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_RIGHT, CLOCK_FREQ,
                      string);
         free(string);
     }
diff --git a/src/win32/thread.c b/src/win32/thread.c
index fca34cbaec..9c731aa832 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -773,7 +773,7 @@ static mtime_t mdate_perf (void)
     /* We need to split the division to avoid 63-bits overflow */
     lldiv_t d = lldiv (counter.QuadPart, clk.perf.freq.QuadPart);
 
-    return (d.quot * 1000000) + ((d.rem * 1000000) / clk.perf.freq.QuadPart);
+    return (d.quot * CLOCK_FREQ) + ((d.rem * CLOCK_FREQ) / clk.perf.freq.QuadPart);
 }
 
 static mtime_t mdate_wall (void)
-- 
2.12.1



More information about the vlc-devel mailing list