Method and apparatus for bit stream synchronization
TECHNICAL FIELD OF THE INVENTION 
     This invention relates in general to the field of electronic systems and more particularly to a system and method for performing bit stream synchronization. 
     BACKGROUND OF THE INVENTION 
     The Motion Pictures Expert Group (MPEG) has promulgated the MPEG audio and video standards for compression and decompression algorithms to be used in the digital transmission and receipt of audio and video broadcasts in ISO-11172. The MPEG audio standard provides for the efficient compression of data according to an established psychoacoustic model to enable real-time transmission, decompression and broadcast of CD quality sound. The MPEG audio standard provides for three possible modes of data transfer. The first mode is audio and visual data plus information to be used to synchronize the broadcast of the audio and video portions. The second mode of possible data transmission involves audio information and information that can be used to synchronize the audio information with a video system. The third and final mode of possible data transmission comprises only audio data. 
     The first two modes of MPEG data transmission provide information in the bit stream to synchronize the bit stream and specify the rate at which the decoded bit stream is to be presented to the listener. The MPEG standard provides for a variety of bit rates and sampling rates. If the data is decoded and presented at a different rate than the rate at which the data was encoded, either underflow or overflow of the decoded data can result. Either of these conditions can result in errors in the output audio signal. 
     SUMMARY OF THE INVENTION 
     Accordingly, a need has arisen for a system that can recover the appropriate bit rate from an encoded bit stream that does not contain information specifically identifying the exact rate at which the bit stream was encoded. 
     In accordance with the teachings of the present invention, an audio decoding system is provided which substantially reduces or eliminates disadvantages associated with prior systems and methods of decoding encoded bit streams. 
     According to one embodiment of the present invention, a data processing system is provided that comprises a bit stream decoder circuit operable to receive an encoded bit stream, decode the bit stream and output pulse code modulated data to a digital-to-analog converter. The bit stream decoder circuit comprises circuitry for determining the average bit rate of information received in the encoded bit stream. The bit stream decoder circuit also comprises circuitry for providing a pulse width modulated error signal indicative of the determined average. The system also comprises circuitry for converting the pulse width modulated error signal for clocking into a clock signal output to the digital-to-analog converter circuit. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     A more complete understanding of the technical advantages of the present invention may be acquired by referring to the attached FIGS. wherein like reference numbers indicate like features and wherein: 
     FIG. 1 is a schematic block diagram of the data processing system of the present invention; and 
     FIG. 2 is a schematic illustration of one embodiment of an error signal generation circuit constructed according to the teachings of the present invention. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     Referring to FIG. 1, a data processing system 10 is illustrated which comprises a bit stream decoder circuit 12 which receives an encoded bit stream and places it in an input buffer 14. The decoder circuit 12 may comprise an integrated audio decoding system such as is described in U.S. Pat. application Ser. No. 08/021,007, entitled &#34;Integrated Audio Decoder System&#34;, filed Feb. 22, 1993 and assigned to the assignee of the present application, the disclosure of which is hereby incorporated by reference. The encoded bit stream received by decoder system 12 can have a widely varying instantaneous bit rate. As discussed in the previously referenced application, the encoded bit stream can represent audio data that was encoded using a variety of bit rates and sampling rates. Some formats for the bit stream include information directly indicating the exact rate of the encoding process. However, it is possible under the MPEG standard to have an encoded bit stream that contains no information directly specifying the exact rate of the bit stream. The system 10 must operate to provide pulse code modulated data to a digital-to-analog converter circuit 16 at the appropriate rate to prevent overflow or underflow of information within the system 10. Either underflow or overflow of information can result in errors in the audio data output by digital-to-analog converter 16. 
     According to the teachings of the present invention, the pulse code modulation (PCM) clock signal provided to control output to the digital analog converter 16 is generated to prevent such underflow or overflow problems by recovering the bit rate from the encoded bit stream itself. This is accomplished by ignoring the instantaneous bit rate and calculating a long-term average bit rate which is indicative of the rate of the encoded bit stream. This long-term average is calculated by an error signal generator circuit 18 associated with decoder system 12. Error signal generator circuit 18 outputs a pulse width modulated error signal to a clock processing circuit 20. The clock processing circuit receives the pulse width modulated error signal and generates a PCM clock signal which is used to control output of decoded PCM data from decoder 12 to digital-to-analog converter 16 through an optional clock divider circuit 22. 
     According to one embodiment of the present invention clock processing circuit 20 may comprise a low pass filter 24 and a variable crystal oscillator (VCO) 26 coupled in series as shown in FIG. 1. 
     Referring to FIG. 2, one embodiment of error signal generating circuit 18 is illustrated in schematic form. The error signal generating circuit 18 operates by retrieving the pointer values used to fill input buffer 14. The pointer values together with the size of the input buffer are used to determine the number of words of unprocessed data stored in the buffer and the number of words of already processed data or empty spaces in the buffer at any given time. The error signal generation circuit 18 calculates a value for the average number of unprocessed words in a buffer and a value for the average number of words of processed data or empty spaces every 24 milliseconds, for example. These average numbers are then used to calculate long-term averages for the number of unprocessed words in the buffer and the number of processed words or spaces in the buffer for an averaging period. The averaging period may be a variable amount of time which may range from 1/2 second to 3 seconds in length, for example. The long-term average of the number of unprocessed words in the buffer is supplied as a 12 -bit number to a first register 25 shown in FIG. 2. The long-term average of the number of processed words or spaces in the buffer is supplied to a second register 27. Register 25 and register 27 are each coupled to a multiplexer 28 which is driven by a state machine 30. The multiplexer 28 routes either the number stored in register 25 or the number stored in register 27 to a counter circuit 32 which is clocked using a clock signal CLK. The counter 32 is loaded responsive to a LOAD signal supplied by state machine 30. The counter circuit 32 decrements the value received from either register 25 or register 27 until zero is reached, at which time a ZERO signal is activated. The ZERO signal is output to a CLOCK input of a latch circuit 34. The D input and the inverted output of the latch circuit 34 are coupled together and to an input of state machine 30. The non-inverting output of latch circuit 34 is coupled to the state machine 30 and supplies the pulse width modulated error signal output to clock processing circuit 20. 
     The state machine 30 functions to alternatively load the numbers stored in first register 25 and second register 27 into the counter circuit 32. Accordingly, the pulse width modulator output comprises a square wave signal having a positive duty cycle proportional to the value of the number stored in first register 25 and a negative duty cycle proportional to the number stored in second register 27. Accordingly, the pulse width modulated error signal provides an indication as to the tendency of the input buffer 14 to tend toward underflow or overflow at any given time. Such a tendency indicates whether or not the processing and output speed of data processing system 10 is synchronized with the average bit rate of the encoded bit stream received by decoder system 12. 
     The pulse width modulated error signal is supplied to the low pass filter 24 which converts the square wave signal to a DC voltage signal, the value of which indicates the relationship of the positive and negative duty cycles of the pulse width modulated error signal. The DC voltage is supplied to variable crystal oscillator 26 to supply the PCM clock signal to clock the output of decoder 12 and input of digital-to-analog converter 16. Accordingly, a feedback loop is established whereby the PCM clock signal will track the average bit rate of the encoded bit stream. 
     According to one embodiment of the present invention, a clock divider circuit 22 can be interposed between clock processing system 20 and the clock inputs that control transfer of PCM data from decoder 12 to digital-to-analog converter 16. Clock divider circuit 22 can provide flexibility within system 10 to allow for the varying requirements of different digital-to-analog converters 16. For example, some digital-to-analog converters provide for oversampling which requires a proportional PCM clock input. 
     If desired, the clock divider circuit 22 can be formed on the same chip as the remainder of decoder system 12. According to this embodiment, the output of the variable crystal oscillator 26 is returned to a clock divider input pin on the integrated decoder system 12 and the PCM clock signal is an output from the integrated decoder system 12. 
     According to another aspect of the present invention, the error signal generation system 18 can monitor the rate of change of the average number of words in the buffer or the rate of change of the average number of spaces in the buffer which are, of course, related in a linear fashion. The error signal generation system 18 can use this information to adjust the long-term averaging period to optimize the operation of the system 10. For example, if the rate of change increases, the error signal generation system is calculating the long-term average too often and as such the long-term average can be stepped up from, for example, 1/2 second to a second or from a second to 2 seconds. 
     According to another aspect of the present invention, the step size within the adjustable averaging period operation can itself be nonuniform. For example, if an original step of from 1/2 second to one second does not sufficiently quiet the rate of change of the average value, the error signal generation can then jump a full second in an attempt to obtain the correct averaging period. 
     According to an alternative embodiment of the present invention, the clock divider circuit 22 is eliminated and the PCM clock signal is supplied directly to the inputs that control transfer of PCM data to digital-to-analog converter 16. Many digital-to-analog converters contain some input buffering and supply a word clock signal to indicate the readiness to receive another group of digital data. In this manner, the PCM data output by decoder system 12 can be output a word at a time using the word clock signal output from digital audio converter 16 as an output enable signal returned to the decoder system 12. 
     Although the present invention has been described in detail, it should be understood that various changes, substitutions and alterations may be made to the embodiments described herein without departing from the spirit and scope of the invention as solely defined by the appended claims.