Encoder

An average quantization error value of each of I, P, and B pictures in an encoded unit of processing is calculated as an actually measured value having a large variation. An average quantization error value of each of I, P, and B pictures in an uncoded unit of processing is set as a target value having a small variation. In the encoding of the uncoded unit of processing, a result of the encoding of the encoded unit of processing is referenced and fed back thereto. By uniformly setting respective quantization errors of images and further by uniformly setting the respective qualities of the images, the image quality of a whole stream can be subjectively improved. Since the prefetch of the uncoded unit of processing is not needed, it is possible to perform real-time processing without any increase in the circuit scale.

TECHNICAL FIELD

The present invention relates to a technique for subjectively improving the image quality of a whole stream by uniformly setting the respective qualities of images in an encoder for encoding an input image into an output image.

BACKGROUND ART

An encoder encodes an input image into an output image to compress the input image having a large data volume into the output image having a small data volume. The encoder generates a prediction image on the basis of the input image and a reference image and further generates a differential image on the basis of the input image and the prediction image. The encoder can improve the compression coding efficiency by encoding the differential image without encoding the input image.

An encoder disclosed in Patent Document 1 calculates a prediction error of each image on the basis of an input image and a prediction image in order to evaluate the quality of each image. Herein, the prediction error refers to a sum of absolute differences (SAD) obtained by adding up differential absolute values of corresponding pixel values of the input image and the prediction image with respect to all the corresponding pixels. Alternatively, the prediction error refers to a sum of square differences (SSD) obtained by adding up differential square values of corresponding pixel values of the input image and the prediction image with respect to all the corresponding pixels.

When the encoder determines that the prediction error of an image to be currently encoded sharply increases, the encoder estimates that the quality of the image to be currently encoded is sharply degraded. Then, for an image to be encoded next, the encoder allocates the target amount of codes larger than that of the image to be currently encoded. Thus, the encoder can improve the quality of the image to be encoded next as compared with the quality of the image to be currently encoded. Further, the encoder can avoid an overflow of an output image buffer.[Patent Document 1] Japanese Patent Application Laid Open Gazette No. 2002-125235

The encoder disclosed in Patent Document 1 can improve the quality of the image to be encoded next even if the quality of the image to be currently encoded is degraded. When the qualities of images in a whole stream are not uniform, however, since an image of high quality and an image of low quality alternately appear, there occurs flicker and the image quality is thereby subjectively degraded. In a whole stream having a little motion, particularly, the subjective degradation of image quality is remarkable.

DISCLOSURE OF INVENTION

The present invention is intended for an encoder for encoding an input image into an output image. According to an aspect of the present invention, the encoder comprises a quantization error calculation part for calculating a quantization error by comparing the input image with a decoded image obtained by decoding once-encoded input image, a measured quantization error storage part for storing a measured quantization error which is an actually measured value of the quantization error with respect to an encoded unit of processing which is already encoded, and a target quantization error setting part for setting a target quantization error which is a target value of the quantization error by making reference to a variation in the measured quantization errors of images in an uncoded unit of processing which is not encoded yet while reducing the variation of the images.

By the above aspect of the present invention, since the qualities of the images are uniformly set, it is possible to subjectively improve the image quality of a whole stream. Further, since the prefetch of the uncoded unit of processing is not needed, it is possible to perform real-time processing without any increase in the circuit scale of the encoder.

According to another preferred embodiment of the present invention, the encoder further comprises a target code amount setting part for setting the target amount of codes so that the target quantization error can be achieved for each of the images in the uncoded unit of processing and a quantization step value setting part for setting a quantization step value so that the target amount of codes can be achieved for each of the images in the uncoded unit of processing.

Since a quantization step value is set for each of the images in the uncoded unit of processing, it is possible to reduce the variation in the quantization errors of the images in the uncoded unit of processing.

Therefore, it is an object of the present invention to provide a technique for subjectively improving the image quality of a whole stream in an encoder for encoding an input image into an output image.

BEST MODE FOR CARRYING OUT THE INVENTION

Constituent Elements of Encoder

Hereinafter, with reference to figures, the preferred embodiment of the present invention will be discussed.FIG. 1is a block diagram showing constituent elements of an encoder E. The encoder E may function alone. The encoder E may be a constituent element of a transcoder or a translator and function together with a decoder. Constituent elements of the encoder E are divided into three groups.

