Transcoder for conversion by obtaining a period conversion factor from a bit rate ratio

09749637 · 2017-08-29

Assignee

Inventors

Cpc classification

International classification

Abstract

If the number of frames in a GOP of an input stream is not less than 15, the GOP is determined as a control unit time. If the number of frames in the GOP is less than 15, the following GOP is connected thereto until the number of frames becomes not less than 15 and the connected GOPs are determined as a control unit time. After correcting the control unit time, the average input bit rate S.sub.n in each control unit time is obtained, and by using information on the input stream including the average input bit rate S.sub.n, a quantization step value of an output stream is calculated.

Claims

1. A transcoder for converting a first stream into a second stream, comprising: period determination circuitry configured to determine a control unit time; circuitry configured to acquire a bit rate of a first stream per the determined control unit time; quantization step value calculation circuitry configured to calculate a quantization step value of the second stream by using information on the first stream including the acquired bit rate of the first stream per the determined control unit time; and period conversion factor calculation circuitry configured to calculate a period conversion factor α.sub.N+1 in the (N+1) period, based on a ratio between a target bit rate T.sub.N+1 of the second stream in the (N+1) period and a bit rate S.sub.N of the first stream before the N period, by performing processing corresponding to α.sub.N+1=f(T.sub.N+1/S.sub.N) where f(x) is a function for obtaining a period conversion factor from a bit rate ratio x, wherein said period determination circuitry determines each control unit time so that a ratio of I picture frames included in each control unit time becomes not more than a predetermined ratio, and wherein said quantization step value calculation circuitry includes circuitry configured to calculate a quantization step value Q.sub.N+1 of the second stream of the (N+1) period, based on a quantization step value P.sub.N+1 of the first stream in the (N+1) period and said period conversion factor α.sub.N+1, by performing processing corresponding to Q.sub.N+1=α.sub.N+1×P.sub.N+1.

2. The transcoder according to claim 1, wherein said period determination circuitry determines a GOP as a control unit time if the ratio of I picture frames in the GOP is not more than a predetermined ratio, and said period determination circuitry connects a plurality of GOPs until the ratio of I picture frames becomes not more than said predetermined ratio and determines the connected GOPs as a control unit time if the ratio of I picture frames in a GOP exceeds said predetermined ratio.

3. The transcoder according to claim 2, wherein said period determination circuitry sets predetermined weights for I, P and B picture frames, respectively, and with weighting, it is judged whether the ratio of I picture frames in the GOP is not more than the predetermined ratio or not.

4. The transcoder according to claim 1, further comprising target bit rate determining circuitry configured to determine a target bit rate of a second stream in the (N+1) period based on a target bit rate of a whole second stream, a bit rate of a second stream converted before the N period and a target bit rate of a second stream in the N period.

5. The transcoder according to claim 4, wherein assuming that a ratio between a bit rate of a second stream converted before the N period and a target bit rate of a second stream in the N period is determined as a target ratio, said target hit rate determining circuitry calculates a target hit rate of a second stream in the (N+1) period based on a ratio between a target bit rate of a whole second stream and said target ratio.

6. The transcoder according to claim 5, wherein assuming that a ratio between a bit rate of a first stream in the (N−1) period and a bit rate of a first stream in the N period is determined as a period ratio, said target hit rate determining circuitry adjusts said target ratio by multiplying said target ratio by said period ratio.

7. The transcoder according to claim 5, wherein assuming that a ratio between a hit rate of a first stream in the N period and a bit rate of a first stream in the (N+1) period is determined as a period ratio, said target bit rate determining circuitry adjusts said target ratio by multiplying said target ratio by said period ratio.

8. The transcoder according to claim 4, wherein assuming that a value calculated based on a difference between a target bit rate of a second stream in the N period and a bit rate of a second stream converted before the N period is determined as a target difference, said target bit rate determining circuitry calculates a target bit rate of a second stream in the (N+1) period by adding said target difference to a target bit rate of a whole second stream.

9. The transcoder according to claim 8, wherein assuming that a ratio between a bit rate of a first stream in the N period and a bit rate of a first stream in the (N−1) period is determined as a period ratio, said target bit rate determining circuitry adjusts said target difference by multiplying said target difference by said period ratio.

10. The transcoder according to claim 8, wherein assuming that a value calculated based on a difference between a bit rate of a first stream in the N period and a bit rate of a first stream in the (N−1) period is determined as a period difference, said target bit rate determining circuitry adjusts said target difference by multiplying said target difference by said period difference.

11. The transcoder according to claim 8, wherein assuming that a value calculated based on a difference between a bit rate of a first stream in the N period and a bit rate of a first stream in the (N−1) period is determined as a period difference, said target bit rate determining circuitry adjusts said target difference by adding said period difference to said target difference.

Description

BRIEF DESCRIPTION OF THE DRAWINGS

(1) FIG. 1 is a block diagram showing a transcoder;

(2) FIG. 2 is a view showing information on an input stream (first stream) and an output stream (second stream) by control unit time;

(3) FIGS. 3A and 3B are views showing a method of correcting the control unit time (exemplary case where no correction is made) in accordance with a first preferred embodiment;

(4) FIGS. 4A and 4B are views showing a method of correcting the control unit time in accordance with the first preferred embodiment;

(5) FIGS. 5A and 5B are views showing another method of correcting the control unit time in accordance with the first preferred embodiment;

(6) FIGS. 6A and 6B are views showing still another method of correcting the control unit time in accordance with the first preferred embodiment;

(7) FIGS. 7A and 7B are views showing a method of correcting the control unit time (exemplary case where no correction is made) in accordance with a second preferred embodiment;

(8) FIGS. 8A and 8B are views showing a method of correcting the control unit time in accordance with the second preferred embodiment;

(9) FIGS. 9A and 9B are views showing another method of correcting the control unit time in accordance with the second preferred embodiment; and

(10) FIGS. 10A and 10B are views showing still another method of correcting the control unit time in accordance with the second preferred embodiment.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

1. Overall Structure of Transcoder

(11) Hereinafter, the preferred embodiments of the present invention will be discussed, referring to the drawings. FIG. 1 is a block diagram showing a transcoder 1 in accordance with the preferred embodiments. The transcoder 1 comprises a decoder 2 and an encoder 3.

(12) The decoder 2 inputs a first stream. The first stream is a stream of coded image. The decoder 2 decodes the first stream and outputs uncompressed image data to the encoder 3. The encoder 3 recodes the uncompressed image data which is decoded by the decoder 2 and outputs a second stream.

(13) 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.

(14) In the rate control methods (A) to (D) discussed later, various computations are performed in the decoder 2 and the encoder 3, and these computations performed in the decoder 2 and the encoder 3 may be implemented by hardware or may be implemented by software operations. In other words, the decoder 2 and the encoder 3 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.

