Computing devices are evolving from general-purpose, non-real time number crunchers into real-time processing devices comprising main processors that perform digital processing tasks. In modern computing devices, a combination of factors such as, for example, cache memories, delayed interrupt handling, and shared resources, generally make processing time in these devices highly variable and unpredictable. For instance, the first pass through a typical program loop may take 10-50 times longer than subsequent passes through the same program loop due to cache fill cycles. However, conventional stream processing typically requires predictable and substantially non-variable processing times in order to achieve high quality results.
The invention described herein is illustrated by way of example and not by way of limitation in the accompanying figures. For simplicity and clarity of illustration, elements illustrated in the figures are not necessarily drawn to scale. For example, the dimensions of some elements may be exaggerated relative to other elements for clarity. Further, where considered appropriate, reference labels have been repeated among the figures to indicate corresponding or analogous elements.
The following description describes event handling techniques that may be useful for, among other things, processing streams such, as for example, audio streams, video streams, and/or data streams. In the following description, numerous specific details such as logic implementations, opcodes, means to specify operands, resource partitioning/sharing/duplication implementations, types and interrelationships of system components, and logic partitioning/integration choices are set forth in order to provide a more thorough understanding of the present invention. It will be appreciated, however, by one skilled in the art that the invention may be practiced without such specific details. In other instances, control structures, gate level circuits and full software instruction sequences have not been shown in detail in order not to obscure the invention. Those of ordinary skill in the art, with the included descriptions, will be able to implement appropriate functionality without undue experimentation.
References in the specification to “one embodiment”, “an embodiment”, “an example embodiment”, etc., indicate that the embodiment described may include a particular feature, structure, or characteristic, but every embodiment may not necessarily include the particular feature, structure, or characteristic. Moreover, such phrases are not necessarily referring to the same embodiment. Further, when a particular feature, structure, or characteristic is described in connection with an embodiment, it is submitted that it is within the knowledge of one skilled in the art to effect such feature, structure, or characteristic in connection with other embodiments whether or not explicitly described.
Embodiments of the invention may be implemented in hardware, firmware, software, or any combination thereof. Embodiments of the invention may also be implemented as instructions stored on a machine-readable medium, which may be read and executed by one or more processors. A machine-readable medium may include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computing device). For example, a machine-readable medium may include read only memory (ROM); random access memory (RAM); magnetic disk storage media; optical storage media; flash memory devices; electrical, optical, acoustical or other forms of propagated signals (e.g., carrier waves, infrared signals, digital signals, etc.); and others. Further, firmware, software, routines, instructions may be described herein as performing certain actions. However, it should be appreciated that such descriptions are merely for convenience and that such actions in fact result from computing devices, processors, controllers, or other devices executing the firmware, software, routines, instructions, etc.
An embodiment of a computing device 100 comprising a time-stamping circuit 102 is shown in
The computing device 100 may further comprise a chipset 114 that is coupled to the processors 104 via a processor bus. The chipset 114 may comprise one or more integrated circuit packages or chips that couple the processors 104 to other components of the computing device 100 such as memory 116. The memory 116 may comprise memory devices (not shown) having addressable storage locations that may be read from and/or written to. The memory devices may comprise one or more volatile memory types such as, for example, RAM (random access memory) devices, SRAM (static RAM) devices, DRAM (dynamic RAM) devices, SDRAM (synchronous DRAM) devices, DDR (double data rate) SDRAM devices, etc. The memory devices may further comprise one or more non-volatile memory types such as, for example, Flash memory devices, ROM (read only memory) devices, PROM (programmable read only memory) devices, EPROM (erasable PROM) devices, EEPROM (electrically erasable PROM) devices, Ferroelectric memory devices, battery-backed memory devices, etc.
The chipset 114 may further couple the processors 104 to the BIOS firmware 112. The BIOS firmware may comprise routines which the computing device 100 may execute during system startup in order to initialize the processors 104, chipset 114, and other components of the computing device 100. Moreover, the BIOS firmware 112 may comprise routines or drivers which the computing device 100 may execute to communicate with one or more components of the computing device 100.
The chipset 114 may further couple the processors 104 to one or more media devices 118, network interfaces 120, and/or other I/O devices 122 via one or more buses 124. The media devices may comprise audio/video playback devices, audio/video capture devices, audio/video transport devices, etc. The network interfaces 120 may comprise LAN (local area network) controllers, modems, and/or wireless network controllers that provide the computing device 100 with communication links to other computing devices, servers, and/or other network-enabled devices. Further, the I/O devices 122 may comprise mice, keyboards, video controllers, hard disk drives, floppy disk drives, etc.
As depicted, a bus 124 may be shared among one or more media devices 118, network interfaces 120, and/or I/O devices 122. Accordingly, the computing device 100 may comprise an arbitration scheme to allocate access to the shared bus 124. In one embodiment, the computing device 100 may comprise an arbiter 126 that receives request signals or messages from the devices 118, 120, 122 sharing the bus and that generates grant signals or messages to grant one of the requesting devices 118, 120, 122 access to or ownership of the shared bus 124. As depicted, the chipset 114 may include the arbiter 126 for the shared bus 124. However, in other embodiments, the arbiter 126 may be external to the chipset 114. Further, the computing device 100 may be implemented without a central arbiter 126 for the shared bus 124. In such an embodiment, the devices 118, 120, 122 may generate signals that result in the devices 118, 120, 122 arbitrating among themselves to obtain ownership of the shared bus 124.
Further, the chipset 114 may comprise an interrupt controller 127 to receive interrupt events (e.g. signals, messages) from the devices 118, 120, 122 and to deliver the interrupt events to the processor 104 for processing. In particular, the interrupt controller 127 may detect the occurrence of one or more interrupt events and may deliver the detected interrupt events to the processor 104 in an order that is based upon a priority associated with each of the detected interrupt events.
Referring now to
As depicted in
The controller 136 may receive events such as, for example, interrupt request signals, interrupt request messages, arbitration grant signals, etc. from the media devices 118, network interfaces 120, I/O devices 122, and/or arbiter 126. The controller 136 may further be programmed to stamp certain events of interest and to basically ignore other events. For example, the controller 136 may be programmed or otherwise configured to stamp the first arbitration grant signal following an interrupt request from an audio interface of the media devices 118. Similarly, a media device 118 may be assigned to generate interrupt requests on a particular interrupt line (e.g. interrupt signal line INT_5), and the controller 136 may be programmed or otherwise configured to stamp all interrupt requests received on the interrupt line assigned to the media device 118.
In response to detecting an event of interest, the controller 136 may store a time stamp 132 for the detected event in the event store 138. In one embodiment, the controller 136 may simply store the current count 130 of the counter 134 as the time stamp 132 for the detected event. In another embodiment, the controller 136 may generate the time stamp 132 based upon the count 130 of the counter 134. For example, the controller 136 may generate the time stamp 132 by encoding the count 130 such that the time stamp 132 includes fewer bits than the count 130 and/or by placing the time stamp 132 in a form suitable for or expected by a requester (e.g. a processor 104).
In response to detecting an event of interest, the controller 136 may further store an event identifier 142 with the time stamp 132 in the event store 138. The event identifier 142 may indicate a source (e.g. a particular media device 118) or type (e.g. interrupt signal INT_5 or arbitration grant GNT_1) of the event. The event identifier 142 may be used to retrieve the time stamp 132 for a particular event from the event store 138. In one embodiment, the event store 138 may store multiple events and multiple events of the same type. The event store 138 may further retrieve stored time stamps 132 in a first in first out (FIFO) order based upon event identifier 142.
In one embodiment, the event store 138 may be implemented as a single tagged FIFO queue-like structure as illustrated in
For example,
The event store 138, however, may be implemented using other storage structures. For example, the event store 138 may comprise a separate FIFO structure for each supported event type/source and the controller 136 may push time stamps 132 into the appropriate FIFO structure. In such an embodiment, event identifiers 142 may not be stored in the event store 138 since time stamps 132 may be simply pulled from the head 146 of the appropriate FIFO structure. It should also be appreciated that the FIFO structures may be implemented in various manners. For example, the FIFO structures may be implemented as ring buffers with head and tail pointers to track the head 146 and tail 144 of each FIFO structure.
Referring now to
The one or more processors 104 of the computing device 100 may prepare the data blocks 158 of the received stream 152 to place the data blocks 158 in a form suitable for processing by a media device 118. The processors 104 may then cause the prepared data blocks 158 to be transferred to a media device 118 (e.g. an audio codec) for processing. The media device 118 may convert the data blocks 158 to audio samples and/or video frames and may playback and/or process the audio samples and/or video frames at a processing rate that is based upon the reference clock 128 of the computing device 100.
Ideally, the frequency of the reference clock 128 and the frequency of the program clock 156 would match. In which case, the media device 118 may stay in synchronization with the server 150 by simply processing the data blocks 158 at a processing rate set by the reference clock 128. However, in practice, the frequency of the reference clock 128 and the frequency of the program clock 156 do not match exactly. As a result, unless corrective action is taken, an over-run or an under-run condition will likely occur thus introducing artifacts into the playback or processing of the stream 152. In particular, if the program clock 156 is faster than the reference clock 128, buffers of the computing device 100 will likely over-run as a result of receiving data blocks 158 at a rate that is faster than they are being processed. Similarly, if the program clock 156 is slower than the reference clock 128, one or more buffers of the computing device 100 will likely under-run as a result of receiving data blocks 158 at a rate that is slower than they are being processed.
In one embodiment, the media device 118 may generate an interrupt signal each time the media device 118. is ready to receive more data blocks 158 for processing. In such an embodiment, the interrupt signals may accurately reflect the actual processing rate of the media device 118. Accordingly, if the processor 104 may accurately determine the times at which such interrupt signals are generated, the processor 104 may accurately determine the actual processing rate of the media device 118. To enable the processor 104 to accurately determine the times of such interrupt signals, the time-stamping circuit 102 may detect and stamp such interrupt signals without appreciable latency and/or latency variance between event occurrence and event stamping.
In another embodiment, the arbiter 126 may generate a grant signal that grants the media device 118 access to bus 124 each time data blocks 158 are transferred to the media device 118 for processing. Such arbitration signals may accurately reflect the actual processing rate of the media device 118. Again, if the processor 104 may accurately determine the times at which such grant signals are generated, the processor 104 may accurately determine the actual processing rate of the media device 118. To enable the processor 104 to accurately determine the times of such grant signals, the time-stamping circuit 102 may detect and stamp such grant signals without appreciable latency and/or latency variance between generation of the detected grant signal and the stamping of the detected grant signal. It should be appreciated, however, that other events may also accurately reflect the processing rate of the media device 118. Accordingly, the time-stamping circuit 102 may be configured to stamp these other events so that the occurrence times of these events may be accurately determined.
An embodiment of a stream processing method is shown in
In response to the application 108 requesting the media device 118 to process one or more data blocks 158, a device driver 110 for the media device 118 in block 206 may configure the media device 118 for processing of the stream 152 and may configure the time-stamping circuit 102 for stamping of events indicative of the processing rate of the media device 118. In one embodiment, the device driver 110 may program the time-stamping circuit 102 to stamp interrupt signals that are generated by the media device 118 when the media device 118 is ready to process more data blocks 158. In another embodiment, the device driver 110 may program the time-stamping circuit 102 to stamp grant signals that are generated by the arbiter 126 prior to data blocks 158 being transferred to the media device 118 via the shared bus 124.
The media device 118 in block 208 may generate an interrupt event (e.g. interrupt signal INT_5) when the media device 118 is ready to receive one or more data blocks 158 of the stream 152. The controller 136 of the time-stamping circuit 102 in block 210 may determine whether to time stamp the interrupt event. In one embodiment, the controller 136 may determine whether the detected interrupt event is an event of interest that the controller 136 has been programmed to time stamp. In response to determining to time stamp the interrupt event, the controller 136 may store a time stamp 132 and an event identifier 142 for the event in the event store 138 (block 212).
In response to the interrupt event, the device driver 110 for the media device 118 in block 214 may request from the time-stamping circuit 102 a time stamp 132 for an event indicative of the processing rate of the media device 118. In one embodiment, the device driver 110 may provide the interface 140 with an event identifier 142 for such an event (e.g. interrupt signal and/or arbitration signal). The time-stamping circuit 102 in block 216 may provide the device driver 110 with a time stamp from its event store 138 based upon the received event identifier 142.
The device driver 110 in block 218 may determine the processing rate of the media device 118 based upon the received time stamp 132 and may determine the PCR of the stream 152 based upon the PCR stamps 160 of the stream 152. In one embodiment, the device driver 110 may determine a processing rate based upon the received time stamp 132 and one or more previously received time stamps 132. Similarly, the device driver 110 may determine a PCR based upon a PCR stamp 160 and one/or more previously received PCR stamps 160. For example, the device driver 110 may determine a difference between the current time stamp 132 and a previously received time stamp 132 and may update a determined processing rate based upon the obtained difference. Similarly, the device driver 110 may determine a difference between a current PCR stamp 160 and a previously received PCR stamp 160 and may update a determined PCR based upon the obtained difference.
In block 220, the device driver 110 may adjust the processing rate of the media device 118 based upon the determined processing rate and PCR. In one embodiment, the device driver 110 may adjust the frequency of the reference clock 128 and/or may reconfigure the media device 118 to adjust its processing rate in relation to the frequency of the reference clock 128. In another embodiment, the device driver 110 and/or application 108 may resample one or more data blocks 158 of the stream 152 to substantially match the PCR of the resampled data blocks 158 to the processing rate of the media device 118. For example, the device driver 110 and/or application 108 may upsample one or more data blocks 158 if the processing rate of the media device 118 is faster than the PCR of the stream 152. Similarly, the device driver 110 and/or application 108 may downsample one or more data blocks 158 if the processing rate of the media device 118 is slower than the PCR of the stream 152.
In block 222, the device driver 110 may cause the chipset 114 and/or media device 118 to transfer data blocks 158 from the memory 116. In one embodiment, the device driver 110 may cause a DMA (direct memory access) engine of the chipset 114 or the media device 118 to transfer data blocks 158 from the memory 116 to the media device 118 for processing. In block 224, the chipset 114 and/or media device 118 may request ownership of the shared bus 124 for the media device 118 and the arbiter 126224 may grant the requester 114,118 ownership of the shared bus 124. The controller 136 of the time-stamping circuit 102 in block 226 may determine whether to time stamp the grant event. In one embodiment, the controller 136 may determine whether the detected grant event is an event of interest that the controller 136 has been programmed to time stamp. In response to determining to time stamp the grant event, the controller 136 may store a time stamp 132 and an event identifier 142 for the event in the event store 138 (block 228).
The media device 118 in block 230 may receive the data blocks 158 and may process the data blocks 158 at a processing rate controlled by the reference clock 128. In particular, the media device 118 may generate audio samples and/or video frames from the data blocks 158 and may playback the audio samples and/or video frames at a rate dictated by the reference clock 128. In block 232, the media device 118 may determine whether it has completed processing of the stream 152. If the media device 118 determines to process further data blocks 158 of the stream 152, then the media device 118 may return to block 208 in order to generate an interrupt signal that indicates that the media device 118 is ready to receive additional data blocks 158. Otherwise, the media device 118 may cease processing of the stream 152.
While certain features of the invention have been described with reference to example embodiments, the description is not intended to be construed in a limiting sense. Various modifications of the example embodiments, as well as other embodiments of the invention, which are apparent to persons skilled in the art to which the invention pertains are deemed to lie within the spirit and scope of the invention.