[0001] The present application claims priority to Chinese Patent Application No.
200810084420.7, entitled "METHOD AND DEVICE FOR CLOCK RECOVERY" and filed with the Chinese Patent
Office on March 21, 2008, which is hereby incorporated by reference in its entirety.
Field of the Invention
[0002] The present invention relates to digital technologies, and in particular, to a method
and device for clock recovery.
Background
[0003] Clock recovery is one of key techniques for digital media play control. Its purpose
is to control the play speed of local bit stream and the bit stream transmission speed
of the source end by means of synchronizing clocks of the bit stream transmitting
end and local end so that the play speed of local bit stream is permanently consistent
with the bit stream transmission speed of the source end, thus preventing the overflow
or underflow of the local player.
[0004] In the prior arts in connection with the present invention, the general solution
is to recover the media stream clock through a hardware phase-locked loop. The Program
Clock Reference (PCR) extracted from a Transport Stream (TS) is compared with the
local System Time Clock (STC) to obtain a difference e and the difference e is input
to a low-pass filter to get a value f after filtering. The value f is generally a
signal that controls the working frequency of a Voltage-Controlled Oscillator (VCO).
The adjusted clock output by the VCO is input to an STC generator to generate recovered
local clock. The Presentation Time Stamp (PTS) of video and that of audio are respectively
compared with the STC, then synchronization process is performed to ensure "lip sync"(abbreviation
of "lip synchronization", means that video and audio is synchronized). The 27 MHz
clock generated by the VCO may be used as a clock source of the video outputting module.
Because the STC is a clock that has been continuously compared and adjusted by the
phase-locked loop and PCR, only a phase difference caused by network delay exists
between the STC and the clock of the source end, but the frequency of the STC is consistent
with the clock of the source end. Thus, consistency is assured between the play speed
and transmission speed of the source end bit stream and therefore overflow will not
happen to the local buffer.
[0005] During the implementation of the present invention, the inventor finds that the prior
art has the following defects:
[0006] A phase-locked loop circuit and external VCO support are necessary so that the cost
is high.
[0007] In the case of an Internet Protocol (IP) network with large jitters, because the
arrival time of the PRC is not accurate, the recovery effect of the VCO is unsatisfactory.
Summary
[0008] The present invention provides a method and device to enable effective clock recovery
in the case of long network delay without a Digital Controlled Oscillator (SCO) or
Voltage Controlled Oscillator (VCO).
[0009] According to a first aspect of the present invention a method for clock recovery
includes:
obtaining a first Program Clock Reference (PCR) signal of a Transport Stream (TS)
and comparing the first PCR signal with a local System Time Clock (STC) signal to
get a first comparison signal;
filtering the first comparison signal to get a second comparison signal and obtaining
an updated second PCR signal according to the second comparison signal and a history
value of a second PCR signal; and
obtaining a recovered first PCR signal according to the updated second PCR signal,
recording time of the second PCR signal recorded by a fixed system clock source and
a current time of the fixed system clock source.
[0010] According to a second aspect of the present invention a device for clock recovery
includes a comparing module, a filtering module and a recovering module.
[0011] The comparing module is configured to: obtain a first PCR signal of a TS and compare
the first PCR signal with a local STC to get a first comparison signal and send the
first comparison signal to the filtering module.
[0012] The filtering module is configured to: filter the first comparison signal to get
a second comparison signal and obtain an updated second PCR signal according to the
second comparison signal and a history value of the second PCR signal, and send the
updated PCR signal to the recovering module.
[0013] The recovering module is configured to: obtain a recovered first PCR according to
the updated second PCR signal and a recording time of the second PCR recorded by a
fixed system clock source and a current time of the fixed system clock source.
[0014] Compared with the prior art, the technical solution of the present invention provides
the following benefits:
[0015] The technical solution of the present invention adopts software filtering and tracks
the first PCR signal to realize cyclic monitoring and recover the first PCR signal
without a DCO/VCO so that clock recovery is more adaptive to network conditions.
Brief Description of the Drawings
[0016]
FIG. 1 shows a procedure of a method for clock recovery in a first embodiment of the
present invention;
FIG. 2 is a schematic drawing of a method for clock recovery in a second embodiment
of the present invention;
FIG. 3 shows a structure of a device for clock recovery in the first embodiment of
the present invention; and
FIG. 4 shows a structure of a device for clock recovery in the second embodiment of
the present invention.
Detailed Description of Embodiments
[0017] The embodiments of the present invention provide a method and device for clock recovery.
[0018] The following describes the present invention in detail with drawings and embodiments.
[0019] The first embodiment of the present invention provides a method for clock recovery,
as shown in FIG. 1. The method includes the following blocks:
[0020] Block S1: Obtain a first Program Clock Reference (PCR) signal of a Transport Stream
(TS) and compare the first PCR signal with a local System Time Clock (STC) signal
to get a first comparison signal.
[0021] Before the block S1, it is necessary to set filtering parameters and the times of
filtering according to the bearer network condition and user requirement and introduce
a fixed system clock source to activate the local system clock module.
[0022] Block S2: Filter the first comparison signal to get a second comparison signal and
obtain an updated second PCR signal according to the second comparison signal and
a history value of a second PCR signal. The filtering algorithm used to filter the
first comparison signal includes the Exponentially Weighted Moving Average (EWMA)
filtering algorithm and the filtering algorithm is substitutable and configurable.
[0023] The first comparison signal is filtered to remove delay and jitter and obtain the
updated second PCR signal. In this block, the history value refers to the continuously
updated second PCR signal. The initial value of the history value is the initial value
of the first PCR when the system initializes.
[0024] Block S3: Obtain a recovered first PCR signal according to the updated second PCR
signal and a recording time of the second PCR signal recorded by a fixed system clock
source and a current time of the fixed system clock source.
[0025] The block of obtaining the recovered first PCR signal also includes updating the
local STC to the recovered first PCR signal to track the first PCR signal. Because
the process of obtaining and outputting of the second local STC is not continuous,
the recovered first PCR (updated STC) needs to provide a continuous local STC to the
player, a fixed clock source of the system is introduced during the course of generating
the local STC to record the recording time of the second PCR signal and the current
time of the system.
[0026] In this block, the calculation of the recovered first PCR signal according to the
second PCR signal, the recording time and the current time is: recovered first PCR
signal = second PCR signal + current time - recording time.
Embodiment 2: method for clock recovery
[0027] As shown in FIG. 2, in the embodiment, the first PCR signal is recovered by means
of filtering and the updated local System Time Clock STC_1 (the first PCR signal which
is recovered) is used as the local system clock for video/audio synchronization of
a player; according to the parameters like Presentation Time Stamp (PTS), the play
speed of video/audio stream is controlled to synchronize the play speed of the local
stream with the transmission speed of the source end, and the lip sync is implemented.
The video outputting module of the player may introduce a constant 27 MHz clock source
instead of STC_1.
[0028] The specific procedure for clock recovery is described hereafter. As shown in FIG.
2, a PCR data extracted from a TS (corresponding to the first PCR signal in the first
embodiment) is compared with (or subtracted from) STC_1 (corresponding to the local
STC signal in the first embodiment) to get a comparison signal e. The signal e is
filtered to eliminate error of the PCR caused by delay and jitter. The filtered comparison
signal is added to a history value to get PCR_1 (corresponding to the second PCR signal
in the first embodiment), the history value herein is the value of PCR_1 before being
updated. When the player needs to use the local STC, clock recovery is performed according
to PCR_1 to get STC_1, which is the local system clock after the PCR is recovered.
[0029] The clock recovery according to PCR_1 to get STC_1 includes: recording the time of
PCR
_1 (time0) when PCR_1 is filtered, where the time is based on a fixed time source of
the system. Here, the time corresponds to the recording time (based on the time of
the fixed system time source) of the second PCR signal in the first embodiment; when
it is needed to generate a local STC (as to perform clock recovery), the current time
(time1) is recorded (based on the time of the fixed system time source); the difference
between time1 and time0 plus the last updated PCR_1 is the STC_1, this means: STC_1
= PCR_1 + time1 - time0. STC_1 corresponds to the recovered first PCR in the first
embodiment and is also used as a new local STC.
[0030] During the play of the TS, the STC_1 may be used as a local clock source for video/audio
synchronization of the player. The advantage is: even in the case of large jitter,
because PCR_1 is obtained by filtering the PCR and the calculating of time difference
during the course of generating the local STC is based on a fixed clock source, if
the play of the video/audio is based on the STC_1 calculated according to the PCR_1
and the time difference, the play speed will be synchronized with the stream transmission
speed so as to guarantee that the buffer of the player will not overflow or underflow;
because the PTS of the audio and the PTS of video are respectively compared with STC_1
when the audio and the video are played, the play time of the audio is close to that
of the video, and thus the lip sync is implemented automatically.
[0031] In the embodiment, the filtering algorithm used for software filtering is substitutable
and configurable. There are many optional filtering algorithms, such as EWMA.
[0032] To facilitate calculation, the filtering parameter is usually 0.5, which facilitates
the shift operation.
[0033] The calculation times of EWMA may be adjusted as required. If the bit stream speed
of the source end is even, the filtering can be done even by only one EWMA operation.
The process of filtering is a process of removing jitter. In the case of an IP network
stream, triple EWMA operation may be used.
[0034] An embodiment of the present invention provides a device for clock recovery. As shown
in FIG. 3, the device includes a comparing module 100, a filtering module 200, and
a recovering module 300.
[0035] The comparing module 100 is configured to: obtain the first PCR signal of a TS and
compare the first PCR signal with the local STC signal to get a first comparison signal
and send the first comparison signal to the filtering module 200.
[0036] The filtering module 200 is configured to: filter the first comparison signal to
get a second comparison signal and obtain an updated second PCR signal according to
the second comparison signal and a history value of a second PCR signal, and send
the updated second PCR signal to the recovering module 300.
[0037] The recovering module 300 is configured to obtain a recovered first PCR signal according
to the updated second PCR signal and a recording time of the second PCR signal recorded
by a fixed system clock source and a current time of the fixed system clock source.
[0038] FIG. 4 shows the structure of a device for clock recovery in the second embodiment
of the present invention. The modules are further divided on the basis of the first
embodiment. The recovering module 300 includes: a receiving unit 310, a recording
unit 320, a calculating unit 330, a clock updating unit 340, and a sending unit 350.
[0039] The receiving unit 310 is configured to receive the updated second PCR signal and
connect the fixed system clock source.
[0040] The recording unit 320 is configured to record the updated second PCR signal received
by the receiving unit 310, the recording time of the second PCR signal recorded by
the fixed system clock source, and the current time of the fixed system clock source.
[0041] The calculating unit 330 is configured to obtain the recovered first PCR signal according
to the updated second PCR signal of the recording unit 320, the recording time and
the current time of the recording unit 320.
[0042] The clock updating unit 340 is configured to update the local STC to the recovered
first PCR signal according to the recovered first PCR signal obtained by the calculating
unit 330.
[0043] The sending unit 350 is configured to send the recovered first PCR obtained by the
calculating unit 330 and the local STC updated by the clock updating unit 340 to the
comparing module to track the source end bit stream play speed of the first PCR signal.
[0044] The filtering module 200 includes a receiving unit 210, a setting unit 220, a filtering
unit 230, a history value updating unit 240 and a sending unit 250.
[0045] The receiving unit 210 is configured to receive the first comparison signal.
[0046] The setting unit 220 is configured to set the filtering parameter and the times of
filtering according to the bearer network condition and user requirement.
[0047] The filtering unit 230 is configured to run the filtering software according to the
filtering parameter and the times of filtering set by the setting unit 220 to filter
the first comparison signal received by the receiving unit 210 to remove delay and
jitter and obtain the second comparison signal.
[0048] The history value updating unit 240 is configured to obtain an updated history value
according to the second comparison signal and the history value of the second PCR
signal and the updated history value is the updated second PCR signal. Because STC_1
has only the fixed system clock source during initialization, and the fixed system
clock source is normally several megahertz that can be ignored compared with the PCR,
the initial history value is the initial value of the first PCR signal through the
comparing module 100.
[0049] The sending unit 250 is configured to send the updated second PCR signal obtained
by the history value updating unit 240 to the recovering module 300.
[0050] In the filtering module 200, the filtering algorithm in the filtering unit 230 is
substitutable and configurable and the filtering algorithm includes the EWMA algorithm.
[0051] An application example of the clock recovery device provided by the embodiment of
the present invention will be described. In the embodiment, unlike the clock recovery
implemented via a phase-locked loop circuit, a constant 27 MHz clock which has no
relationship with the clock recovery device can be introduced in the video outputting
module of the player and the clock will not be impacted by PCR jitters so as to avoid
the transmission jitter and delay of the clock signal in an IP network; moreover,
in the embodiment of the present invention, the support of devices like a VCO is not
needed so that the design and manufacture cost is lower. In addition, the first PCR
is recovered through filtering and the local STC is updated to the recovered first
PCR signal to track the first PCR signal; the updated STC_1 is used as the local system
clock for audio/video synchronization of the player and the play speed of an audio/video
is controlled through parameters (e.g. PTS) to synchronize the play speed of local
bit stream with the transmission speed of the source and the process of lip sync is
performed.
[0052] As shown in FIG. 4, before a player system runs, the clock recovery device is initialized
to obtain the history value of the filtering module 200; the filtering parameter and
the times of filtering are set according to the bearer network condition and user
requirement; and a fixed system clock source is introduced to activate the recovering
module 300. During the play of a bit stream, the PCR data extracted from the TS (corresponding
to the first PCR signal in the first embodiment) is sent to the comparing module 100;
the comparing module compares the PCR with the STC_1 extracted from the recovery device
(corresponding to the local STC signal in the first embodiment) to get e; then e is
filtered by the filtering module 200 to eliminate error of the PCR caused by delay
and jitter; the filtered comparison signal is added to the history value to get PCR_1
(corresponding to the second PCR signal in the first embodiment); the PCR_1 is input
to the recovering module 300; the recovering module 300 updates the PCR_1 recorded
in the recording unit 320 to the latest value and records the time0 of the latest
PCR_1 obtained by the recording unit 320.
[0053] When it is required to obtain STC_1 from the recovering module, the calculating unit
330 first obtains the current time (time1) of the recovering module 300 and the time0
of the recording unit 320; the difference between time1 and time0 is added to the
latest PCR_1 recorded by the recovering module 300 to get STC_1 (corresponding to
the recovered first PCR signal in the first embodiment and used as the new local STC).
This means STC_1 = PCR_1 + time1 - time0, where time1 and time0 are both measured
according to the fixed system clock source.
[0054] In the embodiment, the filtering algorithm used by the filtering module is substitutable
and configurable. There are many optional filtering algorithms, such as EWMA.
[0055] To facilitate calculation, the filtering parameter is usually 0.5, which facilitates
the shift operation.
[0056] The calculation times of EWMA may be adjusted as required. If the bit stream speed
of the source end is even, the filtering can be done even by only one EWMA operation.
The process of filtering is a process of removing jitter. In the case of an IP network
stream, triple EWMA operation may be used.
[0057] During the synchronized playing of the video and the audio, the error between PTS
and STC_1 may be only a few milliseconds and the STC_1 generated by the filtering
module well satisfies the requirement.
[0058] In the embodiment, the filtering module filters the signal e obtained by comparing
PCR and STC_1 to eliminate error of the PCR caused by delay and jitter. The filtered
comparison signal is added to the history value of PCR_1 to get a new PCR_1 and the
history value of the PCR_1 is updated to the new PCR_1. The new PCR_1 is input to
the recovering module 300.
[0059] The video outputting module in the player uses the fixed clock source independent
of the clock recovery device and the constant 27 MHz clock is introduced as the clock
input of the video outputting module. The clock for video/audio synchronization of
the TS player is the local STC which is continuously updated by tracking the PCR of
the TS. Even if inconsistency happens between the play speed and transmission speed
of the source end stream for certain reasons, the player can make analysis and processing
according to the video/audio synchronization clock and the clock of the video outputting
module, for example, through frame skipping, so that the TS player is more adaptive
to the network environment.
[0060] The technical solution provided by the embodiments of the present invention provides
the following benefits: in the prior art, the PCR is used as the local clock source
for synchronization of the video outputting module of the player and the audio/video
synchronization of the player and therefore jitter is inevitable; in the embodiments
of the present invention, a fixed system clock source is introduced independently
of the Digital-Controlled Oscillator (DCO) or VCO and an unadjusted fixed clock source
is used to drive the video outputting module; the video/audio synchronization of the
player is independent of the clock of the video outputting module; the recovered STC_1
is compared with the PCR to track the changes of the PCR and implement clock recovery
through filtering. The process is cyclic so that the STC required by video/audio synchronization
of the local player is generated. This means, in the embodiments of the present invention,
the first PCR signal is tracked to implement cyclic monitoring. The first PCR signal
is thus recovered and the clock recovery is more adaptive to the network condition.
The clock recovering module is implemented by software without the VCO/TCO in the
prior art, and jitter is eliminated through filtering, the local STC is updated, the
changing first PCR signal is tracked to satisfy the requirement of the video/audio
synchronization, and the buffer of the player will not overflow and the cost is saved.
Even in the case of large network delay, the normal work of the video outputting module
will not be impacted. In the video/audio synchronization of the player, the clock
recovery device analyzes the PCR and tracks the clock change of the play speed of
the source end stream and carries out appropriate processing. Thus, the clock recovery
solution is more adaptive to network jitter.
[0061] Based on the descriptions of the preceding embodiments, those skilled in the art
may understand that the present invention may be implemented by only hardware or by
software and a necessary universal hardware platform. The technical solution of the
present invention may be embodied by a software product which may be stored in a nonvolatile
storage medium. The storage medium can be a Compact Disk Read-Only Memory (CD-ROM),
a USB disk, or a mobile hard disk. The software product includes a number of instructions
that enable a computer device (personal computer, server, or network device), to execute
the methods provided in the embodiments of the present invention.
[0062] Although the present invention has been described through several exemplary embodiments,
the invention is not limited to such embodiments. It is apparent that those skilled
in the art can make various modifications and variations to the invention without
departing from the spirit and scope of the present invention. The invention is intended
to cover the modifications and variations provided that they fall in the scope of
protection defined by the following claims or their equivalents.
1. A method for clock recovery, comprising:
obtaining a first Program Clock Reference, PCR, signal of a Transport Stream, TS,
and comparing the first PCR signal with a local System Time Clock, STC, signal to
get a first comparison signal;
filtering the first comparison signal to get a second comparison signal and obtaining
an updated second PCR signal according to the second comparison signal and a history
value of the a PCR signal; and
obtaining a recovered first PCR signal according to the updated second PCR signal
and a recording time of the second PCR signal recorded by a fixed system clock source
and a current time of the fixed system clock source.
2. The method of claim 1, further comprising:
updating the local STC to the recovered first PCR signal to track the first PCR signal.
3. The method of claim 1, before receiving the first PCR of the TS, further comprising:
setting filtering parameters and the times of filtering according to the bearer network
conditions and the user requirement and introducing the fixed system clock source
to record the recording time and the current time.
4. The method of claim 1,
characterized in that the block of obtaining the updated second PCR signal according to the second comparison
signal and a history value of the second PCR signal comprises:
updating the history value to the updated second PCR signal, characterized in that the initial history value is the initial value of the first PCR signal.
5. The method of claim 1,
characterized in that the block of obtaining a recovered first PCR signal according to the updated second
PCR signal and a recording time of the second PCR signal recorded by a fixed system
clock source and a current time of the fixed system clock source comprises:
the recovered first PCR signal = the second PCR signal + the current time - the recording
time.
6. The method of claim 1, characterized in that filtering algorithms adopted to filter the first comparison signal comprise an Exponentially
Weighted Moving Average EWMA filtering algorithm.
7. A device for clock recovery, comprising a comparing module, a filtering module and
a recovering module,
characterized in that:
the comparing module is configured to: obtain a first Program Clock Reference, PCR,
signal of a Transport Stream, TS, and compare the first PCR signal with a local System
Time Clock, STC, Signal to get a first comparison signal and send the first comparison
signal to the filtering module;
the filtering module is configured to: filter the first comparison signal to get a
second comparison signal and obtain an updated second PCR signal according to the
second comparison signal and a history value of a second PCR, and send the updated
second PCR signal to the recovering module; and
the recovering module is configured to: obtain a recovered first PCR signal according
to the updated second PCR signal and a recording time of the second PCR signal recorded
by a fixed system clock source and a current time of the fixed system clock source.
8. The device of claim 7,
characterized in that the recovery module comprises: a receiving unit, a recording unit, a calculating
unit, a clock updating unit and a sending unit, wherein:
the receiving unit is configured to receive the updated second PCR signal and connect
the fixed system clock source;
the recording unit is configured to record the updated second PCR signal received
by the receiving unit, the recording time of the second PCR signal recorded by the
fixed system clock source, and the current time of the fixed system clock source;
the calculating unit is configured to obtain the recovered first PCR signal according
to the updated second PCR signal of the recording unit, the recording time and the
current time of the recording unit;
the clock updating unit is configured to update the local STC to the recovered first
PCR signal according to the recovered first PCR signal obtained by the calculating
unit; and
the sending unit is configured to send the recovered first PCR obtained by the calculating
unit and the local STC updated by the clock updating unit to the comparing module
to track the source end bit stream play speed of the first PCR signal.
9. The device of claim 7,
characterized in that the filtering module comprises: a receiving unit, a setting unit, a filtering unit,
a history value updating unit and a sending unit, wherein:
the receiving unit is configured to receive the first comparison signal;
the setting unit is configured to set a filtering parameter and the times of filtering
according to bearer network conditions and user requirement;
the filtering unit is configured to run filtering software according to the filtering
parameter and the times of filtering set by the setting unit to filter the first comparison
signal received by the receiving unit to remove delay and jitter and obtain the second
comparison signal;
the history value updating unit is configured to obtain the updated history value
according to the second comparison signal obtained by the filtering unit and the history
value of the second PCR signal, characterized in that the updated history value is the updated second PCR signal; and
the sending unit is configured to send the updated second PCR obtained by the history
value updating unit to the recovering module.
10. The device of claim 9, characterized in that filtering algorithms of the filtering unit comprise an Exponentially Weighted Moving
Average, EWMA, filtering algorithm.