The first group of constituent elements serves to perform prediction on an input image. The first group of constituent elements includes an input image buffer11, a reference image buffer12, a prediction image generation part13, a subtracter14, an adder15, and the like.

The input image buffer11inputs an input image from the outside of the encoder E. The reference image buffer12inputs a reference image from the adder15. The prediction image generation part13inputs the input image from the input image buffer11and further inputs the reference image from the reference image buffer12. The prediction image generation part13generates a prediction image on the basis of the input image and the reference image.

When the prediction image generation part13generates a prediction image of I picture which is an intraframe prediction image, the prediction image generation part13determines a prediction mode. When the prediction image generation part13generates a prediction image of P picture which is an interframe forward prediction image or a prediction image of B picture which is an interframe bidirectional prediction image, the prediction image generation part13determines a motion vector.

The subtracter14inputs the input image from the input image buffer11and further inputs the prediction image from the prediction image generation part13. The subtracter14subtracts the prediction image from the input image to thereby generate a differential image. The adder15inputs the differential image from an inverse frequency conversion part26and further inputs the prediction image from the prediction image generation part13. The adder15adds the differential image and the prediction image to thereby generate a reference image. The operation performed by the first group of constituent elements thus takes a round.

The second group of constituent elements serves to perform encoding of the differential image. The second group of constituent elements includes a frequency conversion part21, a quantization part22, an encoding part23, an output image buffer24, an inverse quantization part25, an inverse frequency conversion part26, and the like.

The frequency conversion part21inputs the differential image from the subtracter14and performs frequency conversion. The quantization part22inputs the frequency-converted differential image from the frequency conversion part21and performs quantization. The encoding part23inputs the quantized differential image from the quantization part22, further inputs the prediction mode or the motion vector from the prediction image generation part13, and performs encoding. The output image buffer24outputs an output image to the outside of the encoder E.

The inverse quantization part25inputs the quantized differential image from the quantization part22and performs inverse quantization. The inverse frequency conversion part26inputs the inversely-quantized differential image from the inverse quantization part25and performs inverse frequency conversion. The operation performed by the second group of constituent elements thus takes a round. The differential image outputted from the inverse frequency conversion part26includes a quantization error due to the operations of the quantization part22and the inverse quantization part25, as compared with the differential image inputted to the frequency conversion part21.

The third group of constituent elements serves to uniformly set the respective qualities of the images. The third group of constituent elements includes a quantization error calculation part31, a measured quantization error storage part32, a target quantization error setting part33, a target code amount setting part34, a quantization step value setting part35, and the like.

{Outline of Method of Uniformly Setting Qualities of Images}

An outline of a method of uniformly setting the respective qualities of images will be discussed. With reference toFIGS. 2 and 3, the quantization error calculation part31and the measured quantization error storage part32will be described. With reference toFIG. 4, the target quantization error setting part33, the target code amount setting part34, and the quantization step value setting part35will be described.

[Quantization Error Calculation Part and Measured Quantization Error Storage Part]

The quantization error calculation part31inputs the input image from the input image buffer11, further inputs the reference image from the adder15, and calculates a quantization error. The measured quantization error storage part32stores the quantization error of an encoded unit of processing which is already encoded. The encoded unit of processing will be described with reference toFIG. 3.

FIG. 2is a view showing a definition of the quantization error.FIG. 2(a) shows an input image A, assuming that the image A has a size of 4×4. Reference signs A1, . . . , and A16represent pixels of the input image A and also represent respective pixel values in the input image A.FIG. 2(b) shows a decoded image B, assuming that the image B has a size of 4×4. Reference signs B1, . . . , and B16represent pixels of the decoded image B and also represent respective pixel values in the decoded image B.FIG. 2(c) shows respective definitions of the two types of quantization errors.

A definition of the first type of quantization error will be discussed. The quantization error is defined by a sum of absolute differences (SAD) obtained by adding up differential absolute values of the corresponding pixel values of the input image and the decoded image with respect to all the corresponding pixels. Specifically, as shown in the upper side ofFIG. 2(c), the quantization error Diff is defined by Σ|AN-BN|. Herein, the sum is calculated for the sixteen pixels.

