[bTSstream-devel] fix PTS signaling in PES

Christophe Massiot git at videolan.org
Tue Dec 9 23:41:57 CET 2014


bitstream | branch: master | Christophe Massiot <cmassiot at openheadend.tv> | Tue Dec  9 23:40:18 2014 +0100| [124257e351856d009d416537f7cfb8fcb9645190] | committer: Christophe Massiot

fix PTS signaling in PES

> http://git.videolan.org/gitweb.cgi/bitstream.git/?a=commit;h=124257e351856d009d416537f7cfb8fcb9645190
---

 mpeg/pes.h |   27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/mpeg/pes.h b/mpeg/pes.h
index 26cac26..0095c6d 100644
--- a/mpeg/pes.h
+++ b/mpeg/pes.h
@@ -118,24 +118,29 @@ static inline bool pes_get_dataalignment(const uint8_t *p_pes)
     return !!(p_pes[6] & 0x4);
 }
 
+static inline bool pes_has_pts(const uint8_t *p_pes)
+{
+    return !!(p_pes[7] & 0x80);
+}
+
+static inline bool pes_has_dts(const uint8_t *p_pes)
+{
+    return (p_pes[7] & 0xc0) == 0xc0;
+}
+
 static inline void pes_set_pts(uint8_t *p_pes, uint64_t i_pts)
 {
     p_pes[7] |= 0x80;
     if (p_pes[8] < 5)
         p_pes[8] = 5;
-    p_pes[9] &= 0x10;
-    p_pes[9] |= 0x21 | ((i_pts >> 29) & 0xe);
+    uint8_t marker = pes_has_dts(p_pes) ? 0x30 : 0x20;
+    p_pes[9] = marker | 0x1 | ((i_pts >> 29) & 0xe);
     p_pes[10] = (i_pts >> 22) & 0xff;
     p_pes[11] = 0x1 | ((i_pts >> 14) & 0xfe);
     p_pes[12] = (i_pts >> 7) & 0xff;
     p_pes[13] = 0x1 | ((i_pts << 1) & 0xfe);
 }
 
-static inline bool pes_has_pts(const uint8_t *p_pes)
-{
-    return !!(p_pes[7] & 0x80);
-}
-
 static inline bool pes_validate_pts(const uint8_t *p_pes)
 {
     return ((p_pes[9] & 0xe1) == 0x21)
@@ -154,7 +159,8 @@ static inline void pes_set_dts(uint8_t *p_pes, uint64_t i_dts)
     p_pes[7] |= 0x40;
     if (p_pes[8] < 10)
         p_pes[8] = 10;
-    p_pes[9] |= 0x10;
+    p_pes[9] &= 0x0f;
+    p_pes[9] |= 0x30;
     p_pes[14] = 0x11 | ((i_dts >> 29) & 0xe);
     p_pes[15] = (i_dts >> 22) & 0xff;
     p_pes[16] = 0x1 | ((i_dts >> 14) & 0xfe);
@@ -162,11 +168,6 @@ static inline void pes_set_dts(uint8_t *p_pes, uint64_t i_dts)
     p_pes[18] = 0x1 | ((i_dts << 1) & 0xfe);
 }
 
-static inline bool pes_has_dts(const uint8_t *p_pes)
-{
-    return (p_pes[7] & 0xc0) == 0xc0;
-}
-
 static inline bool pes_validate_dts(const uint8_t *p_pes)
 {
     return (p_pes[9] & 0x10) && ((p_pes[14] & 0xf1) == 0x11)



More information about the biTStream-devel mailing list