Abstract:
A transmitter for transmitting a plurality of digital signals through a plurality of channels, the channels having a predetermined total allocated bitrate, includes a plurality of encoders each associated with one channel, a multiplexer for receiving the encoded digital signals and for transmitting the encoded signals as a stream of data, and operable for adjusting the distribution of the bitrate allocation between and among the encoded signals, and a processing device for providing an indication of a target quality and an actual quality for each channel and for causing the multiplexer to repeatedly adjust the distribution of the bitrate allocation in response to differences between the indicated actual quality and the indicated target quality for each channel so as to equalize differences between the actual and target quality across at least some of the channels. By grouping encoders together in “statistical multiplex groups”, and making real time decisions about the bitrate requirements for those encoders, bitrate can be allocated to maximize picture quality for the group. For a variety of different picture sources in a statistical multiplex group, to achieve a target picture quality the bitrate requirements of each will vary with coding difficulty. Thus, a channel within the statistical multiplex group that is experiencing little difficulty in encoding its picture can free bits to channels that are having greater difficulty. The effect is to smooth the picture quality and subjectively improve it.

Description:
CROSS-REFERENCE TO RELATED APPLICATION 
     This application is a continuation of U.S. patent application Ser. No. 08/700,877 filed Aug. 21, 1996, now U.S. Pat. No. 5,708,664. 
    
    
     FIELD OF THE INVENTION 
     The present invention relates to the transmission of digital signals such as digitally encoded video signals and, more particularly, to the simultaneous transmission of a number of different signals, from different sources, via a single transmission medium. 
     BACKGROUND OF THE INVENTION 
     It is well known to multiplex a plurality of signals for transmission via a single transmission medium. In particular for digital systems, this is done by assigning a predetermined proportion of the total bitrate available in the transmission medium to each of the signals that it is desired to transmit. The proportion of the available bitrate assigned to each signal is fixed in each system. 
     These types of systems are often referred to as Variable Quality Fixed Bitrate systems; FIG. 2 presents an illustration of such a system. The FIG. 2 system includes a number of encoders  20 ,  20   1 ,  20   2  . . .  20   n  connected to a Multiplexer (MUX)  22 . A video signal is transmitted through each of the encoders such that a plurality of fixed bitrate signals  24 ,  24   1 ,  24   2  . . .  24   n  are transmitted to the MUX  22 . Each video signal, by way of typical example, constitutes a different television channel. A Multiplex Control Computer (MCC)  26  controls the output from the MUX so that a satellite signal  28  is generated which includes all of the television channels. The satellite signal is then transmitted, via a satellite (not shown), to a receiver station (not shown) which receives the satellite signal and decodes it back into the plural different television channels. The full details of the decoding operations do not form a part of the present invention and are accordingly not described in detail herein. 
     One problem with such systems is associated with the fact that, in practice, some video pictures require a much higher bitrate than others to achieve acceptable picture quality. In the above-mentioned arrangement, for example, it may be that the signals from some picture sources or television channels cannot be properly encoded using the available bitrate, while others do not require all of the bitrate capacity that is available to them. 
     In the conventional Fixed Bitrate, Variable Quality system, encoders are allocated a bitrate by the MCC as described above. This bitrate is then fixed for the duration of the MCC schedule. Thus, an encoder in the fixed bitrate system cannot respond to changes in criticality of the source video, as a result of which the picture quality of the decoded output of a fixed bitrate encoder varies with the criticality of the picture material. As the picture material becomes more demanding (i.e. contains more motion and complexity), the picture quality will decrease and the decoded output will contain more encoding artifacts. This is clearly undesirable. 
     One object of the present invention is to therefore provide a system or arrangement which overcomes at least some of the limitations of known systems. 
     SUMMARY OF THE INVENTION 
     In general terms, the present invention provides a method of transmitting a plurality of digital signals through a plurality of channels, the channels having a predetermined total bitrate allocated to them, and the method including the steps of encoding each digital signal, multiplexing the encoded signals, adjusting the distribution of the bitrate allocation between the channels in response to a control system, providing an indication of a target quality for each channel, providing an indication of the actual quality of each channel, and repeatedly adjusting the distribution of the bitrate allocation in response to differences between the indicated actual quality and the indicated target quality for each channel so as to tend to equalize the difference between the actual and target quality across some or all of the channels. 
     Preferably, the invention further includes the steps of grouping the channels into groups, assigning a bitrate to the group, and varying the individual bitrates of each channel in the group such that the total bitrate of the group approximates the assigned bitrate. 
     Preferably, and advantageously, the encoding step comprises encoding the digital signals with an encoder having an adjustable bitrate. 
     Advantageously, the digital signals are digital television signals provided as a data stream representing a plurality of frames, the adjustment of the bitrate is carried out as often as possible (but preferably once every frame), and the actual and target qualities are the actual and target picture qualities. 
     The present invention thus aims to provide an improved multiplex arrangement, overcoming or at least effectively minimizing the problem in prior art systems as described hereinabove. In principle, by grouping encoders together in what will be termed herein “statistical multiplex groups”, and making real time decisions about the bitrate requirements for those encoders, bitrate can be dynamically allocated to maximize picture quality for the group. 
     The theory is that for a variety of different picture sources in a statistical multiplex grouping, to achieve a target picture quality the bitrate requirements of each will vary with coding difficulty. Thus, a channel within the statistical multiplex group that is experiencing little difficulty in encoding its picture can free bits to channels that are having greater difficulty. The effect is to smooth the picture quality and to subjectively improve it. 
     In a preferred arrangement, the adjustment of the bitrate of each encoder is determined in relation to an achievable picture quality, the ratio of the achievable picture quality to the target picture quality being the same for each channel. 
     In accordance with the present invention, there is also provided a transmitter for transmitting a plurality of digital signals through a plurality of channels, the channels having a predetermined total bitrate allocated to them, and including a plurality of encoders (one associated with each channel), a multiplexer for receiving the encoded digital signals and transmitting them as a stream of data and capable of adjusting the distribution of the bitrate allocation between the encoded signals, and processing means for providing an indication of a target quality and an actual quality for each channel and causing the multiplexer to repeatedly adjust the distribution of the bitrate allocation in response to differences between the indicated actual quality and the indicated target quality for each channel so as to tend to equalize the difference between the actual and target quality across some or all of the channels. 
     Other objects and features of the present invention will become apparent from the following detailed description considered in conjunction with the accompanying drawings. It is to be understood, however, that the drawings are designed solely for purposes of illustration and not as a definition of the limits of the invention, for which reference should be made to the appended claims. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     In the drawings, wherein like reference characters denote similar elements throughout the several views: 
     FIG. 1 is a block diagram of a television transmission and receiving system; 
     FIG. 2 is a block diagram of a prior art Variable Quality Fixed Bitrate system; 
     FIG. 3 is a block diagram of an apparatus constructed in accordance with and for implementing the present invention; 
     FIG. 4 is a graph of bitrate versus linear quality; and 
     FIG. 5 is a listing of the statistical multiplex allocation algorithm. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     As mentioned hereinabove, the present invention relates to a method and apparatus for transmitting digital television signals through a plurality of transmission channels, FIG. 1 shows a typical transmission and receiving system. A signal  10 , such as a video signal, is input into a transmission channel  12 , described in additional detail below. The signal undergoes signal processing as it passes through the transmission channel and a transmission signal  14  is generated. The transmission signal is then transmitted to a receiver  16  where it is converted back into, for example, a video signal. This recovered video signal may then be either displayed for viewing or retransmitted to another receiver, if necessary. In the FIG. 1 system, the transmission from the transmission end to the receiver end is by way of a satellite  18  although, as should be apparent, various other means of transmission may alternatively be used in place of satellite transmission. 
     Referring now to FIG. 3, each transmission channel includes a digital encoder. The encoders  30 ,  30   1 ,  30   2  . . .  30   n  have a combined total bitrate (or group bitrate) allocated to them and a multiplexer  32  is provided to multiplex the digital signals from the encoders. The multiplexer apportions the group bitrate to the individual encoders in such a way as to meet the individual requirements of each encoder at that point in time. This statistically multiplexed system will be referred to herein as a statistical multiplex system. In the preferred embodiment described in detail hereinbelow, a system control unit signals to the multiplexer a linear target picture quality of each channel. This target quality may be determined by the user (or broadcaster), or may be determined statistically or under the control of a Multiplex Control Computer (MCC)  34 . The target quality is a measure of the picture quality that the user expects the encoder to achieve. By allocating a higher than average target quality to one of the encoders in the statistical multiplex group, the user is able to attach or associate a preference to that channel over the remaining channels in the group. 
     Each encoder has a bitrate which is variable for adjusting the linear picture quality in the channel thereof and each encoder includes means to signal to the multiplexer an indication of the linear picture quality in its channel. The multiplexer is operative to poll the encoders interactively to receive or obtain an indication of picture quality from each channel and is connected through a control network for varying the bitrates of the encoders so as to distribute the total allocated bitrate between the encoders. When allocating new bitrates to the encoders, the MUX must ensure that the new bitrate will not infringe any decoder buffer models and does not exceed any bitrate limits specified by the user. Thus, the statistical multiplex system is operative for responding to variations in the criticality of source material, and for adjusting the operation of one or more of the encoders within the statistical multiplex group, so as to optimize operation of the system. The distribution of the total bitrate is such as to tend to equalize the percentage difference between the actual and target linear picture quality for all of its encoders. 
     In the statistical multiplex system of the invention, the multiplexer is the master and must communicate with the encoders slaved to it as often as possible if variations in picture difficulty are to be fully exploited. To exploit the potential of this invention, bitrate requirements should be re-assessed for each encoder as often as possible. The multiplexer may by way of example communicate with the encoders connected to it via a dedicated fast communications network that connects the multiplexer to each of the encoders. 
     It is the task of the multiplexer to divide the total available bitrate between the encoders in a statistical multiplex group in such a way as to achieve the target quality of each encoder. The multiplexer then continually assesses the performance of each encoder and dynamically adjusts bitrates to keep the actual quality reported by the encoder as close to the target quality as possible. Other secondary tasks of the multiplexer are: 
     (i) to keep the system controller or MCC  34  informed on how realistic the target quality figures are for the total available bitrate, i.e. how well the encoders are achieving target quality figures; and 
     (ii) to ensure that maximum and minimum boundaries are not exceeded for each encoder, or that bitrate changes allocated to an encoder do not cause decoder buffer over- or under-flow. 
     The unit of exchange between the encoder and multiplexer, and the system control computer, must be some measure of picture quality rather than bitrate. A measure of linear quality is required where a quality figure could vary from one to 100, one (i.e. the low end of the linear scale) being a “very poor picture” and 100 (i.e. the upper end of the scale) being “perfect picture quality”. Linear quality has been chosen rather than bitrate because: 
     (a) It is unacceptable for the user to have to understand the subtleties of bitrate versus actual picture quality; and 
     (b) Actual picture quality is affected by many parameters, not just bitrate—e.g. rate of frame cuts. 
     It should be noted that different channels allocated the same linear quality target figure may have different bitrate requirements. 
     Once the task of the statistical multiplex system has been completed, the output signal produced by the MUX may be modulated through a modulator  36  to produce a modulated signal which is transmitted to a remote receiver  38 . The MUX may communicate with the encoders in order to control their operation by means of a communication network  40 . 
     The mathematics of the Multiplexer Statistical Multiplex Function will now be described in more detail. 
     The multiplexer polls each encoder i=1 . . . N, for its current picture quality Q i . The quality, target quality Q T     i    and the current bitrate B 1  are then used to compute new encoder bitrates B NEXT     i    with the aim of matching encoder picture quality to the target quality. 
     The total group bitrate B TOTAL  is defined as                B   TOTAL     =       ∑     i   =   1     N                     B   i               (   1   )                                
     For any given set of channels within a statistical multiplex group, B TOTAL  will be constant. However the total bitrate required to achieve the target qualities will in general not be equal to B TOTAL . This total bitrate mismatch can be removed by aiming to set the quality of all encoders to some fixed ratio ω of their target quality. The ratio w is set such that the sum of the bitrates required to achieve ωQ T     i    for each encoder is equal to the total group bitrate B TOTAL . The relationship between the ratio ω and the target and actual qualities is derived below. 
     The encoder bitrate quality relationship is modeled as 
     
       
         B i =M i Q i   a     i     (2) 
       
     
     The next bitrates are assigned such that the total bitrate B TOTAL  is constant, i.e.                      ∑     i   =   1     N                     B   i       +     ∂     B   i         =     B   TOTAL       ,       or                 alternatively                     ∑     i   =   1     N                     ∂     B   i           =   0             (   3   )                                
     The change in bitrate ∂B i  can be written as,                ∂     B   i       =         α   i          M   i          Q   i       α   1     -   1            ∂     Q   1         =           α   i          B   i         Q   i            ∂     Q   i                   (   4   )                                
     but the encoder quality at the next iteration is set to ωQ T     i   ; therefore the change in ∂Q i  can be written as 
     
       
         ∂Q i =(ωQ T     i    Q i )  (5) 
       
     
     Substituting (5) into (4) and (3) allows ω to be computed as,              ω   =         ∑     i   =   1     N                       α   i          B   i             ∑     i   =   1     N                         α   i          B   i          Q     T   i           Q   i                   (   6   )                                
     This can be simplified by making the assumption, α i =α for each encoder, and the variable name substitution          ϒ   i     =         B   i          Q     T   i           Q   i                              
     Thus, the ratio can be written as              ω   =       B   TOTAL         ∑     i   =   1     N                     γ   i                 (   7   )                                
     and the new encoder bitrate B NEXT     i    can be written as 
      B next     i   =B i +∂B 1   
                     B     next   i       =       B   i     +     α        (             B   i          Q     T   i           Q   i          ω     +     B   i       )                 (   8   )                               B next     i   =(1−α)B i +γ i ω 
     Thus, the statistical multiplex processing algorithm to update the encoder bitrates for a single statistical multiplex group can be written as for example shown in FIG.  5 . 
     The basic bitrate allocation algorithm has no constraints on the bitrate. The algorithm can be shown to allocate bitrates such that the total group bitrate is a constant, even if an individual encoder is assigned a negative bitrate. Thus, the algorithm needs some constraints on bitrate in order to work. Incorporating bitrate constraints into the algorithm also has the advantage that the operator can specify a permissible bitrate range for each encoder so that the statistical multiplex algorithm must choose bitrates from within this range. An iterative application of the algorithm may be used to assign bitrates within specified limits. The iterative algorithm uses three simple rules: 
     (1) The encoder bitrate is computed as if unconstrained; 
     (2) If the new bitrates are outside of the bitrate limits then they are clipped to the limits; and 
     (3) If bitrate is clipped to the minimum limit, then the bitrate assignment algorithm has less bitrate to assign to other encoders than it assumed (as it couldn&#39;t remove bitrate from the clipping encoder due to the lower bitrate limit). Therefore, if any encoder clips bitrate at the lower limit then all non-lower clipping or non-normalizing encoders must be re-assigned bitrates from the remaining bitrate left over. 
     Where the bitrates allocated undesireably oscillate between high and low values, this problem can be overcome by scaling the bitrate changes down by some factor ε which is chosen to be less than 1. In that instance, the derivation of B NEXT     i    is almost the same as that described above, except that all occurrences of ∂B i , are replaced by ∂B i ε. 
     The table below identifies the variables in the algorithm detailed above. 
     
       
         
               
               
             
           
               
                   
               
               
                 Algorithm Variable 
                 Description 
               
               
                   
               
             
             
               
                 N 
                 number of encoders in statistical multiplex group 
               
               
                 B TOTAL   
                 total bitrate for statistical multiplex group 
               
               
                 B TAKEN   
                 sum of bitrates currently assigned to encoders 
               
               
                 B i   
                 current bitrate for encoder i 
               
               
                 B NEXT     i     
                 next bitrate for encoder i 
               
               
                 Q i   
                 current quality for encoder i 
               
               
                 Encoders Assigned 
                 number of encoders with assigned bitrates 
               
               
                 Encoders To Be 
                 number of encoders 
               
               
                 Assigned 
               
               
                 U 
                 set of encoder numbers for encoders with 
               
               
                   
                 unassigned bitrates 
               
               
                 B MAX     —     MCC     i     
                 MCC defined maximum bitrate 
               
               
                 B MIN     —     MCC     i     
                 MCC defined minimum bitrate 
               
               
                 B MAX     —     INST     i     
                 encoder specified maximum instantaneous bitrate 
               
               
                   
                 without need for renormalizing 
               
               
                 B MIN     —     INST     i     
                 encoder defined minimum instantaneous bitrate 
               
               
                   
                 without need for renormalizing 
               
               
                 B MAX     i     
                 effective maximum bitrate which is the more 
               
               
                   
                 stringent of the MCC and encoder limits 
               
               
                 B MIN     i     
                 effective minimum bitrate which is the more 
               
               
                   
                 stringent of the MCC and encoder limits 
               
               
                   
               
             
          
         
       
     
     Further details of examples of algorithms for use in the practice and implementation of the present invention are shown in the Appendix hereto. 
     In general, the statistical multiplex system will be controlled by the user through the MCC  34 . The MCC will allow the user to specify for each encoder connected to the MUX whether the encoder is running statistical multiplex or fixed bitrate. If it is running statistical multiplex, then the user can specify the group to which that encoder is assigned. The user can also set the group bitrates for the statistical multiplex groups and the target qualities for each encoder in a statistical multiplex group. In addition, the user can specify upper and lower bitrates within which limits the individual encoders are constrained. This is an optional limit that will ensure that no one channel is caused to operate at a bitrate that is so low that the picture quality is completely unacceptable. Broadcasters may create new statistical multiplex groups or add or remove encoders from existing groups in a live system. Thus, it will be possible to have a number of statistical multiplex groups operating together and in a broadcasting system. It will be preferable to ensure that no one group has too many channels where long term high bitrates will be needed, so that the system is optimized. 
     The main advantages of using the inventive statistical multiplex system, as above described, include the following: 
     a) In a statistical multiplex system, the encoders are able to respond to changing criticality of the source video material, so that the picture quality of the encoder is smoothed. The removal of the peaks of poor picture quality will produce a subjectively better result. 
     b) A statistical multiplex system removes the burden from broadcasters of producing complex schedules. Even simple material such as ‘Talking Heads’ News programs can contain critical sections of material such as sports. These critical sections require a much higher bitrate in order for the material to be of acceptance quality to the user. Thus, a statistical multiplex system removes the need for broadcasters to have to predict these sequences and schedule a bitrate change. The statistical multiplex system can respond very quickly to changes in the material being transmitted. 
     c) The statistical multiplex system exploits the non-linearity in the relationship between bitrate and picture quality, such that several normally low bitrate channels can benefit significantly during lulls in demand on a high bitrate channel. 
     d) In a fixed bitrate system, significant amounts of bitrate can be wasted by the transmission of stuffing. This will not occur in a statistical multiplex system. 
     e) Specifying a quality for a channel, rather than a bitrate, will help broadcasters convince advertisers and program makers that their material is receiving fair treatment regardless of which channel it is on. Since the statistical multiplex system preferably reacts on a frame by frame basis, there is little or no chance of critical picture information not being shown at the best possible bitrate available at the time. 
     f) Seamless bitrate changing functionality is a minimum requirement for an encoder in the statistical multiplex system. Accordingly, a statistical multiplex system may be used in a fixed bitrate manner and still provide advantages and flexibility over prior art fixed bitrate systems. 
     It will be possible and desireable in certain applications to provide a system with more than one statistical multiplex group and associated circuitry. In such a system, it is possible to ‘statistically multiplex’ two or more ‘statistical multiplex groups’ as described herein under the control of the MCC. 
     It should also be understood that the invention is relevant and applicable to other types of signals than video signals. For example, audio and/or data signals may in some situations require or benefit from statistical multiplexing. In addition, a combination of one or more different types of signal may be processed in accordance with the present invention. 
     Thus, while there have been shown and described and pointed out fundamental novel features of the invention as applied to preferred embodiments thereof, it will be understood that various omissions and substitutions and changes in the form and details of the disclosed invention may be made by those skilled in the art without departing from the spirit of the invention. It is the intention, therefore, to be limited only as indicated by the scope of the claims appended hereto. 
     
       
         
               
               
               
             
               
               
             
               
               
             
               
               
             
               
               
               
             
               
               
             
               
               
               
             
               
               
             
               
               
             
               
               
               
             
               
               
             
               
               
             
               
               
               
             
               
               
               
             
               
               
               
             
               
               
             
               
               
               
             
               
               
             
               
               
               
             
               
               
             
               
               
             
               
               
               
             
               
               
               
             
               
             
               
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 Variable Initialisation 
                   
               
               
                   
                 EncodersAssigned = 0 
                 /* initially none of the encoders have been assigned new bitrates */ 
               
               
                   
                 B TOTAL  = Statistical multiplex Group Bitrate 
                 /* total bitrate assigned to statistical multiplex group */ 
               
               
                   
                 B TAKEN  = 0 
                 /* as yet no bitrate has been assigned to encoders */ 
               
               
                   
                 U = {0,1,2, . . . , N − 1} 
                 /* set of encoders with unset bitrates, initially U includes all encoders */ 
               
               
                   
                 μ = αε 
                 /* α is approx. 2 and ε &lt;&lt;1, therefore μ in the range 0.1 to 0.5 is suitable */ 
               
               
                   
                   
                 /* The value of ε effects the damping of the bitrate assignments - if is low then */ 
               
               
                   
                   
                 /* encoder bitrates changes occur over a longer time. */ 
               
               
                   
                 for (i=0; i&lt;N; ++ i) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 send status request to encoders 
               
               
                   
                 read status response data from encoder, i.e. 
               
             
          
           
               
                   
                  B MAX     —     INST     i   , 
               
               
                   
                 B MIN     —     INST     i   , 
               
               
                   
                 B i , 
               
               
                   
                 Q i , 
               
               
                   
                 RenormFlag i   
               
             
          
           
               
                   
                 /* set B MAX     i    and B MIN     i    to be the more stringent of the bitrate limits */ 
               
               
                   
                 set B MAX     i    = Minimum(B MAX     —     INST     i   , B MAX     —   MCC   i   ) 
               
               
                   
                 set B MIN     i    = Maximum(B MIN     —     INST     i   , B MIN     —   MCC   i   ) 
               
               
                   
                 /* compute γ i , which is a useful ratio for bitrate assignment */ 
               
               
                   
                   
               
               
                   
                 
                   
                     
                       
                         
                           
                             se 
                              
                             tγ 
                           
                           i 
                         
                         = 
                         
                           
                             
                               B 
                               i 
                             
                              
                             
                               Q 
                               
                                 T 
                                 i 
                               
                             
                           
                           
                             Q 
                             i 
                           
                         
                       
                     
                             
                     
                         
                     
                   
                 
               
               
                   
                   
               
               
                   
                 if(RenormFlag i ) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 State i  = RENORMALISING 
                  /* encoder state is renormalised, hence bitrate is assumed*/ 
               
               
                   
                 B next     i    = B i   
                 /* to be set to its highest value */ 
               
               
                   
                 B TAKEN  = B TAKEN  + B next     i     
                 /* add bitrate taken by this encoder to B TAKEN  */ 
               
               
                   
                 EncodersAssigned = EncodersAssigned+1 
                 /* increment number of encoders with assigned bitrates */ 
               
               
                   
                 Remove i from set U 
                 /* take encoder out of set of encoders with unset bitrates */ 
               
             
          
           
               
                   
                 } 
               
               
                   
                 else 
               
               
                   
                 { 
               
             
          
           
               
                   
                 State i  = NOTSET 
                  /* encoder state is bitrate not set (as yet) */ 
               
             
          
           
               
                   
                 } 
               
               
                 } 
                 /* end for loop */ 
               
             
          
           
               
                   
                 Bitrate Assignment 
               
               
                   
                 /* now encoder parameters have been read and all renormalsing encoders have had their bitrates set */ 
               
               
                   
                 /*  enter loop to set bitrates of all remaining encoders i where i ⊂ U */ 
               
               
                   
                 do 
               
               
                   
                 { 
               
             
          
           
               
                   
                 LowerClippedFlag = FALSE 
                  /* initialise flag indicating encoder bitrate B next     i    &lt; B MIN     i    */ 
               
               
                   
                 UpperClippedFlag = FALSE 
                 /* initialise flag indicating encoder bitrate B next     i    &gt; B MAX     i    */ 
               
               
                   
                   
               
               
                   
                 
                   
                     
                       
                         w 
                         = 
                         
                           
                             
                               B 
                               TOTAL 
                             
                             - 
                             
                               B 
                               TAKEN 
                             
                             - 
                             
                               
                                 ( 
                                 
                                   1 
                                   - 
                                   μ 
                                 
                                 ) 
                               
                                
                               
                                 
                                   ∑ 
                                   icU 
                                 
                                  
                                 
                                     
                                 
                                  
                                 
                                   B 
                                   i 
                                 
                               
                             
                           
                           
                             μ 
                              
                             
                               
                                 ∑ 
                                 
                                   i 
                                    
                                   cU 
                                 
                               
                                
                               
                                   
                               
                                
                               
                                 γ 
                                 i 
                               
                             
                           
                         
                       
                     
                             
                     
                         
                     
                   
                 
                 /* compute W for encoders with NOTSET state */ 
               
               
                   
                   
               
               
                   
                 set EncodersToBeAssigned = N - EncodersAssigned 
                 /* get copy of number of encoders to be assigned bitrates */ 
               
               
                   
                 for(i=0; i&lt;n; ++i) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 if(EncoderState i  == NOTSET) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 /* compute bitrate to assign to encoder */ 
               
               
                   
                 if (EncodersToBeAssigned &gt; 1) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 B next     i    = (1 − μ)B i  + wμγ i   
                   /* compute new bitrate */ 
               
             
          
           
               
                   
                 } 
                   
               
               
                   
                 else 
               
               
                   
                 { 
                 /* as encoder is last one to have bitrate set */ 
               
             
          
           
               
                   
                 B next     i    = B TOTAL  − B TAKEN   
                   /* assign all remaining bits to this encoder */ 
               
             
          
           
               
                   
                 } 
               
               
                   
                 /* now check bitrate against limits */ 
               
               
                   
                 if (B next     i    &gt; B MAX     i   ) 
               
               
                   
                 } 
               
             
          
           
               
                   
                 B next = B MAX     i     
                   /* clip bitrate against B MAX     i    */ 
               
               
                   
                 UpperClippedFlag = TRUE 
                 /* note fact that allocated bitrate has been limited 
               
               
                 /* 
               
               
                   
                 EncoderState i =UPPERCLIPPED 
                 /* record encoder state */ 
               
               
                   
                 B TAKEN  = B TAKEN  + B next     i     
                 /* add bitrate taken by this encoder to B TAKEN   
               
               
                 /* 
               
               
                   
                 EncodersAssigned = EncodersAssigned+1 
                 /* inc number of encoders with assigned bitrates 
               
               
                 */ 
               
               
                   
                 Remove i from set U 
                 /* take encoder out of set of encoders with unset 
               
               
                 */ 
               
             
          
           
               
                   
                 } 
               
               
                   
                 else if (B next     i    &lt; B MIN     i   ) 
               
               
                   
                 } 
               
             
          
           
               
                   
                 B next     i    = B MIN     i     
                   /* clip bitrate against B MIN     i    */ 
               
               
                   
                 LowerClippedFlag = TRUE 
                 /* note fact that allocated bitrate has been limited 
               
               
                 */ 
               
               
                   
                 EncoderState i =UPPERCLIPPED 
                 /* record encoder state */ 
               
               
                   
                 B TAKEN  = B TAKEN  + B next     i     
                 /* add bitrate taken by this encoder to B TAKEN   
               
               
                 */ 
               
               
                   
                 EncodersAssigned = EncodersAssigned+1 
                 /* inc number of encoders with assigned bitrates 
               
               
                 */ 
               
               
                   
                 Remove i from set U 
                 /* take encoder out of set of encoders with unset 
               
               
                 */ 
               
             
          
           
               
                   
                 } 
               
               
                   
                 else 
               
               
                   
                 { 
               
             
          
           
               
                   
                 /* even though a bitrate has been assigned still treat the encoder state as NOTSET */ 
               
               
                   
                 /* if bitrates must be re-assigned due to bitrate limiting in other encoders leaving */ 
               
               
                   
                 /* a surplus of deficit bitrate - then this bitrate must be re-assigned therefor it is still */ 
               
             
          
           
               
                   
                 /* considered as NOTSET */ 
                   
               
               
                   
                 EncoderState i =UPPERCLIPPED 
                 /* record encoder state */ 
               
             
          
           
               
                   
                 } 
                   
               
               
                   
                 EncodersToBeAssigned = EncodersToBeAssigned − 1 
                 /* account for encoder with new 
               
             
          
           
               
                 bitrate */ 
               
             
          
           
               
                   
                 } 
                 /* end if EncoderState == NOTSET */ 
               
             
          
           
               
                   
                 } 
               
               
                   
                 /* now bitrates have been assigned to all encoders check to see if bitrate limiting has caused total assigned bitrate differ 
               
               
                 */ 
               
               
                   
                 /* from available group bitrate. If so then some of the encoder bitrates must be re-assigned */ 
               
               
                   
                 if(LowerClippedFlag) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 for (i=0; i&lt;N; ++ i) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 /* if an encoder has lower clipped its bitrate then less bitrate can be taken from this encoder than */ 
               
               
                   
                 /* was assumed - this can lead to encoders being assigned too much bitrate ie B TAKEN  &gt; B TOTAL . */ 
               
               
                   
                 /* To avoid this all non lower clipped and non renormalising encoders must be re-assigned */ 
               
               
                   
                 /* bitrates from what is left over after the lower clipped encoders and renormalised encoders */ 
               
               
                   
                 /* have been assigned new bitrates (no . . . I don&#39;t understand it either ?) */ 
               
               
                   
                 if (EncoderState i  != LOWERCLIPPED &amp;&amp; EncoderState i  != RENORMALISING) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 if (EncoderState i  == UPPERCLIPPED) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 EncoderState i =NOTSET 
               
               
                   
                 B TAKEN  = B TAKEN  − B next     i     
               
               
                   
                 EncodersAssigned = EncodersAssigned − 1 
               
               
                   
                 Add i back into set U 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                 while(LowerClippedFlag ∥ UpperClippedFlag) 
                  /* re-assign bitrates until there is no bitrate limiting */