A definition of the second type of quantization error will be discussed. The quantization error is defined by a sum of square differences (SSD) obtained by adding up differential square values of the corresponding pixel values of the input image and the decoded image with respect to all the corresponding pixels. Specifically, as shown in the lower side ofFIG. 2(c), the quantization error Diff is defined by Σ(AN-BN)2. Herein, the sum is calculated for the sixteen pixels.

In the calculation of the quantization error by any one of the above-discussed two methods, both a luminance signal and a color difference signal of each pixel may be used. There may be a case where the quantization error with respect to the luminance signal and that with respect to the color difference signal are calculated and an average or a weighted average of these errors is obtained. Alternatively, there may be another case where either one of the luminance signal and the color difference signal is used to calculate the quantization error.

FIG. 3is a view showing a time variation of the quantization error Diff. The vertical axis represents the quantization error Diff and the horizontal axis represents time. The characters “I”, “P”, and “B” below the horizontal axis represent which of the I, P, and B pictures an image to be inputted with time is.

On the left side ofFIG. 3shown is a time variation of the quantization error Diff in the encoded unit of processing which is already encoded. In this case, with respect to the encoded unit of processing, encoding is already performed in the encoding part23and the quantization errors Diff are already stored in the measured quantization error storage part32. In other words, the quantization errors Diff in the encoded unit of processing are actually-measured ones and indicated by a bar chart using solid lines.

On the right side ofFIG. 3shown is a time variation of the quantization error Diff in the uncoded unit of processing which is not encoded. In this case, with respect to the uncoded unit of processing, encoding is not performed yet in the encoding part23and no quantization error Diff is stored yet in the measured quantization error storage part32. In other words, the quantization errors Diff in the uncoded unit of processing are non-measured ones and indicated by a bar chart using broken lines.

In the encoded unit of processing, there is a large variation in the quantization errors Diff of the images and in other words, a large variation in the qualities of the images. With respect to the uncoded unit of processing, the target quantization error setting part33, the target code amount setting part34, and the quantization step value setting part35perform the respective operations so that the variation in the quantization errors Diff of the images may become small and in other words, the variation in the qualities of the images may become small.

A result of the encoding of the encoded unit of processing is feedback to the encoding of the uncoded unit of processing. The target quantization error setting part33, the target code amount setting part34, and the quantization step value setting part35perform the respective operations so that the variation in the qualities of the images in the uncoded unit of processing may become smaller than that in the qualities of the images in the encoded unit of processing. Further, the target quantization error setting part33, the target code amount setting part34, and the quantization step value setting part35perform the respective operations so that the variation in the qualities of images in the next uncoded unit of processing may become smaller than that in the qualities of the images in the immediately preceding uncoded unit of processing.

The encoded unit of processing and the uncoded unit of processing are arbitrary units of processing. As a first specific example, each of the encoded unit of processing and the uncoded unit of processing may be a unit of one GOP (Group of Pictures) or a plurality of (an arbitrary number of) GOPs. As a second specific example, both the encoded unit of processing and the uncoded unit of processing may be included in a unit of one GOP. Of course, an exemplary unit of processing is not limited to these specific examples.

In the first specific example, there is a large variation in the qualities of images in an already-encoded unit of one GOP or an arbitrary number of GOPs. In an uncoded unit of one GOP or an arbitrary number of GOPs, however, there is a small variation in the qualities of images. In the first specific example, it is easier than in the second specific example to uniformly set the qualities of the images.

In the second specific example, there is a large variation in the qualities of images in the first half of the unit of one GOP which is already encoded. In the latter half of the unit of one GOP which is not encoded yet, however, there is a small variation in the qualities of images. In the second specific example, it is possible to uniformly set the qualities of the images in more real time than in the first specific example.

[Target Quantization Error Setting Part, Target Code Amount Setting Part, and Quantization Step Value Setting Part]

The target quantization error setting part33inputs the quantization error of the encoded unit of processing from the measured quantization error storage part32and further inputs an output rate of the encoded unit of processing from the output image buffer24. The target quantization error setting part33sets a quantization error of the uncoded unit of processing on the basis of the quantization error and the output rate of the encoded unit of processing.

