# Patent

## Title
Method and apparatus for providing rate control for panel-based real-time video encoder

## Abstract

A method and apparatus for providing multi-panel rate control of real-time video digital encoders such as an MPEG or H series including the steps of bit allocation, rate control and adaptive quantization. Bit allocation assigns a target number of bits per group of pictures, and per picture of each type. Rate control adjusts the quantization parameter at the MB level to achieve that target number of bits per picture. Adaptive quantization further modulates the parameter per MB using local activity measure. Bit allocation and rate control can be implemented through a central control unit, or a central digital signal processor (DSP) while adaptive quantization can be implemented at the local panel.

## Background
BACKGROUND
1. Field
The present disclosure relates generally to the field of video data processing, and, more particularly, to a multi-panel rate control method for real-time digital video encoders such as an MPEG-4 or an H series encoder.
2. Related Art
Video signals generally include data corresponding to one or more video frames, where each video frame is composed of an array of picture elements (pels). A typical color video frame at standard resolution can be composed of over several hundred thousand pel arranged in an array of blocks. Since each pel has to be characterized with a color (or hue) and luminance characteristics, these data may be represented with groups of four luminance pel blocks and two chrominance pel blocks called macroblocks (MBs). Thus, digital signals representing a sequence of video frame data, usually containing many video frames, have a large number of bits. However, the available storage space and bandwidth for transmitting such signals is limited. Therefore, compression processes are used to more efficiently transmit or store video data.
Compression of digital video signals for transmission or for storage has become widely practiced in a variety of contexts, especially in multimedia environments for video conferencing, video games, Internet image transmissions, digital TV and the like. Coding and decoding are accomplished with coding processors which may be general computers, special hardware or multimedia boards and other suitable processing devices.
Compression processes typically involve quantization, in which sampled video signal data values are represented by a fixed number of redefined quantizer values. The quantized signal is composed of quantizer values that are approximations of the sampled video signal. Therefore, the encoding of the video signal data onto a limited number of quantizer values necessarily produces some loss in accuracy during the decoding process.
SUMMARY
The following disclosure describes embodiments of a method which provides an improved video digital data compression capable of adjusting the quantization parameter to achieve an improved coding and decoding process. This method may employ an encoder having a panel based architecture with a digital signal processor to handle one or several rows of MB in lieu of frame-by-frame, thereby, allowing a greater number of frames to be processed. Various embodiments of this method further have the capability of handling both frame and field pictures as opposed to one mode of picture such as frame pictures.
The embodiments may perform several steps including bit allocation, rate control and adaptive quantization. Bit allocation assigns a target number of bits per group of pictures, and per picture of each type. Rate control adjusts the quantization parameter at the MB level to achieve that target number of bits per picture. Adaptive quantization further modulates the parameter per MB using a local activity measure. Bit allocation and rate control can be implemented through a central control unit, or a central digital signal processor (DSP) while adaptive quantization can be implemented at the local panel. One encoder employing the method may have a central DSP and several panels, each with its own DSP. During the process of encoding, a whole frame is divided into multiple slices which are processed in parallel by the DSPs at the multiple panels.
An embodiment capable of implementing the present disclosure may be a video data encoding apparatus comprising of a processor, an input/output device, a memory, and a video encoding module capable of performing bit allocation by assigning a target number of bits per GOP, rate control by adjusting the quantization parameter QP to achieve said target number of bits, and adaptive quantization by modulating the quantization parameter using the local activity measure. Such embodiment shall have the capability of performing scene changes within a GOP, and also the ability to check and adjust the target number of bits assigned for a picture I, P or B in order to prevent the system from overflowing and underflowing.



BRIEF DESCRIPTION OF THE DRAWINGS
The above-mentioned features of the present disclosure will become more apparent with reference to the following description taken in conjunction with the accompanying drawings wherein like reference numerals denote like elements and in which:
FIG. 1 illustrates a block diagram of a real-time video encoding system.
FIG. 2 illustrates a multi-panel architecture for processing a whole picture.
FIG. 3 illustrates a flowchart of a rate control process used by the real-time video encoding module.
FIG. 4 illustrates a flowchart of another embodiment of a rate control process used by the real-time video encoding module.
FIG. 5 illustrates a representation of how an input video sequence is grouped into “Groups of Pictures” (GOPs).
FIG. 6 illustrates a diagram of the geometric positions of MBs being processed by the panels.
FIGS. 7 and 8 illustrate diagrams of scene changes in GOPs.



DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
The following detailed description is not to be taken in a limiting sense, but is made merely for the purpose of illustrating general principles of embodiments of the present disclosure. The scope of the present disclosure is best defined by the appended claims.
FIG. 1 illustrates a block diagram of a real-time video encoding system 10. Specifically, the real-time video encoding system 10 may be employed to compress video data on a panel-based architecture using a multi-panel control process as hereafter described. Such an encoder 10 may comprise, for example, an MPEG-4 AVC encoder.
In one embodiment, the real-time video encoder system 10 is implemented on a general-purpose computer or any other hardware equivalent. Thus, the real-time video encoder system 10 may comprises a processor (CPU) 11, memory 12, e.g., random access memory (RAM) and/or read only memory (ROM), video encoding module 14, and various input/output devices 13, (e.g., storage devices, including but not limited to, a tape drive, a floppy drive, a hard disk drive or a compact disk drive).
It should be understood that the video encoding module 14 may be implemented as one or more physical devices that are coupled to the processor 11 through a communication channel. Alternatively, the video encoding module 14 may be represented by one or more software applications or with a combination of software and hardware, e.g., using application specific integrated circuits (ASIC), where the software is loaded from a storage medium, (e.g., a magnetic or optical drive or diskette) into memory 12 and operated on by the processor 11 of the video encoding module 14. As such, the video encoding module 14 (including associated data structures) of the present embodiment may be stored on a computer readable medium, e.g., RAM memory, magnetic or optical drive or diskette or the like.
Real-time video encoders may have a multi-panel architecture for processing a whole picture. In such an architecture, a picture 21 is divided into several slices 22, and each panel 23 processes one of these slices 22. as shown in FIG. 2. Each of these multiple panels has its own DSP that enables the slices 22 to be processed in parallel at these panels 23.
FIG. 3 illustrates a flow chart of a rate control process 30 for real-time video encoding using a multi-panel based architecture. In one embodiment, the process 30 is performed by a real-time video encoder such as a MPEG-4 encoder. The process 30 starts with the reception of video input data 31 by a video encoder. The input video data is processed using a rate control method consisting of three main steps: (a) bit allocation 32, (b) rate control 33 and (c) adaptive quantization 34. Bit allocation 32 assigns a target number of bits per group of pictures, and per picture of each type. Rate control 33 adjusts the quantization parameter at the MB level to achieve that target number of bits per picture. Adaptive quantization 34 further modulates the parameter per MB using a local activity measure. The steps of bit allocation 32 and rate control 33 can be implemented through a central control unit, or a central DSP, while the step of adaptive quantization 34 can be implemented at the local panel. An exemplary encoder using a multi-panel rate control method such as an MPEG-4 has components capable of performing bit allocation 32, rate control 33, and adaptive quantization 34.
FIG. 4 illustrates a flowchart of another embodiment of a rate control process 40 for real-time video encoder wherein bit allocation is performed at a process block 41 and rate control is performed at a process block 42 are performed. At the process block 41, bit allocation is performed by assigning a target number of bits per group of pictures. Further, at the process block 42, rate control is performed by adjusting the quantization parameters to achieve the target number of bits. In one embodiment, both bit allocation and rate control are implemented by a central DSP of a real-time video encoder.
In one embodiment, it is assumed in the following that a picture can be of type intra picture (I), predictive coded picture (P), or bi-directional predictive coded picture (B).
With respect to first main step of bit allocation 32, pictures of the input video sequence are grouped into GOPs. A GOP 50 may contain one I picture 51 and a few P pictures 52, as shown in FIG. 5. There may be one or more B pictures 53 between I and/or P pictures 51, 52. A group of successive B pictures 53 plus the following I or P picture is called sub_GOP 54. A GOP 50 can be described by the number of pictures per GOP 50 and per sub_GOP 54, that is, the GOP length, NGOP, and the sub_GOP length, Nsub—nGOP. The central DSP allocates a bit budget per GOP and per picture.
Target Rate Per GOP: Given a target bit rate of bit_rate in bits per second and a picture rate of pic_rate in pictures per second, a GOP 50 of NGOP pictures is budgeted a nominal number of bits as




  
    R
    
      G
      ⁢
      
        
      
      ⁢
      O
      ⁢
      
        
      
      ⁢
      P
      ⁢
      
        
      
      ⁢
      _
      ⁢
      
        
      
      ⁢
      n
      ⁢
      
        
      
      ⁢
      o
      ⁢
      
        
      
      ⁢
      minal
    
  
  =
  
    
      N
      GOP
    
    ×
    
      
        bit_rate
        pic_rate
      
      .
    
  




