# Patent

## Title
Method for video coding a sequence of digitized images

## Abstract

The invention relates to a method for video coding a sequence of digitized images comprising predicting the contents of each image taking into account a rate distortion optimization criterion being dependent on a Lagrange multiplier; transforming the prediction error resulting from predicting step into a plurality of transformed residual coefficients in each image; quantizing the transformed residual coefficients in each image; wherein the Lagrange multiplier is determined for each image based on a probability distribution of the transformed residual coefficients of the respective image, the probability distribution having its maximum probability at its mean zero and being formed such that the probabilities decrease to zero from the mean to large absolute values of the transformed residual coefficients, whereby the variance of the probability distribution is calculated from the plurality of transformed residual coefficients in the respective image.

## Background
The invention relates to a method for video coding a sequence of digitized images as well as to a corresponding apparatus for video coding and a computer program product.
In general, the invention refers to video coding wherein the contents of each image of a video sequence to be encoded are predicted by using a rate distortion optimization. Rate distortion optimization is a well-known technique in video coding which minimizes the distortion D of a video image for a given rate Rc by a set of coding parameters. Particularly, this optimization is described by the following equation:

min{D}

subject to R≦Rc  (1)

To solve the optimization task according to equation (1), this equation is converted by the so-called Lagrange multiplier method into the following equation:

min{J}

where J=D+λ·R  (2)

In this equation, J is the Lagrangian cost function and λ is the Lagrange multiplier. A key problem in rate distortion optimization is how to determine the parameter λ.
In the reference T. Wiegand and B. Girod, “Lagrange multiplier selection in hybrid video coder control”, in IEEE Int. Conf. on Image Processing, 2001, pp. 542-545, vol. 3, a method for selecting a Lagrange multiplier in a video coder control is proposed. Assuming that the distortion D is differentiable everywhere, the minimum of the La-grangian cost J is given by setting its derivative to zero, i.e.:




  
    
      
        
          
            d
            J
          
          
            d
            R
          
        
        =
        
          
            
              
                d
                D
              
              
                d
                R
              
            
            +
            λ
          
          =
          0
        
      
    
    
      
        (
        3
        )
      
    
  




This equation (3) leads to the following equation;




  
    
      
        λ
        =
        
          -
          
            
              d
              D
            
            
              d
              R
            
          
        
      
    
    
      
        (
        4
        )
      
    
  




Equation (4) can be solved for given models of R and D.
In the reference H. Gish and J. Pierce, “Asymptotically efficient quantizing”, IEEE Trans. Inf. Theory, vol. 14, no. 5, pp. 676-683, 1968., a high-rate approximation curve is proposed for the dependence of rate R on the distortion D. This approximation reads as follows:




  
    
      
        
          R
          ⁡
          
            (
            D
            )
          
        
        =
        
          a
          ⁢
          
            
          
          ⁢
          
            
              log
              2
            
            ⁡
            
              (
              
                b
                D
              
              )
            
          
        
      
    
    
      
        (
        5
        )
      
    
  




In this equation, a and b are constants. Preserving the high rate assumption, the following equation for the distortion D is derived as:




  
    
      
        D
        =
        
          
            
              
                (
                
                  2
                  ⁢
                  Q
                
                )
              
              2
            
            12
          
          =
          
            
              Q
              2
            
            3
          
        
      
    
    
      
        (
        6
        )
      
    
  




In this equation, Q corresponds to the so-called quantizer value which is a value used in the well-known quantization step in video coding. According to the quantization step, residual coefficients produced in a transformation step are mapped to discrete quantizer reproduction levels, and Q represents half of the distance of those levels.
By inserting equations (5) and (6) into equation (4), the parameter λ can be determined by:




  
    
      
        λ
        =
        
          
            
              d
              D
            
            
              d
              R
            
          
          =
          
            c
            ·
            
              Q
              2
            
          
        
      
    
    
      
        (
        7
        )
      
    
  




where c is a constant which is experimentally suggested to be 0.85. The method for determining λ according to equation (7) is herein referenced as “HR-λ selection”, as it is an approximation applicable for high rates (HR). This method is included in the reference software for the state of the art video coding standard H.264/AVC.

The HR-λ method has the disadvantage that a high rate is assumed for determining λ. However, this assumption is not realistic all the time. Furthermore, the parameter λ is only related to the quantizer value Q and no property of the input video signal is considered. Thus, λ cannot be adapted dynamically to different contents of different videos.
In the reference L. Chen and I. Garbacea, “Adaptive lambda estimation in lagrangian rate-distortion optimization for video coding”, in Visual Comm. And Image Processing, Jan. 17-19, 2006, a Lagrange multiplier selection being dependent on the variance of transformed residual coefficients is proposed. The Lagrange multiplier λ according to this method is chosen as follows:

λ=β·(ln(σ2/D)+δ)·D/R  (8)

