A New Method For Calculating PCR
A New Method For Calculating PCR
1
Dept. of Electronics and Computers, Transilvania University of Braov.
2
Elettronika Research S.R.L. Braov, Romania.
3
Dept. Research & Development, Elettronika Italy.
238 Bulletin of the Transilvania University of Braov Vol. 2 (51) - 2009 Series I
presentation in order to preserve the of delay for video packets arriving at the
illusion of motion. However, delays decoder. This delay wrecks havoc in the
introduced by coding, multiplexing and decoder process mandating buffers in the
transmission can cause a variable amount decoder [2].
these entire packaged elementary stream Program Clock Reference (PCR), which is
packets are further multiplexed together, given by periodically sampling the sender
the final stream is time-stamped with clock.
This resulted transport layer stream is (video, audio, data and timestamps) are
then sent over the network to the receiver, segmented into small packets of constant
or stored in storage devices for the decoder size (188 bytes), and the Packet ID (PID)
to read in the future. As long as the delay field in the 4-byte header of a packet tells
of the whole stream experiences remains which sub stream that packet belongs to.
constant from the receivers point of view, The PCR packets occur at constant
the receiver should be able to reconstruct intervals, and they form a running timeline
the senders clock that has been used when along which all other packets are
the stream was encoded. The accuracy and positioned at the right time point. Data
stability of this recovered clock is very packets arrive and they are read into the
important, since the decoder will try to decoder buffer at constant rate; this rate
match the PTS and DTS against this clock can be calculated by dividing the number
to guide its decoding and displaying activities. of bits between any 2 consecutive PCR
packets by the time difference between
their time stamps. In other words, if the
number of packets between any 2 PCR
packets remains constant, then the dif-
ference between their time stamps should
also be constant. Considering an ideal
state, packets are read into the decoder at
Fig. 3. Generic coding of moving pictures the constant bit rate, and whenever a new
and associated audio systems PCR packet arrives, its time stamp should
match exactly with the receiver clock,
Knowing the general idea in timing, we which confirms the decoder that so far it
introduce now an explanation about how has successfully re-constructed the same
the Transport Layer syntax works, as clock as the encoder. However, since PCR
shown in the Figure 3. All sub streams packets may have experienced jitter in
240 Bulletin of the Transilvania University of Braov Vol. 2 (51) - 2009 Series I
network transmission or storage device carry, and so its following frames are
accessing before they arrive at the receiver, dragged earlier or pushed later along the
we cannot simply set the receivers local timeline. In such circumstances, if we keep
clock to be the same as the time stamp both the time stamp and the spacing of the
carried by the next incoming PCR no PCR packets unchanged, then the
matter when it comes. To smooth out the receivers clock can still be correctly
jitter and maintain a stable clock with a reconstructed, but the arriving time of each
limited buffer size at the receiver, frame will be skewed along the timeline.
generally the receiver will resort to some For example, if the stream is low pass
smoothing technique like the Phase- filtered, and then every frame becomes
Locked-Loop (PLL) to generate a stable shorter, the following frames are dragged
clock from the jittered PCR packets. PLL forward to pack up the vacancy spared out.
is a feedback loop that uses an external From the decoders point of view, more
signal (the incoming PCR packets in our and more future frames begin to come
case) to tune a local signal source earlier and earlier, and to buffer them until
(generated by a local oscillator) to generate their stamped time for decoding, the buffer
a relatively more stable result signal (the will be overflowed in the long run no
receivers reconstructed local clock). As matter how large it is. The fundamental
long as the timing relation between PCR problem is that after the filtering, the actual
packets is correct, the jitter can be bit rate becomes lower or higher, but the
smoothed out with PLL [5]. data is still read in by the decoder at the
After the brief introduction on the usage original rate. So if the new rate is lower,
and importance of the PCR packets, now more and more future data is read in by the
we are ready to discuss how the filtering decoder, causing the decoder buffer to
operation may affect their validity and overflow eventually; on the other hand, if
accuracy. First, even for the same type of the new rate is higher, then at some point
filtering operation, e.g., low pass filtering, in the future, the data will be read in after
for different frames, the time required to its decoding time has already passed.
do the calculation and processing can be
quite different. Since the filtering is 3. Our Solution
transparent to the decoder, it seems to the
decoder that the jitter the stream has Because the length of the packets can be
experienced is larger. This is not a big 188/204Bytes, our solution is designed to
problem, since through longer buffering at work with both types of packets.
the filter and the receiver and the use of The first step was to set-up a real-time
jitter smoothing mechanisms, this stronger packet length monitoring and to verify the
jitter will not greatly affect the decoding nature of the packets, in order to set the
process. The second problem, however, is system to work on 188/204Bytes.
more intractable. As its mentioned above, Then, based on the PID of the packet, we
the packets for any access unit should be checked if the header of the packet
positioned within the stream and so arrive contains PCR values; if so, then those
at the receiver at its supposed time point values have been removed from the packet.
for the decoder to schedule where and how For testing we used an external source
long to buffer it before decoding it. for the PID, consisting of 3 jumpers. We
However, after the filter operations also tested a software approach. In the final
normally, a video frame becomes smaller project we used a block that will calculate
or larger. It takes less or more packets to the PID.
Alexandru, M., et al.: A New Method for Recalculating the Program Clock Reference 241
Fig. 4. Altera Cyclone III + Bitec HSMC BVDC & DekTec USB-2 ASI/SDI
Fig. 6. TSViewer
242 Bulletin of the Transilvania University of Braov Vol. 2 (51) - 2009 Series I