Data formatting apparatus

Abstract: Data formatting apparatus for formatting variable bit length data words into successive fixed bit length data words comprises an N-bit circular buffer (160) comprising a plurality of concatenated buffer sections, each buffer section having the same bit length as one of the fixed bit length data words. A modulo-N counter (120) generates a count of the cumulative length of received variable bit length data words. Each received variable bit length data word is stored in the N-bit circular buffer (160) at a bit position dependent on the count signal, and, in response to a detection that data has been stored in all of the bits of that buffer section, the stored data from that buffer section is output as a fixed bit length data word.

Description: This invention relates to the field of data formatting, and more particularly to the formatting of variable bit length data words into successive fixed bit length data words. Some data compression systems produce compressed data comprising successive variable bit length code words. For example, in an image data compression system proposed by the Joint Photographic Experts Group (JPEG), image data are subjected to frequency separation, quantisation and then entropy encoding. The entropy encoding stage generates variable bit length data words in such a way that more commonly occurring data patterns (such as runs of zero-valued data) are encoded as shorter data words. Although variable length encoding can allow data to be efficiently compressed, subsequent storage of the data or other processes such as error correction encoding generally operate on fixed length data words. It is therefore necessary to convert the variable length data words into fixed length data words. However, the data format conversion itself introduces an additional data processing overhead. In a non real time system, such as still image processing and display in a computer system, this is not a particular problem. However, in a system dealing with data such as real time video data, the high data rates present a particular challenge in providing data format conversion in a way that can keep pace with the overall data rate and only introduce a small time lag in the processing. This invention provides a data formatting apparatus for formatting variable bit length data words into successive fixed bit length data words, the apparatus comprising: an N-bit circular buffer comprising a plurality of concatenated buffer sections, each buffer section having the same bit length as one of the fixed bit length data words; a modulo-N counter for generating a count signal in response to the cumulative length of received variable bit length data words; means for storing a current variable bit length data word in the N-bit circular buffer at a bit position dependent on the count signal; means associated with each buffer section for detecting whether data has been stored in all of the bits of that buffer section; and means responsive to a detection that data has been stored in all of the bits of a buffer section for outputting the stored data from that buffer section as a fixed bit length data word. In a preferred embodiment the means for storing comprises an N-bit barrel-rotator operable to barrel-rotate each variable bit length data word by a number of bits dependent upon the count signal generated by the modulo-N counter in respect of the preceding variable bit length data word. In this way the most significant bit of the current variable length data word can be barrel-rotated to a bit position adjacent to the least significant bit of the preceding variable length data word, before the current variable bit length data word is stored in the N-bit buffer. Preferably the means for storing comprises an enable generator, responsive to the count signals generated by the modulo-N counter in respect of the current and the preceding variable bit length data words, for generating respective write-enable signals to control writing of each bit of the current variable bit length data word from the barrel-rotator to the N-bit buffer. In advantageously simple embodiments the detecting means associated with each buffer section is operable to detect the generation of a write-enable signal to control writing to a predetermined bit in that buffer section. Viewed from a second aspect this invention provides a method of formatting variable bit length data words into successive fixed bit length data words, the method comprising the steps of: generating a modulo-N count signal in response to the cumulative length of received variable bit length data words; storing a received variable bit length data word in an N-bit circular buffer at a bit position dependent on the count signal, the N-bit circular buffer comprising a plurality of concatenated buffer sections, each buffer section having the same bit length as one of the fixed bit length data words; detecting, for each buffer section, whether data has been stored in all of the bits of that buffer section; and outputting the stored data from a buffer section as a fixed bit length data word in response to a detection that data has been stored in all of the bits of that buffer section. Prior art systems for formatting variable bit length data words into successive fixed bit length data words are known. The prior art systems do not use a circular buffer: EP-A-0 384 782 discloses an image coder which includes a packing circuit. Variable length data is applied to a selectable modulo logic circuit, such as a barrel shifter, and code length information is applied to an accumulator. The accumulator provides a shift control input to the barrel shifter and thereby tightly packs the data, i.e., without any gaps. The packed data is read out of the barrel shifter every clock cycle and read into a fixed length storage means via an OR gate arrangement used to prevent data loss. WO-A-8 907 372 discloses an apparatus for packing sequentially occurring variable length codeword data into memory means for subsequent transmission over a channel. The apparatus groups variable length codewords into successive N-bit word groups and stores the word groups in corresponding N-bit-wide memory locations prior to transmission. The locations are filled to capacity on one clock pulse and emptied on a second clock pulse. The invention will now be described by way of example with reference to the accompanying drawings, throughout which like parts are referred to by like references, and in which: Figure 1 is a schematic block diagram of a video data compression system; Figure 2 is a schematic illustration showing the operation of a runlength and Huffman coder; Figure 3 is a schematic illustration of a formatted data block; Figure 4 is a schematic block diagram of the data input side of a block formatter; Figure 5 is a schematic illustration showing the operation of the apparatus of Figure 4; and Figure 6 is a schematic block diagram of the data output side of a block formatter. Referring now to Figure 1, a video data compression system is shown in which luminance (Y) and chrominance (C) video data are separately compressed before being combined into data blocks by a block formatter 10. The video data compression system shown is suitable for use in a digital video tape recorder (DVTR), in which case the data blocks output by the block formatter 10 are subjected to error correction processing and channel encoding before being recorded on a magnetic tape (not shown). Substantially identical data compression processing is applied to the luminance data and the chrominance data, although the degree of compression applied may be different for the luminance data and for the chrominance data. The luminance and chrominance data are first supplied to respective frequency separators 20, 25 which include banks of horizontal and vertical finite impulse response filters that serve to split and decimate the data into respective frequency-transformed images comprising sub-band components in the two-dimensional spatial frequency domain. Data representing the frequency-transformed luminance and chrominance images are supplied from the frequency separators 20, 25 to respective quantisers 30, 35, in which the data are subjected to lossy quantisation. The quantised data are then passed, in the form of 12-bit data samples, to respective luminance and chrominance runlength and Huffman coders 40, 45. The runlength and Huffman coders 40, 45 exploit correlation within the quantised data to effect compression; their output comprises data words having a variable length in such a way that more commonly occurring data patterns within the quantised data are represented by shorter variable length data words. Each of the runlength and Huffman coders 40, 45 processes the quantised data in a serial fashion. As each 12-bit data sample of the quantised data is received, a "partial" (or interim) Huffman code is generated to represent the pattern of data samples of the quantised data received since a "valid" (or complete) Huffman code was last output by the runlength and Huffman coder. If a received data sample (when added to the pattern of data samples for which a partial code has been generated) results in a data sample pattern to which a Huffman code has not been assigned, the most recent partial code is output by the runlength and Huffman coder as a "valid" code, and the coding starts again from that received data sample. This processing is illustrated in Figure 2, in which respective Huffman codes c 1 to c 5 are generated as the data samples s1 to s 5 are received. The codes c 1 to c 4 are designated as partial codes, because, in each case, when the next data sample is received a new Huffman code can be generated. However, the data sample pattern formed by the concatenation of the pattern s 1 s 2 s 3 s 4 s 5 and the received data sample s 6 does not have a corresponding Huffman code and so cannot be encoded by the runlength and Huffman coder. The code c 5 , representing the data sample pattern s 1 s 2 s 3 s 4 s 5 , is therefore output as a valid Huffman code, and coding is restarted from the received data sample s 6 . In the present embodiment, the Huffman codes comprise data words having a variable length of up to 20 bits. At each stage of coding (i.e. as each sample of the quantised data is processed by the runlength and Huffman coder), either a partial or a valid Huffman code is output by the coder on a 20-bit parallel data bus. Any bits of the data bus not occupied by bits of the Huffman code are set to logical 1. At the same time, a 5-bit number indicating the length in bits of the current Huffman code is supplied on a "code length" (CL) output, and a "partial flag" (PF) output from the runlength and Huffman coder indicates whether the current Huffman code is a partial or a valid code. These three sets of output signals from each of the runlength and Huffman coders 40, 45 are supplied to the block formatter 10. The variable length data words output by the luminance and chrominance runlength and Huffman coders 40, 45 in Figure 1 are combined into a single data stream and formatted into fixed length data blocks by the block formatter 10. The block formatter 10 also receives signals from the quantisers 30, 35 indicative of the degree of quantisation applied to the compressed data currently being received by the block formatter. As mentioned above, the formatted data blocks output by the block formatter 10 are subjected to error correction processing and channel encoding before being recorded on a magnetic tape. Figure 3 is a schematic illustration of a formatted data block 80 generated by the block formatter 10. The data block 80 comprises a 4-byte header section 85 and a 120-byte video data section 90. The video data section 90 comprises a luminance data section 95 and a chrominance data section 100, which represent identical portions of the frequency-transformed luminance and chrominance images generated by the respective frequency separators 20, 25. However, the relative sizes of the luminance data section 95 and the chrominance data section 100 will depend (amongst other things) on the respective degrees of quantisation applied by the quantisers 30 and 35, and on the information content of those portions of the transformed luminance and chrominance images. Each formatted data block 80 is self-contained, in so far as it can be replayed and decoded even when adjacently recorded data blocks are not successfully replayed. This means that it is still possible to recover video data during, for example, shuttle (high speed) tape replay when only some of the data blocks are successfully replayed. This feature is made possible by including in each formatted data block 80 the header section 85 defining the relative sizes of the luminance and chrominance data sections, the degree of compression applied to the data in the video data section 90 and the portion of the respective frequency-transformed images represented by the luminance and chrominance data in the video data section 90. In particular, the header section 85 comprises a start address indicative of the position of the video data in the video data section 90 within the transformed images generated by the frequency separators 20 and 25; an indication of the spatial frequency band of the luminance and chrominance data in the data section 90; an indication of the degree of quantisation applied to that data; and a Y/C boundary pointer. The Y/C boundary pointer indicates the position within the video data section 90 of the boundary between the luminance data section 95 and the chrominance data section 100. Figure 4 is a schematic block diagram of the data input side of the block formatter 10. In the block formatter 10, substantially identical processing is applied to the compressed luminance data received from the runlength and Huffman coder 40 and to the compressed chrominance data received from the runlength and Huffman coder 45. Accordingly, for clarity of the diagram, only the processing applied specifically to the luminance data, and the common processing applied to both luminance and chrominance data, have been shown. The code length and partial code signals from the luminance runlength and Huffman coder 40 are received by a format accumulator 120. The format accumulator 120 generates a 5-bit output signal representing a modulo-32 count of the code lengths of valid luminance Huffman codes received during the formatting of a current data block. The count signal is supplied to a latch 130, to an enable generator 135, and (via the latch 130) to a 32-bit barrel-rotator 140. A count accumulator 125 also receives the luminance code length and partial code signals, along with corresponding code length and partial code signals from the chrominance runlength and Huffman coder 45. The count accumulator 125 maintains a count of the cumulative lengths of valid luminance codes and of valid chrominance codes. These counts are then summed to generate a total count. When this total count reaches the available length of the video data section 90 (effectively 119 bytes, because the luminance and chrominance data sections are eventually rounded up to the nearest byte), an end of block signal is generated by the count accumulator 125. The end of block signal is supplied to the format accumulator 120, a header register 150, and the runlength and Huffman coders 40 and 45. The value of the Y/C pointer is generated by a boundary accumulator 126. As described above, the Y/C pointer is included in the header section 85 of each formatted data block, and indicates the boundary between the luminance data section 95 and the chrominance data section 100 in that data block. The position of this boundary is defined only to the nearest byte (to reduce the number of bits required to represent the Y/C pointer) and is dependant on the quantity of luminance data contained in the luminance data section 95. Therefore, the boundary accumulator maintains a count of the cumulative length of the luminance Huffman codes to be included in each data block. When the end of a block is detected, the boundary accumulator 126 supplies the cumulative luminance code length (rounded up to the nearest byte) to the header register 150 for inclusion in the block header as the Y/C pointer. As each valid luminance Huffman code is received by the block formatter, the length of that code in bits is added to the count held by the format accumulator 120. The Huffman code word itself is received on a 20-bit parallel data bus by the 32-bit barrel-rotator 140, with any unused bits of the data bus being set to logical 1. (The 12 remaining inputs of the 32-bit barrel-rotator are also set to logical 1). The barrel-rotator 140 operates to barrel-rotate the code word at its input by a number of bits corresponding to the previous count output of the format accumulator 120. At the same time, the enable generator 135 is supplied with the current and previous count outputs of the format accumulator 120 (i.e. directly and via the latch 130). From these two inputs, the enable generator 135 establishes which bits of the 32-bit barrel-rotator 140 are occupied by data bits of the Huffman code word, and sets corresponding enabling signals to control writing of only those bits from the barrel-rotator 140 into a 32-bit buffer 160. The 32-bit buffer 160 comprises four 8-bit latches, concatenated together to form the 32-bit wide buffer. The arrangement described above means that as each valid Huffman code word is received by the block formatter 10, that word is barrel-rotated so that that word's most significant bit (MSB) is stored in the buffer 160 immediately adjacent to the least significant bit (LSB) of the previously received valid code word. In this way, variable length Huffman code words received on a parallel data bus are abutted next to one another to form an essentially continuous data stream. The abutted code words held in the buffer 160 are read out for storage in a first-in-first-out (FIFO) store 170. The transfer from the buffer 160 to the FIFO store 170 takes place in fixed length 8-bit data words. To achieve this, whenever the MSB of one of the four 8-bit latches is selected by the enable generator 135 (indicating that data has been written to the whole of that 8-bit latch) a write enable (WE) signal is generated to control the transfer of the 8 bits of data previously held by that latch into the FIFO store 170. When the count accumulator 125 detects that the end of a block of data has been reached, it supplies an end of block signal to the format accumulator 120. This has a number of effects. The current Huffman code is considered to be a valid code. The format accumulator 120 adds the current code length to its currently held count and rounds up the result to the nearest byte (i.e. the nearest multiple of 8 bits in modulo 2 arithmetic). Because the count has been rounded up to the nearest byte, the data transferred from the barrel-rotator 140 to the buffer 160 is padded with logical ones (if necessary) to fill a complete latch in the buffer 160. The logical ones are available either from unused bits of the 20-bit Huffman codes or from the twelve additional inputs to the barrel rotator 140. Padding the last fixed length data word of the luminance data section 95 (and of the chrominance data section 100) does not cause problems when the Huffman codes are subsequently decoded. This is because a succession of up to seven logical ones does not form a Huffman code which represents valid data. Instead, the succession of logical ones is ignored by a subsequent Huffman decoder. The header register receives the end of block signal from the count accumulator 125, along with the total number of bytes of luminance data in the current data block. The header register also receives an indication of the degree of quantisation applied to the data in that block (from the quantisers 30, 35), along with an indication of the frequency band of that data and the sample address of the first sample represented by the data (both of which are determined by the runlength and Huffman coders 40, 45 from the position of the currently received data in the serial data stream received from the quantisers 30, 35). These items are concatenated to form the block header 85 for the current block; this block header is stored for later retrieval in a header FIFO 180. Figure 5 is a schematic illustration showing the operation of the block formatter circuit of Figure 4. In Figure 4 the 32 bits of the buffer 160 are numbered from 0 to 31 in a vertical direction and are arranged into four groups of 8 bits, where each group represents one of the 8-bit latches. Eight consecutive valid Huffman code words are illustrated (numbered from 1 to 8) having respective code lengths of 10, 14, 4, 12, 7, 11, 7 and 6. In the example shown, the count held by the format accumulator 10 is assumed to be zero when the first of the code words (code word 1) is received. Code word 1 has a length of 10 bits. It is barrel-rotated by a number of bits corresponding to the count previously held by the format accumulator (i.e. zero), and so is written to the bits 0 to 9 of the buffer 160. Bit 7 of the buffer 160 is a most significant bit (MSB) of one of the four 8-bit latches, so writing to bit 7 triggers the previous contents of that latch to be transferred as an 8-bit word to the FIFO store 170. When the second valid code word (code word 2) is received, its length (14 bits) is added to the count currently held by the format accumulator 120 (10 bits). Code word 2 is barrel-rotated by 10 bits (the previously held count). The enable generator 125 receives the current count output by the format accumulator 120 and the previous count held by the latch 130. This causes write-enables to be generated to control writing of the second code word into the bits 10 to 23 of the buffer 160. Bits 15 and 23 of the buffer 160 are MSBs of two respective 8-bit latches, so the existing contents of those latches are transferred as fixed length 8-bit words to the FIFO store 170. The third received code word has a length of 4 bits, taking the count held by the format accumulator 120 to 28 bits. The length of the fourth code word (12 bits) is added to 28 bits in modulo-23 arithmetic. This means that the count supplied directly to the enable generator 135 is 8, and the count supplied from the latch 130 is 28. Accordingly the bits of the fourth code word are barrel-rotated by 28 bits and are written to bits 28 to 31 and 0 to 7 of the buffer 160. The buffer 160 thus continues to be written to and read from in a circular fashion. Figure 6 is a schematic block diagram of the data output side of the block formatter 10. A read controller 200, which receives information from the header FIFO 180, controls the reading of data from the FIFO store 170, the operation of 3 multiplexers 210, 220 and 230 and the operation of a delay FIFO 240. For each formatted data block, the read controller receives from the header FIFO 180 an indication of the number of bytes of luminance data to be included in that data block. Since the bytes of luminance data were stored in the FIFO store in a cyclic fashion, they are read out under the control of the read controller 200 in an identical cyclic order. The bytes of luminance data read from the FIFO store are combined into a single 8-bit wide data stream by the multiplexer 210. In the data read from the FIFO store, the MSB of each Huffman code word is abutted against the LSB of the preceding code word. This means that the first byte to be read from the FIFO store must have the first bit of the first Huffman code word as its MSB. A corresponding chrominance read controller (not shown) determines the number of chrominance data bytes to be included in the chrominance data section 100 of the data block by subtracting the number of bytes of luminance data from the total number of data bytes in the data block (i.e. 120 bytes). The chrominance read controller controls the reading of the appropriate number of bytes of chrominance data from the chrominance FIFO store into the delay FIFO 240, in which they are held during reading of the luminance data bytes from the FIFO store 170. The luminance and chrominance data bytes are then concatenated together by the multiplexer 220, and finally the header data is concatenated with these data by the multiplexer 230. The output of the multiplexer 230 comprises successive formatted data blocks, each data block having the order of a header section 85, a luminance data section 95, and a chrominance data section 100. Any remaining space in the formatted data blocks is padded with logical ones. As mentioned above, after the Huffman codes have been formatted into data blocks by the block formatter 10, the formatted data blocks are subjected to error correction processing and channel encoding before being recorded on a magnetic tape (not shown).

