From 0b4dff80ac381dd7de75125c70145a206a01eed8 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Mon, 2 Jul 2018 15:51:29 +0200
Subject: [PATCH] rename VLC_TS_INVALID to VLC_TICK_INVALID

(cherry picked from commit 1f17997348e5b5bb039647515c5ea54025bb81d5) (edited)
edited:
* some of the 3.0 code was different
---
 include/vlc_block.h                           |  2 +-
 include/vlc_common.h                          |  2 +
 include/vlc_timestamp_helper.h                |  2 +-
 modules/access/dshow/dshow.cpp                |  6 +--
 modules/access/dvdnav.c                       |  2 +-
 modules/access/imem.c                         | 10 ++--
 modules/access/live555.cpp                    | 44 ++++++++--------
 modules/access/live555_dtsgen.h               |  4 +-
 modules/access/rtp/input.c                    |  6 +--
 modules/access/rtp/rtp.c                      |  2 +-
 modules/access/timecode.c                     |  6 +--
 modules/access_output/livehttp.c              |  2 +-
 modules/audio_output/jack.c                   |  6 +--
 modules/audio_output/pulse.c                  | 18 +++----
 modules/audio_output/vlcpulse.c               |  8 +--
 modules/codec/adpcm.c                         |  4 +-
 modules/codec/aes3.c                          |  2 +-
 modules/codec/aom.c                           |  2 +-
 modules/codec/araw.c                          |  2 +-
 modules/codec/audiotoolbox_midi.c             |  4 +-
 modules/codec/avcodec/audio.c                 |  8 +--
 modules/codec/avcodec/encoder.c               |  6 +--
 modules/codec/avcodec/video.c                 | 30 +++++------
 modules/codec/bpg.c                           |  2 +-
 modules/codec/cc.c                            |  4 +-
 modules/codec/cdg.c                           |  2 +-
 modules/codec/crystalhd.c                     |  4 +-
 modules/codec/cvdsub.c                        |  2 +-
 modules/codec/daala.c                         |  4 +-
 modules/codec/dav1d.c                         |  2 +-
 modules/codec/dmo/dmo.c                       |  4 +-
 modules/codec/dvbsub.c                        |  6 +--
 modules/codec/faad.c                          |  4 +-
 modules/codec/flac.c                          |  6 +--
 modules/codec/fluidsynth.c                    |  4 +-
 modules/codec/g711.c                          |  4 +-
 modules/codec/gstreamer/gstdecode.c           |  6 +--
 modules/codec/jpeg.c                          |  2 +-
 modules/codec/kate.c                          |  8 +--
 modules/codec/libass.c                        |  4 +-
 modules/codec/lpcm.c                          |  2 +-
 modules/codec/mpg123.c                        | 18 +++----
 modules/codec/oggspots.c                      |  6 +--
 modules/codec/omxil/mediacodec.c              | 10 ++--
 modules/codec/omxil/omxil.c                   |  2 +-
 modules/codec/opus.c                          |  2 +-
 modules/codec/png.c                           |  2 +-
 modules/codec/rawvideo.c                      |  8 +--
 modules/codec/schroedinger.c                  |  8 +--
 modules/codec/scte18.c                        |  2 +-
 modules/codec/scte27.c                        |  4 +-
 modules/codec/sdl_image.c                     |  2 +-
 modules/codec/speex.c                         |  4 +-
 modules/codec/spudec/parse.c                  |  6 +--
 modules/codec/spudec/spudec.c                 |  2 +-
 modules/codec/subsdec.c                       |  2 +-
 modules/codec/substext.h                      |  4 +-
 modules/codec/subsusf.c                       |  2 +-
 modules/codec/svg.c                           |  2 +-
 modules/codec/synchro.c                       |  6 +--
 modules/codec/theora.c                        |  6 +--
 modules/codec/ttml/substtml.c                 |  2 +-
 modules/codec/uleaddvaudio.c                  |  4 +-
 modules/codec/videotoolbox.m                  |  8 +--
 modules/codec/vorbis.c                        |  2 +-
 modules/codec/webvtt/subsvtt.c                |  2 +-
 modules/codec/wmafixed/wma.c                  |  6 +--
 modules/codec/xwd.c                           |  2 +-
 modules/control/dbus/dbus.c                   |  2 +-
 modules/demux/adaptive/PlaylistManager.cpp    | 24 ++++-----
 modules/demux/adaptive/SegmentTracker.cpp     |  2 +-
 modules/demux/adaptive/SegmentTracker.hpp     |  2 +-
 modules/demux/adaptive/Streams.cpp            | 16 +++---
 modules/demux/adaptive/Time.hpp               | 18 +++----
 modules/demux/adaptive/playlist/Segment.cpp   |  2 +-
 .../demux/adaptive/plumbing/CommandsQueue.cpp | 26 +++++-----
 modules/demux/adaptive/plumbing/Demuxer.cpp   |  4 +-
 modules/demux/adaptive/plumbing/FakeESOut.cpp | 36 ++++++-------
 .../adaptive/test/plumbing/CommandsQueue.cpp  | 18 +++----
 .../adaptive/test/plumbing/FakeEsOut.cpp      | 16 +++---
 modules/demux/asf/asf.c                       | 16 +++---
 modules/demux/asf/asfpacket.c                 |  2 +-
 modules/demux/avformat/demux.c                | 18 +++----
 modules/demux/avi/avi.c                       |  2 +-
 modules/demux/caf.c                           |  2 +-
 modules/demux/flac.c                          | 10 ++--
 modules/demux/hls/playlist/Parser.cpp         |  6 +--
 modules/demux/image.c                         |  6 +--
 modules/demux/mkv/demux.hpp                   |  4 +-
 modules/demux/mkv/matroska_segment.cpp        |  6 +--
 modules/demux/mkv/mkv.cpp                     | 16 +++---
 modules/demux/mkv/util.cpp                    | 18 +++----
 modules/demux/mkv/virtual_segment.cpp         |  2 +-
 modules/demux/mp4/mp4.c                       | 22 ++++----
 modules/demux/mpeg/es.c                       | 12 ++---
 modules/demux/mpeg/h26x.c                     |  4 +-
 modules/demux/mpeg/mpgv.c                     |  2 +-
 modules/demux/mpeg/ps.c                       | 10 ++--
 modules/demux/mpeg/ts.c                       | 46 ++++++++---------
 modules/demux/mpeg/ts_psip.c                  |  4 +-
 modules/demux/mpeg/ts_streams.c               |  4 +-
 modules/demux/nuv.c                           |  2 +-
 modules/demux/ogg.c                           | 32 ++++++------
 modules/demux/oggseek.c                       |  8 +--
 modules/demux/pva.c                           |  2 +-
 modules/demux/rawdv.h                         |  2 +-
 modules/demux/real.c                          | 26 +++++-----
 modules/demux/ty.c                            | 18 +++----
 modules/demux/vobsub.c                        |  2 +-
 modules/demux/webvtt.c                        |  2 +-
 modules/hw/vaapi/filters.c                    | 10 ++--
 modules/hw/vdpau/deinterlace.c                |  4 +-
 modules/misc/stats.c                          |  2 +-
 modules/mux/asf.c                             |  6 +--
 modules/mux/mp4/mp4.c                         | 38 +++++++-------
 modules/mux/mpeg/pes.c                        |  4 +-
 modules/mux/mpeg/ts.c                         |  8 +--
 modules/packetizer/a52.c                      | 16 +++---
 modules/packetizer/av1.c                      | 18 +++----
 modules/packetizer/avparser.c                 |  2 +-
 modules/packetizer/copy.c                     |  8 +--
 modules/packetizer/dirac.c                    | 38 +++++++-------
 modules/packetizer/dts.c                      |  8 +--
 modules/packetizer/flac.c                     | 12 ++---
 modules/packetizer/h264.c                     | 44 ++++++++--------
 modules/packetizer/hevc.c                     | 16 +++---
 modules/packetizer/hxxx_common.c              |  4 +-
 modules/packetizer/mlp.c                      |  6 +--
 modules/packetizer/mpeg4audio.c               | 14 +++---
 modules/packetizer/mpeg4video.c               | 16 +++---
 modules/packetizer/mpegaudio.c                | 16 +++---
 modules/packetizer/mpegvideo.c                | 46 ++++++++---------
 modules/packetizer/packetizer_helper.h        |  4 +-
 modules/packetizer/vc1.c                      | 32 ++++++------
 modules/stream_out/autodel.c                  |  2 +-
 modules/stream_out/bridge.c                   |  6 +--
 .../stream_out/chromecast/chromecast_ctrl.cpp | 14 +++---
 .../chromecast/chromecast_demux.cpp           |  2 +-
 modules/stream_out/delay.c                    |  4 +-
 modules/stream_out/display.c                  |  4 +-
 modules/stream_out/rtp.c                      |  8 +--
 modules/stream_out/rtpfmt.c                   | 26 +++++-----
 modules/stream_out/stats.c                    |  6 +--
 modules/stream_out/transcode/audio.c          |  4 +-
 modules/video_filter/deinterlace/algo_ivtc.c  |  4 +-
 modules/video_filter/deinterlace/common.c     | 10 ++--
 modules/video_filter/fps.c                    |  4 +-
 modules/visualization/goom.c                  |  4 +-
 src/audio_output/dec.c                        | 10 ++--
 src/input/clock.c                             | 34 ++++++-------
 src/input/decoder.c                           | 46 ++++++++---------
 src/input/es_out.c                            | 22 ++++----
 src/misc/background_worker.c                  |  2 +-
 src/misc/block.c                              |  2 +-
 src/misc/picture.c                            |  2 +-
 src/network/tcp.c                             |  2 +-
 src/video_output/chrono.h                     |  6 +--
 src/video_output/control.c                    |  2 +-
 src/video_output/video_output.c               | 50 +++++++++----------
 159 files changed, 747 insertions(+), 745 deletions(-)

diff --git a/include/vlc_block.h b/include/vlc_block.h
index def8d4631c30..c422c5003100 100644
--- a/include/vlc_block.h
+++ b/include/vlc_block.h
@@ -49,7 +49,7 @@
  * - i_flags may not always be set (ie could be 0, even for a key frame
  *      it depends where you receive the buffer (before/after a packetizer
  *      and the demux/packetizer implementations.
- * - i_dts/i_pts could be VLC_TS_INVALID, it means no pts/dts
+ * - i_dts/i_pts could be VLC_TICK_INVALID, it means no pts/dts
  * - i_length: length in microseond of the packet, can be null except in the
  *      sout where it is mandatory.
  *
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 8056bb217813..fc335fd9a8a9 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -155,6 +155,8 @@
 typedef int64_t vlc_tick_t;
 typedef vlc_tick_t mtime_t; /* deprecated, use vlc_tick_t */
 
+#define VLC_TICK_INVALID  VLC_TS_INVALID
+
 /**
  * The vlc_fourcc_t type.
  *
diff --git a/include/vlc_timestamp_helper.h b/include/vlc_timestamp_helper.h
index 90840fbcf7a5..a13bee1e8448 100644
--- a/include/vlc_timestamp_helper.h
+++ b/include/vlc_timestamp_helper.h
@@ -90,7 +90,7 @@ static inline void timestamp_FifoPut(timestamp_fifo_t *fifo, int64_t ts)
 static inline int64_t timestamp_FifoGet(timestamp_fifo_t *fifo)
 {
     if (timestamp_FifoIsEmpty(fifo))
-        return VLC_TS_INVALID;
+        return VLC_TICK_INVALID;
 
     int64_t result = fifo->buffer[fifo->begin];
     fifo->begin = (fifo->begin + 1) % fifo->capacity;
diff --git a/modules/access/dshow/dshow.cpp b/modules/access/dshow/dshow.cpp
index f22571e18345..147b9e88c9e6 100644
--- a/modules/access/dshow/dshow.cpp
+++ b/modules/access/dshow/dshow.cpp
@@ -1883,10 +1883,10 @@ static int Demux( demux_t *p_demux )
                     p_stream->b_pts = true;
                 }
                 else
-                    i_pts = VLC_TS_INVALID;
+                    i_pts = VLC_TICK_INVALID;
             }
 
-            if( i_pts > VLC_TS_INVALID ) {
+            if( i_pts > VLC_TICK_INVALID ) {
                 i_pts += (i_pts >= 0) ? +5 : -4;
                 i_pts /= 10; /* 100-ns to µs conversion */
                 i_pts += VLC_TS_0;
@@ -1900,7 +1900,7 @@ static int Demux( demux_t *p_demux )
             memcpy( p_block->p_buffer, p_data, i_data_size );
             p_block->i_pts = p_block->i_dts = i_pts;
 
-            if( i_pts > VLC_TS_INVALID )
+            if( i_pts > VLC_TICK_INVALID )
                 es_out_SetPCR( p_demux->out, i_pts );
             es_out_Send( p_demux->out, p_stream->p_es, p_block );
 
diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index 518cd42d8467..a697dc6d9cde 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -1460,7 +1460,7 @@ static int DemuxBlock( demux_t *p_demux, const uint8_t *p, int len )
                     tk->i_next_block_flags = 0;
                     if( i_next_block_flags & BLOCK_FLAG_CELL_DISCONTINUITY )
                     {
-                        if( p_pkt->i_dts >= VLC_TS_INVALID )
+                        if( p_pkt->i_dts >= VLC_TICK_INVALID )
                         {
                             i_next_block_flags &= ~BLOCK_FLAG_CELL_DISCONTINUITY;
                             i_next_block_flags |= BLOCK_FLAG_DISCONTINUITY;
diff --git a/modules/access/imem.c b/modules/access/imem.c
index 1fe68e4ce764..082f664d3856 100644
--- a/modules/access/imem.c
+++ b/modules/access/imem.c
@@ -279,7 +279,7 @@ static int OpenCommon(vlc_object_t *object, imem_sys_t **sys_ptr, const char *ps
 
     /* */
     sys->dts       = 0;
-    sys->deadline  = VLC_TS_INVALID;
+    sys->deadline  = VLC_TICK_INVALID;
 
     *sys_ptr = sys;
     return VLC_SUCCESS;
@@ -571,7 +571,7 @@ static int Demux(demux_t *demux)
 {
     imem_sys_t *sys = (imem_sys_t*)demux->p_sys;
 
-    if (sys->deadline == VLC_TS_INVALID)
+    if (sys->deadline == VLC_TICK_INVALID)
         sys->deadline = sys->dts + 1;
 
     for (;;) {
@@ -594,8 +594,8 @@ static int Demux(demux_t *demux)
         if (buffer_size > 0) {
             block_t *block = block_Alloc(buffer_size);
             if (block) {
-                block->i_dts = dts >= 0 ? (1 + dts) : VLC_TS_INVALID;
-                block->i_pts = pts >= 0 ? (1 + pts) : VLC_TS_INVALID;
+                block->i_dts = dts >= 0 ? (1 + dts) : VLC_TICK_INVALID;
+                block->i_pts = pts >= 0 ? (1 + pts) : VLC_TICK_INVALID;
                 memcpy(block->p_buffer, buffer, buffer_size);
 
                 es_out_SetPCR(demux->out, block->i_dts);
@@ -608,7 +608,7 @@ static int Demux(demux_t *demux)
         sys->source.release(sys->source.data, sys->source.cookie,
                             buffer_size, buffer);
     }
-    sys->deadline = VLC_TS_INVALID;
+    sys->deadline = VLC_TICK_INVALID;
     return 1;
 }
 
diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index 3e66eede1a83..9037ae42a3a4 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -879,8 +879,8 @@ static int SessionsSetup( demux_t *p_demux )
             tk->b_rtcp_sync = false;
             tk->b_flushing_discontinuity = false;
             tk->i_next_block_flags = 0;
-            tk->i_prevpts   = VLC_TS_INVALID;
-            tk->i_pcr       = VLC_TS_INVALID;
+            tk->i_prevpts   = VLC_TICK_INVALID;
+            tk->i_pcr       = VLC_TICK_INVALID;
             tk->f_npt       = 0.;
             dtsgen_Init( &tk->dtsgen );
             tk->state       = live_track_t::STATE_SELECTED;
@@ -1265,7 +1265,7 @@ static int SessionsSetup( demux_t *p_demux )
     p_sys->b_no_data = true;
     p_sys->i_no_data_ti = 0;
     p_sys->b_rtcp_sync = false;
-    p_sys->i_pcr = VLC_TS_INVALID;
+    p_sys->i_pcr = VLC_TICK_INVALID;
 
     return i_return;
 }
@@ -1297,7 +1297,7 @@ static int Play( demux_t *p_demux )
         vlc_tick_t interval = (timeout - 2) * CLOCK_FREQ;
         vlc_timer_schedule( p_sys->timer, false, interval, interval);
     }
-    p_sys->i_pcr = VLC_TS_INVALID;
+    p_sys->i_pcr = VLC_TICK_INVALID;
 
     /* Retrieve the starttime if possible */
     p_sys->f_npt_start = p_sys->ms->playStartTime();
@@ -1446,7 +1446,7 @@ static int Demux( demux_t *p_demux )
 
     if( b_send_pcr )
     {
-        vlc_tick_t i_minpcr = VLC_TS_INVALID;
+        vlc_tick_t i_minpcr = VLC_TICK_INVALID;
         bool b_need_flush = false;
 
         /* Check for gap in pts value */
@@ -1461,11 +1461,11 @@ static int Demux( demux_t *p_demux )
             /* Check for gap in pts value */
             b_need_flush |= (tk->b_flushing_discontinuity);
 
-            if( i_minpcr == VLC_TS_INVALID || ( tk->i_pcr != VLC_TS_INVALID && i_minpcr > tk->i_pcr ) )
+            if( i_minpcr == VLC_TICK_INVALID || ( tk->i_pcr != VLC_TICK_INVALID && i_minpcr > tk->i_pcr ) )
                 i_minpcr = tk->i_pcr;
         }
 
-        if( p_sys->i_pcr > VLC_TS_INVALID && b_need_flush )
+        if( p_sys->i_pcr > VLC_TICK_INVALID && b_need_flush )
         {
             es_out_Control( p_demux->out, ES_OUT_RESET_PCR );
             p_sys->i_pcr = i_minpcr;
@@ -1474,21 +1474,21 @@ static int Demux( demux_t *p_demux )
             for( i = 0; i < p_sys->i_track; i++ )
             {
                 live_track_t *tk = p_sys->track[i];
-                tk->i_prevpts = VLC_TS_INVALID;
-                tk->i_pcr = VLC_TS_INVALID;
+                tk->i_prevpts = VLC_TICK_INVALID;
+                tk->i_pcr = VLC_TICK_INVALID;
                 tk->f_npt = 0.;
                 tk->b_flushing_discontinuity = false;
                 tk->i_next_block_flags |= BLOCK_FLAG_DISCONTINUITY;
             }
-            if( p_sys->i_pcr != VLC_TS_INVALID )
+            if( p_sys->i_pcr != VLC_TICK_INVALID )
                 es_out_SetPCR( p_demux->out, VLC_TS_0 +
                                __MAX(0, p_sys->i_pcr - PCR_OFF) );
         }
-        else if( p_sys->i_pcr == VLC_TS_INVALID ||
+        else if( p_sys->i_pcr == VLC_TICK_INVALID ||
                  i_minpcr > p_sys->i_pcr + PCR_OBS )
         {
             p_sys->i_pcr = __MAX(0, i_minpcr - PCR_OFF);
-            if( p_sys->i_pcr != VLC_TS_INVALID )
+            if( p_sys->i_pcr != VLC_TICK_INVALID )
                 es_out_SetPCR( p_demux->out, VLC_TS_0 + p_sys->i_pcr );
         }
     }
@@ -1617,13 +1617,13 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                         p_sys->env->getResultMsg() );
                     return VLC_EGENERIC;
                 }
-                p_sys->i_pcr = VLC_TS_INVALID;
+                p_sys->i_pcr = VLC_TICK_INVALID;
 
                 for( int i = 0; i < p_sys->i_track; i++ )
                 {
                     p_sys->track[i]->b_rtcp_sync = false;
-                    p_sys->track[i]->i_prevpts = VLC_TS_INVALID;
-                    p_sys->track[i]->i_pcr = VLC_TS_INVALID;
+                    p_sys->track[i]->i_prevpts = VLC_TICK_INVALID;
+                    p_sys->track[i]->i_pcr = VLC_TICK_INVALID;
                     dtsgen_Resync( &p_sys->track[i]->dtsgen );
                 }
 
@@ -1717,7 +1717,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
             /* ReSync the stream */
             p_sys->f_npt_start = 0;
-            p_sys->i_pcr = VLC_TS_INVALID;
+            p_sys->i_pcr = VLC_TICK_INVALID;
             p_sys->f_npt = 0.0;
 
             *pi_int = (int)( INPUT_RATE_DEFAULT / p_sys->ms->scale() );
@@ -1755,10 +1755,10 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                     tk->b_rtcp_sync = false;
                     tk->b_flushing_discontinuity = false;
                     tk->i_next_block_flags |= BLOCK_FLAG_DISCONTINUITY;
-                    tk->i_prevpts = VLC_TS_INVALID;
-                    tk->i_pcr = VLC_TS_INVALID;
+                    tk->i_prevpts = VLC_TICK_INVALID;
+                    tk->i_pcr = VLC_TICK_INVALID;
                 }
-                p_sys->i_pcr = VLC_TS_INVALID;
+                p_sys->i_pcr = VLC_TICK_INVALID;
                 es_out_Control( p_demux->out, ES_OUT_RESET_PCR );
             }
 
@@ -2123,7 +2123,7 @@ static void StreamRead( void *p_private, unsigned int i_size,
     {
         msg_Dbg( p_demux, "tk->rtpSource->hasBeenSynchronizedUsingRTCP()" );
         p_sys->b_rtcp_sync = tk->b_rtcp_sync = true;
-        if( tk->i_pcr != VLC_TS_INVALID )
+        if( tk->i_pcr != VLC_TICK_INVALID )
         {
             tk->i_next_block_flags |= BLOCK_FLAG_DISCONTINUITY;
             const int64_t i_max_diff = CLOCK_FREQ * (( tk->fmt.i_cat == SPU_ES ) ? 60 : 1);
@@ -2181,9 +2181,9 @@ static void StreamRead( void *p_private, unsigned int i_size,
                     tk->i_next_block_flags = 0;
                 }
 
-                vlc_tick_t i_pcr = p_block->i_dts > VLC_TS_INVALID ? p_block->i_dts : p_block->i_pts;
+                vlc_tick_t i_pcr = p_block->i_dts > VLC_TICK_INVALID ? p_block->i_dts : p_block->i_pts;
                 es_out_Send( p_demux->out, tk->p_es, p_block );
-                if( i_pcr > VLC_TS_INVALID )
+                if( i_pcr > VLC_TICK_INVALID )
                 {
                     if( tk->i_pcr < i_pcr )
                         tk->i_pcr = i_pcr;
diff --git a/modules/access/live555_dtsgen.h b/modules/access/live555_dtsgen.h
index e7956e0056de..1df71fa33434 100644
--- a/modules/access/live555_dtsgen.h
+++ b/modules/access/live555_dtsgen.h
@@ -138,7 +138,7 @@ static void dtsgen_AddNextPTS(struct dtsgen_t *d, vlc_tick_t i_pts)
 
 static vlc_tick_t dtsgen_GetDTS(struct dtsgen_t *d)
 {
-    vlc_tick_t i_dts = VLC_TS_INVALID;
+    vlc_tick_t i_dts = VLC_TICK_INVALID;
 
     /* When we have inspected enough packets,
      * use the reorderdepth th packet as dts offset */
@@ -170,7 +170,7 @@ static vlc_tick_t dtsgen_GetDTS(struct dtsgen_t *d)
 static void dtsgen_Debug(vlc_object_t *p_demux, struct dtsgen_t *d,
                          vlc_tick_t dts, vlc_tick_t pts)
 {
-    if(pts == VLC_TS_INVALID)
+    if(pts == VLC_TICK_INVALID)
         return;
     msg_Dbg(p_demux, "dtsgen %" PRId64 " / pts %" PRId64 " diff %" PRId64 ", "
                      "pkt count %u, reorder %u",
diff --git a/modules/access/rtp/input.c b/modules/access/rtp/input.c
index 0cc360fd70ef..5596695f45fb 100644
--- a/modules/access/rtp/input.c
+++ b/modules/access/rtp/input.c
@@ -87,7 +87,7 @@ drop:
 
 static int rtp_timeout (vlc_tick_t deadline)
 {
-    if (deadline == VLC_TS_INVALID)
+    if (deadline == VLC_TICK_INVALID)
         return -1; /* infinite */
 
     vlc_tick_t t = mdate ();
@@ -107,7 +107,7 @@ void *rtp_dgram_thread (void *opaque)
 {
     demux_t *demux = opaque;
     demux_sys_t *sys = demux->p_sys;
-    vlc_tick_t deadline = VLC_TS_INVALID;
+    vlc_tick_t deadline = VLC_TICK_INVALID;
     int rtp_fd = sys->fd;
 #ifdef __linux__
     const int trunc_flag = MSG_TRUNC;
@@ -182,7 +182,7 @@ void *rtp_dgram_thread (void *opaque)
 
     dequeue:
         if (!rtp_dequeue (demux, sys->session, &deadline))
-            deadline = VLC_TS_INVALID;
+            deadline = VLC_TICK_INVALID;
         vlc_restorecancel (canc);
     }
     return NULL;
diff --git a/modules/access/rtp/rtp.c b/modules/access/rtp/rtp.c
index 8637476c15b0..2b4497740008 100644
--- a/modules/access/rtp/rtp.c
+++ b/modules/access/rtp/rtp.c
@@ -445,7 +445,7 @@ void codec_decode (demux_t *demux, void *data, block_t *block)
 {
     if (data)
     {
-        block->i_dts = VLC_TS_INVALID; /* RTP does not specify this */
+        block->i_dts = VLC_TICK_INVALID; /* RTP does not specify this */
         es_out_SetPCR(demux->out, block->i_pts);
         es_out_Send (demux->out, (es_out_id_t *)data, block);
     }
diff --git a/modules/access/timecode.c b/modules/access/timecode.c
index 96d37553a7ae..44a37ff74ece 100644
--- a/modules/access/timecode.c
+++ b/modules/access/timecode.c
@@ -97,7 +97,7 @@ static int Demux (demux_t *demux)
 {
     demux_sys_t *sys = demux->p_sys;
 
-    if (sys->next_time == VLC_TS_INVALID) /* Master mode */
+    if (sys->next_time == VLC_TICK_INVALID) /* Master mode */
         return DemuxOnce (demux, true);
 
     /* Slave mode */
@@ -136,7 +136,7 @@ static int Control (demux_t *demux, int query, va_list args)
         {
             const vlc_tick_t pts = va_arg (args, int64_t );
 
-            if (sys->next_time == VLC_TS_INVALID) /* first invocation? */
+            if (sys->next_time == VLC_TICK_INVALID) /* first invocation? */
             {
                 date_Set (&sys->date, pts);
                 date_Decrement (&sys->date, 1);
@@ -186,7 +186,7 @@ static int Open (vlc_object_t *obj)
 
     date_Init (&sys->date, num, den);
     date_Set (&sys->date, VLC_TS_0);
-    sys->next_time = VLC_TS_INVALID;
+    sys->next_time = VLC_TICK_INVALID;
 
     demux->p_sys = sys;
     demux->pf_demux   = Demux;
diff --git a/modules/access_output/livehttp.c b/modules/access_output/livehttp.c
index 17e9fbe1f0f7..ce8cb80219a8 100644
--- a/modules/access_output/livehttp.c
+++ b/modules/access_output/livehttp.c
@@ -254,7 +254,7 @@ static int Open( vlc_object_t *p_this )
     vlc_array_init( &p_sys->segments_t );
 
     p_sys->stuffing_size = 0;
-    p_sys->i_opendts = VLC_TS_INVALID;
+    p_sys->i_opendts = VLC_TICK_INVALID;
     p_sys->i_dts_offset  = 0;
 
     p_sys->psz_indexPath = NULL;
diff --git a/modules/audio_output/jack.c b/modules/audio_output/jack.c
index 2a02da4ea67b..da134dc6f4c5 100644
--- a/modules/audio_output/jack.c
+++ b/modules/audio_output/jack.c
@@ -125,7 +125,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
         return VLC_EGENERIC;
 
     p_sys->latency = 0;
-    p_sys->paused = VLC_TS_INVALID;
+    p_sys->paused = VLC_TICK_INVALID;
 
     /* Connect to the JACK server */
     psz_name = var_InheritString( p_aout, "jack-name" );
@@ -324,7 +324,7 @@ static void Pause(audio_output_t *aout, bool paused, vlc_tick_t date)
     } else {
         date -= sys->paused;
         msg_Dbg(aout, "resuming after %"PRId64" us", date);
-        sys->paused = VLC_TS_INVALID;
+        sys->paused = VLC_TICK_INVALID;
     }
 }
 
@@ -371,7 +371,7 @@ int Process( jack_nframes_t i_frames, void *p_arg )
 
     /* Get the next audio data buffer unless paused */
 
-    if( p_sys->paused == VLC_TS_INVALID )
+    if( p_sys->paused == VLC_TICK_INVALID )
         frames_from_rb = i_frames;
 
     /* Get the JACK buffers to write to */
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 99bff47cbc08..4af14b0bb0bc 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -226,7 +226,7 @@ static void stream_start(pa_stream *s, audio_output_t *aout)
     aout_sys_t *sys = aout->sys;
     vlc_tick_t delta;
 
-    assert (sys->first_pts != VLC_TS_INVALID);
+    assert (sys->first_pts != VLC_TICK_INVALID);
 
     if (sys->trigger != NULL) {
         vlc_pa_rttime_free(sys->mainloop, sys->trigger);
@@ -234,7 +234,7 @@ static void stream_start(pa_stream *s, audio_output_t *aout)
     }
 
     delta = vlc_pa_get_latency(aout, sys->context, s);
-    if (unlikely(delta == VLC_TS_INVALID)) {
+    if (unlikely(delta == VLC_TICK_INVALID)) {
         msg_Dbg(aout, "cannot synchronize start");
         delta = 0; /* screwed */
     }
@@ -257,7 +257,7 @@ static void stream_latency_cb(pa_stream *s, void *userdata)
     aout_sys_t *sys = aout->sys;
 
     /* This callback is _never_ called while paused. */
-    if (sys->first_pts == VLC_TS_INVALID)
+    if (sys->first_pts == VLC_TICK_INVALID)
         return; /* nothing to do if buffers are (still) empty */
     if (pa_stream_is_corked(s) > 0)
         stream_start(s, aout);
@@ -330,7 +330,7 @@ static void stream_overflow_cb(pa_stream *s, void *userdata)
     if (unlikely(op == NULL))
         return;
     pa_operation_unref(op);
-    sys->first_pts = VLC_TS_INVALID;
+    sys->first_pts = VLC_TICK_INVALID;
 }
 
 static void stream_started_cb(pa_stream *s, void *userdata)
@@ -448,7 +448,7 @@ static int TimeGet(audio_output_t *aout, vlc_tick_t *restrict delay)
     if (pa_stream_is_corked(s) <= 0)
     {   /* latency is relevant only if not corked */
         vlc_tick_t delta = vlc_pa_get_latency(aout, sys->context, s);
-        if (delta != VLC_TS_INVALID)
+        if (delta != VLC_TICK_INVALID)
         {
             *delay = delta;
             ret = 0;
@@ -503,7 +503,7 @@ static void Play(audio_output_t *aout, block_t *block)
      * will take place, and sooner or later a deadlock. */
     pa_threaded_mainloop_lock(sys->mainloop);
 
-    if (sys->first_pts == VLC_TS_INVALID)
+    if (sys->first_pts == VLC_TICK_INVALID)
         sys->first_pts = block->i_pts;
 
     if (pa_stream_is_corked(s) > 0)
@@ -540,7 +540,7 @@ static void Pause(audio_output_t *aout, bool paused, vlc_tick_t date)
         stream_stop(s, aout);
     } else {
         pa_stream_set_latency_update_callback(s, stream_latency_cb, aout);
-        if (likely(sys->first_pts != VLC_TS_INVALID))
+        if (likely(sys->first_pts != VLC_TICK_INVALID))
             stream_start_now(s, aout);
     }
 
@@ -587,7 +587,7 @@ static void Flush(audio_output_t *aout, bool wait)
         op = pa_stream_flush(s, NULL, NULL);
     if (op != NULL)
         pa_operation_unref(op);
-    sys->first_pts = VLC_TS_INVALID;
+    sys->first_pts = VLC_TICK_INVALID;
     stream_stop(s, aout);
 
     pa_threaded_mainloop_unlock(sys->mainloop);
@@ -818,7 +818,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
 
     sys->trigger = NULL;
     pa_cvolume_init(&sys->cvolume);
-    sys->first_pts = VLC_TS_INVALID;
+    sys->first_pts = VLC_TICK_INVALID;
 
     pa_format_info *formatv = pa_format_info_new();
     formatv->encoding = encoding;
diff --git a/modules/audio_output/vlcpulse.c b/modules/audio_output/vlcpulse.c
index 2cdb414bf6bc..4cdbc2293e67 100644
--- a/modules/audio_output/vlcpulse.c
+++ b/modules/audio_output/vlcpulse.c
@@ -250,7 +250,7 @@ void vlc_pa_rttime_free (pa_threaded_mainloop *mainloop, pa_time_event *e)
 #undef vlc_pa_get_latency
 /**
  * Gets latency of a PulseAudio stream.
- * \return the latency or VLC_TS_INVALID on error.
+ * \return the latency or VLC_TICK_INVALID on error.
  */
 vlc_tick_t vlc_pa_get_latency(vlc_object_t *obj, pa_context *ctx, pa_stream *s)
 {
@@ -268,12 +268,12 @@ vlc_tick_t vlc_pa_get_latency(vlc_object_t *obj, pa_context *ctx, pa_stream *s)
 
     if (ti == NULL) {
         msg_Dbg(obj, "no timing infos");
-        return VLC_TS_INVALID;
+        return VLC_TICK_INVALID;
     }
 
     if (ti->write_index_corrupt) {
         msg_Dbg(obj, "write index corrupt");
-        return VLC_TS_INVALID;
+        return VLC_TICK_INVALID;
     }
 
     pa_usec_t wt = pa_bytes_to_usec((uint64_t)ti->write_index, ss);
@@ -282,7 +282,7 @@ vlc_tick_t vlc_pa_get_latency(vlc_object_t *obj, pa_context *ctx, pa_stream *s)
     if (pa_stream_get_time(s, &rt)) {
         if (pa_context_errno(ctx) != PA_ERR_NODATA)
             vlc_pa_error(obj, "unknown time", ctx);
-        return VLC_TS_INVALID;
+        return VLC_TICK_INVALID;
     }
 
     union { uint64_t u; int64_t s; } d;
diff --git a/modules/codec/adpcm.c b/modules/codec/adpcm.c
index 26278d2d8d70..2d2cfb63c848 100644
--- a/modules/codec/adpcm.c
+++ b/modules/codec/adpcm.c
@@ -318,7 +318,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             goto drop;
     }
 
-    if( p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
@@ -328,7 +328,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         goto drop;
 
     /* Don't re-use the same pts twice */
-    p_block->i_pts = VLC_TS_INVALID;
+    p_block->i_pts = VLC_TICK_INVALID;
 
     if( p_block->i_buffer >= p_sys->i_block )
     {
diff --git a/modules/codec/aes3.c b/modules/codec/aes3.c
index cf27aed84566..cd6548be541b 100644
--- a/modules/codec/aes3.c
+++ b/modules/codec/aes3.c
@@ -340,7 +340,7 @@ static block_t * Parse( decoder_t *p_dec, int *pi_frame_length, int *pi_bits,
     }
 
     /* Date management */
-    if( p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
diff --git a/modules/codec/aom.c b/modules/codec/aom.c
index bb37766d6c16..0c4d34426af5 100644
--- a/modules/codec/aom.c
+++ b/modules/codec/aom.c
@@ -150,7 +150,7 @@ static int PushFrame(decoder_t *dec, block_t *block)
     {
         p_buffer = block->p_buffer;
         i_buffer = block->i_buffer;
-        p_sys->frame_priv[priv_index].pts = (block->i_pts != VLC_TS_INVALID) ? block->i_pts : block->i_dts;
+        p_sys->frame_priv[priv_index].pts = (block->i_pts != VLC_TICK_INVALID) ? block->i_pts : block->i_dts;
     }
     else
     {
diff --git a/modules/codec/araw.c b/modules/codec/araw.c
index 8c56acf5a853..5d43b6f4aaad 100644
--- a/modules/codec/araw.c
+++ b/modules/codec/araw.c
@@ -336,7 +336,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
             goto skip;
     }
 
-    if( p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
diff --git a/modules/codec/audiotoolbox_midi.c b/modules/codec/audiotoolbox_midi.c
index 8adf545980e4..282595398cb5 100644
--- a/modules/codec/audiotoolbox_midi.c
+++ b/modules/codec/audiotoolbox_midi.c
@@ -310,7 +310,7 @@ static void Flush (decoder_t *p_dec)
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    date_Set(&p_sys->end_date, VLC_TS_INVALID);
+    date_Set(&p_sys->end_date, VLC_TICK_INVALID);
 
     // Turn all sound on all channels off
     // else 'old' notes could still be playing
@@ -336,7 +336,7 @@ static int DecodeBlock (decoder_t *p_dec, block_t *p_block)
         }
     }
 
-    if (p_block->i_pts > VLC_TS_INVALID && !date_Get(&p_sys->end_date)) {
+    if (p_block->i_pts > VLC_TICK_INVALID && !date_Get(&p_sys->end_date)) {
         date_Set(&p_sys->end_date, p_block->i_pts);
     } else if (p_block->i_pts < date_Get(&p_sys->end_date)) {
         msg_Warn(p_dec, "MIDI message in the past?");
diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 8c3fa7a2179e..50a76c7a18e1 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -251,7 +251,7 @@ int InitAudioDec( vlc_object_t *obj )
     /* Try to set as much information as possible but do not trust it */
     SetupOutputFormat( p_dec, false );
 
-    date_Set( &p_sys->end_date, VLC_TS_INVALID );
+    date_Set( &p_sys->end_date, VLC_TICK_INVALID );
     if( !p_dec->fmt_out.audio.i_rate )
         p_dec->fmt_out.audio.i_rate = p_dec->fmt_in.audio.i_rate;
     if( p_dec->fmt_out.audio.i_rate )
@@ -280,7 +280,7 @@ static void Flush( decoder_t *p_dec )
 
     if( avcodec_is_open( ctx ) )
         avcodec_flush_buffers( ctx );
-    date_Set( &p_sys->end_date, VLC_TS_INVALID );
+    date_Set( &p_sys->end_date, VLC_TICK_INVALID );
 
     if( ctx->codec_id == AV_CODEC_ID_MP2 ||
         ctx->codec_id == AV_CODEC_ID_MP3 )
@@ -332,11 +332,11 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
         if( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY )
         {
-            date_Set( &p_sys->end_date, VLC_TS_INVALID );
+            date_Set( &p_sys->end_date, VLC_TICK_INVALID );
         }
 
         /* We've just started the stream, wait for the first PTS. */
-        if( !date_Get( &p_sys->end_date ) && p_block->i_pts <= VLC_TS_INVALID )
+        if( !date_Get( &p_sys->end_date ) && p_block->i_pts <= VLC_TICK_INVALID )
             goto drop;
 
         if( p_block->i_buffer <= 0 )
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index ddceb227e1e4..d73e10702a44 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -1231,7 +1231,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
         /* Set the pts of the frame being encoded
          * avcodec likes pts to be in time_base units
          * frame number */
-        if( likely( p_pict->date > VLC_TS_INVALID ) )
+        if( likely( p_pict->date > VLC_TICK_INVALID ) )
             frame->pts = p_pict->date * p_sys->p_context->time_base.den /
                           CLOCK_FREQ / p_sys->p_context->time_base.num;
         else
@@ -1240,7 +1240,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
         if ( p_sys->b_hurry_up && frame->pts != AV_NOPTS_VALUE )
             check_hurry_up( p_sys, frame, p_enc );
 
-        if ( ( frame->pts != AV_NOPTS_VALUE ) && ( frame->pts != VLC_TS_INVALID ) )
+        if ( ( frame->pts != AV_NOPTS_VALUE ) && ( frame->pts != VLC_TICK_INVALID ) )
         {
             if ( p_sys->i_last_pts == frame->pts )
             {
@@ -1349,7 +1349,7 @@ static block_t *EncodeAudio( encoder_t *p_enc, block_t *p_aout_buf )
     //Calculate how many bytes we would need from current buffer to fill frame
     size_t leftover_samples = __MAX(0,__MIN((ssize_t)i_samples_left, (ssize_t)(p_sys->i_frame_size - p_sys->i_samples_delay)));
 
-    if( p_aout_buf && ( p_aout_buf->i_pts > VLC_TS_INVALID ) )
+    if( p_aout_buf && ( p_aout_buf->i_pts > VLC_TICK_INVALID ) )
     {
         date_Set( &p_sys->buffer_date, p_aout_buf->i_pts );
         /* take back amount we have leftover from previous buffer*/
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index bfd35ef19fe5..60c7b2195e0f 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -602,7 +602,7 @@ int InitVideoDec( vlc_object_t *obj )
 
     /* ***** misc init ***** */
     date_Init(&p_sys->pts, 1, 30001);
-    date_Set(&p_sys->pts, VLC_TS_INVALID);
+    date_Set(&p_sys->pts, VLC_TICK_INVALID);
     p_sys->b_first_frame = true;
     p_sys->i_late_frames = 0;
     p_sys->b_from_preroll = false;
@@ -657,7 +657,7 @@ static void Flush( decoder_t *p_dec )
     decoder_sys_t *p_sys = p_dec->p_sys;
     AVCodecContext *p_context = p_sys->p_context;
 
-    date_Set(&p_sys->pts, VLC_TS_INVALID); /* To make sure we recover properly */
+    date_Set(&p_sys->pts, VLC_TICK_INVALID); /* To make sure we recover properly */
     p_sys->i_late_frames = 0;
     p_sys->b_draining = false;
     cc_Flush( &p_sys->cc );
@@ -684,7 +684,7 @@ static bool check_block_validity( decoder_sys_t *p_sys, block_t *block )
 
     if( block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
-        date_Set( &p_sys->pts, VLC_TS_INVALID ); /* To make sure we recover properly */
+        date_Set( &p_sys->pts, VLC_TICK_INVALID ); /* To make sure we recover properly */
         cc_Flush( &p_sys->cc );
 
         p_sys->i_late_frames = 0;
@@ -716,7 +716,7 @@ static bool check_block_being_late( decoder_sys_t *p_sys, block_t *block, vlc_ti
 
     if( current_time - p_sys->i_late_frames_start > (5*CLOCK_FREQ))
     {
-        date_Set( &p_sys->pts, VLC_TS_INVALID ); /* To make sure we recover properly */
+        date_Set( &p_sys->pts, VLC_TICK_INVALID ); /* To make sure we recover properly */
         block_Release( block );
         p_sys->i_late_frames--;
         return true;
@@ -751,9 +751,9 @@ static vlc_tick_t interpolate_next_pts( decoder_t *p_dec, AVFrame *frame )
     decoder_sys_t *p_sys = p_dec->p_sys;
     AVCodecContext *p_context = p_sys->p_context;
 
-    if( date_Get( &p_sys->pts ) == VLC_TS_INVALID ||
+    if( date_Get( &p_sys->pts ) == VLC_TICK_INVALID ||
         p_sys->pts.i_divider_num == 0 )
-        return VLC_TS_INVALID;
+        return VLC_TICK_INVALID;
 
     int i_tick = p_context->ticks_per_frame;
     if( i_tick <= 0 )
@@ -769,13 +769,13 @@ static void update_late_frame_count( decoder_t *p_dec, block_t *p_block,
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
    /* Update frame late count (except when doing preroll) */
-   vlc_tick_t i_display_date = VLC_TS_INVALID;
+   vlc_tick_t i_display_date = VLC_TICK_INVALID;
    if( !p_block || !(p_block->i_flags & BLOCK_FLAG_PREROLL) )
        i_display_date = decoder_GetDisplayDate( p_dec, i_pts );
 
-   vlc_tick_t i_threshold = i_next_pts != VLC_TS_INVALID ? (i_next_pts - i_pts) / 2 : 20000;
+   vlc_tick_t i_threshold = i_next_pts != VLC_TICK_INVALID ? (i_next_pts - i_pts) / 2 : 20000;
 
-   if( i_display_date > VLC_TS_INVALID && i_display_date + i_threshold <= current_time )
+   if( i_display_date > VLC_TICK_INVALID && i_display_date + i_threshold <= current_time )
    {
        /* Out of preroll, consider only late frames on rising delay */
        if( p_sys->b_from_preroll )
@@ -1027,12 +1027,12 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
             {
                 pkt->data = p_block->p_buffer;
                 pkt->size = p_block->i_buffer;
-                pkt->pts = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : AV_NOPTS_VALUE;
-                pkt->dts = p_block->i_dts > VLC_TS_INVALID ? p_block->i_dts : AV_NOPTS_VALUE;
+                pkt->pts = p_block->i_pts > VLC_TICK_INVALID ? p_block->i_pts : AV_NOPTS_VALUE;
+                pkt->dts = p_block->i_dts > VLC_TICK_INVALID ? p_block->i_dts : AV_NOPTS_VALUE;
 
                 /* Make sure we don't reuse the same timestamps twice */
                 p_block->i_pts =
-                p_block->i_dts = VLC_TS_INVALID;
+                p_block->i_dts = VLC_TICK_INVALID;
             }
             else /* start drain */
             {
@@ -1132,7 +1132,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
             i_pts = date_Get( &p_sys->pts );
 
         /* Interpolate the next PTS */
-        if( i_pts > VLC_TS_INVALID )
+        if( i_pts > VLC_TICK_INVALID )
             date_Set( &p_sys->pts, i_pts );
 
         const vlc_tick_t i_next_pts = interpolate_next_pts(p_dec, frame);
@@ -1240,12 +1240,12 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
         p_pic->b_top_field_first = frame->top_field_first;
 
         if (DecodeSidedata(p_dec, frame, p_pic))
-            i_pts = VLC_TS_INVALID;
+            i_pts = VLC_TICK_INVALID;
 
         av_frame_free(&frame);
 
         /* Send decoded frame to vout */
-        if (i_pts > VLC_TS_INVALID)
+        if (i_pts > VLC_TICK_INVALID)
         {
             p_sys->b_first_frame = false;
             return p_pic;
diff --git a/modules/codec/bpg.c b/modules/codec/bpg.c
index 28b0167a18f1..8c1e34bee377 100644
--- a/modules/codec/bpg.c
+++ b/modules/codec/bpg.c
@@ -149,7 +149,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         }
     }
 
-    p_pic->date = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : p_block->i_dts;
+    p_pic->date = p_block->i_pts > VLC_TICK_INVALID ? p_block->i_pts : p_block->i_dts;
 
     decoder_QueueVideo( p_dec, p_pic );
 error:
diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index 066367df5f66..050b9f7f9cf2 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -440,7 +440,7 @@ static void Push( decoder_t *p_dec, block_t *p_block )
     /* find insertion point */
     for( pp_block = &p_sys->p_queue; *pp_block ; pp_block = &((*pp_block)->p_next) )
     {
-        if( p_block->i_pts == VLC_TS_INVALID || (*pp_block)->i_pts == VLC_TS_INVALID )
+        if( p_block->i_pts == VLC_TICK_INVALID || (*pp_block)->i_pts == VLC_TICK_INVALID )
             continue;
         if( p_block->i_pts < (*pp_block)->i_pts )
         {
@@ -488,7 +488,7 @@ static subpicture_t *Subtitle( decoder_t *p_dec, eia608_t *h, vlc_tick_t i_pts )
     subpicture_t *p_spu = NULL;
 
     /* We cannot display a subpicture with no date */
-    if( i_pts <= VLC_TS_INVALID )
+    if( i_pts <= VLC_TICK_INVALID )
         return NULL;
 
     /* Create the subpicture unit */
diff --git a/modules/codec/cdg.c b/modules/codec/cdg.c
index 084fc3b61b22..4ede0c97ade1 100644
--- a/modules/codec/cdg.c
+++ b/modules/codec/cdg.c
@@ -177,7 +177,7 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
             goto exit;
 
         Render( p_sys, p_pic );
-        p_pic->date = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : p_block->i_dts;
+        p_pic->date = p_block->i_pts > VLC_TICK_INVALID ? p_block->i_pts : p_block->i_dts;
     }
 
 exit:
diff --git a/modules/codec/crystalhd.c b/modules/codec/crystalhd.c
index 16a17c0d1854..119f465efbbc 100644
--- a/modules/codec/crystalhd.c
+++ b/modules/codec/crystalhd.c
@@ -457,7 +457,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
             BC_STATUS status = BC_FUNC_PSYS(DtsProcInput)( p_sys->bcm_handle,
                                             p_block->p_buffer,
                                             p_block->i_buffer,
-                                            p_block->i_pts >= VLC_TS_INVALID ? TO_BC_PTS(p_block->i_pts) : 0, false );
+                                            p_block->i_pts >= VLC_TICK_INVALID ? TO_BC_PTS(p_block->i_pts) : 0, false );
 
             block_Release( p_block );
 
@@ -514,7 +514,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
 
             //  crystal_CopyPicture( p_pic, &proc_out );
             p_pic->date = proc_out.PicInfo.timeStamp > 0 ?
-                          FROM_BC_PTS(proc_out.PicInfo.timeStamp) : VLC_TS_INVALID;
+                          FROM_BC_PTS(proc_out.PicInfo.timeStamp) : VLC_TICK_INVALID;
             //p_pic->date += 100 * 1000;
 #ifdef DEBUG_CRYSTALHD
             msg_Dbg( p_dec, "TS Output is %"PRIu64, p_pic->date);
diff --git a/modules/codec/cvdsub.c b/modules/codec/cvdsub.c
index 9ab100fb47d5..dd6db458ad55 100644
--- a/modules/codec/cvdsub.c
+++ b/modules/codec/cvdsub.c
@@ -236,7 +236,7 @@ static block_t *Reassemble( decoder_t *p_dec, block_t *p_block )
      * to detect the first packet in a subtitle.  The first packet
      * seems to have a valid PTS while later packets for the same
      * image don't. */
-    if( p_sys->i_state == SUBTITLE_BLOCK_EMPTY && p_block->i_pts <= VLC_TS_INVALID )
+    if( p_sys->i_state == SUBTITLE_BLOCK_EMPTY && p_block->i_pts <= VLC_TICK_INVALID )
     {
         msg_Warn( p_dec, "first packet expected but no PTS present");
         return NULL;
diff --git a/modules/codec/daala.c b/modules/codec/daala.c
index abb5397c9586..83aa3c211f43 100644
--- a/modules/codec/daala.c
+++ b/modules/codec/daala.c
@@ -177,7 +177,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     p_dec->p_sys = p_sys;
     p_dec->p_sys->b_packetizer = false;
     p_sys->b_has_headers = false;
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
     p_sys->b_decoded_first_keyframe = false;
     p_sys->dcx = NULL;
 
@@ -433,7 +433,7 @@ static void *ProcessPacket( decoder_t *p_dec, daala_packet *p_dpacket,
     }
 
     /* Date management */
-    if( p_block->i_pts > VLC_TS_INVALID && p_block->i_pts != p_sys->i_pts )
+    if( p_block->i_pts > VLC_TICK_INVALID && p_block->i_pts != p_sys->i_pts )
     {
         p_sys->i_pts = p_block->i_pts;
     }
diff --git a/modules/codec/dav1d.c b/modules/codec/dav1d.c
index 32ea67e91d97..36dc35b7bff1 100644
--- a/modules/codec/dav1d.c
+++ b/modules/codec/dav1d.c
@@ -215,7 +215,7 @@ static int Decode(decoder_t *dec, block_t *block)
             block_Release(block);
             return VLCDEC_ECRITICAL;
         }
-        vlc_tick_t pts = block->i_pts == VLC_TS_INVALID ? block->i_dts : block->i_pts;
+        vlc_tick_t pts = block->i_pts == VLC_TICK_INVALID ? block->i_dts : block->i_pts;
         p_data->m.timestamp = pts;
         b_eos = (block->i_flags & BLOCK_FLAG_END_OF_SEQUENCE);
     }
diff --git a/modules/codec/dmo/dmo.c b/modules/codec/dmo/dmo.c
index adf54ac72b39..49a6476dd9d4 100644
--- a/modules/codec/dmo/dmo.c
+++ b/modules/codec/dmo/dmo.c
@@ -838,11 +838,11 @@ static int DecBlock( decoder_t *p_dec, block_t **pp_block )
     p_block = *pp_block;
 
     /* Won't work with streams with B-frames, but do we have any ? */
-    if( p_block && p_block->i_pts <= VLC_TS_INVALID )
+    if( p_block && p_block->i_pts <= VLC_TICK_INVALID )
         p_block->i_pts = p_block->i_dts;
 
     /* Date management */
-    if( p_block && p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block && p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c
index 1d61dbd52d26..beb8e26d5a62 100644
--- a/modules/codec/dvbsub.c
+++ b/modules/codec/dvbsub.c
@@ -340,7 +340,7 @@ static int Open( vlc_object_t *p_this )
     if( !p_sys )
         return VLC_ENOMEM;
 
-    p_sys->i_pts          = VLC_TS_INVALID;
+    p_sys->i_pts          = VLC_TICK_INVALID;
     p_sys->i_id           = p_dec->fmt_in.subs.dvb.i_id & 0xFFFF;
     p_sys->i_ancillary_id = p_dec->fmt_in.subs.dvb.i_id >> 16;
 
@@ -397,7 +397,7 @@ static void Flush( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
 }
 
 /*****************************************************************************
@@ -426,7 +426,7 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
         default_dds_init( p_dec );
 
     p_sys->i_pts = p_block->i_pts;
-    if( p_sys->i_pts <= VLC_TS_INVALID )
+    if( p_sys->i_pts <= VLC_TICK_INVALID )
     {
 #ifdef DEBUG_DVBSUB
         /* Some DVB channels send stuffing segments in non-dated packets so
diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 5c3762a8452c..03bd43e5edba 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -229,7 +229,7 @@ static void Flush( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    date_Set( &p_sys->date, VLC_TS_INVALID );
+    date_Set( &p_sys->date, VLC_TICK_INVALID );
     FlushBuffer( p_sys, SIZE_MAX );
 }
 
@@ -329,7 +329,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         date_Init( &p_sys->date, i_rate, 1 );
     }
 
-    if( i_pts > VLC_TS_INVALID && i_pts != date_Get( &p_sys->date ) )
+    if( i_pts > VLC_TICK_INVALID && i_pts != date_Get( &p_sys->date ) )
     {
         if( p_sys->i_last_length == 0 ||
             /* We need to be permissive and rebase dts when it's really way off */
diff --git a/modules/codec/flac.c b/modules/codec/flac.c
index 22c63322ac0c..fbffc2c40b94 100644
--- a/modules/codec/flac.c
+++ b/modules/codec/flac.c
@@ -247,7 +247,7 @@ DecoderWriteCallback( const FLAC__StreamDecoder *decoder,
     if( decoder_UpdateAudioFormat( p_dec ) )
         return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
 
-    if( date_Get( &p_sys->end_date ) <= VLC_TS_INVALID )
+    if( date_Get( &p_sys->end_date ) <= VLC_TICK_INVALID )
         return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
 
     p_sys->p_aout_buffer =
@@ -326,7 +326,7 @@ static void DecoderMetadataCallback( const FLAC__StreamDecoder *decoder,
             p_sys->stream_info = metadata->data.stream_info;
 
             date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
-            date_Set( &p_sys->end_date, VLC_TS_INVALID );
+            date_Set( &p_sys->end_date, VLC_TICK_INVALID );
             break;
 
         case FLAC__METADATA_TYPE_VORBIS_COMMENT:
@@ -661,7 +661,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
 
     p_sys->p_block = p_block;
 
-    if( p_sys->p_block->i_pts > VLC_TS_INVALID &&
+    if( p_sys->p_block->i_pts > VLC_TICK_INVALID &&
         p_sys->p_block->i_pts != date_Get( &p_sys->end_date ) )
         date_Set( &p_sys->end_date, p_sys->p_block->i_pts );
 
diff --git a/modules/codec/fluidsynth.c b/modules/codec/fluidsynth.c
index 1212603281ab..c68c222f99fe 100644
--- a/modules/codec/fluidsynth.c
+++ b/modules/codec/fluidsynth.c
@@ -201,7 +201,7 @@ static void Flush (decoder_t *p_dec)
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    date_Set (&p_sys->end_date, VLC_TS_INVALID);
+    date_Set (&p_sys->end_date, VLC_TICK_INVALID);
     //fluid_synth_system_reset (p_sys->synth);
     fluid_synth_program_reset (p_sys->synth);
     for (unsigned channel = 0; channel < 16; channel++)
@@ -227,7 +227,7 @@ static int DecodeBlock (decoder_t *p_dec, block_t *p_block)
         }
     }
 
-    if (p_block->i_pts > VLC_TS_INVALID && !date_Get (&p_sys->end_date))
+    if (p_block->i_pts > VLC_TICK_INVALID && !date_Get (&p_sys->end_date))
         date_Set (&p_sys->end_date, p_block->i_pts);
     else
     if (p_block->i_pts < date_Get (&p_sys->end_date))
diff --git a/modules/codec/g711.c b/modules/codec/g711.c
index 911e4e248f02..71242c37b5c9 100644
--- a/modules/codec/g711.c
+++ b/modules/codec/g711.c
@@ -231,7 +231,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         }
     }
 
-    if( p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
@@ -244,7 +244,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
     }
 
     /* Don't re-use the same pts twice */
-    p_block->i_pts = VLC_TS_INVALID;
+    p_block->i_pts = VLC_TICK_INVALID;
 
     unsigned samples = p_block->i_buffer / p_dec->fmt_in.audio.i_channels;
     if( samples == 0 )
diff --git a/modules/codec/gstreamer/gstdecode.c b/modules/codec/gstreamer/gstdecode.c
index 23b227f00849..33a5b9cf6a7b 100644
--- a/modules/codec/gstreamer/gstdecode.c
+++ b/modules/codec/gstreamer/gstdecode.c
@@ -693,17 +693,17 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
             return VLCDEC_ECRITICAL;
         }
 
-        if( p_block->i_dts > VLC_TS_INVALID )
+        if( p_block->i_dts > VLC_TICK_INVALID )
             GST_BUFFER_DTS( p_buf ) = gst_util_uint64_scale( p_block->i_dts,
                     GST_SECOND, GST_MSECOND );
 
-        if( p_block->i_pts <= VLC_TS_INVALID )
+        if( p_block->i_pts <= VLC_TICK_INVALID )
             GST_BUFFER_PTS( p_buf ) = GST_BUFFER_DTS( p_buf );
         else
             GST_BUFFER_PTS( p_buf ) = gst_util_uint64_scale( p_block->i_pts,
                     GST_SECOND, GST_MSECOND );
 
-        if( p_block->i_length > VLC_TS_INVALID )
+        if( p_block->i_length > VLC_TICK_INVALID )
             GST_BUFFER_DURATION( p_buf ) = gst_util_uint64_scale(
                     p_block->i_length, GST_SECOND, GST_MSECOND );
 
diff --git a/modules/codec/jpeg.c b/modules/codec/jpeg.c
index 9b7ec82313a0..7dc49acdfde6 100644
--- a/modules/codec/jpeg.c
+++ b/modules/codec/jpeg.c
@@ -573,7 +573,7 @@ static int DecodeBlock(decoder_t *p_dec, block_t *p_block)
     jpeg_destroy_decompress(&p_sys->p_jpeg);
     free(p_row_pointers);
 
-    p_pic->date = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : p_block->i_dts;
+    p_pic->date = p_block->i_pts > VLC_TICK_INVALID ? p_block->i_pts : p_block->i_dts;
 
     block_Release(p_block);
     decoder_QueueVideo( p_dec, p_pic );
diff --git a/modules/codec/kate.c b/modules/codec/kate.c
index f97b3fb86dd5..e65daba61c19 100644
--- a/modules/codec/kate.c
+++ b/modules/codec/kate.c
@@ -365,7 +365,7 @@ static int OpenDecoder( vlc_object_t *p_this )
 #endif
     p_sys->b_ready = false;
     p_sys->i_pts =
-    p_sys->i_max_stop = VLC_TS_INVALID;
+    p_sys->i_max_stop = VLC_TICK_INVALID;
 
     kate_comment_init( &p_sys->kc );
     kate_info_init( &p_sys->ki );
@@ -462,7 +462,7 @@ static void Flush( decoder_t *p_dec )
     tiger_renderer_seek( p_sys->p_tr, 0 );
     vlc_mutex_unlock( &p_sys->lock );
 #endif
-    p_sys->i_max_stop = VLC_TS_INVALID;
+    p_sys->i_max_stop = VLC_TICK_INVALID;
 }
 
 /****************************************************************************
@@ -488,7 +488,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t *p_block )
 #endif
         if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
         {
-            p_sys->i_max_stop = VLC_TS_INVALID;
+            p_sys->i_max_stop = VLC_TICK_INVALID;
             block_Release( p_block );
             return NULL;
         }
@@ -625,7 +625,7 @@ static void *ProcessPacket( decoder_t *p_dec, kate_packet *p_kp,
     decoder_sys_t *p_sys = p_dec->p_sys;
 
     /* Date management */
-    if( p_block->i_pts > VLC_TS_INVALID && p_block->i_pts != p_sys->i_pts )
+    if( p_block->i_pts > VLC_TICK_INVALID && p_block->i_pts != p_sys->i_pts )
     {
         p_sys->i_pts = p_block->i_pts;
     }
diff --git a/modules/codec/libass.c b/modules/codec/libass.c
index 87e3c8202537..efe268b4e521 100644
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -150,7 +150,7 @@ static int Create( vlc_object_t *p_this )
     vlc_mutex_init( &p_sys->lock );
     p_sys->i_refcount = 1;
     memset( &p_sys->fmt, 0, sizeof(p_sys->fmt) );
-    p_sys->i_max_stop = VLC_TS_INVALID;
+    p_sys->i_max_stop = VLC_TICK_INVALID;
     p_sys->p_library  = NULL;
     p_sys->p_renderer = NULL;
     p_sys->p_track    = NULL;
@@ -333,7 +333,7 @@ static void Flush( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    p_sys->i_max_stop = VLC_TS_INVALID;
+    p_sys->i_max_stop = VLC_TICK_INVALID;
 }
 
 /****************************************************************************
diff --git a/modules/codec/lpcm.c b/modules/codec/lpcm.c
index 5eb2ae799050..46b08e4d1ac6 100644
--- a/modules/codec/lpcm.c
+++ b/modules/codec/lpcm.c
@@ -349,7 +349,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
     }
 
     /* Date management */
-    if( p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
diff --git a/modules/codec/mpg123.c b/modules/codec/mpg123.c
index 2465fde2fd42..0ce0e5719eeb 100644
--- a/modules/codec/mpg123.c
+++ b/modules/codec/mpg123.c
@@ -141,7 +141,7 @@ static void Flush( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    date_Set( &p_sys->end_date, VLC_TS_INVALID );
+    date_Set( &p_sys->end_date, VLC_TICK_INVALID );
 
     mpg123_close( p_sys->p_handle );
     mpg123_delete( p_sys->p_handle );
@@ -203,7 +203,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
 {
     int i_err;
     decoder_sys_t *p_sys = p_dec->p_sys;
-    vlc_tick_t i_pts = VLC_TS_INVALID;
+    vlc_tick_t i_pts = VLC_TICK_INVALID;
 
     if( !p_sys->b_opened )
     {
@@ -215,7 +215,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
     /* Feed input block */
     if( p_block != NULL )
     {
-        i_pts = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : p_block->i_dts;
+        i_pts = p_block->i_pts > VLC_TICK_INVALID ? p_block->i_pts : p_block->i_dts;
 
         if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
         {
@@ -227,7 +227,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
             }
         }
 
-        if( !date_Get( &p_sys->end_date ) && i_pts <= VLC_TS_INVALID )
+        if( !date_Get( &p_sys->end_date ) && i_pts <= VLC_TICK_INVALID )
         {
             /* We've just started the stream, wait for the first PTS. */
             msg_Dbg( p_dec, "waiting for PTS" );
@@ -290,7 +290,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
             {
                 msg_Err( p_dec, "mpg123_decode_frame error: %s",
                          mpg123_plain_strerror( i_err ) );
-                date_Set( &p_sys->end_date, VLC_TS_INVALID );
+                date_Set( &p_sys->end_date, VLC_TICK_INVALID );
                 break;
             }
         }
@@ -302,7 +302,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         {
             if( UpdateAudioFormat( p_dec ) != VLC_SUCCESS )
             {
-                date_Set( &p_sys->end_date, VLC_TS_INVALID );
+                date_Set( &p_sys->end_date, VLC_TICK_INVALID );
                 break;
             }
         }
@@ -310,9 +310,9 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         block_t *p_out = p_sys->p_out;
         p_sys->p_out = NULL;
 
-        if( date_Get( &p_sys->end_date ) == VLC_TS_INVALID )
+        if( date_Get( &p_sys->end_date ) == VLC_TICK_INVALID )
         {
-            if( i_pts != VLC_TS_INVALID )
+            if( i_pts != VLC_TICK_INVALID )
             {
                 date_Set( &p_sys->end_date, i_pts );
             }
@@ -396,7 +396,7 @@ static int OpenDecoder( vlc_object_t *p_this )
         return VLC_ENOMEM;
 
     p_sys->p_out = NULL;
-    date_Set( &p_sys->end_date, VLC_TS_INVALID );
+    date_Set( &p_sys->end_date, VLC_TICK_INVALID );
 
     if( MPG123Open( p_dec ) )
         goto error;
diff --git a/modules/codec/oggspots.c b/modules/codec/oggspots.c
index 418c085efb9c..c5b7d67b1f18 100644
--- a/modules/codec/oggspots.c
+++ b/modules/codec/oggspots.c
@@ -115,7 +115,7 @@ static int OpenDecoder(vlc_object_t* p_this)
     p_dec->p_sys = p_sys;
     p_sys->b_packetizer = false;
     p_sys->b_has_headers = false;
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
 
     /* Initialize image handler */
     p_sys->p_image = image_HandlerCreate(p_dec);
@@ -288,7 +288,7 @@ static void Flush(decoder_t* p_dec)
 {
     decoder_sys_t* p_sys = p_dec->p_sys;
 
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
 }
 
 /*****************************************************************************
@@ -309,7 +309,7 @@ static void* ProcessPacket(decoder_t* p_dec, block_t* p_block)
     }
 
     /* Date management */
-    if (p_block->i_pts > VLC_TS_INVALID && p_block->i_pts != p_sys->i_pts) {
+    if (p_block->i_pts > VLC_TICK_INVALID && p_block->i_pts != p_sys->i_pts) {
         p_sys->i_pts = p_block->i_pts;
     }
 
diff --git a/modules/codec/omxil/mediacodec.c b/modules/codec/omxil/mediacodec.c
index d88568b1abdb..a2efa0a4df54 100644
--- a/modules/codec/omxil/mediacodec.c
+++ b/modules/codec/omxil/mediacodec.c
@@ -505,7 +505,7 @@ static int StartMediaCodec(decoder_t *p_dec)
     }
     else
     {
-        date_Set(&p_sys->audio.i_end_date, VLC_TS_INVALID);
+        date_Set(&p_sys->audio.i_end_date, VLC_TICK_INVALID);
 
         args.audio.i_sample_rate    = p_dec->fmt_in.audio.i_rate;
         args.audio.i_channel_count  = p_dec->p_sys->audio.i_channels;
@@ -951,7 +951,7 @@ static int Video_ProcessOutput(decoder_t *p_dec, mc_api_out *p_out,
             return p_sys->api.release_out(&p_sys->api, p_out->buf.i_index, false);
         }
 
-        if (forced_ts == VLC_TS_INVALID)
+        if (forced_ts == VLC_TICK_INVALID)
             p_pic->date = p_out->buf.i_ts;
         else
             p_pic->date = forced_ts;
@@ -1561,7 +1561,7 @@ static int Video_OnNewBlock(decoder_t *p_dec, block_t **pp_block)
     block_t *p_block = *pp_block;
 
     timestamp_FifoPut(p_sys->video.timestamp_fifo,
-                      p_block->i_pts ? VLC_TS_INVALID : p_block->i_dts);
+                      p_block->i_pts ? VLC_TICK_INVALID : p_block->i_dts);
 
     return 1;
 }
@@ -1683,7 +1683,7 @@ static int Audio_OnNewBlock(decoder_t *p_dec, block_t **pp_block)
     /* We've just started the stream, wait for the first PTS. */
     if (!date_Get(&p_sys->audio.i_end_date))
     {
-        if (p_block->i_pts <= VLC_TS_INVALID)
+        if (p_block->i_pts <= VLC_TICK_INVALID)
             return 0;
         date_Set(&p_sys->audio.i_end_date, p_block->i_pts);
     }
@@ -1695,5 +1695,5 @@ static void Audio_OnFlush(decoder_t *p_dec)
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    date_Set(&p_sys->audio.i_end_date, VLC_TS_INVALID);
+    date_Set(&p_sys->audio.i_end_date, VLC_TICK_INVALID);
 }
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 619e90a28051..3ff8ffc698e7 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -1631,7 +1631,7 @@ static int DecodeVideo( decoder_t *p_dec, block_t *p_block )
             if( !decoder_UpdateVideoFormat(p_dec))
                 invalid_picture = decoder_NewPicture(p_dec);
             if (invalid_picture) {
-                invalid_picture->date = VLC_TS_INVALID;
+                invalid_picture->date = VLC_TICK_INVALID;
                 picture_sys_t *p_picsys = invalid_picture->p_sys;
                 p_picsys->hw.p_dec = NULL;
                 p_picsys->hw.i_index = -1;
diff --git a/modules/codec/opus.c b/modules/codec/opus.c
index 1014b724f9e7..603f775bb89d 100644
--- a/modules/codec/opus.c
+++ b/modules/codec/opus.c
@@ -408,7 +408,7 @@ static block_t *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     }
 
     /* Date management */
-    if( p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
diff --git a/modules/codec/png.c b/modules/codec/png.c
index 5ef76f0a0775..973c038ad055 100644
--- a/modules/codec/png.c
+++ b/modules/codec/png.c
@@ -307,7 +307,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
     png_destroy_read_struct( &p_png, &p_info, &p_end_info );
     free( p_row_pointers );
 
-    p_pic->date = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : p_block->i_dts;
+    p_pic->date = p_block->i_pts > VLC_TICK_INVALID ? p_block->i_pts : p_block->i_dts;
 
     block_Release( p_block );
     decoder_QueueVideo( p_dec, p_pic );
diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c
index e98061dc60dc..c9410530e70e 100644
--- a/modules/codec/rawvideo.c
+++ b/modules/codec/rawvideo.c
@@ -137,7 +137,7 @@ static void Flush( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    date_Set( &p_sys->pts, VLC_TS_INVALID );
+    date_Set( &p_sys->pts, VLC_TICK_INVALID );
 }
 
 /****************************************************************************
@@ -159,7 +159,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t *p_block )
         }
     }
 
-    if( p_block->i_pts <= VLC_TS_INVALID && p_block->i_dts <= VLC_TS_INVALID &&
+    if( p_block->i_pts <= VLC_TICK_INVALID && p_block->i_dts <= VLC_TICK_INVALID &&
         !date_Get( &p_sys->pts ) )
     {
         /* We've just started the stream, wait for the first PTS. */
@@ -168,11 +168,11 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t *p_block )
     }
 
     /* Date management: If there is a pts avaliable, use that. */
-    if( p_block->i_pts > VLC_TS_INVALID )
+    if( p_block->i_pts > VLC_TICK_INVALID )
     {
         date_Set( &p_sys->pts, p_block->i_pts );
     }
-    else if( p_block->i_dts > VLC_TS_INVALID )
+    else if( p_block->i_dts > VLC_TICK_INVALID )
     {
         /* NB, davidf doesn't quite agree with this in general, it is ok
          * for rawvideo since it is in order (ie pts=dts), however, it
diff --git a/modules/codec/schroedinger.c b/modules/codec/schroedinger.c
index 53bb64b347f5..c8b84433cabc 100644
--- a/modules/codec/schroedinger.c
+++ b/modules/codec/schroedinger.c
@@ -580,7 +580,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     p_dec->p_sys = p_sys;
     p_sys->p_schro = p_schro;
     p_sys->p_format = NULL;
-    p_sys->i_lastpts = VLC_TS_INVALID;
+    p_sys->i_lastpts = VLC_TICK_INVALID;
     p_sys->i_frame_pts_delta = 0;
 
     /* Set output properties */
@@ -749,7 +749,7 @@ static void Flush( decoder_t *p_dec )
     decoder_sys_t *p_sys = p_dec->p_sys;
 
     schro_decoder_reset( p_sys->p_schro );
-    p_sys->i_lastpts = VLC_TS_INVALID;
+    p_sys->i_lastpts = VLC_TICK_INVALID;
 }
 
 /****************************************************************************
@@ -782,7 +782,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         p_schrobuffer = schro_buffer_new_with_data( p_block->p_buffer, p_block->i_buffer );
         p_schrobuffer->free = SchroBufferFree;
         p_schrobuffer->priv = p_block;
-        if( p_block->i_pts > VLC_TS_INVALID ) {
+        if( p_block->i_pts > VLC_TICK_INVALID ) {
             vlc_tick_t *p_pts = malloc( sizeof(*p_pts) );
             if( p_pts ) {
                 *p_pts = p_block->i_pts;
@@ -844,7 +844,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
                 p_pic->date = *(mtime_t*) p_tag->value;
                 schro_tag_free( p_tag );
             }
-            else if( p_sys->i_lastpts > VLC_TS_INVALID )
+            else if( p_sys->i_lastpts > VLC_TICK_INVALID )
             {
                 /* NB, this shouldn't happen since the packetizer does a
                  * very thorough job of inventing timestamps.  The
diff --git a/modules/codec/scte18.c b/modules/codec/scte18.c
index 2a2181fd3bf9..162f70de5554 100644
--- a/modules/codec/scte18.c
+++ b/modules/codec/scte18.c
@@ -190,7 +190,7 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
             if( p_cea->alert_message_time_remaining )
                 p_spu->i_stop = p_spu->i_start + CLOCK_FREQ * p_cea->alert_message_time_remaining;
             else
-                p_spu->i_stop = VLC_TS_INVALID;
+                p_spu->i_stop = VLC_TICK_INVALID;
 
             p_spu->b_ephemer  = true;
             p_spu->b_absolute = false;
diff --git a/modules/codec/scte27.c b/modules/codec/scte27.c
index bfeb97b98766..8d47cc0bfa7d 100644
--- a/modules/codec/scte27.c
+++ b/modules/codec/scte27.c
@@ -446,7 +446,7 @@ static int Decode(decoder_t *dec, block_t *b)
             if (index == 0) {
                 sys->segment_id = id;
                 sys->segment_size = 0;
-                sys->segment_date = b->i_pts > VLC_TS_INVALID ? b->i_pts : b->i_dts;
+                sys->segment_date = b->i_pts > VLC_TICK_INVALID ? b->i_pts : b->i_dts;
             } else {
                 if (sys->segment_id != id || sys->segment_size <= 0) {
                     sys->segment_id = -1;
@@ -473,7 +473,7 @@ static int Decode(decoder_t *dec, block_t *b)
             sub = DecodeSubtitleMessage(dec,
                                         &b->p_buffer[4],
                                         section_length - 1 - 4,
-                                        b->i_pts > VLC_TS_INVALID ? b->i_pts : b->i_dts);
+                                        b->i_pts > VLC_TICK_INVALID ? b->i_pts : b->i_dts);
         }
         if (sub != NULL)
             decoder_QueueSub(dec, sub);
diff --git a/modules/codec/sdl_image.c b/modules/codec/sdl_image.c
index 76290dbd1a09..0bd7e361314a 100644
--- a/modules/codec/sdl_image.c
+++ b/modules/codec/sdl_image.c
@@ -258,7 +258,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         }
     }
 
-    p_pic->date = (p_block->i_pts > VLC_TS_INVALID) ?
+    p_pic->date = (p_block->i_pts > VLC_TICK_INVALID) ?
         p_block->i_pts : p_block->i_dts;
 
     decoder_QueueVideo( p_dec, p_pic );
diff --git a/modules/codec/speex.c b/modules/codec/speex.c
index 6898d3f8e261..577711c648e6 100644
--- a/modules/codec/speex.c
+++ b/modules/codec/speex.c
@@ -577,7 +577,7 @@ static block_t *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     block_t *p_block = *pp_block;
 
     /* Date management */
-    if( p_block && p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block && p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
@@ -680,7 +680,7 @@ static int DecodeRtpSpeexPacket( decoder_t *p_dec, block_t *p_speex_bit_block )
     int i_decode_ret;
     unsigned int i_speex_frame_size;
 
-    if ( !p_speex_bit_block || p_speex_bit_block->i_pts <= VLC_TS_INVALID )
+    if ( !p_speex_bit_block || p_speex_bit_block->i_pts <= VLC_TICK_INVALID )
         return VLCDEC_SUCCESS;
 
     /*
diff --git a/modules/codec/spudec/parse.c b/modules/codec/spudec/parse.c
index ee569efdeab3..ee09b31cdb36 100644
--- a/modules/codec/spudec/parse.c
+++ b/modules/codec/spudec/parse.c
@@ -293,7 +293,7 @@ static int Validate( decoder_t *p_dec, unsigned i_index,
         return VLC_EGENERIC;
     }
 
-    if( p_spu_properties->i_start == VLC_TS_INVALID )
+    if( p_spu_properties->i_start == VLC_TICK_INVALID )
     {
         msg_Err( p_dec, "no `start display' command" );
         return VLC_EGENERIC;
@@ -370,8 +370,8 @@ static int ParseControlSeq( decoder_t *p_dec, vlc_tick_t i_pts,
     /* Initialize the structure */
     spu_properties_t spu_properties;
     memset( &spu_properties, 0, sizeof(spu_properties) );
-    spu_properties.i_start = VLC_TS_INVALID;
-    spu_properties.i_stop = VLC_TS_INVALID;
+    spu_properties.i_start = VLC_TICK_INVALID;
+    spu_properties.i_stop = VLC_TICK_INVALID;
     spu_properties.b_subtitle = true;
 
     for( i_index = 4 + p_sys->i_rle_size; i_index < p_sys->i_spu_size ; )
diff --git a/modules/codec/spudec/spudec.c b/modules/codec/spudec/spudec.c
index f487c94c9ab6..0f5c9d5869c3 100644
--- a/modules/codec/spudec/spudec.c
+++ b/modules/codec/spudec/spudec.c
@@ -216,7 +216,7 @@ static block_t *Reassemble( decoder_t *p_dec, block_t *p_block )
     }
 
     if( p_sys->i_spu_size <= 0 &&
-        ( p_block->i_pts <= VLC_TS_INVALID || p_block->i_buffer < 4 ) )
+        ( p_block->i_pts <= VLC_TICK_INVALID || p_block->i_buffer < 4 ) )
     {
         msg_Dbg( p_dec, "invalid starting packet (size < 4 or pts <=0)" );
         msg_Dbg( p_dec, "spu size: %d, i_pts: %"PRId64" i_buffer: %zu",
diff --git a/modules/codec/subsdec.c b/modules/codec/subsdec.c
index a440140d1ad6..4fc87e4f290d 100644
--- a/modules/codec/subsdec.c
+++ b/modules/codec/subsdec.c
@@ -367,7 +367,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
         return NULL;
 
     /* We cannot display a subpicture with no date */
-    if( p_block->i_pts <= VLC_TS_INVALID )
+    if( p_block->i_pts <= VLC_TICK_INVALID )
     {
         msg_Warn( p_dec, "subtitle without a date" );
         return NULL;
diff --git a/modules/codec/substext.h b/modules/codec/substext.h
index 60203815bcdc..3835a09c0e7b 100644
--- a/modules/codec/substext.h
+++ b/modules/codec/substext.h
@@ -104,7 +104,7 @@ static int SubpictureTextValidate(subpicture_t *subpic,
     VLC_UNUSED(fmt_src); VLC_UNUSED(fmt_dst);
 
     if (!has_src_changed && !has_dst_changed &&
-        (sys->i_next_update == VLC_TS_INVALID || sys->i_next_update > ts))
+        (sys->i_next_update == VLC_TICK_INVALID || sys->i_next_update > ts))
         return VLC_SUCCESS;
 
     subpicture_updater_sys_region_t *p_updtregion = &sys->region;
@@ -259,7 +259,7 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
     }
 
     if( b_schedule_blink_update &&
-        (sys->i_next_update == VLC_TS_INVALID || sys->i_next_update < ts) )
+        (sys->i_next_update == VLC_TICK_INVALID || sys->i_next_update < ts) )
     {
         sys->i_next_update = ts + CLOCK_FREQ;
         sys->b_blink_even = !sys->b_blink_even;
diff --git a/modules/codec/subsusf.c b/modules/codec/subsusf.c
index 1e6a64fcd152..147f45f26487 100644
--- a/modules/codec/subsusf.c
+++ b/modules/codec/subsusf.c
@@ -221,7 +221,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
         return NULL;
 
     /* We cannot display a subpicture with no date */
-    if( p_block->i_pts <= VLC_TS_INVALID )
+    if( p_block->i_pts <= VLC_TICK_INVALID )
     {
         msg_Warn( p_dec, "subtitle without a date" );
         return NULL;
diff --git a/modules/codec/svg.c b/modules/codec/svg.c
index 9b76e3d62ff7..af7a59073af4 100644
--- a/modules/codec/svg.c
+++ b/modules/codec/svg.c
@@ -244,7 +244,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         goto done;
     }
 
-    p_pic->date = p_block->i_pts > VLC_TS_INVALID ? p_block->i_pts : p_block->i_dts;
+    p_pic->date = p_block->i_pts > VLC_TICK_INVALID ? p_block->i_pts : p_block->i_dts;
 
 done:
     if( rsvg )
diff --git a/modules/codec/synchro.c b/modules/codec/synchro.c
index 9d618bf1680c..3abef0ecd745 100644
--- a/modules/codec/synchro.c
+++ b/modules/codec/synchro.c
@@ -259,7 +259,7 @@ bool decoder_SynchroChoose( decoder_synchro_t * p_synchro, int i_coding_type,
         {
             b_decode = (pts - now) > (TAU_PRIME(I_CODING_TYPE) + DELTA);
         }
-        if( pts <= VLC_TS_INVALID )
+        if( pts <= VLC_TICK_INVALID )
             b_decode = 1;
 
         if( !b_decode && !p_synchro->b_quiet )
@@ -310,7 +310,7 @@ bool decoder_SynchroChoose( decoder_synchro_t * p_synchro, int i_coding_type,
         {
             b_decode = 0;
         }
-        if( p_synchro->i_nb_ref >= 1 && pts <= VLC_TS_INVALID )
+        if( p_synchro->i_nb_ref >= 1 && pts <= VLC_TICK_INVALID )
             b_decode = 1;
         break;
 
@@ -329,7 +329,7 @@ bool decoder_SynchroChoose( decoder_synchro_t * p_synchro, int i_coding_type,
         {
             b_decode = 0;
         }
-        if( p_synchro->i_nb_ref >= 2 && pts <= VLC_TS_INVALID )
+        if( p_synchro->i_nb_ref >= 2 && pts <= VLC_TICK_INVALID )
             b_decode = 1;
         break;
     }
diff --git a/modules/codec/theora.c b/modules/codec/theora.c
index 45dec7cb9035..171f6b317aac 100644
--- a/modules/codec/theora.c
+++ b/modules/codec/theora.c
@@ -161,7 +161,7 @@ static int OpenDecoder( vlc_object_t *p_this )
         return VLC_ENOMEM;
     p_dec->p_sys->b_packetizer = false;
     p_sys->b_has_headers = false;
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
     p_sys->b_decoded_first_keyframe = false;
     p_sys->tcx = NULL;
 
@@ -444,7 +444,7 @@ static void Flush( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
 }
 
 /*****************************************************************************
@@ -470,7 +470,7 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     }
 
     /* Date management */
-    if( p_block->i_pts > VLC_TS_INVALID && p_block->i_pts != p_sys->i_pts )
+    if( p_block->i_pts > VLC_TICK_INVALID && p_block->i_pts != p_sys->i_pts )
     {
         p_sys->i_pts = p_block->i_pts;
     }
diff --git a/modules/codec/ttml/substtml.c b/modules/codec/ttml/substtml.c
index ffdbdbffc6b1..dfe447dbc385 100644
--- a/modules/codec/ttml/substtml.c
+++ b/modules/codec/ttml/substtml.c
@@ -1038,7 +1038,7 @@ static int ParseBlock( decoder_t *p_dec, const block_t *p_block )
         return VLCDEC_SUCCESS;
 
     /* We cannot display a subpicture with no date */
-    if( p_block->i_pts <= VLC_TS_INVALID )
+    if( p_block->i_pts <= VLC_TICK_INVALID )
     {
         msg_Warn( p_dec, "subtitle without a date" );
         return VLCDEC_SUCCESS;
diff --git a/modules/codec/uleaddvaudio.c b/modules/codec/uleaddvaudio.c
index b90f0125e4b4..e1c07d7196f1 100644
--- a/modules/codec/uleaddvaudio.c
+++ b/modules/codec/uleaddvaudio.c
@@ -78,10 +78,10 @@ static block_t *DecodeBlock(decoder_t *dec, block_t **block_ptr)
         }
     }
 
-    if (block->i_pts > VLC_TS_INVALID &&
+    if (block->i_pts > VLC_TICK_INVALID &&
         block->i_pts != date_Get(&sys->end_date))
         date_Set(&sys->end_date, block->i_pts);
-    block->i_pts = VLC_TS_INVALID;
+    block->i_pts = VLC_TICK_INVALID;
     if (!date_Get(&sys->end_date)) {
         /* We've just started the stream, wait for the first PTS. */
         block_Release(block);
diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index d7fca4431686..e07d3c67e121 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -869,7 +869,7 @@ static picture_t * RemoveOneFrameFromDPB(decoder_sys_t *p_sys)
         picture_t *p_field = p_info->p_picture;
 
         /* Compute time if missing */
-        if (p_field->date == VLC_TS_INVALID)
+        if (p_field->date == VLC_TICK_INVALID)
             p_field->date = date_Get(&p_sys->pts);
         else
             date_Set(&p_sys->pts, p_field->date);
@@ -952,7 +952,7 @@ static frame_info_t * CreateReorderInfo(decoder_t *p_dec, const block_t *p_block
     /* required for still pictures/menus */
     p_info->b_forced = (p_block->i_flags & BLOCK_FLAG_END_OF_SEQUENCE);
 
-    if (date_Get(&p_sys->pts) == VLC_TS_INVALID)
+    if (date_Get(&p_sys->pts) == VLC_TICK_INVALID)
         date_Set(&p_sys->pts, p_block->i_dts);
 
     return p_info;
@@ -978,7 +978,7 @@ static void OnDecodedFrame(decoder_t *p_dec, frame_info_t *p_info)
                 break;
             }
             else if (!p_sys->b_poc_based_reorder &&
-                     p_info->p_picture->date > VLC_TS_INVALID &&
+                     p_info->p_picture->date > VLC_TICK_INVALID &&
                      p_sys->p_pic_reorder->p_picture->date > p_info->p_picture->date)
             {
                 p_sys->b_invalid_pic_reorder_max = true;
@@ -1689,7 +1689,7 @@ static CMSampleBufferRef VTSampleBufferCreate(decoder_t *p_dec,
     CMBlockBufferRef  block_buf = NULL;
     CMSampleBufferRef sample_buf = NULL;
     CMTime pts;
-    if(!p_dec->p_sys->b_poc_based_reorder && p_block->i_pts == VLC_TS_INVALID)
+    if(!p_dec->p_sys->b_poc_based_reorder && p_block->i_pts == VLC_TICK_INVALID)
         pts = CMTimeMake(p_block->i_dts, CLOCK_FREQ);
     else
         pts = CMTimeMake(p_block->i_pts, CLOCK_FREQ);
diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c
index f3a4affd54fb..6bec6edd4779 100644
--- a/modules/codec/vorbis.c
+++ b/modules/codec/vorbis.c
@@ -481,7 +481,7 @@ static block_t *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     }
 
     /* Date management */
-    if( p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
diff --git a/modules/codec/webvtt/subsvtt.c b/modules/codec/webvtt/subsvtt.c
index 7e70382532cc..3817e043d84d 100644
--- a/modules/codec/webvtt/subsvtt.c
+++ b/modules/codec/webvtt/subsvtt.c
@@ -595,7 +595,7 @@ static vlc_tick_t webvtt_domnode_GetPlaybackTime( const webvtt_dom_node_t *p_nod
     if( p_node )
         return b_end ? ((const webvtt_dom_cue_t *) p_node)->i_nzstop:
                        ((const webvtt_dom_cue_t *) p_node)->i_nzstart;
-    return VLC_TS_INVALID;
+    return VLC_TICK_INVALID;
 }
 
 #ifdef HAVE_CSS
diff --git a/modules/codec/wmafixed/wma.c b/modules/codec/wmafixed/wma.c
index 84c27249f9f2..1566715203e1 100644
--- a/modules/codec/wmafixed/wma.c
+++ b/modules/codec/wmafixed/wma.c
@@ -197,7 +197,7 @@ static void Flush( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    date_Set( &p_sys->end_date, VLC_TS_INVALID );
+    date_Set( &p_sys->end_date, VLC_TICK_INVALID );
 }
 
 /*****************************************************************************
@@ -222,12 +222,12 @@ static int DecodeFrame( decoder_t *p_dec, block_t *p_block )
     }
 
     /* Date management */
-    if( p_block->i_pts > VLC_TS_INVALID &&
+    if( p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get( &p_sys->end_date ) )
     {
         date_Set( &p_sys->end_date, p_block->i_pts );
         /* don't reuse the same pts */
-        p_block->i_pts = VLC_TS_INVALID;
+        p_block->i_pts = VLC_TICK_INVALID;
     }
     else if( !date_Get( &p_sys->end_date ) )
     {
diff --git a/modules/codec/xwd.c b/modules/codec/xwd.c
index 3e26b0be9fa7..0f8a07b36fe9 100644
--- a/modules/codec/xwd.c
+++ b/modules/codec/xwd.c
@@ -62,7 +62,7 @@ static int Decode (decoder_t *dec, block_t *block)
     if (block == NULL) /* No Drain */
         return VLCDEC_SUCCESS;
 
-    if (block->i_pts <= VLC_TS_INVALID)
+    if (block->i_pts <= VLC_TICK_INVALID)
         goto drop; /* undated block, should never happen */
     if (block->i_buffer < sz_XWDheader)
         goto drop;
diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c
index d6fae6dc6295..0427af781035 100644
--- a/modules/control/dbus/dbus.c
+++ b/modules/control/dbus/dbus.c
@@ -801,7 +801,7 @@ static void *Run( void *data )
 
     int canc = vlc_savecancel();
 
-    vlc_tick_t events_last_date = VLC_TS_INVALID;
+    vlc_tick_t events_last_date = VLC_TICK_INVALID;
     int events_poll_timeout = -1;
     for( ;; )
     {
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index cc5774a385e8..bf256cb7abbf 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -78,7 +78,7 @@ PlaylistManager::PlaylistManager( demux_t *p_demux_,
     vlc_mutex_init(&cached.lock);
     cached.b_live = false;
     cached.f_position = 0.0;
-    cached.i_time = VLC_TS_INVALID;
+    cached.i_time = VLC_TICK_INVALID;
     cached.playlistStart = 0;
     cached.playlistEnd = 0;
     cached.playlistLength = 0;
@@ -276,7 +276,7 @@ AbstractStream::BufferingStatus PlaylistManager::bufferize(Times deadline,
     }
 
     vlc_mutex_lock(&demux.lock);
-    if(demux.times.continuous == VLC_TS_INVALID &&
+    if(demux.times.continuous == VLC_TICK_INVALID &&
         /* don't wait minbuffer on simple discontinuity or restart */
        (demux.pcr_syncpoint == TimestampSynchronizationPoint::Discontinuity ||
         /* prevents starting before buffering is reached */
@@ -328,9 +328,9 @@ Times PlaylistManager::getFirstTimes() const
     for(const AbstractStream *stream : streams)
     {
         const Times dts = stream->getFirstTimes();
-        if(mindts.continuous == VLC_TS_INVALID)
+        if(mindts.continuous == VLC_TICK_INVALID)
             mindts = dts;
-        else if(dts.continuous != VLC_TS_INVALID &&
+        else if(dts.continuous != VLC_TICK_INVALID &&
                 dts.continuous < mindts.continuous)
             mindts = dts;
     }
@@ -355,7 +355,7 @@ bool PlaylistManager::setPosition(vlc_tick_t mediatime, double pos, bool accurat
     bool hasValidStream = false;
     StreamPosition streampos;
     streampos.times = demux.firsttimes;
-    if(streampos.times.continuous != VLC_TS_INVALID)
+    if(streampos.times.continuous != VLC_TICK_INVALID)
         streampos.times.offsetBy(mediatime - streampos.times.segment.media);
     else
         streampos.times.segment.media = mediatime;
@@ -467,7 +467,7 @@ int PlaylistManager::demux_callback(demux_t *p_demux)
 int PlaylistManager::doDemux(int64_t increment)
 {
     vlc_mutex_lock(&demux.lock);
-    if(demux.times.continuous == VLC_TS_INVALID)
+    if(demux.times.continuous == VLC_TICK_INVALID)
     {
         bool b_dead = true;
         bool b_all_disabled = true;
@@ -491,10 +491,10 @@ int PlaylistManager::doDemux(int64_t increment)
     AbstractStream::Status status = dequeue(demux.times, &barrier);
 
     vlc_mutex_lock(&demux.lock);
-    if(demux.firsttimes.continuous == VLC_TS_INVALID && barrier.continuous != VLC_TS_INVALID)
+    if(demux.firsttimes.continuous == VLC_TICK_INVALID && barrier.continuous != VLC_TICK_INVALID)
     {
         demux.firsttimes = barrier;
-        assert(barrier.segment.media != VLC_TS_INVALID);
+        assert(barrier.segment.media != VLC_TICK_INVALID);
     }
     vlc_mutex_unlock(&demux.lock);
 
@@ -539,7 +539,7 @@ int PlaylistManager::doDemux(int64_t increment)
         break;
     case AbstractStream::Status::Demuxed:
         vlc_mutex_lock(&demux.lock);
-        if( demux.times.continuous != VLC_TS_INVALID && barrier.continuous != demux.times.continuous )
+        if( demux.times.continuous != VLC_TICK_INVALID && barrier.continuous != demux.times.continuous )
         {
             demux.times = barrier;
             vlc_tick_t pcr = VLC_TS_0 + std::max(INT64_C(0), demux.times.continuous - CLOCK_FREQ/10);
@@ -657,7 +657,7 @@ int PlaylistManager::doControl(int i_query, va_list args)
             demux.times = Times();
             demux.firsttimes = Times();
             cached.lastupdate = 0;
-            cached.i_time = VLC_TS_INVALID;
+            cached.i_time = VLC_TICK_INVALID;
             setBufferingRunState(true);
             break;
         }
@@ -679,7 +679,7 @@ int PlaylistManager::doControl(int i_query, va_list args)
             demux.times = Times();
             demux.firsttimes = Times();
             cached.lastupdate = 0;
-            cached.i_time = VLC_TS_INVALID;
+            cached.i_time = VLC_TICK_INVALID;
             setBufferingRunState(true);
             break;
         }
@@ -835,7 +835,7 @@ void PlaylistManager::updateControlsPosition()
         if(playlist->duration.Get() > cached.playlistLength)
             cached.playlistLength = playlist->duration.Get();
 
-        if(cached.playlistLength && currentTimes.segment.media != VLC_TS_INVALID)
+        if(cached.playlistLength && currentTimes.segment.media != VLC_TICK_INVALID)
         {
             cached.i_time = currentTimes.segment.media;
             cached.f_position = (double) (cached.i_time - VLC_TS_0 - cached.playlistStart) / cached.playlistLength;
diff --git a/modules/demux/adaptive/SegmentTracker.cpp b/modules/demux/adaptive/SegmentTracker.cpp
index 35bc669c1802..3e0e48ab607b 100644
--- a/modules/demux/adaptive/SegmentTracker.cpp
+++ b/modules/demux/adaptive/SegmentTracker.cpp
@@ -325,7 +325,7 @@ SegmentTracker::prepareChunk(bool switch_allowed, Position pos) const
     if(segment != datasegment) /* need to set for init */
         segmentChunk->discontinuitySequenceNumber = datasegment->getDiscontinuitySequenceNumber();
 
-    vlc_tick_t startTime = VLC_TS_INVALID;
+    vlc_tick_t startTime = VLC_TICK_INVALID;
     vlc_tick_t duration = 0;
     vlc_tick_t displayTime = datasegment->getDisplayTime();
     /* timings belong to timeline and are not set on the segment or need profile timescale */
diff --git a/modules/demux/adaptive/SegmentTracker.hpp b/modules/demux/adaptive/SegmentTracker.hpp
index 4c028b9f7c83..933a019329de 100644
--- a/modules/demux/adaptive/SegmentTracker.hpp
+++ b/modules/demux/adaptive/SegmentTracker.hpp
@@ -143,7 +143,7 @@ namespace adaptive
         public:
             SegmentChangedEvent() = delete;
             SegmentChangedEvent(const ID &, uint64_t,
-                                mtime_t, mtime_t, vlc_tick_t = VLC_TS_INVALID);
+                                mtime_t, mtime_t, vlc_tick_t = VLC_TICK_INVALID);
             virtual ~SegmentChangedEvent() = default;
 
             const ID *id;
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index 4a14dffbd020..2687e578378b 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -209,7 +209,7 @@ Times AbstractStream::getFirstTimes() const
         return Times();
 
     Times times = fakeEsOut()->commandsQueue()->getFirstTimes();
-    if(times.continuous == VLC_TS_INVALID)
+    if(times.continuous == VLC_TICK_INVALID)
         times = fakeEsOut()->commandsQueue()->getPCR();
     return times;
 }
@@ -481,8 +481,8 @@ AbstractStream::BufferingStatus AbstractStream::doBufferize(Times deadline,
     }
 
     vlc_tick_t i_demuxed = fakeEsOut()->commandsQueue()->getDemuxedAmount(deadline).continuous;
-    if(!contiguous && prevEndTimeContext.media != VLC_TS_INVALID
-       && deadline.segment.media != VLC_TS_INVALID)
+    if(!contiguous && prevEndTimeContext.media != VLC_TICK_INVALID
+       && deadline.segment.media != VLC_TICK_INVALID)
     {
         vlc_tick_t i_mediaamount = fakeEsOut()->commandsQueue()->getDemuxedMediaAmount(deadline).segment.media;
         if(i_mediaamount > i_demuxed)
@@ -539,7 +539,7 @@ AbstractStream::BufferingStatus AbstractStream::doBufferize(Times deadline,
             return BufferingStatus::End;
         }
 
-        if(deadline.continuous != VLC_TS_INVALID)
+        if(deadline.continuous != VLC_TICK_INVALID)
         {
             i_demuxed = fakeEsOut()->commandsQueue()->getDemuxedAmount(deadline).continuous;
             segmentTracker->notifyBufferingLevel(i_min_buffering, i_max_buffering, i_demuxed, i_target_buffering);
@@ -547,14 +547,14 @@ AbstractStream::BufferingStatus AbstractStream::doBufferize(Times deadline,
         else
         {
             /* On initial pass, there's no demux time known, we need to fake it */
-            if(fakeEsOut()->commandsQueue()->getBufferingLevel().continuous != VLC_TS_INVALID)
+            if(fakeEsOut()->commandsQueue()->getBufferingLevel().continuous != VLC_TICK_INVALID)
                 i_demuxed = i_min_buffering;
         }
     }
     vlc_mutex_unlock(&lock);
 
     Times first = fakeEsOut()->commandsQueue()->getFirstTimes();
-    if(contiguous && first.continuous != VLC_TS_INVALID && first.segment.demux != VLC_TS_INVALID)
+    if(contiguous && first.continuous != VLC_TICK_INVALID && first.segment.demux != VLC_TICK_INVALID)
         segmentTracker->updateSynchronizationReference(currentSequence, first);
 
     if(i_demuxed < i_max_buffering) /* need to read more */
@@ -721,7 +721,7 @@ bool AbstractStream::getMediaPlaybackTimes(vlc_tick_t *start, vlc_tick_t *end,
 
 bool AbstractStream::getMediaAdvanceAmount(vlc_tick_t *duration) const
 {
-    if(startTimeContext.media == VLC_TS_INVALID)
+    if(startTimeContext.media == VLC_TICK_INVALID)
         return false;
     *duration = currentTimeContext.media - startTimeContext.media;
     return true;
@@ -882,7 +882,7 @@ void AbstractStream::trackerEvent(const TrackerEvent &ev)
             currentTimeContext.display = event.displaytime;
             currentSequence = event.sequence;
             currentDuration = event.duration;
-            if(startTimeContext.media == VLC_TS_INVALID)
+            if(startTimeContext.media == VLC_TICK_INVALID)
                 startTimeContext = currentTimeContext;
         }
             break;
diff --git a/modules/demux/adaptive/Time.hpp b/modules/demux/adaptive/Time.hpp
index 0aa4a313f0e8..ce2629263374 100644
--- a/modules/demux/adaptive/Time.hpp
+++ b/modules/demux/adaptive/Time.hpp
@@ -61,11 +61,11 @@ class SegmentTimes
     public:
         SegmentTimes()
         {
-            demux = VLC_TS_INVALID;
-            media = VLC_TS_INVALID;
-            display = VLC_TS_INVALID;
+            demux = VLC_TICK_INVALID;
+            media = VLC_TICK_INVALID;
+            display = VLC_TICK_INVALID;
         }
-        SegmentTimes(vlc_tick_t a, vlc_tick_t b, vlc_tick_t c = VLC_TS_INVALID)
+        SegmentTimes(vlc_tick_t a, vlc_tick_t b, vlc_tick_t c = VLC_TICK_INVALID)
         {
             demux = a;
             media = b;
@@ -75,11 +75,11 @@ class SegmentTimes
         {
             if(v == 0)
                 return;
-            if(demux != VLC_TS_INVALID)
+            if(demux != VLC_TICK_INVALID)
                 demux += v;
-            if(media != VLC_TS_INVALID)
+            if(media != VLC_TICK_INVALID)
                 media += v;
-            if(display != VLC_TS_INVALID)
+            if(display != VLC_TICK_INVALID)
                 display += v;
         }
         vlc_tick_t demux;
@@ -92,7 +92,7 @@ class Times
     public:
         Times()
         {
-            continuous = VLC_TS_INVALID;
+            continuous = VLC_TICK_INVALID;
         }
         Times(const SegmentTimes &s, vlc_tick_t a)
         {
@@ -101,7 +101,7 @@ class Times
         }
         void offsetBy(vlc_tick_t v)
         {
-            if(continuous != VLC_TS_INVALID)
+            if(continuous != VLC_TICK_INVALID)
                 continuous += v;
             segment.offsetBy(v);
         }
diff --git a/modules/demux/adaptive/playlist/Segment.cpp b/modules/demux/adaptive/playlist/Segment.cpp
index 1a1df3171d42..4cecacb6ca1c 100644
--- a/modules/demux/adaptive/playlist/Segment.cpp
+++ b/modules/demux/adaptive/playlist/Segment.cpp
@@ -52,7 +52,7 @@ ISegment::ISegment(const ICanonicalUrl *parent):
     discontinuitySequenceNumber = std::numeric_limits<uint64_t>::max();
     templated = false;
     discontinuity = false;
-    displayTime = VLC_TS_INVALID;
+    displayTime = VLC_TICK_INVALID;
 }
 
 ISegment::~ISegment()
diff --git a/modules/demux/adaptive/plumbing/CommandsQueue.cpp b/modules/demux/adaptive/plumbing/CommandsQueue.cpp
index e5d2c2818921..94ae7478f1b1 100644
--- a/modules/demux/adaptive/plumbing/CommandsQueue.cpp
+++ b/modules/demux/adaptive/plumbing/CommandsQueue.cpp
@@ -185,7 +185,7 @@ void EsOutMilestoneCommand::Execute()
 EsOutMediaProgressCommand::EsOutMediaProgressCommand(const SegmentTimes &t)
     : AbstractCommand( ES_OUT_PRIVATE_COMMAND_PROGRESS )
 {
-    times = Times(t, VLC_TS_INVALID);
+    times = Times(t, VLC_TICK_INVALID);
 }
 
 void EsOutMediaProgressCommand::Execute()
@@ -334,8 +334,8 @@ static bool compareCommands( const Queueentry &a, const Queueentry &b )
 
         return a.first < b.first;
     }
-    else if (a.second->getTimes().continuous == VLC_TS_INVALID ||
-             b.second->getTimes().continuous == VLC_TS_INVALID)
+    else if (a.second->getTimes().continuous == VLC_TICK_INVALID ||
+             b.second->getTimes().continuous == VLC_TICK_INVALID)
     {
         return a.first < b.first;
     }
@@ -359,7 +359,7 @@ void CommandsQueue::Schedule( AbstractCommand *command, EsType )
     }
     else if( command->getType() == ES_OUT_SET_GROUP_PCR )
     {
-        if(command->getTimes().continuous != VLC_TS_INVALID)
+        if(command->getTimes().continuous != VLC_TICK_INVALID)
             bufferinglevel = command->getTimes();
         LockedCommit();
         commands.push_back( Queueentry(nextsequence++, command) );
@@ -420,7 +420,7 @@ Times CommandsQueue::Process( Times barrier )
                 disabled_esids.insert( id );
                 commands.push_back( entry );
             }
-            else if( command->getTimes().continuous == VLC_TS_INVALID )
+            else if( command->getTimes().continuous == VLC_TICK_INVALID )
             {
                 if( disabled_esids.find( id ) == disabled_esids.end() )
                     output.push_back( entry );
@@ -450,7 +450,7 @@ Times CommandsQueue::Process( Times barrier )
         if( command->getType() == ES_OUT_PRIVATE_COMMAND_SEND )
         {
             Times times = command->getTimes();
-            if( times.continuous != VLC_TS_INVALID )
+            if( times.continuous != VLC_TICK_INVALID )
                 lastdts = times;
         }
 
@@ -507,9 +507,9 @@ void CommandsQueue::setDraining()
 Times CommandsQueue::getDemuxedAmount(Times from) const
 {
     Times bufferingstart = getFirstTimes();
-    if( bufferinglevel.continuous == VLC_TS_INVALID ||
-        bufferingstart.continuous == VLC_TS_INVALID ||
-        from.continuous == VLC_TS_INVALID ||
+    if( bufferinglevel.continuous == VLC_TICK_INVALID ||
+        bufferingstart.continuous == VLC_TICK_INVALID ||
+        from.continuous == VLC_TICK_INVALID ||
         from.continuous > bufferinglevel.continuous )
         return Times(SegmentTimes(0,0),0); /* durations */
 
@@ -520,8 +520,8 @@ Times CommandsQueue::getDemuxedAmount(Times from) const
 
 Times CommandsQueue::getDemuxedMediaAmount(const Times &from) const
 {
-    if(from.continuous == VLC_TS_INVALID ||
-       bufferinglevel_media.media == VLC_TS_INVALID ||
+    if(from.continuous == VLC_TICK_INVALID ||
+       bufferinglevel_media.media == VLC_TICK_INVALID ||
        from.segment.media > bufferinglevel_media.media)
         return Times(SegmentTimes(0,0),0);  /* durations */
     Times t = from;
@@ -541,9 +541,9 @@ Times CommandsQueue::getFirstTimes() const
     for( it = commands.begin(); it != commands.end(); ++it )
     {
         const Times times = (*it).second->getTimes();
-        if( times.continuous != VLC_TS_INVALID )
+        if( times.continuous != VLC_TICK_INVALID )
         {
-            if( times.continuous < first.continuous || first.continuous == VLC_TS_INVALID )
+            if( times.continuous < first.continuous || first.continuous == VLC_TICK_INVALID )
                 first = times;
             break;
         }
diff --git a/modules/demux/adaptive/plumbing/Demuxer.cpp b/modules/demux/adaptive/plumbing/Demuxer.cpp
index 8d57101516a0..67c7b8e1f457 100644
--- a/modules/demux/adaptive/plumbing/Demuxer.cpp
+++ b/modules/demux/adaptive/plumbing/Demuxer.cpp
@@ -168,7 +168,7 @@ SlaveDemuxer::SlaveDemuxer(vlc_object_t *p_obj, const std::string &name,
                            es_out_t *out, AbstractSourceStream *source)
     : Demuxer(p_obj, name, out, source)
 {
-    length = VLC_TS_INVALID;
+    length = VLC_TICK_INVALID;
     b_reinitsonseek = false;
     b_startsfromzero = false;
 }
@@ -182,7 +182,7 @@ bool SlaveDemuxer::create()
 {
     if(Demuxer::create())
     {
-        length = VLC_TS_INVALID;
+        length = VLC_TICK_INVALID;
         if(demux_Control(p_demux, DEMUX_GET_LENGTH, &length) != VLC_SUCCESS)
             b_eof = true;
         return true;
diff --git a/modules/demux/adaptive/plumbing/FakeESOut.cpp b/modules/demux/adaptive/plumbing/FakeESOut.cpp
index dff3da6ad430..89fceff0fe5a 100644
--- a/modules/demux/adaptive/plumbing/FakeESOut.cpp
+++ b/modules/demux/adaptive/plumbing/FakeESOut.cpp
@@ -171,14 +171,14 @@ FakeESOut::~FakeESOut()
 
 void FakeESOut::resetTimestamps()
 {
-    setExpectedTimestamp(VLC_TS_INVALID);
-    setAssociatedTimestamp(VLC_TS_INVALID);
+    setExpectedTimestamp(VLC_TICK_INVALID);
+    setAssociatedTimestamp(VLC_TICK_INVALID);
     startTimes = SegmentTimes();
 }
 
 void FakeESOut::setExpectedTimestamp(vlc_tick_t ts)
 {
-    if(ts == VLC_TS_INVALID)
+    if(ts == VLC_TICK_INVALID)
     {
         expected.b_timestamp_set = false;
         timestamps_offset = 0;
@@ -193,7 +193,7 @@ void FakeESOut::setExpectedTimestamp(vlc_tick_t ts)
 
 void FakeESOut::setAssociatedTimestamp(vlc_tick_t ts)
 {
-    if(ts == VLC_TS_INVALID)
+    if(ts == VLC_TICK_INVALID)
     {
         associated.b_timestamp_set = false;
         timestamps_offset = 0;
@@ -208,7 +208,7 @@ void FakeESOut::setAssociatedTimestamp(vlc_tick_t ts)
 
 void FakeESOut::setAssociatedTimestamp(vlc_tick_t mpegts, vlc_tick_t muxed)
 {
-    if(mpegts == VLC_TS_INVALID)
+    if(mpegts == VLC_TICK_INVALID)
     {
         setAssociatedTimestamp(mpegts);
     }
@@ -333,7 +333,7 @@ size_t FakeESOut::esCount() const
 
 bool FakeESOut::hasSegmentStartTimes() const
 {
-    return startTimes.media != VLC_TS_INVALID;
+    return startTimes.media != VLC_TICK_INVALID;
 }
 
 void FakeESOut::setSegmentStartTimes(const SegmentTimes &t)
@@ -350,7 +350,7 @@ void FakeESOut::setSegmentProgressTimes(const SegmentTimes &t)
 
 bool FakeESOut::hasSynchronizationReference() const
 {
-    return synchronizationReference.second.continuous != VLC_TS_INVALID;
+    return synchronizationReference.second.continuous != VLC_TICK_INVALID;
 }
 
 void FakeESOut::setSynchronizationReference(const SynchronizationReference &r)
@@ -469,7 +469,7 @@ void FakeESOut::scheduleNecessaryMilestone()
 
 vlc_tick_t FakeESOut::fixTimestamp(vlc_tick_t ts)
 {
-    if(ts != VLC_TS_INVALID)
+    if(ts != VLC_TICK_INVALID)
     {
         if(associated.b_timestamp_set)
         {
@@ -503,12 +503,12 @@ vlc_tick_t FakeESOut::fixTimestamp(vlc_tick_t ts)
 
 vlc_tick_t FakeESOut::applyTimestampContinuity(vlc_tick_t ts)
 {
-    if(ts == VLC_TS_INVALID)
+    if(ts == VLC_TICK_INVALID)
         return ts;
 
     constexpr vlc_tick_t rollover = INT64_C(0x1FFFFFFFF) * 100 / 9;
     constexpr vlc_tick_t halfroll = INT64_C(0x0FFFFFFFF) * 100 / 9;
-    if(synchronizationReference.second.segment.demux != VLC_TS_INVALID)
+    if(synchronizationReference.second.segment.demux != VLC_TICK_INVALID)
     {
         while(ts - synchronizationReference.second.segment.demux > halfroll)
         {
@@ -520,8 +520,8 @@ vlc_tick_t FakeESOut::applyTimestampContinuity(vlc_tick_t ts)
         }
     }
 
-    if(synchronizationReference.second.segment.demux != VLC_TS_INVALID &&
-       synchronizationReference.second.continuous != VLC_TS_INVALID)
+    if(synchronizationReference.second.segment.demux != VLC_TICK_INVALID &&
+       synchronizationReference.second.continuous != VLC_TICK_INVALID)
     {
         vlc_tick_t continuityoffset = synchronizationReference.second.continuous -
                                    synchronizationReference.second.segment.demux;
@@ -531,7 +531,7 @@ vlc_tick_t FakeESOut::applyTimestampContinuity(vlc_tick_t ts)
             synchronizationReference.second.offsetBy(halfroll / 2);
 
         ts += continuityoffset;
-        assert(ts >= VLC_TS_INVALID);
+        assert(ts >= VLC_TICK_INVALID);
     }
     else /* First synchronization point */
     {
@@ -610,7 +610,7 @@ int FakeESOut::esOutSend(es_out_id_t *p_es, block_t *p_block)
     p_block->i_dts = fixTimestamp( p_block->i_dts );
     p_block->i_pts = fixTimestamp( p_block->i_pts );
 
-    if(!hasSynchronizationReference() && p_block->i_dts != VLC_TS_INVALID)
+    if(!hasSynchronizationReference() && p_block->i_dts != VLC_TICK_INVALID)
     {
         synchronizationReference.second.segment = startTimes;
         synchronizationReference.second.continuous = p_block->i_dts;
@@ -622,11 +622,11 @@ int FakeESOut::esOutSend(es_out_id_t *p_es, block_t *p_block)
     p_block->i_pts = applyTimestampContinuity( p_block->i_pts );
 
     SegmentTimes times;
-    if(p_block->i_dts != VLC_TS_INVALID)
+    if(p_block->i_dts != VLC_TICK_INVALID)
     {
         times = synchronizationReference.second.segment;
         times.offsetBy(p_block->i_dts - times.demux);
-        assert(times.media != VLC_TS_INVALID);
+        assert(times.media != VLC_TICK_INVALID);
     }
 
    AbstractCommand *command = commandsfactory->createEsOutSendCommand( es_id, times, p_block );
@@ -672,7 +672,7 @@ int FakeESOut::esOutControl(int i_query, va_list args)
 
             SegmentTimes times;
 
-            if(synchronizationReference.second.segment.demux != VLC_TS_INVALID)
+            if(synchronizationReference.second.segment.demux != VLC_TICK_INVALID)
             {
                 pcr = fixTimestamp( pcr );
 
@@ -681,7 +681,7 @@ int FakeESOut::esOutControl(int i_query, va_list args)
                 times = synchronizationReference.second.segment;
                 times.offsetBy(pcr - times.demux);
             }
-            else pcr = VLC_TS_INVALID;
+            else pcr = VLC_TICK_INVALID;
 
             AbstractCommand *command = commandsfactory->createEsOutControlPCRCommand( i_group, times, pcr );
             if( likely(command) )
diff --git a/modules/demux/adaptive/test/plumbing/CommandsQueue.cpp b/modules/demux/adaptive/test/plumbing/CommandsQueue.cpp
index 684f615fb572..e3eda309d649 100644
--- a/modules/demux/adaptive/test/plumbing/CommandsQueue.cpp
+++ b/modules/demux/adaptive/test/plumbing/CommandsQueue.cpp
@@ -109,9 +109,9 @@ int CommandsQueue_test()
         Expect(queue.isDraining() == false);
         Expect(queue.isEmpty() == true);
         Expect(queue.getDemuxedAmount(DT(VLC_TS_0)).continuous == 0);
-        Expect(queue.getBufferingLevel().continuous == VLC_TS_INVALID);
-        Expect(queue.getFirstTimes().continuous == VLC_TS_INVALID);
-        Expect(queue.getPCR().continuous == VLC_TS_INVALID);
+        Expect(queue.getBufferingLevel().continuous == VLC_TICK_INVALID);
+        Expect(queue.getFirstTimes().continuous == VLC_TICK_INVALID);
+        Expect(queue.getPCR().continuous == VLC_TICK_INVALID);
         cmd = factory.createEsOutAddCommand(id0);
         queue.Schedule(cmd);
         cmd = factory.createEsOutDelCommand(id0);
@@ -126,7 +126,7 @@ int CommandsQueue_test()
         Expect(queue.isDraining() == false);
         Expect(queue.isEmpty() == true);
         Expect(queue.getDemuxedAmount(DT(VLC_TS_0)).continuous == 0);
-        Expect(queue.getBufferingLevel().continuous == VLC_TS_INVALID);
+        Expect(queue.getBufferingLevel().continuous == VLC_TICK_INVALID);
         Expect(queue.getPCR().continuous == std::numeric_limits<mtime_t>::max());
 
         queue.Abort(true);
@@ -141,10 +141,10 @@ int CommandsQueue_test()
             cmd = factory.createEsOutSendCommand(id0, SegmentTimes(), data);
             queue.Schedule(cmd);
         }
-        Expect(queue.getPCR().continuous == VLC_TS_INVALID);
-        Expect(queue.getFirstTimes().continuous == VLC_TS_INVALID);
+        Expect(queue.getPCR().continuous == VLC_TICK_INVALID);
+        Expect(queue.getFirstTimes().continuous == VLC_TICK_INVALID);
         Expect(queue.getDemuxedAmount(DT(VLC_TS_0)).continuous == 0);
-        Expect(queue.getBufferingLevel().continuous == VLC_TS_INVALID);
+        Expect(queue.getBufferingLevel().continuous == VLC_TICK_INVALID);
         /* commit some */
         cmd = factory.createEsOutControlPCRCommand(0, SegmentTimes(), VLC_TS_0 + vlc_tick_from_sec(8));
         queue.Schedule(cmd);
@@ -152,7 +152,7 @@ int CommandsQueue_test()
         Expect(queue.getBufferingLevel().continuous == VLC_TS_0 + vlc_tick_from_sec(8));
         Expect(queue.getDemuxedAmount(DT(VLC_TS_0 + vlc_tick_from_sec(8))).continuous == 0);
         Expect(queue.getDemuxedAmount(DT(VLC_TS_0 + vlc_tick_from_sec(7))).continuous == vlc_tick_from_sec(1));
-        Expect(queue.getPCR().continuous == VLC_TS_INVALID);
+        Expect(queue.getPCR().continuous == VLC_TICK_INVALID);
         /* extend through PCR */
         cmd = factory.createEsOutControlPCRCommand(0, SegmentTimes(), VLC_TS_0 + vlc_tick_from_sec(10));
         queue.Schedule(cmd);
@@ -299,7 +299,7 @@ int CommandsQueue_test()
             esout.output.pop_front();
             val = esout.output.front();
             Expect(val.first == id);
-            Expect(val.second->i_dts == VLC_TS_INVALID);
+            Expect(val.second->i_dts == VLC_TICK_INVALID);
             block_Release(val.second);
             esout.output.pop_front();
         }
diff --git a/modules/demux/adaptive/test/plumbing/FakeEsOut.cpp b/modules/demux/adaptive/test/plumbing/FakeEsOut.cpp
index 4bd0ce643982..505de072908b 100644
--- a/modules/demux/adaptive/test/plumbing/FakeEsOut.cpp
+++ b/modules/demux/adaptive/test/plumbing/FakeEsOut.cpp
@@ -123,7 +123,7 @@ static int check2(es_out_t *out, struct context *, FakeESOut *fakees)
     try
     {
         vlc_tick_t mediaref = TMS(10000);
-        SegmentTimes segmentTimes(VLC_TS_INVALID, mediaref, mediaref);
+        SegmentTimes segmentTimes(VLC_TICK_INVALID, mediaref, mediaref);
 
         /* setExpectedTimestamp check starting from zero every segment (smooth streaming) */
         fakees->setSegmentStartTimes(segmentTimes);
@@ -212,7 +212,7 @@ static int check1(es_out_t *out, struct context *ctx, FakeESOut *fakees)
     try
     {
         vlc_tick_t mediaref = TMS(10000);
-        SegmentTimes segmentTimes(VLC_TS_INVALID, mediaref, mediaref);
+        SegmentTimes segmentTimes(VLC_TICK_INVALID, mediaref, mediaref);
         fakees->setSegmentStartTimes(segmentTimes);
 
         PCR(TMS(0));
@@ -221,7 +221,7 @@ static int check1(es_out_t *out, struct context *ctx, FakeESOut *fakees)
         PCR(TMS(5000));
 
         Times first = fakees->commandsQueue()->getFirstTimes();
-        Expect(first.continuous != VLC_TS_INVALID);
+        Expect(first.continuous != VLC_TICK_INVALID);
         Expect(first.continuous == TMS(0));
         Expect(first.segment.media == mediaref);
 
@@ -327,10 +327,10 @@ static int check0(es_out_t *out, struct context *, FakeESOut *fakees)
     {
 
         vlc_tick_t mediaref = TMS(10000);
-        SegmentTimes segmentTimes(VLC_TS_INVALID, mediaref, mediaref);
+        SegmentTimes segmentTimes(VLC_TICK_INVALID, mediaref, mediaref);
         fakees->setSegmentStartTimes(segmentTimes);
 
-        Expect(fakees->commandsQueue()->getBufferingLevel().segment.media == VLC_TS_INVALID);
+        Expect(fakees->commandsQueue()->getBufferingLevel().segment.media == VLC_TICK_INVALID);
 
         PCR(TMS(0));
         for(int i=0; i<=5000; i += 1000)
@@ -338,7 +338,7 @@ static int check0(es_out_t *out, struct context *, FakeESOut *fakees)
         PCR(TMS(5000));
 
         Times first = fakees->commandsQueue()->getFirstTimes();
-        Expect(first.continuous != VLC_TS_INVALID);
+        Expect(first.continuous != VLC_TICK_INVALID);
         Expect(first.continuous == TMS(0));
         Expect(first.segment.media == mediaref);
         Expect(mediaref + DMS(5000) == fakees->commandsQueue()->getBufferingLevel().segment.media);
@@ -351,7 +351,7 @@ static int check0(es_out_t *out, struct context *, FakeESOut *fakees)
         //    assert(fakees->commandsQueue()->getBufferingLevel().continuous == TMS(6000));
 
         //    first = fakees->commandsQueue()->getFirstTimes();
-        //    assert(first.continuous != VLC_TS_INVALID);
+        //    assert(first.continuous != VLC_TICK_INVALID);
         //    assert(first.continuous == TMS(0));
         //    assert(first.segment.media == mediaref);
 
@@ -364,7 +364,7 @@ static int check0(es_out_t *out, struct context *, FakeESOut *fakees)
 
 int FakeEsOut_test()
 {
-    struct context ctx = {VLC_TS_INVALID,VLC_TS_INVALID,VLC_TS_INVALID};
+    struct context ctx = {VLC_TICK_INVALID,VLC_TICK_INVALID,VLC_TICK_INVALID};
     struct dropesout dummy = {
             .ctx = &ctx,
             .esout = {
diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 70dd7356f899..4e389ed04e8c 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -239,7 +239,7 @@ static int Demux( demux_t *p_demux )
                 p_sys->b_eof = true;
         }
 
-        if ( p_sys->i_time == VLC_TS_INVALID )
+        if ( p_sys->i_time == VLC_TICK_INVALID )
             p_sys->i_time = p_sys->i_sendtime;
     }
 
@@ -249,7 +249,7 @@ static int Demux( demux_t *p_demux )
     {
         bool b_data = Block_Dequeue( p_demux, p_sys->i_time + CHUNK );
 
-        if( p_sys->i_time != VLC_TS_INVALID )
+        if( p_sys->i_time != VLC_TICK_INVALID )
         {
             p_sys->i_time += CHUNK;
             p_sys->b_pcr_sent = true;
@@ -261,7 +261,7 @@ static int Demux( demux_t *p_demux )
 
         if ( !b_data && p_sys->b_eos )
         {
-            if( p_sys->i_time != VLC_TS_INVALID )
+            if( p_sys->i_time != VLC_TICK_INVALID )
                 es_out_SetPCR( p_demux->out, p_sys->i_time );
 
             /* We end this stream */
@@ -403,8 +403,8 @@ static void SeekPrepare( demux_t *p_demux )
     p_sys->b_eof = false;
     p_sys->b_eos = false;
     p_sys->b_pcr_sent = false;
-    p_sys->i_time = VLC_TS_INVALID;
-    p_sys->i_sendtime = VLC_TS_INVALID;
+    p_sys->i_time = VLC_TICK_INVALID;
+    p_sys->i_sendtime = VLC_TICK_INVALID;
     p_sys->i_preroll_start = ASFPACKET_PREROLL_FROM_CURRENT;
 
     for( int i = 0; i < MAX_ASF_TRACKS ; i++ )
@@ -687,7 +687,7 @@ static bool Block_Dequeue( demux_t *p_demux, vlc_tick_t i_nexttime )
             else
                 p_block->p_next = NULL;
 
-            if( !p_sys->b_pcr_sent && p_sys->i_time != VLC_TS_INVALID )
+            if( !p_sys->b_pcr_sent && p_sys->i_time != VLC_TICK_INVALID )
             {
                 p_sys->b_pcr_sent = true;
                 es_out_SetPCR( p_demux->out, p_sys->i_time );
@@ -786,8 +786,8 @@ static int DemuxInit( demux_t *p_demux )
     demux_sys_t *p_sys = p_demux->p_sys;
 
     /* init context */
-    p_sys->i_time   = VLC_TS_INVALID;
-    p_sys->i_sendtime    = VLC_TS_INVALID;
+    p_sys->i_time   = VLC_TICK_INVALID;
+    p_sys->i_sendtime    = VLC_TICK_INVALID;
     p_sys->i_length = 0;
     p_sys->b_eos = false;
     p_sys->b_eof = false;
diff --git a/modules/demux/asf/asfpacket.c b/modules/demux/asf/asfpacket.c
index bc87f68954b7..c93957a9d619 100644
--- a/modules/demux/asf/asfpacket.c
+++ b/modules/demux/asf/asfpacket.c
@@ -93,7 +93,7 @@ static int DemuxSubPayload( asf_packet_sys_t *p_packetsys,
         return -1;
     }
 
-    p_frag->i_pts = (b_ignore_pts) ? VLC_TS_INVALID : VLC_TS_0 + i_pts;
+    p_frag->i_pts = (b_ignore_pts) ? VLC_TICK_INVALID : VLC_TS_0 + i_pts;
     p_frag->i_dts = VLC_TS_0 + i_dts;
     if ( b_keyframe )
         p_frag->i_flags |= BLOCK_FLAG_TYPE_I;
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index e6615db59827..5075257137c8 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -821,7 +821,7 @@ static int Demux( demux_t *p_demux )
         i_start_time = 0;
 
     if( pkt.dts == (int64_t)AV_NOPTS_VALUE )
-        p_frame->i_dts = VLC_TS_INVALID;
+        p_frame->i_dts = VLC_TICK_INVALID;
     else
     {
         q = lldiv( pkt.dts, p_stream->time_base.den );
@@ -832,7 +832,7 @@ static int Demux( demux_t *p_demux )
     }
 
     if( pkt.pts == (int64_t)AV_NOPTS_VALUE )
-        p_frame->i_pts = VLC_TS_INVALID;
+        p_frame->i_pts = VLC_TICK_INVALID;
     else
     {
         q = lldiv( pkt.pts, p_stream->time_base.den );
@@ -852,14 +852,14 @@ static int Demux( demux_t *p_demux )
         /* FLV and video PTS */
         if( p_stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
             pkt.dts != (int64_t)AV_NOPTS_VALUE && pkt.dts == pkt.pts )
-                p_frame->i_pts = VLC_TS_INVALID;
+                p_frame->i_pts = VLC_TICK_INVALID;
 
         /* Handle broken dts/pts increase with AAC. Duration is correct.
          * sky_the80s_aacplus.flv #8195 */
         if( p_stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
             p_stream->codecpar->codec_id == AV_CODEC_ID_AAC )
         {
-            if( p_track->i_pcr != VLC_TS_INVALID &&
+            if( p_track->i_pcr != VLC_TICK_INVALID &&
                 p_track->i_pcr + p_frame->i_length > p_frame->i_dts )
             {
                 p_frame->i_dts = p_frame->i_pts = p_track->i_pcr + p_frame->i_length;
@@ -870,7 +870,7 @@ static int Demux( demux_t *p_demux )
     msg_Dbg( p_demux, "tk[%d] dts=%"PRId64" pts=%"PRId64,
              pkt.stream_index, p_frame->i_dts, p_frame->i_pts );
 #endif
-    if( p_frame->i_dts > VLC_TS_INVALID && p_track->p_es != NULL )
+    if( p_frame->i_dts > VLC_TICK_INVALID && p_track->p_es != NULL )
         p_track->i_pcr = p_frame->i_dts;
 
     int64_t i_ts_max = INT64_MIN;
@@ -884,7 +884,7 @@ static int Demux( demux_t *p_demux )
     for( unsigned i = 0; i < p_sys->i_tracks; i++ )
     {
         if( p_sys->tracks[i].p_es != NULL &&
-                p_sys->tracks[i].i_pcr > VLC_TS_INVALID &&
+                p_sys->tracks[i].i_pcr > VLC_TICK_INVALID &&
                 p_sys->tracks[i].i_pcr + 10 * CLOCK_FREQ >= i_ts_max )
             i_ts_min = __MIN( i_ts_min, p_sys->tracks[i].i_pcr );
     }
@@ -931,15 +931,15 @@ static void ResetTime( demux_t *p_demux, int64_t i_time )
     demux_sys_t *p_sys = p_demux->p_sys;
 
     if( p_sys->ic->start_time == (int64_t)AV_NOPTS_VALUE || i_time < 0 )
-        i_time = VLC_TS_INVALID;
+        i_time = VLC_TICK_INVALID;
     else if( i_time == 0 )
         i_time = 1;
 
     p_sys->i_pcr = i_time;
     for( unsigned i = 0; i < p_sys->i_tracks; i++ )
-        p_sys->tracks[i].i_pcr = VLC_TS_INVALID;
+        p_sys->tracks[i].i_pcr = VLC_TICK_INVALID;
 
-    if( i_time > VLC_TS_INVALID )
+    if( i_time > VLC_TICK_INVALID )
     {
         es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_time );
         UpdateSeekPoint( p_demux, i_time );
diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 868bdcf12335..fc03ea30effd 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -1054,7 +1054,7 @@ static void AVI_SendFrame( demux_t *p_demux, avi_track_t *tk, block_t *p_frame )
     else
     {
         p_frame->i_dts = p_frame->i_pts;
-        p_frame->i_pts = VLC_TS_INVALID;
+        p_frame->i_pts = VLC_TICK_INVALID;
     }
 
     if( tk->i_dv_audio_rate )
diff --git a/modules/demux/caf.c b/modules/demux/caf.c
index 2651ae184e5c..68efd3c7e8c0 100644
--- a/modules/demux/caf.c
+++ b/modules/demux/caf.c
@@ -333,7 +333,7 @@ static int FrameSpanAddDescription( demux_t *p_demux, uint64_t i_desc_offset, fr
 static inline vlc_tick_t FrameSpanGetTime( frame_span_t *span, uint32_t i_sample_rate )
 {
     if( !i_sample_rate )
-        return VLC_TS_INVALID;
+        return VLC_TICK_INVALID;
 
     return ( span->i_samples * CLOCK_FREQ ) / i_sample_rate + VLC_TS_0;
 }
diff --git a/modules/demux/flac.c b/modules/demux/flac.c
index 432f711aaf1e..9c2f33cab274 100644
--- a/modules/demux/flac.c
+++ b/modules/demux/flac.c
@@ -145,7 +145,7 @@ static int Open( vlc_object_t * p_this )
     p_sys->p_packetizer = NULL;
     p_sys->p_meta = NULL;
     p_sys->i_length = 0;
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
     p_sys->b_stream_info = false;
     p_sys->p_es = NULL;
     p_sys->p_current_block = NULL;
@@ -227,7 +227,7 @@ static block_t *GetPacketizedBlock( decoder_t *p_packetizer,
     {
         if( p_block->i_buffer >= FLAC_HEADER_SIZE_MIN && p_block->i_buffer < INT_MAX )
         {
-            struct flac_header_info headerinfo = { .i_pts = VLC_TS_INVALID };
+            struct flac_header_info headerinfo = { .i_pts = VLC_TICK_INVALID };
             int i_ret = FLAC_ParseSyncInfo( p_block->p_buffer, p_block->i_buffer,
                                             streaminfo, NULL, &headerinfo );
             assert( i_ret != 0 ); /* Same as packetizer */
@@ -252,7 +252,7 @@ static void FlushPacketizer( decoder_t *p_packetizer )
 
 static void Reset( demux_sys_t *p_sys )
 {
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
 
     FlushPacketizer( p_sys->p_packetizer );
     if( p_sys->p_current_block )
@@ -372,7 +372,7 @@ static int Demux( demux_t *p_demux )
         p_sys->p_current_block->i_flags = p_sys->i_next_block_flags;
         p_sys->i_next_block_flags = 0;
         p_sys->p_current_block->i_pts =
-        p_sys->p_current_block->i_dts = p_sys->b_start ? VLC_TS_0 : VLC_TS_INVALID;
+        p_sys->p_current_block->i_dts = p_sys->b_start ? VLC_TS_0 : VLC_TICK_INVALID;
     }
 
     while( (p_block_out = GetPacketizedBlock( p_sys->p_packetizer,
@@ -388,7 +388,7 @@ static int Demux( demux_t *p_demux )
             p_block_out->p_next = NULL;
 
             /* set PCR */
-            if( unlikely(p_sys->i_pts == VLC_TS_INVALID) )
+            if( unlikely(p_sys->i_pts == VLC_TICK_INVALID) )
                 es_out_SetPCR( p_demux->out, __MAX(p_block_out->i_dts - 1, VLC_TS_0) );
 
             p_sys->i_pts = p_block_out->i_dts;
diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp
index 5760f55c2143..2b2117b88d61 100644
--- a/modules/demux/hls/playlist/Parser.cpp
+++ b/modules/demux/hls/playlist/Parser.cpp
@@ -292,7 +292,7 @@ void M3U8Parser::parseSegments(vlc_object_t *, HLSRepresentation *rep, const std
 
     vlc_tick_t totalduration = 0;
     vlc_tick_t nzStartTime = 0;
-    vlc_tick_t absReferenceTime = VLC_TS_INVALID;
+    vlc_tick_t absReferenceTime = VLC_TICK_INVALID;
     uint64_t sequenceNumber = 0;
     uint64_t discontinuitySequence = 0;
     bool discontinuity = false;
@@ -351,7 +351,7 @@ void M3U8Parser::parseSegments(vlc_object_t *, HLSRepresentation *rep, const std
                 segment->startTime.Set(timescale.ToScaled(nzStartTime));
                 nzStartTime += nzDuration;
                 totalduration += nzDuration;
-                if(absReferenceTime > VLC_TS_INVALID)
+                if(absReferenceTime > VLC_TICK_INVALID)
                 {
                     segment->setDisplayTime(absReferenceTime);
                     absReferenceTime += nzDuration;
@@ -393,7 +393,7 @@ void M3U8Parser::parseSegments(vlc_object_t *, HLSRepresentation *rep, const std
                 absReferenceTime = VLC_TS_0 +
                         UTCTime(static_cast<const SingleValueTag *>(tag)->getValue().value).mtime();
                 /* Reverse apply UTC timespec from first discont */
-                if(segmentstoappend.size() && segmentstoappend.back()->getDisplayTime() == VLC_TS_INVALID)
+                if(segmentstoappend.size() && segmentstoappend.back()->getDisplayTime() == VLC_TICK_INVALID)
                 {
                     vlc_tick_t tempTime = absReferenceTime;
                     for(auto it = segmentstoappend.crbegin(); it != segmentstoappend.crend(); ++it)
diff --git a/modules/demux/image.c b/modules/demux/image.c
index 0000da764bc8..ca582a9f9ced 100644
--- a/modules/demux/image.c
+++ b/modules/demux/image.c
@@ -192,7 +192,7 @@ static int Demux(demux_t *demux)
 
     vlc_tick_t deadline;
     const vlc_tick_t pts_first = sys->pts_origin + date_Get(&sys->pts);
-    if (sys->pts_next > VLC_TS_INVALID) {
+    if (sys->pts_next > VLC_TICK_INVALID) {
         deadline = sys->pts_next;
     } else if (sys->is_realtime) {
         deadline = mdate();
@@ -265,7 +265,7 @@ static int Control(demux_t *demux, int query, va_list args)
     }
     case DEMUX_SET_NEXT_DEMUX_TIME: {
         int64_t pts_next = VLC_TS_0 + va_arg(args, int64_t);
-        if (sys->pts_next <= VLC_TS_INVALID)
+        if (sys->pts_next <= VLC_TICK_INVALID)
             sys->pts_origin = pts_next;
         sys->pts_next = pts_next;
         return VLC_SUCCESS;
@@ -722,7 +722,7 @@ static int Open(vlc_object_t *object)
     sys->duration    = CLOCK_FREQ * var_InheritFloat(demux, "image-duration");
     sys->is_realtime = var_InheritBool(demux, "image-realtime");
     sys->pts_origin  = sys->is_realtime ? mdate() : 0;
-    sys->pts_next    = VLC_TS_INVALID;
+    sys->pts_next    = VLC_TICK_INVALID;
     date_Init(&sys->pts, fmt.video.i_frame_rate, fmt.video.i_frame_rate_base);
     date_Set(&sys->pts, 0);
 
diff --git a/modules/demux/mkv/demux.hpp b/modules/demux/mkv/demux.hpp
index 45029482ed54..07b236914088 100644
--- a/modules/demux/mkv/demux.hpp
+++ b/modules/demux/mkv/demux.hpp
@@ -331,8 +331,8 @@ struct demux_sys_t
 public:
     demux_sys_t( demux_t & demux )
         :demuxer(demux)
-        ,i_pts(VLC_TS_INVALID)
-        ,i_pcr(VLC_TS_INVALID)
+        ,i_pts(VLC_TICK_INVALID)
+        ,i_pcr(VLC_TICK_INVALID)
         ,i_start_pts(VLC_TS_0)
         ,i_mk_chapter_time(0)
         ,meta(NULL)
diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 7c7ab57dcb94..4768dccba3f5 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -820,9 +820,9 @@ bool matroska_segment_c::Seek( demux_t &demuxer, vlc_tick_t i_absolute_mk_date,
         mkv_track_t &track = *it->second;
 
         track.i_skip_until_fpos = std::numeric_limits<uint64_t>::max();
-        if( track.i_last_dts > VLC_TS_INVALID )
+        if( track.i_last_dts > VLC_TICK_INVALID )
             track.b_discontinuity = true;
-        track.i_last_dts        = VLC_TS_INVALID;
+        track.i_last_dts        = VLC_TICK_INVALID;
 
         bool selected;
         if (track.p_es == NULL)
@@ -888,7 +888,7 @@ bool matroska_segment_c::Seek( demux_t &demuxer, vlc_tick_t i_absolute_mk_date,
 
     // propogate seek information //
 
-    sys.i_pcr           = VLC_TS_INVALID;
+    sys.i_pcr           = VLC_TICK_INVALID;
     sys.i_pts           = VLC_TS_0 + i_mk_seek_time + i_mk_time_offset;
     if (b_accurate)
         sys.i_start_pts = VLC_TS_0 + i_absolute_mk_date;
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 9dac3f39e1f7..667eb890aca3 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -334,7 +334,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             if( p_sys->f_duration > 0.0 )
                 *pi64 = static_cast<int64_t>( p_sys->f_duration * 1000 );
             else
-                *pi64 = VLC_TS_INVALID;
+                *pi64 = VLC_TICK_INVALID;
             return VLC_SUCCESS;
 
         case DEMUX_GET_POSITION:
@@ -512,7 +512,7 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
         return;
     }
 
-    if (i_pts != VLC_TS_INVALID)
+    if (i_pts != VLC_TICK_INVALID)
         i_pts += p_segment->pcr_shift - track.i_codec_delay;
 
     if ( track.fmt.i_cat != DATA_ES )
@@ -523,7 +523,7 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
         if( !b )
         {
             if( track.fmt.i_cat == VIDEO_ES || track.fmt.i_cat == AUDIO_ES )
-                track.i_last_dts = VLC_TS_INVALID;
+                track.i_last_dts = VLC_TICK_INVALID;
             return;
         }
     }
@@ -603,7 +603,7 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
             block_Release(p_block);
             i_pts = ( track.i_default_duration )?
                 i_pts + ( vlc_tick_t )track.i_default_duration:
-                VLC_TS_INVALID;
+                VLC_TICK_INVALID;
             continue;
          }
 
@@ -679,7 +679,7 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
             // correct timestamping when B frames are used
             if( track.b_dts_only )
             {
-                p_block->i_pts = VLC_TS_INVALID;
+                p_block->i_pts = VLC_TICK_INVALID;
                 p_block->i_dts = i_pts;
             }
             else if( track.b_pts_only )
@@ -693,7 +693,7 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
                 // condition when the DTS is correct (keyframe or B frame == NOT P frame)
                 if ( b_key_picture || b_discardable_picture )
                         p_block->i_dts = p_block->i_pts;
-                else if ( track.i_last_dts == VLC_TS_INVALID )
+                else if ( track.i_last_dts == VLC_TICK_INVALID )
                     p_block->i_dts = i_pts;
                 else
                     p_block->i_dts = std::min( i_pts, track.i_last_dts + ( vlc_tick_t )track.i_default_duration );
@@ -705,7 +705,7 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
         /* use time stamp only for first block */
         i_pts = ( track.i_default_duration )?
                  i_pts + ( vlc_tick_t )track.i_default_duration:
-                 ( track.fmt.b_packetized ) ? VLC_TS_INVALID : i_pts + 1;
+                 ( track.fmt.b_packetized ) ? VLC_TICK_INVALID : i_pts + 1;
     }
 }
 
@@ -839,7 +839,7 @@ mkv_track_t::mkv_track_t(enum es_format_category_e es_cat) :
   ,b_no_duration(false)
   ,i_default_duration(0)
   ,f_timecodescale(1.0)
-  ,i_last_dts(VLC_TS_INVALID)
+  ,i_last_dts(VLC_TICK_INVALID)
   ,i_skip_until_fpos(std::numeric_limits<uint64_t>::max())
   ,f_fps(0)
   ,p_es(NULL)
diff --git a/modules/demux/mkv/util.cpp b/modules/demux/mkv/util.cpp
index c5642fb1322b..16f4f1b62456 100644
--- a/modules/demux/mkv/util.cpp
+++ b/modules/demux/mkv/util.cpp
@@ -170,7 +170,7 @@ void handle_real_audio(demux_t * p_demux, mkv_track_t * p_tk, block_t * p_blk, v
     Cook_PrivateTrackData * p_sys = (Cook_PrivateTrackData *) p_tk->p_sys;
     size_t size = p_blk->i_buffer;
 
-    if( p_tk->i_last_dts == VLC_TS_INVALID )
+    if( p_tk->i_last_dts == VLC_TICK_INVALID )
     {
         for( size_t i = 0; i < p_sys->i_subpackets; i++)
             if( p_sys->p_subpackets[i] )
@@ -212,8 +212,8 @@ void handle_real_audio(demux_t * p_demux, mkv_track_t * p_tk, block_t * p_blk, v
                 return;
 
             memcpy( p_block->p_buffer, p_frame, p_sys->i_subpacket_size );
-            p_block->i_dts = VLC_TS_INVALID;
-            p_block->i_pts = VLC_TS_INVALID;
+            p_block->i_dts = VLC_TICK_INVALID;
+            p_block->i_pts = VLC_TICK_INVALID;
             if( !p_sys->i_subpacket )
             {
                 p_tk->i_last_dts =
@@ -315,7 +315,7 @@ int UpdatePCR( demux_t * p_demux )
     demux_sys_t *p_sys = (demux_sys_t *)p_demux->p_sys;
     matroska_segment_c *p_segment = p_sys->p_current_vsegment->CurrentSegment();
 
-    int64_t i_pcr = VLC_TS_INVALID;
+    int64_t i_pcr = VLC_TICK_INVALID;
 
     typedef matroska_segment_c::tracks_map_t tracks_map_t;
 
@@ -323,19 +323,19 @@ int UpdatePCR( demux_t * p_demux )
     {
         mkv_track_t &track = *it->second;
 
-        if( track.i_last_dts == VLC_TS_INVALID )
+        if( track.i_last_dts == VLC_TICK_INVALID )
             continue;
 
         if( track.fmt.i_cat != VIDEO_ES && track.fmt.i_cat != AUDIO_ES )
             continue;
 
-        if( track.i_last_dts < i_pcr || i_pcr <= VLC_TS_INVALID )
+        if( track.i_last_dts < i_pcr || i_pcr <= VLC_TICK_INVALID )
         {
             i_pcr = track.i_last_dts;
         }
     }
 
-    if( i_pcr > VLC_TS_INVALID && i_pcr > p_sys->i_pcr )
+    if( i_pcr > VLC_TICK_INVALID && i_pcr > p_sys->i_pcr )
     {
         if( es_out_SetPCR( p_demux->out, i_pcr ) )
         {
@@ -360,7 +360,7 @@ void send_Block( demux_t * p_demux, mkv_track_t * p_tk, block_t * p_block, unsig
                              p_tk->pi_chan_table, p_tk->fmt.i_codec );
     }
 
-    if( p_block->i_dts > VLC_TS_INVALID &&
+    if( p_block->i_dts > VLC_TICK_INVALID &&
         ( p_tk->fmt.i_cat == VIDEO_ES || p_tk->fmt.i_cat == AUDIO_ES ) )
     {
         p_tk->i_last_dts = p_block->i_dts;
@@ -378,7 +378,7 @@ void send_Block( demux_t * p_demux, mkv_track_t * p_tk, block_t * p_block, unsig
         p_tk->b_discontinuity = false;
     }
 
-    if ( p_sys->i_pcr == VLC_TS_INVALID )
+    if ( p_sys->i_pcr == VLC_TICK_INVALID )
         UpdatePCR( p_demux );
 
     es_out_Send( p_demux->out, p_tk->p_es, p_block);
diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index 21c78760f407..2825c268ba46 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -437,7 +437,7 @@ bool virtual_segment_c::UpdateCurrentToChapter( demux_t & demux )
             return true;
     }
 
-    if ( sys.i_pts != VLC_TS_INVALID )
+    if ( sys.i_pts != VLC_TICK_INVALID )
     {
         if ( p_current_vchapter != NULL && p_current_vchapter->ContainsTimestamp( sys.i_pts - VLC_TS_0 ))
             p_cur_vchapter = p_current_vchapter;
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 3b0aeb675cc5..e1f64deaec2f 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -1317,7 +1317,7 @@ static int DemuxTrack( demux_t *p_demux, mp4_track_t *tk, uint64_t i_readpos,
             }
 
             /* !important! Ensure clock is set before sending data */
-            if( p_demux->p_sys->i_pcr == VLC_TS_INVALID )
+            if( p_demux->p_sys->i_pcr == VLC_TICK_INVALID )
             {
                 es_out_SetPCR( p_demux->out, VLC_TS_0 + i_current_nzdts );
                 p_demux->p_sys->i_pcr = VLC_TS_0 + i_current_nzdts;
@@ -1331,7 +1331,7 @@ static int DemuxTrack( demux_t *p_demux, mp4_track_t *tk, uint64_t i_readpos,
             else if( tk->fmt.i_cat != VIDEO_ES )
                 p_block->i_pts = p_block->i_dts;
             else
-                p_block->i_pts = VLC_TS_INVALID;
+                p_block->i_pts = VLC_TICK_INVALID;
 
             MP4_Block_Send( p_demux, tk, p_block );
         }
@@ -1388,7 +1388,7 @@ static int DemuxMoov( demux_t *p_demux )
     const vlc_tick_t i_nztime = MP4_GetMoviePTS( p_sys );
 
     /* We demux/set pcr, even without selected tracks, (empty edits, ...) */
-    if( p_sys->i_pcr != VLC_TS_INVALID /* not after a seek */ )
+    if( p_sys->i_pcr != VLC_TICK_INVALID /* not after a seek */ )
     {
         bool b_eof = true;
         for( i_track = 0; i_track < p_sys->i_tracks; i_track++ )
@@ -1466,7 +1466,7 @@ static int DemuxMoov( demux_t *p_demux )
     }
 
     p_sys->i_nztime += DEMUX_INCREMENT;
-    if( p_sys->i_pcr > VLC_TS_INVALID )
+    if( p_sys->i_pcr > VLC_TICK_INVALID )
     {
         p_sys->i_pcr = VLC_TS_0 + p_sys->i_nztime;
         es_out_SetPCR( p_demux->out, p_sys->i_pcr );
@@ -1551,7 +1551,7 @@ static int Seek( demux_t *p_demux, vlc_tick_t i_date, bool b_accurate )
     MP4ASF_ResetFrames( p_sys );
     /* update global time */
     p_sys->i_nztime = i_start;
-    p_sys->i_pcr  = VLC_TS_INVALID;
+    p_sys->i_pcr  = VLC_TICK_INVALID;
 
     if( b_accurate )
         es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME, i_date );
@@ -1645,7 +1645,7 @@ static int FragSeekLoadFragment( demux_t *p_demux, uint32_t i_moox, stime_t i_mo
         p_sys->context.i_lastseqnumber = FragGetMoofSequenceNumber( p_moox );
 
         p_sys->i_nztime = FragGetDemuxTimeFromTracksTime( p_sys );
-        p_sys->i_pcr = VLC_TS_INVALID;
+        p_sys->i_pcr = VLC_TICK_INVALID;
     }
 
     msg_Dbg( p_demux, "seeked to %4.4s at pos %" PRIu64, (char *) &i_moox, p_moox->i_pos );
@@ -1800,7 +1800,7 @@ static int FragSeekToTime( demux_t *p_demux, vlc_tick_t i_nztime, bool b_accurat
         return VLC_EGENERIC;
     }
 
-    p_sys->i_pcr  = VLC_TS_INVALID;
+    p_sys->i_pcr  = VLC_TICK_INVALID;
 
     for( unsigned i=0; i<p_sys->i_tracks; i++ )
     {
@@ -1808,7 +1808,7 @@ static int FragSeekToTime( demux_t *p_demux, vlc_tick_t i_nztime, bool b_accurat
         {
             MP4_TrackSeek( p_demux, &p_sys->track[i], i_sync_time );
             p_sys->i_nztime = i_sync_time;
-            p_sys->i_pcr  = VLC_TS_INVALID;
+            p_sys->i_pcr  = VLC_TICK_INVALID;
         }
         else
         {
@@ -4429,7 +4429,7 @@ static int FragDemuxTrack( demux_t *p_demux, mp4_track_t *p_track,
         {
             p_block->i_dts = VLC_TS_0 + MP4_rescale( i_dts, p_track->i_timescale, CLOCK_FREQ );
             if( p_track->fmt.i_cat == VIDEO_ES && !( p_trun->i_flags & MP4_TRUN_SAMPLE_TIME_OFFSET ) )
-                p_block->i_pts = VLC_TS_INVALID;
+                p_block->i_pts = VLC_TICK_INVALID;
             else
                 p_block->i_pts = VLC_TS_0 + MP4_rescale( i_pts, p_track->i_timescale, CLOCK_FREQ );
             p_block->i_length = MP4_rescale( dur, p_track->i_timescale, CLOCK_FREQ );
@@ -4461,7 +4461,7 @@ static int DemuxMoof( demux_t *p_demux )
     const vlc_tick_t i_nztime = MP4_GetMoviePTS( p_sys );
 
     /* !important! Ensure clock is set before sending data */
-    if( p_sys->i_pcr == VLC_TS_INVALID )
+    if( p_sys->i_pcr == VLC_TICK_INVALID )
         es_out_SetPCR( p_demux->out, VLC_TS_0 + i_nztime );
 
     /* Set per track read state */
@@ -5003,7 +5003,7 @@ static int DemuxFrag( demux_t *p_demux )
                     if( b_discontinuity )
                     {
                         p_sys->i_nztime = FragGetDemuxTimeFromTracksTime( p_sys );
-                        p_sys->i_pcr = VLC_TS_INVALID;
+                        p_sys->i_pcr = VLC_TICK_INVALID;
                     }
                     /* !Prepare chunk */
                 }
diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index 249674853fa8..328cff70ac64 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -329,10 +329,10 @@ static int Demux( demux_t *p_demux )
         /* Correct timestamp */
         if( p_sys->p_packetizer->fmt_out.i_cat == VIDEO_ES )
         {
-            if( p_block_out->i_pts <= VLC_TS_INVALID &&
-                p_block_out->i_dts <= VLC_TS_INVALID )
+            if( p_block_out->i_pts <= VLC_TICK_INVALID &&
+                p_block_out->i_dts <= VLC_TICK_INVALID )
                 p_block_out->i_dts = VLC_TS_0 + p_sys->i_pts + 1000000 / p_sys->f_fps;
-            if( p_block_out->i_dts > VLC_TS_INVALID )
+            if( p_block_out->i_dts > VLC_TICK_INVALID )
                 p_sys->i_pts = p_block_out->i_dts - VLC_TS_0;
         }
         else
@@ -340,11 +340,11 @@ static int Demux( demux_t *p_demux )
             p_sys->i_pts = p_block_out->i_pts - VLC_TS_0;
         }
 
-        if( p_block_out->i_pts > VLC_TS_INVALID )
+        if( p_block_out->i_pts > VLC_TICK_INVALID )
         {
             p_block_out->i_pts += p_sys->i_time_offset;
         }
-        if( p_block_out->i_dts > VLC_TS_INVALID )
+        if( p_block_out->i_dts > VLC_TICK_INVALID )
         {
             p_block_out->i_dts += p_sys->i_time_offset;
             es_out_SetPCR( p_demux->out, p_block_out->i_dts );
@@ -502,7 +502,7 @@ static bool Parse( demux_t *p_demux, block_t **pp_output )
             swab( p_block_in->p_buffer, p_block_in->p_buffer, p_block_in->i_buffer );
         }
 
-        p_block_in->i_pts = p_block_in->i_dts = p_sys->b_start || p_sys->b_initial_sync_failed ? VLC_TS_0 : VLC_TS_INVALID;
+        p_block_in->i_pts = p_block_in->i_dts = p_sys->b_start || p_sys->b_initial_sync_failed ? VLC_TS_0 : VLC_TICK_INVALID;
     }
     p_sys->b_initial_sync_failed = p_sys->b_start; /* Only try to resync once */
 
diff --git a/modules/demux/mpeg/h26x.c b/modules/demux/mpeg/h26x.c
index f74f0ac40440..24f2628d7e50 100644
--- a/modules/demux/mpeg/h26x.c
+++ b/modules/demux/mpeg/h26x.c
@@ -456,13 +456,13 @@ static int Demux( demux_t *p_demux)
             vlc_tick_t dts = date_Increment( &dtsdate, 2 );
 
             p_block_out->i_dts = dts;
-            if( p_block_out->i_pts != VLC_TS_INVALID )
+            if( p_block_out->i_pts != VLC_TICK_INVALID )
                 p_block_out->i_pts = dts + dtsdiff;
 
             if( p_block_in )
             {
                 p_block_in->i_dts = date_Get( &p_sys->feed_dts );
-                p_block_in->i_pts = VLC_TS_INVALID;
+                p_block_in->i_pts = VLC_TICK_INVALID;
             }
 
             if( p_sys->p_es == NULL )
diff --git a/modules/demux/mpeg/mpgv.c b/modules/demux/mpeg/mpgv.c
index 47be270dbe77..08069b075d83 100644
--- a/modules/demux/mpeg/mpgv.c
+++ b/modules/demux/mpeg/mpgv.c
@@ -158,7 +158,7 @@ static int Demux( demux_t *p_demux )
     if( p_block_in )
     {
         p_block_in->i_pts =
-        p_block_in->i_dts = ( p_sys->b_start ) ? VLC_TS_0 : VLC_TS_INVALID;
+        p_block_in->i_dts = ( p_sys->b_start ) ? VLC_TS_0 : VLC_TICK_INVALID;
     }
 
     while( (p_block_out = p_sys->p_packetizer->pf_packetize( p_sys->p_packetizer,
diff --git a/modules/demux/mpeg/ps.c b/modules/demux/mpeg/ps.c
index 4e6c91a05a0f..1158ea5c96a0 100644
--- a/modules/demux/mpeg/ps.c
+++ b/modules/demux/mpeg/ps.c
@@ -301,7 +301,7 @@ static int Probe( demux_t *p_demux, bool b_end )
     {
         ps_track_t *tk = &p_sys->tk[ps_id_to_tk(i_id)];
         if( !ps_pkt_parse_pes( VLC_OBJECT(p_demux), p_pkt, tk->i_skip ) &&
-             p_pkt->i_pts > VLC_TS_INVALID )
+             p_pkt->i_pts > VLC_TICK_INVALID )
         {
             if( b_end && p_pkt->i_pts > tk->i_last_pts )
             {
@@ -394,7 +394,7 @@ static void NotifyDiscontinuity( ps_track_t *p_tk, es_out_t *out )
 
 static void CheckPCR( demux_sys_t *p_sys, es_out_t *out, vlc_tick_t i_scr )
 {
-    if( p_sys->i_scr > VLC_TS_INVALID &&
+    if( p_sys->i_scr > VLC_TICK_INVALID &&
         llabs( p_sys->i_scr - i_scr ) > CLOCK_FREQ )
         NotifyDiscontinuity( p_sys->tk, out );
 }
@@ -574,7 +574,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_TS_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 > 2 * CLOCK_FREQ )
                 {
                     msg_Warn( p_demux, "Incorrect SCR timing offset by of %"PRId64 "ms, disabling",
                                        tk->i_first_pts - p_sys->i_pack_scr / 1000 );
@@ -607,7 +607,7 @@ static int Demux( demux_t *p_demux )
 
                 if( ((!b_new && !p_sys->b_have_pack) || p_sys->b_bad_scr) &&
                     p_sys->i_scr_track_id == tk->i_id &&
-                    p_pkt->i_pts > VLC_TS_INVALID )
+                    p_pkt->i_pts > VLC_TICK_INVALID )
                 {
                     /* A hack to sync the A/V on PES files. */
                     msg_Dbg( p_demux, "force SCR: %"PRId64, p_pkt->i_pts );
@@ -619,7 +619,7 @@ static int Demux( demux_t *p_demux )
                 }
 
                 if( tk->fmt.i_codec == VLC_CODEC_TELETEXT &&
-                    p_pkt->i_pts <= VLC_TS_INVALID && p_sys->i_scr >= 0 )
+                    p_pkt->i_pts <= VLC_TICK_INVALID && p_sys->i_scr >= 0 )
                 {
                     /* Teletext may have missing PTS (ETSI EN 300 472 Annexe A)
                      * In this case use the last SCR + 40ms */
diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index a0df7b5f29de..3c9a48412593 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -691,7 +691,7 @@ static int Demux( demux_t *p_demux )
 
         /* Adaptation field cannot be scrambled */
         vlc_tick_t i_pcr = GetPCR( p_pkt );
-        if( i_pcr > VLC_TS_INVALID )
+        if( i_pcr > VLC_TICK_INVALID )
             PCRHandle( p_demux, p_pid, i_pcr );
 
         /* Probe streams to build PAT/PMT after MIN_PAT_INTERVAL in case we don't see any PAT */
@@ -930,7 +930,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         if( !p_sys->b_ignore_time_for_positions &&
              p_pmt &&
-             p_pmt->pcr.i_first > -1 && p_pmt->i_last_dts > VLC_TS_INVALID &&
+             p_pmt->pcr.i_first > -1 && p_pmt->i_last_dts > VLC_TICK_INVALID &&
              p_pmt->pcr.i_current > -1 )
         {
             double i_length = TimeStampWrapAround( p_pmt->pcr.i_first,
@@ -975,7 +975,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         }
 
         if( !p_sys->b_ignore_time_for_positions && b_bool && p_pmt &&
-             p_pmt->pcr.i_first > -1 && p_pmt->i_last_dts > VLC_TS_INVALID &&
+             p_pmt->pcr.i_first > -1 && p_pmt->i_last_dts > VLC_TICK_INVALID &&
              p_pmt->pcr.i_current > -1 )
         {
             int64_t i_length = TimeStampWrapAround( p_pmt->pcr.i_first,
@@ -1050,7 +1050,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         if( !p_sys->b_ignore_time_for_positions &&
             p_pmt &&
-           ( p_pmt->pcr.i_first > -1 || p_pmt->pcr.i_first_dts > VLC_TS_INVALID ) &&
+           ( p_pmt->pcr.i_first > -1 || p_pmt->pcr.i_first_dts > VLC_TICK_INVALID ) &&
              p_pmt->i_last_dts > 0 )
         {
             int64_t i_start = (p_pmt->pcr.i_first > -1) ? p_pmt->pcr.i_first :
@@ -1339,19 +1339,19 @@ static block_t * ConvertPESBlock( demux_t *p_demux, ts_es_t *p_es,
     }
     else if( p_es->fmt.i_codec == VLC_CODEC_TELETEXT )
     {
-        if( p_block->i_pts <= VLC_TS_INVALID )
+        if( p_block->i_pts <= VLC_TICK_INVALID )
         {
             /* Teletext may have missing PTS (ETSI EN 300 472 Annexe A)
              * In this case use the last PCR + 40ms */
             vlc_tick_t i_pcr = p_es->p_program->pcr.i_current;
-            if( i_pcr > VLC_TS_INVALID )
+            if( i_pcr > VLC_TICK_INVALID )
                 p_block->i_pts = FROM_SCALE(i_pcr) + 40000;
         }
     }
     else if( p_es->fmt.i_codec == VLC_CODEC_ARIB_A ||
              p_es->fmt.i_codec == VLC_CODEC_ARIB_C )
     {
-        if( p_block->i_pts <= VLC_TS_INVALID )
+        if( p_block->i_pts <= VLC_TICK_INVALID )
         {
             if( i_pes_size > 0 && p_block->i_buffer > i_pes_size )
             {
@@ -1600,16 +1600,16 @@ static void ParsePESDataChain( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes,
                     continue;
                 }
 
-                if ( p_pmt->pcr.b_disable && p_block->i_dts > VLC_TS_INVALID &&
+                if ( p_pmt->pcr.b_disable && p_block->i_dts > VLC_TICK_INVALID &&
                      ( p_pmt->i_pid_pcr == pid->i_pid || p_pmt->i_pid_pcr == 0x1FFF ) )
                 {
                     ProgramSetPCR( p_demux, p_pmt, TO_SCALE(p_block->i_dts) - 120000 );
                 }
 
                 /* Compute PCR/DTS offset if any */
-                int64_t i_pcrref = i_append_pcr > VLC_TS_INVALID ? i_append_pcr : p_pmt->pcr.i_first;
-                if( p_pmt->pcr.i_pcroffset == -1 && p_block->i_dts > VLC_TS_INVALID &&
-                    i_pcrref > VLC_TS_INVALID &&
+                int64_t i_pcrref = i_append_pcr > VLC_TICK_INVALID ? i_append_pcr : p_pmt->pcr.i_first;
+                if( p_pmt->pcr.i_pcroffset == -1 && p_block->i_dts > VLC_TICK_INVALID &&
+                    i_pcrref > VLC_TICK_INVALID &&
                    (p_es->fmt.i_cat == VIDEO_ES || p_es->fmt.i_cat == AUDIO_ES) )
                 {
                     int64_t i_dts27 = TO_SCALE(p_block->i_dts);
@@ -1627,9 +1627,9 @@ static void ParsePESDataChain( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes,
 
                 if( p_pmt->pcr.i_pcroffset != -1 )
                 {
-                    if( p_block->i_dts > VLC_TS_INVALID )
+                    if( p_block->i_dts > VLC_TICK_INVALID )
                         p_block->i_dts += FROM_SCALE_NZ(p_pmt->pcr.i_pcroffset);
-                    if( p_block->i_pts > VLC_TS_INVALID )
+                    if( p_block->i_pts > VLC_TICK_INVALID )
                         p_block->i_pts += FROM_SCALE_NZ(p_pmt->pcr.i_pcroffset);
                 }
 
@@ -2187,7 +2187,7 @@ static void ProgramSetPCR( demux_t *p_demux, ts_pmt_t *p_pmt, vlc_tick_t i_pcr )
             {
                 ts_pid_t *p_pid = p_opmt->e_streams.p_elems[j];
                 block_t *p_block = p_pid->u.p_stream->prepcr.p_head;
-                while( p_block && p_block->i_dts == VLC_TS_INVALID )
+                while( p_block && p_block->i_dts == VLC_TICK_INVALID )
                     p_block = p_block->p_next;
 
                 if( p_block && ( i_mindts == -1 || p_block->i_dts < i_mindts ) )
@@ -2195,7 +2195,7 @@ static void ProgramSetPCR( demux_t *p_demux, ts_pmt_t *p_pmt, vlc_tick_t i_pcr )
             }
         }
 
-        if( i_mindts > VLC_TS_INVALID )
+        if( i_mindts > VLC_TICK_INVALID )
         {
             msg_Dbg( p_demux, "Program %d PCR prequeue fixup %"PRId64"->%"PRId64,
                      p_pmt->i_number, TO_SCALE(i_mindts), i_pcr );
@@ -2288,25 +2288,25 @@ static void PCRCheckDTS( demux_t *p_demux, ts_pmt_t *p_pmt, vlc_tick_t i_pcr)
             continue;
 
         if (p_pmt->pcr.i_pcroffset > 0) {
-            if( i_dts > VLC_TS_INVALID )
+            if( i_dts > VLC_TICK_INVALID )
                 i_dts += p_pmt->pcr.i_pcroffset;
-            if( i_pts > VLC_TS_INVALID )
+            if( i_pts > VLC_TICK_INVALID )
                 i_pts += p_pmt->pcr.i_pcroffset;
         }
 
-        if( i_dts > VLC_TS_INVALID )
+        if( i_dts > VLC_TICK_INVALID )
             i_dts = TimeStampWrapAround( i_pcr, i_dts );
-        if( i_pts > VLC_TS_INVALID )
+        if( i_pts > VLC_TICK_INVALID )
             i_pts = TimeStampWrapAround( i_pcr, i_pts );
 
-        if(( i_dts > VLC_TS_INVALID && i_dts <= i_pcr ) ||
-           ( i_pts > VLC_TS_INVALID && i_pts <= i_pcr ))
+        if(( i_dts > VLC_TICK_INVALID && i_dts <= i_pcr ) ||
+           ( i_pts > VLC_TICK_INVALID && i_pts <= i_pcr ))
         {
             if( IsVideoEnd( p_pid ) )
             {
                 msg_Warn( p_demux, "send queued data for pid %d: TS %"PRId64" <= PCR %"PRId64"\n",
-                          p_pid->i_pid, i_dts > VLC_TS_INVALID ? i_dts : i_pts, i_pcr);
-                PushPESBlock( p_demux, p_pid, NULL, true, VLC_TS_INVALID ); /* Flush */
+                          p_pid->i_pid, i_dts > VLC_TICK_INVALID ? i_dts : i_pts, i_pcr);
+                PushPESBlock( p_demux, p_pid, NULL, true, VLC_TICK_INVALID ); /* Flush */
             }
         }
     }
diff --git a/modules/demux/mpeg/ts_psip.c b/modules/demux/mpeg/ts_psip.c
index f850ae08c94c..dd1acae0500e 100644
--- a/modules/demux/mpeg/ts_psip.c
+++ b/modules/demux/mpeg/ts_psip.c
@@ -373,7 +373,7 @@ static vlc_epg_event_t * ATSC_CreateVLCEPGEvent( demux_t *p_demux, ts_psip_conte
                                                              p_ett->p_etm_data, p_ett->i_etm_length );
     }
 
-    if( i_start > VLC_TS_INVALID && psz_title )
+    if( i_start > VLC_TICK_INVALID && psz_title )
     {
 #ifdef ATSC_DEBUG_EIT
         msg_Dbg( p_demux, "EIT Event time %ld +%d %s id 0x%x",
@@ -407,7 +407,7 @@ static time_t ATSC_AddVLCEPGEvent( demux_t *p_demux, ts_psip_context_t *p_basect
             return p_evt->i_start;
         vlc_epg_event_Delete( p_evt );
     }
-    return VLC_TS_INVALID;
+    return VLC_TICK_INVALID;
 }
 
 
diff --git a/modules/demux/mpeg/ts_streams.c b/modules/demux/mpeg/ts_streams.c
index 645a1c142dca..41817a0ef228 100644
--- a/modules/demux/mpeg/ts_streams.c
+++ b/modules/demux/mpeg/ts_streams.c
@@ -131,7 +131,7 @@ ts_pmt_t *ts_pmt_New( demux_t *p_demux )
     pmt->pcr.i_current = -1;
     pmt->pcr.i_first  = -1;
     pmt->pcr.b_disable = false;
-    pmt->pcr.i_first_dts = VLC_TS_INVALID;
+    pmt->pcr.i_first_dts = VLC_TICK_INVALID;
     pmt->pcr.i_pcroffset = -1;
 
     pmt->pcr.b_fix_done = false;
@@ -286,7 +286,7 @@ ts_stream_t *ts_stream_New( demux_t *p_demux, ts_pmt_t *p_program )
     pes->gather.p_data = NULL;
     pes->gather.pp_last = &pes->gather.p_data;
     pes->gather.i_saved = 0;
-    pes->gather.i_append_pcr = VLC_TS_INVALID;
+    pes->gather.i_append_pcr = VLC_TICK_INVALID;
     pes->b_broken_PUSI_conformance = false;
     pes->b_always_receive = false;
     pes->p_sections_proc = NULL;
diff --git a/modules/demux/nuv.c b/modules/demux/nuv.c
index 16aa90f7d409..718de83528e8 100644
--- a/modules/demux/nuv.c
+++ b/modules/demux/nuv.c
@@ -389,7 +389,7 @@ static int Demux( demux_t *p_demux )
         return VLC_DEMUXER_EOF;
 
     p_data->i_dts = VLC_TS_0 + (int64_t)fh.i_timecode * 1000;
-    p_data->i_pts = (fh.i_type == 'V') ? VLC_TS_INVALID : p_data->i_dts;
+    p_data->i_pts = (fh.i_type == 'V') ? VLC_TICK_INVALID : p_data->i_dts;
 
     /* only add keyframes to index */
     if( !fh.i_keyframe && !p_sys->b_index )
diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c
index 635576f7cc93..57a400f8ba27 100644
--- a/modules/demux/ogg.c
+++ b/modules/demux/ogg.c
@@ -194,7 +194,7 @@ static void fill_channels_info(audio_format_t *audio)
 
 /* Special TS value: don't send or derive any pts/pcr from it.
    Represents TS state prior first known valid timestamp */
-#define VLC_TS_UNKNOWN (VLC_TS_INVALID - 1)
+#define VLC_TS_UNKNOWN (VLC_TICK_INVALID - 1)
 
 /*****************************************************************************
  * Open: initializes ogg demux structures
@@ -299,7 +299,7 @@ static int Demux( demux_t * p_demux )
         {
             msg_Dbg( p_demux, "end of a group of %d logical streams", p_sys->i_streams );
 
-            vlc_tick_t i_lastpcr = VLC_TS_INVALID;
+            vlc_tick_t i_lastpcr = VLC_TICK_INVALID;
             for( i_stream = 0; i_stream < p_sys->i_streams; i_stream++ )
             {
                 logical_stream_t *p_stream = p_sys->pp_stream[i_stream];
@@ -320,13 +320,13 @@ static int Demux( demux_t * p_demux )
             Ogg_EndOfStream( p_demux );
             p_sys->b_chained_boundary = true;
 
-            if( i_lastpcr > VLC_TS_INVALID )
+            if( i_lastpcr > VLC_TICK_INVALID )
             {
                 p_sys->i_nzpcr_offset = i_lastpcr - VLC_TS_0;
                 if( likely( !p_sys->b_slave ) )
                     es_out_SetPCR( p_demux->out, i_lastpcr );
             }
-            p_sys->i_pcr = VLC_TS_INVALID;
+            p_sys->i_pcr = VLC_TICK_INVALID;
         }
 
         if( Ogg_BeginningOfStream( p_demux ) != VLC_SUCCESS )
@@ -419,7 +419,7 @@ static int Demux( demux_t * p_demux )
             {
                 msg_Err( p_demux, "Broken Ogg stream (serialno) mismatch" );
                 Ogg_ResetStream( p_stream );
-                if( p_stream->i_pcr > VLC_TS_INVALID )
+                if( p_stream->i_pcr > VLC_TICK_INVALID )
                     p_sys->i_nzpcr_offset = p_stream->i_pcr - VLC_TS_0;
                 ogg_stream_reset_serialno( &p_stream->os, ogg_page_serialno( &p_sys->current_page ) );
             }
@@ -590,7 +590,7 @@ static int Demux( demux_t * p_demux )
                     pagestamp -= CLOCK_FREQ * p_block->i_nb_samples / p_stream->f_rate;
                     if ( pagestamp < 0 )
                     {
-                        p_block->i_pts = VLC_TS_INVALID;
+                        p_block->i_pts = VLC_TICK_INVALID;
                         if( p_sys->i_nzpcr_offset == 0 ) /* not on chained streams */
                             p_block->i_flags |= BLOCK_FLAG_PREROLL;
                     }
@@ -649,7 +649,7 @@ static int Demux( demux_t * p_demux )
     /* We will consider the lowest PCR among tracks, because the audio core badly
      * handles PCR rewind (mute)
      */
-    vlc_tick_t i_pcr_candidate = VLC_TS_INVALID;
+    vlc_tick_t i_pcr_candidate = VLC_TICK_INVALID;
     for( i_stream = 0; i_stream < p_sys->i_streams; i_stream++ )
     {
         logical_stream_t *p_stream = p_sys->pp_stream[i_stream];
@@ -677,7 +677,7 @@ static int Demux( demux_t * p_demux )
         }
     }
 
-    if ( i_pcr_candidate > VLC_TS_INVALID && p_sys->i_pcr != i_pcr_candidate )
+    if ( i_pcr_candidate > VLC_TICK_INVALID && p_sys->i_pcr != i_pcr_candidate )
     {
         if ( p_sys->i_streams == 1 && p_sys->i_access_delay )
         {
@@ -792,7 +792,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             return VLC_EGENERIC;
 
         case DEMUX_GET_TIME:
-            if( p_sys->i_pcr > VLC_TS_INVALID || p_sys->b_slave )
+            if( p_sys->i_pcr > VLC_TICK_INVALID || p_sys->b_slave )
             {
                 pi64 = va_arg( args, int64_t * );
                 *pi64 = p_sys->i_pcr;
@@ -841,7 +841,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_POSITION:
             pf = va_arg( args, double * );
-            if( p_sys->i_length > 0 && p_sys->i_pcr > VLC_TS_INVALID )
+            if( p_sys->i_length > 0 && p_sys->i_pcr > VLC_TICK_INVALID )
             {
                 *pf =  (double) p_sys->i_pcr / (double) p_sys->i_length;
             }
@@ -1200,7 +1200,7 @@ static void Ogg_SendOrQueueBlocks( demux_t *p_demux, logical_stream_t *p_stream,
                          tosend->i_dts, tosend->i_pts, p_stream->i_pcr, p_ogg->i_pcr ); )
                 es_out_Send( p_demux->out, p_stream->p_es, tosend );
 
-                if ( p_ogg->i_pcr < VLC_TS_0 && i_firstpts > VLC_TS_INVALID )
+                if ( p_ogg->i_pcr < VLC_TS_0 && i_firstpts > VLC_TICK_INVALID )
                 {
                     p_ogg->i_pcr = i_firstpts;
                     if( likely( !p_ogg->b_slave ) )
@@ -1450,12 +1450,12 @@ static void Ogg_DecodePacket( demux_t *p_demux,
         {
             ogg_int64_t nzdts = Oggseek_GranuleToAbsTimestamp( p_stream, p_oggpacket->granulepos, false );
             ogg_int64_t nzpts = Oggseek_GranuleToAbsTimestamp( p_stream, p_oggpacket->granulepos, true );
-            p_block->i_dts = ( nzdts > VLC_TS_INVALID ) ? VLC_TS_0 + nzdts : nzdts;
-            p_block->i_pts = ( nzpts > VLC_TS_INVALID ) ? VLC_TS_0 + nzpts : nzpts;
+            p_block->i_dts = ( nzdts > VLC_TICK_INVALID ) ? VLC_TS_0 + nzdts : nzdts;
+            p_block->i_pts = ( nzpts > VLC_TICK_INVALID ) ? VLC_TS_0 + nzpts : nzpts;
             /* granulepos for dirac is possibly broken, this value should be ignored */
             if( 0 >= p_oggpacket->granulepos )
             {
-                p_block->i_pts = VLC_TS_INVALID;
+                p_block->i_pts = VLC_TICK_INVALID;
                 p_block->i_dts = p_stream->i_pcr;
             }
         }
@@ -1466,7 +1466,7 @@ static void Ogg_DecodePacket( demux_t *p_demux,
         }
         else
         {
-            p_block->i_pts = VLC_TS_INVALID;
+            p_block->i_pts = VLC_TICK_INVALID;
             p_block->i_dts = p_stream->i_pcr;
         }
     }
@@ -1484,7 +1484,7 @@ static void Ogg_DecodePacket( demux_t *p_demux,
         if( p_stream->i_end_length )
             p_block->i_length = p_stream->i_end_length;
         p_block->i_dts = p_stream->i_pcr;
-        p_block->i_pts = p_stream->b_interpolation_failed ? VLC_TS_INVALID : p_stream->i_pcr;
+        p_block->i_pts = p_stream->b_interpolation_failed ? VLC_TICK_INVALID : p_stream->i_pcr;
     }
     else if( p_stream->fmt.i_cat == SPU_ES )
     {
diff --git a/modules/demux/oggseek.c b/modules/demux/oggseek.c
index 28fb66a77139..3f320a93c4db 100644
--- a/modules/demux/oggseek.c
+++ b/modules/demux/oggseek.c
@@ -87,7 +87,7 @@ void oggseek_index_entries_free ( demux_index_entry_t *idx )
 
 static demux_index_entry_t *index_entry_new( int64_t i_timestamp, int64_t i_pagepos )
 {
-    if ( i_timestamp == VLC_TS_INVALID || i_pagepos < 1 )
+    if ( i_timestamp == VLC_TICK_INVALID || i_pagepos < 1 )
         return NULL;
 
     demux_index_entry_t *idx = malloc( sizeof(*idx) );
@@ -697,14 +697,14 @@ int64_t Oggseek_GranuleToAbsTimestamp( logical_stream_t *p_stream,
     }
     case VLC_CODEC_OPUS:
     {
-        if ( b_presentation ) return VLC_TS_INVALID;
+        if ( b_presentation ) return VLC_TICK_INVALID;
         i_timestamp = ( i_granule - p_stream->i_pre_skip ) * CLOCK_FREQ / 48000;
         break;
     }
     case VLC_CODEC_VORBIS:
     case VLC_CODEC_FLAC:
     {
-        if ( b_presentation ) return VLC_TS_INVALID;
+        if ( b_presentation ) return VLC_TICK_INVALID;
         i_timestamp = i_granule * CLOCK_FREQ / p_stream->f_rate;
         break;
     }
@@ -718,7 +718,7 @@ int64_t Oggseek_GranuleToAbsTimestamp( logical_stream_t *p_stream,
     }
     case VLC_CODEC_OGGSPOTS:
     {
-        if ( b_presentation ) return VLC_TS_INVALID;
+        if ( b_presentation ) return VLC_TICK_INVALID;
         i_timestamp = ( i_granule >> p_stream->i_granule_shift )
                 * CLOCK_FREQ / p_stream->f_rate;
         break;
diff --git a/modules/demux/pva.c b/modules/demux/pva.c
index 090b911bc449..4f684845d585 100644
--- a/modules/demux/pva.c
+++ b/modules/demux/pva.c
@@ -215,7 +215,7 @@ static int Demux( demux_t *p_demux )
                 if( ( p_frame = p_sys->p_es ) )
                 {
 
-                    if( p_frame->i_pts > VLC_TS_INVALID && !p_sys->b_pcr_audio )
+                    if( p_frame->i_pts > VLC_TICK_INVALID && !p_sys->b_pcr_audio )
                     {
                         es_out_SetPCR( p_demux->out, p_frame->i_pts);
                     }
diff --git a/modules/demux/rawdv.h b/modules/demux/rawdv.h
index e8039f397fb0..a2d7a7dcde4f 100644
--- a/modules/demux/rawdv.h
+++ b/modules/demux/rawdv.h
@@ -200,7 +200,7 @@ static inline block_t *dv_extract_audio( block_t *p_frame_block )
         }
     }
 
-    p_block->i_pts = p_frame_block->i_pts > VLC_TS_INVALID ? p_frame_block->i_pts
+    p_block->i_pts = p_frame_block->i_pts > VLC_TICK_INVALID ? p_frame_block->i_pts
                                                            : p_frame_block->i_dts;
     p_block->i_dts = p_frame_block->i_dts;
     return p_block;
diff --git a/modules/demux/real.c b/modules/demux/real.c
index 14d4187b9db3..3d22b40f4b7e 100644
--- a/modules/demux/real.c
+++ b/modules/demux/real.c
@@ -206,7 +206,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_data_offset = 0;
     p_sys->i_track = 0;
     p_sys->track   = NULL;
-    p_sys->i_pcr   = VLC_TS_INVALID;
+    p_sys->i_pcr   = VLC_TICK_INVALID;
 
     p_sys->b_seek  = false;
     p_sys->b_real_audio = b_real_audio;
@@ -343,15 +343,15 @@ static int Demux( demux_t *p_demux )
     }
 
     /* Update PCR */
-    vlc_tick_t i_pcr = VLC_TS_INVALID;
+    vlc_tick_t i_pcr = VLC_TICK_INVALID;
     for( int i = 0; i < p_sys->i_track; i++ )
     {
         tk = p_sys->track[i];
 
-        if( i_pcr <= VLC_TS_INVALID || ( tk->i_last_dts > VLC_TS_INVALID && tk->i_last_dts < i_pcr ) )
+        if( i_pcr <= VLC_TICK_INVALID || ( tk->i_last_dts > VLC_TICK_INVALID && tk->i_last_dts < i_pcr ) )
             i_pcr = tk->i_last_dts;
     }
-    if( i_pcr > VLC_TS_INVALID && i_pcr != p_sys->i_pcr )
+    if( i_pcr > VLC_TICK_INVALID && i_pcr != p_sys->i_pcr )
     {
         p_sys->i_pcr = i_pcr;
         es_out_SetPCR( p_demux->out, p_sys->i_pcr );
@@ -394,7 +394,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                so use duration to determin the position at first  */
             if( p_sys->i_our_duration > 0 )
             {
-                if( p_sys->i_pcr > VLC_TS_INVALID )
+                if( p_sys->i_pcr > VLC_TICK_INVALID )
                     *pf = (double)p_sys->i_pcr / 1000.0 / p_sys->i_our_duration;
                 else
                     *pf = 0.0;
@@ -413,7 +413,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
             if( p_sys->i_our_duration > 0 )
             {
-                *pi64 = p_sys->i_pcr > VLC_TS_INVALID ? p_sys->i_pcr : 0;
+                *pi64 = p_sys->i_pcr > VLC_TICK_INVALID ? p_sys->i_pcr : 0;
                 return VLC_SUCCESS;
             }
 
@@ -499,10 +499,10 @@ static void CheckPcr( demux_t *p_demux, real_track_t *tk, vlc_tick_t i_dts )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    if( i_dts > VLC_TS_INVALID )
+    if( i_dts > VLC_TICK_INVALID )
         tk->i_last_dts = i_dts;
 
-    if( p_sys->i_pcr > VLC_TS_INVALID || i_dts <= VLC_TS_INVALID )
+    if( p_sys->i_pcr > VLC_TICK_INVALID || i_dts <= VLC_TICK_INVALID )
         return;
 
     p_sys->i_pcr = i_dts;
@@ -572,11 +572,11 @@ static void DemuxVideo( demux_t *p_demux, real_track_t *tk, vlc_tick_t i_dts, un
             }
 
             tk->p_frame->i_dts = i_dts;
-            tk->p_frame->i_pts = VLC_TS_INVALID;
+            tk->p_frame->i_pts = VLC_TICK_INVALID;
             if( i_flags & 0x02 )
                 tk->p_frame->i_flags |= BLOCK_FLAG_TYPE_I;
 
-            i_dts = VLC_TS_INVALID;
+            i_dts = VLC_TICK_INVALID;
         }
 
         int i_frame_data;
@@ -663,7 +663,7 @@ static void DemuxAudioMethod1( demux_t *p_demux, real_track_t *tk, vlc_tick_t i_
 
             memcpy( p_block->p_buffer, p_buf, tk->i_subpacket_size );
             p_block->i_dts =
-            p_block->i_pts = VLC_TS_INVALID;
+            p_block->i_pts = VLC_TICK_INVALID;
 
             p_buf += tk->i_subpacket_size;
 
@@ -698,7 +698,7 @@ static void DemuxAudioMethod1( demux_t *p_demux, real_track_t *tk, vlc_tick_t i_
 
             memcpy( p_block->p_buffer, p_buf, tk->i_coded_frame_size );
             p_block->i_dts =
-            p_block->i_pts = i_index == 0 ? i_pts : VLC_TS_INVALID;
+            p_block->i_pts = i_index == 0 ? i_pts : VLC_TICK_INVALID;
 
             p_buf += tk->i_coded_frame_size;
 
@@ -773,7 +773,7 @@ static void DemuxAudioMethod2( demux_t *p_demux, real_track_t *tk, vlc_tick_t i_
         p_sub += i_sub_size;
 
         p_block->i_dts =
-        p_block->i_pts = i == 0 ? i_pts : VLC_TS_INVALID;
+        p_block->i_pts = i == 0 ? i_pts : VLC_TICK_INVALID;
 
         CheckPcr( p_demux, tk, p_block->i_pts );
         es_out_Send( p_demux->out, tk->p_es, p_block );
diff --git a/modules/demux/ty.c b/modules/demux/ty.c
index b15a8e1b3e8c..2a01ff0a48cf 100644
--- a/modules/demux/ty.c
+++ b/modules/demux/ty.c
@@ -334,8 +334,8 @@ static int Open(vlc_object_t *p_this)
     p_sys->b_first_chunk = true;
     p_sys->b_have_master = (U32_AT(p_peek) == TIVO_PES_FILEID);
     p_sys->firstAudioPTS = -1;
-    p_sys->lastAudioPTS  = VLC_TS_INVALID;
-    p_sys->lastVideoPTS  = VLC_TS_INVALID;
+    p_sys->lastAudioPTS  = VLC_TICK_INVALID;
+    p_sys->lastVideoPTS  = VLC_TICK_INVALID;
     p_sys->i_stream_size = stream_Size(p_demux->s);
     p_sys->tivo_type = TIVO_TYPE_UNKNOWN;
     p_sys->audio_type = TIVO_AUDIO_UNKNOWN;
@@ -446,7 +446,7 @@ static int Demux( demux_t *p_demux )
 
         /* set these as 'unknown' for now */
         p_block_in->i_pts =
-        p_block_in->i_dts = VLC_TS_INVALID;
+        p_block_in->i_dts = VLC_TICK_INVALID;
     }
     /*else
     {
@@ -748,13 +748,13 @@ static int DemuxRecVideo( demux_t *p_demux, ty_rec_hdr_t *rec_hdr, block_t *p_bl
             //p_sys->l_last_ty_pts += 33366667;
         }
         /* set PTS for this block before we send */
-        if (p_sys->lastVideoPTS > VLC_TS_INVALID)
+        if (p_sys->lastVideoPTS > VLC_TICK_INVALID)
         {
             p_block_in->i_pts = p_sys->lastVideoPTS;
             /* PTS gets used ONCE.
              * Any subsequent frames we get BEFORE next PES
              * header will have their PTS computed in the codec */
-            p_sys->lastVideoPTS = VLC_TS_INVALID;
+            p_sys->lastVideoPTS = VLC_TICK_INVALID;
         }
     }
 
@@ -784,7 +784,7 @@ static int DemuxRecVideo( demux_t *p_demux, ty_rec_hdr_t *rec_hdr, block_t *p_bl
 
     }
     /* Send the CC data */
-    if( p_block_in->i_pts > VLC_TS_INVALID && p_sys->cc.i_data > 0 )
+    if( p_block_in->i_pts > VLC_TICK_INVALID && p_sys->cc.i_data > 0 )
     {
         for( i = 0; i < 4; i++ )
         {
@@ -949,7 +949,7 @@ static int DemuxRecAudio( demux_t *p_demux, ty_rec_hdr_t *rec_hdr, block_t *p_bl
         /*msg_Dbg(p_demux,
                 "Adding SA Audio Packet Size %ld", l_rec_size ); */
 
-        if (p_sys->lastAudioPTS > VLC_TS_INVALID )
+        if (p_sys->lastAudioPTS > VLC_TICK_INVALID )
             p_block_in->i_pts = p_sys->lastAudioPTS;
     }
     else if( subrec_type == 0x09 )
@@ -1000,7 +1000,7 @@ static int DemuxRecAudio( demux_t *p_demux, ty_rec_hdr_t *rec_hdr, block_t *p_bl
     }
 
     /* set PCR before we send (if PTS found) */
-    if( p_block_in->i_pts > VLC_TS_INVALID )
+    if( p_block_in->i_pts > VLC_TICK_INVALID )
         es_out_Control( p_demux->out, ES_OUT_SET_PCR,
                         p_block_in->i_pts );
     /* Send data */
@@ -1084,7 +1084,7 @@ static int ty_stream_seek_pct(demux_t *p_demux, double seek_pct)
                  (p_sys->i_num_recs * 16) + l_skip_amt + 4);
 
     /* to hell with syncing any audio or video, just start reading records... :) */
-    /*p_sys->lastAudioPTS = p_sys->lastVideoPTS = VLC_TS_INVALID;*/
+    /*p_sys->lastAudioPTS = p_sys->lastVideoPTS = VLC_TICK_INVALID;*/
     return VLC_SUCCESS;
 }
 
diff --git a/modules/demux/vobsub.c b/modules/demux/vobsub.c
index 98cdf07ae504..7d8afcba9ebd 100644
--- a/modules/demux/vobsub.c
+++ b/modules/demux/vobsub.c
@@ -711,7 +711,7 @@ static int DemuxVobSub( demux_t *p_demux, block_t *p_bk )
             if( p_tk->p_es && p_tk->i_track_id == i_spu )
             {
                 es_out_Send( p_demux->out, p_tk->p_es, p_pkt );
-                p_bk->i_pts = VLC_TS_INVALID;     /*only first packet has a pts */
+                p_bk->i_pts = VLC_TICK_INVALID;     /*only first packet has a pts */
                 break;
             }
         }
diff --git a/modules/demux/webvtt.c b/modules/demux/webvtt.c
index cd65e610818f..48e619b86b9f 100644
--- a/modules/demux/webvtt.c
+++ b/modules/demux/webvtt.c
@@ -523,7 +523,7 @@ static int ControlStream( demux_t *p_demux, int i_query, va_list args )
     {
         case DEMUX_GET_TIME:
             pi64 = va_arg( args, int64_t * );
-            if( p_sys->i_next_demux_time != VLC_TS_INVALID )
+            if( p_sys->i_next_demux_time != VLC_TICK_INVALID )
             {
                 *pi64 = p_sys->i_next_demux_time;
                 return VLC_SUCCESS;
diff --git a/modules/hw/vaapi/filters.c b/modules/hw/vaapi/filters.c
index 31706a0e097c..4db7d5a1c6ca 100644
--- a/modules/hw/vaapi/filters.c
+++ b/modules/hw/vaapi/filters.c
@@ -915,7 +915,7 @@ DeinterlaceX2(filter_t * filter, picture_t * src)
     vlc_tick_t i_field_dur = 0;
     unsigned int i = 0;
     for ( ; i < METADATA_SIZE-1; i ++)
-        if (p_deint_data->meta[i].date > VLC_TS_INVALID)
+        if (p_deint_data->meta[i].date > VLC_TICK_INVALID)
             break;
     if (i < METADATA_SIZE-1) {
         unsigned int i_fields_total = 0;
@@ -943,10 +943,10 @@ DeinterlaceX2(filter_t * filter, picture_t * src)
 
     dest[0]->p_next = dest[1];
     dest[0]->date = cur->date;
-    if (dest[0]->date > VLC_TS_INVALID)
+    if (dest[0]->date > VLC_TICK_INVALID)
         dest[1]->date = dest[0]->date + i_field_dur;
     else
-        dest[1]->date = VLC_TS_INVALID;
+        dest[1]->date = VLC_TICK_INVALID;
 
     return dest[0];
 
@@ -972,7 +972,7 @@ Deinterlace_Flush(filter_t *filter)
 
     for (unsigned int i = 0; i < METADATA_SIZE; ++i)
     {
-        p_deint_data->meta[i].date = VLC_TS_INVALID;
+        p_deint_data->meta[i].date = VLC_TICK_INVALID;
         p_deint_data->meta[i].i_nb_fields = 2;
     }
 }
@@ -1143,7 +1143,7 @@ OpenDeinterlace(vlc_object_t * obj)
 
     for (unsigned int i = 0; i < METADATA_SIZE; ++i)
     {
-        p_data->meta[i].date = VLC_TS_INVALID;
+        p_data->meta[i].date = VLC_TICK_INVALID;
         p_data->meta[i].i_nb_fields = 2;
     }
 
diff --git a/modules/hw/vdpau/deinterlace.c b/modules/hw/vdpau/deinterlace.c
index f6c472b56ccf..0ce9aeb99c3e 100644
--- a/modules/hw/vdpau/deinterlace.c
+++ b/modules/hw/vdpau/deinterlace.c
@@ -67,7 +67,7 @@ static picture_t *Deinterlace(filter_t *filter, picture_t *src)
     picture_CopyProperties(dst, src);
     dst->context = &f2->context;
 
-    if (last_pts != VLC_TS_INVALID)
+    if (last_pts != VLC_TICK_INVALID)
         dst->date = (3 * src->date - last_pts) / 2;
     else
     if (filter->fmt_in.video.i_frame_rate != 0)
@@ -114,7 +114,7 @@ static int Open(vlc_object_t *obj)
     /* NOTE: Only weave and bob are mandatory for the hardware to implement.
      * The other modes and IVTC should be checked. */
 
-    sys->last_pts = VLC_TS_INVALID;
+    sys->last_pts = VLC_TICK_INVALID;
 
     filter->pf_video_filter = Deinterlace;
     filter->p_sys = sys;
diff --git a/modules/misc/stats.c b/modules/misc/stats.c
index 3c827f1360aa..c2842c4fa06d 100644
--- a/modules/misc/stats.c
+++ b/modules/misc/stats.c
@@ -66,7 +66,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         *(vlc_tick_t *)(p_pic->p->p_pixels) = mdate();
     }
 
-    p_pic->date = p_block->i_pts > VLC_TS_INVALID ?
+    p_pic->date = p_block->i_pts > VLC_TICK_INVALID ?
             p_block->i_pts : p_block->i_dts;
     p_pic->b_force = true;
 
diff --git a/modules/mux/asf.c b/modules/mux/asf.c
index 8bf51db8b2cd..ca92453b42c2 100644
--- a/modules/mux/asf.c
+++ b/modules/mux/asf.c
@@ -211,7 +211,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_pk_used    = 0;
     p_sys->i_pk_frame   = 0;
     p_sys->i_dts_first  =
-    p_sys->i_dts_last   = VLC_TS_INVALID;
+    p_sys->i_dts_last   = VLC_TICK_INVALID;
     p_sys->i_preroll_time = 2000;
     p_sys->i_bitrate    = 0;
     p_sys->i_bitrate_override = 0;
@@ -704,7 +704,7 @@ static int Mux( sout_mux_t *p_mux )
             return VLC_SUCCESS;
         }
 
-        if( p_sys->i_dts_first <= VLC_TS_INVALID )
+        if( p_sys->i_dts_first <= VLC_TICK_INVALID )
         {
             p_sys->i_dts_first = i_dts;
         }
@@ -854,7 +854,7 @@ static block_t *asf_header_create( sout_mux_t *p_mux, bool b_broadcast )
 
     msg_Dbg( p_mux, "Asf muxer creating header" );
 
-    if( p_sys->i_dts_first > VLC_TS_INVALID )
+    if( p_sys->i_dts_first > VLC_TICK_INVALID )
     {
         i_duration = p_sys->i_dts_last - p_sys->i_dts_first;
         if( i_duration < 0 ) i_duration = 0;
diff --git a/modules/mux/mp4/mp4.c b/modules/mux/mp4/mp4.c
index 670f2fe6e96f..ee64c1764b4a 100644
--- a/modules/mux/mp4/mp4.c
+++ b/modules/mux/mp4/mp4.c
@@ -249,7 +249,7 @@ static int Open(vlc_object_t *p_this)
     p_sys->b_mov        = p_mux->psz_mux && !strcmp(p_mux->psz_mux, "mov");
     p_sys->b_3gp        = p_mux->psz_mux && !strcmp(p_mux->psz_mux, "3gp");
     p_sys->i_read_duration   = 0;
-    p_sys->i_start_dts = VLC_TS_INVALID;
+    p_sys->i_start_dts = VLC_TICK_INVALID;
     p_sys->b_fragmented = false;
     p_sys->b_header_sent = false;
 
@@ -417,7 +417,7 @@ static int AddStream(sout_mux_t *p_mux, sout_input_t *p_input)
 
     es_format_Copy(&p_stream->mux.fmt, p_input->p_fmt);
     p_stream->i_length_neg  = 0;
-    p_stream->i_first_dts   = VLC_TS_INVALID;
+    p_stream->i_first_dts   = VLC_TICK_INVALID;
     switch( p_stream->mux.fmt.i_cat )
     {
     case AUDIO_ES:
@@ -453,9 +453,9 @@ static int AddStream(sout_mux_t *p_mux, sout_input_t *p_input)
 
     p_stream->mux.p_edits = NULL;
     p_stream->mux.i_edits_count = 0;
-    p_stream->mux.i_firstdts = VLC_TS_INVALID;
-    p_stream->i_last_dts    = VLC_TS_INVALID;
-    p_stream->i_last_pts    = VLC_TS_INVALID;
+    p_stream->mux.i_firstdts = VLC_TICK_INVALID;
+    p_stream->i_last_dts    = VLC_TICK_INVALID;
+    p_stream->i_last_pts    = VLC_TICK_INVALID;
 
     p_stream->b_hasiframes  = false;
 
@@ -542,7 +542,7 @@ static bool CreateCurrentEdit(mp4_stream_t *p_stream, vlc_tick_t i_mux_start_dts
     }
     else
     {
-        if(p_stream->i_last_pts > VLC_TS_INVALID)
+        if(p_stream->i_last_pts > VLC_TICK_INVALID)
             p_newedit->i_duration = p_stream->i_last_pts - p_stream->i_first_dts;
         else
             p_newedit->i_duration = p_stream->i_last_dts - p_stream->i_first_dts;
@@ -585,7 +585,7 @@ static block_t * BlockDequeue(sout_input_t *p_input, mp4_stream_t *p_stream)
 
 static inline vlc_tick_t dts_fb_pts( const block_t *p_data )
 {
-    return p_data->i_dts > VLC_TS_INVALID ? p_data->i_dts: p_data->i_pts;
+    return p_data->i_dts > VLC_TICK_INVALID ? p_data->i_dts: p_data->i_pts;
 }
 
 static int Mux(sout_mux_t *p_mux)
@@ -615,7 +615,7 @@ static int Mux(sout_mux_t *p_mux)
         /* Reset reference dts in case of discontinuity (ex: gather sout) */
         if (p_data->i_flags & BLOCK_FLAG_DISCONTINUITY && p_stream->mux.i_entry_count)
         {
-            if(p_stream->i_first_dts != VLC_TS_INVALID)
+            if(p_stream->i_first_dts != VLC_TICK_INVALID)
             {
                 if(!CreateCurrentEdit(p_stream, p_sys->i_start_dts, p_sys->b_fragmented))
                 {
@@ -625,9 +625,9 @@ static int Mux(sout_mux_t *p_mux)
             }
 
             p_stream->i_length_neg = 0;
-            p_stream->i_first_dts = VLC_TS_INVALID;
-            p_stream->i_last_dts = VLC_TS_INVALID;
-            p_stream->i_last_pts = VLC_TS_INVALID;
+            p_stream->i_first_dts = VLC_TICK_INVALID;
+            p_stream->i_last_dts = VLC_TICK_INVALID;
+            p_stream->i_last_pts = VLC_TICK_INVALID;
         }
 
         /* XXX: -1 to always have 2 entry for easy adding of empty SPU */
@@ -638,10 +638,10 @@ static int Mux(sout_mux_t *p_mux)
         }
 
         /* Set current segment ranges */
-        if( p_stream->i_first_dts == VLC_TS_INVALID )
+        if( p_stream->i_first_dts == VLC_TICK_INVALID )
         {
             p_stream->i_first_dts = dts_fb_pts( p_data );
-            if( p_sys->i_start_dts == VLC_TS_INVALID )
+            if( p_sys->i_start_dts == VLC_TICK_INVALID )
                 p_sys->i_start_dts = p_stream->i_first_dts;
         }
 
@@ -719,7 +719,7 @@ static int Mux(sout_mux_t *p_mux)
         e->i_pos    = p_sys->i_pos;
         e->i_size   = p_data->i_buffer;
 
-        if ( p_data->i_dts > VLC_TS_INVALID && p_data->i_pts > p_data->i_dts )
+        if ( p_data->i_dts > VLC_TICK_INVALID && p_data->i_pts > p_data->i_dts )
         {
             e->i_pts_dts = p_data->i_pts - p_data->i_dts;
             if ( !p_stream->mux.b_hasbframes )
@@ -1027,7 +1027,7 @@ static bo_t *GetMoofBox(sout_mux_t *p_mux, size_t *pi_mdat_total_size,
                 if (i_trun_flags & MP4_TRUN_SAMPLE_TIME_OFFSET)
                 {
                     uint32_t i_diff = 0;
-                    if ( p_entry->p_block->i_dts  > VLC_TS_INVALID &&
+                    if ( p_entry->p_block->i_dts  > VLC_TICK_INVALID &&
                          p_entry->p_block->i_pts > p_entry->p_block->i_dts )
                     {
                         i_diff = p_entry->p_block->i_pts - p_entry->p_block->i_dts;
@@ -1223,7 +1223,7 @@ static int OpenFrag(vlc_object_t *p_this)
 
     p_sys->b_header_sent = false;
     p_sys->b_fragmented  = true;
-    p_sys->i_start_dts = VLC_TS_INVALID;
+    p_sys->i_start_dts = VLC_TICK_INVALID;
     p_sys->i_mfhd_sequence = 1;
 
     return VLC_SUCCESS;
@@ -1417,10 +1417,10 @@ static int MuxFrag(sout_mux_t *p_mux)
         return VLC_SUCCESS;
 
     /* Set time ranges */
-    if( p_stream->i_first_dts == VLC_TS_INVALID )
+    if( p_stream->i_first_dts == VLC_TICK_INVALID )
     {
         p_stream->i_first_dts = p_currentblock->i_dts;
-        if( p_sys->i_start_dts == VLC_TS_INVALID )
+        if( p_sys->i_start_dts == VLC_TICK_INVALID )
             p_sys->i_start_dts = p_currentblock->i_dts;
     }
 
@@ -1472,7 +1472,7 @@ static int MuxFrag(sout_mux_t *p_mux)
         if (!p_stream->b_hasiframes && (p_currentblock->i_flags & BLOCK_FLAG_TYPE_I))
             p_stream->b_hasiframes = true;
 
-        if (!p_stream->mux.b_hasbframes && p_currentblock->i_dts > VLC_TS_INVALID &&
+        if (!p_stream->mux.b_hasbframes && p_currentblock->i_dts > VLC_TICK_INVALID &&
             p_currentblock->i_pts > p_currentblock->i_dts)
             p_stream->mux.b_hasbframes = true;
     }
diff --git a/modules/mux/mpeg/pes.c b/modules/mux/mpeg/pes.c
index fd3b015cef0e..87598f1ef563 100644
--- a/modules/mux/mpeg/pes.c
+++ b/modules/mux/mpeg/pes.c
@@ -384,9 +384,9 @@ void EStoPES ( block_t **pp_pes,
 
     vlc_tick_t i_dts = 0;
     vlc_tick_t i_pts = 0;
-    if (p_es->i_pts > VLC_TS_INVALID)
+    if (p_es->i_pts > VLC_TICK_INVALID)
         i_pts = (p_es->i_pts - ts_offset) * 9 / 100;
-    if (p_es->i_dts > VLC_TS_INVALID)
+    if (p_es->i_dts > VLC_TICK_INVALID)
         i_dts = (p_es->i_dts - ts_offset) * 9 / 100;
 
     i_size = p_es->i_buffer;
diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index f4399a3b55b6..b70b901a7dfb 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -1274,9 +1274,9 @@ static bool MuxStreams(sout_mux_t *p_mux )
                  (p_input->p_fmt->i_codec != VLC_CODEC_MP3) ) )
         {
             p_data = block_FifoGet( p_input->p_fifo );
-            if( p_data->i_dts <= VLC_TS_INVALID )
+            if( p_data->i_dts <= VLC_TICK_INVALID )
                 p_data->i_dts = p_data->i_pts;
-            else if ( p_data->i_pts <= VLC_TS_INVALID )
+            else if ( p_data->i_pts <= VLC_TICK_INVALID )
                 p_data->i_pts = p_data->i_dts;
 
             if( p_input->p_fmt->i_codec == VLC_CODEC_MP4A )
@@ -1289,7 +1289,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
 
         SetBlockDuration( p_input, p_data );
 
-        if( p_data->i_dts == VLC_TS_INVALID )
+        if( p_data->i_dts == VLC_TICK_INVALID )
         {
             msg_Err( p_mux, "non dated packet dropped" );
             block_Release( p_data );
@@ -1306,7 +1306,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
                     block_FifoCount( p_mux->pp_inputs[j]->p_fifo) > 0 )
                 {
                     block_t *p_block = block_FifoShow( p_mux->pp_inputs[j]->p_fifo );
-                    if( p_block->i_dts > VLC_TS_INVALID &&
+                    if( p_block->i_dts > VLC_TICK_INVALID &&
                         p_block->i_dts < p_sys->first_dts )
                         p_sys->first_dts = p_block->i_dts;
                 }
diff --git a/modules/packetizer/a52.c b/modules/packetizer/a52.c
index ed6737299d99..e5cf080a2a10 100644
--- a/modules/packetizer/a52.c
+++ b/modules/packetizer/a52.c
@@ -78,9 +78,9 @@ static void PacketizeFlush( decoder_t *p_dec )
     decoder_sys_t *p_sys = p_dec->p_sys;
 
     p_sys->b_discontuinity = true;
-    date_Set( &p_sys->end_date, VLC_TS_INVALID );
+    date_Set( &p_sys->end_date, VLC_TICK_INVALID );
     p_sys->i_state = STATE_NOSYNC;
-    p_sys->i_prev_bytestream_pts = VLC_TS_INVALID;
+    p_sys->i_prev_bytestream_pts = VLC_TICK_INVALID;
     block_BytestreamEmpty( &p_sys->bytestream );
 }
 
@@ -105,14 +105,14 @@ static block_t *GetOutBuffer( decoder_t *p_dec )
     }
 
     if( p_sys->bytestream.p_block->i_pts != date_Get( &p_sys->end_date ) &&
-        p_sys->bytestream.p_block->i_pts != VLC_TS_INVALID )
+        p_sys->bytestream.p_block->i_pts != VLC_TICK_INVALID )
     {
         /* Make sure we don't reuse the same pts twice
          * as A/52 in PES sends multiple times the same pts */
         if( p_sys->bytestream.p_block->i_pts != p_sys->i_prev_bytestream_pts )
             date_Set( &p_sys->end_date, p_sys->bytestream.p_block->i_pts );
         p_sys->i_prev_bytestream_pts = p_sys->bytestream.p_block->i_pts;
-        p_sys->bytestream.p_block->i_pts = VLC_TS_INVALID;
+        p_sys->bytestream.p_block->i_pts = VLC_TICK_INVALID;
     }
 
     p_dec->fmt_out.audio.i_rate     = p_sys->frame.i_rate;
@@ -128,7 +128,7 @@ static block_t *GetOutBuffer( decoder_t *p_dec )
 
     p_block->i_nb_samples = p_sys->frame.i_samples;
     p_block->i_pts = p_block->i_dts = date_Get( &p_sys->end_date );
-    if( p_block->i_pts != VLC_TS_INVALID )
+    if( p_block->i_pts != VLC_TICK_INVALID )
         p_block->i_length = date_Increment( &p_sys->end_date,
                                             p_block->i_nb_samples ) - p_block->i_pts;
 
@@ -288,7 +288,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
 
             p_sys->i_state = STATE_NOSYNC;
 
-            if( p_out_buffer->i_dts == VLC_TS_INVALID )
+            if( p_out_buffer->i_dts == VLC_TICK_INVALID )
             {
                 block_Release( p_out_buffer );
                 return NULL;
@@ -340,9 +340,9 @@ static int Open( vlc_object_t *p_this )
 
     /* Misc init */
     p_sys->i_state = STATE_NOSYNC;
-    date_Set( &p_sys->end_date, VLC_TS_INVALID );
+    date_Set( &p_sys->end_date, VLC_TICK_INVALID );
     p_sys->b_discontuinity = false;
-    p_sys->i_prev_bytestream_pts = VLC_TS_INVALID;
+    p_sys->i_prev_bytestream_pts = VLC_TICK_INVALID;
     memset(&p_sys->frame, 0, sizeof(vlc_a52_header_t));
 
     block_BytestreamInit( &p_sys->bytestream );
diff --git a/modules/packetizer/av1.c b/modules/packetizer/av1.c
index e13b25430b48..fa63e0034276 100644
--- a/modules/packetizer/av1.c
+++ b/modules/packetizer/av1.c
@@ -89,7 +89,7 @@ static bool block_Differs(const block_t *a, const block_t *b)
 #define PUSHQ(name,b) \
 {\
     block_ChainLastAppend(&p_sys->name.pp_chain_last, b);\
-    if(p_sys->tu.dts == VLC_TS_INVALID)\
+    if(p_sys->tu.dts == VLC_TICK_INVALID)\
         p_sys->tu.dts = b->i_dts; p_sys->tu.pts = b->i_pts;\
 }
 
@@ -202,8 +202,8 @@ static block_t * OutputQueues(decoder_t *p_dec, bool b_valid)
     }
 
     p_sys->tu.b_has_visible_frame = false;
-    p_sys->tu.dts = VLC_TS_INVALID;
-    p_sys->tu.pts = VLC_TS_INVALID;
+    p_sys->tu.dts = VLC_TICK_INVALID;
+    p_sys->tu.pts = VLC_TICK_INVALID;
     p_sys->i_seen = 0;
 
     return p_output;
@@ -390,8 +390,8 @@ static void PacketizeFlush(decoder_t *p_dec)
     block_ChainRelease(p_sys->obus.p_chain);
     INITQ(obus);
 
-    p_sys->tu.dts = VLC_TS_INVALID;
-    p_sys->tu.pts = VLC_TS_INVALID;
+    p_sys->tu.dts = VLC_TICK_INVALID;
+    p_sys->tu.pts = VLC_TICK_INVALID;
     p_sys->tu.b_has_visible_frame = false;
     p_sys->i_seen = 0;
     p_sys->i_next_block_flags = BLOCK_FLAG_DISCONTINUITY;
@@ -475,8 +475,8 @@ static block_t *PacketizeOBU(decoder_t *p_dec, block_t **pp_block)
             p_obublock->i_pts = p_frag->i_pts;
             p_obublock->i_flags = p_frag->i_flags;
             p_frag->i_flags = 0;
-            p_frag->i_dts = VLC_TS_INVALID;
-            p_frag->i_pts = VLC_TS_INVALID;
+            p_frag->i_dts = VLC_TICK_INVALID;
+            p_frag->i_pts = VLC_TICK_INVALID;
         }
 
         p_output = ParseOBUBlock(p_dec, p_obublock);
@@ -529,8 +529,8 @@ static int Open(vlc_object_t *p_this)
     p_sys->p_sequence_header_block = NULL;
     p_sys->p_sequence_header = NULL;
     p_sys->tu.b_has_visible_frame = false;
-    p_sys->tu.dts = VLC_TS_INVALID;
-    p_sys->tu.pts = VLC_TS_INVALID;
+    p_sys->tu.dts = VLC_TICK_INVALID;
+    p_sys->tu.pts = VLC_TICK_INVALID;
     p_sys->i_seen = 0;
     p_sys->i_next_block_flags = 0;
     INITQ(tu.pre);
diff --git a/modules/packetizer/avparser.c b/modules/packetizer/avparser.c
index 272f494b2124..6fbd8a227124 100644
--- a/modules/packetizer/avparser.c
+++ b/modules/packetizer/avparser.c
@@ -204,7 +204,7 @@ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block )
         memcpy( p_ret->p_buffer, p_outdata, i_outlen );
         p_ret->i_pts = p_block->i_pts;
         p_ret->i_dts = p_block->i_dts;
-        p_block->i_pts = p_block->i_dts = VLC_TS_INVALID;
+        p_block->i_pts = p_block->i_dts = VLC_TICK_INVALID;
     }
     else /* as-is block is now used */
     {
diff --git a/modules/packetizer/copy.c b/modules/packetizer/copy.c
index 073a663ed87a..d451fb12162e 100644
--- a/modules/packetizer/copy.c
+++ b/modules/packetizer/copy.c
@@ -170,12 +170,12 @@ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block )
     p_block = *pp_block;
     *pp_block = NULL;
 
-    if( p_block->i_dts <= VLC_TS_INVALID )
+    if( p_block->i_dts <= VLC_TICK_INVALID )
     {
         p_block->i_dts = p_block->i_pts;
     }
 
-    if( p_block->i_dts <= VLC_TS_INVALID )
+    if( p_block->i_dts <= VLC_TICK_INVALID )
     {
         msg_Dbg( p_dec, "need valid dts" );
         block_Release( p_block );
@@ -212,12 +212,12 @@ static block_t *PacketizeSub( decoder_t *p_dec, block_t **pp_block )
     p_block = *pp_block;
     *pp_block = NULL;
 
-    if( p_block->i_dts <= VLC_TS_INVALID )
+    if( p_block->i_dts <= VLC_TICK_INVALID )
     {
         p_block->i_dts = p_block->i_pts;
     }
 
-    if( p_block->i_dts <= VLC_TS_INVALID )
+    if( p_block->i_dts <= VLC_TICK_INVALID )
     {
         msg_Dbg( p_dec, "need valid dts" );
         block_Release( p_block );
diff --git a/modules/packetizer/dirac.c b/modules/packetizer/dirac.c
index 98c45cb63b15..60f62c61930a 100644
--- a/modules/packetizer/dirac.c
+++ b/modules/packetizer/dirac.c
@@ -313,7 +313,7 @@ static void dirac_RecoverTimestamps ( decoder_t *p_dec, size_t i_length )
     i_offset += i_length;
     for(; p_block != NULL; p_block = p_block->p_next )
     {
-        if( p_sys->i_sync_pts <= VLC_TS_INVALID && p_sys->i_sync_dts <= VLC_TS_INVALID )
+        if( p_sys->i_sync_pts <= VLC_TICK_INVALID && p_sys->i_sync_dts <= VLC_TICK_INVALID )
         {
             /* oldest timestamp wins */
             p_sys->i_sync_pts = p_block->i_pts;
@@ -321,7 +321,7 @@ static void dirac_RecoverTimestamps ( decoder_t *p_dec, size_t i_length )
         }
         /* clear timestamps -- more than one data unit can come from a block */
         p_block->i_flags = 0;
-        p_block->i_pts = p_block->i_dts = VLC_TS_INVALID;
+        p_block->i_pts = p_block->i_dts = VLC_TICK_INVALID;
         if( i_offset < p_block->i_buffer )
             break;
         i_offset -= p_block->i_buffer;
@@ -340,7 +340,7 @@ static void dirac_BackdateDTS( block_t *p_block, block_t *p_last, date_t *p_dts
     {
         if( pp_array[n]->i_flags & DIRAC_NON_DATED )
             continue;
-        if( pp_array[n]->i_dts <= VLC_TS_INVALID )
+        if( pp_array[n]->i_dts <= VLC_TICK_INVALID )
             pp_array[n]->i_dts = date_Decrement( p_dts, 1 );
     }
     free( pp_array );
@@ -358,7 +358,7 @@ static void dirac_BackdatePTS( block_t *p_block, block_t *p_last, date_t *p_pts,
     {
         if( pp_array[n]->i_flags & DIRAC_NON_DATED )
             continue;
-        if( pp_array[n]->i_dts > VLC_TS_INVALID )
+        if( pp_array[n]->i_dts > VLC_TICK_INVALID )
             continue;
         dirac_block_encap_t *dbe = dirac_GetBlockEncap( pp_array[n] );
         int32_t u_pic_num = dbe ? dbe->u_picture_number : 0;
@@ -800,7 +800,7 @@ sync_fail:
 
     p_block->i_pts = p_sys->i_sync_pts;
     p_block->i_dts = p_sys->i_sync_dts;
-    p_sys->i_sync_pts = p_sys->i_sync_dts = VLC_TS_INVALID;
+    p_sys->i_sync_pts = p_sys->i_sync_dts = VLC_TICK_INVALID;
 
     /* recover any new timestamps from the data that is about to be consumed */
     dirac_RecoverTimestamps( p_dec, p_sys->i_offset );
@@ -861,7 +861,7 @@ static int dirac_InspectDataUnit( decoder_t *p_dec, block_t **pp_block, block_t
         /* timestamps apply to pictures only */
         p_eu->i_dts = p_sys->i_eu_dts;
         p_eu->i_pts = p_sys->i_eu_pts;
-        p_sys->i_eu_dts = p_sys->i_eu_pts = VLC_TS_INVALID;
+        p_sys->i_eu_dts = p_sys->i_eu_pts = VLC_TICK_INVALID;
 
         if( !p_sys->b_seen_seq_hdr )
         {
@@ -959,12 +959,12 @@ static block_t *dirac_BuildEncapsulationUnit( decoder_t *p_dec, block_t *p_block
 
     assert(p_block->i_buffer >= 13 && 0x42424344 == GetDWBE( p_block->p_buffer ));
 
-    if( p_sys->i_eu_pts <= VLC_TS_INVALID && p_sys->i_eu_dts <= VLC_TS_INVALID )
+    if( p_sys->i_eu_pts <= VLC_TICK_INVALID && p_sys->i_eu_dts <= VLC_TICK_INVALID )
     {
         /* earliest block with pts/dts gets to set the pts/dts for the dated
          * encapsulation unit as a whole */
         /* NB, the 'earliest block' criteria is aribtary */
-        if( p_block->i_pts > VLC_TS_INVALID || p_block->i_dts > VLC_TS_INVALID )
+        if( p_block->i_pts > VLC_TICK_INVALID || p_block->i_dts > VLC_TICK_INVALID )
         {
             p_sys->i_eu_pts = p_block->i_pts;
             p_sys->i_eu_dts = p_block->i_dts;
@@ -1081,7 +1081,7 @@ static int dirac_TimeGenPush( decoder_t *p_dec, block_t *p_block_in )
      * Stage 1, sync to input timestamps, backdate timestamps for old
      * EUs that are in the outqueue with missing dates
      */
-    if( p_block_in->i_dts > VLC_TS_INVALID )
+    if( p_block_in->i_dts > VLC_TICK_INVALID )
     do {
         /* if timestamps exist, sync to them */
         if( p_sys->b_dts )
@@ -1092,7 +1092,7 @@ static int dirac_TimeGenPush( decoder_t *p_dec, block_t *p_block_in )
         dirac_BackdateDTS( p_sys->p_outqueue, p_block_in, &dts );
     } while( 0 );
 
-    if( p_block_in->i_pts > VLC_TS_INVALID )
+    if( p_block_in->i_pts > VLC_TICK_INVALID )
     do {
         /* if timestamps exist, sync to them */
         p_sys->u_pts_picnum = u_picnum;
@@ -1118,13 +1118,13 @@ static int dirac_TimeGenPush( decoder_t *p_dec, block_t *p_block_in )
     /*
      * Stage 3, for block_in, interpolate any missing timestamps
      */
-    if( p_sys->b_dts && p_block_in->i_dts <= VLC_TS_INVALID )
+    if( p_sys->b_dts && p_block_in->i_dts <= VLC_TICK_INVALID )
     {
         /* dts has previously been seen, but not this time, interpolate */
         p_block_in->i_dts = date_Increment( &p_sys->dts, 1 );
     }
 
-    if( p_sys->b_pts && p_block_in->i_pts <= VLC_TS_INVALID )
+    if( p_sys->b_pts && p_block_in->i_pts <= VLC_TICK_INVALID )
     {
         /* pts has previously been seen, but not this time, interpolate */
         date_t pts = p_sys->dts;
@@ -1299,8 +1299,8 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
             p_block->i_dts = p_sys->i_dts_last_out;
             p_block->i_pts = p_sys->i_pts_last_out;
         }
-        else if( p_block->i_pts <= VLC_TS_INVALID ) break;
-        else if( p_block->i_dts <= VLC_TS_INVALID ) break;
+        else if( p_block->i_pts <= VLC_TICK_INVALID ) break;
+        else if( p_block->i_dts <= VLC_TICK_INVALID ) break;
 
         p_sys->i_dts_last_out = p_block->i_dts;
         p_sys->i_pts_last_out = p_block->i_pts;
@@ -1318,7 +1318,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
 
     if( i_flushing )
     {
-        p_sys->i_eu_dts = p_sys->i_eu_pts = VLC_TS_INVALID;
+        p_sys->i_eu_dts = p_sys->i_eu_pts = VLC_TICK_INVALID;
 
         /* reset timegen state (except synchronizer) */
         p_sys->b_seen_seq_hdr = false;
@@ -1348,7 +1348,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
         while( p_block )
         {
             block_t *p_block_next = p_block->p_next;
-            if( p_block->i_pts > VLC_TS_INVALID && p_block->i_dts > VLC_TS_INVALID )
+            if( p_block->i_pts > VLC_TICK_INVALID && p_block->i_dts > VLC_TICK_INVALID )
                 break;
             dirac_ReorderDequeueAndReleaseBlock( p_dec, p_block );
             p_sys->p_outqueue = p_block = p_block_next;
@@ -1383,9 +1383,9 @@ static int Open( vlc_object_t *p_this )
     if( !p_sys )
         return VLC_ENOMEM;
 
-    p_sys->i_eu_pts = p_sys->i_eu_dts = VLC_TS_INVALID;
-    p_sys->i_sync_pts = p_sys->i_sync_dts = VLC_TS_INVALID;
-    p_sys->i_dts_last_out = p_sys->i_pts_last_out = VLC_TS_INVALID;
+    p_sys->i_eu_pts = p_sys->i_eu_dts = VLC_TICK_INVALID;
+    p_sys->i_sync_pts = p_sys->i_sync_dts = VLC_TICK_INVALID;
+    p_sys->i_dts_last_out = p_sys->i_pts_last_out = VLC_TICK_INVALID;
 
     p_sys->i_state = NOT_SYNCED;
     block_BytestreamInit( &p_sys->bytestream );
diff --git a/modules/packetizer/dts.c b/modules/packetizer/dts.c
index 82b44be22f34..b02cf3520ae9 100644
--- a/modules/packetizer/dts.c
+++ b/modules/packetizer/dts.c
@@ -150,7 +150,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
             }
         }
 
-        if ( !date_Get( &p_sys->end_date ) && p_block->i_pts <= VLC_TS_INVALID ) {
+        if ( !date_Get( &p_sys->end_date ) && p_block->i_pts <= VLC_TICK_INVALID ) {
             /* We've just started the stream, wait for the first PTS. */
             block_Release( p_block );
             return NULL;
@@ -186,7 +186,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
         case STATE_SYNC:
             /* New frame, set the Presentation Time Stamp */
             p_sys->i_pts = p_sys->bytestream.p_block->i_pts;
-            if( p_sys->i_pts > VLC_TS_INVALID &&
+            if( p_sys->i_pts > VLC_TICK_INVALID &&
                 p_sys->i_pts != date_Get( &p_sys->end_date ) )
             {
                 date_Set( &p_sys->end_date, p_sys->i_pts );
@@ -365,7 +365,7 @@ static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block )
 
             /* Make sure we don't reuse the same pts twice */
             if( p_sys->i_pts == p_sys->bytestream.p_block->i_pts )
-                p_sys->i_pts = p_sys->bytestream.p_block->i_pts = VLC_TS_INVALID;
+                p_sys->i_pts = p_sys->bytestream.p_block->i_pts = VLC_TICK_INVALID;
 
             if( p_sys->b_discontinuity )
             {
@@ -409,7 +409,7 @@ static int Open( vlc_object_t *p_this )
     /* Misc init */
     p_sys->i_state = STATE_NOSYNC;
     date_Set( &p_sys->end_date, 0 );
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
     p_sys->b_date_set = false;
     p_sys->b_discontinuity = false;
     memset(&p_sys->first, 0, sizeof(vlc_dts_header_t));
diff --git a/modules/packetizer/flac.c b/modules/packetizer/flac.c
index 7c7bc06b84fe..8998f5dac0fd 100644
--- a/modules/packetizer/flac.c
+++ b/modules/packetizer/flac.c
@@ -276,7 +276,7 @@ static void Flush(decoder_t *p_dec)
 
     p_sys->i_state = STATE_NOSYNC;
     p_sys->i_offset = 0;
-    date_Set( &p_sys->pts, VLC_TS_INVALID );
+    date_Set( &p_sys->pts, VLC_TICK_INVALID );
     block_BytestreamEmpty(&p_sys->bytestream);
 }
 
@@ -528,11 +528,11 @@ static block_t *Packetize(decoder_t *p_dec, block_t **pp_block)
 
         if( p_sys->bytestream.p_block &&
             p_sys->bytestream.p_block->i_pts > date_Get( &p_sys->pts ) &&
-            p_sys->bytestream.p_block->i_pts != VLC_TS_INVALID )
+            p_sys->bytestream.p_block->i_pts != VLC_TICK_INVALID )
         {
             date_Init( &p_sys->pts, p_sys->headerinfo.i_rate, 1 );
             date_Set( &p_sys->pts, p_sys->bytestream.p_block->i_pts );
-            p_sys->bytestream.p_block->i_pts = VLC_TS_INVALID;
+            p_sys->bytestream.p_block->i_pts = VLC_TICK_INVALID;
         }
 
         out = block_heap_Alloc( p_sys->p_buf, p_sys->i_buf );
@@ -541,7 +541,7 @@ static block_t *Packetize(decoder_t *p_dec, block_t **pp_block)
             out->i_dts = out->i_pts = date_Get( &p_sys->pts );
             out->i_flags = p_sys->i_next_block_flags;
             p_sys->i_next_block_flags = 0;
-            if( out->i_pts != VLC_TS_INVALID )
+            if( out->i_pts != VLC_TICK_INVALID )
                 date_Increment( &p_sys->pts, p_sys->headerinfo.i_frame_length );
         }
         else
@@ -586,13 +586,13 @@ static int Open(vlc_object_t *p_this)
     p_sys->i_offset      = 0;
     p_sys->b_stream_info = false;
     p_sys->i_last_frame_size = FLAC_FRAME_SIZE_MIN;
-    p_sys->headerinfo.i_pts  = VLC_TS_INVALID;
+    p_sys->headerinfo.i_pts  = VLC_TICK_INVALID;
     p_sys->i_buf         = 0;
     p_sys->p_buf         = NULL;
     p_sys->i_next_block_flags = 0;
     block_BytestreamInit(&p_sys->bytestream);
     date_Init( &p_sys->pts, 1, 1 );
-    date_Set( &p_sys->pts, VLC_TS_INVALID );
+    date_Set( &p_sys->pts, VLC_TICK_INVALID );
 
     /* */
     es_format_Copy(&p_dec->fmt_out, &p_dec->fmt_in);
diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 615ad1d9ec72..b58e8e60ec4a 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -381,16 +381,16 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_next_block_flags = 0;
     p_sys->b_recovered = false;
     p_sys->i_recoveryfnum = UINT_MAX;
-    p_sys->i_frame_dts = VLC_TS_INVALID;
-    p_sys->i_frame_pts = VLC_TS_INVALID;
+    p_sys->i_frame_dts = VLC_TICK_INVALID;
+    p_sys->i_frame_pts = VLC_TICK_INVALID;
     p_sys->i_dpb_output_delay = 0;
 
     /* POC */
     h264_poc_context_init( &p_sys->pocctx );
-    p_sys->prevdatedpoc.pts = VLC_TS_INVALID;
+    p_sys->prevdatedpoc.pts = VLC_TICK_INVALID;
 
     date_Init( &p_sys->dts, 30000 * 2, 1001 );
-    date_Set( &p_sys->dts, VLC_TS_INVALID );
+    date_Set( &p_sys->dts, VLC_TICK_INVALID );
 
     /* Setup properties */
     es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
@@ -547,8 +547,8 @@ static block_t *GetCc( decoder_t *p_dec, decoder_cc_desc_t *p_desc )
  ****************************************************************************/
 static void ResetOutputVariables( decoder_sys_t *p_sys )
 {
-    p_sys->i_frame_dts = VLC_TS_INVALID;
-    p_sys->i_frame_pts = VLC_TS_INVALID;
+    p_sys->i_frame_dts = VLC_TICK_INVALID;
+    p_sys->i_frame_pts = VLC_TICK_INVALID;
     p_sys->slice.type = H264_SLICE_TYPE_UNKNOWN;
     p_sys->b_new_sps = false;
     p_sys->b_new_pps = false;
@@ -572,12 +572,12 @@ static void PacketizeReset( void *p_private, bool b_broken )
         p_sys->p_active_sps = NULL;
         /* POC */
         h264_poc_context_init( &p_sys->pocctx );
-        p_sys->prevdatedpoc.pts = VLC_TS_INVALID;
+        p_sys->prevdatedpoc.pts = VLC_TICK_INVALID;
     }
     p_sys->i_next_block_flags = BLOCK_FLAG_DISCONTINUITY;
     p_sys->b_recovered = false;
     p_sys->i_recoveryfnum = UINT_MAX;
-    date_Set( &p_sys->dts, VLC_TS_INVALID );
+    date_Set( &p_sys->dts, VLC_TICK_INVALID );
 }
 static block_t *PacketizeParse( void *p_private, bool *pb_ts_used, block_t *p_block )
 {
@@ -773,13 +773,13 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_ts_used, block_t *p_fr
     }
 
     *pb_ts_used = false;
-    if( p_sys->i_frame_dts <= VLC_TS_INVALID &&
-        p_sys->i_frame_pts <= VLC_TS_INVALID )
+    if( p_sys->i_frame_dts <= VLC_TICK_INVALID &&
+        p_sys->i_frame_pts <= VLC_TICK_INVALID )
     {
         p_sys->i_frame_dts = i_frag_dts;
         p_sys->i_frame_pts = i_frag_pts;
         *pb_ts_used = true;
-        if( i_frag_dts > VLC_TS_INVALID )
+        if( i_frag_dts > VLC_TICK_INVALID )
             date_Set( &p_sys->dts, i_frag_dts );
     }
 
@@ -965,16 +965,16 @@ static block_t *OutputPicture( decoder_t *p_dec )
     p_pic->i_pts = p_sys->i_frame_pts;
 
     /* Fixup missing timestamps after split (multiple AU/block)*/
-    if( p_pic->i_dts <= VLC_TS_INVALID )
+    if( p_pic->i_dts <= VLC_TICK_INVALID )
         p_pic->i_dts = date_Get( &p_sys->dts );
 
     if( p_sys->slice.type == H264_SLICE_TYPE_I )
-        p_sys->prevdatedpoc.pts = VLC_TS_INVALID;
+        p_sys->prevdatedpoc.pts = VLC_TICK_INVALID;
 
-    if( p_pic->i_pts == VLC_TS_INVALID )
+    if( p_pic->i_pts == VLC_TICK_INVALID )
     {
-        if( p_sys->prevdatedpoc.pts > VLC_TS_INVALID &&
-            date_Get( &p_sys->dts ) != VLC_TS_INVALID )
+        if( p_sys->prevdatedpoc.pts > VLC_TICK_INVALID &&
+            date_Get( &p_sys->dts ) != VLC_TICK_INVALID )
         {
             date_t pts = p_sys->dts;
             date_Set( &pts, p_sys->prevdatedpoc.pts );
@@ -996,7 +996,7 @@ static block_t *OutputPicture( decoder_t *p_dec )
             p_pic->i_pts = p_pic->i_dts;
         }
         else if( p_sys->slice.type == H264_SLICE_TYPE_I &&
-                 date_Get( &p_sys->dts ) != VLC_TS_INVALID )
+                 date_Get( &p_sys->dts ) != VLC_TICK_INVALID )
         {
             /* Hell no PTS on IDR. We're totally blind */
             date_t pts = p_sys->dts;
@@ -1004,15 +1004,15 @@ static block_t *OutputPicture( decoder_t *p_dec )
             p_pic->i_pts = date_Get( &pts );
         }
     }
-    else if( p_pic->i_dts == VLC_TS_INVALID &&
+    else if( p_pic->i_dts == VLC_TICK_INVALID &&
              CanSwapPTSwithDTS( &p_sys->slice, p_sps ) )
     {
         p_pic->i_dts = p_pic->i_pts;
-        if( date_Get( &p_sys->dts ) == VLC_TS_INVALID )
+        if( date_Get( &p_sys->dts ) == VLC_TICK_INVALID )
             date_Set( &p_sys->dts, p_pic->i_pts );
     }
 
-    if( p_pic->i_pts > VLC_TS_INVALID )
+    if( p_pic->i_pts > VLC_TICK_INVALID )
     {
         p_sys->prevdatedpoc.pts = p_pic->i_pts;
         p_sys->prevdatedpoc.num = PictureOrderCount;
@@ -1034,10 +1034,10 @@ static block_t *OutputPicture( decoder_t *p_dec )
 #endif
 
     /* save for next pic fixups */
-    if( date_Get( &p_sys->dts ) != VLC_TS_INVALID )
+    if( date_Get( &p_sys->dts ) != VLC_TICK_INVALID )
     {
         if( p_sys->i_next_block_flags & BLOCK_FLAG_DISCONTINUITY )
-            date_Set( &p_sys->dts, VLC_TS_INVALID );
+            date_Set( &p_sys->dts, VLC_TICK_INVALID );
         else
             date_Increment( &p_sys->dts, i_num_clock_ts );
     }
diff --git a/modules/packetizer/hevc.c b/modules/packetizer/hevc.c
index 3336d93824dd..990cc03d9b4f 100644
--- a/modules/packetizer/hevc.c
+++ b/modules/packetizer/hevc.c
@@ -206,8 +206,8 @@ static int Open(vlc_object_t *p_this)
                                 p_dec->fmt_in.video.i_frame_rate_base );
     else
         date_Init( &p_sys->dts, 2 * 30000, 1001 );
-    date_Set( &p_sys->dts, VLC_TS_INVALID );
-    p_sys->pts = VLC_TS_INVALID;
+    date_Set( &p_sys->dts, VLC_TICK_INVALID );
+    p_sys->pts = VLC_TICK_INVALID;
     p_sys->b_need_ts = true;
 
     /* Set callbacks */
@@ -339,7 +339,7 @@ static void PacketizeReset(void *p_private, bool b_broken)
 
     p_sys->b_init_sequence_complete = false;
     p_sys->b_need_ts = true;
-    date_Set(&p_sys->dts, VLC_TS_INVALID);
+    date_Set(&p_sys->dts, VLC_TICK_INVALID);
 }
 
 static bool InsertXPS(decoder_t *p_dec, uint8_t i_nal_type, uint8_t i_id,
@@ -841,12 +841,12 @@ static void SetOutputBlockProperties(decoder_t *p_dec, block_t *p_output)
         uint8_t i_num_clock_ts = hevc_get_num_clock_ts(p_sys->p_active_sps,
                                                        p_sys->p_timing);
         const vlc_tick_t i_start = date_Get(&p_sys->dts);
-        if( i_start != VLC_TS_INVALID )
+        if( i_start != VLC_TICK_INVALID )
         {
             date_Increment(&p_sys->dts, i_num_clock_ts);
             p_output->i_length = date_Get(&p_sys->dts) - i_start;
         }
-        p_sys->pts = VLC_TS_INVALID;
+        p_sys->pts = VLC_TICK_INVALID;
     }
     hevc_release_sei_pic_timing(p_sys->p_timing);
     p_sys->p_timing = NULL;
@@ -863,10 +863,10 @@ static block_t *ParseNALBlock(decoder_t *p_dec, bool *pb_ts_used, block_t *p_fra
 
     if(p_sys->b_need_ts)
     {
-        if(p_frag->i_dts > VLC_TS_INVALID)
+        if(p_frag->i_dts > VLC_TICK_INVALID)
             date_Set(&p_sys->dts, p_frag->i_dts);
         p_sys->pts = p_frag->i_pts;
-        if(date_Get( &p_sys->dts ) != VLC_TS_INVALID)
+        if(date_Get( &p_sys->dts ) != VLC_TICK_INVALID)
             p_sys->b_need_ts = false;
         *pb_ts_used = true;
     }
@@ -906,7 +906,7 @@ static block_t *ParseNALBlock(decoder_t *p_dec, bool *pb_ts_used, block_t *p_fra
     if(p_output)
     {
         SetOutputBlockProperties( p_dec, p_output );
-        if (dts > VLC_TS_INVALID)
+        if (dts > VLC_TICK_INVALID)
             date_Set(&p_sys->dts, dts);
         p_sys->pts = pts;
         *pb_ts_used = true;
diff --git a/modules/packetizer/hxxx_common.c b/modules/packetizer/hxxx_common.c
index e7d66b698d9e..3ba7cbcb0375 100644
--- a/modules/packetizer/hxxx_common.c
+++ b/modules/packetizer/hxxx_common.c
@@ -45,8 +45,8 @@ cc_storage_t * cc_storage_new( void )
     cc_storage_t *p_ccs = malloc( sizeof(*p_ccs) );
     if( likely(p_ccs) )
     {
-        p_ccs->i_pts = VLC_TS_INVALID;
-        p_ccs->i_dts = VLC_TS_INVALID;
+        p_ccs->i_pts = VLC_TICK_INVALID;
+        p_ccs->i_dts = VLC_TICK_INVALID;
         p_ccs->i_flags = 0;
         cc_Init( &p_ccs->current );
         cc_Init( &p_ccs->next );
diff --git a/modules/packetizer/mlp.c b/modules/packetizer/mlp.c
index e7ceb35487c0..4b5b84e575ca 100644
--- a/modules/packetizer/mlp.c
+++ b/modules/packetizer/mlp.c
@@ -289,7 +289,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
             }
         }
 
-        if( !date_Get( &p_sys->end_date ) && p_block->i_pts <= VLC_TS_INVALID )
+        if( !date_Get( &p_sys->end_date ) && p_block->i_pts <= VLC_TICK_INVALID )
         {
             /* We've just started the stream, wait for the first PTS. */
             msg_Dbg( p_dec, "waiting for PTS" );
@@ -331,7 +331,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
         case STATE_SYNC:
             /* New frame, set the Presentation Time Stamp */
             p_sys->i_pts = p_sys->bytestream.p_block->i_pts;
-            if( p_sys->i_pts > VLC_TS_INVALID &&
+            if( p_sys->i_pts > VLC_TICK_INVALID &&
                 p_sys->i_pts != date_Get( &p_sys->end_date ) )
             {
                 date_Set( &p_sys->end_date, p_sys->i_pts );
@@ -447,7 +447,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
 
             /* Make sure we don't reuse the same pts twice */
             if( p_sys->i_pts == p_sys->bytestream.p_block->i_pts )
-                p_sys->i_pts = p_sys->bytestream.p_block->i_pts = VLC_TS_INVALID;
+                p_sys->i_pts = p_sys->bytestream.p_block->i_pts = VLC_TICK_INVALID;
 
             if( p_sys->b_discontinuity )
             {
diff --git a/modules/packetizer/mpeg4audio.c b/modules/packetizer/mpeg4audio.c
index 87c5275b2692..443800ccdf30 100644
--- a/modules/packetizer/mpeg4audio.c
+++ b/modules/packetizer/mpeg4audio.c
@@ -330,10 +330,10 @@ static block_t *ForwardRawBlock(decoder_t *p_dec, block_t **pp_block)
     *pp_block = NULL; /* Don't reuse this block */
 
     int64_t i_diff = 0;
-    if (p_block->i_pts > VLC_TS_INVALID &&
+    if (p_block->i_pts > VLC_TICK_INVALID &&
         p_block->i_pts != date_Get(&p_sys->end_date))
     {
-        if(date_Get(&p_sys->end_date) > VLC_TS_INVALID)
+        if(date_Get(&p_sys->end_date) > VLC_TICK_INVALID)
             i_diff = llabs( date_Get(&p_sys->end_date) - p_block->i_pts );
         date_Set(&p_sys->end_date, p_block->i_pts);
     }
@@ -342,7 +342,7 @@ static block_t *ForwardRawBlock(decoder_t *p_dec, block_t **pp_block)
 
     /* Might not be known due to missing extradata,
        will be set to block pts above */
-    if(p_dec->fmt_out.audio.i_frame_length && p_block->i_pts != VLC_TS_INVALID)
+    if(p_dec->fmt_out.audio.i_frame_length && p_block->i_pts != VLC_TICK_INVALID)
     {
         p_block->i_length = date_Increment(&p_sys->end_date,
             p_dec->fmt_out.audio.i_frame_length) - p_block->i_pts;
@@ -1020,7 +1020,7 @@ static void Flush(decoder_t *p_dec)
 
     p_sys->i_state = STATE_NOSYNC;
     block_BytestreamEmpty(&p_sys->bytestream);
-    date_Set(&p_sys->end_date, VLC_TS_INVALID);
+    date_Set(&p_sys->end_date, VLC_TICK_INVALID);
     p_sys->b_discontuinity = true;
 }
 
@@ -1089,7 +1089,7 @@ static block_t *PacketizeStreamBlock(decoder_t *p_dec, block_t **pp_block)
     case STATE_SYNC:
         /* New frame, set the Presentation Time Stamp */
         p_sys->i_pts = p_sys->bytestream.p_block->i_pts;
-        if (p_sys->i_pts > VLC_TS_INVALID &&
+        if (p_sys->i_pts > VLC_TICK_INVALID &&
             p_sys->i_pts != date_Get(&p_sys->end_date))
             date_Set(&p_sys->end_date, p_sys->i_pts);
         p_sys->i_state = STATE_HEADER;
@@ -1217,7 +1217,7 @@ static block_t *PacketizeStreamBlock(decoder_t *p_dec, block_t **pp_block)
         SetupOutput(p_dec, p_out_buffer);
         /* Make sure we don't reuse the same pts twice */
         if (p_sys->i_pts == p_sys->bytestream.p_block->i_pts)
-            p_sys->i_pts = p_sys->bytestream.p_block->i_pts = VLC_TS_INVALID;
+            p_sys->i_pts = p_sys->bytestream.p_block->i_pts = VLC_TICK_INVALID;
 
         /* So p_block doesn't get re-added several times */
         if( pp_block )
@@ -1261,7 +1261,7 @@ static block_t *Packetize(decoder_t *p_dec, block_t **pp_block)
             }
         }
 
-        if (!date_Get(&p_sys->end_date) && p_block->i_pts <= VLC_TS_INVALID)
+        if (!date_Get(&p_sys->end_date) && p_block->i_pts <= VLC_TICK_INVALID)
         {
             /* We've just started the stream, wait for the first PTS. */
             block_Release(p_block);
diff --git a/modules/packetizer/mpeg4video.c b/modules/packetizer/mpeg4video.c
index c8c031983a70..c5a81e6f3a2f 100644
--- a/modules/packetizer/mpeg4video.c
+++ b/modules/packetizer/mpeg4video.c
@@ -222,7 +222,7 @@ static void PacketizeReset( void *p_private, bool b_broken )
 
     p_sys->i_interpolated_pts =
     p_sys->i_interpolated_dts =
-    p_sys->i_last_ref_pts = VLC_TS_INVALID;
+    p_sys->i_last_ref_pts = VLC_TICK_INVALID;
 
     p_sys->i_last_time_ref =
     p_sys->i_time_ref =
@@ -251,8 +251,8 @@ static int PacketizeValidate( void *p_private, block_t *p_au )
 
     /* We've just started the stream, wait for the first PTS.
      * We discard here so we can still get the sequence header. */
-    if( p_sys->i_interpolated_pts <= VLC_TS_INVALID &&
-        p_sys->i_interpolated_dts <= VLC_TS_INVALID )
+    if( p_sys->i_interpolated_pts <= VLC_TICK_INVALID &&
+        p_sys->i_interpolated_dts <= VLC_TICK_INVALID )
     {
         msg_Dbg( p_dec, "need a starting pts/dts" );
         return VLC_EGENERIC;
@@ -553,9 +553,9 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
     p_sys->i_last_timeincr = i_time_increment;
 
     /* Correct interpolated dts when we receive a new pts/dts */
-    if( p_vop->i_pts > VLC_TS_INVALID )
+    if( p_vop->i_pts > VLC_TICK_INVALID )
         p_sys->i_interpolated_pts = p_vop->i_pts;
-    if( p_vop->i_dts > VLC_TS_INVALID )
+    if( p_vop->i_dts > VLC_TICK_INVALID )
         p_sys->i_interpolated_dts = p_vop->i_dts;
 
     if( (p_sys->i_flags & BLOCK_FLAG_TYPE_B) || !p_sys->b_frame )
@@ -564,16 +564,16 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
 
         p_sys->i_interpolated_dts = p_sys->i_interpolated_pts;
 
-        if( p_vop->i_pts > VLC_TS_INVALID )
+        if( p_vop->i_pts > VLC_TICK_INVALID )
             p_sys->i_interpolated_dts = p_vop->i_pts;
-        if( p_vop->i_dts > VLC_TS_INVALID )
+        if( p_vop->i_dts > VLC_TICK_INVALID )
             p_sys->i_interpolated_dts = p_vop->i_dts;
 
         p_sys->i_interpolated_pts = p_sys->i_interpolated_dts;
     }
     else
     {
-        if( p_sys->i_last_ref_pts > VLC_TS_INVALID )
+        if( p_sys->i_last_ref_pts > VLC_TICK_INVALID )
             p_sys->i_interpolated_dts = p_sys->i_last_ref_pts;
 
         p_sys->i_last_ref_pts = p_sys->i_interpolated_pts;
diff --git a/modules/packetizer/mpegaudio.c b/modules/packetizer/mpegaudio.c
index 141723010272..99b9a0220e7f 100644
--- a/modules/packetizer/mpegaudio.c
+++ b/modules/packetizer/mpegaudio.c
@@ -97,7 +97,7 @@ static void Flush( decoder_t *p_dec )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    date_Set( &p_sys->end_date, VLC_TS_INVALID );
+    date_Set( &p_sys->end_date, VLC_TICK_INVALID );
     p_sys->i_state = STATE_NOSYNC;
     block_BytestreamEmpty( &p_sys->bytestream );
     p_sys->b_discontinuity = true;
@@ -111,7 +111,7 @@ static uint8_t *GetOutBuffer( decoder_t *p_dec, block_t **pp_out_buffer )
     decoder_sys_t *p_sys = p_dec->p_sys;
 
     if( p_dec->fmt_out.audio.i_rate != p_sys->i_rate ||
-        date_Get( &p_sys->end_date ) == VLC_TS_INVALID )
+        date_Get( &p_sys->end_date ) == VLC_TICK_INVALID )
     {
         msg_Dbg( p_dec, "MPGA channels:%d samplerate:%d bitrate:%d",
                   p_sys->i_channels, p_sys->i_rate, p_sys->i_bit_rate );
@@ -309,7 +309,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             }
         }
 
-        if( !date_Get( &p_sys->end_date ) && p_block->i_pts <= VLC_TS_INVALID )
+        if( !date_Get( &p_sys->end_date ) && p_block->i_pts <= VLC_TICK_INVALID )
         {
             /* We've just started the stream, wait for the first PTS. */
             msg_Dbg( p_dec, "waiting for PTS" );
@@ -349,12 +349,12 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         case STATE_SYNC:
             /* New frame, set the Presentation Time Stamp */
             p_sys->i_pts = p_sys->bytestream.p_block->i_pts;
-            if( p_sys->i_pts > VLC_TS_INVALID &&
+            if( p_sys->i_pts > VLC_TICK_INVALID &&
                 p_sys->i_pts != date_Get( &p_sys->end_date ) )
             {
                 if( p_dec->fmt_in.i_original_fourcc == VLC_FOURCC( 'D','V','R',' ') )
                 {
-                    if( date_Get( &p_sys->end_date ) == VLC_TS_INVALID )
+                    if( date_Get( &p_sys->end_date ) == VLC_TICK_INVALID )
                         date_Set( &p_sys->end_date, p_sys->i_pts );
                 }
                 else if ( p_sys->i_pts != date_Get( &p_sys->end_date ) )
@@ -572,7 +572,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
             /* Make sure we don't reuse the same pts twice */
             if( p_sys->i_pts == p_sys->bytestream.p_block->i_pts )
-                p_sys->i_pts = p_sys->bytestream.p_block->i_pts = VLC_TS_INVALID;
+                p_sys->i_pts = p_sys->bytestream.p_block->i_pts = VLC_TICK_INVALID;
 
             if( p_sys->b_discontinuity )
             {
@@ -629,9 +629,9 @@ static int Open( vlc_object_t *p_this )
     /* Misc init */
     p_sys->i_state = STATE_NOSYNC;
     date_Init( &p_sys->end_date, 1, 1 );
-    date_Set( &p_sys->end_date, VLC_TS_INVALID );
+    date_Set( &p_sys->end_date, VLC_TICK_INVALID );
     block_BytestreamInit( &p_sys->bytestream );
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
     p_sys->b_discontinuity = false;
     p_sys->i_frame_size = 0;
 
diff --git a/modules/packetizer/mpegvideo.c b/modules/packetizer/mpegvideo.c
index f1ca56a4a931..462f1115be6f 100644
--- a/modules/packetizer/mpegvideo.c
+++ b/modules/packetizer/mpegvideo.c
@@ -221,11 +221,11 @@ static int Open( vlc_object_t *p_this )
     p_sys->b_frame_slice = false;
 
     p_sys->i_dts =
-    p_sys->i_pts = VLC_TS_INVALID;
+    p_sys->i_pts = VLC_TICK_INVALID;
     date_Init( &p_sys->dts, 30000, 1001 );
-    date_Set( &p_sys->dts, VLC_TS_INVALID );
+    date_Set( &p_sys->dts, VLC_TICK_INVALID );
     date_Init( &p_sys->prev_iframe_dts, 30000, 1001 );
-    date_Set( &p_sys->prev_iframe_dts, VLC_TS_INVALID );
+    date_Set( &p_sys->prev_iframe_dts, VLC_TICK_INVALID );
 
     p_sys->i_frame_rate = 2 * 30000;
     p_sys->i_frame_rate_base = 1001;
@@ -242,7 +242,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_progressive_frame = 0;
     p_sys->b_inited = 0;
 
-    p_sys->i_last_ref_pts = VLC_TS_INVALID;
+    p_sys->i_last_ref_pts = VLC_TICK_INVALID;
     p_sys->b_second_field = 0;
 
     p_sys->i_next_block_flags = 0;
@@ -427,15 +427,15 @@ static block_t *OutputFrame( decoder_t *p_dec )
 
         if( ( p_pic->i_flags & BLOCK_FLAG_TYPE_I ) && b_first_xmited )
         {
-            if( date_Get( &p_sys->prev_iframe_dts ) == VLC_TS_INVALID )
+            if( date_Get( &p_sys->prev_iframe_dts ) == VLC_TICK_INVALID )
             {
-                if( p_sys->i_dts != VLC_TS_INVALID )
+                if( p_sys->i_dts != VLC_TICK_INVALID )
                 {
                     date_Set( &p_sys->dts, p_sys->i_dts );
                 }
                 else
                 {
-                    if( date_Get( &p_sys->dts ) == VLC_TS_INVALID )
+                    if( date_Get( &p_sys->dts ) == VLC_TICK_INVALID )
                     {
                         date_Set( &p_sys->dts, VLC_TS_0 );
                     }
@@ -463,7 +463,7 @@ static block_t *OutputFrame( decoder_t *p_dec )
 
         p_pic->i_pts = date_Get( &datepts );
 
-        if( date_Get( &p_sys->dts ) != VLC_TS_INVALID )
+        if( date_Get( &p_sys->dts ) != VLC_TICK_INVALID )
         {
             date_Increment( &p_sys->dts,  i_num_fields );
 
@@ -477,17 +477,17 @@ static block_t *OutputFrame( decoder_t *p_dec )
         {
             /* Trivial case (DTS == PTS) */
             /* Correct interpolated dts when we receive a new pts/dts */
-            if( p_sys->i_pts != VLC_TS_INVALID )
+            if( p_sys->i_pts != VLC_TICK_INVALID )
                 date_Set( &p_sys->dts, p_sys->i_pts );
-            if( p_sys->i_dts != VLC_TS_INVALID )
+            if( p_sys->i_dts != VLC_TICK_INVALID )
                 date_Set( &p_sys->dts, p_sys->i_dts );
         }
         else
         {
             /* Correct interpolated dts when we receive a new pts/dts */
-            if(p_sys->i_last_ref_pts != VLC_TS_INVALID && !p_sys->b_second_field)
+            if(p_sys->i_last_ref_pts != VLC_TICK_INVALID && !p_sys->b_second_field)
                 date_Set( &p_sys->dts, p_sys->i_last_ref_pts );
-            if( p_sys->i_dts != VLC_TS_INVALID )
+            if( p_sys->i_dts != VLC_TICK_INVALID )
                 date_Set( &p_sys->dts, p_sys->i_dts );
 
             if( !p_sys->b_second_field )
@@ -497,7 +497,7 @@ static block_t *OutputFrame( decoder_t *p_dec )
         p_pic->i_dts = date_Get( &p_sys->dts );
 
         /* Set PTS only if we have a B frame or if it comes from the stream */
-        if( p_sys->i_pts != VLC_TS_INVALID )
+        if( p_sys->i_pts != VLC_TICK_INVALID )
         {
             p_pic->i_pts = p_sys->i_pts;
         }
@@ -507,10 +507,10 @@ static block_t *OutputFrame( decoder_t *p_dec )
         }
         else
         {
-            p_pic->i_pts = VLC_TS_INVALID;
+            p_pic->i_pts = VLC_TICK_INVALID;
         }
 
-        if( date_Get( &p_sys->dts ) != VLC_TS_INVALID )
+        if( date_Get( &p_sys->dts ) != VLC_TICK_INVALID )
         {
             date_Increment( &p_sys->dts,  i_num_fields );
 
@@ -522,7 +522,7 @@ static block_t *OutputFrame( decoder_t *p_dec )
     msg_Dbg( p_dec, "pic: type=%d ref=%d nf=%d tff=%d dts=%"PRId64" ptsdiff=%"PRId64" len=%"PRId64,
              p_sys->i_picture_structure, p_sys->i_temporal_ref, i_num_fields,
              p_sys->i_top_field_first,
-             p_pic->i_dts , (p_pic->i_pts != VLC_TS_INVALID) ? p_pic->i_pts - p_pic->i_dts : 0, p_pic->i_length );
+             p_pic->i_dts , (p_pic->i_pts != VLC_TICK_INVALID) ? p_pic->i_pts - p_pic->i_dts : 0, p_pic->i_length );
 #endif
 
 
@@ -566,11 +566,11 @@ static void PacketizeReset( void *p_private, bool b_broken )
         p_sys->pp_last = &p_sys->p_frame;
         p_sys->b_frame_slice = false;
     }
-    date_Set( &p_sys->dts, VLC_TS_INVALID );
-    date_Set( &p_sys->prev_iframe_dts, VLC_TS_INVALID );
+    date_Set( &p_sys->dts, VLC_TICK_INVALID );
+    date_Set( &p_sys->prev_iframe_dts, VLC_TICK_INVALID );
     p_sys->i_dts =
     p_sys->i_pts =
-    p_sys->i_last_ref_pts = VLC_TS_INVALID;
+    p_sys->i_last_ref_pts = VLC_TICK_INVALID;
     p_sys->b_waiting_iframe = p_sys->b_sync_on_intra_frame;
     p_sys->i_prev_temporal_ref = 2048;
 }
@@ -628,16 +628,16 @@ static int PacketizeValidate( void *p_private, block_t *p_au )
 
     /* We've just started the stream, wait for the first PTS.
      * We discard here so we can still get the sequence header. */
-    if( unlikely( p_sys->i_dts <= VLC_TS_INVALID && p_sys->i_pts <= VLC_TS_INVALID &&
-        date_Get( &p_sys->dts ) <= VLC_TS_INVALID ))
+    if( unlikely( p_sys->i_dts <= VLC_TICK_INVALID && p_sys->i_pts <= VLC_TICK_INVALID &&
+        date_Get( &p_sys->dts ) <= VLC_TICK_INVALID ))
     {
         msg_Dbg( p_dec, "need a starting pts/dts" );
         return VLC_EGENERIC;
     }
 
     /* When starting the stream we can have the first frame with
-     * an invalid DTS (i_interpolated_pts is initialized to VLC_TS_INVALID) */
-    if( unlikely( p_au->i_dts <= VLC_TS_INVALID ) )
+     * an invalid DTS (i_interpolated_pts is initialized to VLC_TICK_INVALID) */
+    if( unlikely( p_au->i_dts <= VLC_TICK_INVALID ) )
         p_au->i_dts = p_au->i_pts;
 
     return VLC_SUCCESS;
diff --git a/modules/packetizer/packetizer_helper.h b/modules/packetizer/packetizer_helper.h
index 1ea66ebc6315..6b18e8797e1c 100644
--- a/modules/packetizer/packetizer_helper.h
+++ b/modules/packetizer/packetizer_helper.h
@@ -208,8 +208,8 @@ static block_t *packetizer_PacketizeBlock( packetizer_t *p_pack, block_t **pp_bl
                 p_pic = p_pack->pf_parse( p_pack->p_private, &b_used_ts, p_pic );
                 if( b_used_ts )
                 {
-                    p_block_bytestream->i_dts = VLC_TS_INVALID;
-                    p_block_bytestream->i_pts = VLC_TS_INVALID;
+                    p_block_bytestream->i_dts = VLC_TICK_INVALID;
+                    p_block_bytestream->i_pts = VLC_TICK_INVALID;
                 }
             }
 
diff --git a/modules/packetizer/vc1.c b/modules/packetizer/vc1.c
index e75fd4a37b44..8f70154d8a60 100644
--- a/modules/packetizer/vc1.c
+++ b/modules/packetizer/vc1.c
@@ -167,14 +167,14 @@ static int Open( vlc_object_t *p_this )
     p_sys->b_entry_point = false;
     p_sys->ep.p_ep = NULL;
 
-    p_sys->i_frame_dts = VLC_TS_INVALID;
-    p_sys->i_frame_pts = VLC_TS_INVALID;
+    p_sys->i_frame_dts = VLC_TICK_INVALID;
+    p_sys->i_frame_pts = VLC_TICK_INVALID;
 
     p_sys->b_frame = false;
     p_sys->p_frame = NULL;
     p_sys->pp_last = &p_sys->p_frame;
 
-    p_sys->i_interpolated_dts = VLC_TS_INVALID;
+    p_sys->i_interpolated_dts = VLC_TICK_INVALID;
     p_sys->b_check_startcode = p_dec->fmt_in.b_packetized;
 
     if( p_dec->fmt_out.i_extra > 0 )
@@ -195,8 +195,8 @@ static int Open( vlc_object_t *p_this )
     }
 
     /* */
-    p_sys->i_cc_pts = VLC_TS_INVALID;
-    p_sys->i_cc_dts = VLC_TS_INVALID;
+    p_sys->i_cc_pts = VLC_TICK_INVALID;
+    p_sys->i_cc_dts = VLC_TICK_INVALID;
     p_sys->i_cc_flags = 0;
     cc_Init( &p_sys->cc );
     cc_Init( &p_sys->cc_next );
@@ -287,9 +287,9 @@ static void PacketizeReset( void *p_private, bool b_broken )
         p_sys->b_frame = false;
     }
 
-    p_sys->i_frame_dts = VLC_TS_INVALID;
-    p_sys->i_frame_pts = VLC_TS_INVALID;
-    p_sys->i_interpolated_dts = VLC_TS_INVALID;
+    p_sys->i_frame_dts = VLC_TICK_INVALID;
+    p_sys->i_frame_pts = VLC_TICK_INVALID;
+    p_sys->i_interpolated_dts = VLC_TICK_INVALID;
 }
 static block_t *PacketizeParse( void *p_private, bool *pb_ts_used, block_t *p_block )
 {
@@ -303,7 +303,7 @@ static int PacketizeValidate( void *p_private, block_t *p_au )
     decoder_t *p_dec = p_private;
     decoder_sys_t *p_sys = p_dec->p_sys;
 
-    if( p_sys->i_interpolated_dts <= VLC_TS_INVALID )
+    if( p_sys->i_interpolated_dts <= VLC_TICK_INVALID )
     {
         msg_Dbg( p_dec, "need a starting pts/dts" );
         return VLC_EGENERIC;
@@ -381,23 +381,23 @@ static block_t *ParseIDU( decoder_t *p_dec, bool *pb_ts_used, block_t *p_frag )
         p_pic->i_pts = p_sys->i_frame_pts;
 
         /* */
-        if( p_pic->i_dts > VLC_TS_INVALID )
+        if( p_pic->i_dts > VLC_TICK_INVALID )
             p_sys->i_interpolated_dts = p_pic->i_dts;
 
         /* We can interpolate dts/pts only if we have a frame rate */
         if( p_dec->fmt_out.video.i_frame_rate != 0 && p_dec->fmt_out.video.i_frame_rate_base != 0 )
         {
-            if( p_sys->i_interpolated_dts > VLC_TS_INVALID )
+            if( p_sys->i_interpolated_dts > VLC_TICK_INVALID )
                 p_sys->i_interpolated_dts += INT64_C(1000000) *
                                              p_dec->fmt_out.video.i_frame_rate_base /
                                              p_dec->fmt_out.video.i_frame_rate;
 
             //msg_Dbg( p_dec, "-------------- XXX0 dts=%"PRId64" pts=%"PRId64" interpolated=%"PRId64,
             //         p_pic->i_dts, p_pic->i_pts, p_sys->i_interpolated_dts );
-            if( p_pic->i_dts <= VLC_TS_INVALID )
+            if( p_pic->i_dts <= VLC_TICK_INVALID )
                 p_pic->i_dts = p_sys->i_interpolated_dts;
 
-            if( p_pic->i_pts <= VLC_TS_INVALID )
+            if( p_pic->i_pts <= VLC_TICK_INVALID )
             {
                 if( !p_sys->sh.b_has_bframe || (p_pic->i_flags & BLOCK_FLAG_TYPE_B ) )
                     p_pic->i_pts = p_pic->i_dts;
@@ -417,14 +417,14 @@ static block_t *ParseIDU( decoder_t *p_dec, bool *pb_ts_used, block_t *p_frag )
 
         /* Reset context */
         p_sys->b_frame = false;
-        p_sys->i_frame_dts = VLC_TS_INVALID;
-        p_sys->i_frame_pts = VLC_TS_INVALID;
+        p_sys->i_frame_dts = VLC_TICK_INVALID;
+        p_sys->i_frame_pts = VLC_TICK_INVALID;
         p_sys->p_frame = NULL;
         p_sys->pp_last = &p_sys->p_frame;
     }
 
     /*  */
-    if( p_sys->i_frame_dts <= VLC_TS_INVALID && p_sys->i_frame_pts <= VLC_TS_INVALID )
+    if( p_sys->i_frame_dts <= VLC_TICK_INVALID && p_sys->i_frame_pts <= VLC_TICK_INVALID )
     {
         p_sys->i_frame_dts = p_frag->i_dts;
         p_sys->i_frame_pts = p_frag->i_pts;
diff --git a/modules/stream_out/autodel.c b/modules/stream_out/autodel.c
index 68df0e785e54..9a04fd320f20 100644
--- a/modules/stream_out/autodel.c
+++ b/modules/stream_out/autodel.c
@@ -122,7 +122,7 @@ static sout_stream_id_sys_t * Add( sout_stream_t *p_stream,
     es_format_Copy( &p_es->fmt, p_fmt );
 
     p_es->id = NULL;
-    p_es->i_last = VLC_TS_INVALID;
+    p_es->i_last = VLC_TICK_INVALID;
     p_es->b_error = false;
     TAB_APPEND( p_sys->i_es_num, p_sys->pp_es, p_es );
 
diff --git a/modules/stream_out/bridge.c b/modules/stream_out/bridge.c
index 55d017eec5bd..2b29bacdd4b9 100644
--- a/modules/stream_out/bridge.c
+++ b/modules/stream_out/bridge.c
@@ -284,7 +284,7 @@ static sout_stream_id_sys_t * AddOut( sout_stream_t *p_stream, const es_format_t
     p_es->b_empty = false;
 
     p_es->id = NULL;
-    p_es->i_last = VLC_TS_INVALID;
+    p_es->i_last = VLC_TICK_INVALID;
     p_es->b_changed = true;
 
     msg_Dbg( p_stream, "bridging out input codec=%4.4s id=%d pos=%d",
@@ -418,8 +418,8 @@ static int OpenIn( vlc_object_t *p_this )
     var_Get( p_stream, SOUT_CFG_PREFIX_IN "placeholder-delay", &val );
     p_sys->i_placeholder_delay = (vlc_tick_t)val.i_int * 1000;
 
-    p_sys->i_last_video = VLC_TS_INVALID;
-    p_sys->i_last_audio = VLC_TS_INVALID;
+    p_sys->i_last_video = VLC_TICK_INVALID;
+    p_sys->i_last_audio = VLC_TICK_INVALID;
     p_sys->id_video = NULL;
     p_sys->id_audio = NULL;
 
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 697db73e4baa..217384815772 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -113,8 +113,8 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
  , m_httpd_file(NULL)
  , m_art_url(NULL)
  , m_art_idx(0)
- , m_cc_time_date( VLC_TS_INVALID )
- , m_cc_time( VLC_TS_INVALID )
+ , m_cc_time_date( VLC_TICK_INVALID )
+ , m_cc_time( VLC_TICK_INVALID )
  , m_pingRetriesLeft( PING_WAIT_RETRIES )
 {
     m_communication = new ChromecastCommunication( p_this,
@@ -405,9 +405,9 @@ void intf_sys_t::setHasInput( const std::string mime_type )
     m_paused = false;
     m_cc_eof = false;
     m_request_load = true;
-    m_cc_time_last_request_date = VLC_TS_INVALID;
-    m_cc_time_date = VLC_TS_INVALID;
-    m_cc_time = VLC_TS_INVALID;
+    m_cc_time_last_request_date = VLC_TICK_INVALID;
+    m_cc_time_date = VLC_TICK_INVALID;
+    m_cc_time = VLC_TICK_INVALID;
     m_mediaSessionId = 0;
 
     tryLoad();
@@ -1169,7 +1169,7 @@ vlc_tick_t intf_sys_t::getPlaybackTimestamp()
         case Buffering:
         case Paused:
             if( !m_played_once )
-                return VLC_TS_INVALID;
+                return VLC_TICK_INVALID;
             /* fallthrough */
         case Playing:
         {
@@ -1185,7 +1185,7 @@ vlc_tick_t intf_sys_t::getPlaybackTimestamp()
             return m_cc_time + now - m_cc_time_date;
         }
         default:
-            return VLC_TS_INVALID;
+            return VLC_TICK_INVALID;
     }
 }
 
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index 5b9461ba157f..01e63b0629e3 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -195,7 +195,7 @@ struct demux_cc
         int64_t time = m_start_time;
         vlc_tick_t cc_time = getCCTime();
 
-        if( cc_time != VLC_TS_INVALID )
+        if( cc_time != VLC_TICK_INVALID )
             time += cc_time;
         m_last_time = time;
         return time;
diff --git a/modules/stream_out/delay.c b/modules/stream_out/delay.c
index 3badf94c901a..d126f379d6a2 100644
--- a/modules/stream_out/delay.c
+++ b/modules/stream_out/delay.c
@@ -163,9 +163,9 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
         block_t *p_block = p_buffer;
         while ( p_block != NULL )
         {
-            if ( p_block->i_pts != VLC_TS_INVALID )
+            if ( p_block->i_pts != VLC_TICK_INVALID )
                 p_block->i_pts += p_sys->i_delay;
-            if ( p_block->i_dts != VLC_TS_INVALID )
+            if ( p_block->i_dts != VLC_TICK_INVALID )
                 p_block->i_dts += p_sys->i_delay;
             p_block = p_block->p_next;
         }
diff --git a/modules/stream_out/display.c b/modules/stream_out/display.c
index 46fae8537e95..8844340c50ab 100644
--- a/modules/stream_out/display.c
+++ b/modules/stream_out/display.c
@@ -176,12 +176,12 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
 
         if( id != NULL && p_buffer->i_buffer > 0 )
         {
-            if( p_buffer->i_dts <= VLC_TS_INVALID )
+            if( p_buffer->i_dts <= VLC_TICK_INVALID )
                 p_buffer->i_dts = 0;
             else
                 p_buffer->i_dts += p_sys->i_delay;
 
-            if( p_buffer->i_pts <= VLC_TS_INVALID )
+            if( p_buffer->i_pts <= VLC_TICK_INVALID )
                 p_buffer->i_pts = 0;
             else
                 p_buffer->i_pts += p_sys->i_delay;
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index 7458f463599a..099d62b13a37 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -524,7 +524,7 @@ static int Open( vlc_object_t *p_this )
      * without waiting (and already did in the VoD case). So until then,
      * we use an arbitrary reference PTS for timestamp computations, and
      * then actual PTS will catch up using offsets. */
-    p_sys->i_npt_zero = VLC_TS_INVALID;
+    p_sys->i_npt_zero = VLC_TICK_INVALID;
     p_sys->i_pts_zero = rtp_init_ts(p_sys->p_vod_media,
                                     p_sys->psz_vod_session);
     p_sys->i_es = 0;
@@ -1172,7 +1172,7 @@ static sout_stream_id_sys_t *Add( sout_stream_t *p_stream,
 #endif
 
     vlc_mutex_lock( &p_sys->lock_ts );
-    id->b_ts_init = ( p_sys->i_npt_zero != VLC_TS_INVALID );
+    id->b_ts_init = ( p_sys->i_npt_zero != VLC_TICK_INVALID );
     vlc_mutex_unlock( &p_sys->lock_ts );
     if( id->b_ts_init )
         id->i_ts_offset = rtp_compute_ts( id->rtp_fmt.clock_rate,
@@ -1597,7 +1597,7 @@ int64_t rtp_get_ts( const sout_stream_t *p_stream, const sout_stream_id_sys_t *i
     i_npt_zero = p_sys->i_npt_zero;
     vlc_mutex_unlock( &p_sys->lock_ts );
 
-    if( i_npt_zero == VLC_TS_INVALID )
+    if( i_npt_zero == VLC_TICK_INVALID )
         return p_sys->i_pts_zero;
 
     vlc_tick_t now = mdate();
@@ -1618,7 +1618,7 @@ void rtp_packetize_common( sout_stream_id_sys_t *id, block_t *out,
     {
         sout_stream_sys_t *p_sys = id->p_stream->p_sys;
         vlc_mutex_lock( &p_sys->lock_ts );
-        if( p_sys->i_npt_zero == VLC_TS_INVALID )
+        if( p_sys->i_npt_zero == VLC_TICK_INVALID )
         {
             /* This is the first packet of any ES. We initialize the
              * NPT=0 time reference, and the offset to match the
diff --git a/modules/stream_out/rtpfmt.c b/modules/stream_out/rtpfmt.c
index e7db9aa4aae4..7123261cfa66 100644
--- a/modules/stream_out/rtpfmt.c
+++ b/modules/stream_out/rtpfmt.c
@@ -923,7 +923,7 @@ static int rtp_packetize_mpv( sout_stream_id_sys_t *id, block_t *in )
 
         /* rtp common header */
         rtp_packetize_common( id, out, (i == i_count - 1)?1:0,
-                          in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts );
+                          in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts );
 
         SetDWBE( out->p_buffer + 12, h );
 
@@ -1041,7 +1041,7 @@ static int rtp_packetize_split( sout_stream_id_sys_t *id, block_t *in )
 
         /* rtp common header */
         rtp_packetize_common( id, out, (i == i_count - 1),
-                      (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) );
+                      (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts) );
         memcpy( &out->p_buffer[12], p_data, i_payload );
 
         out->i_dts    = in->i_dts + i * in->i_length / i_count;
@@ -1142,7 +1142,7 @@ static int rtp_packetize_mp4a_latm( sout_stream_id_sys_t *id, block_t *in )
 
         /* rtp common header */
         rtp_packetize_common( id, out, ((i == i_count - 1) ? 1 : 0),
-                      (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) );
+                      (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts) );
 
         if( i == 0 )
         {
@@ -1189,7 +1189,7 @@ static int rtp_packetize_mp4a( sout_stream_id_sys_t *id, block_t *in )
 
         /* rtp common header */
         rtp_packetize_common( id, out, ((i == i_count - 1)?1:0),
-                      (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) );
+                      (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts) );
         /* AU headers */
         /* AU headers length (bits) */
         out->p_buffer[12] = 0;
@@ -1257,7 +1257,7 @@ static int rtp_packetize_h263( sout_stream_id_sys_t *id, block_t *in )
         /* rtp common header */
         //b_m_bit = 1; // always contains end of frame
         rtp_packetize_common( id, out, (i == i_count - 1)?1:0,
-                          in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts );
+                          in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts );
 
         /* h263 header */
         SetWBE( out->p_buffer + 12, h );
@@ -1352,7 +1352,7 @@ static int rtp_packetize_h264( sout_stream_id_sys_t *id, block_t *in )
     {
         /* TODO add STAP-A to remove a lot of overhead with small slice/sei/... */
         rtp_packetize_h264_nal( id, p_nal, i_nal,
-                (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts), in->i_dts,
+                (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts), in->i_dts,
                 it.p_head + 3 >= it.p_tail, in->i_length * i_nal / in->i_buffer );
     }
 
@@ -1433,7 +1433,7 @@ static int rtp_packetize_h265( sout_stream_id_sys_t *id, block_t *in )
     while( hxxx_annexb_iterate_next( &it, &p_nal, &i_nal ) )
     {
         rtp_packetize_h265_nal( id, p_nal, i_nal,
-                (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts), in->i_dts,
+                (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts), in->i_dts,
                 it.p_head + 3 >= it.p_tail, in->i_length * i_nal / in->i_buffer );
     }
 
@@ -1458,7 +1458,7 @@ static int rtp_packetize_amr( sout_stream_id_sys_t *id, block_t *in )
 
         /* rtp common header */
         rtp_packetize_common( id, out, ((i == i_count - 1)?1:0),
-                      (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) );
+                      (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts) );
         /* Payload header */
         out->p_buffer[12] = 0xF0; /* CMR */
         out->p_buffer[13] = p_data[0]&0x7C; /* ToC */ /* FIXME: frame type */
@@ -1595,7 +1595,7 @@ static int rtp_packetize_spx( sout_stream_id_sys_t *id, block_t *in )
 
     /* Add the RTP header to our p_output buffer. */
     rtp_packetize_common( id, p_out, 0,
-                        (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) );
+                        (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts) );
     /* Copy the Speex payload to the p_output buffer */
     memcpy( &p_out->p_buffer[12], p_buffer, i_data_size );
 
@@ -1624,7 +1624,7 @@ static int rtp_packetize_g726( sout_stream_id_sys_t *id, block_t *in, int i_pad
 
         /* rtp common header */
         rtp_packetize_common( id, out, 0,
-                      (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) );
+                      (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts) );
 
         memcpy( &out->p_buffer[12], p_data, i_payload );
 
@@ -1697,7 +1697,7 @@ static int rtp_packetize_vp8( sout_stream_id_sys_t *id, block_t *in )
 
         /* rtp common header */
         rtp_packetize_common( id, out, (i == i_count - 1),
-                      (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) );
+                      (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts) );
         memcpy( &out->p_buffer[RTP_VP8_PAYLOAD_START], p_data, i_payload );
 
         out->i_dts    = in->i_dts + i * in->i_length / i_count;
@@ -1839,7 +1839,7 @@ static int rtp_packetize_rawvideo( sout_stream_id_sys_t *id, block_t *in, vlc_fo
 
         /* rtp common header */
         rtp_packetize_common( id, out, i_line_number >= i_height,
-                (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) );
+                (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts) );
 
         out->i_dts    = in->i_dts;
         out->i_length = in->i_length;
@@ -2030,7 +2030,7 @@ static int rtp_packetize_jpeg( sout_stream_id_sys_t *id, block_t *in )
 
         /* rtp common header */
         rtp_packetize_common( id, out, (i_payload == i_data),
-                      (in->i_pts > VLC_TS_INVALID ? in->i_pts : in->i_dts) );
+                      (in->i_pts > VLC_TICK_INVALID ? in->i_pts : in->i_dts) );
         memcpy( p, p_data, i_payload );
 
         out->i_dts    = in->i_dts;
diff --git a/modules/stream_out/stats.c b/modules/stream_out/stats.c
index 69bc549dc063..15a23e16fd25 100644
--- a/modules/stream_out/stats.c
+++ b/modules/stream_out/stats.c
@@ -175,7 +175,7 @@ static sout_stream_id_sys_t * Add( sout_stream_t *p_stream, const es_format_t *p
     }
     id->next_id = NULL;
     id->segment_number = 0;
-    id->previous_dts = VLC_TS_INVALID;
+    id->previous_dts = VLC_TICK_INVALID;
     id->track_duration = 0;
     InitMD5( &id->hash );
 
@@ -227,8 +227,8 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
         /* We could just set p_sys->output to stdout and remove user of msg_Dbg
          * if we don't need ability to output info to gui modules (like qt messages window
          */
-        vlc_tick_t dts_difference = VLC_TS_INVALID;
-        if( likely( id->previous_dts != VLC_TS_INVALID ) )
+        vlc_tick_t dts_difference = VLC_TICK_INVALID;
+        if( likely( id->previous_dts != VLC_TICK_INVALID ) )
             dts_difference = p_block->i_dts - id->previous_dts;
         if( p_sys->output )
         {
diff --git a/modules/stream_out/transcode/audio.c b/modules/stream_out/transcode/audio.c
index 54ad30970590..2222314bdef9 100644
--- a/modules/stream_out/transcode/audio.c
+++ b/modules/stream_out/transcode/audio.c
@@ -345,7 +345,7 @@ int transcode_audio_process( sout_stream_t *p_stream,
             vlc_tick_t i_pts = date_Get( &id->next_input_pts );
             vlc_tick_t i_drift = 0;
 
-            if( likely( p_audio_buf->i_pts != VLC_TS_INVALID ) )
+            if( likely( p_audio_buf->i_pts != VLC_TICK_INVALID ) )
                 i_drift = p_audio_buf->i_pts - i_pts;
 
             if ( unlikely(i_drift > MASTER_SYNC_MAX_DRIFT
@@ -356,7 +356,7 @@ int transcode_audio_process( sout_stream_t *p_stream,
                     i_drift );
                 date_Set( &id->next_input_pts, p_audio_buf->i_pts );
                 i_pts = date_Get( &id->next_input_pts );
-                if( likely(p_audio_buf->i_pts != VLC_TS_INVALID ) )
+                if( likely(p_audio_buf->i_pts != VLC_TICK_INVALID ) )
                     i_drift = p_audio_buf->i_pts - i_pts;
             }
             p_sys->i_master_drift = i_drift;
diff --git a/modules/video_filter/deinterlace/algo_ivtc.c b/modules/video_filter/deinterlace/algo_ivtc.c
index 62e7a754b626..f75783f52544 100644
--- a/modules/video_filter/deinterlace/algo_ivtc.c
+++ b/modules/video_filter/deinterlace/algo_ivtc.c
@@ -1216,7 +1216,7 @@ static bool IVTCOutputOrDropFrame( filter_t *p_filter, picture_t *p_dst )
 
     filter_sys_t *p_sys = p_filter->p_sys;
     ivtc_sys_t *p_ivtc  = &p_sys->ivtc;
-    vlc_tick_t t_final = VLC_TS_INVALID; /* for custom timestamp mangling */
+    vlc_tick_t t_final = VLC_TICK_INVALID; /* for custom timestamp mangling */
 
     picture_t *p_curr = p_sys->context.pp_history[1];
     picture_t *p_next = p_sys->context.pp_history[2];
@@ -1458,7 +1458,7 @@ static bool IVTCOutputOrDropFrame( filter_t *p_filter, picture_t *p_dst )
     /* Note that picture_Copy() copies the PTS, too. Apply timestamp mangling
        now, if any was needed.
     */
-    if( t_final > VLC_TS_INVALID )
+    if( t_final > VLC_TICK_INVALID )
         p_dst->date = t_final;
 
     return true;
diff --git a/modules/video_filter/deinterlace/common.c b/modules/video_filter/deinterlace/common.c
index ce15beb14d71..89155f4a4c4b 100644
--- a/modules/video_filter/deinterlace/common.c
+++ b/modules/video_filter/deinterlace/common.c
@@ -40,7 +40,7 @@ void InitDeinterlacingContext( struct deinterlace_ctx *p_context )
     p_context->settings.b_use_frame_history = false;
     p_context->settings.b_custom_pts = false;
 
-    p_context->meta[0].pi_date = VLC_TS_INVALID;
+    p_context->meta[0].pi_date = VLC_TICK_INVALID;
     p_context->meta[0].pi_nb_fields = 2;
     p_context->meta[0].pb_top_field_first = true;
     for( int i = 1; i < METADATA_SIZE; i++ )
@@ -54,7 +54,7 @@ void InitDeinterlacingContext( struct deinterlace_ctx *p_context )
 
 void FlushDeinterlacing(struct deinterlace_ctx *p_context)
 {
-    p_context->meta[0].pi_date = VLC_TS_INVALID;
+    p_context->meta[0].pi_date = VLC_TICK_INVALID;
     p_context->meta[0].pi_nb_fields = 2;
     p_context->meta[0].pb_top_field_first = true;
     for( int i = 1; i < METADATA_SIZE; i++ )
@@ -81,7 +81,7 @@ vlc_tick_t GetFieldDuration(const struct deinterlace_ctx *p_context,
     /* Find oldest valid logged date.
        The current input frame doesn't count. */
     for( ; i < iend; i++ )
-        if( p_context->meta[i].pi_date > VLC_TS_INVALID )
+        if( p_context->meta[i].pi_date > VLC_TICK_INVALID )
             break;
     if( i < iend )
     {
@@ -324,10 +324,10 @@ picture_t *DoDeinterlacing( filter_t *p_filter,
             {
                 /* XXX it's not really good especially for the first picture, but
                  * I don't think that delaying by one frame is worth it */
-                if( i_base_pts > VLC_TS_INVALID )
+                if( i_base_pts > VLC_TICK_INVALID )
                     p_dst[i]->date = i_base_pts + i * i_field_dur;
                 else
-                    p_dst[i]->date = VLC_TS_INVALID;
+                    p_dst[i]->date = VLC_TICK_INVALID;
             }
         }
     }
diff --git a/modules/video_filter/fps.c b/modules/video_filter/fps.c
index 1ea43d8d0013..2c9e6940a318 100644
--- a/modules/video_filter/fps.c
+++ b/modules/video_filter/fps.c
@@ -85,7 +85,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_picture)
 
     /* First time we get some valid timestamp, we'll take it as base for output
         later on we retake new timestamp if it has jumped too much */
-    if( unlikely( ( date_Get( &p_sys->next_output_pts ) == VLC_TS_INVALID ) ||
+    if( unlikely( ( date_Get( &p_sys->next_output_pts ) == VLC_TICK_INVALID ) ||
                    ( p_picture->date > ( date_Get( &p_sys->next_output_pts ) + (vlc_tick_t)p_sys->i_output_frame_interval ) )
                 ) )
     {
@@ -175,7 +175,7 @@ static int Open( vlc_object_t *p_this)
     date_Init( &p_sys->next_output_pts,
                p_filter->fmt_out.video.i_frame_rate, p_filter->fmt_out.video.i_frame_rate_base );
 
-    date_Set( &p_sys->next_output_pts, VLC_TS_INVALID );
+    date_Set( &p_sys->next_output_pts, VLC_TICK_INVALID );
     p_sys->p_previous_pic = NULL;
 
     p_filter->pf_video_filter = Filter;
diff --git a/modules/visualization/goom.c b/modules/visualization/goom.c
index 8d5538bb1aec..ba219c16823f 100644
--- a/modules/visualization/goom.c
+++ b/modules/visualization/goom.c
@@ -242,12 +242,12 @@ static int FillBuffer( int16_t *p_data, int *pi_data,
                 p_block->i_buffer / sizeof(float) / p_this->i_channels );
 
         /* Date management */
-        if( p_block->i_pts > VLC_TS_INVALID &&
+        if( p_block->i_pts > VLC_TICK_INVALID &&
             p_block->i_pts != date_Get( pi_date_end ) )
         {
            date_Set( pi_date_end, p_block->i_pts );
         }
-        p_block->i_pts = VLC_TS_INVALID;
+        p_block->i_pts = VLC_TICK_INVALID;
 
         date_Increment( pi_date_end, i_samples );
 
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 905255c1122d..8dfe4f5419cb 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -107,7 +107,7 @@ error:
     }
 
 
-    owner->sync.end = VLC_TS_INVALID;
+    owner->sync.end = VLC_TICK_INVALID;
     owner->sync.resamp_type = AOUT_RESAMPLING_NONE;
     owner->sync.discontinuity = true;
     aout_OutputUnlock (p_aout);
@@ -168,7 +168,7 @@ static int aout_CheckReady (audio_output_t *aout)
         }
 
         msg_Dbg (aout, "restarting filters...");
-        owner->sync.end = VLC_TS_INVALID;
+        owner->sync.end = VLC_TICK_INVALID;
         owner->sync.resamp_type = AOUT_RESAMPLING_NONE;
 
         if (owner->mixer_format.i_format)
@@ -277,7 +277,7 @@ static void aout_DecSynchronize (audio_output_t *aout, vlc_tick_t dec_pts,
         aout_OutputFlush (aout, false);
 
         aout_StopResampling (aout);
-        owner->sync.end = VLC_TS_INVALID;
+        owner->sync.end = VLC_TICK_INVALID;
         owner->sync.discontinuity = true;
 
         /* Now the output might be too early... Recheck. */
@@ -434,7 +434,7 @@ void aout_DecChangePause (audio_output_t *aout, bool paused, vlc_tick_t date)
     aout_owner_t *owner = aout_owner (aout);
 
     aout_OutputLock (aout);
-    if (owner->sync.end != VLC_TS_INVALID)
+    if (owner->sync.end != VLC_TICK_INVALID)
     {
         if (paused)
             owner->sync.end -= date;
@@ -451,7 +451,7 @@ void aout_DecFlush (audio_output_t *aout, bool wait)
     aout_owner_t *owner = aout_owner (aout);
 
     aout_OutputLock (aout);
-    owner->sync.end = VLC_TS_INVALID;
+    owner->sync.end = VLC_TICK_INVALID;
     if (owner->mixer_format.i_format)
     {
         if (wait)
diff --git a/src/input/clock.c b/src/input/clock.c
index 9d744d6b0ccc..3099cfeec5c8 100644
--- a/src/input/clock.c
+++ b/src/input/clock.c
@@ -196,16 +196,16 @@ input_clock_t *input_clock_New( int i_rate )
 
     vlc_mutex_init( &cl->lock );
     cl->b_has_reference = false;
-    cl->ref = clock_point_Create( VLC_TS_INVALID, VLC_TS_INVALID );
+    cl->ref = clock_point_Create( VLC_TICK_INVALID, VLC_TICK_INVALID );
     cl->b_has_external_clock = false;
 
-    cl->last = clock_point_Create( VLC_TS_INVALID, VLC_TS_INVALID );
+    cl->last = clock_point_Create( VLC_TICK_INVALID, VLC_TICK_INVALID );
 
-    cl->i_ts_max = VLC_TS_INVALID;
+    cl->i_ts_max = VLC_TICK_INVALID;
 
     cl->i_buffering_duration = 0;
 
-    cl->i_next_drift_update = VLC_TS_INVALID;
+    cl->i_next_drift_update = VLC_TICK_INVALID;
     AvgInit( &cl->drift, 10 );
 
     cl->late.i_index = 0;
@@ -215,7 +215,7 @@ input_clock_t *input_clock_New( int i_rate )
     cl->i_rate = i_rate;
     cl->i_pts_delay = 0;
     cl->b_paused = false;
-    cl->i_pause_date = VLC_TS_INVALID;
+    cl->i_pause_date = VLC_TICK_INVALID;
 
     return cl;
 }
@@ -243,7 +243,7 @@ void input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
 {
     bool b_reset_reference = false;
 
-    assert( i_ck_stream > VLC_TS_INVALID && i_ck_system > VLC_TS_INVALID );
+    assert( i_ck_stream > VLC_TICK_INVALID && i_ck_system > VLC_TICK_INVALID );
 
     vlc_mutex_lock( &cl->lock );
 
@@ -252,7 +252,7 @@ void input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
         /* */
         b_reset_reference= true;
     }
-    else if( cl->last.i_stream > VLC_TS_INVALID &&
+    else if( cl->last.i_stream > VLC_TICK_INVALID &&
              ( (cl->last.i_stream - i_ck_stream) > CR_MAX_GAP ||
                (cl->last.i_stream - i_ck_stream) < -CR_MAX_GAP ) )
     {
@@ -260,7 +260,7 @@ void input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
          * warning from the stream control facilities (dd-edited
          * stream ?). */
         msg_Warn( p_log, "clock gap, unexpected stream discontinuity" );
-        cl->i_ts_max = VLC_TS_INVALID;
+        cl->i_ts_max = VLC_TICK_INVALID;
 
         /* */
         msg_Warn( p_log, "feeding synchro with a new reference point trying to recover from clock gap" );
@@ -270,7 +270,7 @@ void input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
     /* */
     if( b_reset_reference )
     {
-        cl->i_next_drift_update = VLC_TS_INVALID;
+        cl->i_next_drift_update = VLC_TICK_INVALID;
         AvgReset( &cl->drift );
 
         /* Feed synchro with a new reference point. */
@@ -334,9 +334,9 @@ void input_clock_Reset( input_clock_t *cl )
     vlc_mutex_lock( &cl->lock );
 
     cl->b_has_reference = false;
-    cl->ref = clock_point_Create( VLC_TS_INVALID, VLC_TS_INVALID );
+    cl->ref = clock_point_Create( VLC_TICK_INVALID, VLC_TICK_INVALID );
     cl->b_has_external_clock = false;
-    cl->i_ts_max = VLC_TS_INVALID;
+    cl->i_ts_max = VLC_TICK_INVALID;
 
     vlc_mutex_unlock( &cl->lock );
 }
@@ -419,9 +419,9 @@ int input_clock_ConvertTS( vlc_object_t *p_object, input_clock_t *cl,
         vlc_mutex_unlock( &cl->lock );
         msg_Err(p_object, "Timestamp conversion failed for %"PRId64": "
                 "no reference clock", *pi_ts0);
-        *pi_ts0 = VLC_TS_INVALID;
+        *pi_ts0 = VLC_TICK_INVALID;
         if( pi_ts1 )
-            *pi_ts1 = VLC_TS_INVALID;
+            *pi_ts1 = VLC_TICK_INVALID;
         return VLC_EGENERIC;
     }
 
@@ -430,7 +430,7 @@ int input_clock_ConvertTS( vlc_object_t *p_object, input_clock_t *cl,
     const vlc_tick_t i_ts_delay = cl->i_pts_delay + ClockGetTsOffset( cl );
 
     /* */
-    if( *pi_ts0 > VLC_TS_INVALID )
+    if( *pi_ts0 > VLC_TICK_INVALID )
     {
         *pi_ts0 = ClockStreamToSystem( cl, *pi_ts0 + AvgGet( &cl->drift ) );
         if( *pi_ts0 > cl->i_ts_max )
@@ -439,7 +439,7 @@ int input_clock_ConvertTS( vlc_object_t *p_object, input_clock_t *cl,
     }
 
     /* XXX we do not update i_ts_max on purpose */
-    if( pi_ts1 && *pi_ts1 > VLC_TS_INVALID )
+    if( pi_ts1 && *pi_ts1 > VLC_TICK_INVALID )
     {
         *pi_ts1 = ClockStreamToSystem( cl, *pi_ts1 + AvgGet( &cl->drift ) ) +
                   i_ts_delay;
@@ -448,7 +448,7 @@ int input_clock_ConvertTS( vlc_object_t *p_object, input_clock_t *cl,
     vlc_mutex_unlock( &cl->lock );
 
     /* Check ts validity */
-    if (i_ts_bound != INT64_MAX && *pi_ts0 > VLC_TS_INVALID) {
+    if (i_ts_bound != INT64_MAX && *pi_ts0 > VLC_TICK_INVALID) {
         if (*pi_ts0 >= mdate() + i_ts_delay + i_ts_buffering + i_ts_bound) {
             msg_Err(p_object,
                 "Timestamp conversion failed (delay %"PRId64", buffering "
@@ -604,7 +604,7 @@ vlc_tick_t input_clock_GetJitter( input_clock_t *cl )
 static vlc_tick_t ClockStreamToSystem( input_clock_t *cl, vlc_tick_t i_stream )
 {
     if( !cl->b_has_reference )
-        return VLC_TS_INVALID;
+        return VLC_TICK_INVALID;
 
     return ( i_stream - cl->ref.i_stream ) * cl->i_rate / INPUT_RATE_DEFAULT +
            cl->ref.i_system;
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 9439d794c6e6..69488a681c4b 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -634,15 +634,15 @@ static vlc_tick_t DecoderGetDisplayDate( decoder_t *p_dec, vlc_tick_t i_ts )
 
     vlc_mutex_lock( &p_owner->lock );
     if( p_owner->b_waiting || p_owner->paused )
-        i_ts = VLC_TS_INVALID;
+        i_ts = VLC_TICK_INVALID;
     vlc_mutex_unlock( &p_owner->lock );
 
-    if( !p_owner->p_clock || i_ts <= VLC_TS_INVALID )
+    if( !p_owner->p_clock || i_ts <= VLC_TICK_INVALID )
         return i_ts;
 
     if( input_clock_ConvertTS( VLC_OBJECT(p_dec), p_owner->p_clock, NULL, &i_ts, NULL, INT64_MAX ) ) {
         msg_Err(p_dec, "Could not get display date for timestamp %"PRId64"", i_ts);
-        return VLC_TS_INVALID;
+        return VLC_TICK_INVALID;
     }
 
     return i_ts;
@@ -709,7 +709,7 @@ int decoder_GetInputAttachments( decoder_t *p_dec,
 vlc_tick_t decoder_GetDisplayDate( decoder_t *p_dec, vlc_tick_t i_ts )
 {
     if( !p_dec->pf_get_display_date )
-        return VLC_TS_INVALID;
+        return VLC_TICK_INVALID;
 
     return p_dec->pf_get_display_date( p_dec, i_ts );
 }
@@ -773,9 +773,9 @@ static inline void DecoderUpdatePreroll( int64_t *pi_preroll, const block_t *p )
     else if( (p->i_flags & BLOCK_FLAG_DISCONTINUITY) &&
              (p->i_buffer == 0 || (p->i_flags & BLOCK_FLAG_CORRUPTED)) )
         *pi_preroll = INT64_MAX;
-    else if( p->i_dts > VLC_TS_INVALID )
+    else if( p->i_dts > VLC_TICK_INVALID )
         *pi_preroll = __MIN( *pi_preroll, p->i_dts );
-    else if( p->i_pts > VLC_TS_INVALID )
+    else if( p->i_pts > VLC_TICK_INVALID )
         *pi_preroll = __MIN( *pi_preroll, p->i_pts );
 }
 
@@ -795,10 +795,10 @@ static void DecoderFixTs( decoder_t *p_dec, vlc_tick_t *pi_ts0, vlc_tick_t *pi_t
     const bool b_ephemere = pi_ts1 && *pi_ts0 == *pi_ts1;
     int i_rate;
 
-    if( *pi_ts0 > VLC_TS_INVALID )
+    if( *pi_ts0 > VLC_TICK_INVALID )
     {
         *pi_ts0 += i_es_delay;
-        if( pi_ts1 && *pi_ts1 > VLC_TS_INVALID )
+        if( pi_ts1 && *pi_ts1 > VLC_TICK_INVALID )
             *pi_ts1 += i_es_delay;
         if( i_ts_bound != INT64_MAX )
             i_ts_bound += i_es_delay;
@@ -809,7 +809,7 @@ static void DecoderFixTs( decoder_t *p_dec, vlc_tick_t *pi_ts0, vlc_tick_t *pi_t
                         ", %"PRId64" for %s", *pi_ts0, *pi_ts1, psz_name );
             else
                 msg_Err(p_dec, "Could not convert timestamp %"PRId64" for %s", *pi_ts0, psz_name );
-            *pi_ts0 = VLC_TS_INVALID;
+            *pi_ts0 = VLC_TICK_INVALID;
         }
     }
     else
@@ -851,7 +851,7 @@ static int DecoderPlaySout( decoder_t *p_dec, block_t *p_sout_block )
 
     vlc_mutex_unlock( &p_owner->lock );
 
-    /* FIXME --VLC_TS_INVALID inspect stream_output*/
+    /* FIXME --VLC_TICK_INVALID inspect stream_output*/
     return sout_InputSendBuffer( p_owner->p_sout_input, p_sout_block );
 }
 
@@ -1021,10 +1021,10 @@ static int DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,
         msg_Dbg( p_dec, "end of video preroll" );
 
         if( p_vout )
-            vout_Flush( p_vout, VLC_TS_INVALID+1 );
+            vout_Flush( p_vout, VLC_TICK_INVALID+1 );
     }
 
-    if( p_picture->date <= VLC_TS_INVALID )
+    if( p_picture->date <= VLC_TICK_INVALID )
     {
         msg_Warn( p_dec, "non-dated video buffer received" );
         goto discard;
@@ -1050,7 +1050,7 @@ static int DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,
         p_picture->b_force = true;
     }
 
-    const bool b_dated = p_picture->date > VLC_TS_INVALID;
+    const bool b_dated = p_picture->date > VLC_TICK_INVALID;
     int i_rate = INPUT_RATE_DEFAULT;
     DecoderFixTs( p_dec, &p_picture->date, NULL, NULL,
                   &i_rate, DECODER_BOGUS_VIDEO_DELAY );
@@ -1068,8 +1068,8 @@ static int DecoderPlayVideo( decoder_t *p_dec, picture_t *p_picture,
     if( p_vout == NULL )
         goto discard;
 
-    if( p_picture->b_force || p_picture->date > VLC_TS_INVALID )
-        /* FIXME: VLC_TS_INVALID -- verify video_output */
+    if( p_picture->b_force || p_picture->date > VLC_TICK_INVALID )
+        /* FIXME: VLC_TICK_INVALID -- verify video_output */
     {
         if( i_rate != p_owner->i_last_rate || b_first_after_wait )
         {
@@ -1161,7 +1161,7 @@ static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
     }
 
     /* */
-    if( p_audio->i_pts <= VLC_TS_INVALID ) // FIXME --VLC_TS_INVALID verify audio_output/*
+    if( p_audio->i_pts <= VLC_TICK_INVALID ) // FIXME --VLC_TICK_INVALID verify audio_output/*
     {
         msg_Warn( p_dec, "non-dated audio buffer received" );
         *pi_lost_sum += 1;
@@ -1187,7 +1187,7 @@ static int DecoderPlayAudio( decoder_t *p_dec, block_t *p_audio,
 
     audio_output_t *p_aout = p_owner->p_aout;
 
-    if( p_aout != NULL && p_audio->i_pts > VLC_TS_INVALID
+    if( p_aout != NULL && p_audio->i_pts > VLC_TICK_INVALID
      && i_rate >= INPUT_RATE_DEFAULT/AOUT_MAX_INPUT_RATE
      && i_rate <= INPUT_RATE_DEFAULT*AOUT_MAX_INPUT_RATE
      && !DecoderTimedWait( p_dec, p_audio->i_pts - AOUT_MAX_PREPARE_TIME ) )
@@ -1258,7 +1258,7 @@ static void DecoderPlaySpu( decoder_t *p_dec, subpicture_t *p_subpic )
     vout_thread_t *p_vout = p_owner->p_spu_vout;
 
     /* */
-    if( p_subpic->i_start <= VLC_TS_INVALID )
+    if( p_subpic->i_start <= VLC_TICK_INVALID )
     {
         msg_Warn( p_dec, "non-dated spu buffer received" );
         subpicture_Delete( p_subpic );
@@ -1279,7 +1279,7 @@ static void DecoderPlaySpu( decoder_t *p_dec, subpicture_t *p_subpic )
                   NULL, INT64_MAX );
     vlc_mutex_unlock( &p_owner->lock );
 
-    if( p_subpic->i_start <= VLC_TS_INVALID
+    if( p_subpic->i_start <= VLC_TICK_INVALID
      || DecoderTimedWait( p_dec, p_subpic->i_start - SPU_MAX_PREPARE_TIME ) )
     {
         subpicture_Delete( p_subpic );
@@ -1314,9 +1314,9 @@ static int DecoderQueueSpu( decoder_t *p_dec, subpicture_t *p_spu )
     {
         /* Preroll does not work very well with subtitle */
         vlc_mutex_lock( &p_owner->lock );
-        if( p_spu->i_start > VLC_TS_INVALID &&
+        if( p_spu->i_start > VLC_TICK_INVALID &&
             p_spu->i_start < p_owner->i_preroll_end &&
-            ( p_spu->i_stop <= VLC_TS_INVALID || p_spu->i_stop < p_owner->i_preroll_end ) )
+            ( p_spu->i_stop <= VLC_TICK_INVALID || p_spu->i_stop < p_owner->i_preroll_end ) )
         {
             vlc_mutex_unlock( &p_owner->lock );
             subpicture_Delete( p_spu );
@@ -1512,7 +1512,7 @@ static void DecoderProcessFlush( decoder_t *p_dec )
     else if( p_dec->fmt_out.i_cat == VIDEO_ES )
     {
         if( p_owner->p_vout )
-            vout_Flush( p_owner->p_vout, VLC_TS_INVALID+1 );
+            vout_Flush( p_owner->p_vout, VLC_TICK_INVALID+1 );
     }
     else if( p_dec->fmt_out.i_cat == SPU_ES )
     {
@@ -1691,7 +1691,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
     p_owner->p_description = NULL;
 
     p_owner->paused = false;
-    p_owner->pause_date = VLC_TS_INVALID;
+    p_owner->pause_date = VLC_TICK_INVALID;
     p_owner->frames_countdown = 0;
 
     p_owner->b_waiting = false;
diff --git a/src/input/es_out.c b/src/input/es_out.c
index d2689cca3c27..ad09c98b18f7 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -621,12 +621,12 @@ static void EsOutChangePosition( es_out_t *out )
                     input_DecoderStartWait( p_es->p_dec_record );
             }
         }
-        p_es->i_pts_level = VLC_TS_INVALID;
+        p_es->i_pts_level = VLC_TICK_INVALID;
     }
 
     for( int i = 0; i < p_sys->i_pgrm; i++ ) {
         input_clock_Reset( p_sys->pgrm[i]->p_clock );
-        p_sys->pgrm[i]->i_last_pcr = VLC_TS_INVALID;
+        p_sys->pgrm[i]->i_last_pcr = VLC_TICK_INVALID;
     }
 
     p_sys->b_buffering = true;
@@ -1102,7 +1102,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
     p_pgrm->i_es = 0;
     p_pgrm->b_selected = false;
     p_pgrm->b_scrambled = false;
-    p_pgrm->i_last_pcr = VLC_TS_INVALID;
+    p_pgrm->i_last_pcr = VLC_TICK_INVALID;
     p_pgrm->p_meta = NULL;
     p_pgrm->p_clock = input_clock_New( p_sys->i_rate );
     if( !p_pgrm->p_clock )
@@ -1647,7 +1647,7 @@ static es_out_id_t *EsOutAddSlave( es_out_t *out, const es_format_t *fmt, es_out
     es->cc.type = 0;
     es->cc.i_bitmap = 0;
     es->p_master = p_master;
-    es->i_pts_level = VLC_TS_INVALID;
+    es->i_pts_level = VLC_TICK_INVALID;
 
     TAB_APPEND( p_sys->i_es, p_sys->es, es );
 
@@ -2087,26 +2087,26 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
     if( p_sys->i_preroll_end >= 0 )
     {
         int64_t i_date = p_block->i_pts;
-        if( p_block->i_pts <= VLC_TS_INVALID )
+        if( p_block->i_pts <= VLC_TICK_INVALID )
             i_date = p_block->i_dts;
 
         /* In some cases, the demuxer sends non dated packets.
            We use interpolation, previous, or pcr value to compare with
            preroll target timestamp */
-        if( i_date == VLC_TS_INVALID )
+        if( i_date == VLC_TICK_INVALID )
         {
-            if( es->i_pts_level != VLC_TS_INVALID )
+            if( es->i_pts_level != VLC_TICK_INVALID )
                 i_date = es->i_pts_level;
-            else if( es->p_pgrm->i_last_pcr != VLC_TS_INVALID )
+            else if( es->p_pgrm->i_last_pcr != VLC_TICK_INVALID )
                 i_date = es->p_pgrm->i_last_pcr;
         }
 
-        if( i_date != VLC_TS_INVALID )
+        if( i_date != VLC_TICK_INVALID )
             es->i_pts_level = i_date + p_block->i_length;
 
         /* If i_date is still invalid (first/all non dated), expect to be in preroll */
 
-        if( i_date == VLC_TS_INVALID ||
+        if( i_date == VLC_TICK_INVALID ||
             es->i_pts_level < p_sys->i_preroll_end )
             p_block->i_flags |= BLOCK_FLAG_PREROLL;
     }
@@ -2512,7 +2512,7 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
             return VLC_EGENERIC;
 
         i_pcr = va_arg( args, int64_t );
-        if( i_pcr <= VLC_TS_INVALID )
+        if( i_pcr <= VLC_TICK_INVALID )
         {
             msg_Err( p_sys->p_input, "Invalid PCR value in ES_OUT_SET_(GROUP_)PCR !" );
             return VLC_EGENERIC;
diff --git a/src/misc/background_worker.c b/src/misc/background_worker.c
index 204a74b7a4ee..ec6be8bc92e6 100644
--- a/src/misc/background_worker.c
+++ b/src/misc/background_worker.c
@@ -193,7 +193,7 @@ struct background_worker* background_worker_New( void* owner,
     worker->owner = owner;
     worker->head.id = NULL;
     worker->head.active = false;
-    worker->head.deadline = VLC_TS_INVALID;
+    worker->head.deadline = VLC_TICK_INVALID;
 
     vlc_mutex_init( &worker->lock );
     vlc_cond_init( &worker->head.wait );
diff --git a/src/misc/block.c b/src/misc/block.c
index 12299f36ab2e..3fa279ccd1df 100644
--- a/src/misc/block.c
+++ b/src/misc/block.c
@@ -84,7 +84,7 @@ void block_Init( block_t *restrict b, void *buf, size_t size )
     b->i_flags = 0;
     b->i_nb_samples = 0;
     b->i_pts =
-    b->i_dts = VLC_TS_INVALID;
+    b->i_dts = VLC_TICK_INVALID;
     b->i_length = 0;
 #ifndef NDEBUG
     b->pf_release = BlockNoRelease;
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 0338076fd80e..892d5b7dac3b 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -129,7 +129,7 @@ static void picture_Destroy( picture_t *p_picture )
 void picture_Reset( picture_t *p_picture )
 {
     /* */
-    p_picture->date = VLC_TS_INVALID;
+    p_picture->date = VLC_TICK_INVALID;
     p_picture->b_force = false;
     p_picture->b_progressive = false;
     p_picture->i_nb_fields = 2;
diff --git a/src/network/tcp.c b/src/network/tcp.c
index e2920ba4d26d..7448158f55d1 100644
--- a/src/network/tcp.c
+++ b/src/network/tcp.c
@@ -161,7 +161,7 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
             }
 
             struct pollfd ufd;
-            vlc_tick_t deadline = VLC_TS_INVALID;
+            vlc_tick_t deadline = VLC_TICK_INVALID;
 
             ufd.fd = fd;
             ufd.events = POLLOUT;
diff --git a/src/video_output/chrono.h b/src/video_output/chrono.h
index 073f417fb4a0..2a957b5f774c 100644
--- a/src/video_output/chrono.h
+++ b/src/video_output/chrono.h
@@ -46,7 +46,7 @@ static inline void vout_chrono_Init(vout_chrono_t *chrono, int shift, vlc_tick_t
     chrono->shift_var   = shift+1;
     chrono->var         = avg_initial / 2;
 
-    chrono->start = VLC_TS_INVALID;
+    chrono->start = VLC_TICK_INVALID;
 }
 static inline void vout_chrono_Clean(vout_chrono_t *chrono)
 {
@@ -67,7 +67,7 @@ static inline vlc_tick_t vout_chrono_GetLow(vout_chrono_t *chrono)
 
 static inline void vout_chrono_Stop(vout_chrono_t *chrono)
 {
-    assert(chrono->start != VLC_TS_INVALID);
+    assert(chrono->start != VLC_TICK_INVALID);
 
     /* */
     const vlc_tick_t duration = mdate() - chrono->start;
@@ -80,7 +80,7 @@ static inline void vout_chrono_Stop(vout_chrono_t *chrono)
     chrono->var = (((1 << chrono->shift_var) - 1) * chrono->var + var) >> chrono->shift_var;
 
     /* For assert */
-    chrono->start = VLC_TS_INVALID;
+    chrono->start = VLC_TICK_INVALID;
 }
 static inline void vout_chrono_Reset(vout_chrono_t *chrono)
 {
diff --git a/src/video_output/control.c b/src/video_output/control.c
index 0faaf5233ee8..6390f480c840 100644
--- a/src/video_output/control.c
+++ b/src/video_output/control.c
@@ -185,7 +185,7 @@ int vout_control_Pop(vout_control_t *ctrl, vout_control_cmd_t *cmd,
         vlc_cond_broadcast(&ctrl->wait_acknowledge);
 
         /* Spurious wakeups are perfectly fine */
-        if (deadline > VLC_TS_INVALID && ctrl->can_sleep)
+        if (deadline > VLC_TICK_INVALID && ctrl->can_sleep)
             vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock, deadline);
     }
 
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 838b6d3d5d92..592c0474ca3a 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -1200,7 +1200,7 @@ static int ThreadDisplayPicture(vout_thread_t *vout, vlc_tick_t *deadline)
     const vlc_tick_t render_delay = vout_chrono_GetHigh(&vout->p->render) + VOUT_MWAIT_TOLERANCE;
 
     bool drop_next_frame = frame_by_frame;
-    vlc_tick_t date_next = VLC_TS_INVALID;
+    vlc_tick_t date_next = VLC_TICK_INVALID;
     if (!paused && vout->p->displayed.next) {
         date_next = vout->p->displayed.next->date - render_delay;
         if (date_next /* + 0 FIXME */ <= date)
@@ -1218,17 +1218,17 @@ static int ThreadDisplayPicture(vout_thread_t *vout, vlc_tick_t *deadline)
      */
     bool refresh = false;
 
-    vlc_tick_t date_refresh = VLC_TS_INVALID;
-    if (vout->p->displayed.date > VLC_TS_INVALID) {
+    vlc_tick_t date_refresh = VLC_TICK_INVALID;
+    if (vout->p->displayed.date > VLC_TICK_INVALID) {
         date_refresh = vout->p->displayed.date + VOUT_REDISPLAY_DELAY - render_delay;
         refresh = date_refresh <= date;
     }
     bool force_refresh = !drop_next_frame && refresh;
 
     if (!frame_by_frame) {
-        if (date_refresh != VLC_TS_INVALID)
+        if (date_refresh != VLC_TICK_INVALID)
             *deadline = date_refresh;
-        if (date_next != VLC_TS_INVALID && date_next < *deadline)
+        if (date_next != VLC_TICK_INVALID && date_next < *deadline)
             *deadline = date_next;
     }
 
@@ -1294,9 +1294,9 @@ static void ThreadChangePause(vout_thread_t *vout, bool is_paused, vlc_tick_t da
     if (vout->p->pause.is_on) {
         const vlc_tick_t duration = date - vout->p->pause.date;
 
-        if (vout->p->step.timestamp > VLC_TS_INVALID)
+        if (vout->p->step.timestamp > VLC_TICK_INVALID)
             vout->p->step.timestamp += duration;
-        if (vout->p->step.last > VLC_TS_INVALID)
+        if (vout->p->step.last > VLC_TICK_INVALID)
             vout->p->step.last += duration;
         picture_fifo_OffsetDate(vout->p->decoder_fifo, duration);
         if (vout->p->displayed.decoded)
@@ -1305,8 +1305,8 @@ static void ThreadChangePause(vout_thread_t *vout, bool is_paused, vlc_tick_t da
 
         ThreadFilterFlush(vout, false);
     } else {
-        vout->p->step.timestamp = VLC_TS_INVALID;
-        vout->p->step.last      = VLC_TS_INVALID;
+        vout->p->step.timestamp = VLC_TICK_INVALID;
+        vout->p->step.last      = VLC_TICK_INVALID;
     }
     vout->p->pause.is_on = is_paused;
     vout->p->pause.date  = date;
@@ -1318,8 +1318,8 @@ static void ThreadChangePause(vout_thread_t *vout, bool is_paused, vlc_tick_t da
 
 static void ThreadFlush(vout_thread_t *vout, bool below, vlc_tick_t date)
 {
-    vout->p->step.timestamp = VLC_TS_INVALID;
-    vout->p->step.last      = VLC_TS_INVALID;
+    vout->p->step.timestamp = VLC_TICK_INVALID;
+    vout->p->step.last      = VLC_TICK_INVALID;
 
     ThreadFilterFlush(vout, false); /* FIXME too much */
 
@@ -1330,8 +1330,8 @@ static void ThreadFlush(vout_thread_t *vout, bool below, vlc_tick_t date)
             picture_Release(last);
 
             vout->p->displayed.decoded   = NULL;
-            vout->p->displayed.date      = VLC_TS_INVALID;
-            vout->p->displayed.timestamp = VLC_TS_INVALID;
+            vout->p->displayed.date      = VLC_TICK_INVALID;
+            vout->p->displayed.timestamp = VLC_TICK_INVALID;
         }
     }
 
@@ -1343,7 +1343,7 @@ static void ThreadStep(vout_thread_t *vout, vlc_tick_t *duration)
 {
     *duration = 0;
 
-    if (vout->p->step.last <= VLC_TS_INVALID)
+    if (vout->p->step.last <= VLC_TICK_INVALID)
         vout->p->step.last = vout->p->displayed.timestamp;
 
     if (ThreadDisplayPicture(vout, NULL))
@@ -1351,7 +1351,7 @@ static void ThreadStep(vout_thread_t *vout, vlc_tick_t *duration)
 
     vout->p->step.timestamp = vout->p->displayed.timestamp;
 
-    if (vout->p->step.last > VLC_TS_INVALID &&
+    if (vout->p->step.last > VLC_TICK_INVALID &&
         vout->p->step.timestamp > vout->p->step.last) {
         *duration = vout->p->step.timestamp - vout->p->step.last;
         vout->p->step.last = vout->p->step.timestamp;
@@ -1540,12 +1540,12 @@ static int ThreadStart(vout_thread_t *vout, vout_display_state_t *state)
     vout->p->displayed.current       = NULL;
     vout->p->displayed.next          = NULL;
     vout->p->displayed.decoded       = NULL;
-    vout->p->displayed.date          = VLC_TS_INVALID;
-    vout->p->displayed.timestamp     = VLC_TS_INVALID;
+    vout->p->displayed.date          = VLC_TICK_INVALID;
+    vout->p->displayed.timestamp     = VLC_TICK_INVALID;
     vout->p->displayed.is_interlaced = false;
 
-    vout->p->step.last               = VLC_TS_INVALID;
-    vout->p->step.timestamp          = VLC_TS_INVALID;
+    vout->p->step.last               = VLC_TICK_INVALID;
+    vout->p->step.timestamp          = VLC_TICK_INVALID;
 
     vout->p->spu_blend_chroma        = 0;
     vout->p->spu_blend               = NULL;
@@ -1597,7 +1597,7 @@ static void ThreadInit(vout_thread_t *vout)
     vout->p->dead            = false;
     vout->p->is_late_dropped = var_InheritBool(vout, "drop-late-frames");
     vout->p->pause.is_on     = false;
-    vout->p->pause.date      = VLC_TS_INVALID;
+    vout->p->pause.date      = VLC_TICK_INVALID;
 
     vout_chrono_Init(&vout->p->render, 5, 10000); /* Arbitrary initial time */
 }
@@ -1615,7 +1615,7 @@ static int ThreadReinit(vout_thread_t *vout,
     video_format_t original;
 
     vout->p->pause.is_on = false;
-    vout->p->pause.date  = VLC_TS_INVALID;
+    vout->p->pause.date  = VLC_TICK_INVALID;
 
     if (VoutValidateFormat(&original, cfg->fmt)) {
         ThreadStop(vout, NULL);
@@ -1791,7 +1791,7 @@ static void *Thread(void *object)
     vout_thread_t *vout = object;
     vout_thread_sys_t *sys = vout->p;
 
-    vlc_tick_t deadline = VLC_TS_INVALID;
+    vlc_tick_t deadline = VLC_TICK_INVALID;
     bool wait = false;
     for (;;) {
         vout_control_cmd_t cmd;
@@ -1799,15 +1799,15 @@ static void *Thread(void *object)
         if (wait)
         {
             const vlc_tick_t max_deadline = mdate() + 100000;
-            deadline = deadline <= VLC_TS_INVALID ? max_deadline : __MIN(deadline, max_deadline);
+            deadline = deadline <= VLC_TICK_INVALID ? max_deadline : __MIN(deadline, max_deadline);
         } else {
-            deadline = VLC_TS_INVALID;
+            deadline = VLC_TICK_INVALID;
         }
         while (!vout_control_Pop(&sys->control, &cmd, deadline))
             if (ThreadControl(vout, cmd))
                 return NULL;
 
-        deadline = VLC_TS_INVALID;
+        deadline = VLC_TICK_INVALID;
         wait = ThreadDisplayPicture(vout, &deadline) != VLC_SUCCESS;
 
         const bool picture_interlaced = sys->displayed.is_interlaced;
-- 
GitLab