In this equation, β and δ are both coding constants and σ refers to the variance of transformed residual coefficients. Due to the dependence of λ on this variance, equation (8) is dependent on the contents in the digitized video image and, thus, the above selection of λ is able to fit videos dynamically. However, the above selection of λ decouples quantization information Q from λ, and λ is calculated by R and D directly, which may result in error propagation, especially in the case of imprecise estimations of R and D.
SUMMARY
It is an object of the invention to provide a method for video coding incorporating rate distortion optimization providing better coding efficiency and enabling a dynamic adaptation of the rate distortion optimization criterion.
This object is solved by the various embodiments of the invention described in more detail below.
The method according to various embodiments of the invention comprises a predicting step a) in which the contents of each image of the digitized video sequence is predicted taking into account a rate distortion optimization criterion being dependent on a Lagrange multiplier. In a transforming step b), the predicting error resulting from the predicting step a) is transformed into a plurality of transformed residual coefficients in each image. Well-known transformation techniques, e.g., the Discrete Cosine Transformation (DCT) or a separable integer transformation (used in H.264) can be applied in step b). In a quantization step c), the transformed residual coefficients in each image of the video sequence are quantized. Well-known quantization techniques may be used in step c), e.g., a linear quantization wherein the intervals of residual coefficient values mapped to one quantizer reproduction level are constant or a logarithmic quantization technique, wherein the intervals of the residual coefficient values mapped to one quantizer reproduction level become bigger with growing values of the coefficients.
A new selection of the Lagrange multiplier is provided. Particularly, the Lagrange multiplier is determined adaptively for each image based on a probability distribution of the transformed residual coefficients of the respective image, the probability distribution having its maximum probability at its mean zero and being formed such that the probabilities decrease to zero from the mean to large absolute values of the transformed residual coefficient, whereby the variance of the probability distribution is calculated from the plurality of transformed residual coefficients in the respective image.
Due to the dependence of the Lagrange multiplier on the variance of the transformed residual coefficients, the Lagrange multiplier is adapted dynamically in dependence on the contents of each image. Furthermore, the probability distribution having the above defined form has shown to be very efficient with respect to achieving a low distortion while keeping the rate of transmission low. Furthermore, the above defined probability distribution in not based on an assumption with respect to the rate and, thus, it can also be applied for low rates of the encoded video stream.
In a preferred embodiment of invention, the probability distribution comprises a generalized Gaussian distribution which is a well-known mathematical distribution. Particularly, the probability distribution may comprise a Gaussian distribution. Furthermore, in a preferred embodiment of the invention, the probability distribution comprises a Laplace distribution.
In an embodiment of the invention, where the probability distribution is assumed to be a Laplace distribution, the Lagrange multiplier λ is calculated by solving the following equation:




  λ
  =
  
    -
    
      
        
          ∂
          D
        
        /
        
          ∂
          Q
        
      
      
        
          ∂
          R
        
        /
        
          ∂
          Q
        
      
    
  




wherein D is an estimation for the distortion and defined as





  D
  =
  
    
      
        
          e
          
            
              λ
              L
            
            ⁢
            F
          
        
        ⁡
        
          (
          
            
              2
              ⁢
              
                λ
                L
              
              ⁢
              Q
            
            +
            
              
                λ
                L
                2
              
              ⁢
              
                Q
                2
              
            
            -
            
              2
              ⁢
              
                λ
                L
                2
              
              ⁢
              QF
            
          
          )
        
      
      +
      2
      -
      
        2
        ⁢
        
          e
          
            
              λ
              L
            
            ⁢
            Q
          
        
      
    
    
      
        λ
        L
        2
      
      ⁡
      
        (
        
          1
          -
          
            e
            
              
                λ
                L
              
              ⁢
              Q
            
          
        
        )
      
    
  




wherein R is an approximation for the rate and defined as




  
    R
    =
    
      
        S
        
          ln
          ⁢
          
            
          
          ⁢
          2
        
      
      ⁡
      
        [
        
          
            
              
                
                  
                    -
                    
                      (
                      
                        1
                        -
                        
                          e
                          
                            -
                            
                              
                                λ
                                L
                              
                              ⁡
                              
                                (
                                
                                  Q
                                  -
                                  F
                                
                                )
                              
                            
                          
                        
                      
                      )
                    
                  
                  ⁢
                  
                    ln
                    ⁡
                    
                      (
                      
                        1
                        -
                        
                          e
                          
                            -
                            
                              
                                λ
                                L
                              
                              ⁡
                              
                                (
                                
                                  Q
                                  -
                                  F
                                
                                )
                              
                            
                          
                        
                      
                      )
                    
                  
                
                +
              
            
          
          
            
              
                
                  e
                  
                    -
                    
                      
                        λ
                        L
                      
                      ⁡
                      
                        (
                        
                          Q
                          -
                          F
                        
                        )
                      
                    
                  
                
                ⁡
                
                  (
                  
                    
                      ln
                      ⁢
                      
                        
                      
                      ⁢
                      2
                    
                    -
                    
                      ln
                      ⁡
                      
                        (
                        
                          1
                          -
                          
                            e
                            
                              
                                -
                                
                                  λ
                                  L
                                
                              
                              ⁢
                              Q
                            
                          
                        
                        )
                      
                    
                    -
                    
                      
                        λ
                        L
                      
                      ⁢
                      F
                    
                    +
                    
                      
                        
                          λ
                          L
                        
                        ⁢
                        Q
                      
                      
                        1
                        -
                        
                          e
                          
                            
                              -
                              
                                λ
                                L
                              
                            
                            ⁢
                            Q
                          
                        
                      
                    
                  
                  )
                
              
            
          
        
        ]
      
    
  




  
    
      
        where
        ⁢
        
          
        
        ⁢
        
          λ
          L
        
      
      =
      
        
          2
        
        σ
      
    
    ,
  