The target code amount setting part34inputs the quantization error of the uncoded unit of processing from the target quantization error setting part33. The target code amount setting part34sets the target amount of codes in the uncoded unit of processing on the basis of the quantization error of the uncoded unit of processing.

The quantization step value setting part35inputs the target amount of codes in the uncoded unit of processing from the target code amount setting part34. The quantization step value setting part35sets a quantization step value of the uncoded unit of processing on the basis of the target amount of codes in the uncoded unit of processing.

The quantization part22and the inverse quantization part25perform quantization and inverse quantization of the uncoded unit of processing, respectively, on the basis of the quantization step value of the uncoded unit of processing.

FIG. 4is a view showing an outline of a method of uniformly setting the respective qualities of the images. In the encoded unit of processing, an average quantization error value Diff_Ave is an average of actually measured values of respective quantization errors Diff of the I, P, B pictures. In the uncoded unit of processing, an average quantization error value Diff_Ave is an average of target values of the respective quantization errors Diff of the I, P, B pictures. As shown inFIG. 3, the actually measured values are different from the target values. The actually measured values and the target values are indicated by the bar charts using solid lines and broken lines, respectively.

The target quantization error setting part33calculates respective average quantization error values321,322, and323of the I, P, B pictures in the encoded unit of processing. The target quantization error setting part33uniformly sets the respective average quantization error values Diff_Ave of the I, P, B pictures in the uncoded unit of processing as indicated by the arrow331.

The target code amount setting part34sets respective target amounts of codes341,342, and343of the I, P, B pictures in the uncoded unit of processing so that the respective average quantization error values Diff_Ave of the I, P, B pictures in the uncoded unit of processing can be achieved.

The quantization step value setting part35sets respective quantization step values351,352, and353of the I, P, B pictures in the uncoded unit of processing so that the respective target amounts of codes341,342, and343of the I, P, B pictures in the uncoded unit of processing can be achieved.

As the method of uniformly setting the average quantization error values Diff_Ave and the method of setting the target amounts of codes341,342, and343and the quantization step values351,352, and353, a plurality of methods will be discussed with reference toFIGS. 5 to 9.

{The First Method of Uniformly Setting Quantization Errors of Images}

A first method of uniformly setting the quantization errors of the images will be discussed. The target quantization error setting part33compares the output rate of the encoded unit of processing with a target rate set by a user of the encoder E. The target quantization error setting part33uniformly sets the average quantization error values Diff_Ave in the uncoded unit of processing so that an output rate of the uncoded unit of processing can be approximated to the target rate set by the user of the encoder E.

FIG. 5is a view showing a method of uniformly setting the quantization errors of the images in a case where the output rate of the encoded unit of processing is lower than the target rate. In other words, the output rate of the uncoded unit of processing may be higher than the output rate of the encoded unit of processing.

The target quantization error setting part33calculates the respective average quantization error values321,322, and323of the I, P, B pictures in the encoded unit of processing. The target quantization error setting part33sets the minimum value out of the average quantization error values321,322, and323as the uniform average quantization error value Diff_Ave for the I, P, B pictures in the uncoded unit of processing as indicated by the arrow332. It is desirable, as a matter of course, that the output rate of the uncoded unit of processing should be equal to the target rate or should not be extremely higher than the target rate.

The target quantization error setting part33sets the uniform average quantization error value Diff_Ave of the uncoded unit of processing to be smaller than the average quantization error value321of the I picture in the encoded unit of processing and to be equal to the average quantization error values322and323of the P and B pictures in the encoded unit of processing.

In order to make the quantization error smaller, it is desirable that the quantization step value should be set to be smaller and the target amount of codes should be set to be larger.

The target code amount setting part34increases the target amount of codes341of the I picture in the uncoded unit of processing to be larger than the target amount of codes of the I picture in the encoded unit of processing which is set earlier. The target code amount setting part34keeps the target amounts of codes342and343of the P and B pictures in the uncoded unit of processing equal to the target amounts of codes of the P and B pictures in the encoded unit of processing which are set earlier, respectively. The target code amount setting part34increases the target amount of codes per a picture in the uncoded unit of processing to be larger than the target amount of codes per a picture in the encoded unit of processing which is set earlier.

