[Live-devel] Time calculation in MPEG2TransportStreamFromESSource

Ross Finlayson finlayson at live555.com
Thu Oct 5 06:23:45 PDT 2006


>in MPEG2TransportStreamFromESSource
>
>00239   if (fInputBufferBytesAvailable == SIMPLE_PES_HEADER_SIZE) {
>00240     // Use this presentationTime for our SCR:
>00241     fSCR.highBit
>00242       = ((presentationTime.tv_sec*45000 +
>(presentationTime.tv_usec*9)/200)&
>00243          0x80000000) != 0;
>00244     fSCR.remainingBits
>00245       = presentationTime.tv_sec*90000 +
>(presentationTime.tv_usec*9)/100;
>00246     fSCR.extension = (presentationTime.tv_usec*9)%100;
>
>>From ISO/IEC 13818-1 2.4.2.2 extension time is the lower 9 bits of a 27Mhz
>clock.

Not quite.  It's actually the portion of a 27 MHz clock that can't be 
represented in the 90 kHz PCR base - i.e., it's the 27 MHz clock 
value modulo 300 (because 27 MHz = 90 kHz * 300).  You're correct 
that this is a 9-bit value (because you need 9 bits to represent the 
values [0,299]; however, it's not "the lower 9 bits of a 27 MHz 
clock".

>Are the calculations on lines 245 and 246 above correct?

I believe so, yes.  (Note that ((x/1000000)*27000000) % 300 == (9*x) % 100)
-- 

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/


More information about the live-devel mailing list