wherein:

    
    
        σ is the variance calculated from the plurality of transformed residual coefficients in the respective image;
        Q is a quantization interval representing half of the distance between quantizer reproduction levels and F is the quantization offset used in the quantizing step c); and
        S is a constant factor, preferably assuming a value greater than 0 and smaller than 1, most preferably assuming 0.181.
    
    


In the detailed description below, the evaluation of the above mentioned equations based on the assumption of a Laplacian distribution for the transformed residual coefficients is described.
Instead of using a probability distribution based on one fixed generalized Gaussian distribution, the invention may also be implemented by using a probability distribution based on a mixture of different generalized Gaussian distribution.
In another embodiment of the invention, a lookup table may be used for determining the Lagrange multiplier for each image, the lookup table giving, for each variance, the corresponding value of the Lagrange multiplier. The use of such a lookup table results in a fast performance of the coding method.
In a preferred embodiment of the invention, the quantized and transformed residual coefficients are entropy encoded after the quantization step c). Entropy encoding is a well-known lossless coding technique which is commonly used in video coding to further enhance the compression of the video.
In predicting step a), different prediction techniques may be used. In one embodiment, a temporal prediction comprising motion estimation and motion compensation is applied, wherein the contents of one image are predicted from the contents of one or more temporally prior or later images. Furthermore, a spatial intra-coding prediction may be used in predicting step a), wherein the blocks in an image are predicted from other blocks in this image.
Besides the above defined method, various embodiments of the invention also relate to an apparatus for video coding a sequence of digitized images, comprising: a first mechanism for predicting the contents of each image taking into account a rate distortion optimization criterion being dependent on a Lagrange multiplier; a second mechanism for transforming the prediction error resulting from predicting step a) into a plurality of transformed residual coefficients in each image; and a third mechanism for quantizing the transformed residual coefficients in each image; wherein the apparatus is designed such that the Lagrange multiplier is determined adaptively for each image based on a probability distribution of the transformed residual coefficients of the respective image, the probability distribution having its maximum probability at its mean zero and being formed such that the probabilities decrease to zero from the mean to large absolute values of the transformed residual coefficients, whereby the variance of the probability distribution is calculated from the plurality of transformed coefficients in the respective image.
According to the foregoing, such an apparatus includes a corresponding mechanism for performing any of the above defined embodiments of the method according to the invention. Particularly, additionally to the first, second and third mechanisms, the apparatus may include a fourth mechanism for entropy coding the residual coefficients transformed by the second mechanism quantized by the third mechanism.
According to an embodiment, an apparatus is provided having the following structure: an system input for inputting an input image; a motion estimator comprising a first input connected to the system input at which the input image is provided, a second input, a third input, a first output, and a second output; a first adder comprising a first input connected to the system input, a second input, and an output; a transformer and quantizer comprising an input connected to the output of the first adder, and an output; an entropy coding unit comprising a first input connected to the output of the transformer and quantizer, and a second input connected to the second output of the motion estimator, and an output; a second adder having a first input, a second input, and an output; a motion compensator comprising a first input and a second input, and a first output that is connected to the second input of the motion estimator, and a second output that is connected to the second input of the first adder as well as a first input of the second adder; a spatial intra-predictor comprising an output connected to the second input of the first adder; a deblocker comprising an input connected to the output of the second adder, and an output connected to the third input of the motion estimator; and an inverse quantizer and inverse transformer comprising an input connected to the output of the transformer and quantizer, and an output connected to the second input of the second adder.
Furthermore, the invention comprises a computer program product comprising a computer readable storage medium having encoded thereon computer-executable instructions for executing by a processor for performing a method according the invention.



DESCRIPTION OF THE DRAWINGS
Preferred embodiments of the invention will be described in the following with reference to the accompanying drawings.
FIG. 1 is a block schematic diagram of an encoding architecture in according to an embodiment of the invention;
FIG. 2 is a table comparing the results of a method according to one embodiment of the invention with results achieved by prior art methods for different video sequences; and
FIGS. 3A, B are graphs of the results shown in the table of FIG. 2.



DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
FIG. 1 shows an example of a video encoder based on the video coding standard H.264/AVC. In the encoder of FIG. 1, a sequence of digitized images T is compressed by encoding the so-called prediction error resulting from the prediction performed in a predicting step.
The prediction error is generated by supplying the input image T to an adder A subtracting from the input image I a predicted image P determined in a corresponding prediction step. The prediction error is supplied to the transformer 1 performing a well-known transformation T on the digitized image resulting in transformed residual coefficients.
After a scaling step (not shown), the transformed residual coefficients of each image I are subjected to a quantization Q performed in a corresponding quantizer 2. The resulting transformed and quantized residual coefficients are supplied to an entropy encoder 9 performing entropy coding EC. Furthermore, those coefficients are scaled and supplied to an inverse quantizer 3 performing an inverse quantization IQ on the coefficients.
After this inverse quantization, the coefficients are subjected to an inverse transformation IT by inverse transformer 4. The resulting decoded error is added to the predicted image P in an adder A′. The image resulting from this is subjected to a deblocking step DB in a corresponding deblocker 5.
As a result, a decoded image DI is obtained, which is supplied to a motion compensator 6 performing a motion compensation. The motion compensation is performed by the use of so-called motion vectors MV which are calculated in a motion estimation step ME in a motion estimator 7. The motion vectors describe the motion of picture blocks from one image to another. After performing the motion compensation MC, the predicted image P is obtained, which is supplied to the adder A in order to determine the prediction error.
The prediction based on motion compensation MC and motion estimation ME is a temporal prediction. When rate distortion optimization is used for this temporal prediction, different prediction methods for a respective image are applied. The prediction methods, e.g., differ in the feature which images and how many images are used for determining the predicted image P. For each encoded image obtained by the different predicting methods, the cost function J according to equation (2) on the basis of the Lagrange multiplier is calculated, the Lagrange multiplier being determined by the method associated with the invention. The prediction method resulting in the lowest cost J for the respective image is used as the prediction method for this image.
Instead of the temporal prediction described before, the encoder in FIG. 1 may use a spatial intra-prediction IP being performed by intra predictor 8. In this intra-prediction, the so-called macroblocks in each image are predicted from neighboring previously encoded macroblocks. To exploit spatial correlation among pixels in the image to be encoded, the coding standard H.264 uses three basic types of prediction, namely full-macroblock prediction for 16×16 luma or the corresponding chroma block size, 8×8 luma prediction (called FRExt-only) or 4×4 luma prediction.
For the full-macroblock prediction, the pixel values of an entire macro block of luma or chroma data are predicted from the edge pixels of neighboring previously decoded macroblocks. Full-macroblock predictions can be performed in one of four different ways that can be selected by the encoder for the prediction of each particular macroblock. Those different ways refer to vertical, horizontal, DC and planar prediction. For the vertical and horizontal prediction types, the pixel values of a macroblock are predicted from the pixels just above or to the left of the macroblock, respectively. In DC prediction, the luma values of the neighboring pixels are averaged and the resulting average value is used as a predictor. In planar prediction, a three-parameter curve fitting equation is used to form a prediction block having a brightness slope in the horizontal direction and a brightness slope in the vertical direction that approximately matches the neighboring pixels.
In the above-mentioned 4×4 luma prediction, the values of each 4×4 block of luma samples are predicted from the neighboring pixels above or left of a 4×4 block, and 9 different directional ways of performing the prediction can be selected by the encoder. The above mentioned 8×8 luma prediction basically uses the same concepts as the 4×4 prediction, but with a prediction block size that is 8×8 rather than 4×4 and with low-pass filtering of the predictor to improve prediction performance.
When rate distortion optimization is applied to intra-prediction, different intra-prediction modes are applied to the blocks in each image, and the prediction mode leading to the lowest cost according to equation (2) is used for the respective blocks in the image, wherein the Lagrange multiplier λ is selected based on a method associated with the invention.
In the following, an embodiment of the invention is described, where the Lagrange multiplier for rate distortion optimization is determined based on a Laplace distribution. Furthermore, results based on this embodiment will be presented when applying the inventive method in the reference software of H.264/AVC for intra prediction.
The Laplacian distribution applied for the intra predicted images has a zero mean and is defined as follows:




  
    
      
        
          
            f
            L
          
          ⁡
          
            (
            x
            )
          
        
        =
        
          
            1
            2
          
          ⁢
          
            λ
            L
          
          ⁢
          
            e
            
              
                -
                
                  λ
                  L
                
              
              ⁢
              
                
                x
                
              
            
          
        
      
    
    
      
        (
        9
        )
      
    
  
  
    
      
        
          λ
          L
        
        =
        
          
            2
          
          σ
        
      
    
    
      
        (
        10
        )
      
    
  




In equation (9), x represents the transformed residual coefficients after applying the transformation step T in FIG. 1 and σ is the variance of the transformed residual coefficients in an image I which indicates the property of the input video. Because of the one-to-one mapping between σ and λL, the latter will be used instead in the following expressions for simplicity. In the H.264/AVC standard, a uniform reconstruction quantizer is used. Therefore, the entropy of the transformed residual coefficients after quantization step Q in FIG. 1 can be modeled as follows:




  
    
      
        H
        =
        
          
            
              
                -
                
                  P
                  0
                
              
              ·
              
                log
                2
              
            
            ⁢
            
              P
              0
            
          
          -
          
            2
            ⁢
            
              
                ∑
                
                  n
                  =
                  1
                
                ∞
              
              ⁢
              
                
                  
                    P
                    n
                  
                  ·
                  
                    log
                    2
                  
                
                ⁢
                
                  P
                  n
                
              
            
          
        
      
    
    
      
        (
        11
        )
      
    
  
  
    
      
        
          P
          0
        
        =
        
          2
          ⁢
          
            
              ∫
              0
              
                Q
                -
                F
              
            
            ⁢
            
              
                
                  f
                  L
                
                ⁡
                
                  (
                  x
                  )
                
              
              ⁢
              
                
              
              ⁢
              
                d
                x
              
            
          
        
      
    
    
      
        (
        12
        )
      
    
  
  
    
      
        
          P
          n
        
        =
        
          2
          ⁢
          
            
              ∫
              
                nQ
                -
                F
              
              
                
                  
                    (
                    
                      n
                      +
                      1
                    
                    )
                  
                  ⁢
                  Q
                
                -
                F
              
            
            ⁢
            
              
                
                  f
                  L
                
                ⁡
                
                  (
                  x
                  )
                
              
              ⁢
              
                
              
              ⁢
              
                d
                x
              
            
          
        
      
    
    
      
        (
        13
        )
      
    
  