The quantization step value setting part35decreases the quantization step value351of the I picture in the uncoded unit of processing to be smaller than the quantization step value of the I picture in the encoded unit of processing which is set earlier. The quantization step value setting part35keeps the quantization step values352and353of the P and B pictures in the uncoded unit of processing equal to the quantization step values of the P and B pictures in the encoded unit of processing which are set earlier, respectively. This feedback is repeated.

The image quality of the I picture in the uncoded unit of processing becomes higher than that of the I picture in the encoded unit of processing. The respective image qualities of the P and B pictures in the uncoded unit of processing become equal to the respective image qualities of the P and B pictures in the encoded unit of processing, respectively.

The overall image quality of the uncoded unit of processing becomes higher than that of the encoded unit of processing. Further, since the qualities of the images in the uncoded unit of processing are uniformly set, no flicker is caused in the uncoded unit of processing and the image quality of the uncoded unit of processing on the whole is improved even subjectively.

FIG. 6is a view showing a method of uniformly setting the quantization errors of the images in a case where the output rate of the encoded unit of processing is higher than the target rate. In other words, the output rate of the uncoded unit of processing has only to be lower than the output rate of the encoded unit of processing.

The target quantization error setting part33calculates the respective average quantization error values321,322, and323of the I, P, B pictures in the encoded unit of processing. The target quantization error setting part33sets the maximum value out of the average quantization error values321,322, and323as the uniform average quantization error value Diff_Ave for the I, P, B pictures in the uncoded unit of processing as indicated by the arrow333. It is desirable, as a matter of course, that the output rate of the uncoded unit of processing should be equal to the target rate or should not be extremely lower than the target rate.

The target quantization error setting part33sets the uniform average quantization error value Diff_Ave of the uncoded unit of processing to be equal to the average quantization error value321of the I picture in the encoded unit of processing and to be larger than the average quantization error values322and323of the P and B pictures in the encoded unit of processing.

In order to make the quantization error larger, it is desirable that the quantization step value should be set to be larger and the target amount of codes should be set to be smaller.

The target code amount setting part34keeps the target amount of codes341of the I picture in the uncoded unit of processing equal to the target amount of codes of the I picture in the encoded unit of processing which is set earlier. The target code amount setting part34decreases the target amounts of codes342and343of the P and B pictures in the uncoded unit of processing to be smaller than the target amounts of codes of the P and B pictures in the encoded unit of processing which are set earlier, respectively. The target code amount setting part34decreases the target amount of codes per a picture in the uncoded unit of processing to be smaller than the target amount of codes per a picture in the encoded unit of processing which is set earlier.

The quantization step value setting part35keeps the quantization step value351of the I picture in the uncoded unit of processing equal to the quantization step value of the I picture in the encoded unit of processing which is set earlier. The quantization step value setting part35increases the quantization step values352and353of the P and B pictures in the uncoded unit of processing to be larger than the quantization step values of the P and B pictures in the encoded unit of processing which are set earlier, respectively. This feedback is repeated.

The image quality of the I picture in the uncoded unit of processing becomes equal to that of the I picture in the encoded unit of processing. The respective image qualities of the P and B pictures in the uncoded unit of processing become lower than the respective image qualities of the P and B pictures in the encoded unit of processing, respectively.

The individual qualities of the images in the uncoded unit of processing become lower than those of the images in the encoded unit of processing. Since the qualities of the images in the uncoded unit of processing are uniformly set, however, no flicker is caused in the uncoded unit of processing and the overall image quality of the uncoded unit of processing is improved subjectively.

FIG. 7is a view showing a method of uniformly setting the quantization errors of the images in a case where the output rate of the encoded unit of processing is equal to the target rate. In other words, the output rate of the uncoded unit of processing has only to be equal to the output rate of the encoded unit of processing.

The target quantization error setting part33calculates the respective average quantization error values321,322, and323of the I, P, B pictures in the encoded unit of processing. The target quantization error setting part33sets the average value of the average quantization error values321,322, and323as the uniform average quantization error value Diff_Ave for the I, P, B pictures in the uncoded unit of processing as indicated by the arrow334. It is desirable, as a matter of course, that the output rate of the uncoded unit of processing should be equal to the target rate or should not be extremely different from the target rate. Further, other than the average value of the quantization errors, a median may be selected.