2. Rate Control Methods

(15) FIG. 2 is a view showing information on streams that the transcoder 1 inputs or outputs, by control unit time. The transcoder 1 divides the processing time base into control unit times L.sub.n (n=1, 2 . . . ) and performs a rate control by using this control unit time L.sub.n as a unit of processing. In the following discussion, the control unit time L.sub.n is referred to as “the n-th period” as appropriate. In the preferred embodiments of the present invention, though one GOP is set as the control unit time L.sub.n basically, a plurality of successive GOPs are set as the control unit time L.sub.n in accordance with the state of the input stream as discussed later. As the control unit time L.sub.n, however, one frame, a plurality of successive frames, or the like may be set.

(16) 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.sub.n is an average bit rate of the first stream in the n period. The transcoder 1 comprises a buffer and can store information on average input bit rates S.sub.n for M periods. Specifically, the buffer can store information on the average input bit rates S.sub.n from the (n-M+1) period to the n period. An average period bit rate AS.sub.n is an average value of the average input bit rates S.sub.n from the (n-M+1) period to the n period. The average period bit rate AS.sub.n is expressed by Eq. 1.

(17) AS n = 1 M .Math. n - M + 1 n S i ( Eq . 1 )

(18) The decoder 2 acquires information on the total input bit rate S, the average input bit rate S.sub.n, the average period bit rate AS.sub.n, the quantization step value P in the n period or the like from the inputted first stream and outputs these information to the encoder 3. The encoder 3 uses these information to recode the image.

(19) 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 included in the transcoder 1 to set the total target bit rate T. A target setting bit rate T.sub.n is a target bit rate of the second stream in the n period. An average output bit rate C.sub.n is an average bit rate of the second stream converted in the n period. The transcoder 1 comprises a buffer and can store information on the average output bit rates C.sub.n for M periods. Specifically, the buffer can store information on the average output bit rates C.sub.n from the (n-M+1) period to the n period. An average period bit rate AC.sub.n is an average value of the average output bit rates C.sub.n from the (n-M+1) period to the n period. The average period bit rate AC.sub.n is expressed by Eq. 2. Though the buffer period used for calculation of the average period bit rate AS.sub.n or AC.sub.n is linked to the control unit time L.sub.n in these preferred embodiments, setting of the buffer period is not limited to this case. For example, one past frame at the point of time when coding is finished, a plurality of successive past frames, or the like may be set as the buffer period.

(20) A C n = 1 M .Math. n - M + 1 n C i ( Eq . 2 )

(21) Further, a quantization step conversion factor α.sub.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 the quantization step value of the first stream or a value P calculated from the quantization step value of the first stream by the quantization step conversion factor α.sub.n. This relation is expressed by Eq. 3.
Q=α.sub.nP  (Eq. 3)

(22) The initial value α.sub.1 of the quantization step conversion factor α.sub.n a is given by Eq. 4. Specifically, a value obtained by dividing the total target bit rate T of the second stream by the total input bit rate S of the first stream, i.e., a bit rate ratio, is substituted into function f, to obtain the initial value α.sub.1 of the quantization step conversion factor α.sub.n.
α.sub.1=f(T/S)  (Eq. 4)

(23) The function f is a function for obtaining a ratio of quantization step values from the ratio of bit rates, and assuming that the ratio of bit rates is R.sub.B and the ratio of quantization step values is R.sub.Q, the function f is generally expressed by Eq. 5.
R.sub.Q=f(R.sub.B)  (Eq. 5)

(24) A specific example of the function f will be discussed. In these preferred embodiments, as shown in Eq. 6, used are functions controlling the ratio of quantization step values with different features of types I, P and B (I picture, P picture and B picture) of picture or macroblock. In Eq. 6, f.sub.I(x), f.sub.P(x) and f.sub.B(x) are functions corresponding to the I picture, the P picture and the B picture, respectively.