Q indicates the quantization interval and F is the rounding offset used for quantization. In the H.264/AVC standard, Q is determined by the well-known quantization parameter qp and reads as follows:




  
    
      
        Q
        =
        
          2
          
            
              (
              
                qp
                -
                12
              
              )
            
            6
          
        
      
    
    
      
        (
        14
        )
      
    
  




Since the Laplacian distribution assumed for the residual coefficients is usually not an ideal Laplacian distribution, the rate R is compensated by a factor S and reads as follows:

R=S·H  (15)

Similarly, the distortion D can be written as follows:

D=2∫0Q−Fx2.

Putting equation (9) into equations (15) and (16), results in a rate R and a distortion D defined as follows:




  
    
      
        R
        =
        
          
            S
            
              ln
              ⁢
              
                
              
              ⁢
              2
            
          
          ⁡
          
            [
            
              
                
                  
                    
                      
                        -
                        
                          (
                          
                            1
                            -
                            
                              e
                              
                                -
                                
                                  
                                    λ
                                    L
                                  
                                  ⁡
                                  
                                    (
                                    
                                      Q
                                      -
                                      F
                                    
                                    )
                                  
                                
                              
                            
                          
                          )
                        
                      
                      ⁢
                      
                        ln
                        ⁡
                        
                          (
                          
                            1
                            -
                            
                              e
                              
                                -
                                
                                  
                                    λ
                                    L
                                  
                                  ⁡
                                  
                                    (
                                    
                                      Q
                                      -
                                      F
                                    
                                    )
                                  
                                
                              
                            
                          
                          )
                        
                      
                    
                    +
                  
                
              
              
                
                  
                    
                      e
                      
                        -
                        
                          
                            λ
                            L
                          
                          ⁡
                          
                            (
                            
                              Q
                              -
                              F
                            
                            )
                          
                        
                      
                    
                    ⁡
                    
                      (
                      
                        
                          ln
                          ⁢
                          
                            
                          
                          ⁢
                          2
                        
                        -
                        
                          ln
                          ⁡
                          
                            (
                            
                              1
                              -
                              
                                e
                                
                                  
                                    -
                                    
                                      λ
                                      L
                                    
                                  
                                  ⁢
                                  Q
                                
                              
                            
                            )
                          
                        
                        -
                        
                          
                            λ
                            L
                          
                          ⁢
                          F
                        
                        +
                        
                          
                            
                              λ
                              L
                            
                            ⁢
                            Q
                          
                          
                            1
                            -
                            
                              e
                              
                                
                                  -
                                  
                                    λ
                                    L
                                  
                                
                                ⁢
                                Q
                              
                            
                          
                        
                      
                      )
                    
                  
                
              
            
            ]
          
        
      
    
    
      
        (
        17
        )
      
    
  
  
    
      
        D
        =
        
          
            
              
                e
                
                  
                    λ
                    L
                  
                  ⁢
                  F
                
              
              ⁡
              
                (
                
                  
                    2
                    ⁢
                    
                      λ
                      L
                    
                    ⁢
                    Q
                  
                  +
                  
                    
                      λ
                      L
                      2
                    
                    ⁢
                    
                      Q
                      2
                    
                  
                  -
                  
                    2
                    ⁢
                    
                      λ
                      L
                      2
                    
                    ⁢
                    QF
                  
                
                )
              
            
            +
            2
            -
            
              2
              ⁢
              
                e
                
                  
                    λ
                    L
                  
                  ⁢
                  Q
                
              
            
          
          
            
              λ
              L
              2
            
            ⁡
            
              (
              
                1
                -
                
                  e
                  
                    
                      λ
                      L
                    
                    ⁢
                    Q
                  
                
              
              )
            
          
        
      
    
    
      
        (
        18
        )
      
    
  




As λL is an inherent property of the input videos, in can be supposed to be constant during a short time, such as several images. Consequently, equation (4) turns to:




  
    
      
        λ
        =
        
          
            
              ∂
              D
            
            /
            
              ∂
              Q
            
          
          
            
              ∂
              R
            
            /
            
              ∂
              Q
            
          
        
      
    
    
      
        (
        19
        )
      
    
  




