The MPEG2 transport stream clock (PCR, PTS, DTS) has units of 1/90000 of a second. PTS and DTS have three marker bits that you need to skip. A pattern is always (from most to least significant) 3 bits, marker, 15 bits, marker, 15 bits, marker. Markers must be equal to 1. In C, removing markers will work as follows:
uint64_t v; // this is a 64bit integer, lowest 36 bits contain a timestamp with markers uint64_t pts = 0; pts |= (v >> 3) & (0x0007 << 30); // top 3 bits, shifted left by 3, other bits zeroed out pts |= (v >> 2) & (0x7fff << 15); // middle 15 bits pts |= (v >> 1) & (0x7fff << 0); // bottom 15 bits // pts now has correct timestamp without markers in lowest 33 bits
They also have a 9-bit extension field, forming a 42-bit integer in which the extension is the least significant bits. Units for expanding the base + 1/27000000 seconds. Many implementations leave the extension as all zeros.
source share