[vlc-commits] mux:pes: use MPEG timestamp macros

Steve Lhomme git at videolan.org
Tue Sep 18 14:30:33 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jun 12 14:41:05 2018 +0200| [91db95507ca2a5ec62a307ed077c45c152c6c62a] | committer: Steve Lhomme

mux:pes: use MPEG timestamp macros

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

 modules/mux/Makefile.am |  3 ++-
 modules/mux/mpeg/pes.c  | 18 ++++++++++--------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/modules/mux/Makefile.am b/modules/mux/Makefile.am
index 910b72f19b..e805b36bb8 100644
--- a/modules/mux/Makefile.am
+++ b/modules/mux/Makefile.am
@@ -13,7 +13,8 @@ libmux_mp4_plugin_la_SOURCES = mux/mp4/mp4.c \
 libmux_mpjpeg_plugin_la_SOURCES = mux/mpjpeg.c
 libmux_ps_plugin_la_SOURCES = \
 	mux/mpeg/pes.c mux/mpeg/pes.h \
-	mux/mpeg/ps.c mux/mpeg/bits.h
+	mux/mpeg/ps.c mux/mpeg/bits.h \
+	demux/mpeg/timestamps.h
 libmux_wav_plugin_la_SOURCES = mux/wav.c
 
 mux_LTLIBRARIES = \
diff --git a/modules/mux/mpeg/pes.c b/modules/mux/mpeg/pes.c
index d392b8065a..7855b70319 100644
--- a/modules/mux/mpeg/pes.c
+++ b/modules/mux/mpeg/pes.c
@@ -38,6 +38,8 @@
 #include "pes.h"
 #include "bits.h"
 
+#include "../../demux/mpeg/timestamps.h"
+
 /** PESHeader, write a pes header
  * \param i_es_size length of payload data. (Must be < PES_PAYLOAD_SIZE_MAX
  *                  unless the conditions for unbounded PES packets are met)
@@ -50,7 +52,7 @@
  * \param i_header_size length of padding data to insert into PES packet
  *                      header in bytes.
  */
-static inline int PESHeader( uint8_t *p_hdr, vlc_tick_t i_pts, vlc_tick_t i_dts,
+static inline int PESHeader( uint8_t *p_hdr, int64_t i_pts, int64_t i_dts,
                              int i_es_size, const es_format_t *p_fmt,
                              int i_stream_id, bool b_mpeg2,
                              bool b_data_alignment, int i_header_size )
@@ -382,12 +384,12 @@ void EStoPES ( block_t **pp_pes,
 
     }
 
-    vlc_tick_t i_dts = 0;
-    vlc_tick_t i_pts = 0;
+    int64_t i_dts = 0;
+    int64_t i_pts = 0;
     if (p_es->i_pts != VLC_TICK_INVALID)
-        i_pts = (p_es->i_pts - ts_offset) * 9 / 100;
+        i_pts = TO_SCALE_NZ(p_es->i_pts - ts_offset);
     if (p_es->i_dts != VLC_TICK_INVALID)
-        i_dts = (p_es->i_dts - ts_offset) * 9 / 100;
+        i_dts = TO_SCALE_NZ(p_es->i_dts - ts_offset);
 
     i_size = p_es->i_buffer;
     p_data = p_es->p_buffer;
@@ -437,14 +439,14 @@ void EStoPES ( block_t **pp_pes,
 
     /* Now redate all pes */
     p_pes = *pp_pes;
-    i_dts    = p_pes->i_dts;
+    vlc_tick_t i_block_dts = p_pes->i_dts;
     vlc_tick_t i_length = p_pes->i_length / i_pes_count;
     while( p_pes )
     {
-        p_pes->i_dts = i_dts;
+        p_pes->i_dts = i_block_dts;
         p_pes->i_length = i_length;
 
-        i_dts += i_length;
+        i_block_dts += i_length;
         p_pes = p_pes->p_next;
     }
 }



More information about the vlc-commits mailing list