Philippe Gaultier wrote:
Program Clock Reference. It's the clock value of the transmitting playout center and can/should be used to adjust the local clocks in small steps (or a hard step at initialisation time) and avoid that the local decoder clock drifts away.Hi, Thnak you all for your answers. If understand everything : 1) my SCR isn't correctly set 2) When viewing live TV, I have to get the correct value to set the SCR So : There are 4 different Timestamps : PCR, SCR, PTS, DTS PCR is the program stream clock
More generally you can call the MPEG system clock STC. SCR clock reference in MPEG1 system streams and MPEG2 program streams (DVDs and so on).SCR is the decoder clock
PTS is the presentation time stamp (the time when the data should get exposed, "presented" to the user). DTS is the Decoding time stamp that can be used to minimize buffer usage by optimally scheduling the data to decode. Hardware MPEG decoders have only pretty limited buffer sizes.PTS / DTS are timestamps to present frames to the user
If a frame is played when SCR == PTSNo, whenever you receive a PCR you should adjust the STC smoothly in small steps to avoid jumping images and sound. If I remember correctly the MPEG2 spec allows corrections at a change rate of up to 0.075Hz/second.
If SCR > PTS
{
The decoder skips frames until PTS == SCR In this case, my decoder seems to discard everything except IFRAMEs. }
Else if SCR < PTS
{
The decoder should wait until SCR == PTS In this case it plays the frames according to the speed set in the decoder
}
Else if SCR == PTS
{
In this case, the decoder should play every frame
}
If this is right, I have to do : If(isFirstFrame() && (SCR!=PTS)) SCR = PTS;
That's the hard initialisation. I'd rather write: /** * Situation: you received a TS packet either containing a PCR * (PCR_seen is set true) or a PES start (PUSI set) (PTS_seen is * set true). * initialized and received_a_PCR are boolean values initially set * to zero. */ if ((initialized || received_a_PCR) && PCR_seen) { int64_t PCR_error = diff33bit(PCR, STC); adjust_STC_smoothly(PCR_error); } if (!received_a_PCR && PCR_seen) { received_a_PCR = 1; initialized = 1; STC = PCR + buffer_safety_margin; } if (!initialized && PTS_seen) { initialized = 1; STC = PTS + buffer_safety_margin; } diff33bit() is a function that subtracts two 33bit numbers. hope that helps to make things clearer - just ask if I can help further, Holger -- Info: To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe vdr" as subject.