By putting equations (17) and (18) into equation (19), the Laplacian distribution based on the Lagrange multiplier λ can be determined The complete expression according to equation (19) is too long and will not be presented here. Practically, it can be easily computed by mathematical software or well-known numerical methods. In one embodiment, a lookup table is used to determining λ in order to save computation time.
The above described method for calculating the Lagrange multiplier based on equations (17) to (19) (referred to as “Lap-λ” in the following) was embedded into an H.264/AVC environment for intra frame encoding. The rounding offset F in equations (17) and (18) is set to be Q/3. The factor S in equation (17) was determined by using the fact that the Laplacian distribution will reduce to a uniform distribution when λL→0 (σ→∞). Consequently, in the limit of λL→0, the following equation holds:




  
    
      
        
          
            lim
            
              
                λ
                L
              
              →
              0
            
          
          ⁢
          λ
        
        =
        
          
            
              lim
              
                
                  λ
                  L
                
                →
                0
              
            
            ⁢
            
              -
              
                
                  
                    ∂
                    D
                  
                  /
                  
                    ∂
                    Q
                  
                
                
                  
                    ∂
                    R
                  
                  /
                  
                    ∂
                    Q
                  
                
              
            
          
          =
          
            
              
                2
                ⁢
                
                  
                
                ⁢
                ln
                ⁢
                
                  
                
                ⁢
                2
              
              
                9
                ⁢
                S
              
            
            ·
            
              Q
              2
            
          
        
      
    
    
      
        (
        20
        )
      
    
  




Equation (20) is set equal to equation (7), providing.




  
    
      
        S
        =
        
          
            
              2
              ⁢
              
                
              
              ⁢
              ln
              ⁢
              
                
              
              ⁢
              2
            
            
              9
              ⁢
              c
            
          
          =
          0.181
        
      
    
    
      
        (
        21
        )
      
    
  




Hence, by choosing S=0.181, this guarantees that the inventive Lap-λ selection equals the HR-λ selection in the limit when λL goes to 0.
In the implementation used for testing the invention, λL is calculated according to the variance o of the transformed residual coefficients for each image on the basis of equations (17) to (21). For the first image, no variance information is available. Therefore, for the first image, the HR-λ selection is used instead of the Lap-λ selection according to various embodiments of the invention.
The implementation used for testing the invention was applied to four video sequences V1, V2, V3 and V4. Video V1 refers to a small movement video showing a person making a phone call. Video V2 also refers to a small movement video of playing children. Video V3 refers to a large movement of a person playing tennis. Video V4 is a computer animation. The first 50 images of each sequence were coded, all in intra-frame with the well-known Context-Adaptive Arithmetic Coding (CABAC) technique. Rate distortion optimization was used based on the state of the art HR-λ selection as well as based on the Lap-λ selection according to embodiments of the invention. In order to ease the evaluation of the relationship among the Lagrange multiplier λ, the parameter qp and the parameter λL, all the sequences shared the same fixed qp.
The table according to FIG. 2 shows the simulation results for the different videos V1 to V4 and for different parameters gp. Peak signal-to-noise rate (PSNR) values in dB, the rate R in Kbps (kilo bits per second) and the average parameter Aver λ were calculated for the HR-λ selection and the Lap-λ selection. The PSNR value is a measure of the distortion and the lower this value, the higher the distortion D. Furthermore, the table of FIG. 2 shows the difference ΔPSNR between the PSNR values of both methods as well as the difference ΔR of the rate of both methods.
FIG. 3 shows a graphical representation of the results shown in the table in FIG. 2. Particularly, FIG. 3 shows, for each Video V1 to V4, a diagram representing the dependency of the PSNR value on the rate R. It is evident from FIG. 2 and FIG. 3, that the Lap-λ selection is all the time more efficient than the HR-λ selection, especially for the animation according to video V4 and for the small movement videos V1 and V2.
According to FIG. 3, a gain of up to 0.3 dB and 0.2 dB in the PSNR values were achieved for videos V1 and V4, respectively, while a little gain was achieved for video V3. For video V3, it can be observed from the table of FIG. 2 that the differences of the average λ between the two selection methods are much smaller than those in the other videos. Such a behavior can be explained by the property of the new λ (Lap-λ) function. The new λ increases much faster with smaller λL which corresponds to larger variances σ.
In the extreme condition when λL approaches 0, the new λ approaches the value of the HR-λ selection. That is, the smaller λL, the smaller differences between the two methods. Thus, less gain is achieved for fast videos having a large variance σ and thus a small λL. On the other hand, for computer animations and small movement videos, where the average λ calculated by the inventive method is much smaller than those of the HR-λ selection, the method according to the invention performs much better.
According to the above simulation results, an embodiment of the invention based on an adjustment of the Lagrange multiplier adaptively based on a Laplacian distribution outperforms the state of the art technique in the reference soft ware of H.264/AVC. The simulations were performed for intra-frame predictions but may be applied to inter-frame prediction as well.
For the purposes of promoting an understanding of the principles of the invention, reference has been made to the preferred embodiments illustrated in the drawings, and specific language has been used to describe these embodiments. However, no limitation of the scope of the invention is intended by this specific language, and the invention should be construed to encompass all embodiments that would normally occur to one of ordinary skill in the art.
The present invention may be described in terms of functional block components and various processing steps. Such functional blocks may be realized by any number of hardware and/or software components configured to perform the specified functions. For example, the present invention may employ various integrated circuit components, e.g., memory elements, processing elements, logic elements, look-up tables, and the like, which may carry out a variety of functions under the control of one or more microprocessors or other control devices. Similarly, where the elements of the present invention are implemented using software programming or software elements the invention may be implemented with any programming or scripting language such as C, C++, Java, assembler, or the like, with the various algorithms being implemented with any combination of data structures, objects, processes, routines or other programming elements. Furthermore, the present invention could employ any number of conventional techniques for electronics configuration, signal processing and/or control, data processing and the like.
The particular implementations shown and described herein are illustrative examples of the invention and are not intended to otherwise limit the scope of the invention in any way. For the sake of brevity, conventional electronics, control systems, software development and other functional aspects of the systems (and components of the individual operating components of the systems) may not be described in detail. Furthermore, the connecting lines, or connectors shown in the various figures presented are intended to represent exemplary functional relationships and/or physical or logical couplings between the various elements. It should be noted that many alternative or additional functional relationships, physical connections or logical connections may be present in a practical device. Moreover, no item or component is essential to the practice of the invention unless the element is specifically described as “essential” or “critical”. The word “mechanism”, as used herein, is not limited to any specific hardware configuration, but could incorporate any combination of hardware or software elements. Numerous modifications and adaptations will be readily apparent to those skilled in this art without departing from the spirit and scope of the present invention.

