Abstract:
A circuit determines a quantification coefficient to be provided to a quantizer incorporated in a picture macroblock compression chain. A first counter counts the number of bits of each macroblock compressed by the compression chain. A first accumulator integrates the difference between each number provided by the first counter and a target, and provides a value corresponding to the quantification coefficient. A microprocessor provides the first accumulator with an initial value and a target at each N macroblocks. Parameters that characterize the current compression process are determined so that the microprocessor determines the target and the initial value to be provided to the first accumulator.

Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     The present invention relates to quantizers used in picture compression circuits according to MPEG or H.261 standards, and more particularly to a circuit for determining the quantization coefficients to be used. 
     2. Discussion of the Related Art 
     According to MPEG and H.261 standards, each picture is processed by squares of 16×16 pixels. A &#34;macroblock&#34; constituted by four 8×8-pixels luminance blocks and two 8×8-pixel chrominance blocks corresponds to each square. The terms &#34;luminance pixel&#34; and &#34;chrominance pixel&#34; are used for the sake of simplification (a pixel is, in fact, a combination of luminance and chrominance pixels). 
     FIG. 1 represents a portion of a picture compression chain according to MPEG and H.261 standards. This chain includes a discrete cosine transform (DCT) circuit 10 processing the macroblocks block by block. The DCT circuit 10 provides for each block a matrix whose coefficients rapidly approach 0 while the position of these coefficients in the matrix get further from the left upper corner of the matrix. 
     A quantizer 12 processes the coefficients provided by the DCT circuit 10. Quantization achieves a division by a positive quantization coefficient Q. The object of the division is to cancel the coefficients approaching 0 in the matrix provided by the DCT circuit 10. 
     The output of the quantizer 12 is provided to a circuit 14 carrying out a zigzag scanning (ZZ) and a run/level coding (RLC). The zigzag scanning scans the quantified matrices to provide long sequences of successive null coefficients between two non null coefficients. The RLC provides pairs of numbers whose first pair represents a number of successive null coefficients and the second pair represents the next first non-null coefficient. 
     A variable length coding (VLC) circuit 16 receives the pairs provided by circuit 14. The VLC circuit 16 replaces the frequent pairs with a short code and the infrequent pairs with a long code. Each code is provided by the VLC circuit 16 on two buses C and L. Bus C provides the code on a determined number of lines, generally lower than the number of lines of the bus. Bus L provides the code length, that is, indicates the number of lines effectively used by the code on bus C. 
     A packing circuit 18 juxtaposes the codes provided by the VLC circuit 16 by eliminating the non-used bits of bus C. The juxtaposed codes constitute the compressed data CD. 
     A major problem for implementing data compression lies in the selection of the quantization coefficient Q. Standards MPEG and H.261 authorize the modification of coefficient Q at each macroblock but do not recommend any particular rule to select the coefficient. 
     The value of the coefficient Q is conventionally selected as a function of the number of bits provided by the compression of each macroblock. As represented, the packing circuit provides a circuit 20 calculating the coefficients Q with the number of bits of each compressed macroblock. The number of bits per macroblock is obtained, for example, by cumulating the lengths L of the codes provided by the VLC circuit for each macroblock. 
     FIG. 1 illustrates a conventional method for determining the quantization coefficient Q, referred to hereinafter as a target method. This method provides setting a target, or objective, indicating the desired number of bits for each compressed macroblock, and adjusting the quantization coefficient at each macroblock by circuit 20 so that the actual number approaches the target. 
     FIG. 2 represents, in solid lines, the effective variation over time of the number of bits of a compressed picture as a function of the number of processed macroblocks MB. The selection of a target for the macroblocks, determines a theoretical linear variation over time, drawn in dotted lines. 
     Prior to the processing of the first picture macroblock, the quantization coefficient Q is initialized. The first macroblock is processed with this quantization coefficient Q and the number of bits increases according to a determined slope. 
     As soon as the first macroblock is processed, its number of bits is compared with the target, and the quantization coefficient is modified proportionally to the difference. In the represented example, the number of bits is higher than the target and the quantization coefficient is increased. 
     In practice, because of the time delays introduced in the processing sequence and in the negative feedback sequence (circuit 20) of a method such as a target method, the value of a quantization coefficient calculated at the end of a first macroblock is determined too late to be applied to the second macroblock; the value is applied to the third macroblock only. This time delay is little impairing because successive macroblocks are often similar. 
     With this method, the effective variation of the number of bits of a picture oscillates about the theoretical variation, the slope of the variation varying at each macroblock to approach the theoretical variation determined by the target. 
     When the target is determined to be the same for all the pictures, this target method is advantageous since it can be easily implemented in a wired system. However, the compression quality significantly varies from one picture to the other. 
     To avoid this drawback, some users desire to modify the target from one picture to the other according to criteria determined during the processing of preceding pictures. However, this method is particularly complex to implement in a wired system and its software implementation would be too slow to carry out a real time compression. 
     Assigning a constant target to a picture provides a variable quality of the picture compression due to the different levels of complexity that may exist in a picture. 
     SUMMARY OF THE INVENTION 
     An object of the present invention is to provide a circuit for determining the quantization coefficient having a particularly simple structure while providing a particularly fast determination of the quantization coefficients according to complex methods. 
     Another object of the present invention is to provide such a circuit implementing a target method wherein the target may vary within a single picture. 
     A further object of the present invention is to provide such a circuit for implementing, with a single structure, a large number of different methods for determining the quantization coefficient. 
     To achieve these objects, an embodiment of the present invention provides a circuit implementing, by hardware, simple functions carried out at a high speed, and, by software, complex functions carried out at a low speed. Particularly, the circuit is designed to implement by hardware a process wherein the target is constant, the target being stored in a register whose content can be modified by a microprocessor carrying out a program designed to allow determination of a variable target from one picture to the next one, and also to allow a target to be varied within one picture. 
     The present invention is more particularly directed to a circuit for determining a quantization coefficient to be provided to a quantizer included in a chain for compressing pictures by macroblocks, including a first counter counting the number of bits of each macroblock compressed by the compression chain; a first accumulator integrating, from an initial value, the difference between each number provided by the first counter and a target, and providing a value corresponding to the quantization coefficient; a microprocessor providing the first accumulator with an initial value at least at each picture and a target at each N macroblocks, where N is a number lower than the number of macroblocks contained in a picture; and means accessible by the microprocessor, providing parameters characterizing the current compression process so that the microprocessor determines the target and the initial value to provide to the first accumulator. 
     According to an embodiment of the invention, the above-mentioned means include a second counter counting the number of bits in each group of N compressed macroblocks; a second accumulator integrating the quantization coefficients used for each group of N macroblocks; and a control circuit interrupting the microprocessor at the end of each group of N macroblocks, so that the microprocessor reads the contents of the second counter and of the second accumulator and calculates, depending on these contents, a target and an initial value provided to the first accumulator. 
     According to an embodiment of the invention, the circuit includes a multiplier receiving the content of the first accumulator and a gain contained in a register accessible by the microprocessor, the output of the multiplier providing the quantization coefficient. 
     According to an embodiment of the invention, the circuit includes a third counter counting the number of bits in each block of compressed macroblocks, the numbers provided by this third counter being accessible by the microprocessor so that the circuit has a mode with two compression steps for each picture. During the first step, the microprocessor must cumulate the number of bits per block to determine gains to be provided to the multiplier during the second step. 
     The foregoing and other objects, features, aspects and advantages of the invention will become apparent from the following detailed description of the present invention when taken in conjunction with the accompanying drawings. 
    
    
     BRIEF DESCRIPTION OF DRAWINGS 
     FIG. 1, above described, partially represents a portion of a picture compression chain according to MPEG and H.261 standards; 
     FIG. 2, above described, represents a diagram of the variation of the number of bits of a picture during compression; 
     FIG. 3 represents the processing sequence of FIG. 1 including an embodiment of a circuit according to the present invention for determining a quantization coefficient to be used in the chain; and 
     FIG. 4 represents the variation of the number of bits of a picture being compressed by the circuit of FIG. 3. 
    
    
     DETAILED DESCRIPTION 
     In FIG. 3, the same elements as those in FIG. 1 are designated with the same references. The invention provides a circuit 20 for calculating the quantization coefficients Q to be provided to the quantizer 12. FIG. 3 represents an embodiment according to the present invention of circuit 20. 
     According to the invention, the calculation circuit 20 is designed for implementing in a wired manner simple functions that may be carried out frequently, for example, at each macroblock, and which are in addition common to most of the methods for determining the quantization coefficients. These functions relate in particular to the determination of the quantization coefficient Q from a constant target. Furthermore, according to the present invention, this target can be readjusted for each picture or even for each picture portion, by a microprocessor that implements complex functions that need not be frequently executed, for example, for each picture or portion of picture. These complex functions are, for example, the determination of the target of a picture to be processed from characteristics provided during the processing of the preceding picture. These functions, that may be programmed by a user or other circuitry, can be implemented with a single structure of the calculation circuit 20. 
     According to one embodiment, the calculation circuit 20 includes a register 30 in which a target of bits per macroblock is stored. The difference between the number of bits per macroblock provided by the packing circuit 18 and the target 30 is accumulated in a register 32 each time a macroblock is processed. For this purpose, register 32 stores, at the rate of a macroblock synchronization signal SMB, the output of an adder 34 which receives the output of register 32, the number of bits per macroblock provided by the packing circuit 18 and, at a subtraction input, the target 30. The content of register 32 may be regularly reset to an initial value, for example each time picture processing begins. 
     The synchronization signal SMB may be, for example, provided by the VLC circuit 16 at each beginning of a variable length coding of a macroblock. 
     The number of bits of each macroblock is obtained, for example, by accumulating in a register (not shown) the code lengths provided by the VLC circuit 16 on bus L, this register being reset at each macroblock by signal SMB. 
     The quantization coefficient Q to be provided to the quantizer 12 constitutes the output of multiplier 36 which multiplies the output of register 32 by a gain stored in register 38. Since MPEG and H.261 standards require a maximum limit for the quantization coefficient Q, the output of multiplier 36 may be limited to this maximum value by a saturation circuit 40. 
     The feedback sequence above described implements the target method using a constant target for all the processed pictures. 
     Moreover, in this embodiment, the target register 30 is connected to a microprocessor 42 through a bus PBUS, which makes it possible for the microprocessor 42 to modify the target. The present invention allows a user or other circuitry to select the modification of the target by units of N macroblocks, where N is a number chosen by the user between 1 and the number of macroblocks of a picture. The lower number N is, the higher the quality of the picture compression, due to the homogenization of the quality of each picture, but the more microprocessor 42 will be used. Thus, the user can make a trade-off between the desired quality and the power of his microprocessor. 
     Number N is, for example, stored in a register of a control circuit 44, accessible by the microprocessor 42 which writes number N in the register at each powering on. The control circuit 44 receives the macroblock synchronization signal SMB, from which it generates a synchronization of N-macroblocks unit (SMMU) signal and an end of N-macroblocks unit (ENMU) signal. Signal ENMU is activated before the end of each unit of N macroblocks, for example at the beginning of the last macroblock of the unit, and its activation constitutes an interruption request IRQ of the microprocessor 42. Microprocessor 42 processes each of these interruptions by calculating a new target and by writing the latter in register 30. 
     To calculate the target, conventional methods require parameters such as the average quantization coefficient Qavg used for the macroblocks of the preceding picture as well as the number of bits provided during compression of the preceding picture. 
     The circuit according to an embodiment of the present invention provides that the average quantization coefficient Qavg and the corresponding number of bits are supplied at each unit of N macroblocks and not at each picture. Thus, it is possible to use these parameters to determine the target of the next unit, or to store these parameters for each picture to determine the targets of the units of the next picture. 
     At each interruption of the microprocessor 42, an average quantization coefficient Qavg is present in a register 46 and the number of bits of the corresponding unit is present in register 48. 
     Register 46 accumulates at each macroblock the quantization coefficient that is used. For this purpose, register 46 may be enabled by the macroblock synchronization signal SMB and receives the output of an adder 50 which sums the content of register 46 and the quantization coefficients Q. 
     At each macroblock, register 48 accumulates the number of bits per macroblock provided by the packing circuit 18. For this purpose, register 48 is enabled by the macroblock synchronization signal SMB and receives the output of an adder 52 which sums the content of register 48 and the number of bits per macroblock. 
     Registers 46 and 48 may be reset by the synchronization signal of macroblock unit SNMU. 
     The parameters stored in registers 46 and 48 are accessible by the microprocessor 42 which reads them at each interruption and calculates as a function of these parameters, or of those stored during the processing of a preceding picture, the new target to write in register 30. 
     There are many methods for calculating a target from an average quantization coefficient Qavg and from the corresponding number of bits; they need not be described here. 
     The possibility of modifying a target at each portion of a picture (at each unit of N macroblocks, for example), makes it possible to assign high targets to complex portions of a picture and low targets to less complex portions of a picture to homogenize the compression quality in a picture. 
     As mentioned above, each interruption of the microprocessor 42 occurs before the end of the processing of a unit of N macroblocks, for example, at the beginning of the last macroblock of the unit. This operation mode allows the microprocessor 42 to have time fox updating the target in register 30 before processing the next picture. In some cases, the microprocessor may have not time enough to update the content of register 30. To avoid the resulting problems, the microprocessor 42 may enable a bit in a register of the control circuit 44 once it has modified the content of register 30. If this bit is not enabled before the beginning of the next unit, the processing may be interrupted until this bit is enabled. 
     With this operation mode, the average quantization coefficient Qavg and the corresponding number of bits are in fact calculated on N-1 macroblocks for each unit of N macroblocks. This very little affects the calculation of the target because two successive macroblocks, especially the last two macroblocks of a unit, are usually similar. 
     In contrast, when number N is chosen equal to 1, the circuit is such that the average quantization coefficient Qavg (in this case, the quantization coefficient Q) and the number of bits provided for a first macroblock are used to calculate the target assigned to the third macroblock. 
     As represented, registers 32 and 38 are connected to the bus PBUS, which makes it possible for the microprocessor 42, at each interruption, to modify the gain of the feedback chain in register 38 and to determine the initial accumulation value in register 32. 
     The calculation circuit of the quantization coefficient more particularly allows to easily and efficiently implement a conventional method for calculating the quantization coefficient Q with a two-step process for each picture. 
     The two-step processing of a picture consists in counting, during a first step, the number of bits of each compressed picture block achieved by using a fixed quantization coefficient. Then, a correction coefficient of the quantization coefficient may be determined for each macroblock according to various conventional methods, which need not be described here. During the second step, in which the original picture is again compressed, the quantization coefficient is determined normally by the feedback chain, but it is modified at each macroblock by the corresponding correction coefficient provided during the first step. 
     To carry out a two-step processing, the microprocessor 42 enables a corresponding bit of a register of the control circuit 44. During the first step, the content of register 30, corresponding to the quantization coefficient, is not modified (for example, signal SMB is prevented from enabling this register). The number of bits per block is provided to a memory 54 of the first-in/first-out (FIFO) type enabled by a block synchronization signal SB (provided, for example, by the VLC circuit). The numbers of bits per block are provided, for example, by accumulating in a register (not shown) the code lengths provided by the VLC circuit on bus L, this register being reset at each block by signal SB. The size of the FIFO memory 54 is at least 6N numbers. Thus, at each interruption of the microprocessor 42, the microprocessor clears the FIFO memory 54 and determines, as a function of its content, the correction to make to the corresponding N quantization coefficients during the second step. 
     During the second step, the quantization coefficient Q is normally determined by the circuit, but microprocessor 42 modifies the gain contained in register 38 at each macroblock. For this purpose, preferably, register 38 is a FIFO memory whose size is at least N gains. Thus, the microprocessor 42 fills the FIFO memory 38 with a new series of N gains at each interruption. The gains are provided to the multiplier 36 at the rate of the macroblock synchronization signal SMB. 
     FIG. 4 represents an exemplary variation of the number of bits versus the number of processed macroblocks, obtained by the calculation circuit according to the present invention. FIG. 4 is similar to FIG. 2 which represents in dotted lines the ideal variation determined by the targets and in solid lines the actual variation. 
     FIG. 4 differs from FIG. 2 by the fact that the ideal variation, drawn in dotted lines, gradually varies, at each N macroblocks, corresponding to the target modifications. 
     Having thus described one particular embodiment of the invention, various alterations, modifications, and improvements will readily occur to those skilled in the art. Such alterations, modifications, and improvements are intended to be part of this disclosure, and are intended to be within the spirit and scope of the invention. Accordingly, the foregoing description is by way of example only and is not intended to be limiting. The invention is limited only as defined in the following claims and the equivalents thereto.