Claims: Data formatting apparatus (10) for formatting variable bit length data words into successive fixed bit length data words, the apparatus comprising: an N-bit circular buffer (160) comprising a plurality of concatenated buffer sections, each buffer section having the same bit length as one of the fixed bit length data words; a modulo-N counter (120) for generating a count signal in response to the cumulative length of received variable bit length data words; means (135, 140) for storing a current variable bit length data word in the N-bit circular buffer (160) at a bit position dependent on the count signal; means associated with each buffer section for detecting whether data has been stored in all of the bits of that buffer section; and means responsive to a detection that data has been stored in all of the bits of a buffer section for outputting the stored data from that buffer section as a fixed bit length data word. Apparatus according to claim 1, in which the means (135, 140) for storing comprises an N-bit barrel-rotator (140) operable to barrel-rotate each variable bit length data word by a number of bits dependent upon the count signal generated by the modulo-N counter (120) in respect of the preceding variable bit length data word. Apparatus according to claim 2, in which the means (135, 140) for storing comprises an enable generator (135), responsive to the count signals generated by the modulo-N counter (120) in respect of the current and the preceding variable bit length data words, for generating respective write-enable signals to control writing of each bit of the current variable bit length data word from the barrel-rotator (140) to the N-bit circular buffer (160). Apparatus according to claim 3, in which the detecting means associated with each buffer section is operable to detect the generation of a write-enable signal to control writing to a predetermined bit in that buffer section. Apparatus according to any one of the preceding claims, in which variable bit length luminance and chrominance data words from a representation of an image are formatted into respective fixed bit length luminance and chrominance data words, the apparatus comprising: a luminance data store (170) for storing the fixed bit length luminance data words; a chrominance data store for storing the fixed bit length chrominance data words; and means for multiplexing fixed bit length luminance data words read from the luminance data store and fixed bit length chrominance data words read from the chrominance data store, to generate data blocks (80) comprising a predetermined total number of fixed bit length data words. Apparatus according to claim 5, in which each data block (80) comprises: a luminance data section (95) comprising a plurality of fixed bit length luminance data words, concatenated with a chrominance data section (100) comprising a plurality of fixed bit length chrominance data words; and a block header (85) indicative of the position in the data block of the boundary between the luminance data section and the chrominance data section. Apparatus according to claim 6, in which the luminance data section and the chrominance data section in each data block respectively comprise luminance and chrominance data from the same portion of the representation. Apparatus according to claim 7, comprising: means for receiving variable bit length luminance data words and variable bit length chrominance data words from corresponding positions in the representation; a total counter (125) for generating a total data count in response to the cumulative number of fixed bit length luminance data words generated from the received variable bit length luminance data words and fixed bit length chrominance data words generated from the received variable bit length chrominance data words; a boundary counter (126) for generating a boundary count in response to the cumulative number of fixed bit length luminance data words generated from the received variable bit length luminance data words; means (125) for determining when the total data count reaches the predetermined total number; and means (150) responsive to a determination that the total data count has reached the predetermined total number for generating the block header in response to the boundary count, for resetting the total counter, and for resetting the boundary counter. Apparatus according to any one of claims 5 to 8, in which the representation comprises frequency-separated image data representing the image in the two-dimensional spatial frequency domain. Apparatus according to any one of claims 5 to 9, in which each data store (170) comprises a first-in-first-out (FIFO) buffer. Apparatus according to any one of the preceding claims, in which the variable bit length data words comprise Huffman code words. Apparatus according to any one of the preceding claims, in which N = 32 and in which the N-bit circular buffer (160) comprises four 8-bit buffer sections. A method of formatting variable bit length data words into successive fixed bit length data words, the method comprising the steps of: generating (120) a modulo-N count signal in response to the cumulative length of received variable bit length data words; storing (135, 140) a received variable bit length data word in an N-bit circular buffer (160) at a bit position dependent on the count signal, the N-bit circular buffer (160) comprising a plurality of concatenated buffer sections, each buffer section having the same bit length as one of the fixed bit length data words; detecting, for each buffer section, whether data has been stored in all of the bits of that buffer section; and outputting the stored data from a buffer section as a fixed bit length data word in response to a detection that data has been stored in all of the bits of that buffer section.

Inventors: GILLARD CLIVE HENRY, LUDGATE MICHAEL JOHN, GILLARD, CLIVE HENRY, LUDGATE, MICHAEL JOHN
Applicants: SONY UK LTD, SONY UNITED KINGDOM LIMITED
Application year: 1993
Main classification: H03M7
IPC codes: H04N7, H04N9, H03M7, H04N11