## Claims

1. A method for video coding a sequence of digitized images using a video encoder apparatus having one or more processors operable to execute computer-executable instructions, said method comprising:
(a) predicting, with the one or more processors, contents of each image utilizing a rate distortion optimization criterion that is dependent on a Lagrange multiplier, thereby determining a prediction error;
(b) transforming, with the one or more processors, the prediction error resulting from predicting step (a) into a plurality of transformed residual coefficients in each image;
(c) quantizing, with the one or more processors, the transformed residual coefficients in each image;
(d) determining, with the one or more processors, the Lagrange multiplier for each image based on a probability distribution of the transformed residual coefficients of the respective image, the probability distribution having its maximum probability at its mean zero and being formed such that the probabilities decrease to zero from the mean to large absolute values of the transformed residual coefficients, wherein a variance of the probability distribution is calculated from the plurality of transformed residual coefficients in the respective image; and
(e) video coding, with the one or more processors, a sequence of digitized images based on the determined Lagrange multiplier for each image.

2. The method according to claim 1, wherein the probability distribution comprises a generalized Gaussian distribution.

3. The method according to claim 2, wherein the probability distribution comprises a Gaussian distribution.

4. The method according to claim 2, wherein the probability distribution comprises a Laplace distribution.

5. The method according to claim 4, wherein the Laplace multiplier λ is calculated by solving the following equation:




  λ
  =
  
    
      
        ∂
        D
      
      /
      
        ∂
        Q
      
    
    
      
        ∂
        R
      
      /
      
        ∂
        Q
      
    
  



wherein D is an estimation for the distortion and defined as





  D
  =
  
    
      
        
          e
          
            
              λ
              L
            
            ⁢
            F
          
        
        ⁡
        
          (
          
            
              2
              ⁢
              
                λ
                L
              
              ⁢
              Q
            
            +
            
              
                λ
                L
                2
              
              ⁢
              
                Q
                2
              
            
            -
            
              2
              ⁢
              
                λ
                L
                2
              
              ⁢
              QF
            
          
          )
        
      
      +
      2
      -
      
        2
        ⁢
        
          e
          
            
              λ
              L
            
            ⁢
            Q
          
        
      
    
    
      
        λ
        L
        2
      
      ⁡
      
        (
        
          1
          -
          
            e
            
              
                λ
                L
              
              ⁢
              Q
            
          
        
        )
      
    
  



wherein R is an approximation for the rate and defined as





  R
  =
  
    
      S
      
        ln
        ⁢
        
          
        
        ⁢
        2
      
    
    ⁡
    
      [
      
        
          
            
              
                
                  -
                  
                    (
                    
                      1
                      -
                      
                        e
                        
                          -
                          
                            
                              λ
                              L
                            
                            ⁡
                            
                              (
                              
                                Q
                                -
                                F
                              
                              )
                            
                          
                        
                      
                    
                    )
                  
                
                ⁢
                
                  ln
                  ⁡
                  
                    (
                    
                      1
                      -
                      
                        e
                        
                          -
                          
                            
                              λ
                              L
                            
                            ⁡
                            
                              (
                              
                                Q
                                -
                                F
                              
                              )
                            
                          
                        
                      
                    
                    )
                  
                
              
              +
            
          
        
        
          
            
              
                e
                
                  -
                  
                    
                      λ
                      L
                    
                    ⁡
                    
                      (
                      
                        Q
                        -
                        F
                      
                      )
                    
                  
                
              
              ⁡
              
                (
                
                  
                    ln
                    ⁢
                    
                      
                    
                    ⁢
                    2
                  
                  -
                  
                    ln
                    ⁡
                    
                      (
                      
                        1
                        -
                        
                          e
                          
                            
                              -
                              
                                λ
                                L
                              
                            
                            ⁢
                            Q
                          
                        
                      
                      )
                    
                  
                  -
                  
                    
                      λ
                      L
                    
                    ⁢
                    F
                  
                  +
                  
                    
                      
                        λ
                        L
                      
                      ⁢
                      Q
                    
                    
                      1
                      -
                      
                        e
                        
                          
                            -
                            
                              λ
                              L
                            
                          
                          ⁢
                          Q
                        
                      
                    
                  
                
                )
              
            
          
        
      
      ]
    
  