(25) { f I ( x ) = .Math. I * x - δ I = 2.1 * x - 1.1 f P ( x ) = .Math. P * x - δ P = 2.1 * x - 0.8 f B ( x ) = .Math. B * x - δ B = 1.3 * x - 0.9 ( Eq . 6 )

(26) In Eq. 6, as values of ε.sub.I, ε.sub.P, ε.sub.B, δ.sub.I, δ.sub.P and δ.sub.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 ε.sub.I=2.1, ε.sub.P=2.1, ε.sub.B=1.3, δ.sub.I=1.1, δ.sub.P=0.8 and δ.sub.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 shown in FIG. 7, for example, on the basis of an activity value (act value) and a motion evaluation value (sad value), the values of ε and δ may be determined.

(27) { f I ( x ) = .Math. I ( a , s ) * x - δ I ( a , s ) f P ( x ) = .Math. P ( a , s ) * x - δ P ( a , s ) f B ( x ) = .Math. B ( a , s ) * x - δ B ( a , s ) ( Eq . 7 )

(28) In Eq. 7, “a” represents the act value and “s” represents the sad value, and ε.sub.I(a, s), ε.sub.P(a, s), ε.sub.B(a, s), −δ.sub.I(a, s), −δ.sub.P(a, s), −δ.sub.B(a, s) represent the values of ε and δ which are calculated by using the act value and the sad value as parameters.

(29) The activity value is obtained by calculating a differential absolute value sum of an average pixel value in a macroblock and a pixel value of each pixel in the macroblock by 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 differential absolute value sum of a pixel value of each pixel in a reference image macroblock and a pixel value of the corresponding pixel in a macroblock, by macroblock. In other words, the motion evaluation value is obtained by comparing each pixel in a macroblock and the corresponding pixel in the reference image macroblock and calculating an absolute value sum of differentials of pixel values of corresponding pixels in the same coordinate positions.

(30) More generally, assuming that an feature value of an image in the n period is determined as I.sub.Ln, f.sub.I(x), f.sub.P(x) and f.sub.B(x) are expressed by Eq. 8.

(31) { f I ( x ) = .Math. I ( I L n ) * x - δ I ( I L n ) f P ( x ) = .Math. P ( I L n ) * x - δ P ( I L n ) f B ( x ) = .Math. B ( I L n ) * x - δ B ( I L n ) ( Eq . 8 )

(32) In Eq. 8, ε.sub.I(I.sub.Ln), ε.sub.P(I.sub.Ln), ε.sub.B(I.sub.Ln), −δ.sub.I(I.sub.Ln), −δ.sub.P(I.sub.Ln) and −δ.sub.B(I.sub.Ln) represent the factors ε and δ which are determined by using the feature value I.sub.Ln of the image as parameters.

(33) Hereafter, four rate control methods (A) to (D) will be discussed.

2-1. Rate Control Method (A)

(34) First, on the rate control method (A), a method of calculating the quantization step conversion factor α.sub.n used for calculation of the quantization step value Q of the second stream will be discussed. The transcoder 1 calculates the quantization step conversion factor α.sub.n+1 after a lapse of the n period.

(35) Eq. 9 is an equation for calculation of the quantization step conversion factor α.sub.n+1. In Eq. 9, (T−C.sub.n) is obtained by subtracting the average output bit rate C.sub.n of the converted second stream in the n period from the total target bit rate T of the second stream. This value is referred to as a coefficient of variation. In Eq. 9, “k” represents an adjustment factor used for adjusting the coefficient of variation and is a positive value.
α.sub.n+1=k*(T−C.sub.n)+α.sub.1  (Eq. 9)

(36) Thus, the ratio of the quantization step values is adjusted toward a target by adding the coefficient of variation to the initial value α.sub.1 obtained by Eq. 4. In this meaning, the initial value α.sub.1 of the quantization step conversion factor can be referred to as a reference conversion factor.

(37) After obtaining the quantization step conversion factor α.sub.n+1 by using Eq. 9, the quantization step value Q of the second stream in the (n+1) period is obtained by using Eq. 3.

(38) For the above calculation of the coefficient of variation in Eq. 9, the average output bit rate C.sub.n in the n period is used. Herein, as shown in Eq. 10, the average period bit rate AC.sub.n from the (n-M+1) period to the n period may be used, instead of the average output bit rate C.sub.n.
α.sub.n+1=k*(T−AC.sub.n)+α.sub.1  (Eq.10)

(39) With Eq. 10, it is possible to gently control the coefficient of variation, without largely depending on local variation of the average output bit rate C.sub.n.

(40) Further, for the above calculation of the coefficient of variation in Eq. 9, the value obtained by subtracting the average output bit rate C.sub.n of the converted second stream in the n period from the total target bit rate T of the second stream is used. Herein, as shown in Eq. 11, the value obtained by this subtraction may be further divided by the average input bit rate S.sub.n of the first stream in the n period.

(41) α n + 1 = k * ( T - C n S n ) + α 1 ( Eq . 11 )

(42) With Eq. 11, even if the bit rate of the first stream locally varies significantly, it is possible to avoid a large effect of this on the coefficient of variation.

(43) Further, both the ideas for the methods of calculating the coefficient of variation by using Eqs. 10 and 11 may be taken. Specifically, as shown in Eq. 12, the average period bit rate AC.sub.n is used instead of the average output bit rate C.sub.n and the value obtained by subtraction is divided by the average input bit rate S.sub.n. With this, it is possible to more gently control the coefficient of variation.

(44) α n + 1 = k * ( T - A C n S n ) + α 1 ( Eq . 12 )

(45) In Eq. 11, the value obtained by subtracting the average output bit rate C.sub.n from the total target bit rate T is divided by the average input bit rate S.sub.n. Instead of this, as shown in Eq. 13, the value obtained by subtraction may be divided by the average period bit rate AS.sub.n of the first stream from the (n-M+1) period to the n period. With this method, it is possible to more gently control the coefficient of variation without any effect of local variation of the bit rate of the first stream.

(46) α n + 1 = k * ( T - C n AS n ) + α 1 ( Eq . 13 )

(47) Further, as shown in Eq. 14, the average period bit rate AC.sub.n may be used instead of the average output bit rate C.sub.n and the average period bit rate AS.sub.n may be used instead of the average input bit rate S.sub.n. With this, it is possible to more gently control the coefficient of variation.

(48) α n + 1 = k * ( T - A C n AS n ) + α 1 ( Eq . 14 )

2-2. Rate Control Method (B)

(49) Next, the rate control method (B) will be discussed. Also in the rate control method (B), the quantization step conversion factor is calculated and by using Eq. 3, the quantization step value Q of the second stream is calculated. The method of calculating the quantization step conversion factor, however, is different from that in the rate control method (A). In the rate control method (A), the initial value α.sub.1 of the quantization step conversion factor is obtained and by using the initial value α.sub.1 as the reference conversion factor, the variations from the reference conversion factor are sequentially obtained. On the other hand, in the rate control method (B), at the point of time when the n period is finished, a target setting bit rate T.sub.n+1 of the second stream in the (n+1) period is determined and by using the determined target setting bit rate T.sub.n+1, the quantization step conversion factor α.sub.n+1 in the (n+1) period is calculated.

(50) After determining the target setting bit rate T.sub.n+1 in the (n+1) period, the quantization step conversion factor α.sub.n+1 is calculated by the same method as that using Eq. 5. Specifically, by using the function f shown in Eqs. 6 to 8, the quantization step conversion factor α.sub.n+1 is calculated. More specifically, as shown Eq. 15, by substituting the ratio between the target setting bit rate T.sub.n+1 in the (n+1) period and the average input bit rate S.sub.n in the n period into the function f, the quantization step conversion factor α.sub.n+1 is calculated.
α.sub.n+1=f(T.sub.n+1/S.sub.n)  (Eq. 15)

(51) Alternatively, as shown in Eq. 16 by using the average period bit rate AS.sub.n from the (n-M+1) period to the n period, instead of the average input bit rate S.sub.n in the n period, the quantization step conversion factor α.sub.n+1 may be calculated.
α.sub.n+1=f(T.sub.n+1/AS.sub.n)  (Eq. 16)

(52) Eq. 17 is an equation for calculation of the target setting bit rate T.sub.n+1 in the (n+1) period. In other words, it represents the target setting bit rate T.sub.n+1 in the (n+1) period calculated by the transcoder 1 at the point of time when the n period is finished. Specifically, assuming that a value obtained by dividing the average output bit rate C.sub.n of the converted second stream in the n period by the target setting bit rate T.sub.n in the n period is determined as a target ratio, the target setting bit rate T.sub.n+1 in the (n+1) period can be calculated by dividing the total target bit rate T of the second stream by the target ratio.

(53) 0 T n + 1 = k * T C n T n ( Eq . 17 )

(54) In Eq. 17, “k” is a positive factor and a factor for adjusting the target setting bit rate T.sub.n+1. Thus, the ratio (target ratio) between the bit rate and the target in the n period is calculated by C.sub.n/T.sub.n and then the total target bit rate T is divided by the target ratio to adjust the target setting bit rate T.sub.n+1 in the (n+1) period, thereby controlling the bit rate to approximate the target bit rate on the whole.

(55) Though the value obtained by dividing the average output bit rate C.sub.n of the second stream in the n period by the target setting bit rate T.sub.n is used as the target ratio in Eq. 17, this target ratio is further adjusted in Eq. 18.

(56) T n + 1 = k * T S n - 1 S n * C n T n ( Eq . 18 )

(57) In Eq. 18, the target ratio is multiplied by S.sub.n−1/S.sub.n. This multiplier factor S.sub.n−1/S.sub.n is a value obtained by dividing the average input bit rate S.sub.n−1 of the first stream in the (n−1) period by the average input bit rate S.sub.n of the first stream in the n period and may be referred to as a period ratio of the average input bit rate. Multiplying the target ratio by the period ratio can adjust the target ratio.

(58) Thus, multiplying the target ratio by the period ratio can correct the local variation of the target ratio. For example, if the average input bit rate S.sub.n locally becomes smaller, sometimes the target ratio C.sub.n/T.sub.n accordingly becomes smaller. Also in such a case, multiplying the target ratio C.sub.n/T.sub.n by the period ratio S.sub.n−1/S.sub.n (the period ratio is larger than 1 in this case) makes it possible to adjust the target ratio and avoid large variation of the target setting bit rate T.sub.n+1. Conversely, if the average input bit rate S.sub.n locally becomes larger, the period ratio S.sub.n−1/S.sub.n is smaller than 1 and this suppresses sharp increase of the target ratio.

(59) In Eq. 18, the value obtained by dividing the average input bit rate S.sub.n−1 of the first stream in the (n−1) period by the average input bit rate S.sub.n of the first stream in the n period is used as the period ratio. On the other hand, in the case where the average input bit rate S.sub.n+1 of the first stream in the (n+1) period can be prefetched, the average input bit rate S.sub.n+1 may be used. The case where the average input bit rate S.sub.n+1 can be prefetched is a case where there is enough time to buffer the information on the average input bit rate S.sub.n+1 and then calculate the target setting bit rate T.sub.n+1 in the (n+1) period. In other words, this is a case where some processing delay is allowed. Eq. 19 is an equation for calculation of the target setting bit rate T.sub.n+1 by using the average input bit rate S.sub.n+1.

(60) T n + 1 = k * T S n S n + 1 * C n T n ( Eq . 19 )

(61) As shown in Eq. 19, as the period ratio used is S.sub.n/S.sub.n+1, that is, a value obtained by dividing the average input bit rate S.sub.n of the first stream in the n period by the average input bit rate S.sub.n+1 of the first stream in the (n+1) period. Thus, by using the average input bit rate S.sub.n+1 of the first stream in the (n+1) period, it is possible to control the target setting bit rate T.sub.n+1 with higher precision. In other words, it is possible to optimally control the target bit rate by using the latest input information.

(62) In a case where the average input bit rate S.sub.n+1 of the first stream in the (n+1) period is used as the period ratio, as shown in Eq. 20, instead of Eq. 15, the quantization step conversion factor α.sub.n+1 in the (n+1) period can be calculated by substituting the ratio between the target setting bit rate T.sub.n+1 in the (n+1) period and the average input bit rate S.sub.n+1 in the (n+1) period into the function f.
α.sub.n+1=f(T.sub.n+1/S.sub.n+1)  (Eq. 20)

(63) Further, in Eq. 18, S.sub.n−1/S.sub.n is used as the period ratio. Instead of S.sub.n−1/S.sub.n the ratio between the average period bit rate AS.sub.n−1 of past M periods including the (n−1) period and the average period bit rate AS.sub.n of past M periods including the n period may be used as the period ratio. In other words, in Eq. 18, AS.sub.n−1/AS.sub.n may be used, instead of S.sub.n−1/S.sub.n, as the period ratio. With this, it is possible to decrease the effect of local variation and optimally control the target setting bit rate T.sub.n+1.

(64) Alternatively, if the average input bit rate S.sub.n+1 of the first stream in the (n+1) period can be prefetched, the ratio between the average period bit rate AS.sub.n of past M periods including the n period and the average period bit rate AS.sub.n+1 of past M periods including the (n+1) period may be used as the period ratio. In other words, in Eq. 18, AS.sub.n/AS.sub.n+1 may be used, instead of S.sub.n−1/S.sub.n, as the period ratio. With this, it is possible to decrease the effect of local variation and control the target setting bit rate T.sub.n+1 with higher precision by using the latest input bit rate.

(65) In a case where the average period bit rate AS.sub.n+1 of past M periods including the (n+1) period is used as the period ratio, as shown in Eq. 21, instead of Eq. 16, the quantization step conversion factor α.sub.n+1 in the (n+1) period can be calculated by substituting the ratio between the target setting bit rate T.sub.n+1 in the (n+1) period and the average period bit rate AS.sub.n+1 of past M periods including the (n+1) period into the function f.
α.sub.n+1=f(T.sub.n+1/AS.sub.n+1)  (Eq.21)

(66) Further, though the method of calculating the target setting bit rate T.sub.n+1 of the rate control method (B) has been discussed by using Eqs. 17, 18, 19 and the like, in all the cases discussed in the above rate control method (B) including the case discussed by using these equations, the average period bit rate AC.sub.n from the (n-M+1) period to the n period may be used instead of the average output bit rate C.sub.n in the n period. For example, in Eqs. 17, 18, 19 and the like, AC.sub.n is used instead of C.sub.n. This makes it possible to more gently control the target setting bit rate T.sub.n+1.

2-3. Rate Control Method (C)

(67) Next, the rate control method (C) will be discussed. Also in the rate control method (C), the quantization step conversion factor is calculated, and by using Eq. 3, the quantization step value Q of the second stream is calculated. Further, in the rate control method (C), like in the rate control method (B), the target setting bit rate T.sub.n+1 of the second stream in the (n+1) period is determined at the point of time when the n period is finished, and by using the determined target setting bit rate T.sub.n+1, the quantization step conversion factor α.sub.n+1 in the (n+1) period is calculated.

(68) After determining the target setting bit rate T.sub.n+1 in the (n+1) period, the quantization step conversion factor α.sub.n+1 is calculated in the same method as that discussed by using Eq. 5. In other words, by using the function f shown in Eqs. 6 to 8, the quantization step conversion factor α.sub.n+1 is calculated. Specifically, as shown in Eq. 15, the quantization step conversion factor α.sub.n+1 is calculated by substituting the ratio between the target setting bit rate T.sub.n+1 in the (n+1) period and the average input bit rate S.sub.n in the n period into the function f. Alternatively, as shown in Eq. 16, the quantization step conversion factor α.sub.n+1 may be calculated by using the average period bit rate AS.sub.n from the (n-M+1) period to the n period, instead of the average input bit rate S.sub.n.

(69) Eq. 22 is an equation for calculation of the target setting bit rate T.sub.n+1 in the (n+1) period. In other words, it represents the target setting bit rate T.sub.n+1 in the (n+1) period calculated by the transcoder 1 at the point of time when the n period is finished. Specifically, assuming that a value obtained by subtracting the average output bit rate C.sub.n of the converted second stream in the n period from the target setting bit rate T.sub.n in the n period is determined as a target difference, the target setting bit rate T.sub.n+1 in the (n+1) period can be calculated by adding the target difference to the total target bit rate T of the second stream.
T.sub.n+1=T+k*(T.sub.n−C.sub.n)  (Eq. 22)

(70) In Eq. 22, “k” is a positive factor and a factor for adjusting the target setting bit rate T.sub.n+1. Thus, the difference between the bit rate and the target in the n period is calculated by (T.sub.n−C.sub.n) and then the target difference is added to the total target bit rate T, to thereby control the output stream to approximate the target bit rate.

(71) Though the value obtained by subtracting the average output bit rate C.sub.n of the second stream in the n period from the target setting bit rate T.sub.n in the n period is used as the target difference in Eq. 22, this target difference is further adjusted in Eq. 23.

(72) T n + 1 = T + k * S n S n - 1 * ( T n - C n ) ( Eq . 23 )

(73) In Eq. 23, the target difference is multiplied by S.sub.n/S.sub.n−1. This multiplier factor S.sub.n/S.sub.n−1 is the period ratio obtained by dividing the average input bit rate S.sub.n of the first stream in the n period by the average input bit rate S.sub.n−1 of the first stream in the (n−1) period. Multiplying the target difference by the period ratio can adjust the target difference.

(74) Thus, multiplying the target difference by the period ratio can correct the local variation of the target difference. For example, if the average input bit rate S.sub.n in the n period locally becomes smaller than that in the (n−1) period, sometimes the target difference (T.sub.n−C.sub.n) accordingly varies largely. Also in such a case, multiplying the target difference (T.sub.n−C.sub.n) by the period ratio S.sub.n/S.sub.n−1 (the period ratio is smaller than 1 in this case) makes it possible to adjust the target difference and avoid large variation of the target setting bit rate T.sub.n+1.

(75) In Eq. 23, the value obtained by dividing the average input bit rate S.sub.n of the first stream in the n period by the average input bit rate S.sub.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.sub.n+1 of the first stream in the (n+1) period can be prefetched, the average input bit rate S.sub.n+1 may be used. The case where the average input bit rate S.sub.n+1 can be prefetched is, as discussed above, a case where there is enough time to buffer the information on the average input bit rate S.sub.n+1 and then calculate the target setting bit rate T.sub.n+1 in the (n+1) period. In this case, in Eq. 23, S.sub.n+1/S.sub.n is used, instead of S.sub.n/S.sub.n−1, as the period ratio. Thus, by using the average input bit rate S.sub.n+1 of the first stream in the (n+1) period, it is possible to control the target setting bit rate T.sub.n+1 with higher precision.

(76) In a case where the average input bit rate S.sub.n+1 of the first stream in the (n+1) period is used as the period ratio, as shown in Eq. 20, instead of Eq. 15, the quantization step conversion factor α.sub.n+1 in the (n+1) period can be calculated by substituting the ratio between the target setting bit rate T.sub.n+1 in the (n+1) period and the average input bit rate S.sub.n+1 in the (n+1) period into the function f.

(77) Further, in Eq. 23, S.sub.n/S.sub.n−1 is used as the period ratio. Instead of S.sub.n/S.sub.n−1, the ratio between the average period bit rate AS.sub.n of past M periods including the n period and the average period bit rate AS.sub.n−1 of past M periods including the (n−1) period may be used as the period ratio. In other words, in Eq. 23, AS.sub.n/AS.sub.n−1 may be used, instead of S.sub.n/S.sub.n−1, as the period ratio. With this, it is possible to decrease the effect of local variation and optimally control the target setting bit rate T.sub.n+1.

(78) Alternatively, if the average input bit rate S.sub.n+1 of the first stream in the (n+1) period can be prefetched, the ratio between the average period bit rate AS.sub.n+1 of past M periods including the (n+1) period and the average period bit rate AS.sub.n of past M periods including the n period may be used as the period ratio. In other words, in Eq. 23, AS.sub.n+1/AS.sub.n may be used, instead of S.sub.n/S.sub.n−1, as the period ratio. With this, it is possible to decrease the effect of local variation and control the target setting bit rate T.sub.n+1 with higher precision by using the latest input bit rate.

(79) In a case where the average period bit rate AS.sub.n+1 of past M periods including the (n+1) period is used as the period ratio, as shown in Eq. 21, instead of Eq. 16, the quantization step conversion factor α.sub.n+1 in the (n+1) period can be calculated by substituting the ratio between the target setting bit rate T.sub.n+1 in the (n+1) period and the average period bit rate AS.sub.n+1 of past M periods including the (n+1) period into the function f.

(80) Further, though the method of calculating the target setting bit rate T.sub.n+1 of the rate control method (C) has been discussed by using Eqs. 22, 23 and the like, in all the calculation methods discussed in the rate control method (C) including the cases discussed by using these equations, the average period bit rate AC.sub.n from the (n-M+1) period to the n period may be used instead of the average output bit rate C.sub.n in the n period. For example, in Eqs. 22, 23 and the like, AC.sub.n may be used instead of C.sub.n. This makes it possible to more gently control the target setting bit rate T.sub.n+1.

2-4. Rate Control Method (D)

(81) Next, the rate control method (D) will be discussed. Also in the rate control method (D), like in the rate control method (C), the target setting bit rate T.sub.n+1 of the second stream in the (n+1) period is determined at the point of time when the n period is finished, and by using the determined target setting bit rate T.sub.n+1, the quantization step conversion factor α.sub.n+1 in the (n+1) period is calculated. In the rate control method (D), the method of determining the target setting bit rate T.sub.n+1 of the second stream in the (n+1) period is different from that of the rate control method (C).

(82) Eq. 24 is an equation for calculation of the target setting bit rate T.sub.n+1 in the (n+1) period. Like in the rate control method (C), the value obtained by subtracting the average output bit rate C.sub.n of the converted second stream in the n period from the target setting bit rate T.sub.n in the n period is used as the target difference. Though the target difference is adjusted, however, by multiplying the target difference by the period ratio in the rate control method (C), the target difference is multiplied by a period difference in the rate control method (D), as shown in Eq. 24.
T.sub.n+1=T+k*(S.sub.n−S.sub.n−1)*(T.sub.n−C.sub.n)  (Eq. 24)

(83) In Eq. 24, the target difference is multiplied by (S.sub.n−S.sub.n−1). This multiplier factor (S.sub.n−S.sub.n−1) is the period difference obtained by subtracting the average input bit rate S.sub.n−1 of the first stream in the (n−1) period from the average input bit rate S.sub.n of the first stream in the n period. Multiplying the target difference by the period difference can adjust the target difference. In Eq. 24, the factor “k” is a positive factor for adjusting the target setting bit rate T.sub.n+1.

(84) Thus, multiplying the target difference by the period difference can correct the local variation of the target difference. For example, if the average input bit rate S.sub.n, gradually becomes smaller, sometimes the average output bit rate C.sub.n accordingly becomes smaller and target difference (T.sub.n−C.sub.n) becomes a positive value. Also in such a case, the period difference (S.sub.n−S.sub.n−1) becomes a negative value, to thereby make such a correction that the target setting bit rate T.sub.n+1 should not be set larger. In other words, if the average input bit rate S.sub.n becomes smaller, contrary to this variation, the target setting bit rate T.sub.n+1 is controlled not to become larger.

(85) In the method of calculating the target setting bit rate T.sub.n+1 discussed by using Eq. 24, the target difference (T.sub.n−C.sub.n) is multiplied by the period difference. On the other hand, as shown in Eq. 25, the period difference may be added to the target difference. In Eq. 25, “h” is a positive factor for adjusting the target setting bit rate T.sub.n+1. Thus, by adding the period difference to the target difference, it is possible to control the target setting bit rate T.sub.n+1 with a feature different from that in the case of multiplication.
T.sub.n+1=T+h*(S.sub.n−S+k*(T.sub.n−C.sub.n)  (Eq. 25)

(86) In Eq. 24, the value obtained by subtracting the average input bit rate S.sub.n−1 of the first stream in the (n−1) period from the average input bit rate S.sub.n of the first stream in the n period is used as the period difference. Then, the target difference is multiplied by the period difference. On the other hand, in the case where the average input bit rate S.sub.n+1 of the first stream in the (n+1) period can be prefetched, the average input bit rate S.sub.n+1 may be used. In this case, in Eq. 24, (S.sub.n+1−S.sub.n) is used, instead of (S.sub.n−S.sub.n−1), as the period difference. Thus, by using the average input bit rate S.sub.n+1 of the first stream in the (n+1) period, it is possible to control the target setting bit rate T.sub.n+1 with higher precision.

(87) Also in Eq. 25, the value obtained by subtracting the average input bit rate S.sub.n−1 of the first stream in the (n−1) period from the average input bit rate S.sub.n of the first stream in the n period is used as the period difference. Then, the period difference is added to the target difference. On the other hand, in the case where the average input bit rate S.sub.n+1 of the first stream in the (n+1) period can be prefetched, the average input bit rate S.sub.n+1 may be used. In this case, in Eq. 25, (S.sub.n+1−S.sub.n) is used, instead of (S.sub.n−S.sub.n−1), as the period difference. Thus, by using the average input bit rate S.sub.n+1 of the first stream in the (n+1) period, it is possible to control the target setting bit rate T.sub.n+1 with higher precision.

(88) In a case where the average input bit rate S.sub.n+1 of the first stream in the (n+1) period is used as the period difference, as shown in Eq. 20, the quantization step conversion factor α.sub.n+1 in the (n+1) period can be calculated by substituting the ratio between the target setting bit rate T.sub.n+1 in the (n+1) period and the average input bit rate S.sub.n+1 in the (n+1) period into the function f.

(89) In Eqs. 24 and 25, (S.sub.n−S.sub.n−1) is used as the period difference. Instead of this period difference, the difference between the average period bit rate AS.sub.n of past M periods including the n period and the average period bit rate AS.sub.n−1 of past M periods including the (n−1) period may be used as the period difference. In other words, in Eqs. 24 and 25, (AS.sub.n−AS.sub.n−1) may be used, instead of (S.sub.n−S.sub.n−1), as the period difference. With this, it is possible to decrease the effect of local variation and optimally control the target setting bit rate T.sub.n+1.

(90) Alternatively, if the average input bit rate S.sub.n+1 of the first stream in the (n+1) period can be prefetched, the ratio between the average period bit rate AS.sub.n+1 of past M periods including the (n+1) period and the average period bit rate AS.sub.n of past M periods including the n period may be used as the period difference. In other words, in Eqs. 24 and 25, (AS.sub.n+1−AS.sub.n) may be used, instead of (S.sub.n−S.sub.n−1), as the period difference. With this, it is possible to decrease the effect of local variation and control the target setting bit rate T.sub.n+1 with higher precision by using the latest input bit rate.

(91) In a case where the average period bit rate AS.sub.n+1 of past M periods including the (n+1) period is used as the period difference, as shown in Eq. 21, the quantization step conversion factor α.sub.n+1 in the (n+1) period can be calculated by substituting the ratio between the target setting bit rate T.sub.n+1 in the (n+1) period and the average period bit rate AS.sub.n+1 of past M periods including the (n+1) period into the function f.

(92) Further, though the method of calculating the target setting bit rate T.sub.n+1 of the rate control method (D) has been discussed by using Eqs. 24, 25 and the like, in all the calculation methods discussed in the rate control method (D) including the cases discussed by using these equations, the average period bit rate AC.sub.n from the (n-M+1) period to the n period may be used instead of the average output bit rate C.sub.n in the n period. For example, in Eqs. 24, 25 and the like, AC.sub.n may be used instead of C.sub.n. This makes it possible to more gently control the target setting bit rate T.sub.n+1.

3. Method of Determining Control Unit Time

(93) Next, discussion will be made on a method of determining the control unit time. As discussed above, in the rate control methods (A) to (D), the average input bit rate S.sub.n in the control unit time L.sub.n is used in the process of calculating the quantization step value Q. Alternatively, the average input bit rate S.sub.n−1 or S.sub.n+1 in the control unit time L.sub.n−1 or L.sub.n+1 is used. Further, the average period bit rate AS.sub.n or the like is used.

(94) In the preferred embodiments of the present invention, as discussed above, one GOP period is used basically as the control unit time L.sub.n. If the number of frames in one GOP is small or the ratio of I picture frames in one GOP is high, however, there is a possibility that the average input bit rate S.sub.n may become high sharply. Then, in such a case, the transcoder 1 of the preferred embodiments corrects the control unit time L.sub.n to reduce variation of the average input bit rate S.sub.n.

3-1. The First Preferred Embodiment

(95) On the method of correcting the control unit time, the first preferred embodiment will be discussed. The decoder 2, first, acquires the number of frames included in an inputted GOP. Then, if the number of frames included in the GOP is not less than a predetermined threshold value, it is determined, with respect to the GOP, that one GOP serves as a control unit time L.sub.n. On the other hand, if the number of frames included in the GOP is less than the predetermined threshold value, the GOP is connected to the following GOP so that the number of frames included in the two connected GOPs can become not less than the predetermined threshold value. If the number of frames included in the two connected GOPs is less than the predetermined threshold value, the following GOP is further connected to the connected GOPs. Thus, the GOPs are connected to one another until the number of frames included in the connected GOPs becomes not less than the predetermined threshold value and it is determined that the connected GOPs serve as one control unit time.

(96) With reference to the exemplary cases shown in FIGS. 3A and 3B to 6A and 6B, correction of the control unit time will be discussed. In FIGS. 3A and 3B to 6A and 6B, the upper FIGS. 3A, 4A, 5A and 6A show cases where the GOPs of the input streams are in a one-to-one correspondence with the control unit times. On the other hand, the lower FIGS. 3B, 4B, 5B and 6B show cases where the control unit times are corrected by using the methods of determining the control unit times of the first preferred embodiment after the input streams having the same picture structures as those in the respective upper figures are inputted. In FIGS. 3A and 3B to 6A and 6B, the threshold value of the number of frames is set to 15. Specifically, if the number of frames in the GOP is less than 15, GOPs are connected until the number of frames becomes not less than 15, to correct the control unit time.

(97) The exemplary case shown in FIGS. 3A and 3B will be discussed. This case is the most general one. Each of the GOP1 to the GOP3 consists of 15 frames. Specifically, each of the GOP1 to the GOP3 has a basic picture structure “IBBPBBPBBPBBPBB”. Therefore, both in FIGS. 3A and 3B, the GOP1 to the GOP3 correspond to the control unit times L.sub.1 to L.sub.3, respectively. In other words, in this case, the control unit time is a unit of one GOP and not corrected.

(98) The exemplary case shown in FIGS. 4A and 4B will be discussed. In this case, the GOP1 and the GOP4 each have the basic picture structure “IBBPBBPBBPBBPBB”, consisting of 15 frames. The GOP2, however, has a picture structure “IBB” and the number of frames is 3. The GOP3 has a picture structure “IBBPBBPBBPBB” and the number of frames is 12.

(99) If the GOP1 to the GOP4 correspond to the control unit times L.sub.1 to L.sub.4, respectively, like in FIG. 4A, the respective values of the average input bit rates S.sub.2 and S.sub.3 of the control unit times L.sub.2 and L.sub.3 become high sharply. Then, as shown in FIG. 4B, the GOP2 and the GOP3 are connected to each other, to determine one control unit time L.sub.2. With this connection, the number of frames in the control unit time L.sub.2 becomes 15 and the variation of the average input bit rate S.sub.n can be reduced to be smaller.

(100) The exemplary case shown in FIGS. 5A and 5B will be discussed. In this case, the GOP1, the GOP3 and the GOP4 each have the basic picture structure “IBBPBBPBBPBBPBB”, consisting of 15 frames. The GOP2, however, has a picture structure “IBB” and the number of frames is 3.

(101) If the GOP1 to the GOP4 correspond to the control unit times L.sub.1 to L.sub.4, respectively, like in FIG. 5A, the value of the average input bit rate S.sub.2 of the control unit time L.sub.2 becomes high sharply. Then, as shown in FIG. 5B, the GOP2 and the GOP3 are connected to each other, to determine one control unit time L.sub.2. With this connection, the number of frames in the control unit time L.sub.2 becomes 18 and the variation of the average input bit rate S.sub.n can be reduced to be smaller. Thus, though the number of frames in the GOP3 is 15 and the condition for the control unit time is satisfied, since the number of frames in the GOP2 is smaller, the GOP3 is connected to the GOP2, to correct the control unit time. As a result, though the number of frames in the control unit time L.sub.2 becomes 18, which is larger than the number of frames in other control unit times, there is no problem in terms of reduction of the variation of the average input bit rate S.sub.n.

(102) The exemplary case shown in FIGS. 6A and 6B will be discussed. In this case, the GOP1 has the basic picture structure “IBBPBBPBBPBBPBB”, consisting of 15 frames. The GOP2, however, has a picture structure “IBB” and the number of frames is 3. The GOP3 has a picture structure “IBBPBBPBB” and the number of frames is 9, and the GOP4 has a picture structure “IBBPBBPBBPBBPBBPBB” and the number of frames is 18.

(103) If the GOP1 to the GOP4 correspond to the control unit times L.sub.1 to L.sub.4, respectively, like in FIG. 6A, the respective values of the average input bit rates S.sub.2 and S.sub.3 of the control unit times L.sub.2 and L.sub.3 become high sharply. Then, as shown in FIG. 6B, the GOP2, the GOP3 and the GOP4 are connected to one another, to determine one control unit time L.sub.2. With this connection, the number of frames in the control unit time L.sub.2 becomes 30 and the variation of the average input bit rate S.sub.n can be reduced to be smaller. Thus, if the number of frames is less than 15 after the two GOPs are connected to each other, the following GOP is further connected thereto, to thereby reduce the variation of the average input bit rate S.sub.n.

(104) Though the case where the control unit times are connected on a GOP basis has been discussed in the first preferred embodiment, the control unit times may be corrected on a frame basis.

(105) Thus, in the first preferred embodiment, the control unit time is corrected adaptively in accordance with the number of frames included in the GOPs of the input stream. This can reduce the variation of the average input bit rate S.sub.n, and with the constant average input bit rate S.sub.n, it is possible to perform an optimal rate control.

3-2. The Second Preferred Embodiment

(106) On the method of correcting the control unit time, the second preferred embodiment will be discussed. The decoder 2, first, acquires the number of I picture frames included in an inputted GOP. Then, if the ratio of the I picture frames included in the GOP is not more than a predetermined threshold value, it is determined, with respect to the GOP, that one GOP serves as a control unit time L.sub.n. On the other hand, if the ratio of the I picture frames included in the GOP exceeds the predetermined threshold value, the GOP is connected to the following GOP so that the ratio of the I picture frames included in the two connected GOPs can become not more than the predetermined threshold value. If the ratio of the I picture frames included in the two connected GOPs exceeds the predetermined threshold value, the following GOP is further connected to the connected GOPs. Thus, the GOPs are connected to one another until the ratio of the I picture frames included in the connected GOPs becomes not more than the predetermined threshold value and it is determined that the connected GOPs serve as one control unit time.

(107) With reference to the exemplary cases shown in FIGS. 7A and 7B to 10A and 10B, correction of the control unit time will be discussed. In FIGS. 7A and 7B to 10A and 10B, the upper FIGS. 7A, 8A, 9A and 10A show cases where the GOPs of the input streams are in a one-to-one correspondence with the control unit times. On the other hand, the lower FIGS. 7B, 8B, 9B and 10B show cases where the control unit times are corrected by using the methods of determining the control unit times of the second preferred embodiment after the input streams having the same picture structures as those in the respective upper figures are inputted. In FIGS. 7A and 7B to 10A and 10B, the threshold value of the ratio of I picture frames is set to 0.2. Specifically, if the ratio of the I picture frames included in the GOP exceeds 0.2, GOPs are connected until the ratio of the I picture frames becomes not more than 0.2, to correct the control unit time.

(108) The exemplary case shown in FIGS. 7A and 7B will be discussed. This case is the most general one. Each of the GOP1 to the GOP3 consists of 15 frames and each of the GOP1 to the GOP3 has a picture structure “IBBPBBPBBPBBPBB”. In each of the GOP1 to the GOP3, the ratio of the I picture frames is 1/15≈0.07. Therefore, both in FIGS. 7A and 7B, the GOP1 to the GOP3 correspond to the control unit times L.sub.1 to L.sub.3, respectively. In other words, in this case, the control unit time is a unit of one GOP and not corrected.

(109) The exemplary case shown in FIGS. 8A and 8B will be discussed. In this case, the GOP1 and the GOP4 each have the basic picture structure “IBBPBBPBBPBBPBB”, consisting of 15 frames, and the ratio of the I picture frames is 1/15≈0.07. The GOP2, however, has a picture structure “III” and the number of frames is 3. The ratio of the I picture frames is 3/3=1. The GOP3 has a picture structure “IBBPBBPBBPBB” and the number of frames is 12.

(110) If the GOP1 to the GOP4 correspond to the control unit times L.sub.1 to L.sub.4, respectively, like in FIG. 8A, the value of the average input bit rate S.sub.2 of the control unit time L.sub.2 becomes high sharply. Then, as shown in FIG. 8B, the GOP2, the GOP3 and the GOP4 are connected to one another, to determine one control unit time L.sub.2. Even if the GOP2 and the GOP3 are connected to each other, the ratio of the I picture frames is 4/15≈0.27, exceeding the threshold value of 0.2. With connection of the three GOPs, the number of frames in the control unit time L.sub.2 becomes 30 and the ratio of the I picture frames becomes 5/30≈0.17. This reduces the variation of the average input bit rate S.sub.n to be smaller.

(111) The exemplary case shown in FIGS. 9A and 9B will be discussed. In this case, the GOP1 and the GOP4 each have the basic picture structure “IBBPBBPBBPBBPBB”, consisting of 15 frames. The GOP2, however, has a picture structure “IPPIPP” and the ratio of the I picture frames is 2/6≈0.33. The GOP3 has a picture structure “IBBPBBPBBPBB”.

(112) If the GOP1 to the GOP4 correspond to the control unit times L.sub.1 to L.sub.4, respectively, like in FIG. 9A, the value of the average input bit rate S.sub.2 of the control unit time L.sub.2 becomes high sharply. Then, as shown in FIG. 9B, the GOP2 and the GOP3 are connected to each other, to determine one control unit time L.sub.2. With this connection, the ratio of the I picture frames in the control unit time L.sub.2 becomes 3/18≈0.17 and the variation of the average input bit rate S.sub.n can be reduced to be smaller.

(113) The exemplary case shown in FIGS. 10A and 10B will be discussed. In this case, the GOP1 and the GOP4 each have the basic picture structure “IBBPBBPBBPBBPBB”, consisting of 15 frames. The GOP2, however, has a picture structure “IPPPPP” and the ratio of the I picture frames is 1/6≈0.17, not more than the threshold value of 0.2. The GOP3 has a picture structure “IBBPBBPBB” and the ratio of the I picture frames is not more than 0.2. Therefore, both in FIGS. 10A and 10B, the GOP1 to the GOP4 correspond to the control unit times L.sub.1 to L.sub.4, respectively.

(114) The threshold value of the second preferred embodiment, 0.2, is only one example. In accordance with the bit rate of the input stream or the picture structure, an optimal value may be selected as appropriate. Though the case where the control unit times are connected on a GOP basis has been discussed in the second preferred embodiment, the control unit times may be corrected on a frame basis.

(115) Thus, in the second preferred embodiment, the control unit time is corrected adaptively in accordance with the ratio of the I picture frames included in the GOP of the input stream. This can reduce the variation of the average input bit rate S.sub.n, and with the constant average input bit rate S.sub.n, it is possible to perform an optimal rate control.

3-3. Variation

(116) Next, a variation will be discussed. This is a variation of the above-discussed second preferred embodiment. In the second preferred embodiment, the number of I picture frames relative to the number of all frames included in the GOP is the ratio of the I picture frames. In MPEG2, generally, the bit ratio of I, P and B picture frames constituting the GOP is I:P:B=5:3:1. In this variation, respective weighted numbers are obtained by multiplying the respective numbers of I, P and B picture frames constituting the GOP by the bit ratio and the ratio of the I picture frames is obtained by using these weighted numbers.

(117) Since the ratio of the I picture frames becomes higher with weighting, the threshold value has only to be set to any value larger than 0.2 which is used in the second preferred embodiment. For example, any value in a range from 0.22 to 0.24 may be used.

(118) In the exemplary case shown in FIGS. 10A and 10B, for example, the ratio of the I picture frames in the GOP2 is 1/6≈0.17, which satisfies the condition for the control unit time in the second preferred embodiment. On the other hand, when weighting, the number of I picture frames is 1×5=5 and the number of P picture frames is 5×3=15. Therefore, the weighted number of all frames in the GOP2 is 20 and the weighted ratio of the I picture frames in the GOP2 is 5/20=0.25.

(119) Then, discussion will be made on the control unit time made by connection of the GOP2 and the GOP3. The weighted number of I picture frames in the GOP3 is 1×5=5, the weighted number of P picture frames is 3×3=9 and the weighted number of B picture frames is 8×1=8. Therefore, the weighted number of all frames in the GOP3 is 22 and the weighted number of I picture frames is 5. In the control unit time by connection of the GOP2 and the GOP3, since the weighted number of all frames is 42 and the weighted number of I picture frames is 10, the weighted ratio of the I picture frames is 10/42≈0.24.

(120) Therefore, if the threshold value is 0.24, correction is made with the period made by connection of the GOP2 and the GOP3 as the control unit time. If the threshold value is less than 0.24, the GOP4 is further connected thereto.

(121) Thus, by weighting with the bit ratio of the I, P and B picture frames, it is possible to further reduce the variation of the average input bit rate S.sub.n to be smaller.

(122) While the invention has been shown and described in detail, the foregoing description is in all aspects illustrative and not restrictive. It is therefore understood that numerous modifications and variations can be devised without departing from the scope of the invention.