The target quantization error setting part33sets the uniform average quantization error value Diff_Ave of the uncoded unit of processing to be smaller than the average quantization error value321of the I picture in the encoded unit of processing and to be larger than the average quantization error values322and323of the P and B pictures in the encoded unit of processing.

The target code amount setting part34increases the target amount of codes341of the I picture in the uncoded unit of processing to be larger than the target amount of codes of the I picture in the encoded unit of processing which is set earlier. The target code amount setting part34decreases the target amounts of codes342and343of the P and B pictures in the uncoded unit of processing to be smaller than the target amounts of codes of the P and B pictures in the encoded unit of processing which are set earlier, respectively. The target code amount setting part34keeps the target amount of codes per a picture in the uncoded unit of processing equal to the target amount of codes per a picture in the encoded unit of processing which is set earlier.

The quantization step value setting part35decreases the quantization step value351of the I picture in the uncoded unit of processing to be smaller than the quantization step value of the I picture in the encoded unit of processing which is set earlier. The quantization step value setting part35increases the quantization step values352and353of the P and B pictures in the uncoded unit of processing to be larger than the quantization step values of the P and B pictures in the encoded unit of processing which are set earlier, respectively. This feedback is repeated.

In common toFIGS. 5 to 7, the qualities of the images in the uncoded unit of processing are uniformly set. Therefore, no flicker is caused in the uncoded unit of processing and the overall image quality of the uncoded unit of processing is improved subjectively. In common toFIGS. 5 to 7, performed is one-pass processing in which the result of encoding of the encoded unit of processing is feedback to the encoding of the uncoded unit of processing, not two-pass processing in which the prefetch of the uncoded unit of processing is needed. For this reason, it is possible to perform real-time processing without any increase in the circuit scale.

{The Second Method of Uniformly Setting Quantization Errors of Images}

A second method of uniformly setting the quantization errors of the images will be discussed. Also in the second method, like in the first method, the target amount of codes in the uncoded unit of processing is set. In the second method, unlike in the first method, as a result of setting the target amount of codes in the uncoded unit of processing, how degree the average quantization error value of the uncoded unit of processing actually becomes is taken into consideration and how degree the amount of outputted codes in the uncoded unit of processing actually becomes is taken into consideration.

FIGS. 8 and 9are views each showing the second method of uniformly setting the quantization errors of the images. On the left end of each of these figures, actually measured values of the average quantization error values Diff_Ave in the encoded unit of processing are indicated by a bar chart using solid lines. In the center of each of these figures, target values of the average quantization error values Diff_Ave in the uncoded unit of processing before the actual encoding are indicated by a bar chart using broken lines. On the right end of each of these figures, actually measured values of the average quantization error values Diff_Ave in the uncoded unit of processing after the actual encoding are indicated by a bar chart using solid lines.

FIG. 8is a view showing a method of uniformly setting the quantization errors of the images in a case where the average quantization error value321in the I picture in the encoded unit of processing is larger than each of the average quantization error values322and323of the P and B pictures in the encoded unit of processing.

The method of uniformly setting the quantization errors of the images is almost the same as the method in the case ofFIG. 5. The target quantization error setting part33sets the uniform average quantization error value Diff_Ave in the uncoded unit of processing to be smaller than the average quantization error value321of the I picture in the encoded unit of processing and to be equal to the average quantization error values322and323of the P and B pictures in the encoded unit of processing. The target value of the uniform average quantization error value Diff_Ave in the uncoded unit of processing is indicated by the arrow335A.

As to the I picture in the uncoded unit of processing, there is a high probability that the actually measured value of the average quantization error value Diff_Ave will become equal to the target value of the average quantization error value Dar_Ave.

There is a high probability that the amount of outputted codes of the I picture in the uncoded unit of processing will become larger than the amount of outputted codes of the I picture in the encoded unit of processing. These probabilities are clear from the case ofFIG. 5.

As to the P and B pictures in the uncoded unit of processing, there is a probability that the actually measured value of the average quantization error value Diff_Ave will become smaller than the target value of the average quantization error value Diff_Ave. There is a probability that the amount of outputted codes of each of the P and B pictures in the uncoded unit of processing will become smaller than the amount of outputted codes of each of the P and B pictures in the encoded unit of processing. The actually measured value of the average quantization error value Diff_Ave of each of the P and B pictures in the uncoded unit of processing is indicated by the arrow335B. These probabilities are not clear from the case ofFIG. 5and the reason for these probabilities will be discussed below.