wherein:
σ is a variance calculated from the plurality of transformed residual coefficients in the respective image;
Q is a quantization interval representing half of a distance between quantizer reproduction levels and F is the quantization offset used in the quantizing step (c); and
S is a constant factor.

6. The method according to claim 5, wherein 0>S>1.

7. The method according to claim 6, wherein S=0.181.

8. The method according to claim 2, wherein the probability distribution is a mixture of different generalized Gaussian distributions.

9. The method according to claim 1, wherein a lookup table is utilized for determining the Lagrange multiplier for each image.

10. The method according to claim 1, the method further comprising, after the quantization step (c):
entropy encoding, with the one or more processors, the quantized and transformed residual coefficients.

11. The method according to claim 1, wherein a spatial intra coding prediction is used in predicting step (a).

12. The method according to claim 1, wherein a temporal prediction comprising motion estimation and motion compensation is used in predicting step (a).

13. An apparatus for video coding a sequence of digitized images, the apparatus comprising:
one or more processors;
an adder module configured to predict contents of each image taking into account a rate distortion optimization criterion being dependent on a Lagrange multiplier and producing a prediction error;
a transformer module configured to transform the prediction error into a plurality of transformed residual coefficients in each image;
a quantizer module configured to quantize the transformed residual coefficients in each image;
the apparatus configured such that the Lagrange multiplier is determined for each image based on a probability distribution of the transformed residual coefficients of the respective image, the probability distribution having its maximum probability at its mean zero and being formed such that the probabilities decrease to zero from the mean to large absolute values of the transformed residual coefficients, whereby the variance of the probability distribution is calculated from the plurality of transformed residual coefficients in the respective image and a sequence of digitized images is video coded based on the determined Lagrange multiplier for each image.

14. The apparatus according to claim 13, further comprising an entropy encoder module configured to entropy code the residual coefficients transformed by the transformer module and quantized by the quantizer module.

15. A computer program product comprising a non-transitory computer readable storage medium having encoded thereon computer-executable instructions for executing by the one or more processors for performing a method of video coding a sequence of digitized images, said method comprising:
(a) predicting, with the one or more processors, contents of each image utilizing a rate distortion optimization criterion that is dependent on a Lagrange multiplier, thereby determining a prediction error;
(b) transforming, with the one or more processors, the prediction error resulting from predicting step (a) into a plurality of transformed residual coefficients in each image;
(c) quantizing, with the one or more processors, the transformed residual coefficients in each image;
(d) determining, with the one or more processors, the Lagrange multiplier for each image based on a probability distribution of the transformed residual coefficients of the respective image, the probability distribution having its maximum probability at its mean zero and being formed such that the probabilities decrease to zero from the mean to large absolute values of the transformed residual coefficients, wherein a variance of the probability distribution is calculated from the plurality of transformed residual coefficients in the respective image; and
(e) video coding, with the one or more processors, a sequence of digitized images based on the determined Lagrange multiplier for each image.

16. An apparatus for video coding a sequence of digitized images, the apparatus comprising:
one or more processors;
a system input module for inputting an input image;
a first adder module comprising a first input connected to the system input module to receive the input image and an output, the first adder module configured to generate a prediction error by subtracting from the input image a predicted image;
a transformer and quantizer module comprising an input connected to the output of the first adder module and an output, the transformer and quantizer module configured to perform a transformation on the input image received from the first adder module to generate transformed residual coefficients, and after a scaling step subject the transformed residual coefficients to a quantization to generate transformed and quantized residual coefficients;
an entropy coding module connected to the output of the transformer and quantizer module, the entropy coding module configured to determine, with the one or more processors, a Lagrange multiplier for each image based on a probability distribution of the transformed residual coefficients of a respective image, wherein a variance of the probability distribution is calculated from the transformed residual coefficients in the respective image;
an inverse quantizer and inverse transformer module comprising an input connected to the output of the transformer and quantizer module and an output, the inverse quantizer and inverse transformer module configured to receive the transformed and quantized residual coefficients from the transformer and quantizer module and perform an inverse quantization on the transformed and quantized residual coefficients and, after an inverse quantization, subject the residual coefficients to an inverse transformation to generate a decoded error;
a second adder module having a first input connected to the output of the inverse quantizer and inverse transformer module and an output, the second adder module configured to add the decoded error to the predicted image to produce a second image;
a deblocker module comprising an input connected to the output of the second adder module and an output, the deblocker module configured to deblock the second image to generate a decoded image; and
a motion compensator module comprising an input connected to the output of the deblocker module and an output that is connected to a second input of the first adder module as well as a second input of the second adder module, the motion compensator module configured to perform a motion compensation on the decoded image to obtain the predicted image which is supplied to the first adder module to determine the prediction error to facilitate video coding the sequence of digitized images.