The present invention relates to a method and apparatus for data stream management.
Compressed media is packed into bitstream or bytestream by an encoder, which are serialized compressed data stream for broadcast or storage media. The decoder shall unpack the bitstream or bytestream, and perform necessary transformation of unpacked data using information available in unpacked data.
Compressed data is generally segmented as frames for error recovery, reducing decoding latency and buffering size. For example, In a MPEG 1 Layer 3 audio compression, the current frame can be decompressed using data from current and limited number of past frames. The past frame dependency is due to bit reservoir support in MPEG 1 Layer 3[3].
In order to decode the compressed audio streams, the bitstream or bytestram needs to be buffered in a memory accessible by decoder hardware. The decoder hardware shall perform bit/byte extraction from the stream buffer to retrieve information needed for decompression.
Since the rate of data stream and data processing is different, buffers are utilized to archive the data received and facilitate later processing of such data. Such processing requires a lot of data movement, processing cycles and power consumption.
Therefore, there is a need for a method and a system for improved data stream management.
Embodiment of the present invention is a method and apparatus of managing data stream. The method comprising archiving received data in a circular buffer; utilizing a breakpoint in realizing the archived received data continuity, wherein the breakpoint is set to the last data portion of the archived received data; when the archiving of the received data approaches the end of the circular buffer, stitching the last portion of the archived received data to the start of the circular buffer; and setting the breakpoint to the updated last data portion of the archived data.
So that the manner in which the above recited features of the present invention can be understood in detail, a more particular description of the invention, briefly summarized above, may be had by reference to embodiments, some of which are illustrated in the appended drawings. It is to be noted, however, that the appended drawings illustrate only typical embodiments of this invention and are therefore not to be considered limiting of its scope, for the invention may admit to other equally effective embodiments.
In one embodiment, CIP 102 passes control information needed for processing the bitstream from HOST to the audio core 100 (i.e. BPU 104). The audio core 100 may intimate HOST of bitstream properties, playback completion of stream, etc. The audio core 100 may utilize multiple channels, such as, channel 0 (CH0) 114 and channel 1 (CH1) 116. The audio core 100 may utilize burst data transfer capability for allowing for faster data transfer.
BPU program memory 118 and AU program memory 120, usually, are separate program memories. Program memories may be entirely ROM, partly ROM and rest RAM, or entirely RAM. BPU data memory 108 and AU data memory 112 may be mix of RAM and ROM or RAM only. BPU 104 and AU 106 may communicate via a shared memory bank. In one embodiment, BPU 104 serves as master and AU 106 as slave. As such, BPU 104 may initiate AU to start executing instruction from AU program memory 102 and AU 106 may interrupt BPU 104 to inform AU of processing completion. BPU 104 and AU 106 may be idled (sleep) when not in use.
Bitstream buffer may be a 16 bit memory. During the unpacking of the bitstream, varying number of bits need to be extracted from the bitstream. The number of bits extracted need not fall on 16 bit (word) boundary. Thus, a ‘bit’ register is used to point to a current position on the bitstream, from which the next unpacking of bits needs to be performed (i.e. MS 12 bits of ‘bit’ hold word address and LS 4 bits hold bit position in the word). Furthermore, to extract bits, 16 bit funnel shifter may be used.
Usually, a bitstream contains more bits than available memory in a bitstream buffer. Thus, part of the bitstream is fetched into a bitstream buffer for decoding. A bitstream break interrupt may be set on any word boundary in the bitstream buffer. When a ‘bit’ pointer reaches the word breakpoint, breakpoint interrupt is generated. The bitstream break interrupt is usually utilized for handling the end of a bitstream buffer wrap-around and the main data discontinuity caused by the bit reservoir. Without bitstream break interrupt, the data usually needs to be stitched by means of extensive memory copy/move. Though this example describes the data as audio data, one of ordinary skill in the art would appreciate that the data may be any type of data, such as, media, video, and the like.
A circular buffering can be implemented using the bitstream breakpoint 202.
One of ordinary skill in the art may recognize that a Huffman decoder, i.e. in MPEG 1 Layer 3, could move ‘bit’ pointer backwards by up to 16 bits (1 word). Thus, in circular buffer wrap-around, an additional word may be copied in order to satisfy a Huffman decoder. The word, before the breakpoint word (last word in bitstream buffer), is copied to the top of bitstream buffer+breakpoint word stitch, as shown in
If the refill area wraps around on bitstream buffer end, the refill be accompanied with two DMA transfers. The first transfer is to fill from refill start position through the end of bitstream buffer. The second transfer is to fill from bitstream buffer start through the refill end position.
For bit rates other than free format, frame length may be determined from bit rate and sample rate information contained in header. As such, the ‘bit’ pointer may be advanced by frame length from current frame sync position to obtain the next sync position. Since sync word pattern is not unique, this ensures the detected sync is not pseudo-sync. Moreover, it is beneficial in checking the header to detect stream consistency. In other words, header can be assumed as extension to sync word. The size of header, including extraneous information, may be a fixed number of bits. Furthermore, the main_data_begin may be included with the extraneous information. Thus, the entire current frame (including main_data contained in previous frames), the next frame header and side information may be contained in the bitstream buffer.
The last frame decode would not include a next frame sync. Hence, successive sync search logic may be skipped. If the file size of the stream being decoded is known, the last frame may be detected from DIP DMA source address; typically, the HOST would know the file size.
If next frame sync is not detected in estimated buffer position, the ‘bit’ position may be advanced by 8-bits from the current sync position and the sync search may be performed again. If a stream starts with non-mp3 data followed by mp3 bitstream, on detection of first sync, the buffer is refilled through the sync position. Once the sync position is filled, a full frame would be in the buffer. If the sync position is not found, the entire buffer would be refilled. After the refilling of the buffer, a sync search may be performed. If the sync is not found, other than for the last frame, the frame may be determined to be erroneous and not decoded.
In case of non-mp3 data in between mp3 data, the handling is similar to non-mp3 data in the beginning. The mp3 data marks the beginning of the decoding. The mp3 frame receding non-mp3 data is skipped from the decoder. Sync search is performed on the available data. Once the sync is detected, the buffer is refilled through the sync position. The refill may start from the bitstream buffer start. After the refill is performed, the decoding may continue normally.
If a main_data_begin field points to an invalid data, the frame is not decoded. In such a circumstance and since the buffer is circular, the main_data_begin may be pointing to future data. If the stream starts with non-zero main_data_begin (i.e. the frame refers to previous frame for current frame decode), and since a circular buffer wraps around the bitstream buffer start, the ‘bit’ pointer may look at future data for main_data decode/parse. As a result, the current frame is neither decoded nor refilled.
The next stream header and side information is parsed. The main_data_begin pointing position validity is established before proceeding to the decoding step. Since the previous frames are not present in memory, the data is not decoded. Consequently, and since the data is established as mp3 frames, the refill is not performed on non-decodable frames. As a result, only partial frame or full frame (not the next frame start) is present in bitstream buffer. If the next sync is not detectable in the bitstream buffer, the buffer is refilled to the side information of the next frame. This ensures the presence of the present frame in bitstream buffer, including main_data in past frames.
The DMA refill operation may run in parallel with decoding of the last granule/channel in current frame in AU. While the current frame PCM samples are being generated, the DMA refill operation requires the parsing of the side information (main_data_begin) of next frame. This is possible because of dual core architecture. The side information needed for the AU for processing PCM samples are already copied on the AU memory. Hence, the BPU can update the BPU memory with the next frame side information.
While the foregoing is directed to embodiments of the present invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof, and the scope thereof is determined by the claims that follow.
This application claims benefit of U.S. provisional patent application Ser. No. 60/893,907, filed Mar. 9, 2007, which is herein incorporated by reference.
Number | Date | Country | |
---|---|---|---|
60893907 | Mar 2007 | US |