At the beginning of a GOP 50, the central DSP calculates a target number of bits, RGOP—remaining, for the GOP 50 as RGOP—remaining=RGOP—remaining+RGOP—nominal, where RGOP—remaining on the right is the number of bits left over from the previous GOP 50. For the first GOP 40 of a sequence, RGOP—remaining on the right is set to 0 bits.
Target Rate Per Picture: Given a target number of bits for a GOP 50, RGOP—remaining, the central DSP needs to assign a picture of pic_type I, P or B a target number of bits, TPic—type, according to its relative complexity measure, CPic—type, over other pictures within the GOP 50.
For instance, in one embodiment of an encoder such as a MPEG-4 AVC |H.264, encoding a MB may require the coded information of its left and above neighbor MBs. The geometric positions of the current MBs in panels therefore may not be the same, as shown in FIG. 6, where the shaded blocks are the current MBs 60. In addition, the upper panels may complete the processing of their MBs much earlier than the lower panels, and move on to the MBs in next picture, as shown in FIG. 6. The two pictures may have different types of I, P and B. Hence, the central DSP needs to have the target numbers of bits ready for all the three picture types of I, P and B all the time.
The present method allows an interlace picture of two fields, field 0 and field 1, to be encoded as a single frame picture or as two separate field pictures. An encoder such as an MPEG encoder may allow adaptive switching between frame and field picture coding. The rate control method therefore maintains two sets of the complexity measures of pic_type I, P and B picture: one for frame pictures and one for field pictures. The target numbers of bits for frame pictures of pic_type I, P and B are set as




  
    
      T
      
        p
        ⁢
        
          
        
        ⁢
        i
        ⁢
        
          
        
        ⁢
        c
        ⁢
        
          
        
        ⁢
        _
        ⁢
        
          
        
        ⁢
        type
      
    
    =
    
      
        
          K
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ⁢
        
          C
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ⁢
        
          R
          
            GOP
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            remaining
          
        
      
      
        
          
            K
            1
          
          ⁢
          
            n
            
              frame
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              I
            
          
          ⁢
          
            C
            
              frame
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              I
            
          
        
        +
        
          
            K
            P
          
          ⁢
          
            n
            
              frame
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              P
            
          
          ⁢
          
            C
            
              frame
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              P
            
          
        
        +
        
          
            K
            B
          
          ⁢
          
            n
            
              frame
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              B
            
          
          ⁢
          
            C
            
              frame
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              B
            
          
        
      
    
  
  ,




and the target numbers of bits for field pictures of pic_type I, P and B are set as





  
    
      T
      
        pic
        ⁢
        
          
        
        ⁢
        _
        ⁢
        
          
        
        ⁢
        t
        ⁢
        
          
        
        ⁢
        ype
      
    
    =
    
      
        
          K
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ⁢
        
          C
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ⁢
        
          R
          
            GOP
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            remaining
          
        
      
      
        
          
            
              
                
                  K
                  I
                
                ⁢
                
                  n
                  
                    field
                    ⁢
                    
                      
                    
                    ⁢
                    _
                    ⁢
                    
                      
                    
                    ⁢
                    I
                  
                
                ⁢
                
                  C
                  fieldI
                
              
              +
              
                
                  K
                  P
                
                ⁢
                
                  (
                  
                    
                      
                        n
                        
                          field
                          ⁢
                          
                            
                          
                          ⁢
                          0
                          ⁢
                          _
                          ⁢
                          
                            
                          
                          ⁢
                          P
                        
                      
                      ⁢
                      
                        C
                        
                          field
                          ⁢
                          
                            
                          
                          ⁢
                          0
                          ⁢
                          _
                          ⁢
                          
                            
                          
                          ⁢
                          P
                        
                      
                    
                    +
                    
                      
                        n
                        
                          field
                          ⁢
                          
                            
                          
                          ⁢
                          1
                          ⁢
                          _
                          ⁢
                          
                            
                          
                          ⁢
                          P
                        
                      
                      ⁢
                      
                        C
                        
                          field
                          ⁢
                          
                            
                          
                          ⁢
                          1
                          ⁢
                          _
                          ⁢
                          
                            
                          
                          ⁢
                          P
                        
                      
                    
                  
                  )
                
              
              +
            
          
        
        
          
            
              
                K
                B
              
              ⁢
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              ⁢
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
            
          
        
      
    
  
  ,




where pic_type indicates the picture type of I, P or B for the current picture; Cpic—type is the complexity measure for picture of pic_type in either frame or field; Cframe—I, Cframe—P, and Cframe—B are the complex measures for frame pictures of pic_type I, P and B, respectively; Cfield—I, Cfield0—P, Cfield1—P, and Cfield—B are the complex measures for I field, P field 0, P field 1 and B field pictures, respectively; KI, KP and KB are the pre-set constants for pictures of pic_type I, P and B, respectively (for example, KI=KP=1 and KB=1/1.4); nframe—I, nframe—P, and nframe—B are the remaining numbers of I, P and B frame pictures in the current GOP; and nfield—I, nfield0—P, nfield1—P, and nfield—B are the remaining numbers of I field, P field 0, P field 1 and B field pictures in the current GOP.