In the uncoded unit of processing, there are P and B pictures which make reference to the I picture and there are P and B pictures which makes reference to the P picture which has made reference to the I picture. In the case ofFIG. 5, in the uncoded unit of processing, the effect of the quantization error of the I picture produced on the quantization errors of the P and B pictures is not taken into consideration. In the case ofFIG. 8, however, in the uncoded unit of processing, the effect of the quantization error of the I picture produced on the quantization errors of the P and B pictures is taken into consideration.

If the quantization error of the I picture is small, the quantization errors of the P and B pictures which make reference to the I picture are also small. If the quantization error of the P picture which has made reference to the I picture is small, the quantization errors of the P and B pictures which make reference to the P picture which has made reference to the I picture are also small.

Then, there is a probability that the measured quantization error values of the P and B pictures in the uncoded unit of processing will become smaller than the target quantization error values of the P and B pictures in the uncoded unit of processing. Further, there is a probability that the respective amounts of outputted codes of the P and B pictures in the uncoded unit of processing will become smaller than the respective target amounts of codes of the P and B pictures in the uncoded unit of processing. In other words, the probabilities discussed first exist.

There is a high probability that the amount of outputted codes of the I picture will increase as the process goes from the encoding of the encoded unit of processing to the encoding of the uncoded unit of processing. There is a probability that the respective amounts of outputted codes of the P and B pictures will decrease as the process goes from the encoding of the encoded unit of processing to the encoding of the uncoded unit of processing. If the degree of decrease in the amounts of outputted codes of the P and B pictures is higher than the degree of increase in the amount of outputted codes of the I picture, the amount of outputted codes per a picture in the uncoded unit of processing can become smaller than the amount of outputted codes per a picture in the encoded unit of processing.

FIG. 9is a view showing a method of uniformly setting the quantization errors of the images in a case where the average quantization error value321in the I picture in the encoded unit of processing is smaller than each of the average quantization error values322and323of the P and B pictures in the encoded unit of processing.

The method of uniformly setting the quantization errors of the images is almost the same as the method in the case ofFIG. 6. The target quantization error setting part33sets the uniform average quantization error value Diff_Ave in the uncoded unit of processing to be larger than the average quantization error value321of the I picture in the encoded unit of processing and to be equal to the average quantization error values322and323of the P and B pictures in the encoded unit of processing. The target value of the uniform average quantization error value Diff_Ave in the uncoded unit of processing is indicated by the arrow336A.

As to the I picture in the uncoded unit of processing, there is a high probability that the actually measured value of the average quantization error value Diff_Ave will become equal to the target value of the average quantization error value Diff_Ave. There is a high probability that the amount of outputted codes of the I picture in the uncoded unit of processing will become smaller than the amount of outputted codes of the I picture in the encoded unit of processing. These probabilities are clear from the case ofFIG. 6.

As to the P and B pictures in the uncoded unit of processing, there is a probability that the actually measured value of the average quantization error value Diff_Ave will become larger than the target value of the average quantization error value Diff_Ave. There is a probability that the amount of outputted codes of each of the P and B pictures in the uncoded unit of processing will become larger than the amount of outputted codes of each of the P and B pictures in the encoded unit of processing. The actually measured value of the average quantization error value Diff_Ave of each of the P and B pictures in the uncoded unit of processing is indicated by the arrow336B. These probabilities are not clear from the case ofFIG. 6but become clear when a case reverse to the case ofFIG. 8is considered.

There is a high probability that the amount of outputted codes of the I picture will decrease as the process goes from the encoding of the encoded unit of processing to the encoding of the uncoded unit of processing. There is a probability that the respective amounts of outputted codes of the P and B pictures will increase as the process goes from the encoding of the encoded unit of processing to the encoding of the uncoded unit of processing. If the degree of decrease in the amount of outputted codes of the I picture is higher than the degree of increase in the amounts of outputted codes of the P and B pictures, the amount of outputted codes per a picture in the uncoded unit of processing can become smaller than the amount of outputted codes per a picture in the encoded unit of processing.