Patent Publication Number: US-9426474-B2

Title: Transcoder

Description:
TECHNICAL FIELD 
     The present invention relates to a transcoder for converting an input stream into a different output stream by decoding, and more particularly to a technique to appropriately control the amount of generated codes of the output stream toward a target bit rate. 
     BACKGROUND ART 
     Images to be delivered on digital broadcasts, those to be stored in media such as DVDs and hard disks, and the like are compressed by various coding systems. The object for such compressions is to avoid constraint on a transmission band, increase the transmission speed, decrease the memory size, or the like. 
     There are various standards for image coding system, such as MPEG2 and H.264. And there is a case where the coding system is converted for the purpose of reducing the amount of codes in a coded image that is inputted, or the like. A transcoder once decodes the inputted coded image. Then, the transcoder encodes the decoded image by a different coding system (or the same coding system) again. Thus, the transcoder controls a bit rate of an output stream. 
     The following Patent Document 1 relates to a transcoder for converting an input stream compressed by a first compressive coding system into an output stream compressed by a second compressive coding system. This transcoder acquires the degree of dispersion of an image and the degree of variation of the image in a time direction during the decoding of the input stream compressed by the first compressive coding system. By using these values as evaluation values, the transcoder calculates a quantization step value to be used for the second compressive coding. 
     [Patent Document 1] Japanese Patent Application Laid Open Gazette No. 2008-42426 
     The coded image conversion technique disclosed in Patent Document 1 aims to obtain an image of high quality from the output stream while controlling the bit rate to be a target value. In other words, a method of simply controlling the bit rate to be constant regardless of the content of an image has a possibility of causing degradation of image quality due to uniform bit allocation. By adopting the method disclosed in Patent Document 1, a large number of bits are allocated to an image which needs more bits to be allocated thereto and no superfluous bits are allocated to another image which does not need more bits to be allocated thereto. 
     Thus, in the technique for calculating an optimal quantization step value on the basis of information on the image obtained from the input stream, the optimal bit allocation is basically predicted from the condition of the input stream. Therefore, it can be expected to achieve further optimization if the condition of the image of the actually generated output stream is also taken into consideration. 
     DISCLOSURE OF INVENTION 
     The present invention is intended for a transcoder converting a first stream into a second stream. According to an aspect of the present invention, the transcoder comprises a part for setting a target bit rate of a whole second stream, and a target bit rate determination part for determining a target bit rate of a second stream in the (N+1) period on the basis of the target bit rate of the whole second stream, a distortion evaluation value of a second stream converted in or before the N period, and a target distortion evaluation value of the whole second stream. 
     It thereby becomes possible to optimally control the bit rate of the second stream toward the target bit rate without degradation of image quality. 
     According to another preferred embodiment of the present invention, the transcoder of the present invention comprises a part for setting a target bit rate of a whole second stream, and a target bit rate determination part for determining a target bit rate of a second stream in the (N+1) period on the basis of the target bit rate of the whole second stream, a bit rate and a distortion evaluation value of a second stream converted in or before the N period, a target bit rate of a second stream in the N period, and a target distortion evaluation value of the whole second stream. 
     Therefore, it is an object of the present invention to appropriately control the amount of generated codes of an output stream toward a target bit rate while maintaining high quality of the image of the output stream. 
     These and other objects, features, aspects and advantages of the present invention will become more apparent from the following detailed description of the present invention when taken in conjunction with the accompanying drawings. 
    
    
     
       BRIEF DESCRIPTION OF DRAWINGS 
       [ FIG. 1 ] is a block diagram showing a transcoder; 
       [ FIG. 2 ] is a view showing information on an input stream (first stream) and an output stream (second stream) per control unit time; 
       [ FIG. 3 ] is a view showing a characteristic of a function θ 1 ; 
       [ FIG. 4 ] is a view showing a characteristic of a function θ 2 ; 
       [ FIG. 5 ] is a view showing a characteristic of a function θ 3 ; 
       [ FIG. 6 ] is a view showing a characteristic of a function θ 4 ; 
       [ FIG. 7 ] is a view showing a characteristic of a function θ 5 ; 
       [ FIG. 8 ] is a view showing a characteristic of a function θ 6 ; and 
       [ FIG. 9 ] is a block diagram showing a transcoder in accordance with a seventh preferred embodiment. 
     
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     Hereinafter, with reference to figures, the preferred embodiments of the present invention will be discussed.  FIG. 1  is a block diagram showing a transcoder  1  in accordance with the preferred embodiments. The transcoder  1  comprises a CPU  11 , a first decoder  12 , an image memory  13 , a step value calculation part  14 , an encoder  15 , a buffer memory  16 , a second decoder  17 , and a distortion calculation part  18 . 
     The first decoder  12  inputs a first stream. The first stream is a stream of coded image. The first decoder  12  decodes the first stream and outputs uncompressed image data to the image memory  13 . The encoder  15  again codes the uncompressed image data which is decoded and stored in the image memory  13 , to thereby output a second stream. 
     The transcoder  1  converts a coding system of stream, and for example, inputs a first stream coded in MPEG2 and outputs a second stream coded in H.264. The present invention is devised in order to optimally control the rate of the second stream to be outputted in the conversion. Alternatively, the transcoder  1  outputs a stream of the same coding system, and for example, inputs a first stream coded in MPEG2 and outputs a second stream recoded in MPEG2. Also in this case, the present invention is devised in order to optimally control the rate of the second stream to be outputted. 
     Various computations performed in the first decoder  12 , the step value calculation part  14 , the encoder  15 , the second decoder  17 , and the distortion calculation part  18  may be implemented by hardware or may be implemented by software operations. In other words, these processing parts may be constructed as hardware circuits or implemented by a CPU and programs stored in memories. Alternatively, there may be a case where some of the computations are performed by hardware and the others are performed by software. 
       FIG. 2  is a view showing information on streams that the transcoder  1  inputs or outputs per control unit time. The transcoder  1  divides the processing time base into control unit times L n  (n=1, 2 . . . ) and performs a rate control by using this control unit time L n  as a unit of processing. In the following discussion, the control unit time L n  is referred to as “the n period” as appropriate. As to the control unit time L n , one frame, a plurality of successive frames, one GOP, a plurality of successive GOPs, or the like may be set as one unit time. 
     A total input bit rate S of the first stream is acquired from a sequence header or the like. An average input bit rate S n  is an average bit rate of the first stream in the n period. The transcoder  1  can store information on the average input bit rates S n  for M periods in the buffer memory  16 . Specifically, the buffer memory  16  can store information on the average input bit rates S n  from the (n−M+1) period to the n period. An average period bit rate AS n  is an average value of the average input bit rates S n  from the (n−M+1) period to the n period. The average period bit rate AS n  is expressed by Eq. (1). 
     
       
         
           
             
               
                 
                   
                     AS 
                     n 
                   
                   = 
                   
                     
                       1 
                       M 
                     
                     ⁢ 
                     
                       
                         ∑ 
                         
                           n 
                           - 
                           M 
                           + 
                           1 
                         
                         n 
                       
                       ⁢ 
                       
                         S 
                         i 
                       
                     
                   
                 
               
               
                 
                   ( 
                   1 
                   ) 
                 
               
             
           
         
       
     
     A total target bit rate T of the second stream is set by a user. For example, the user uses a not-shown operation part provided in the transcoder  1  to set the total target bit rate T. 
     A target setting bit rate T n  is a target bit rate of the second stream in the n period. An average output bit rate C n  is an average bit rate of the second stream which is already converted in the n period. The transcoder  1  can store information on the average output bit rates C n  for M periods in the buffer memory  16 . Specifically, the buffer memory  16  can store information on the average output bit rates C n  from the (n−M+1) period to the n period. An average period bit rate AC n  is an average value of the average output bit rates C n  from the (n−M+1) period to the n period. The average period bit rate AC n  is expressed by Eq. (2). Though the buffering period used for calculation of the average period bit rate AS n  or AC n  is linked to the control unit time L n  in the preferred embodiments, setting of the buffering period is not limited to this case. For example, one past frame, a plurality of successive past frames, one past GOP, a plurality of successive past GOPs, or the like at the point of time when the coding is completed may be set as the buffering period. 
     
       
         
           
             
               
                 
                   
                     AC 
                     n 
                   
                   = 
                   
                     
                       1 
                       M 
                     
                     ⁢ 
                     
                       
                         ∑ 
                         
                           n 
                           - 
                           M 
                           + 
                           1 
                         
                         n 
                       
                       ⁢ 
                       
                         C 
                         i 
                       
                     
                   
                 
               
               
                 
                   ( 
                   2 
                   ) 
                 
               
             
           
         
       
     
     A total target distortion evaluation value d of the second stream is set by the user. For example, the user uses the not-shown operation part provided in the transcoder  1  to set the total target distortion evaluation value d. 
     An average distortion evaluation value d n  is an evaluation value indicating the degree of image distortion of the second stream which is already converted in the n period. The transcoder  1  can store information on the average distortion evaluation values d n  for M periods in the buffer memory  16 . Specifically, the buffer memory  16  can store information on the average distortion evaluation values d n  from the (n−M+1) period to the n period. An average period distortion evaluation value Ad n  is an average value of the average distortion evaluation values d n  from the (n−M+1) period to the n period. The average period distortion evaluation value Ad n  is expressed by Eq. (3). 
     
       
         
           
             
               
                 
                   
                     Ad 
                     n 
                   
                   = 
                   
                     
                       1 
                       M 
                     
                     ⁢ 
                     
                       
                         ∑ 
                         
                           n 
                           - 
                           M 
                           + 
                           1 
                         
                         n 
                       
                       ⁢ 
                       
                         d 
                         i 
                       
                     
                   
                 
               
               
                 
                   ( 
                   3 
                   ) 
                 
               
             
           
         
       
     
     A quantization step conversion factor α n  is a factor calculated at the point of time when the (n−1) period is finished. A quantization step value Q of the second stream is determined by multiplying a value P, which is a quantization step value of the first stream or a value calculated from the quantization step value of the first stream, by the quantization step conversion factor α n . This relation is expressed by Eq. (4).
 
 Q−α   n   P   (4)
 
     Referring back to  FIG. 1 , the CPU  11  acquires a bit rate s_b for each picture of the first stream from the first decoder  12  and stores the bit rate s_b into the buffer memory  16 . The CPU  11  calculates the average input bit rate S n  and the average period bit rate AS n  in the n period on the basis of the bit rate s_b stored in the buffer memory  16 . 
     The first decoder  12  outputs the quantization step value P for each macroblock of the first stream to the step value calculation part  14 . 
     The CPU  11  acquires a bit rate c_b for each picture of the converted second stream from the encoder  15  and stores the bit rate c_b into the buffer memory  16 . The CPU  11  calculates the average input bit rate C n  and the average period bit rate AC n  in the n period on the basis of the bit rate c_b stored in the buffer memory  16 . 
     The CPU  11  acquires the total target bit rate T and the total target distortion evaluation value d which are set by the user. 
     The encoder  15  encodes the uncompressed image data on the basis of the quantization step value Q inputted from the step value calculation part  14  to thereby generate the second stream. The second decoder  17  inputs the second stream encoded by the encoder  15  and decodes the second stream again to obtain the uncompressed image data. The distortion calculation part  18  inputs the uncompressed image data from each of the image memory  13  and the second decoder  17  and calculates a distortion evaluation value dI for each picture of the second stream. 
     For example, the distortion calculation part  18  compares the uncompressed image data acquired from the image memory  13  with the uncompressed image data acquired from the second decoder  17  and calculates a sum of squares of pixel difference values of these images, to thereby calculate the distortion evaluation value dI for each picture. Alternatively, the distortion evaluation value dI may be calculated by using a sum of absolute values of the pixel difference values of these images. 
     The CPU  11  inputs the distortion evaluation value dI for each picture from the distortion calculation part  18  and stores the distortion evaluation value dI into the buffer memory  16 . The CPU  11  calculates the average distortion evaluation value d n  and the average period distortion evaluation value Ad n  from the distortion evaluation value dI stored in the buffer memory  16 . 
     In the preferred embodiments, the smaller the distortion evaluation value dI is, the smaller the distortion of the image is. Therefore, also as to the average distortion evaluation value d n  and the average period distortion evaluation value Ad n , the smaller the value thereof is, the smaller the distortion of the image is. In the calculation of the distortion evaluation value dI, a weighting in accordance with a color component may be given. 
     The CPU  11  performs computations shown in the first to sixth preferred embodiments discussed later by using information on the total target bit rate T, the total target distortion evaluation value d, the average distortion evaluation value d n , the average period distortion evaluation value Ad n , the average output bit rate C n , the average period bit rate AC n , the average input bit rate S n , the average period bit rate AS n , and the like, to thereby determine the target setting bit rate T n+1  of the second stream in the (n+1) period. Further, the CPU  11  calculates the quantization step conversion factor α n+1  from the target setting bit rate T n+1  of the second stream in the (n+1) period and outputs the quantization step conversion factor α n+1  to the step value calculation part  14 . The step value calculation part  14  performs the computation expressed by Eq. (4) to calculate the quantization step value Q of the second stream and gives the quantization step value Q to the encoder  15 . 
     It can be seen from Eq. (4) that the quantization step conversion factor α n  is a ratio between the quantization step values. A relation between the ratio R B  between the bit rates and the ratio R Q  between the quantization step values can be expressed as Eq. (5) using a function f.
 
 R   Q   =f ( R   B )  (5)
 
     A specific example of the function f will be discussed. In these preferred embodiments, as shown in Eq. (6), used are functions which can control the ratio between the quantization step values with different characteristics for types I, P and B (I picture, P picture and B picture) of a picture or a macroblock. In Eq. (6), f I (x), f P (x) and f B (x) are functions adapted correspondingly to the I picture, the P picture and the B picture, respectively. 
     
       
         
           
             
               
                 
                   { 
                   
                     
                       
                         
                           
                             
                               f 
                               I 
                             
                             ⁡ 
                             
                               ( 
                               x 
                               ) 
                             
                           
                           = 
                           
                             
                               
                                 ɛ 
                                 I 
                               
                               * 
                               
                                 x 
                                 
                                   - 
                                   
                                     δ 
                                     I 
                                   
                                 
                               
                             
                             = 
                             
                               2.1 
                               * 
                               
                                 x 
                                 
                                   - 
                                   1.1 
                                 
                               
                             
                           
                         
                       
                     
                     
                       
                         
                           
                             
                               f 
                               P 
                             
                             ⁡ 
                             
                               ( 
                               x 
                               ) 
                             
                           
                           = 
                           
                             
                               
                                 ɛ 
                                 P 
                               
                               * 
                               
                                 x 
                                 
                                   - 
                                   
                                     δ 
                                     P 
                                   
                                 
                               
                             
                             = 
                             
                               2.1 
                               * 
                               
                                 x 
                                 
                                   - 
                                   0.8 
                                 
                               
                             
                           
                         
                       
                     
                     
                       
                         
                           
                             
                               f 
                               B 
                             
                             ⁡ 
                             
                               ( 
                               x 
                               ) 
                             
                           
                           = 
                           
                             
                               
                                 ɛ 
                                 B 
                               
                               * 
                               
                                 x 
                                 
                                   - 
                                   
                                     δ 
                                     B 
                                   
                                 
                               
                             
                             = 
                             
                               1.3 
                               * 
                               
                                 x 
                                 
                                   - 
                                   0.9 
                                 
                               
                             
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   6 
                   ) 
                 
               
             
           
         
       
     
     In Eq. (6), as values of ε I , ε P , ε B , δ I , δ P  and δ B  in the case of stream conversion from MPEG2 into H.264, specific numerical values calculated on the basis of an experiment or the like are shown. Specifically, as the result of the experiment, when ε 1 =2.1, ε P =2.1, ε B =1.3, δ I =1.1, δ P =0.8 and δ B =0.9, an excellent feature can be obtained. Other than this, by using the feature value of the image which is acquired in decoding the input stream, the values of ε and δ may be determined. As expressed by Eq. (7), for example, on the basis of an activity value (act value) and a motion evaluation value (sad value) of the input stream, the values of ε and δ may be determined. 
     
       
         
           
             
               
                 
                   { 
                   
                     
                       
                         
                           
                             
                               f 
                               I 
                             
                             ⁡ 
                             
                               ( 
                               x 
                               ) 
                             
                           
                           = 
                           
                             
                               
                                 ɛ 
                                 I 
                               
                               ⁡ 
                               
                                 ( 
                                 
                                   a 
                                   , 
                                   s 
                                 
                                 ) 
                               
                             
                             * 
                             
                               x 
                               
                                 - 
                                 
                                   
                                     δ 
                                     I 
                                   
                                   ⁡ 
                                   
                                     ( 
                                     
                                       a 
                                       , 
                                       s 
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                         
                       
                     
                     
                       
                         
                           
                             
                               f 
                               P 
                             
                             ⁡ 
                             
                               ( 
                               x 
                               ) 
                             
                           
                           = 
                           
                             
                               
                                 ɛ 
                                 P 
                               
                               ⁡ 
                               
                                 ( 
                                 
                                   a 
                                   , 
                                   s 
                                 
                                 ) 
                               
                             
                             * 
                             
                               x 
                               
                                 - 
                                 
                                   
                                     δ 
                                     P 
                                   
                                   ⁡ 
                                   
                                     ( 
                                     
                                       a 
                                       , 
                                       s 
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                         
                       
                     
                     
                       
                         
                           
                             
                               f 
                               B 
                             
                             ⁡ 
                             
                               ( 
                               x 
                               ) 
                             
                           
                           = 
                           
                             
                               
                                 ɛ 
                                 B 
                               
                               ⁡ 
                               
                                 ( 
                                 
                                   a 
                                   , 
                                   s 
                                 
                                 ) 
                               
                             
                             * 
                             
                               x 
                               
                                 - 
                                 
                                   
                                     δ 
                                     B 
                                   
                                   ⁡ 
                                   
                                     ( 
                                     
                                       a 
                                       , 
                                       s 
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   7 
                   ) 
                 
               
             
           
         
       
     
     In Eq. (7), “a” represents the act value and “s” represents the sad value, and ε 1 (a, s), ε P (a, s), ε B (a, s), −δ I (a, s), −δ P (a, s), −δ B (a, s) represent the values of ε and δ which are calculated by using the act value and the sad value as parameters. 
     The activity value is obtained by calculating a sum of absolute differences (SAD) of an average pixel value in a macroblock and a pixel value of each pixel in the macroblock by the macroblock. In other words, the activity value is an evaluation value indicating the degree of dispersion of pixels in the macroblock. This is the same as an activity value used in the code amount control model TM5 of MPEG2 or the like. The motion evaluation value (sad value) is obtained by calculating an interframe sum of absolute differences of a pixel value of each pixel in a reference image macroblock and a pixel value of the corresponding pixel in a macroblock, by the macroblock. In other words, the motion evaluation value is obtained by comparing each pixel in a macroblock with the corresponding pixel in the reference image macroblock and calculating a sum of absolute values of differences of pixel values of corresponding pixels in the same coordinate positions. 
     More generally, assuming that an feature value of an image in the n period is determined as I Ln , f I (x), f P (x) and f B (x) are expressed by Eq. (8). 
     
       
         
           
             
               
                 
                   { 
                   
                     
                       
                         
                           
                             
                               f 
                               I 
                             
                             ⁡ 
                             
                               ( 
                               x 
                               ) 
                             
                           
                           = 
                           
                             
                               
                                 ɛ 
                                 I 
                               
                               ⁡ 
                               
                                 ( 
                                 
                                   I 
                                   
                                     L 
                                     n 
                                   
                                 
                                 ) 
                               
                             
                             * 
                             
                               x 
                               
                                 - 
                                 
                                   
                                     δ 
                                     I 
                                   
                                   ⁡ 
                                   
                                     ( 
                                     
                                       I 
                                       
                                         L 
                                         n 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                         
                       
                     
                     
                       
                         
                           
                             
                               f 
                               P 
                             
                             ⁡ 
                             
                               ( 
                               x 
                               ) 
                             
                           
                           = 
                           
                             
                               
                                 ɛ 
                                 P 
                               
                               ⁡ 
                               
                                 ( 
                                 
                                   I 
                                   
                                     L 
                                     n 
                                   
                                 
                                 ) 
                               
                             
                             * 
                             
                               x 
                               
                                 - 
                                 
                                   
                                     δ 
                                     P 
                                   
                                   ⁡ 
                                   
                                     ( 
                                     
                                       I 
                                       
                                         L 
                                         n 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                         
                       
                     
                     
                       
                         
                           
                             
                               f 
                               B 
                             
                             ⁡ 
                             
                               ( 
                               x 
                               ) 
                             
                           
                           = 
                           
                             
                               
                                 ɛ 
                                 B 
                               
                               ⁡ 
                               
                                 ( 
                                 
                                   I 
                                   
                                     L 
                                     n 
                                   
                                 
                                 ) 
                               
                             
                             * 
                             
                               x 
                               
                                 - 
                                 
                                   
                                     δ 
                                     B 
                                   
                                   ⁡ 
                                   
                                     ( 
                                     
                                       I 
                                       
                                         L 
                                         n 
                                       
                                     
                                     ) 
                                   
                                 
                               
                             
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   8 
                   ) 
                 
               
             
           
         
       
     
     In Eq. (8), ε I (I Ln ), ε P (I Ln ), ε B (I Ln ), −δ I (I Ln ), −δ P (I Ln ) and −δ B (I Ln ) represent the factors ε and δ which are determined by using the feature value I Ln  of the image as a parameter. 
     The First Preferred Embodiment 
     Next, the first preferred embodiment of the present invention will be discussed. The transcoder  1  of the first preferred embodiment determines the target setting bit rate T n+1  of the second stream in the (n+1) period at the point of time when the n period is finished. After the target setting bit rate T n+1  in the (n+1) period is determined, the quantization step conversion factor α n+1  is calculated in the same manner as discussed with reference to Eq. (5). In other words, the quantization step conversion factor α n+1  is calculated by using the function f shown in Eqs. (6) to (8). 
     Specifically, as expressed by Eq. (9), the quantization step conversion factor α n+1  is calculated by substituting the ratio between the target setting bit rate T n+1  in the (n+1) period and the average input bit rate S n  in the n period into the function f. Then, the computation expressed by Eq. (4) is performed by using the calculated quantization step conversion factor α n+1 , to thereby calculate the quantization step value Q of the second stream.
 
α n+1   =f ( T   n+1   /S   n )  (9)
 
     Alternatively, as expressed by Eq. (10), the quantization step conversion factor α n+1  may be calculated by using the average period bit rate AS n  from the (n−M+1) period to the n period, instead of the average input bit rate S n  in the n period.
 
α n+1   =f ( T   n+1   /AS   n )  (10)
 
     Eq. (11) is an equation for calculation of the target setting bit rate T n+1  in the (n+1) period. In other words, Eq. (11) represents the target setting bit rate in the (n+1) period calculated by the transcoder  1  after the n period is finished. Specifically, assuming that a value obtained by dividing the average distortion evaluation value d n  of the second stream which is already converted in the n period by the total target distortion evaluation value d is determined as a target distortion ratio, the target setting bit rate T n+1  in the (n+1) period can be calculated by multiplying the total target bit rate T of the second stream by the target distortion ratio. 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     T 
                     * 
                     k 
                     * 
                     
                       
                         d 
                         n 
                       
                       d 
                     
                   
                 
               
               
                 
                   ( 
                   11 
                   ) 
                 
               
             
           
         
       
     
     In Eq. (11), “k” is a positive factor and a factor for adjusting the target distortion ratio. When the average distortion evaluation value d n  in the n period exceeds the total target distortion evaluation value d, the image quality is lower than the target quality. In this case, adjustment is made toward the direction in which d n /d will become larger than 1 and the target setting bit rate T n+1  will become larger. In the reverse case where the d n /d is smaller than 1, since the image quality is higher than the target quality, the target setting bit rate T n+1  is suppressed. The bit rate by which the target setting bit rate T n+1  is suppressed may be allocated to another control unit time where the image quality is degraded. When the image quality is higher than the target quality, it is not always necessary to suppress the target setting bit rate T n+1 . Thus, the ratio of the image distortion to the target distortion is calculated by the d n /d and the target setting bit rate T n+1  in the (n+1) period is adjusted by multiplying the total target bit rate T by the target distortion ratio so that the distortion of the image may not become larger. 
     Though the total target bit rate T of the second stream is multiplied by the d n /d as the target distortion ratio (while the factor k is also used as a multiplier) in Eq. (11), the target distortion ratio may be obtained by substituting the d n /d into a function θ n  as expressed by Eq. (12). In this case, the target setting bit rate T n+1  can be adjusted by adding the target distortion ratio to the total target bit rate T. 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     T 
                     + 
                     
                       
                         θ 
                         1 
                       
                       ⁡ 
                       
                         ( 
                         
                           
                             d 
                             n 
                           
                           d 
                         
                         ) 
                       
                     
                   
                 
               
               
                 
                   ( 
                   12 
                   ) 
                 
               
             
           
         
       
     
     Eq. (13) is an equation representing the specific example of the function θ 1 . 
     
       
         
           
             
               
                 
                   
                     
                       θ 
                       1 
                     
                     ⁡ 
                     
                       ( 
                       x 
                       ) 
                     
                   
                   = 
                   
                     { 
                     
                       
                         
                           
                             x 
                             - 
                             1 
                             - 
                             
                               b 
                               0 
                             
                           
                         
                         
                           
                             ( 
                             
                               x 
                               ≥ 
                               
                                 1 
                                 + 
                                 
                                   c 
                                   0 
                                 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               a 
                               0 
                             
                             * 
                             
                               
                                 ( 
                                 
                                   x 
                                   - 
                                   1 
                                 
                                 ) 
                               
                               3 
                             
                           
                         
                         
                           
                             ( 
                             
                               
                                 1 
                                 + 
                                 
                                   c 
                                   0 
                                 
                               
                               &gt; 
                               x 
                               ≥ 
                               1 
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               a 
                               1 
                             
                             * 
                             
                               
                                 ( 
                                 
                                   x 
                                   - 
                                   1 
                                 
                                 ) 
                               
                               3 
                             
                           
                         
                         
                           
                             ( 
                             
                               1 
                               &gt; 
                               x 
                               ≥ 
                               
                                 1 
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             x 
                             - 
                             1 
                             + 
                             
                               b 
                               1 
                             
                           
                         
                         
                           
                             ( 
                             
                               
                                 1 
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                               &gt; 
                               x 
                             
                             ) 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   13 
                   ) 
                 
               
             
           
         
       
     
     A relation of a 0 , a 1 , b 0 , b 1 , c 0 , and c 1  in Eq. (13) is expressed by Eq. (14). A characteristic of the function θ 1  represented by such a condition is shown in  FIG. 3 . 
     
       
         
           
             
               
                 
                   
                     
                       
                         a 
                         0 
                       
                       &gt; 
                       0 
                     
                     , 
                     
                         
                     
                     ⁢ 
                     
                       
                         a 
                         1 
                       
                       &gt; 
                       0 
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         c 
                         0 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               0 
                             
                           
                         
                       
                     
                     , 
                     
                         
                     
                     ⁢ 
                     
                       
                         c 
                         1 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               1 
                             
                           
                         
                       
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         b 
                         0 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           0 
                         
                       
                     
                     , 
                     
                         
                     
                     ⁢ 
                     
                       
                         b 
                         1 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           1 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   14 
                   ) 
                 
               
             
           
         
       
     
     Thus, the function θ 1  has the characteristic that when an input value is close to “1”, an output does not vary significantly from “0”. From the time when the input value becomes larger than a threshold value (or when the input value becomes smaller than a threshold value), the output value also varies linearly. In the specific examples expressed by Eqs. (13) and (14), the variation of the output value also becomes larger from the time when the input value becomes larger than (1+c 0 ) or becomes smaller than (1−c 1 ). 
     By using the function θ 1 , it is possible to avoid significant variation of the target setting bit rate T n+1  from the total target bit rate T even when the d n /d deviates a little from “1”. In a case where the target distortion ratio relatively largely deviates, by varying the target setting bit rate it is possible to ensure improvement of the image quality. 
     In the exemplary case shown in  FIG. 3 , the function θ 1  has the characteristic of bilateral symmetry (point symmetry with respect to the point (1, 0)). In other words, the rate of change is symmetric with respect to a boundary where the value of the d n /d is 1. The rate of increase in the target distortion ratio in the case where the value of the d n /d is larger than 1 is equal to the rate of decrease in the target distortion ratio in the case where the value of the d n /d is smaller than 1. The rate of change may be asymmetric with respect to a boundary where the value of the d n /d is 1. In this case, the rate of increase in the target distortion ratio in the case where the value of the d n /d is larger than 1 is different from the rate of decrease in the target distortion ratio in the case where the value of the d n /d is smaller than 1. By controlling the values of a 0  and a 1 , it is possible to provide a characteristic of bilateral asymmetry. By increasing a n  and decreasing a 1 , for example, when the distortion evaluation value of the image is larger than a target distortion value, quick improvement of the image quality is performed and when the distortion evaluation value of the image is smaller than the target distortion value, the bit rate is gently suppressed. 
     The Second Preferred Embodiment 
     Next, the second preferred embodiment of the present invention will be discussed. Also in the second preferred embodiment, like in the first preferred embodiment, the transcoder  1  determines the target setting bit rate T n+1  of the second stream in the (n+1) period at the point of time when the n period is finished. 
     After the target setting bit rate T n+1  in the (n+1) period is determined, the quantization step conversion factor α n+1  is calculated in the same manner as discussed with reference to Eq. (5). In other words, the quantization step conversion factor α n+1  is calculated by performing the computation expressed by Eq. (9) or Eq. (10) using the function f shown in Eqs. (6) to (8). After the quantization step conversion factor α n+1  is calculated, the quantization step value Q of the second stream is calculated by using Eq. (4). 
     Eq. (15) is an equation for calculation of the target setting bit rate T n+1  in the (n+1) period. In this case, a value obtained by dividing the average output bit rate C n  of the second stream which is already converted in the n period by the target setting bit rate T n  in the n period is determined as a target rate ratio. The target setting bit rate T n+1  in the (n+1) period can be calculated by multiplying a quotient of the total target bit rate T of the second stream divided by the target rate ratio by the target distortion ratio. The target distortion ratio is a value obtained by dividing the average distortion evaluation value d n  by the total target distortion evaluation value d like in the first preferred embodiment. 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     k 
                     * 
                     
                       T 
                       
                         
                           C 
                           n 
                         
                         
                           T 
                           n 
                         
                       
                     
                     * 
                     
                       
                         d 
                         n 
                       
                       d 
                     
                   
                 
               
               
                 
                   ( 
                   15 
                   ) 
                 
               
             
           
         
       
     
     In Eq. (15), “k” is a positive factor and a factor for adjusting the target rate ratio and the target distortion ratio. A ratio of the bit rate to the target bit rate in the n period is calculated by C n /T n  and the target setting bit rate T n+1  in the (n+1) period is adjusted by dividing the total target bit rate T by the target rate ratio. When the average output bit rate C n  exceeds the target setting bit rate T, the C n /T n  becomes larger than 1 and then the target setting bit rate T n+1  is suppressed and controlled so that the bit rate should be close to the target bit rate on the whole. 
     Further, the total target bit rate T is multiplied by the target distortion ratio (d n /d) and when the image quality is degraded (d n /d is larger than 1), adjustment is made toward the direction to increase the target setting bit rate T n+1 . It is thereby possible to improve the image quality while maintaining the target bit rate. In the reverse case where the d n /d is smaller than 1, since the image quality is higher than the target quality, the target setting bit rate T n+1  is suppressed. The bit rate by which the target setting bit rate T n+1  is suppressed may be allocated to another control unit time where the image quality is degraded. When the image quality is higher than the target quality, it is not always necessary to suppress the target setting bit rate T n+1 . 
     Though the C n /T n  is used as the target rate ratio (while the factor k is also used as a multiplier) in Eq. (15), the target rate ratio may be obtained by substituting the C n /T n  into a function θ 2  as expressed by Eq. (16). 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     k 
                     * 
                     
                       T 
                       
                         
                           θ 
                           2 
                         
                         ⁡ 
                         
                           ( 
                           
                             
                               C 
                               n 
                             
                             
                               T 
                               n 
                             
                           
                           ) 
                         
                       
                     
                     * 
                     
                       
                         d 
                         n 
                       
                       d 
                     
                   
                 
               
               
                 
                   ( 
                   16 
                   ) 
                 
               
             
           
         
       
     
     Eq. (17) is an equation representing the specific example of the function θ 2 . 
     
       
         
           
             
               
                 
                   
                     
                       θ 
                       2 
                     
                     ⁡ 
                     
                       ( 
                       x 
                       ) 
                     
                   
                   = 
                   
                     { 
                     
                       
                         
                           
                             x 
                             - 
                             
                               b 
                               0 
                             
                           
                         
                         
                           
                             ( 
                             
                               x 
                               ≥ 
                               
                                 1 
                                 + 
                                 
                                   c 
                                   0 
                                 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               
                                 a 
                                 0 
                               
                               * 
                               
                                 
                                   ( 
                                   
                                     x 
                                     - 
                                     1 
                                   
                                   ) 
                                 
                                 3 
                               
                             
                             + 
                             1 
                           
                         
                         
                           
                             ( 
                             
                               
                                 1 
                                 + 
                                 
                                   c 
                                   0 
                                 
                               
                               &gt; 
                               x 
                               ≥ 
                               1 
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               
                                 a 
                                 1 
                               
                               * 
                               
                                 
                                   ( 
                                   
                                     x 
                                     - 
                                     1 
                                   
                                   ) 
                                 
                                 3 
                               
                             
                             + 
                             1 
                           
                         
                         
                           
                             ( 
                             
                               1 
                               &gt; 
                               x 
                               ≥ 
                               
                                 1 
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             x 
                             + 
                             
                               b 
                               1 
                             
                           
                         
                         
                           
                             ( 
                             
                               
                                 1 
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                               &gt; 
                               x 
                             
                             ) 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   17 
                   ) 
                 
               
             
           
         
       
     
     A relation of a 0 , a 1 , b 0 , b 1 , c 0 , and c 1  in Eq. (17) is expressed by Eq. (18). A characteristic of the function θ 2  represented by such a condition is shown in  FIG. 4 . 
     
       
         
           
             
               
                 
                   
                     
                       
                         a 
                         0 
                       
                       &gt; 
                       0 
                     
                     , 
                     
                         
                     
                     ⁢ 
                     
                       
                         a 
                         1 
                       
                       &gt; 
                       0 
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         c 
                         0 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               0 
                             
                           
                         
                       
                     
                     , 
                     
                         
                     
                     ⁢ 
                     
                       
                         c 
                         1 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               1 
                             
                           
                         
                       
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         b 
                         0 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           0 
                         
                       
                     
                     , 
                     
                         
                     
                     ⁢ 
                     
                       
                         b 
                         1 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           1 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   18 
                   ) 
                 
               
             
           
         
       
     
     Thus, the function θ 2  has the characteristic that when the input value is close to “1”, an output does not vary significantly from “1”. From the time when the input value becomes larger than a threshold value (or when the input value becomes smaller than a threshold value), the output value also varies linearly. In the specific examples expressed by Eqs. (17) and (18), the variation of the output value also becomes larger from the time when the input value becomes larger than (1+c 0 ) or becomes smaller than (1−c 1 ). 
     By using the function θ 2 , it is possible to avoid significant variation of the target setting bit rate T n+1  from the total target bit rate T even when the C n /T n  deviates a little from “1”. In a case where the target rate ratio relatively largely deviates, by varying the target setting bit rate T n+1 , it is possible to optimally follow the target. 
     In the exemplary case shown in  FIG. 4 , the function θ 2  has the characteristic of bilateral symmetry (point symmetry with respect to the point (1, 1)). In other words, the rate of change is symmetric with respect to a boundary where the value of the C n /T n  is 1. The rate of increase in the target rate ratio in the case where the value of the C n /T n  is larger than 1 is equal to the rate of decrease in the target rate ratio in the case where the value of the C n /T n  is smaller than 1. The rate of change may be asymmetric with respect to a boundary where the value of the C n /T n  is 1. In this case, the rate of increase in the target rate ratio in the case where the value of the C n /T n  is larger than 1 is different from the rate of decrease in the target rate ratio in the case where the value of the C n /T n  is smaller than 1. By controlling the values of a 0  and a 1 , it is possible to provide a characteristic of bilateral asymmetry. By increasing a 0  and decreasing a 1 , for example, when the bit rate becomes larger than the target value, the bit rate can be controlled to quickly decrease to the target value and when the bit rate becomes smaller than the target value, the bit rate can be controlled to gently increase to the target value. 
     Though the value obtained by dividing the average output bit rate C n  of the second stream in the n period by the target setting bit rate T n  is used as the target rate ratio in Eq. (15), the target rate ratio is further adjusted in Eq. (19). 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     k 
                     * 
                     
                       T 
                       
                         
                           
                             S 
                             
                               n 
                               - 
                               1 
                             
                           
                           
                             S 
                             n 
                           
                         
                         * 
                         
                           
                             C 
                             n 
                           
                           
                             T 
                             n 
                           
                         
                       
                     
                     * 
                     
                       
                         d 
                         n 
                       
                       d 
                     
                   
                 
               
               
                 
                   ( 
                   19 
                   ) 
                 
               
             
           
         
       
     
     In Eq. (19), the target rate ratio is multiplied by S n−1 /S n . The S n−1 /S n  is a value obtained by dividing the average input bit rate S n−1  of the first stream in the (n−1) period by the average input bit rate S n  of the first stream in the n period and may be referred to as a period ratio of the average input bit rates. In other words, the target ratio is adjusted by multiplying the target rate ratio by the period ratio. 
     By multiplying the target ratio by the period ratio, it is possible to correct local variation of the target ratio. When the average input bit rate S n  locally decrease, for example, the target ratio C n /T n  also accordingly decrease in some cases. Also in such a case, the target ratio is adjusted by multiplying the target ratio by the period ratio S n−1 /S n  (the period ratio takes a value larger than 1 in this case) and it is possible to avoid significant variation of the target setting bit rate T n+1 . In the reverse case where the average input bit rate S n  locally increase, the period ratio S n+1 /S n  takes a value smaller than 1 and it is possible to suppress a quick increase of the target ratio. 
     Also in the method of calculating the target setting bit rate T n+1  by using the function θ 2  expressed by Eq. (16), similarly, the target rate ratio may be set by multiplying the target rate ratio by the period ratio. The target setting bit rate T n+1  calculated by this method is shown in Eq. (20). Also in this case, the target rate ratio is adjusted with the variation of the average input bit rate and it is possible to avoid significant variation of the target setting bit rate T n+1 . 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     k 
                     * 
                     
                       T 
                       
                         
                           
                             S 
                             
                               n 
                               - 
                               1 
                             
                           
                           
                             S 
                             n 
                           
                         
                         * 
                         
                           
                             θ 
                             2 
                           
                           ⁡ 
                           
                             ( 
                             
                               
                                 C 
                                 n 
                               
                               
                                 T 
                                 n 
                               
                             
                             ) 
                           
                         
                       
                     
                     * 
                     
                       
                         d 
                         n 
                       
                       d 
                     
                   
                 
               
               
                 
                   ( 
                   20 
                   ) 
                 
               
             
           
         
       
     
     In Eq. (19), the value obtained by dividing the average input bit rate S n−1  of the first stream in the (n−1) period by the average input bit rate S n  of the first stream in the n period is used as the period ratio. On the other hand, in a case where the average input bit rate S n+1  of the first stream in the (n+1) period can be obtained in advance, the average input bit rate S n+1  may be used. The case where the average input bit rate S n+1  can be obtained in advance refers to a case where there is spare time to perform buffering of information on the average input bit rate S n+1  and then calculate the target setting bit rate T n+1  in the (n+1) period. In other words, it refers to a case where a processing delay to some degree is allowed. 
     In the case where the average input bit rate S n+1  can be obtained in advance, in Eq. (19), the target rate ratio may be multiplied by the period ratio S n /S n+1 , instead of the period ratio S n−1 /S n . By using the latest input information, it is possible to ensure optimal control of the target bit rate. 
     In Eq. (20), the target rate ratio obtained by using the function θ 2  is multiplied by the period ratio. Also in this case, similarly, the target rate ratio may be multiplied by the period ratio S n /S n+1 , instead of the period ratio S n−1 /S n . It is thereby possible to control the target setting bit rate T n+1  with higher accuracy. 
     In the case where the average input bit rate S n+1  of the first stream in the (n+1) period is used as the period ratio, instead of Eq. (9), as expressed by Eq. (21), by substituting a ratio between the target setting bit rate T n+1 , in the (n+1) period and the average input bit rate S n+1  in the (n+1) period into the function f, the quantization step conversion factor α n+1  in the (n+1) period can be calculated.
 
α n+1   =f ( T   n+1   /S   n+1 )  (21)
 
     In Eq. (19) and Eq. (20), the S n−1 /S n  is used as the period ratio. Instead, a ratio between the average period bit rate AS n−1  for past M periods including the (n−1) period and the average period bit rate AS n  for past M periods including the n period may be used as the period ratio. In other words, in Eqs. (19) and (20), AS n−1 /AS n  may be used as the period ratio, instead of the S n−1 /S n . It is thereby possible to ensure optimal control of the target setting bit rate T n+1  by reducing the effect of the local variation. 
     Alternatively, in the case where the average input bit rate S n+1  of the first stream in the (n+1) period can be obtained in advance, a ratio between the average period bit rate AS n  for the past M periods including the n period and the average period bit rate AS n+1  for past M periods including the (n+1) period may be used as the period ratio. In other words, in Eqs. (19) and (20), AS n /AS n+1  may be used as the period ratio, instead of the S n−1 /S n . It is thereby possible to control the target setting bit rate T n+1  with higher accuracy by reducing the effect of the local variation and using the latest input bit rate. 
     In the case where the average period bit rate AS n+1  for the past M periods including the (n+1) period is used as the period ratio, instead of Eq. (10), as expressed by Eq. (22), by substituting a ratio between the target setting bit rate T n+1  in the (n+1) period and the average period bit rate AS n+1  for the past M periods including the (n+1) period into the function f, the quantization step conversion factor α +1  in the (n+1) period can be calculated.
 
α n+1   =f ( T   n+1   /AS   n+1 )  (22)
 
     Though the method of calculating the target setting bit rate T n+1  in the second preferred embodiment has been discussed with reference to Eqs. (15), (16), (19), (20), and the like, in all the cases of the second preferred embodiment including the cases discussed with reference to these equations, the average period bit rate AC n  from the (n−M+1) period to the n period may be used, instead of the average output bit rate C n  in the n period. In Eqs. (15), (16), (19), (20), and the like, for example, AC n  is used instead of C n . It is thereby possible to ensure optimal control of the target setting bit rate T n+1  by gently evaluating the variation of C n . 
     The Third Preferred Embodiment 
     Next, the third preferred embodiment of the present invention will be discussed. Also in the third preferred embodiment, like in the first and second preferred embodiments, the transcoder  1  determines the target setting bit rate T n+1  of the second stream in the (n+1) period at the point of time when the n period is finished. 
     After the target setting bit rate T n+1  in the (n+1) period is determined, the quantization step conversion factor α n+1  is calculated in the same manner as discussed with reference to Eq. (5). In other words, the quantization step conversion factor α n+1  is calculated by performing the computation expressed by Eq. (9) or Eq. (10) using the function f shown in Eqs. (6) to (8). After the quantization step conversion factor α n+1  is calculated, the quantization step value Q of the second stream is calculated by using Eq. (4). 
     Eq. (23) is an equation for calculation of the target setting bit rate T n+1  in the (n+1) period. In this case, a value obtained by subtracting the average output bit rate C n  of the second stream which is already converted in the n period from the target setting bit rate T n  in the n period is determined as a target rate difference. The target rate difference is adjusted by multiplying the target rate difference by the target distortion ratio (d n /d). The target setting bit rate T n+1  in the (n+1) period can be calculated by adding the target rate difference adjusted by the target distortion ratio to the total target bit rate T of the second stream. 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     T 
                     + 
                     
                       k 
                       * 
                       
                         ( 
                         
                           
                             T 
                             n 
                           
                           - 
                           
                             C 
                             n 
                           
                         
                         ) 
                       
                       * 
                       
                         
                           d 
                           n 
                         
                         d 
                       
                     
                   
                 
               
               
                 
                   ( 
                   23 
                   ) 
                 
               
             
           
         
       
     
     In Eq. (23), “k” is a positive factor and a factor for adjusting the target rate difference and the target distortion ratio. A difference between the bit rate and the target bit rate in the n period is calculated by (T n −C n ) and the target setting bit rate T n+1  in the (n+1) period is adjusted by adding the target rate difference to the total target bit rate T. When the average output bit rate C n  exceeds the target setting bit rate T n , the (T n −C n ) becomes a negative value and the target setting bit rate T n+1  is suppressed and controlled so that the bit rate should be close to the target bit rate on the whole. In the reverse case where the average output bit rate C n  is smaller than the target setting bit rate T n , the (T n −C n ) becomes a positive value and the target setting bit rate T n+1  is increased and controlled so that the bit rate should be close to the target bit rate on the whole. 
     Further, the target rate difference is multiplied by the target distortion ratio (d n /d). When the average output bit rate C n  is smaller than the target setting bit rate T n  and the image quality is lower than the target quality, the d n /d becomes larger than 1 and adjustment is made toward the direction to increase an increase range of the target setting bit rate T n+1 . It is thereby possible to quickly improve the image quality. When the average output bit rate C n  is larger than the target setting bit rate T n  and the image quality is higher than the target quality, the d n /d becomes smaller than 1 and this decreases a suppression range of the target setting bit rate T n+1  and gently suppresses the bit rate. 
     Though the (T n −C n ) is used as the target rate difference (while the factor k is also used as a multiplier) in Eq. (23), the target rate difference may be obtained by substituting the (T n −C n ) into a function θ 3  as expressed by Eq. (24). 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     T 
                     + 
                     
                       
                         
                           θ 
                           3 
                         
                         ⁡ 
                         
                           ( 
                           
                             
                               T 
                               n 
                             
                             - 
                             
                               C 
                               n 
                             
                           
                           ) 
                         
                       
                       * 
                       
                         
                           d 
                           n 
                         
                         d 
                       
                     
                   
                 
               
               
                 
                   ( 
                   24 
                   ) 
                 
               
             
           
         
       
     
     Eq. (25) is an equation representing the specific example of the function θ 3 . 
     
       
         
           
             
               
                 
                   
                     
                       θ 
                       3 
                     
                     ⁡ 
                     
                       ( 
                       x 
                       ) 
                     
                   
                   = 
                   
                     { 
                     
                       
                         
                           
                             x 
                             - 
                             
                               b 
                               0 
                             
                           
                         
                         
                           
                             ( 
                             
                               x 
                               ≥ 
                               
                                 c 
                                 0 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               a 
                               0 
                             
                             * 
                             
                               x 
                               3 
                             
                           
                         
                         
                           
                             ( 
                             
                               
                                 c 
                                 0 
                               
                               &gt; 
                               x 
                               ≥ 
                               0 
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               a 
                               1 
                             
                             * 
                             
                               x 
                               3 
                             
                           
                         
                         
                           
                             ( 
                             
                               0 
                               &gt; 
                               x 
                               ≥ 
                               
                                 c 
                                 1 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             x 
                             + 
                             
                               b 
                               1 
                             
                           
                         
                         
                           
                             ( 
                             
                               
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                               &gt; 
                               x 
                             
                             ) 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   25 
                   ) 
                 
               
             
           
         
       
     
     A relation of a 0 , a 1 , b 0 , b 1 , c 0 , and c 1  in Eq. (25) is expressed by Eq. (26). A characteristic of the function θ 3  represented by such a condition is shown in  FIG. 5 . 
     
       
         
           
             
               
                 
                   
                     
                       
                         a 
                         0 
                       
                       &gt; 
                       0 
                     
                     , 
                     
                       
                         a 
                         1 
                       
                       &gt; 
                       0 
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         c 
                         0 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               0 
                             
                           
                         
                       
                     
                     , 
                     
                       
                         c 
                         1 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               1 
                             
                           
                         
                       
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         b 
                         0 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           0 
                         
                       
                     
                     , 
                     
                       
                         b 
                         1 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           1 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   26 
                   ) 
                 
               
             
           
         
       
     
     Thus, the function θ 3  has the characteristic that when the input value is close to “0”, an output does not vary significantly from “0”. In the specific examples expressed by Eqs. (25) and (26), the output value also significantly varies from the time when the input value becomes larger than c 0  or becomes smaller than −c 1 . 
     By using the function θ 3 , it is possible to avoid significant variation of the target setting bit rate T n+1  from the total target bit rate T even when the (T n −C n ) deviates a little from “0”. In a case where the target difference relatively largely deviates, by varying the target setting bit rate T n+1 , it is possible to optimally follow the target. 
     In the exemplary case shown in  FIG. 5 , the function θ 3  has the characteristic of bilateral symmetry (point symmetry with respect to the point (0, 0)). In other words, the rate of change is symmetric with respect to a boundary where the value of the (T n −C n ) is 0. By increasing a 1  and decreasing a 0 , for example, when the bit rate becomes larger than the target value, the bit rate can be controlled to quickly decrease to the target value and when the bit rate becomes smaller than the target value, the bit rate can be controlled to gently increase to the target value. 
     Though the target rate difference obtained by subtracting the average output bit rate C n  of the second stream in the n period from the target setting bit rate T n  in the n period is used in Eq. (23), the target rate difference is further adjusted in Eq. (27). 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     T 
                     + 
                     
                       k 
                       * 
                       
                         
                           S 
                           n 
                         
                         
                           S 
                           
                             n 
                             - 
                             1 
                           
                         
                       
                       * 
                       
                         ( 
                         
                           
                             T 
                             n 
                           
                           - 
                           
                             C 
                             n 
                           
                         
                         ) 
                       
                       * 
                       
                         
                           d 
                           n 
                         
                         d 
                       
                     
                   
                 
               
               
                 
                   ( 
                   27 
                   ) 
                 
               
             
           
         
       
     
     In Eq. (27), the target rate difference is multiplied by S n /S n−1 . The S n /S n−1  is a period ratio obtained by dividing the average input bit rate S n  of the first stream in the n period by the average input bit rate S n−1  of the first stream in the (n−1) period. In other words, the target difference is adjusted by multiplying the target rate difference by the period ratio. 
     By multiplying the target rate difference by the period ratio, it is possible to correct local variation of the target difference. When the average input bit rate S n  in the n period varies locally less than that in the (n−1) period, for example, the target rate difference (T n −C n ) accordingly increases quickly in some cases. Also in such a case, the target rate difference is adjusted by multiplying the target rate difference by the period ratio S n /S n−1  (the period ratio takes a value smaller than 1 in this case) and it is possible to avoid a quick increase of the target setting bit rate T n+1 . 
     Further, the target rate difference is multiplied by the target distortion ratio (d n /d). When the average output bit rate C n  is smaller than the target setting bit rate T n  and the image quality is lower than the target quality, the d n /d becomes larger than 1 and adjustment is made toward the direction to increase the increase range of the target setting bit rate T n+1 . It is thereby possible to quickly improve the image quality. When the average output bit rate C n  is larger than the target setting bit rate T n  and the image quality is higher than the target quality, the d n /d becomes smaller than 1 and this decreases the suppression range of the target setting bit rate T n+1  and gently suppresses the bit rate. 
     Also in the method of calculating the target setting bit rate T n+1  by using the function θ 3  expressed by Eq. (24), similarly, the target rate difference may be set by multiplying the target rate difference by the period ratio. The target setting bit rate T n+1  calculated by this method is shown in Eq. (28). Also in this case, the target rate difference is adjusted with the variation of the average input bit rate and it is possible to avoid significant variation of the target setting bit rate T n+1 . Further, the target rate difference is multiplied by the target distortion ratio (d n /d) and it is thereby possible to improve the image quality while maintaining the target bit rate. 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     T 
                     + 
                     
                       
                         
                           S 
                           n 
                         
                         
                           S 
                           
                             n 
                             - 
                             1 
                           
                         
                       
                       * 
                       
                         
                           θ 
                           3 
                         
                         ⁡ 
                         
                           ( 
                           
                             
                               T 
                               n 
                             
                             - 
                             
                               C 
                               n 
                             
                           
                           ) 
                         
                       
                       * 
                       
                         
                           d 
                           n 
                         
                         d 
                       
                     
                   
                 
               
               
                 
                   ( 
                   28 
                   ) 
                 
               
             
           
         
       
     
     In Eq. (27), the value obtained by dividing the average input bit rate S n  of the first stream in the n period by the average input bit rate S n−1  of the first stream in the (n−1) period is used as the period ratio. On the other hand, in the case where the average input bit rate S n+1  of the first stream in the (n+1) period can be obtained in advance, the average input bit rate S n+1  may be used. As discussed above, the case where the average input bit rate S n+1  can be obtained in advance refers to a case where there is spare time to perform buffering of information on the average input bit rate S n+1  and then calculate the target setting bit rate T n+1  in the (n+1) period. In this case, in Eq. (27), S n+1 /S n  is used, instead of the S n /S n−1 . Thus, by using the average input bit rate S n+1  of the first stream in the (n+1) period, it is possible to control the target setting bit rate T n+1  with higher accuracy. 
     In Eq. (28), the target rate difference obtained by using the function θ 3  is multiplied by the period ratio. Also in this case, similarly, the period ratio S n+1 /S n  may be used, instead of the period ratio S n /S n−1 . Also in this case, it is thereby possible to control the target setting bit rate T n+1  with higher accuracy. 
     In the case where the average input bit rate S n+1  of the first stream in the (n+1) period is used as the period ratio, instead of Eq. (9), as expressed by Eq. (21), by substituting the ratio between the target setting bit rate T n+1  in the (n+1) period and the average input bit rate S n+1  in the (n+1) period into the function f, the quantization step conversion factor α n+1  in the (n+1) period can be calculated. 
     In Eq. (27) and Eq. (28), the S n /S n , is used as the period ratio. Instead, a ratio between the average period bit rate AS n  for the past M periods including the n period and the average period bit rate AS n−1  for the past M periods including the (n−1) period may be used as the period ratio. In other words, in Eqs. (27) and (28), AS n /AS n−1  may be used as the period ratio, instead of the S n /S n−1 . It is thereby possible to ensure optimal control of the target setting bit rate T n+1  by reducing the effect of the local variation. 
     Alternatively, in the case where the average input bit rate S n+1  of the first stream in the (n+1) period can be obtained in advance, the ratio between the average period bit rate AS n+1  for the past M periods including the (n+1) period and the average period bit rate AS n  for the past M periods including the n period may be used as the period ratio. In other words, in Eqs. (27) and (28), AS n+1 /AS n  may be used as the period ratio, instead of the S n /S n−1 . It is thereby possible to control the target setting bit rate T n+1  with higher accuracy by reducing the effect of the local variation and using the latest input bit rate. 
     In the case where the average period bit rate AS n+1  for the past M periods including the (n+1) period is used as the period ratio, instead of Eq. (10), as expressed by Eq. (22), by substituting the ratio between the target setting bit rate T n+1  in the (n+1) period and the average period bit rate AS n+1  for the past M periods including the (n+1) period into the function f, the quantization step conversion factor α n+1  in the (n+1) period can be calculated. 
     Though the method of calculating the target setting bit rate T n+1  in the third preferred embodiment has been discussed with reference to Eqs. (23), (24), (27), (28), and the like, in all the cases of the third preferred embodiment including the cases discussed with reference to these equations, the average period bit rate AC n  from the (n−M+1) period to the n period may be used, instead of the average output bit rate C n  in the n period. In Eqs. (23), (24), (27), (28), and the like, for example, AC n  may be used instead of C n . It is thereby possible to ensure optimal control of the target setting bit rate T n+1  by gently evaluating the variation of C n . 
     The Fourth Preferred Embodiment 
     Next, the fourth preferred embodiment of the present invention will be discussed. Also in the fourth preferred embodiment, like in the first to third preferred embodiments, the transcoder  1  determines the target setting bit rate T n+1  of the second stream in the (n+1) period at the point of time when the n period is finished. The fourth preferred embodiment is an application example of the first to third preferred embodiments. 
     Though the value obtained by dividing the average distortion evaluation value d n  by the total target distortion evaluation value d is used as the target distortion ratio in Eq. (11), the target distortion ratio may be obtained by substituting the d n /d into the function θ 4  as expressed by Eq. (29), 
     
       
         
           
             
               
                 
                   
                     T 
                     
                       n 
                       + 
                       1 
                     
                   
                   = 
                   
                     T 
                     * 
                     k 
                     * 
                     
                       
                         θ 
                         4 
                       
                       ⁡ 
                       
                         ( 
                         
                           
                             d 
                             n 
                           
                           d 
                         
                         ) 
                       
                     
                   
                 
               
               
                 
                   ( 
                   29 
                   ) 
                 
               
             
           
         
       
     
     Eq. (30) is an equation representing the specific example of the function θ 4 . 
     
       
         
           
             
               
                 
                   
                     
                       θ 
                       4 
                     
                     ⁡ 
                     
                       ( 
                       x 
                       ) 
                     
                   
                   = 
                   
                     { 
                     
                       
                         
                           
                             x 
                             - 
                             
                               b 
                               0 
                             
                           
                         
                         
                           
                             ( 
                             
                               x 
                               ≥ 
                               
                                 1 
                                 + 
                                 
                                   c 
                                   0 
                                 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               
                                 a 
                                 0 
                               
                               * 
                               
                                 
                                   ( 
                                   
                                     x 
                                     - 
                                     1 
                                   
                                   ) 
                                 
                                 3 
                               
                             
                             + 
                             1 
                           
                         
                         
                           
                             ( 
                             
                               
                                 1 
                                 + 
                                 
                                   c 
                                   0 
                                 
                               
                               &gt; 
                               x 
                               ≥ 
                               1 
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               
                                 a 
                                 1 
                               
                               * 
                               
                                 
                                   ( 
                                   
                                     x 
                                     - 
                                     1 
                                   
                                   ) 
                                 
                                 3 
                               
                             
                             + 
                             1 
                           
                         
                         
                           
                             ( 
                             
                               1 
                               &gt; 
                               x 
                               ≥ 
                               
                                 1 
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             x 
                             + 
                             
                               b 
                               1 
                             
                           
                         
                         
                           
                             ( 
                             
                               
                                 1 
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                               &gt; 
                               x 
                             
                             ) 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   30 
                   ) 
                 
               
             
           
         
       
     
     A relation of a 0 , a 1 , b 0 , b 1 , c 0 , and c 1  in Eq. (30) is expressed by Eq. (31). A characteristic of the function θ 4  represented by such a condition is shown in  FIG. 6 . 
     
       
         
           
             
               
                 
                   
                     
                       
                         a 
                         0 
                       
                       &gt; 
                       0 
                     
                     , 
                     
                       
                         a 
                         1 
                       
                       &gt; 
                       0 
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         c 
                         0 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               0 
                             
                           
                         
                       
                     
                     , 
                     
                       
                         c 
                         1 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               1 
                             
                           
                         
                       
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         b 
                         0 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           0 
                         
                       
                     
                     , 
                     
                       
                         b 
                         1 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           1 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   31 
                   ) 
                 
               
             
           
         
       
     
     Thus, the function θ 4  has the characteristic that when an input value is close to “1”, an output does not vary significantly from “1”. In the specific examples expressed by Eqs. (30) and (31), the output value also significantly varies from the time when the input value becomes larger than (1+c 0 ) or becomes smaller than (1−c 1 ). 
     By using the function θ 4 , it is possible to avoid significant variation of the target setting bit rate T n+1  from the total target bit rate T even when the target distortion ratio (d n /d) deviates a little from “1”. In the case where the target distortion ratio relatively largely deviates, by varying the target setting bit rate T n+1 , it is possible to optimally follow the target. 
     In the exemplary case shown in  FIG. 6 , the function θ 4  has the characteristic of bilateral symmetry (point symmetry with respect to the point (1, 1)). The rate of change may be asymmetric with respect to a boundary where the value of the (d n /d) is 1. By increasing a 0  and decreasing a 1 , for example, when the distortion evaluation value becomes larger than the target distortion value (in other words, the image quality is degraded), quick improvement of the image quality can be performed and when the distortion evaluation value becomes smaller than the target distortion value, the bit rate can be controlled to gently increase to the target value. 
     Though the preferred embodiment in which d n /d is replaced by θ 4 (d n /d) in Eq. (11) has been discussed with reference to Eq. (29), similarly, d n /d may be replaced by θ 4 (d n /d) in Eqs. (15), (16), (19), and (20) in the second preferred embodiment. 
     When the distortion evaluation value of the image is larger than the target distortion value (the image quality is degraded as compared with the target quality), adjustment can be made toward the direction to increase the target setting bit rate T n+1  at a desired speed by using the function θ 4 . It is thereby possible to improve the image quality while maintaining the target bit rate on the whole. 
     Also in Eqs. (23), (24), (27), and (28) in the third preferred embodiment, d n /d may be replaced by θ 4 (d n /d). In this case, however, unlike in the case where the function θ 4  is applied to Eqs. (11), (15), and the like, it is necessary to change the characteristic of the function θ 4  a little by adjusting a 0 , a 1 , b 0 , b 1 , c 0 , and c 1 . This is because θ 4 (d n /d) is used as a parameter by which the total target bit rate T is multiplied in the case where the function θ 4  is applied to Eqs. (11), (15), and the like but θ 4 (d n /d) is used as a parameter by which the target rate difference is multiplied in the case where the function θ 4  is applied to Eq. (23) and the like in the third preferred embodiment. 
     The Fifth Preferred Embodiment 
     Next, the fifth preferred embodiment of the present invention will be discussed. Also in the fifth preferred embodiment, like in the first to fourth preferred embodiments, the transcoder  1  determines the target setting bit rate T n+1  of the second stream in the (n+1) period at the point of time when the n period is finished. 
     Though the target distortion ratio obtained by dividing the average distortion evaluation value d n  by the total target distortion evaluation value d is used as a parameter in the first to fourth preferred embodiments, a target distortion difference obtained by subtracting the total target distortion evaluation value d from the average distortion evaluation value d n  is used as a parameter in the fifth preferred embodiment. 
     Eq. (32) is an equation for calculation of the target setting bit rate T n+1  in the (n+1) period. The target setting bit rate T n+1 , is calculated by adding the target distortion difference (d n −d) to the total target bit rate T.
 
 T   n+1   =T+k *( d   n   −d )  (32)
 
     In Eq. (32), “k” is a positive factor and a factor for adjusting the target distortion difference. When the image quality is lower than the target quality and the (d n −d) becomes positive, adjustment is made toward the direction to increase the target setting bit rate T n+1  and the image quality is improved. When the image quality is higher than the target quality and the (d n −d) becomes negative, the target setting bit rate T n+1  is suppressed. The bit rate by which the target setting bit rate T n+1  is suppressed may be allocated later to another control unit time where improvement of the image quality will be needed. When the image quality is higher than the target quality, it is not always necessary to suppress the target setting bit rate T n+1 . 
     Though the (d n −d) is added as the target distortion difference to the total target bit rate T (while the factor k is also used as a multiplier) in Eq. (32), the target distortion difference may be obtained by substituting the (d n −d) into a function θ 5  as expressed by Eq. (33). In this case, the target setting bit rate T n+1  can be adjusted by multiplying the total target bit rate T by the target distortion difference.
 
 T   n+1   =T*θ   5 ( d   n   −d )  (33)
 
     Eq. (34) is an equation representing the specific example of the function θ 5 . 
     
       
         
           
             
               
                 
                   
                     
                       θ 
                       5 
                     
                     ⁡ 
                     
                       ( 
                       x 
                       ) 
                     
                   
                   = 
                   
                     { 
                     
                       
                         
                           
                             x 
                             - 
                             
                               b 
                               0 
                             
                             + 
                             1 
                           
                         
                         
                           
                             ( 
                             
                               x 
                               ≥ 
                               
                                 c 
                                 0 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               
                                 a 
                                 0 
                               
                               * 
                               
                                 x 
                                 3 
                               
                             
                             + 
                             1 
                           
                         
                         
                           
                             ( 
                             
                               
                                 c 
                                 0 
                               
                               &gt; 
                               x 
                               ≥ 
                               0 
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               
                                 a 
                                 1 
                               
                               * 
                               
                                 x 
                                 3 
                               
                             
                             + 
                             1 
                           
                         
                         
                           
                             ( 
                             
                               0 
                               &gt; 
                               x 
                               ≥ 
                               
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             x 
                             + 
                             
                               b 
                               1 
                             
                             + 
                             1 
                           
                         
                         
                           
                             ( 
                             
                               
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                               &gt; 
                               x 
                             
                             ) 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   34 
                   ) 
                 
               
             
           
         
       
     
     A relation of a 0 , a 1 , b 0 , b 1 , c 0 , and c 1  in Eq. (34) is expressed by Eq. (35). A characteristic of the function θ 5  represented by such a condition is shown in  FIG. 7 . 
     
       
         
           
             
               
                 
                   
                     
                       
                         a 
                         0 
                       
                       &gt; 
                       0 
                     
                     , 
                     
                       
                         a 
                         1 
                       
                       &gt; 
                       0 
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         c 
                         0 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               0 
                             
                           
                         
                       
                     
                     , 
                     
                       
                         c 
                         1 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               1 
                             
                           
                         
                       
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         b 
                         0 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           0 
                         
                       
                     
                     , 
                     
                       
                         b 
                         1 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           1 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   35 
                   ) 
                 
               
             
           
         
       
     
     Thus, the function θ 5  has the characteristic that when an input value is close to “0”, an output does not vary significantly from “1”. In the specific examples expressed by Eqs. (34) and (35), the output value also significantly varies from the time when the input value becomes larger than c 0  or becomes smaller than −c 1 . 
     By using the function θ 5 , it is possible to avoid significant variation of the target setting bit rate T n+1  from the total target bit rate T even when the (d n −d) deviates a little from “0”. In a case where the target distortion difference relatively largely deviates, by varying the target setting bit rate T n+1 , it is possible to improve the image quality in accordance with the degree of the distortion. 
     In the exemplary case shown in  FIG. 7 , the function θ 5  has the characteristic of bilateral symmetry (point symmetry with respect to the point (0, 1)). The rate of change may be asymmetric with respect to a boundary where the value of the (d n −d) is 0. By increasing a 0  and decreasing a 1 , for example, when the average distortion evaluation value d n  becomes larger than the total target distortion evaluation value d, since the image quality is degraded as compared with the target quality, quick improvement of the image quality is performed. In the reverse case where the average distortion evaluation value d n  becomes smaller than the total target distortion evaluation value d, since the image quality is higher than the target quality, the target setting bit rate T n+1  is gently suppressed. 
     Though the value of the (d n −d) is used as the target distortion difference in Eq. (32), the (d n −d) may be substituted into a function θ 6  as expressed by Eq. (36).
 
 T   n+1   =T+θ   6 ( d   n   −d )  (36)
 
     Eq. (37) is an equation representing the specific example of the function θ 6 . 
     
       
         
           
             
               
                 
                   
                     
                       θ 
                       6 
                     
                     ⁡ 
                     
                       ( 
                       x 
                       ) 
                     
                   
                   = 
                   
                     { 
                     
                       
                         
                           
                             x 
                             - 
                             
                               b 
                               0 
                             
                           
                         
                         
                           
                             ( 
                             
                               x 
                               ≥ 
                               
                                 c 
                                 0 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               a 
                               0 
                             
                             * 
                             
                               x 
                               3 
                             
                           
                         
                         
                           
                             ( 
                             
                               
                                 c 
                                 0 
                               
                               &gt; 
                               x 
                               ≥ 
                               0 
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             
                               a 
                               1 
                             
                             * 
                             
                               x 
                               3 
                             
                           
                         
                         
                           
                             ( 
                             
                               0 
                               &gt; 
                               x 
                               ≥ 
                               
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                             
                             ) 
                           
                         
                       
                       
                         
                           
                             x 
                             + 
                             
                               b 
                               1 
                             
                           
                         
                         
                           
                             ( 
                             
                               
                                 - 
                                 
                                   c 
                                   1 
                                 
                               
                               &gt; 
                               x 
                             
                             ) 
                           
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   37 
                   ) 
                 
               
             
           
         
       
     
     A relation of a 0 , a 1 , b 0 , b 1 , c 0 , and c 1  in Eq. (37) is expressed by Eq. (38). A characteristic of the function θ 6  represented by such a condition is shown in  FIG. 8 . 
     
       
         
           
             
               
                 
                   
                     
                       
                         a 
                         0 
                       
                       &gt; 
                       0 
                     
                     , 
                     
                       
                         a 
                         1 
                       
                       &gt; 
                       0 
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         c 
                         0 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               0 
                             
                           
                         
                       
                     
                     , 
                     
                       
                         c 
                         1 
                       
                       = 
                       
                         1 
                         
                           
                             3 
                             * 
                             
                               a 
                               1 
                             
                           
                         
                       
                     
                   
                   ⁢ 
                   
                     
 
                   
                   ⁢ 
                   
                     
                       
                         b 
                         0 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           0 
                         
                       
                     
                     , 
                     
                       
                         b 
                         1 
                       
                       = 
                       
                         
                           2 
                           3 
                         
                         * 
                         
                           c 
                           1 
                         
                       
                     
                   
                 
               
               
                 
                   ( 
                   38 
                   ) 
                 
               
             
           
         
       
     
     Thus, the function θ 6  has the characteristic that when an input value is close to “0”, an output does not vary significantly from “0”. In the specific examples expressed by Eqs. (37) and (38), the output value also significantly varies from the time when the input value becomes larger than c 0  or becomes smaller than −c 1 . 
     By using the function θ 6 , it is possible to avoid significant variation of the target setting bit rate T n+1  from the total target bit rate T even when the (d n −d) deviates a little from “0”. In a case where the target distortion difference relatively largely deviates, by varying the target setting bit rate T n+1 , it is possible to improve the image quality in accordance with the degree of the distortion. 
     In the exemplary case shown in  FIG. 8 , the function θ 6  has the characteristic of bilateral symmetry (point symmetry with respect to the point (0, 0)). The rate of change may be asymmetric with respect to a boundary where the value of the (d n −d) is 0. By increasing a 0  and decreasing a 1 , for example, when the average distortion evaluation value d n  becomes larger than the total target distortion evaluation value d, since the image quality is degraded as compared with the target quality, quick improvement of the image quality is performed. In the reverse case where the average distortion evaluation value d, becomes smaller than the total target distortion evaluation value d, since the image quality is higher than the target quality, the target setting bit rate T n+1  is gently suppressed. 
     The Sixth Preferred Embodiment 
     In the first to fifth preferred embodiments, the average distortion evaluation value d n  is used as a parameter in order to calculate the target setting bit rate T n+1 . Herein, in the first to fifth preferred embodiments, the average period distortion evaluation value Ad n  may be used, instead of the average distortion evaluation value d n . In Eqs. (11), (12), (15), (16), (19), (20), (23), (24), (27), (28), (29), (32), (33), (36), and the like, the average distortion evaluation value d n  has only to be replaced by the average period distortion evaluation value Ad n . 
     It is thereby possible to optimally control the target setting bit rate T n+1  while gently evaluating the variation of the average distortion evaluation value d n  and improving the image quality, without being affected by local distortion of the image quality. 
     The Seventh Preferred Embodiment 
     In the transcoder  1  shown in  FIG. 1 , the second decoder  17  for decoding the second stream outputted from the encoder  15  is separately provided. In the seventh preferred embodiment, as shown in  FIG. 9 , data outputted from a local decoder  151  in the encoder  15  is outputted to the distortion calculation part  18 . 
     The local decoder  151  is a processing block used to decode again the image data encoded in the encoder  15 , to thereby perform interframe prediction. By using the local decoder  151  both for encoding and for calculation of the distortion evaluation value, there is no necessity of separately providing a decoder for calculating the distortion evaluation value and this allows compact device configuration. 
     While the present invention has been described with reference to the particular illustrative embodiments, it is not to be restricted by the embodiments but only by the appended claims. It is to be appreciated that those skilled in the art can change or modify the embodiments without departing from the scope and spirit of the present invention.