METHOD AND DEVICE FOR DETERMINING BIT ALLOCATION IN A VIDEO COMPRESSION SYSTEM

Abstract: A digital video encoder and method for its operation are disclosed. This encoder comprises a frame-layer rate controller that bases a rate-distortion-optimized target bit assignment Tj on an energy estimate for frame j, an average energy estimate for a group of frames, and the desired overall bit rate. If the encoder uses motion compensation, motion bits used for frame j and an average motion bits estimate for a group of frames may also be used by the frame-layer rate controller. Preferably, the desired delay in the system affects how average estimates are computed by the encoder. The frame-layer rate controller of the video encoder above may also utilize buffer protection logic during target bit assignment. This logic adjusts an initial target bit assignment Tj based on the transmission bit rate and desired delay. A primary benefit of the frame-layer rate controller disclosed herein is its basis in a rate-distortion optimal solution to the frame-layer rate control problem. Additional benefits are provided by the explicit consideration of buffer delay during selection of a target bit assignment: rate control robustness allows one controller to be used in a range of delay situations (or even a varying delay situation); and buffer underflow/overflow can be largely eliminated, even in very low delay implementations.

Description: METHOD AND DEVICE FOR DETERMINING BIT ALLOCATION IN A VIDEO COMPRESSION SYSTEM Field of the Invention This invention pertains generally to digital video encoders, and more particularly to frame-adaptive bit rate control of such encoders. Background of the Invention Uncompressed video requires a relatively high transmission bandwidth. Almost all human-viewable video sequences, however, contain a large amount of redundant and/or visually unimportant information. Digital video allows the use of complex algorithms that remove redundant and relatively unimportant information from a digital video bitstream. With this information removed, video transmission bandwidth may be reduced to acceptable levels. A system that implements video compression algorithms is known as a digital video encoder. FIG. 1 shows a digital video encoder 36 that employs motion compensation to reduce bandwidth. An image sequence 20, consisting of M frames Fj, F2, ■■■ F Jt ... F M , provides the input to encoder 36. Motion compensator 24 is often crucial for effective bandwidth reduction. Motion compensator 24 produces a prediction frame F } for each input frame E, by comparing regions of F j to regions from previously encoded frames for similarity. To be more concrete, given a region in frame E , the encoder searches for regions in previously encoded frames that are good matches for such region and combines these good matches to form the region's prediction. Thus F represents an approximation of E, based on combinations and/or translations of regions of previously encoded frames. This approximated image can be encoded by merely sending the combination and/or translation instructions, or motion vectors MN,, for framey. Before an image Fj is encoded, approximation E. is subtracted from it in image summer 22. The remaining motion-compensated frame, i.e., the difference image F. - F j , represents the portion of the input image F j frame that cannot be easily predicted from previous frames. The motion-compensated frame is compressed to a target size of approximately bits by image encoder 26. The motion vectors are likewise compressed in motion encoder 28. When the image sequence is to be transmitted directly to a viewer through channel or interface 34 without intermediate storage (e.g., storage to a disk or other storage media), a buffer 30 is often used to allow the "bursty" encoder outputs to be smoothly transmitted as bitstream 32. At the receiving end of interface 34, bitstream 32 is received by a video decoder 38. Video decoder 38 often places bitstream 32 in a decoder buffer 47 and then parses bitstream 32 to a motion decoder 42 and an image decoder 40. Image summer 44 combines the output of decoders 40 and 42 to produce an output image sequence 46. Depending on whether image encoder 26 is lossless or lossy, output image sequence 46 may or may not be an exact representation of image sequence 20. In a digital video encoder 36, and more specifically its embedded image coder 26, it is often preferable to vary the target size T from image frame to image frame. A process that varies 77 is known as a "frame-layer rate control." A large body of work on frame-layer rate control has been reported in the patent and academic literature [1- 14, Appendix A]. Typically, all of these methods decide the target number of bits for a frame using some formula that depends on the energy in that frame, the number of bits used for encoding previous frames, and the current fullness of the encoder buffer 30 (or that of the decoder buffer 47, which is equivalent since both buffers are related). For example, the frame-layer rate control described in [1] uses a formula for the frame target that depends on the energy of the pixels in the frame and the number of bits used in a previous frame with similar energy. In [13], the energy and previous bits are combined in a different formula to select the target and in [14] such formula depends on the product of quantization values and bits used for a previous frame of the same type. In [3], the frame target depends on a formula that increases in inverse proportion to the fullness of the encoder buffer. Finally, the method in [12] assigns a fixed target number of bits per frame (equal to the channel rate divided by the frame rate) and skips frames when the encoder buffer is close to buffer overflow. Summary of the Invention Even though all frame-layer rate control techniques in the prior art measure similar parameters to determine the target number of bits for a frame [1-14], the formula or method chosen for combining these measurements is the key for an effective bit allocation. Typically, these formulas are ad hoc and are not optimized in a rate-distortion sense and, as a result, they do not minimize image distortion (i.e., maximize image quality) for the available bit rate. Additionally, the desired communication delay, which increases with the size of the encoder buffer, is not taken directly into account when deciding the frame target. At low delay, the latter produces large fluctuations of the fullness level in the encoder buffer that lead to undesired buffer overflow, underflow, and frame skipping. The present invention provides a frame-layer rate control mechanism that is based on a rate-distortion optimization. And the present invention further teaches modifications to this basic mechanism that allow a digital video encoder rate controller to respond to differences in communication delay. In addition to the benefits of the rate-distortion optimal solution provided by the basic mechanism, these modifications add robustness to a rate controller, such that one controller can be used in a range of delay situations (or even a varying delay situation). A digital video encoder is disclosed herein. This encoder comprises a frame- layer rate controller that bases a target bit assignment T j on an energy estimate for framey, an average energy estimate for a group of frames, and the desired overall bit rate. If the encoder uses motion compensation, motion bits used for framey and an average motion bits estimate for a group of frames may also be used by the frame- layer rate controller. Preferably, the desired delay in the system affects how average estimates are computed by the encoder. The rate controller of the video encoder above may also use buffer protection logic during target bit assignment. This logic corrects an initial target bit assignment T j , based on the transmission bit rate, desired delay, and current buffer fullness. In a further aspect of the invention, methods for combining the parameters and estimates described above are also disclosed. For example, an initial target bit assignment can be computed by multiplying the desired overall average bit assignment by the ratio of the frame energy estimate to the average energy estimate. Preferably, the average energy estimate is calculated by filtering frame energy estimates with a filter having a time constant dependent on the desired system delay. Brief Description of the Drawing The invention may be best understood by reading the disclosure with reference to the drawing, wherein: FIG. 1 illustrates a block diagram of a prior art digital video encoder; FIG. 2 shows a corresponding block diagram of a prior art digital video decoder; FIG. 3 illustrates the concept of a block coder; FIGS. 4-6 show suggested delay-adaptive relationships for several parameters of frame-adaptive bit rate control; FIG. 7 shows a digital video encoder embodiment of the present invention; and FIG. 8 shows the improvement in image quality in terms of PS R (peak signal-to-noise ratio) obtained using frame layer rate control according to the present invention, in comparison to the frame layer rate control in [14]. Detailed Description of the Preferred Embodiments A typical block-based image coder will be used to describe the following preferred embodiments. The present invention can, however, be used for assigning the target number of bits per frame within any image or video coder. In block-based image coding, the image to be encoded is decomposed into image blocks of the same size, typically 16x16 pixels per block, and each block is encoded with bits using some coding technique, for example a DCT-based coder. FIG. 3 illustrates the process of encoding the fth block in they ' th frame of a video sequence having M frames. In FIG. 3, B, j is the number of bits produced when encoding the z ' th image block in they ' th frame and D, j is the loss in quality or distortion introduced in that block. In many types of block coders, the distortion is controlled by the user with one or several parameters and is typically measured by computing the mean squared error (MSE) between the original and the encoded block. For example, in H.263 and MPEG encoders, the distortion at each image block is controlled by a parameter called the block's quantization step and the MSE distortion is proportional to the square of that parameter. Encoding a block with higher distortion (i.e., lower quality) produces fewer bits for the block. In other words, B tJ decreases with larger D, j . The present invention uses the following mathematical model for the relationship between B, j and D 10 . Bit-Distortion Model U.S. Patent application 09/008,137, filed January 16, 1998, by J. Ribas- Corbera and S. Lei, and incorporated herein by reference, discloses an analytical study of typical block-based coders, including formulas for the number of bits produced for a block (B, j ) and the MSE distortion in the block (Dj j ), as a function of several parameters. A combination of these formulas expresses a direct relationship between B, 0 and D, j : where A is the number of pixels in an image block (e.g., in MPEG and H.263 A = 16 2 pixels), K, is a parameter that depends on the encoder's coding efficiency and frame pixels' distribution (K, will not be needed), C } is the rate (in bits per pixel) of the motion and syntax in they ' th frame, and σ 2 is the variance or energy of the pixels in the block, i.e., where A is the number of pixels in a block, P,/l) is the value of the -th pixel in the block, and P t j is the average of the pixel values in the block, r.^{±p ,). (3) For color images, the P tJ (l) 's are the values of the luminance and chrominance components at the respective pixels. Finally, ] is a distortion weight chosen by the encoder designer (as described in U.S. Patent Application 09/008,137) and typically takes values between 1 and σ^ . Equation (1) indicates that the number of bits B, 0 produced when encoding the z ' th block (in they ' th frame) is inversely proportional to the block's distortion D 1?J . The Rate-Distortion Optimization Problem Let N be the number of image blocks in a frame (with A pixels per block). Then, the total number of image blocks in the video sequence is MN, since there are M frames. We define the overall MSE distortion D as the average of the distortions for all the blocks, i.e., using the relationship between B, j and D, j from (1). Now, let T be the total number of bits available for the M frames and T j the number of bits for the jth frame. T is the sum of the bits for the frames or, equivalently, the sum of the bits for all the blocks, i.e., N M N T = ∑T J = ∑∑B y . (5) Our objective is to find the values of the optimal target number of bits for each frame in the sequence, Ti*, T 2 *, ... , T M *, that minimize the distortion in (4) subject to the bit budget constraint in (5), i.e., M N AK a 2 σ 2 T*,T : *,...,T M * = argmin D= argmin ∑∑ ' " " T,,T : ,...,T M T,,T 2 ,...,T M J -"- i2 IB.j-AC M M M N T-∑ , T=∑T =∑∑B,. J (6) Since (6) involves the minimization of a convex function on a convex set, a unique solution to (6) may be found using the method of Lagrange multipliers : M N AK, a 2 σ 2 ( M N λ T,*,T 2 *,..,T M *= argmin ΣΣ ' " " ^ + A T-∑∑B, J, τ τ τ J=1 ,=ι 12 B -AC J " , • * • 15 ^2 ' * ' * ' M V 1,J J / (7) where λ is the Lagrange multiplier. We solve the minimization problem in (6) by setting partial derivatives of (7) to zero to obtain the following expression for the optimum target number of bits for a frame: where S } is the following weighted sum of the standard deviations in they ' th frame, S^∑α.^, (9) ι = l which can be interpreted as the energy in they ' th frame, and S is the average of all the frame energies, The formula in (8) is the basis in the invention for assigning a target number of bits to frames of a video sequence. Equation (8) makes sense intuitively. If all the frames have approximately the same energy and motion-syntax overhead, i.e., S, « S, ~ ... « S j ~ ... ~ S M , c ∞ c ∞ ~ c ~ « c then T j * in (8) is approximately T/M, and hence each frame is assigned the same number of bits (recall that T and M are the total number of bits and frames, respectively, for the video sequence). If different frames have different energy and motion activity, those with higher energy and motion (i.e., larger S_, and ) will be assigned more bits. In order to compute the value of S in (10), the energy in each frame of the M frame-sequence must be computed. This computation would introduce large delays in the encoding process, since it would require the encoder to wait for M frames before encoding the first one ( S would also be inaccurate without recursion, as frame energy for a frame depends on the target bit rate used for predictive frames). These drawbacks are often not acceptable; preferably then, the encoder estimates S with an averaging technique (described in the next section). Similarly, the sum of the C s in (8) cannot be known in advance and will also preferably be estimated. FRAME TARGET SELECTION Practical implementations of equation (8) can take a variety of forms. For example, in MPEG2-type applications (8) could be used for selecting the bit targets in groups of frames (i.e., patterns of I, P, and B frames). In the following embodiment, low-delay type applications, where all frames are predicted from the previous ones, and information for future frames is not available, are considered. The goal in this type of application is to select an adequate target number of bits for the current frame to be encoded. Based on (8), the following low-delay formula can be used for assigning a target number of bits T 0 for the current frame: The parameters B, S, V and Fin (11) correspond to T/M, S } , AN∑ m C m / M , and ANC j in (8), respectively. The formula in (11) for B > V is the same as that in (8). However, V is estimated and may be inaccurate at times — when B < V , the estimate for V is too large. In that case, a second estimate SV I S = V reduces (8) to the simple formula at the bottom of (11). The values of the parameters in (11) can be computed as follows: B - average number of bits per frame B is the number of bits accepted by the communication channel during a frame interval. Specifically: R B = ~, (12) E where R is the channel or target bit rate (in bits per second) and E is the frame rate of the video source (in frames per second). For example, 10 encoded frames per second of digital video at 64 Kilobits per second results in B= 6400 bits. S - energy of the current frame In this example a frame to be encoded is decomposed into N blocks of a fixed size, e.g., 16x16 pixels per block. S is the sum of the empirical standard deviations of the pixels in the blocks and can be obtained as described in (9). Preferably, a tJ is set N toσ^ , resulting in the simplification S j = σ,^ . ι=l S - Average frame energy S is the average energy of the frames in the video sequence as defined in (10). But, as explained earlier, in practice it is often impractical to look ahead to find the value of the energies of future frames and hence the value ofS needs to be estimated. At the first frame, S = S can be used as the estimate. In the next frames, the value of S can be updated using a weighted average, e.g., a first-order filtered version ofS: S = aS + (l - a)S , (13) where the weight parameter a is a function of the desired maximum delay d (in seconds) introduced by the encoder buffer; for example: In this example, when the delay d is below 0.5 seconds, the value of a decreases linearly with d. The formula for a is plotted in FIG. 4. Typically, the buffer delay d is directly proportional to the size (in bits) of the encoder buffer, Buff, defined herein as Buff- d R. V - Motion and syntax bit overhead V is the number of bits spent in motion and syntax for the current frame. This number can be directly measured in some encoders, or can be estimated by the number of motion and syntax bits spent in the previous frame. V - Average motion and syntax bit overhead V is the average number of bits per frame used for motion vectors and codec syntax in the video sequence, 1 M f = —∑ V m , (15) with M the total number of frames and V m the number of motion and syntax bits used for the m-th frame. However, as in the case of S , in practice it is often impractical to look ahead to find the value of future m 's — hence, the value of V needs to be estimated. At the first frame, V = V can be used as the estimate. In succeeding frames, the value of V can be updated using the same type of weighted average used for S in (13): V = aV + (l - a)V , (16) where the weight parameter a is a function of the desired buffer delay d (in seconds) in the communication system, as described above. Frame Target Selection for Very Low Delay The frame target selection system described above reduces the range of values taken by T 0 when the user desires lower communication delay. This is because the value of a becomes smaller for lower delay, and hence the values of the estimates S (13) and V (15) become closer to S and V, respectively. Actually, when the buffer delay d is close to 0, a is also close to 0, and as a result S ~ S and V ∞ V . Consequently, with very low d the frame target (11) is approximately constant and equal to the average channel bits per frame, R 7 5 = -, (17) which is the best strategy for frame-layer rate control at very low delay. This is because the number of bits per frame matches those taken by the channel and hence few or no bits are accumulated in the buffer. As a result, the buffer size and delay can be very small. BUFFER PROTECTION The objective of a buffer protection subsystem is to maintain the number of bits in the buffer close to a desired level. If the buffer fullness is too high or low, the buffer may overflow or underflow, respectively. Also, even if a target number of bits would not overflow or underflow the buffer, typical block-layer rate control schemes do not achieve the target exactly; thus a danger of overflow or underflow still exists. Two separate buffer protection levels, disclosed below, can help protect the buffer from such problems. These levels can be used together (for maximum protection) or independently. Level 1 In this level, a factor Δ , which depends on the fullness of the encoder buffer, corrects the target number of bits per frame. Specifically, Δ adds to the initial frame target To , forming the target Tj with level- 1 protection, T t = T 0 + A, (18) where W W > G Δ = otherwise E' and where: W - Current number of bits in the encoder buffer E - Frame rate of the video sequence in frames per second (e.g., 30 fps) G - Desired number of bits in the encoder buffer. The goal of (19) is to decrease the frame target if the current number of bits in the buffer, W, is above the goal G, or to decrease it otherwise. The value of G can be selected in terms of the buffer delay d and the buffer size Buffzs, follows: 05 Buff ; d > 0.5 G = d Buff ; 01 < d ≤ 05. (20) 0.1 Buff ; d ≤ O.l The formula for G indicates that for delays larger than 0.5 seconds, the rate control should aim to keep the buffer fullness at 50 percent, but at lower delays the fullness should be lower (down to 10 percent). This is because when the delay is very small, the buffer size is also very small (recall that Buff= d R), and keeping the buffer fullness to 50 percent may easily produce buffer overflow. The formula for G in (20) is illustrated in FIG. 5. Ex A parameter that depends on the frame rate E and the delay d, as follows: E ; d > 05 E - l E' = ■ (d - 0.l) + \ 0.1 < d ≤ 0.5. (21) 0.4 1 ; d ≤ O.l The value of E' is set using (21), which is illustrated in FIG. 6, throughout the video sequence. The rationale in (21) is that when the buffer delay d (or buffer size) is small, since G in (20) is also small, the buffer fullness will be low and there is danger of buffer underflow. To prevent underflow, F' can be made smaller for lower d, which in turn will make the target increase Δ in (19) larger. Level 2 The buffer protection at this level is also done before encoding the current frame. This level assumes that Tj bits will be spent for encoding that frame and checks whether that may produce buffer overflow or underflow. To do this, the encoder computes the number of bits expected to be in the buffer after encoding the current frame as follows: W , = τasa{W+ T l - B, 0) , (22) where Wis the current number of bits in the buffer, Tι is the target number of bits for the current frame (with level- 1 protection), and B is the number of bits accepted by the communication channel per frame interval. If the current frame occupies 7 / bits, the number of bits or fullness of the buffer after encoding this frame will be the current fullness Jfplus Tι and minus the B bits sent through the channel. If B is larger than W+Tι there is buffer underflow, because the channel accepts more bits than those available in the buffer. In this situation, the max operator in (22) sets the content of the buffer to zero. To prevent buffer overflow, H Buff " is selected to be the desired maximum number of bits in the encoder buffer (the value of H is typically between 0.85 and 0.95 — hence, H Buff " is 85 to 95 percent of the buffer size). If the expected number of bits in the buffer W (22) is larger than the desired maximum H Buff the buffer is almost full and the frame target is decreased to prevent buffer overflow. Conversely, if W is zero, there will be buffer underflow and the target is increased. This process can be described as follows: if(W' > H Buff) T 2 = H Buff- W + B; else if(W' = 0) T 2 = -W+ B; else T 2 = T,. (23) where T 2 is the new target number of bits per frame (with level-2 protection) and H is the buffer threshold that can be set to a fixed value, or found using either of the two formulas below: 0.95 R > 112000 0.1 85.7 a) H = -R + -— 10000 < R < 112000 (24) 0.102 102 0.85 R < 10000 b) H = l -ξ- , (25) Fa where R, F, and d are the bit rate, frame rate, and delay, respectively, and;? is a number between 0 and 1 (e.g., 0.1). The rationale behind (24) and (25) is that the buffer threshold H can be larger with larger buffer size Buff where recall that Buff- R d. H increases with larger R in (24) and larger d in (25). The equation in (24) was designed using empirical experiments. The equation in (25) was derived by isolating the value of H from the following constraint: Buff -H Buff = p R/F, (l-H) R d =p R/F, (26) in which Buff-H Buff is the safety number of bits kept above the desired maximum buffer fullness H Buff, and p R/F is a percentage of the average number of bits per frame. For example, ifp= 0.1, the equation in (25) would select the value of Hthat would keep 10 percent of the average bits per frame as the safety margin. ENCODER BLOCK DIA GRAM Frame target selection and buffer protection as described above can be implemented in conjunction with any image or video encoder. For generality, FIG. 7 shows a video encoder 60 that includes an image encoder 62, a motion encoder 56, and a buffer 68. The motion compensator 24 and summer 22 of FIG. 1 are not shown to aid clarity, but such would typically exist in encoder 60. Neither motion compensation nor buffering need be present in a specific implementation in order for the invention to be used. In operation, motion-compensated frames are routed to energy estimator 70. Energy estimator 70 implements, e.g., (9) and routes its output S j both to frame-layer rate controller 66 and average energy estimator 72. Average energy estimator implements, e.g., (13) and (14), and routes its outputS to frame-layer rate controller 66. In a basic system, frame-layer rate controller 66 ratios these values and multiplies the result by the desired average bits per frame B to produce target bit rate T j . Image encoder 62 then uses 7) to adjust its compression to the desired target. In a system employing motion compensation (and more generally, prediction), prediction bit totals can be supplied to frame-layer rate controller 66. Motion encoder 56 sends its count of motion bits for the current frame, , both to frame-layer rate controller 66 and average motion bits estimator 58. Average motion bits estimator 58, e.g., implementing (15) and (16), also sends its output C to frame-layer rate controller 66. Frame-layer rate controller uses these additional variables, e.g., to form an estimate for T j as described in equation (11). Note that T j includes C,; image encoder 62 must comprehend that these C} bits are not available to it for coding the motion- compensated image. In a system employing buffer protection, buffer 68 can supply feedback on its current fullness level Wto frame-layer rate controller 66. Controller 66 can use, e.g., Level 1 and or Level 2 buffer protection to adjust T j . Particular estimates in each estimation block of encoder 60 will generally be application-dependent, although the delay adaptive implementations described herein are preferred. EXPERIMENTAL RESULTS The frame target selection and buffer protection of the present invention were implemented in the frame layer of a rate control technique that encoded frames of real video sequences using an MPEG4 codec. This codec also used the block and data selection layers as described in co-pending U.S. Patent applications 09/008,137, incorporated above, and 09/052,882, filed March 31, 1998, by J. Ribas-Corbera and S. Lei, also incorporated herein by reference. The methods described in these two applications were used as block and data selection layers, respectively. The frame layer included the frame target selection system and Level 2 buffer protection (Level 1 buffer protection was also implemented and tested in a different codec). Formula (24) was used to select the value of H. The performance of this method (referred to as SLA rate control) was compared to VM7 rate control, which is a well-known rate control method from Sarnoff Corporation [13]. Table 1 describes the name of the video sequences, format, bit rates and frame rates used in each experiment, and assigns a name to each experiment. All video sequences contained 300 frames and were downsampled at the encoding frame rate specified in the experiments. Overall, 1400 frames were encoded. In the tests, the fullness of the encoder buffer was simulated. Rate control was tested with two different buffers: Buffer 1: a buffer of size 0.125 times the bit rate of each sequence, Buff= 0.125*R, which corresponds to a buffer delay of d = 0.125 seconds. This buffer size is often used for low delay video communications. Buffer 2: a buffer of size 0.05 times the bit rate, Buff= 0.050*R, which corresponds to a delay d = 0.050. This is a very small buffer size that is not typically used in practice, but was selected here in order to explore the performance of the SLA rate control method in such a challenging case. Tables 2 and 3 show the percentage of times that the buffers overflow and underflow, respectively, with SLA and VM7 rate control. Buffer overflow is an important problem that forces the encoder to slow down or drop image blocks — preferably, overflow should rarely occur. On the other hand, buffer underflow is less critical, but should also be avoided if possible since it wastes channel bandwidth. Table 2 shows the percentage of times that the buffer overflows (with respect to the number of frames encoded) when Buffer 1 and Buffer 2 are used with SLA and VM7 rate control. For Buffer 1, SLA rate control controls the bit rate so well that the buffer practically never overflows. In fact, overflow occurred only once in "fmnl 12_c" (and only a few bits overflowed), which would have barely affected the encoder. For the challenging Buffer 2, the SLA rate control method suffers overflow in only 4 of the 1400 encoded frames — again, only a few bits overflowed in each case. This is particularly impressive, since it is very difficult to control the bit rate fluctuations within such a small buffer. In order to appreciate the benefits of the SLA procedure, observe that overflow is much more common in both buffers with VM7 rate control. Further, with VM7 it was found that the number of bits that overflow is sometimes as large as twice the size of the buffer. Table 3 shows the percentages of buffer underflow. Observe that SLA rate control underflows the buffers occasionally, but much less often than VM7 rate control. In particular, VM7 rate control underflows the buffer above 80 percent of the time in most of the experiments for Buffer 2. Overall, SLA rate control is very robust for controlling the bit rate with small buffer sizes and overflows and underflows the buffer much less often than VM7's. Table 1. Description of the video sequences, formats, bit rates and frame rates used in the experiments. Each video sequence contained 300 frames at 30 frames per second and was downsampled at the encoding frame rate. The left-most column shows the name given to each of the experiments. Table 2. Percentage of times that buffer overflow occurs in an MPEG4 codec using SLA rate control (SLA) and VM7's (VM7) [13]. Table 3. Percentage of times that buffer underflow occurs in an MPEG4 codec using SLA rate control (SLA) and VM7's (NM7) [13]. ALTERNATIVE IMPLEMENTATIONS Several variations on the basic invention are described below. One-pass If the computation of the σ^ 's used for finding S j in (9) cannot be done in advance, a good estimate for S j such as the value of S from the previous video frame may be substituted. Low-complexity estimation of σ ' In order to further reduce computational complexity, the formula for the standard deviation in (2) may be approximated as where abs(x) is the absolute value of x. In video coding, the mean value of pixels in motion-compensated blocks is usually zero and hence this formula may be further simplified by setting P . = 0. Encoding Intra and Inter Blocks If some of the blocks to be encoded are of class intra and some are inter, as described in U.S. Patent Application 09/008,137, the performance of the frame target selection method can be improved by dividing the standard deviation of the intra blocks by a factor f . Specifically, after computing the value for theσ j 's in Step 1, set: - k if th block is intra σ. σ k otherwise The factory is: γ - where K / and Kp are the averages of the K's from (1) measured for the intra and mter blocks, respectively. The value of γ can be estimated and updated during encoding. In practice, a constant/ = 3 works quite well. Encoding a group of pictures (GOP) In MPEG and H.263+ codecs, there are different types of frames: I frames, whose pixel values are encoded by themselves (or intracoded) without using a prediction from other frames in the video sequence. P frames, whose pixels are predicted from a previous frame in the video sequence. B frames, whose pixels are bi-directionally predicted using previous and future frames in the sequence. A simple variation of equation (8) can be used to assign a target number of bits for each type of frame. For example, consider the typical case where the sequence or pattern of frame types is: I,B,...,B,P,B,...,B,P, B,...,B,P,B,...,B,P, ... (27) The set of frames "B,...,B,P" is repeated periodically after the first I frame. In MPEG, such a set (or any other that repeats periodically) is called a group of pictures or GOP. GOP type B,...,B,P Let N B be the number of B frames in the GOP above. The target number of bits for the P picture in that GOP, Tp, and the target for each of the B frames, T B , can be computed from (8) as follows: S B (T -ANMC PB ) ^ B • + ANC, (29) N ' „ B + l where the parameters in (28) and (29) are equivalent to those in (8). Specifically: Sp is the energy (9) for the P frame in the current GOP, which can either be measured or estimated as the average of the energies of P frames in previous GOP's. S B is the average of the energies (9) for the B frames in the current GOP, which again can either be measured or estimated as the average of B frame energy in previous GOP's. S is the (estimated) average of the energy in the GOP, i.e., ^S p +N , 1 + N Cp and C B are the motion and syntax rate (in bits per pixel) for the P and B frames, respectively, as defined in (1), and they can also either be measured or estimated. C PB is their average in the GOP, i.e., _C P +N B C B 1 + N 1 , B ' Finally, T, M, and N are the total number of bits (for the GOP), frames (in the GOP), and macroblocks in a frame. Equations (28) and (29) may be rearranged in an implementation. For example, after some lengthy but straightforward manipulations, equations (28) and (29) can be rewritten as follows: T-AN(C p -j3C ' B B) T X B = • (30) J3+N T P =T-N B T B , (31) where β = -A- . Alternative formulas for estimating P The value of β is the ratio Sp/ S B - In (30) and (31), β is a key parameter that has strong influence on how many bits are assigned to P and B frames. For example, if3 is close to 1, the number of bits for each frame in the GOP is similar, i.e., T p « T B , and if β is larger than 1 , then T p is also larger than T B . Since β is a key parameter, its value must be estimated carefully. Two methods for estimating β are presented here: Method 1 : Set β equal to Sp/ SB, where S P is the average of the energies in the M previously encoded P frames and S B is the average of the energies in the N previously encoded B frames. If available, the energy of the frame that is being encoded could be used as well in the respective average. Method 2: After a given frame is encoded, update the value of β as follows: j3 = b/3 prev + (l - b)F^ , (32) where here β pτev is the previous value of β , and Sp and S B are the energies of the last encoded P and B frames, respectively. F and b are filter or weight parameters. Typically F takes values between 1 and 5, and b between 0.7 and 0.9. When F is 1, experiments show that the image quality (in terms of MSE) is similar for P and B frames. However, in some cases, the average image quality can be increased by allowing some frames to have better quality than others. For example, increasing F would result in a larger β , which in turn would increase both Tp and the quality of the P frame. This would appear to reduce the quality of the B frames, since T B would be smaller. But since the P frame has higher quality and is used to predict the B's by motion compensation, the quality of the B frames could also increase. Using empirical tests, the value of F that optimizes MSE performance decreases with bit rate. This effect can be modeled with the following formula: Bpp ψ where Bpp is the rate in bits per pixel for the given video sequence, and c, d, and ψ are constant parameters whose value can be set for a given video codec. For example, in an H.263+ encoder, we empirically found that c=1.35, d--0.4, andi// =0.5, are good choices. We implemented a frame layer rate control based on (30), (31), (32), and (33), and Thomson's frame layer from [14] in a video encoder compliant to the H.263+ standard. The method in [14] is known as TM5 rate control and is a very popular technique used as a benchmark for comparisons in the rate control literature. For a fair comparison, the rate control at the block layer was the same for both cases. We turned on the advanced prediction, extended motion range, and true B frame options (annexes D, F, and O) in the H.263+ encoder, and selected GOPs with either one (N B =1) or two (N B =2) B frames. The tests are described in Table 4 and the results are in Table 5. FIG. 8 plots the peak signal- to-noise ratio or PSNR per video frame for one of the tests. The PSNR is the typical measure of image quality used in the image and video compression literature and is given in dB's, and a PSNR improvement of 1 dB corresponds to bit rate savings of about 20 percent. Observe that our new frame layer improves the average PSNR up to 1.38 dB with respect to TM5's. Our superior performance is because our frame target formulas are based on a rate-distortion optimization. Table 4. Description of the experiments: names assigned to each experiment, original video sequences, GOP pattern of frames, and target bit rates. The spatial resolution of the video frames was QCIF and the frame rate was of 15 frames per second. The bit rate achieved was very close to the target in all cases. A total of five seconds were encoded for each video sequence. Table 5. Results of the average PSNR (PSNR) obtained when using our new frame-layer rate control and TM5's [14] for the P (PSNR P) and B (PSNR B) frames. The last column (GAIN) shows the improvement in average PSNR with our new method. General GOP type Observe that equations similar to (28) and (29) can be derived from (8) for any GOP frame pattern. For example, consider a GOP where the number of I, P, and B frames is respectively Ni, Np, and Nβ. Then the target number of bits for each frame type is: S^(T-ANMC ffB ) + P S N,+N P +N B P ' S^(T-ANMC gB ) + S N,+N P +N B B which, once again, after some manipulations, can be re-written as follows: (T-ANMC IPB ) L P + ANC t (38) N, N,A P +N P + A. (T-ANMC IPB ) T -- N ÷ N tfl , + N , +ANC - (39> The parameters in (37), (38), and (39) have the same meaning as in previous formulas. For example, { , Cp, C B } are the respective C 's for I, P, and B frames, and: The values of the β 's can be estimated with either Method 1 or 2 above. For example, S P βp B = PB 3p B,prev + (1 - b PB )F PB — , (42) 'B where { bip, F IP } and {bpβ, F PB } are the respective estimator parameters, as in (32). After reading this disclosure, one of ordinary skill in the art will recognize that many advantageous modifications to the disclosed embodiments are enabled by the concepts taught herein. In particular, estimation of the parameters used in the calculation of a frame target bit allocation is typically a design choice, and practically will be based on encoder structure and block timing. Such obvious modifications are intended to fall within the scope of the invention as claimed. Appendix A [1] C. Conzales and E. Viscito, IBM, "Motion Video Compression System with Adaptive Bit Allocation and Quantization," U.S. Patent No. 5,231,484 issued July 27, 1993. [2] C. Auyeung, S.N. Ievine and JJ. Kosmach, Motorola, Inc., "Method and Device for Determining Bit Allocation in a Video Compression System," U.S. Patent No. 5,506,686 issued April 9, 1996. [3] Hang, ATT, "Adaptive Buffer/Quantizer Control for Transform Video Coders," U.S. Patent No. 5,038,209 issued August 6, 1991. [4] J.Y. Nam, S.G. Park, S.Y. Lee and CT. Ahn, ETRI, Korea, "Video Bit Rate Control Method," U.S. Patent No. 5,617,150 issued April 1, 1997. [5] S.H. Chang, Korea Telecommun. Authority, "Bit Allocation Method for Controlling Transmission Rate of Video Encoder," U.S. Patent No. 5,532,746 issued July 2, 1996. [6] B.G. Haskell and A.R. Reibman, AT&T Bell Laboratories, "Buffer control for variable bit-rate channel," US patent 5,159,447, Oct. 27, 92. [7] C.-T. Cheng and A.H. Wong, Bell Commun. Research, "Pseudo-constant bit rate video coding with quantization parameter adjustment," US patent 5,241,383, Aug. 31,93. [8] K. Dachiku, H. Ueno, and T. Watanabe, Kabushiki Kaisha Toshiba, "Moving picture image encoder with continuously changing quantization step size," US patent 5,274,443, Dec. 28, 93. [9] J. E. Bruder, PictureTel Corporation, "Quantizer control method and apparatus, US patent 5,283,646, Feb. 1, 94. [10] D.J. Rei inger and A. Guha, RCA Thomson Licensing Corporation, "Apparatus for controlling quantizing in a video signal compressor," US patent 5,426,463, Jun. 20, 95. [11] K Park, Samsung Electronics Co., Ltd., "Image compression system by setting fixed bit rates," US patent 5,323,187, June 21, 94. [12] Video Test Codec Model, TMN7, ITU-T Recommendation H.263+, Nice, Feb. 97. [13] Video Verification Model, VM7, ISO-MPEG4, Bristol, Mar. 97. [14] T. Savatier, Thomson Consumer Electronics, "Apparatus for video data quantization control," US patent 5,144,424, Sept. 1, 92.

Claims: What is Claimed is: 1. A method for allocating, among the image frames in an image frame sequence, the bits available for representing the image frame sequence, said method comprising the steps of: defining a desired average frame target bit allocation B for a group of image frames; estimating the average frame energy S for said group; estimating the frame energy S, of an individual image frame / selected from said group; setting an individual frame target bit allocation T, for said individual image frame asT = ArB . S 2. The method of claim 1, wherein at least some of the image frames i utilize a portion of their individual target bit allocation T, in transmitting overhead bits V„ wherein the individual frame target bit allocation T, for said individual image frame compensates for overhead bits V t by computing the individual frame target S bit allocation asT t = - r (B -V) + V l , where V is obtained by estimating the average overhead bits per image frame for said group. 3. The method of claim 2, wherein said step of estimating the frame energy S, of an individual image i comprises measuring the frame energy of frame i-l. 4. The method of claim 2, wherein said step of estimating the frame energy S ; of an individual image / comprises computing a weighted sum of the absolute value of pixels in image i. 5. The method of claim 2, wherein said step of estimating the average frame energy S comprises initializing S = S, for a first frame i in said group, and updating S on subsequent frames in said group using a first order filter of the form S = aS + (1 - a)S t , where 0.0 < a < 1.0. 6. The method of claim 5, further comprising the steps of encoding each of said frames i and storing them in an encoder buffer for transmission, wherein the value of a is a function of a maximum transmission delay d introduced by the encoder buffer. 7. The method of claim 6, wherein said function is the relationship shown in FIG. 4. 8. The method of claim 2, wherein said step of estimating the average overhead bits per image frame V comprises initializing V = V. for a first frame i in said group, and updating^ on subsequent frames in said group using a first order filter of the form V = aV + (\ -a)V i , where 0.0 < α < 1.0. 9. The method of claim 8, further comprising the steps of encoding each of said frames i and storing them in an encoder buffer for transmission, wherein the value of a is a function of a maximum transmission delay d introduced by the encoder buffer. 10. The method of claim 9, wherein said function is the relationship shown in FIG. 4. 11. The method of claim 2, further comprising the steps of: obtaining the current number of bits in the encoder buffer; comparing the current number of bits in the encoder buffer to a desired number of bits in the encoder buffer; computing an individual target bit allocation correction based on the comparing step; and adding the individual target bit allocation correction to the individual frame target bit allocation 7)-. 12. The method of claim 11, wherein said desired number of bits in the encoder buffer is a function of buffer delay. 13. The method of claim 9, wherein said function is the relationship shown in FIG. 5. 14. A method for allocating, among the image frames in an image frame sequence, the bits available for representing the image frame sequence, wherein said image frame sequence comprises at least two image frame types X and Y, said method comprising the steps of: defining a desired average frame target bit allocation B for a group of image frames; estimating the average frame energy S for said group; estimating the average frame energy Sx for image frames of type X from said group; estimating the average frame energy Sy for image frames of type Y from said group; setting an individual frame target bit allocation T, for an individual image S S frame / as T = -A-B when frame / is of type X, and as T = X-Bwhen frame / is of S S type 7. 15. The method of claim 14, wherein at least some of the image frames i utilize a portion of their individual target bit allocation T, in transmitting overhead bits V„ wherein the individual frame target bit allocation T, for said individual image frame compensates for overhead bits V,. 16. The method of claim 14, wherein the target bit allocation T, is rearranged to contain a ratio β of average frame energies Sχ and Sy, β = —%- , such that S NB NB T = — — when frame i is of type X. and T = when frame i is of N + ^J N x β + N γ X β type Y, where N is the total number of image frames in the image frame sequence, N x is the total number of frames of type X in the image sequence, and N is the total number of frame of type Tin the image sequence. ES 17. The method of claim 16, wherein β is a filtered version of — —that is updated for S y each encoded frame of type X or type Y, and wherein E is a weighting factor based on the relative importance of frames of type X and type Y. 18. The method of claim 17, wherein frames of type X are forward-predicted from previous frames of type X, frames of type Y are bi-directionally predicted from previous and subsequent frames of type X, and 1 < E < 5. 19. The method of claim 17, wherein F varies as a function of the inverse of bit rate expressed in bits per pixel. 20. The method of claim 16, wherein at least some of the image frames / utilize a portion of their individual target bit allocation T, in transmitting overhead bits V t , wherein the individual frame target bit allocation T, for said individual image frame compensates for overhead bits V,. 21. A digital video encoder comprising: a frame-layer rate controller; an image encoder that encodes images based on a target bit assignment supplied by said frame-layer rate controller; a frame energy estimator that operates on said images to produce frame energy estimates; and an average frame energy estimator that operates on said frame energy estimates to produce average frame energy estimates; wherein said frame-layer rate controller adjusts said target bit assignment based on a ratio of one of said frame energy estimates to one of said average frame energy estimates. 22. The digital video encoder of claim 21, further comprising a buffer for buffering images encoded by said image encoder for a known average buffer delay, wherein said average frame energy estimator comprises a frame energy estimate filter, said filter having a time constant that is a function of said buffer delay. 23. The digital video encoder of claim 22, wherein said buffer reports its fullness to said frame-layer rate controller, and wherein said frame-layer rate controller adjusts said target bit assignment based on said fullness to avoid buffer underflow and overflow. 24. The digital video encoder of claim 21, further comprising: a predictor that computes a prediction vector for a current image based on previously encoded images; a prediction vector encoder that codes said prediction vector and produces an encoded vector bit size; and an average prediction vector bit size estimator that operates on said encoded vector bit size to produce an average encoded vector bit size, wherein said frame-layer rate controller adjusts said target bit assignment for average encoded vector bit size and encoded vector bit size. 25. A digital video encoder comprising: a buffer; a motion encoder that supplies an encoded motion vector to said buffer; an image encoder that supplies encoded motion-compensated images to said buffer; a motion-compensated image energy estimator; an average motion-compensated energy estimator; an average motion vector bit size estimator; and a frame-layer rate controller that selects a target bit allocation for said image encoder based on parameters obtained from said buffer, said motion encoder, said motion-compensated image energy estimator, said average motion-compensated energy estimator, and said average motion vector bit size estimator. 26. The digital video encoder of claim 25, further comprising a motion compensator, wherein said motion compensator supplies at least two different types of motion- compensated images to said image encoder, and wherein said average motion- compensated energy estimator and said average motion vector bit size estimator produce a separate estimate for each different type of motion-compensated image.

Inventors: LEI SHAW-MIN, RIBAS-CORBERA JORDI, LEI, SHAW-MIN, RIBAS-CORBERA, JORDI
Applicants: SHARP LAB OF AMERICA INC, SHARP LABORATORIES OF AMERICA, INC.
Application year: 1998
Main classification: G06T9
IPC codes: G06T9, H04N7