GOP Remaining Bits Updating: After encoding a picture of type I, P or B, the remaining number of bits for the current GOP is updated as RGOP—remaining=RGOP—remaining−Rpic—actual, where Rpic—actual is the actual number of bits consumed for the picture.
Complexity Initialization: At the beginning of a sequence, the complex measures for frame and field pictures are initialized. For example,




  {
  
    
      
        
          
            
              C
              
                frame
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                I
              
            
            =
            160
          
        
      
      
        
          
            
              C
              
                frame
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                P
              
            
            =
            60
          
        
      
      
        
          
            
              
                C
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              =
              42
            
            ,
          
        
      
    
    ⁢
    
      

    
    ⁢
    and
    ⁢
    
      

    
    ⁢
    
      {
      
        
          
            
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              =
              160
            
          
        
        
          
            
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  0
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              =
              60
            
          
        
        
          
            
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  1
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              =
              42
            
          
        
        
          
            
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              =
              42.
            
          
        
      
    
  




After the first I and P frame pictures, the complexity measure for B frame picture is set based upon the updated complexity measures of I and P. For example,

Cframe—B=(42/60)×Cframe—P.

If the first I frame is coded as one I field followed by one P field, the complexity measures for P field 0 and B field pictures are set based upon the updated complexity measures of I and P. For example,




  {
  
     
    
      
        
          
            
              C
              
                field
                ⁢
                
                  
                
                ⁢
                0
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                P
              
            
            =
            
              
                (
                
                  60
                  /
                  42
                
                )
              
              ×
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  1
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
            
          
        
      
      
        
          
            
              C
              
                fiel
                ⁢
                
                  
                
                ⁢
                d
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                B
              
            
            =
            
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  1
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              .
            
          
        
      
    
  




Note that the above settings for complexity measures are implemented only once per sequence.

Complexity Updating: The complexity measure of pic_type I, P or B is defined as the product of the number of bits used for a picture of pic_type I, P or B and the associated coding distortion, D, that is, Cpic—type=Rpic—actual×D. D can be any square distortion, for example, the mean square error. The complexity measure of pic_type I, P or B is updated after a frame or field picture of I, P or B is encoded. Note that in the real-time system, certain delays are inevitable. For example, in the proposed encoder design, the actual number of compressed bits for a given picture, Rpic—actual, may not be available until three or four pictures later. Hence, the picture complexities used in calculating the target numbers of bits per picture in frame or field may be the ones calculated a few pictures away in the past.
Note that a picture is encoded only once, either in frame mode or in field mode. However, the complexity measures in both frame and field modes are updated. Specifically, when a picture is coded in frame mode, the complexity measures in frame mode are updated using equation Cpic—type=Rpic—actual×D and the complexity measures in field mode are updated using equations




  {
  
     
    
      
        
          
            
              C
              
                field
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                I
              
            
            =
            
              
                C
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              /
              2
            
          
        
      
      
        
          
            
              C
              
                field
                ⁢
                
                  
                
                ⁢
                0
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                P
              
            
            =
            
              
                C
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              *
              
                2
                /
                3
              
            
          
        
      
      
        
          
            
              C
              
                field
                ⁢
                
                  
                
                ⁢
                1
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                P
              
            
            =
            
              
                C
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              /
              3
            
          
        
      
      
        
          
            
              C
              
                field
                ⁢
                
                  
                
                ⁢
                0
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                B
              
            
            =
            
              
                C
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              /
              2.
            
          
        
      
    
  




When a picture is coded in field mode, the complexity measures in field mode are updated using the equations

Cpic—type=Rpic—actual×D

After field 1 is coded, the complexity measures in frame mode are also updated as




  {
  
     
    
      
        
          
            
              C
              
                frame
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                I
              
            
            =
            
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              ×
              2
            
          
        
      
      
        
          
            
              C
              
                frame
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                P
              
            
            =
            
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  1
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              ×
              3
            
          
        
      
      
        
          
            
              C
              
                frame
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                B
              
            
            =
            
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              ×
              2.
            
          
        
      
    
  




Picture Number Updating: The numbers of I, P and B (frame) pictures per GOP, NI, NP, and NB, are pre-set. For example, assume there is only one I frame in a GOP of NGOP and Nsub—GOP is not changed, NI, NP, and NB are set as




  {
  
     
    
      
        
          
            
              N
              I
            
            =
            1
          
        
      
      
        
          
            
              N
              P
            
            =
            
              
                (
                
                  
                    N
                    GOP
                  
                  /
                  
                    N
                    
                      sub
                      ⁢
                      
                        
                      
                      ⁢
                      _
                      ⁢
                      
                        
                      
                      ⁢
                      GOP
                    
                  
                
                )
              
              -
              1
            
          
        
      
      
        
          
            
              N
              B
            
            =
            
              
                N
                GOP
              
              -
              
                N
                I
              
              -
              
                
                  N
                  P
                
                .
              
            
          
        
      
    
  




Further assume that I in field mode is configured to be coded as two I fields, or I field 0 followed by P field 1, or P field 0 followed by I field 1, or I field 0 followed by B field 1, or B field 0 followed by I field 1, and P and B in field mode are configured as two P fields and two B fields, other configurations for P and B in field are also possible.
At the beginning of a GOP, the remaining numbers of I, P and B frame and field pictures for the current GOP are set as




  {
  
     
    
      
        
          
            
              n
              
                frame
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                I
              
            
            =
            
              N
              I
            
          
        
      
      
        
          
            
              n
              
                frame
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                P
              
            
            =
            
              N
              P
            
          
        
      
      
        
          
            
              
                n
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              =
              
                N
                B
              
            
            ,
          
        
      
    
  




and if I in field mode is configured to be coded as two I fields,





  {
  
    
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              =
              2
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  0
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              =
              
                N
                P
              
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  1
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              =
              
                N
                P
              
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              =
              
                2
                ×
                
                  N
                  B
                
              
            
          
        
      
    
    ;
  




or if I in field mode is configured to be coded as I field 0 followed by P field 1,





  {
  
    
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              =
              1
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  0
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              =
              
                N
                P
              
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  1
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              =
              
                
                  N
                  P
                
                +
                1
              
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              =
              
                2
                ×
                
                  N
                  B
                
              
            
          
        
      
    
    ;
  




or if I in field mode is configured to be coded as P field 0 followed by I field 1,





  {
  
    
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              =
              1
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  0
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              =
              
                
                  N
                  P
                
                +
                1
              
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  1
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              =
              
                N
                P
              
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              =
              
                2
                ×
                
                  N
                  B
                
              
            
          
        
      
    
    ;
  




or if I in field mode is configured to be coded as one I field and one B field,





  {
  
    
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              =
              1
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  0
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              =
              
                N
                P
              
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  1
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              =
              
                N
                P
              
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              =
              
                
                  2
                  ×
                  
                    N
                    B
                  
                
                +
                1
              
            
          
        
      
    
    .
  




After a frame picture of I, P or B is encoded, the corresponding number of I, P or B pictures in the current GOP is updated in the following manner: if it is a I picture and if the I picture in field is configured to be coded as two I fields, then




  {
  
    
      
        
          
            
            ⁢
            
              
                n
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              --
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              -=
              2
            
          
        
      
    
    ;
  




or if the I picture in field mode is configured to be coded as I field 0 followed by P field 1, then





  {
  
    
      
        
          
            
            ⁢
            
              
                n
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              --
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              --
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              --
            
          
        
      
    
    ;
  




or if the I picture in field mode is configured to be coded as P field 0 followed by I field 1, then





  {
  
    
      
        
          
            
            ⁢
            
              
                n
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              --
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  0
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              --
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              --
            
          
        
      
    
    ;
  




or if the I picture in field mode is configured to be coded as one I field and one B field,





  {
  
    
      
        
          
            
            ⁢
            
              
                n
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              --
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              --
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              --
            
          
        
      
    
    ;
  




else, if it is a P picture, then





  {
  
    
      
        
          
            
            ⁢
            
              
                n
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              --
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  0
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              --
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  1
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              --
            
          
        
      
    
    ;
    
      else
      ⁢
      
        
      
      ⁢
      
        {
        
          
            
              
                
                  
                  ⁢
                  
                    
                      n
                      
                        frame
                        ⁢
                        
                          
                        
                        ⁢
                        _
                        ⁢
                        
                          
                        
                        ⁢
                        B
                      
                    
                    --
                  
                
              
            
            
              
                
                  
                  ⁢
                  
                    
                      n
                      
                        field
                        ⁢
                        
                          
                        
                        ⁢
                        _
                        ⁢
                        
                          
                        
                        ⁢
                        B
                      
                    
                    -=
                    2
                  
                
              
            
          
          .
        
      
    
  




After field 0 of I, P, or B is encoded, the corresponding number of I, P or B pictures in the current GOP is updated in the following manner: if it is a I picture, then nfield—I . . . ; else if it is a P picture, then nfield0—P . . . ; else if it is a B picture then nfield—B . . . .
After field 1 of I, P or B is encoded, the corresponding number of I, P or B pictures in the current GOP is updated in the following manner: if it is an I picture, then




  {
  
    
      
        
          
            
            ⁢
            
              
                n
                
                  frame
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              --
            
          
        
      
      
        
          
            
            ⁢
            
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              --
            
          
        
      
    
    ;
  




else if it is a P picture and if field 0 is coded as I, then nframe—I . . ., or if field 0 is coded as P field, then nframe—P . . . ; nfeld1—P . . . ; else if it is a B picture and field 0 is coded as I, then nframe—I . . . ; or if field 0 is coded as B, then nframe—B . . . ; nfield —B . . . .

Scene Change Handling: In one embodiment, a proposed encoder system allows preview beyond the current GOP in handling a scene change. If a scene change occurs within a GOP and I picture in the GOP is in the new scene, no action is taken. Otherwise, the first P picture in the new scene is changed to I picture. The following process is invoked depending upon whether the first P picture in the new scene is in the first half or the second half of the GOP.
Assume that the first P picture in the new scene is the Nth picture of the GOP. If the first P picture is in the first half of GOP, the scheduled I in the GOP is changed to P picture. This creates a longer GOP 70 followed by a shorter current GOP 71, as shown in FIG. 7. The longer and the shorter GOPs 70, 71 are compensated so that the later scheduled I, P and B pictures will maintain. The longer GOP 70 is of the length equal to NGOP=NGOP+(N−Nsub—GOP) and the shorter GOP 71 of the length equal to NGOP=NGOP−(N−Nsub—GOP).
The corresponding numbers of I, P and B frame and field pictures for the longer and shorter GOPs 70, 71 can be calculated from the above equations using the updated GOP lengths.
The nominal number of bits for the longer GOP 70 is set as




  
    
      R
      
        GOP
        ⁢
        
          
        
        ⁢
        _
        ⁢
        
          
        
        ⁢
        nominal
      
    
    =
    
      
        R
        
          GOP
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          nominal
        
      
      +
      
        
          
            N
            -
            
              N
              
                sub_
                ⁢
                
                  
                
                ⁢
                GOP
              
            
          
          
            N
            GOP
          
        
        ×
        
          R
          
            GOP
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            nominal
          
        
      
    
  
  ,




and the nominal number of bits for the shorter GOP 61 is reset as





  
    R
    
      GOP
      ⁢
      
        
      
      ⁢
      _
      ⁢
      
        
      
      ⁢
      nominal
    
  
  =
  
    
      R
      
        GOP
        ⁢
        
          
        
        ⁢
        _
        ⁢
        
          
        
        ⁢
        nominal
      
    
    -
    
      
        
          N
          -
          
            N
            
              sub_
              ⁢
              
                
              
              ⁢
              GOP
            
          
        
        
          N
          GOP
        
      
      ×
      
        
          R
          
            GOP
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            nominal
          
        
        .
      
    
  




On the other hand, if the first P in the new scene is in the second half of GOP, the scheduled I picture in the next GOP is changed to P picture. This creates a shorter GOP 72 followed by a longer GOP 73, as shown in FIG. 7. The shorter and the longer GOPs 72, 73 are compensated so that the later scheduled I, P and B pictures will maintain.
The shorter GOP 72 is of the length equal to NGOP=N−Nsub—GOP, and the longer GOP 73 of the length equal to NGOP=2×NGOP−(N−Nsub—GOP).
Similarly, the corresponding numbers of I, P and B frame and field pictures for the longer and shorter GOPs 72, 73 can be calculated from the above equations using the updated GOP lengths. The nominal number of bits for the shorter GOP 72 is reset as




  
    R
    
      GOP
      ⁢
      
        
      
      ⁢
      _
      ⁢
      
        
      
      ⁢
      nominal
    
  
  =
  
    
      
        N
        -
        
          N
          
            sub_
            ⁢
            
              
            
            ⁢
            GOP
          
        
      
      
        N
        GOP
      
    
    ×
    
      R
      
        GOP
        ⁢
        
          
        
        ⁢
        _
        ⁢
        
          
        
        ⁢
        nominal
      
    
  




as and the nominal number of bits for the longer GOP 73 is reset as





  
    R
    
      GOP
      ⁢
      
        
      
      ⁢
      _
      ⁢
      
        
      
      ⁢
      nominal
    
  
  =
  
    
      2
      ×
      
        R
        
          GOP
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          nominal
        
      
    
    -
    
      
        
          N
          -
          
            N
            
              sub_
              ⁢
              
                
              
              ⁢
              GOP
            
          
        
        
          N
          GOP
        
      
      ×
      
        
          R
          
            GOP
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            nominal
          
        
        .
      
    
  




An alterative embodiment to the above embodiment which compensates the longer or the shorter GOP is described in FIG. 8 where an irregular GOP 80, 82 is followed by a regular GOP 81, 83. The longer and shorter GOP lengths are calculated in the same manner as described above. The nominal number of bits for the longer and shorter GOP are also determined in the same manner as described above. In both embodiments shown in FIGS. 7 and 8 the irregular GOP length 70, 71, 72, 73, 80, and 82 is within the range of 0.5 to 1.5 times of the regular GOP length 81, 83. The benefit of the first embodiment is that on average the same numbers of I, P and B picture can be maintained per second. On the other hand, the second embodiment may result in a variable number of I, P and B pictures per second. For example, if there are many shorter GOPs within a period of time, there are clearly more I pictures within this period than in the regular GOP case.
Rate Control: The target number of bits per frame or field may be achieved by properly selecting a value of QP per MB or a group of MBs. MPEG4 AVC |H.264 encoder, for instance, allows a total of 52 possible values in quantization parameter (QP), e.g., 0, 1, 2, . . ., 51. Given the target numbers of bits for (frame or field) pictures of pic_type I, P and B, Tpic—type, the central DSP first determines six reference (not final) quantization parameters, QPpic—type(t), at a time instant t based upon the fullness of six virtual buffers, one for each picture types of pic_type in frame or field. The virtual buffer fullness of pic_type I, P or B in frame or field at time t is computed as




  
    
      d
      
        pic
        ⁢
        
          
        
        ⁢
        _
        ⁢
        
          
        
        ⁢
        type
      
    
    ⁡
    
      (
      t
      )
    
  
  =
  
    
      
        d
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ⁡
      
        (
        0
        )
      
    
    +
    
      
        α
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ×
      
        
          B
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ⁡
        
          (
          t
          )
        
      
    
    -
    
      
        
          
            MB
            
              pic
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              type
            
          
          ⁡
          
            (
            t
            )
          
        
        
          MB
          pic
        
      
      ⁢
      
        
          T
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        .
      
    
  




is the initial virtual buffer fullness at the beginning of the picture of pic_type I, P or B in frame or field. The final virtual buffer fullness of the current picture, dpic—type(T), is used as dpic—type(0) for the next picture of the same frame or field pic_type. MBpic—typet(t) is the number of MBs that have been processed among all the panels in the picture of pic_type up to time t. Note that the processing order of MBs in a picture may not necessarily be the same as the actual encoding scan path. MBpic is the total number of MBs in a picture. Bpic—type(t) is the number of bins generated from the coded MBs among all the panels in the picture of pic_type up to time t. αpic—type is the ratio of the total number of actual bits and the total number of bins for picture of pic_type. αpic—type is updated after encoding a picture of pic_type. For the first I, αpic—type is set as 0.75, for the first P, set to be the same as that of the previous I, and for the first B, set to be the same as that of the previous P. αpic—type is reset at each scene cut. Note that due to the encoding delay, αpic—type may be calculated a few pictures away in the past.

The above assumes that each MB uses the same nominal number of bits. An alternative embodiment provides for weighing the bit budget per MB according to its need. For example,




  
    
      
        d
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ⁡
      
        (
        t
        )
      
    
    =
    
      
        
          d
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ⁡
        
          (
          0
          )
        
      
      +
      
        
          α
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ×
        
          
            B
            
              pic
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              type
            
          
          ⁡
          
            (
            t
            )
          
        
      
      -
      
        
          
            
              ∑
              
                i
                =
                0
              
              
                
                  MB
                  
                    pic
                    ⁢
                    
                      
                    
                    ⁢
                    _
                    ⁢
                    
                      
                    
                    ⁢
                    type
                  
                
                ⁡
                
                  (
                  t
                  )
                
              
            
            ⁢
            
              act
              i
            
          
          total_act
        
        ⁢
        
          T
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
      
    
  
  ,




where acti is the local activity measure of MB(i),





  
    total_act
    =
    
      
        ∑
        i
      
      ⁢
      
        act
        i
      
    
  
  ,




and the index i is over all the MBs in the current picture. Another way of determining the virtual buffer fullness is by the equation





  
    
      
        d
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ⁡
      
        (
        t
        )
      
    
    =
    
      
        
          d
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ⁡
        
          (
          0
          )
        
      
      +
      
        
          α
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ×
        
          
            B
            
              pic
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              type
            
          
          ⁡
          
            (
            t
            )
          
        
      
      -
      
        
          
            
              ∑
              
                i
                =
                0
              
              
                
                  MB
                  
                    pic
                    ⁢
                    
                      
                    
                    ⁢
                    _
                    ⁢
                    
                      
                    
                    ⁢
                    type
                  
                
                ⁡
                
                  (
                  t
                  )
                
              
            
            ⁢
            
              cos
              ⁢
              
                
              
              ⁢
              
                t
                i
              
            
          
          
            total_cos
            ⁢
            
              
            
            ⁢
            t
          
        
        ⁢
        
          T
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
      
    
  
  ,




where costs is the cost measure of MB(i) (often used in mode decision), and





  
    total_cost
    =
    
      
        ∑
        i
      
      ⁢
      
        cost
        i
      
    
  
  ,




and the index i is over all the MBs in the current picture. The above two options tend to distribute the bits over MBs of a picture according to their need. The initial values of the virtual buffer fullness are set as dpic—type(0)=bit_rate/pic_rate. Note that frame and field pictures maintain separate sets of virtual buffer fullness. The quantization stepsize at time t is set proportional to the fullness of virtual buffer as, Qpic—type(t)=51×(pic_rate/bit_rate)×dpic type(t). The quantization stepsize, Qpic type(t), is then converted into the reference quantization parameter by QPpic—type(t)=[6×log2(Qpic—type(t))+c] where constant c is set to a value of 4 [1].

The same reference quantization parameter, QPpic—type(t), is now applied to all the current MBs of the panels of the current pictures of pic_type I, P and/or B in frame or field.
Interval for Updating Reference QP: The central DSP checks the virtual buffer fullness at a constant, or variable, interval. The interval may be set around an average time for processing one or several MBs. At each checking time instant, say t, the central DSP receives the information on the number of MBs that have been processed since the last checking time from each of the panels of the current (one, two or three) pictures of pic_type I, P and/or B, and the associated bit, or bin, counts of the processed MBs. Note that due to the complexity of each MB as well as the possible different coding modes assigned, panels may not necessarily sync at processing their current MBs. Hence, at time t, panels may give slightly different numbers of the processed MBs, that is, 1, 0, or other numbers. The central DSP then re-computes the virtual buffer fullness dpic—type(t) for all the three picture types of pic_type I, P and B, and determines the new reference quantization parameters, QPpic13 type(t). The new QPpic—type(t) are sent back to all the panels of the current pictures of pic—typeI, P and/or B. The QPpic—type(t) is used for the next MBs until a new QP is received.
Adaptive Quantization: The reference quantization parameter, QPpic—type(t) is further modulated per MB by the MB's spatial local activity at each panel. The spatial local activity measure of MB (j) in frame or field mode is computed using the original pixel values of the MB, that is, actj=1+min(var_blockk|k=1,2, . . ., 2×(16/n)×(16/m)), where var_blockk is the variance of MB/sub_MB partition (k), defined as




  
    
      var_block
      k
    
    =
    
      
        1
        
          n
          ×
          m
        
      
      ⁢
      
        
          ∑
          
            i
            ,
            
              j
              =
              0
            
          
          
            n
            ,
            m
          
        
        ⁢
        
          
            (
            
              
                
                  x
                  k
                
                ⁡
                
                  (
                  
                    i
                    ,
                    j
                  
                  )
                
              
              -
              
                mean_block
                k
              
            
            )
          
          2
        
      
    
  
  ,
  
    

  
  ⁢
  
    
      mean_block
      k
    
    =
    
      
        1
        
          n
          ×
          m
        
      
      ⁢
      
        
          ∑
          
            i
            ,
            
              j
              =
              0
            
          
          
            n
            ,
            m
          
        
        ⁢
        
          
            x
            k
          
          ⁡
          
            (
            
              i
              ,
              j
            
            )
          
        
      
    
  




and xk(i, j) are the original pixel values of MB/sub_MB partition (k). Normalized local activity is given by





  
    
      N_act
      j
    
    =
    
      
        
          β
          ×
          
            act
            j
          
        
        +
        avg_act
      
      
        
          act
          j
        
        +
        
          β
          ×
          avg_act
        
      
    
  
  ,




where β is a constant and avg_act is the average value of actj of the picture. The reference quantization parameter QPpic—type(t) determined in rate control is modulated by N_actj, giving the final QPj for MB (j) in frame or field mode, that is, QPj=QPpic—type(t)+6×log2(N_actj). The range of modulation is controlled by β. For example, in one embodiment, β is set to a value of 2. The final QPj may need to be further clipped into the allowable range of [0,51].

Additional Buffer Protection: Assume that buffer_delay and decoder_buffer _size are the buffer delay and the decoder buffer size, respectively. The encoder buffer size can be set as buffer_size=min(buffer_delay, decoder_buffer_size). To prevent the overflow and underflow of both the encoder and decoder buffers, the target number of bits determined for the current picture in bit allocation, Tpic—target, may need to be checked. It is further assumed that the bits generated per picture are moved into the encoder buffer during an interval of 0 second, and the bits are moved out the encoder buffer at a constant rate of bit_rate/pic_rate
Assume that buffer_occupany is the buffer occupancy of the encoder buffer. Before encoding a picture, the target number of bits assigned for the picture is checked and, if necessary, adjusted as follows: if

buffer_occupany+Tpic—target>α×buffer_size, then

Tpic—target=α×buffer_size−buffer_occupancy, and if

buffer_occupany+Tpic—target−bit_rate/pic_rate<(1−α)×buffer_size, then

Tpic—target=(1−α)×buffer_size−buffer_occupancy+bit_rate/pic_rate,

where α is a constant, and can be set, for example, to be between 0.90 and 0.95

It is understood that this multi-panel rate control method for real-time video encoders may also be applied in other type of encoders. Those skilled in the art will appreciate that the various adaptations and modifications of the preferred embodiments of this method and apparatus can be configured without departing from the scope and spirit of the present method and apparatus. Therefore, it is to be understood that, within the scope of the appended claims, the present method and apparatus may be practiced other than as specifically described herein.

## Claims

1. A method for panel-based rate control for encoding real-time digital video, comprising:
performing bit allocation by assigning and updating a target rate for a group of pictures (GOP), and computing a target rate for a picture of type I, P or B in frame or field within said GOP from said target rate of said GOP, where said picture is processed on multiple panels; and
performing rate control by adjusting guantization parameters to achieve said target rates
protecting both encoder and decoder buffers from overflowing or underflowing before encoding a picture, wherein protecting the encoder buffers comprises checking and adjusting the target number of bits assigned for a picture according to the following two conditions: if


buffer_occupancy +Tpic—target>α×buffer_size, then



Tpic—target=α×buffer_size−buffer_occupancy; and if



buffer_occupancy+Tpic—target−bit−rate/pic_rate<(1−α)×buffer_size, then



Tpic—target=(1−α)×buffer_size−buffer—occupancy+bit_rate/pic_rate.

2. The method of claim 1, wherein the step of bit allocation further comprises budgeting a nominal number of bits (RGOP—nnominal) determined by the equation




  
    R
    
      GOP
      ⁢
      
        
      
      ⁢
      _
      ⁢
      
        
      
      ⁢
      nominal
    
  
  =
  
    
      N
      GOP
    
    ×
    
      bit_rate
      pic_rate
    
  




for a group of pictures (GOP), where NGOP is the length of the GOP, bit_rate is a target bit rate in bits per second, and pic_rate is a picture rate in pictures per second.

3. A method for panel-based rate control for encoding real-time digital video, comprising:
performing bit allocation by assigning and updating a target rate for a group of pictures (GOP), and computing a target rate for a picture of type I, P or B in frame or field within said GOP from said target rate of said GOP, where said picture is processed on multiple panels, wherein a central DSP computes said target rate for said picture of type intra picture (I), predictive coded picture (P), or bi-directional predictive coded picture (B), using the expressions





  
    T
    
      pic
      ⁢
      
        
      
      ⁢
      _
      ⁢
      
        
      
      ⁢
      type
    
  
  =
  
    
      
        K
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ⁢
      
        C
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ⁢
      
        R
        
          GOP
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          remaining
        
      
    
    
      
        
          
            
              
                K
                I
              
              ⁢
              
                n
                
                  pic
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              ⁢
              
                C
                
                  pic
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
            
            +
            
              
                K
                P
              
              ⁢
              
                n
                
                  pic
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
              ⁢
              
                C
                
                  pic
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  P
                
              
            
            +
          
        
      
      
        
          
            
              K
              B
            
            ⁢
            
              n
              
                pic
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                B
              
            
            ⁢
            
              C
              
                pic
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                B
              
            
          
        
      
    
  




for frame pictures, and




  
    T
    
      pic
      ⁢
      
        
      
      ⁢
      _
      ⁢
      
        
      
      ⁢
      type
    
  
  =
  
    
      
        K
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ⁢
      
        C
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ⁢
      
        R
        
          GOP
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          remaining
        
      
    
    
      
        
          
            
              
                K
                I
              
              ⁢
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
              ⁢
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  I
                
              
            
            +
            
              
                K
                P
              
              (
              
                
                  
                    n
                    
                      field
                      ⁢
                      
                        
                      
                      ⁢
                      0
                      ⁢
                      _
                      ⁢
                      
                        
                      
                      ⁢
                      P
                    
                  
                  ⁢
                  
                    C
                    
                      field
                      ⁢
                      
                        
                      
                      ⁢
                      0
                      ⁢
                      _
                      ⁢
                      
                        
                      
                      ⁢
                      P
                    
                  
                
                +
              
            
          
        
      
      
        
          
            
              
                
                  n
                  
                    field
                    ⁢
                    
                      
                    
                    ⁢
                    1
                    ⁢
                    
                      
                    
                    ⁢
                    _
                    ⁢
                    
                      
                    
                    ⁢
                    P
                  
                
                ⁢
                
                  C
                  
                    field
                    ⁢
                    
                      
                    
                    ⁢
                    1
                    ⁢
                    _
                    ⁢
                    
                      
                    
                    ⁢
                    P
                  
                
              
              )
            
            +
            
              
                K
                B
              
              ⁢
              
                n
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
              ⁢
              
                C
                
                  field
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  B
                
              
            
          
        
      
    
  




for field pictures, and
performing rate control by adjusting guantization parameters to achieve said target rates.

4. The method of claim 1 wherein the step of bit allocation further comprises initializing and updating the complexity measures of frame and field pictures of type I, P and B.

5. The method of claim 1 wherein the step of rate control further comprises updating the picture numbers of picture type I, P and B (NI, NP, and NB).

6. A method for panel-based rate control for encoding real-time digital video, comprising:
performing bit allocation by assigning and updating a target rate for a group of pictures (GOP), and computing a target rate for a picture of type I, P or B in frame or field within said GOP from said target rate of said GOP, where said picture is processed on multiple panels; and
performing rate control by adjusting guantization parameters to achieve said target rates, wherein the step of rate control further comprises determining six virtual buffer fullnesses, one for each picture of type I, P or B in frame or field, at a time instant t is using the expression





  
    
      
        d
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ⁡
      
        (
        t
        )
      
    
    =
    
      
        
          d
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ⁡
        
          (
          0
          )
        
      
      +
      
        
          α
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ×
        
          
            B
            
              pic
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              type
            
          
          ⁡
          
            (
            t
            )
          
        
      
      -
      
        
          
            
              MB
              
                pic
                ⁢
                
                  
                
                ⁢
                _
                ⁢
                
                  
                
                ⁢
                type
              
            
            ⁡
            
              (
              t
              )
            
          
          
            MB
            pic
          
        
        ⁢
        
          T
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
      
    
  
  ;




or the expression




  
    
      
        d
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ⁡
      
        (
        t
        )
      
    
    =
    
      
        
          d
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ⁡
        
          (
          0
          )
        
      
      +
      
        
          α
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ×
        
          
            B
            
              pic
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              type
            
          
          ⁡
          
            (
            t
            )
          
        
      
      -
      
        
          
            
              ∑
              
                i
                =
                0
              
              
                
                  MB
                  
                    pic
                    ⁢
                    
                      
                    
                    ⁢
                    _
                    ⁢
                    
                      
                    
                    ⁢
                    type
                  
                
                ⁡
                
                  (
                  t
                  )
                
              
            
            ⁢
            
              act
              i
            
          
          total_act
        
        ⁢
        
          T
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
      
    
  
  ,




if the bit budget per MB is assigned according to its need, where acti is the local activity measure of MB(i)




  
    total_act
    =
    
      
        ∑
        i
      
      ⁢
      
        
      
      ⁢
      
        act
        i
      
    
  
  ,




and the index i is over all the MBs in the current picture; or the expression




  
    
      
        d
        
          pic
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          type
        
      
      ⁡
      
        (
        t
        )
      
    
    =
    
      
        
          d
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ⁡
        
          (
          0
          )
        
      
      +
      
        
          α
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
        ×
        
          
            B
            
              pic
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              type
            
          
          ⁡
          
            (
            t
            )
          
        
      
      -
      
        
          
            
              ∑
              
                i
                =
                0
              
              
                
                  MB
                  
                    pic
                    ⁢
                    
                      
                    
                    ⁢
                    _
                    ⁢
                    
                      
                    
                    ⁢
                    type
                  
                
                ⁡
                
                  (
                  t
                  )
                
              
            
            ⁢
            
              cost
              i
            
          
          total_cost
        
        ⁢
        
          T
          
            pic
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            type
          
        
      
    
  
  ,




where costi is the cost measure of MB(i) and




  total_cost
  =
  
    
      ∑
      i
    
    ⁢
    
      
        cost
        i
      
      .

7. The method of claim 1, wherein the step of bit allocation further comprises handling scene changes in a GOP.

8. The method of claim 6, wherein a central DSP maintains and updates said six virtual buffers, and determines six quantization parameters,—QPpic—type, proportional to six virtual buffer fullnesses, one for each of the picture types I, P and B in frame or field.

9. The method of claim 8, wherein the central DSP sends the six quantization parameters to all the current pictures of I, P or B.

10. The method of claim 9, wherein the same quantization parameter is applied to all the panels (panel based architecture) in a picture until a new quantization parameter is received.

11. The method of claim 10, wherein a final quantization parameter for a macroblock (MB) j in frame or field mode in each panel is determined by using the expression QPj=QPpic—type(t)+6×log2(N_actj) where N_actj is the normalized local activity of MB j.

12. The method of claim 7, wherein no action occurs if a scene change occurs within a GOP and an I picture in the GOP is in a new scene, otherwise a first P picture in the new scene is changed to an I picture.

13. The method of claim 7, wherein a short or long GOP (“Irregular GOP”) is created and followed by a regular GOP.

14. The method of claim 13, wherein the length of the Irregular GOP is between 0.5 to 1.5 times the regular GOP length.

15. The method of claim 12, wherein the first P picture in the new scene is the Nth picture of the GOP.

16. The method of claim 15, wherein, if the first P picture is in the first half of the GOP, then the scheduled I picture in the GOP is changed to a P picture.

17. The method of claim 16, wherein the long and short GOPs, with lengths determined by the expressions NGOP=NGOP+(N−Nsub—GOP) and NGOP=NGOP−(N−Nsub—GOP),respectively, are created.

18. The method of claim 17, wherein the long GOP is followed by the short GOP.

19. The method of claim 17, wherein the corresponding GOP lengths for I, P and B frame and field pictures are determined by the expressions recited in claim 17 using an updated GOP length.

20. The method of claim 17, wherein the nominal numbers of bits for the long and short GOPs are determined using the expressions



  
    
      R
      
        GOP
        ⁢
        
          
        
        ⁢
        _
        ⁢
        
          
        
        ⁢
        nominal
      
    
    =
    
      
        R
        
          GOP
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          nominal
        
      
      +
      
        
          
            N
            -
            
              N
              sub_GOP
            
          
          
            N
            GOP
          
        
        ×
        
          R
          
            GOP
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            nominal
          
        
        ⁢
        
          
        
        ⁢
        and
      
    
  




  
    
      
        R
        
          GOP
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          nominal
        
      
      =
      
        
          R
          
            GOP
            ⁢
            
              
            
            ⁢
            _
            ⁢
            
              
            
            ⁢
            nominal
          
        
        -
        
          
            
              N
              -
              
                N
                sub_GOP
              
            
            
              N
              GOP
            
          
          ×
          
            R
            
              GOP
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              nominal
            
          
        
      
    
    ,
  



respectively.

21. The method of claim 15, wherein, if the first P in the new scene is in the second half of the GOP, then the scheduled I picture in the next GOP is changed to a P picture.

22. The method of claim 21, wherein the short and long GOPs with lengths determined by the expressions NGOP=N−Nsub—GOP and NGOP=2×NGOP−(N−Nsub—GOP),respectively, are created.

23. The method of claim 22, wherein the short GOP is followed by the long GOP.

24. The method of claim 23, wherein the corresponding GOP lengths for I, P and B frame and field pictures are determined by the expressions recited in claim 24 using an updated GOP length.

25. The method of claim 23, wherein the nominal numbers of bits for the long and short GOPs are determined using the expression



  
    
      R
      
        GOP
        ⁢
        
          
        
        ⁢
        _
        ⁢
        
          
        
        ⁢
        nominal
      
    
    =
    
      
        
          N
          -
          
            N
            sub_GOP
          
        
        
          N
          GOP
        
      
      ×
      
        R
        
          GOP
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          nominal
        
      
      ⁢
      
        
      
      ⁢
      and
    
  




  
    
      
        R
        
          GOP
          ⁢
          
            
          
          ⁢
          _
          ⁢
          
            
          
          ⁢
          nominal
        
      
      =
      
        
          2
          ×
          
            R
            
              GOP
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              nominal
            
          
        
        =
        
          
            
              N
              -
              
                N
                
                  sub
                  ⁢
                  
                    
                  
                  ⁢
                  _
                  ⁢
                  
                    
                  
                  ⁢
                  GOP
                
              
            
            
              N
              GOP
            
          
          ×
          
            R
            
              GOP
              ⁢
              
                
              
              ⁢
              _
              ⁢
              
                
              
              ⁢
              nominal
            
          
        
      
    
    ,
  



respectively.

26. A video data coding-apparatus comprising:
a processor;
an input/output device;
a memory; and
a video encoding module that performs bit allocation by assigning a target number of bits per GOP, performs rate control by adjusting the quantization parameter QP to achieve said target number of bits, and performs adaptive quantization by modulating the quantization parameter using the local activity measure wherein the step of rate control further comprises determining six virtual buffer fullnesses, one for each picture of type I, P or B in frame or field, at a time instant t is using the expression





  
    
      
        d
        
          pic
          ⁢
          _
          ⁢
          type
        
      
      ⁡
      
        (
        t
        )
      
    
    =
    
      
        
          d
          
            pic
            ⁢
            _
            ⁢
            type
          
        
        ⁡
        
          (
          0
          )
        
      
      +
      
        
          α
          
            pic
            ⁢
            _
            ⁢
            type
          
        
        ×
        
          
            B
            
              pic
              ⁢
              _
              ⁢
              type
            
          
          ⁡
          
            (
            t
            )
          
        
      
      -
      
        
          
            
              MB
              
                pic
                ⁢
                _
                ⁢
                type
              
            
            ⁡
            
              (
              t
              )
            
          
          
            MB
            pic
          
        
        ⁢
        
          T
          
            pic
            ⁢
            _
            ⁢
            type
          
        
      
    
  
  ;




or the expression




  
    
      
        d
        
          pic
          ⁢
          _
          ⁢
          type
        
      
      ⁡
      
        (
        t
        )
      
    
    =
    
      
        
          d
          
            pic
            ⁢
            _
            ⁢
            type
          
        
        ⁡
        
          (
          0
          )
        
      
      +
      
        
          α
          
            pic
            ⁢
            _
            ⁢
            type
          
        
        ×
        
          
            B
            
              pic
              ⁢
              _
              ⁢
              type
            
          
          ⁡
          
            (
            t
            )
          
        
      
      -
      
        
          
            
              ∑
              
                i
                =
                0
              
              
                
                  MB
                  
                    pic
                    ⁢
                    _
                    ⁢
                    type
                  
                
                ⁡
                
                  (
                  t
                  )
                
              
            
            ⁢
            
              
            
            ⁢
            
              act
              i
            
          
          total_act
        
        ⁢
        
          T
          
            pic
            ⁢
            _
            ⁢
            type
          
        
      
    
  
  ,




if the bit budget per MB is assigned according to its need, where acti is the local activity measure of MB(i),




  
    total_act
    =
    
      
        ∑
        i
      
      ⁢
      
        
      
      ⁢
      
        act
        i
      
    
  
  ,




and the index i is over all the MBs in the current picture; or the expression




  
    
      
        d
        
          pic
          ⁢
          _
          ⁢
          type
        
      
      ⁡
      
        (
        t
        )
      
    
    =
    
      
        
          d
          
            pic
            ⁢
            _
            ⁢
            type
          
        
        ⁡
        
          (
          0
          )
        
      
      +
      
        
          α
          
            pic
            ⁢
            _
            ⁢
            type
          
        
        ×
        
          
            B
            
              pic
              ⁢
              _
              ⁢
              type
            
          
          ⁡
          
            (
            t
            )
          
        
      
      -
      
        
          
            
              ∑
              
                i
                =
                0
              
              
                
                  MB
                  
                    pic
                    ⁢
                    _
                    ⁢
                    type
                  
                
                ⁡
                
                  (
                  t
                  )
                
              
            
            ⁢
            
              
            
            ⁢
            
              act
              i
            
          
          total_cost
        
        ⁢
        
          T
          
            pic
            ⁢
            _
            ⁢
            type
          
        
      
    
  
  ,




where costi is the cost measure of MB(i) and




  total_cost
  =
  
    
      ∑
      i
    
    ⁢
    
      
        cost
        i
      
      .

27. The video data coding apparatus of claim 26, wherein the video encoding module checks and adjusts the target number of bits assigned for a picture to prevent the system from overflowing and underflowing.

28. The video data coding apparatus of claim 26, wherein the video encoding module budgets a nominal number of bits for a GOP, assigns each picture of type I, P, or B a target number of bits, and initializes and updates the complexity measures of frame and field pictures.

29. The video data coding apparatus of claim 26, wherein the video encoding module updates the picture numbers of picture type I, P or B, determines the fullness of six virtual buffers, and maintains and updates said virtual buffers.

30. The video data coding apparatus of claim 26, wherein the video encoding determines the quantization parameter for the MB in frame or field mode and modulates said quantization parameter using a local activity measure.

31. The video data coding apparatus of claim 26, wherein the video encoding module generates, updates, and applies six quantization parameters to all the panels in a picture of type I, P or B.

32. The video coding apparatus of claim 26, wherein the video encoding module is capable of handling scene changes.

33. The method of claim 3, wherein the step of bit allocation further comprises budgeting a nominal number of bits (RGOP—nominal) determined by the equation




  
    R
    
      GOP
      ⁢
      _
      ⁢
      nominal
    
  
  =
  
    
      N
      GOP
    
    ×
    
      bit_rate
      pic_rate
    
  




for a group of pictures (GOP), where NGOP is the length of the GOP, bit_rate is a target bit rate in bits per second, and pic_rate is a picture rate in pictures per second.

34. The method of claim 3, wherein the step of bit allocation further comprises initializing and updating the complexity measures of frame and field pictures of type I, P and B.

35. The method of claim 3, wherein the step of rate control further comprises updating the picture numbers of picture type I, P and B (NI, NP, and NB)

36. The method of claim 6, wherein the step of bit allocation further comprises budgeting a nominal number of bits (RGOP—nominal) determined by the equation




  
    R
    
      GOP
      ⁢
      _
      ⁢
      nominal
    
  
  =
  
    
      N
      GOP
    
    ×
    
      bit_rate
      pic_rate
    
  




for a group of pictures (GOP), where NGOP is the length of the GOP, bit_rate is a target bit rate in bits per second, and pic_rate is a picture rate in pictures per second.

37. The method of claim 6, wherein the step of bit allocation further comprises initializing and updating the complexity measures of frame and field pictures of type I, P and B.

38. The method of claim 8, wherein the step of rate control further comprises updating the picture numbers of picture type I, P and B (NI, NP, and NB)