# Patent

## Title
Image encoding device and image encoding method

## Abstract

An image encoding device includes: a first encoding unit for calculating a generated code amount when encoding image data using a fixed quantizing parameter, and block distinction regarding whether a macro block is a block for performing temporal prediction or block for performing spatial prediction regarding a picture for predicting a temporal direction; a code amount control unit for setting the offset amount of a quantizing parameter so as to have great code amount to be assigned to a picture including many images to be referenced according to a percentage between the block for temporal prediction, and the block for spatial prediction based on the results of the block distinction, and determining a quantizing parameter based on the generated code amount calculated at the first encoding unit; and a second encoding unit for encoding the image data using the offset quantizing parameter for realizing a target generated code amount.

## Background
BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention relates to an image encoding device, and an image encoding method, and more specifically, it enables distribution of a generated code amount as to each picture to be performed so as to reduce fluctuation of image quality.
2. Description of the Related Art
Hitherto, with an image encoding method such as MPEG2 (Moving Picture Experts Group 2) or the like, it is a great problem to maintain subjective image quality to ideally distribute a code amount.
For example, an ideal code amount distribution of a still image is a state in which distortion is uniformly encoded (with a fixed quantized scale). When reaching a code amount whereby this distortion becomes great, subjective image quality can be enhanced by biasing the distortion toward a high-frequency component or complicated portion.
Now, for example, with International Publication WO96/28937, an image signal encoding method has been disclosed wherein the image quality of a decoded image can be improved by employing code amount control according to a feed forward method to enable control adapted to the local property of an image quality signal. The feed forward method is for determining a suitable quantizing scale in a range where a generated code amount does not exceed a target generated code amount by calculating a code amount to be generated in increments of equal lengthening regarding a plurality of quantizing scales.
On the other hand, with code amount control such as TM5 proposed as a test model with MPEG2, or the like, code amount control is performed by performing feedback control using relationship between the remaining amount of a virtual buffer, a quantization index at the time of previous encoding, and a generated code amount.
SUMMARY OF THE INVENTION
Incidentally, in the case of performing encoding so that the generated code amount of 1 GOP (Group of Picture) becomes a desired code amount for example, it is important for maintaining subjective image quality to ideally distribute a code amount as to each picture within 1 GOP. In particular, in the case of performing distribution of a code amount as to continuous images while taking dubbing into consideration, fluctuation of image quality between pictures has to be suppressed to some extent. With an image of scene changing, flashing, or the like, in the event that no distribution of code amount according thereto is performed, image quality fluctuates for each picture, and flickering due to fluctuation thereof, or the like, becomes conspicuous. For example, in the event that little code amount is assigned to the first picture after scene change, the image quality of the first picture after scene change is greatly deteriorated as compared to before scene change. Also, an image to be displayed will appear like a flickering image due to this deterioration in image quality. Also, in the event of repeating dubbing, fluctuation of image quality becomes great, and the image quality may greatly deteriorate.
It has been found to be desirable to provide an image encoding device and an image encoding method whereby distribution of a code amount as to each picture can be performed so as to reduce fluctuation of image quality.
An embodiment of the present invention is an image encoding device including: a first encoding unit configured to perform calculation of a generated code amount at the time of performing encoding of image data using a fixed quantizing parameter, and block distinction regarding whether a macro block is a block for performing temporal prediction or a block for performing spatial prediction regarding a picture for performing prediction of a temporal direction; a code amount control unit configured to set the offset amount of a quantizing parameter so as to have great code amount to be assigned to a picture including many images to be referenced according to a percentage between the block for performing temporal prediction, and the block for performing spatial prediction of the picture for performing prediction of a temporal direction based on the block distinction results at the first encoding unit, and to determine a quantizing parameter based on the generated code amount calculated at the first encoding unit so that a generated code amount at the time of performing encoding using the quantizing parameter offset with that offset amount realizes a target generated code amount; and a second encoding unit configured to perform encoding of the image data using the offset quantizing parameter for realizing the target generated code amount.
With the above configuration, according to the first encoding unit, calculation of a generated code amount at the time of performing encoding of image data using a fixed quantizing parameter, and block distinction regarding whether a macro block is a block for performing temporal prediction or a block for performing spatial prediction regarding a picture for performing prediction of a temporal direction, are performed using a fixed quantizing parameter. With the code amount control unit, when the percentage of the number of the blocks for performing spatial prediction as to the number of the blocks for performing temporal prediction is equal to or smaller than a first threshold, an offset amount is set so as to reduce a code amount to be assigned to this picture. Also, when the percentage of the number of the blocks for performing spatial prediction as to the number of the blocks for performing temporal prediction is equal to or greater than a second threshold that is greater than the first threshold, an offset amount is set smaller than the offset amount at the time of the percentage being equal to or smaller than the first threshold. Further, with the code amount control unit, a quantizing parameter is determined based on the generated code amount calculated at the first encoding unit so that the generated code amount at the time of performing encoding using the quantizing parameter offset with the set offset amount realizes a target generated code amount. With the second encoding unit, encoding of image data is performed using the offset quantizing parameter for realizing the target generated code amount. Also, the third encoding unit is provided, which uses plurality of different quantizing parameters to perform encoding for each of the quantizing parameters with the image data as the image data of an intra picture to calculate a generated code amount. The code amount control unit performs prediction of a generated code amount at the time of using a quantizing parameter for realizing a target generated code amount, and the offset quantizing parameter based on the generated code amount calculated at the first encoding unit, corrects this predicted generated code amount according to the generated code amount calculated at the third encoding unit, and determines a quantizing parameter so that 1 GOP (Group of Picture) worth of generated code amount after correction realizes the target generated code amount. Also, the upper limit of the offset amount is set according to the quantizing parameter for realizing the target generated code amount.
Another embodiment of the present invention is an image encoding method including the steps of: calculating, with a first encoding unit, of a generated code amount at the time of performing encoding of image data using a fixed quantizing parameter; performing, with the first encoding unit, of block distinction regarding whether a macro block is a block for performing temporal prediction or a block for performing spatial prediction regarding a picture for performing prediction of a temporal direction; setting, with a code amount control unit, of the offset amount of a quantizing parameter so as to have great code amount to be assigned to a picture including many images to be referenced according to a ratio between the block for performing temporal prediction, and the block for performing spatial prediction of the picture for performing prediction of a temporal direction based on the block distinction results at the first encoding unit; determining, with the code amount control unit, of a quantizing parameter based on the generated code amount calculated at the first encoding unit so that a generated code amount at the time of performing encoding using the quantizing parameter offset with that offset amount realizes a target generated code amount; and encoding, with a second encoding unit, of the image data using the offset quantizing parameter for realizing the target generated code amount.
With the above configuration, according to the first encoding unit, calculation of a generated code amount at the time of performing encoding of image data using a fixed quantizing parameter, and block distinction regarding whether a macro block is a block for performing temporal prediction or a block for performing spatial prediction regarding a picture for performing prediction of a temporal direction, are performed using a fixed quantizing parameter. With the code amount control unit, based on the block distinction results at the first encoding unit, the offset amount of a quantizing parameter is set so as to have great code amount to be assigned to a picture including many images to be referenced, and a quantizing parameter is determined based on the generated code amount calculated at the first encoding unit so that a generated code amount at the time of performing encoding using the quantizing parameter offset with that offset amount realizes a target generated code amount. With the second encoding unit, encoding of image data is performing using the offset quantizing parameter for realizing the target generated code amount. Thus, distribution of a code amount as to each picture can be performed so as to reduce fluctuation of image quality.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a diagram illustrating the configuration of an image encoding device;
FIGS. 2A through 2C are diagrams illustrating quantizing matrices;
FIG. 3 is a flowchart illustrating the operation of the image encoding device;
FIG. 4 is a flowchart illustrating basic quantizing parameter determining processing;
FIG. 5 is a diagram for describing processing for calculating a quantizing parameter and a generated code amount;
FIG. 6 is a diagram for describing the processing for calculating a quantizing parameter and a generated code amount;
FIG. 7 is a flowchart illustrating processing for calculating 1 GOP worth of generated code amount;
FIG. 8 is a flowchart illustrating quantizing parameter offset amount setting processing;
FIG. 9 is a flowchart illustrating I picture generated code amount calculation processing;
FIG. 10 is a flowchart illustrating second generated code amount detecting processing;
FIG. 11 is a flowchart illustrating the operation of high-frequency component cost calculation;
FIG. 12 is a diagram illustrating the processing results of intra pre-encoding processing; and
FIG. 13 is a flowchart illustrating non-I picture generated code amount calculation processing.



DESCRIPTION OF THE PREFERRED EMBODIMENTS
An embodiment for implementing the present invention will be described below. With the present invention, a generated code amount is calculated by a pre-encoding unit serving as a first encoding unit performing pre-encoding processing of image data using a fixed quantizing parameter. Also, according to the pre-encoding unit, block distinction regarding whether a macro block is a block for performing temporal prediction or a block for performing spatial prediction is performed regarding a picture for performing prediction of a temporal direction. A code amount control unit calculates a ratio between a block for performing temporal prediction, and a block for performing spatial prediction of a picture for performing prediction of a temporal direction based on the block distinction results at the pre-encoding unit. Also, the code amount control unit sets the offset amount of a quantizing parameter so as to have great code amount to be assigned to a picture including many images to be referenced. Further, the code amount control unit determines a quantizing parameter based on the generated code amount calculated at the pre-encoding unit so that a generated code amount at the time of performing encoding using the quantizing parameter offset with that offset amount realizes a target generated code amount. A main encoding unit serving as a second encoding unit performs encoding of image data using a quantizing parameter that is the determined quantizing parameter being offset with the set offset amount. Such an operation is performed, thereby enabling encoding processing to be performed wherein the generated code amount is equal to or smaller than the target generated code amount, and image fluctuation is small. Note that description will be made in accordance with the following sequence.

    1. Configuration of Image Encoding Device
    2. Operation of Image Encoding Device
    1. Configuration of Image Encoding Device


FIG. 1 illustrates the configuration of an image encoding device according to an embodiment of the present invention. An image encoding device 10 includes an image rearrangement processing unit 11, a pre-encoding unit 20, an intra pre-encoding unit 30, a code amount control unit 40, a delay buffer 50, and a main encoding unit 60.
The pre-encoding unit 20 includes a prediction mode determining unit 21, a DCT (Discrete Cosine Transform) unit 22, a quantizing unit 23, an inverse quantizing unit 24, an IDCT (Inverse Discrete Cosine Transform) unit 25, a predictive image generating unit 26, and a code length computing unit 27.
The intra pre-encoding unit 30 includes an intra-screen prediction processing unit 31, a DCT unit 32, a quantizing unit 33, an inverse quantizing unit 34, an IDCT unit 35, an intra predictive image generating unit 36, and a code length computing unit 37. Also, the quantizing unit 33 is configured of multiple stages of quantizing units 33-1 through 33-n, and the code length computing unit 37 is configured of multiple stages of code length computing units 37-1 through 37-n. 
The main encoding unit 60 includes a prediction processing unit 61, a DCT unit 62, a quantizing unit 63, an inverse quantizing unit 64, an IDCT unit 65, a predictive image generating unit 66, and a variable length encoding unit 67.
With such a configuration, the image rearrangement processing unit 11 rearranges the image data of an input image in the sequence of pictures from the display sequence to the encoding sequence in accordance with, for example, a GOP (Group of Picture) configuration. Subsequently, the image rearrangement processing unit 11 outputs the image data rearranged in the encoding sequence to the pre-encoding unit 20, the intra pre-encoding unit 30, and the delay buffer 50.
The pre-encoding unit 20 serving as a first encoding unit performs calculation of a generated code amount when encoding of the image data has been performed using a fixed quantizing parameter, and outputs the calculated generated code amount to the code amount control unit 40. The prediction mode determining unit 21 of the pre-encoding unit 20 determines a prediction mode for each macro block using the image data of the input image, and the predictive image data generated at the later-described predictive image generating unit 26. Also, the prediction mode determining unit 21 uses the predictive image data of the determined prediction mode to output difference image data indicating error as to the image data of the input image to the DCT unit 22.
The DCT unit 22 performs discrete cosine transform as to the difference image data to generate a DCT coefficient, and outputs this to the quantizing unit 23.
The quantizing unit 23 performs quantization of the DCT coefficient using a fixed quantizing parameter QP(p), and outputs the generated quantized data to the inverse quantizing unit 24 and the code length computing unit 27.
The inverse quantizing unit 24 performs inverse quantization as to the quantized data to generate a DCT coefficient, and outputs this to the IDCT unit 25.
The IDCT unit 25 performs inverse discrete cosine transform of the DCT coefficient supplied from the inverse quantizing unit 24 to generate difference image data, and outputs this to the predictive image generating unit 26.
The predictive image generating unit 26 uses the difference image data to generate the image data of a local decoded image. Also, the predictive image generating unit 26 uses the image data of the input image to perform motion estimation between the current frame and the next temporally adjacent frame in increments of macro blocks. Further, the predictive image generating unit 26 performs motion compensation of the local decoded image based on the motion estimation result to generate predictive image data from the image data of the local decoded image, and outputs this to the prediction mode determining unit 21.
The code length computing unit 27 performs encoding as to the quantized data using either the Context-Adaptive Variable Length Coding (CAVLC) method or the Context-Adaptive Binary Arithmetic Coding (CABAC) method, calculates a generated code amount for each macro block, and outputs this to the code amount control unit 40.
The CAVLC method is a method simpler than the CABAC method, and the CABAC method is a method whereby data amount can be reduced as compared to the CAVLC method. Now, description will be made regarding a case where the variable length coding method is employed at the pre-encoding unit 20 for simplifying the processing, and the arithmetic coding method is employed at the main encoding unit 60 for reducing data amount. With the variable length coding, the information of a certain region is effectively encoded, and with the arithmetic coding, a region can effectively be encoded without being identified. Accordingly, great error may be caused when predicting a code amount of the arithmetic coding from the variable length coding. However, the CAVLC can effectively encode a region without identifying the region well as compared to common variable length coding by adaptively changing context. Thus, the error is reduced, and a generated code amount at the time of employing the CABAC method can be estimated by encoding according to the CAVLC method. Accordingly, a generated code amount at the main encoding unit 60 employing the CABAC method can also be estimated by employing the CAVLC method at the code length computing unit 27. Note that the code length computing unit 27 can also suppress the circuit scale by employing the CAVLC method.
The intra pre-encoding unit 30 serving as a third encoding unit performs encoding using multiple different quantizing parameters with all of the image data as I pictures, and calculates a generated code amount for each of the quantizing parameters to output this to the code amount control unit 40. The intra-screen prediction processing unit 31 of the intra pre-encoding unit 30 generates difference image data indicating error between the image data of the input image, and the predictive image data generated at the intra predictive image generating unit 36 to output this to the DCT unit 32.
The DCT unit 32 performs discrete cosine transform as to the difference image data to generate a DCT coefficient, and outputs this to the quantizing unit 33.
The quantizing unit 33 is configured of multiple stages, e.g., nine stages of quantizing units 33-1 through 33-9. The quantizing units 33-1 through 33-9 perform quantization in accordance with nine conditions by combining three different quantizing parameters QP(i0), QP(i1), and QP(i2), and three different quantizing matrices QMF, QMN, and QMS. The quantizing units 33-1 through 33-9 outputs the quantized data obtained by performing quantization of the DCT coefficient to the code length computing unit 37. Also, the quantizing unit 33 selects one of the quantized data generated at the quantizing units 33-1 through 33-9, and outputs this to the inverse quantizing unit 34.
FIGS. 2A through 2C exemplify the quantizing matrices QMF, QMN, and QMS. FIG. 2A illustrates the quantizing matrix QMF. With the quantizing matrix QMF, all matrix values are equal values. That is to say, the quantizing matrix QMF is a quantizing matrix having a flat property. FIG. 2B illustrates the quantizing matrix QMN. With the quantizing matrix QMN, the matrix value of a high-frequency component is greater than the matrix value of a low-frequency component. That is to say, the quantizing matrix QMN is a quantizing matrix having a common property wherein reduction of high-frequency components is performed. FIG. 2C illustrates the quantizing matrix QMS. With the quantizing matrix QMS, the matrix value of a high-frequency component is a further greater value as compared to the quantizing matrix QMN. That is to say, the quantizing matrix QMS is a quantizing matrix having a property wherein reduction of high-frequency components is further increased as compared to the quantizing matrix QMN.
The inverse quantizing unit 34 performs inverse quantization as to the quantized data supplied from the quantizing unit 33 to generate DCT coefficient data, and outputs this to the IDCT unit 35.
The IDCT unit 35 performs inverse discrete cosine transform of the DCT coefficient data supplied from the inverse quantizing unit 34 to generate difference image data, and outputs this to the intra predictive image generating unit 36.
The intra predictive image generating unit 36 uses the difference image data to generate the image data of the local decoded image. Also, the intra predictive image generating unit 36 outputs the image data of the local decoded image to the intra-screen prediction processing unit 31 as predictive image data.
The code length computing unit 37 is configured of multiple stages, e.g., nine stages of code length computing units 37-1 through 37-9 corresponding to the quantizing unit 33. The code length computing units 37-1 through 37-9 perform encoding using the same method as with the code length computing unit 27 of the pre-encoding unit 20 to calculate a generated code amount for each macro block, and output this to the code amount control unit 40.
The code amount control unit 40 determines a target generated code amount to be assigned to 1 GOP from relationship between a bit rate and a GOP configuration. The code amount control unit 40 predicts a quantizing parameter for realizing a target generated code amount, and a generated code amount when employing this quantizing parameter based on 1 GOP worth of the generated code amount calculated at the pre-encoding unit 20. That is to say, the code amount control unit 40 predicts a quantizing parameter wherein the generated code amount of 1 GOP is equal to or smaller than the target generated code amount and most closely approximated to the target generated code amount, and a generated code amount when employing this quantizing parameter. Also, the code amount control unit 40 predicts a generated code amount with the predicted quantizing parameter based on the generated code amount calculated at the intra pre-encoding unit 30. Further, the code amount control unit 40 determines a quantizing parameter for realizing the target generated code amount from this predicted generated code amount to output this to the main encoding unit 60. Note that, with the following description, a quantizing parameter for realizing the target generated code amount will be referred to as a basic quantizing parameter.
Also, with a picture for performing prediction of a temporal direction, the code amount control unit 40 calculates a ratio between a macro block for performing temporal prediction, and a macro block for performing spatial prediction. The code amount control unit 40 offsets the quantizing parameter so as to have great code amount to be assigned to a picture including many images to be referenced, according to the calculated ratio. Specifically, with regard to a picture wherein the percentage of macro blocks for performing prediction of a temporal direction is high, the quantizing parameter is offset so as to reduce deterioration in image quality by increasing the distribution of a code amount as to a picture referenced from this picture. Also, with regard to a picture wherein the percentage of macro blocks for performing prediction of a spatial direction is high, the quantizing parameter is offset so as to reduce deterioration in image quality by increasing the distribution of a code amount as to this picture. Further, the code amount control unit 40 determines a quantizing parameter so that a generated code amount at the time of performing encoding using the offset quantizing parameter realizes the target generated code amount, and outputs this offset quantizing parameter for realizing this target generated code amount to the main encoding unit 60 as a basic quantizing parameter.
The delay buffer 50 delays the image data of the input image by the time used for processing for determining the basic quantizing parameter at the code amount control unit 40, and outputs the delayed image data to the main encoding unit 60.
The main encoding unit 60 serving as a second encoding unit performs encoding of the image data using the basic quantizing parameter determined at the code amount control unit 40. The prediction processing unit 61 of the main encoding unit 60 selects predictive image data according to the picture type determined by the prediction mode determining unit 21 of the pre-encoding unit 20. Also, the prediction processing unit 61 generates a difference image indicating error between the selected predictive image data, and the image data of the input image delayed at the delay buffer 50, and outputs this to the DCT unit 62.
The DCT unit 62 performs discrete cosine transform as to the difference image data to generate a DCT coefficient, and outputs this to the quantizing unit 63.
The quantizing unit 63 uses the quantization parameter determined at the code amount control unit 40 to perform quantization of the DCT coefficient, and outputs the quantized data to the inverse quantizing unit 64 and the variable length encoding unit 67.
The inverse quantizing unit 64 performs inverse quantization as to the quantized data to generate a DCT coefficient, and outputs this to the IDCT unit 65.
The IDCT unit 65 performs inverse discrete cosine transform of the DCT coefficient supplied from the inverse quantizing unit 64 to generate difference image data, and outputs this to the predictive image generating unit 66.
The predictive image generating unit 66 uses the difference image data to generate the image data of a local decoded image. Also, the predictive image generating unit 66 uses the image data from the delay buffer 50 to perform motion estimation between the current frame and the next temporally adjacent frame in increments of macro blocks. Further, the predictive image generating unit 66 performs motion compensation of the local decoded image based on the motion estimation result to generate a predictive image, and outputs this to the prediction processing unit 61.
The variable length encoding unit 67 performs encoding as to the quantized data by the CAVLC method or CABAC method to generate encoded streams, and outputs these. The variable length encoding unit 67 performs encoding of the quantized data using the CABAC method, for example, so as to reduce the data amount, to generate encoded streams.
2. Operation of Image Encoding Device
Next, the operation of the image encoding device will be described. FIG. 3 is a flowchart illustrating the operation of the image encoding device.
In step ST1, the image encoding device 10 performs determination of a picture type, and image rearrangement. The image encoding device 10 determines a picture type as to the input image, for example, in accordance with a GOP (Group of Picture) configuration. Also, the image encoding device 10 rearranges the image data of the input image at the image rearrangement processing unit 11 from the display sequence to the encoding sequence, and proceeds to step ST2.
In step ST2, the image encoding device 10 performs pre-encoding processing. The image encoding device 10 encodes the image data of the input image at the pre-encoding unit 20 using the determined picture type to calculate a generated code amount, and proceeds to step ST3.
In step ST3, the image encoding device 10 distinguishes whether or not the generated code amount has reached 1 GOP worth. In the event that the generated code amount calculated at the pre-encoding unit 20 has reached 1 GOP worth, the image encoding device 10 proceeds to step ST6, and in the event that the generated code amount has not reached 1 GOP worth, returns to step ST2.
In step ST4, the image encoding device 10 performs intra pre-encoding processing. The image encoding device 10 encodes the image data of the input image at the intra pre-encoding unit 30 as I picture to calculate a generated code amount, and proceeds to step ST5. Also, the image encoding device 10 performs encoding in parallel using multiple different quantizing parameters and multiple different quantizing matrices in the intra pre-encoding processing to calculate a generated code amount.
In step ST5, the image encoding device 10 distinguishes whether or not the generated code amount has reached 1 GOP worth. In the event that the generated code amount calculated at the intra pre-encoding unit 30 has reached 1 GOP worth, the image encoding device 10 proceeds to step ST6. Also, in the event that the generated code amount has not reached 1 GOP worth, the image encoding device 10 returns to step ST4.
In step ST6, the image encoding device 10 performs basic quantizing parameter determining processing to be used in main encoding processing. The image encoding device 10 determines a basic quantizing parameter to be used for the main encoding processing at the code amount control unit 40 from the generated code amount obtained by performing the pre-encoding processing, and the generated code amount obtained by performing the intra pre-encoding processing.
In step ST7, the image encoding device 10 performs the main encoding processing. The image encoding device 10 uses the basic quantizing parameter determined in step ST6 to encode the image data of the input image at the main encoding unit 60.
Next, the basic quantizing parameter determining processing to be used for the main encoding processing will be described. With the basic quantizing parameter determining processing, a quantizing parameter for realizing the target generated code amount, and a generated code amount at the time of employing this quantizing parameter, are predicted based on the generated code amount calculated at the pre-encoding unit 20. Also, this predicted generated code amount is corrected according to the generated code amount calculated at the intra pre-encoding unit 30. When the target generated code amount is not realized by 1 GOP worth of the corrected generated code amount, prediction of a generated code amount, and correction thereof are preformed by changing the parameter value of the predicted quantizing parameter. When the target generated code amount is realized by 1 GOP worth of the corrected generated code amount, the quantizing parameter at this time is taken as a basic quantizing parameter.
FIG. 4 exemplifies a flowchart illustrating the basic quantizing parameter determining processing to be used for the main encoding processing. In step ST11, the code amount control unit 40 performs prediction of a quantizing parameter. The code amount control unit 40 predicts a quantizing parameter for realizing the target generated code amount based on the generated code amount calculated at the pre-encoding unit 20, and proceeds to step ST12.
FIGS. 5 and 6 are diagrams for describing processing for calculating a quantizing parameter, and a generated code amount. The code amount control unit 40 classifies the macro blocks into groups using a fixed quantizing parameter QP(p) according to a generated code amount BT(p) at the time of performing encoding at the pre-encoding unit 20. Also, such as illustrated in FIG. 5, the predictive curve of the corresponding group, e.g., a predictive curve CB is selected from multiple predictive curves indicating relationship a quantizing parameter and a generated code amount provided beforehand for each group. Further, such as illustrated in FIG. 6, a quantizing parameter of which the generated code amount is equal to or smaller than the target generated code amount BT(t) and most closely approximated thereto is predicted using the selected predictive curve CB.
In step ST12, the code amount control unit 40 calculates 1 GOP worth of generated code amount. The code amount control unit 40 corrects the generated code amount predicted in step ST11 according to the generated code amount calculated at the intra pre-encoding unit 30, and calculates 1 GOP worth of the corrected generated code amount, and proceeds to step ST13.
In step ST13, the code amount control unit 40 distinguishes whether or not 1 GOP worth of generated code amount is greater than the target generated code amount. When the generated code amount is not greater than the target generated code amount, the code amount control unit 40 proceeds to step ST14, and when the generated code amount is greater than the target generated code amount, proceeds to step ST15.
In step ST14, the code amount control unit 40 determines a basic quantizing parameter from the predicted quantizing parameter. When difference between the generated code amount and the target generated code amount is small, e.g., when the difference is smaller than the increase of the generated code amount at the time of reducing the value of the predicted quantizing parameter by one for example, the code amount control unit 40 takes the predicted quantizing parameter as a basic quantizing parameter, and ends the processing. Also, when difference between the generated code amount and the target generated code amount is great, the code amount control unit 40 reduces the value of the predicted quantizing parameter so as to reduce the difference, and takes this as a basic quantizing parameter.
In step ST15, the code amount control unit 40 increases the value of the predicted quantizing parameter. The code amount control unit 40 determines an increment according to the difference between the generated code amount and the target generated code amount, increases the value of the predicted quantizing parameter, and proceeds to step ST16.
In step ST16, the code amount control unit 40 calculates 1 GOP worth of generated code amount. The code amount control unit 40 uses the quantizing parameter updated in step ST115 to calculate 1 GOP worth of generated code amount in the same way as in step ST12, and proceeds to step ST17.
In step ST17, the code amount control unit 40 distinguishes whether or not the target generated code amount is realizable. In the event that distinction is made that the target generated code amount is unrealizable, the code amount control unit 40 returns to step ST13, and in the event that distinction is made that the target generated code amount is realizable, takes the quantizing parameter updated in step ST15 as a basic quantizing parameter, and ends the processing. For example, when a generated code amount at the time of employing the quantizing parameter updated in step ST15 is equal to or smaller than the target generated code amount, and a generated code amount at the time of employing a quantizing parameter smaller than the quantizing parameter updated in step ST15 by one exceeds the target generated code amount, the code amount control unit 40 distinguishes that the target generated code amount is realizable, and takes the updated quantizing parameter as a basic quantizing parameter.
Thus, a basic quantizing parameter can be determined whereby the target generated code amount can be realized. Note that the basic quantizing parameter determining processing is not restricted to the processing illustrated in the flowchart in FIG. 4. For example, the increment or decrement of a quantizing parameter is set according to the difference between the generated code amount and the target generated code amount to calculate a generated code amount again. Also, when the difference between the generated code amount and the target generated code amount is small, a quantizing parameter whereby the target generated code amount can be realized may be searched by increasing or decreasing the quantizing parameter by one at a time.
FIG. 7 is a flowchart exemplifying 1 GOP worth of generated code amount calculation processing. In step ST20, the code amount control unit 40 performs quantizing parameter offset amount setting processing. Here, a picture including many inter macro blocks for performing temporal prediction often references another picture, and a picture including many intra macro blocks for performing spatial prediction seldom references another picture. In the case of referencing another picture, allocating great generated code amount so as to improve the image quality of the picture to be referenced can effectively improve the image quality as compared to a case where the generated code amount of the side for referencing the other picture is increased. Accordingly, with a P picture or B picture that is a non-I picture, the code amount control unit 40 sets the offset amount of a quantizing parameter so as to have great code amount to be allocated to a picture including many images to be referenced.
FIG. 8 is a flowchart illustrating quantizing parameter offset amount setting processing. In step ST31, the code amount control unit 40 distinguishes regarding whether or not the picture is an I picture. When the picture is not an I picture, the code amount control unit 40 proceeds to step ST32, and when the picture is an I picture, proceeds to step ST38.
In step ST32, the code amount control unit 40 calculates a macro block ratio MBR. The code amount control unit 40 uses the number of intra macro blocks MBNintra and the number of inter macro blocks MBNinter within a picture to calculate the macro block ratio MBR from Expression (1), and proceeds to step ST33.

MBR=MBNintra/MBNinter   (1)

In step ST33, the code amount control unit 40 distinguishes whether or not the ratio MBR is smaller than a threshold THra. When the ratio MBR is not smaller than the threshold THra, the code amount control unit 40 proceeds to step ST34, and when the ratio MBR is smaller than the threshold THra, proceeds to step ST35.
In step ST34, the code amount control unit 40 distinguishes whether or not the ratio MBR is smaller than a threshold THrb. When the ratio MBR is smaller than the threshold THrb (THra<THrb), the code amount control unit 40 proceeds to step ST36, and when the ratio MBR is not smaller than the threshold THrb, proceeds to step ST37.
In step ST35, since the percentage of the number of inter macro blocks is high, the code amount control unit 40 offsets the quantizing parameter by an offset amount “Va (e.g., 5)” so as to allocate great code amount to a picture to be referenced, and ends the offset processing.
In step ST36, since the percentage of the number of inter macro blocks is low as compared to the case of step ST35, the code amount control unit 40 sets an offset amount “Vb (<Va, e.g., 3)” smaller than the offset amount in step ST35, and ends the offset amount setting processing.
In step ST37, since the percentage of the number of inter macro blocks is low as compared to the case of step ST36, the code amount control unit 40 sets an offset amount “Vc (<Vb, e.g., 1)” smaller than the offset amount in step ST36, and ends the offset amount setting processing.
In step ST38, since the picture is an I picture, the code amount control unit 40 sets the offset amount to “0”, and ends the offset amount setting processing.
Also, with regard to the offset amount, the upper limit may be changed according to a quantizing parameter to be applied. As can be apparent from FIG. 5, when the quantizing parameter is small, change in the generated code amount is great at the time of offsetting the quantizing parameter, and when the quantizing parameter is great, change in the generated code amount is small at the time of offsetting the quantizing parameter. Accordingly, for example, in the event of the upper limit of the offset amount has been set according to change in the generated code amount at the time of the quantizing parameter being small, when the quantizing parameter is great, the generated code amount is not greatly changed even when offsetting the quantizing parameter to the upper limit. Therefore, when the quantizing parameter is great, the upper limit is increased, and when the quantizing parameter is small, the upper limit is decreased. For example, when the quantizing parameter is great, the upper limit is set to “8”. and when the quantizing parameter is small, the upper limit is set to “5”. Thus, setting the upper limit of the offset amount according to the quantizing parameter enables the generated code amount to be greatly changed, for example, even when the quantizing parameter is great.
Thus, with a picture for performing prediction of a temporal direction, for example, when the percentage of the number of blocks for performing spatial prediction as to the number of blocks for performing temporal prediction is equal to or smaller than a first threshold, the setting of the offset amount is performed so as to reduce a code amount to be allocated to this picture. Also, when the percentage of the number of blocks for performing spatial prediction as to the number of blocks for performing temporal prediction is equal to or greater than a second threshold that is greater than the first threshold, the offset is set smaller than the offset amount at the time of the percentage being equal to or smaller than the first threshold.
In step ST21, the code amount control unit 40 offsets the predicted quantizing parameter to calculate the generated code amount of an I picture using the quantizing parameter after offset, and proceeds to step ST22. Note that since the offset amount of an I picture is “0”, the code amount control unit 40 calculates the generated code amount of an I picture using the predicted quantizing parameter.
In step ST22, the code amount control unit 40 distinguishes whether or not the next picture is an picture. When the next picture is not an I picture, the code amount control unit 40 proceeds to step ST23, and when the next picture is an I picture, ends the 1 GOP worth of generated code amount calculation processing.
In step ST23, the code amount control unit 40 offsets the predicted quantizing parameter to calculate the generated code amount of a non-I picture, i.e., a P picture or B picture using the quantizing parameter after offset, and proceeds to step ST22.
Next, description will be made regarding processing for calculating the generated code amount of an I picture, and processing for calculating the generated code amount of a non-I picture.
FIG. 9 is a flowchart illustrating I picture generated code amount calculation processing. In step ST41, the code amount control unit 40 predicts the first generated code amount. The code amount control unit 40 predicts a generated code amount at the time of employing the predicted quantizing parameter, takes this as the first generated code amount, and proceeds to step ST44. For example, such as illustrated in FIG. 6, the code amount control unit 40 uses the selected predictive curve CB to predict a quantization parameter whereby the generated code amount has a value equal to or less than the target generated code amount BT(t) and most closely approximated thereto, and predicts a generated code amount at the time of employing this predicted quantizing parameter. That is to say, the code amount control unit 40 takes the generated code amount BT(pt) of the predicted quantizing parameter QP(t) as the first generated code amount, and proceeds to step ST44. Note that the quantizing parameter QP(p) should be set to a small value beforehand so that the generated code amount at the time of performing encoding using the quantizing parameter QP(p) becomes greater than the target generated code amount. In the event of thus setting the quantizing parameter QP(p), a basic quantizing parameter can be set so as to decrease the generated code amount equal to or smaller than the target generated code amount and most closely approximated thereto.
In step ST44, the code amount control unit 40 detects the second generated code amount. The code amount control unit 40 detects the generated code amount BT(it) in the quantizing parameter QP(t) from the generated code amounts BT(i0), BT(i1), and BT(i2) at the time of performing encoding using the quantizing parameters QP(i0) through QP(i2), and takes this as the second generated code amount.
FIG. 10 is a flowchart illustrating second generated code amount detection processing. In step ST81, the code amount control unit 40 detects a quantizing parameter most closely approximated to the predicted quantizing parameter from quantizing parameters employed in the intra pre-encoding processing. The code amount control unit 40 detects a quantizing parameter most closely approximated to the quantizing parameter QP(t) out of the quantizing parameters QP(i0) through QP(i2) for example, takes this as a quantizing parameter QP(ia), and proceeds to step ST82.
In step ST82, the code amount control unit 40 detects a quantizing parameter second-most closely approximated to the predicted quantizing parameter out of the quantizing parameters employed in the intra pre-encoding processing. The code amount control unit 40 detects a quantizing parameter second-most closely approximated to the quantizing parameter QP(t) out of the quantizing parameters QP(i0) through QP(i2) for example, takes this as a quantizing parameter QP(ib), and proceeds to step ST83.
In step ST83, the code amount control unit 40 calculates the generated code amount of the predicted quantizing parameter. The code amount control unit 40 uses the generated code amount BT(ia) at the time of employing the quantizing parameter QP(ia), and the generated code amount BT(ib) at the time of employing the quantizing parameter QP(ib) to perform interpolation processing. The code amount control unit 40 performs linear interpolation, curve interpolation, or the like as the interpolation processing to calculate the generated code amount BT(it) of the predicted quantizing parameter QP(t).
The code amount control unit 40 uses, such as illustrated in FIG. 6 for example, the generated code amount BT(i1) of the quantizing parameter QP(i1) most closely approximated to the quantizing parameter QP(t), and the generated code amount BT(i0) of the quantizing parameter QP(i0) second-most closely approximated to the quantizing parameter QP(t) to perform the interpolation processing. The code amount control unit 40 calculates the generated code amount BT(it) of the predicted quantizing parameter QP(t) by the interpolation processing.
The code amount control unit 40 thus detects the generated code amount BT(it) of the predicted quantizing parameter QP(t), and proceeds from step ST44 to step ST45 in FIG. 8.
In step ST45, the code amount control unit 40 calculates a correction coefficient. The code amount control unit 40 uses the first generated code amount BT(pt) detected from the pre-encoding processing results, and the second generated code amount BT(it) detected from the intra pre-encoding processing results to perform the calculation of Expression (1) to calculate a correction coefficient C(i), and proceeds to step ST46.

C(i)=BT(it)/BT(pt)   (2)

In step ST46, the code amount control unit 40 calculates high-frequency component cost. The code amount control unit 40 calculates high-frequency component cost H(i) indicating the state of a high-frequency component in an I picture.
FIG. 11 is a flowchart illustrating high-frequency component cost calculating operation. Also, FIG. 12 illustrates the processing results of the intra pre-encoding processing.
In FIG. 11, in step ST91 the code amount control unit 40 selects the minimum value of the quantizing parameters in the intra pre-encoding processing. For example, such as illustrated in FIG. 12, with the intra pre-encoding processing, in the event that quantizing parameters QP(i0), QP(i1), and QP(i2) (QP(i0)<QP(i1)<QP(i2)) are employed, the code amount control unit 40 selects the quantizing parameter QP(i0), and proceeds to step ST92.
In step ST92, the code amount control unit 40 selects a generated code amount when employing the smallest quantizing parameter, and a quantizing matrix of which the quantizing steps from a high frequency to a low frequency are flat. For example, the quantizing matrix QMF will be a matrix of which the matrix values are fixed values, and the quantizing steps from a high frequency to a low frequency are flat. The quantizing matrix QMN will be a matrix wherein the matrix value of a high frequency is a value greater than that of a low frequency, and a high frequency is roughly quantized as compared to a low frequency. The quantizing matrix QMS will be a matrix wherein the matrix value of a high frequency is a further great value as compared to the quantizing matrix QMN, and quantization is performed in a state in which reduction of high frequency components is steep as compared to the quantizing matrix QMN. In this case, as the quantizing parameter QP(i0) is selected as the smallest quantizing parameter, the code amount control unit 40 selects the generated code amount BT(i0F) at the time of employing the quantizing parameter QP(i0) and the quantizing matrix QMF, and proceeds to the step ST93.
In step ST93, the code amount control unit 40 selects a generated code amount at the time of employing the smallest quantizing parameter, and a common quantizing matrix for roughly quantizing a high frequency as compared to a low frequency. For example, the code amount control unit 40 selects the generated code amount BT(i0N) at the time of employing the quantizing parameter QP(i0) and the quantizing matrix QMN, and proceeds to step ST94.
In step ST94, the code amount control unit 40 calculates high-frequency component cost. The code amount control unit 40 performs the calculation of Expression (3) to calculate high-frequency component cost H(i).

H(i)=BT(i0F)/BT(i0N)   (3)

When thus calculating high-frequency cost, the code amount control unit 40 proceeds from step ST46 to step ST48 in FIG. 9, and performs the calculation of the predicted first generated code amount. The code amount control unit 40 performs the calculation of Expression (4) using the first generated code amount BT(pt) and the correction coefficient C(i) to calculate a corrected generated code amount BT(itc).

BT(itc)=BT(pt)×C(i)   (4)

When thus performing the processing in FIG. 9, the generated code amount predicted from the results of the pre-encoding processing using the fixed quantizing parameter is corrected according to the processing results of the intra pre-encoding processing using multiple different quantizing parameters and multiple different quantizing matrices. Accordingly, the prediction accuracy of the generated code amount of an I picture can be improved.
Next, description will be made regarding non-I picture generated code amount calculation processing at the time of employing the predicted quantizing parameter using the flowchart illustrated in FIG. 13. In step ST111, the code amount control unit 40 detects a third generated code amount. The code amount control unit 40 classifies macro blocks into groups according to the generated code amount BT(p) at the time of performing encoding using the fixed quantizing parameter QP(p) at the pre-encoding unit 20. Also, the code amount control unit 40 selects a predictive curve of the corresponding group from multiple predictive curves indicating relationship between a quantizing parameter and a generated code amount provided for each group beforehand. Further, the code amount control unit 40 takes already predicted generated code amount BT(ut) in the quantizing parameter QP(t) using the selected predictive curve as the third generated code amount, and proceeds to step ST112.
In step ST112, the code amount control unit 40 calculates high-frequency component cost in a non-I picture. The code amount control unit 40 performs the same processing as the high-frequency component cost calculation shown in the above FIG. 11 to calculate high-frequency cost H(u) in a non-I picture. In this case, calculation of the high-frequency component H(u) is performed using Expression (5).

H(u)=BT(i0Fu)/BT(i0Nu)   (5)

Note that, in Expression (5), the generated code amounts BT(i0Fu) and BT(i0Nu) are generated code amounts at the time of subjecting the image data of a non-I picture for calculating high-frequency component cost to the intra pre-encoding processing as an I picture.
In this way, after calculating high-frequency cost in step ST112 in FIG. 13, the code amount control unit 40 proceeds to step ST113 to calculate a correction coefficient. The code amount control unit 40 performs the calculation of Expression (6) using the correction coefficient C(i) and the high-frequency component cost H(i) calculated in the I picture processing, and the high-frequency component cost H(u) calculated in step ST112 to calculate a correction coefficient C(ic) corresponding to a non-I picture, and proceeds to step ST115.

C(ic)=C(i)×H(i)/H(u)   (6)

In step ST115, the code amount control unit 40 performs correction of a third generated code amount. The code amount control unit 40 performs the calculation of Expression (7) using the generated code amount BT(ut) and the correction coefficients C(ic) to calculate a corrected generated code amount BT(utc).

BT(utc)=BT(ut)×C(ic)   (7)

When thus performing the processing in FIG. 13, the generated code amount predicted from the results of the pre-encoding processing using the fixed quantizing parameter is corrected according to the processing results of the intra pre-encoding processing using multiple different quantizing parameters and multiple different quantizing matrices. Accordingly, the prediction accuracy of the generated code amount of a non-I picture can be improved.
AS described above, the offset processing of the predicted quantizing matrix is performed, and encoding is performed at the main encoding unit 60 with the offset quantizing parameter for realizing the target generated code amount as a basic quantizing parameter. When encoding is performed in this way, great code amount is allocated to a picture including many images to be referenced. Accordingly, fluctuation of image quality can be reduced as compared to the case of performing no offset processing, and a phenomenon can be reduced such that image quality deteriorates regarding only the image of one frame, or deterioration in image quality at the time of dubbing can be reduced.
Also, in the event of applying the same quantizing parameter to continuous images having correlation between pictures, great code amount is not allocated to a picture to be referenced, and accordingly, an advantage obtained by performing prediction of a temporal direction is reduced. That is to say, this may cause deterioration in subjective image quality. In such a case, the quantizing parameter offset processing is performed, and allocation of a code amount as to a picture to be referenced is increased, whereby deterioration in image quality of a picture to be referenced can be reduced as compared to a case of applying the same quantizing parameter. Accordingly, encoding processing can be performed while suppressing deterioration and fluctuation of image quality. For example, with a picture after scene change, when the percentage of intra macro blocks is great, great code amount is allocated thereto as compared to a picture having a small ratio of intra macro blocks. Therefore, the image quality after scene change can be prevented from deteriorating as compared to before scene change. Also, deterioration in image quality at the time of dubbing can also be reduced.
Further, with the code amount control unit 40, a quantizing parameter for realizing the target generated code amount, and a generated code amount at the time of employing this quantizing parameter, are predicted based on the generated code amount calculated by performing pre-encoding at the pre-encoding unit 20. Also, the predicted generated code amount is corrected according to the generated code amount calculated by performing pre-encoding at the intra pre-encoding unit 30. Further, with the code amount control unit 40, a quantizing parameter is determined so that the generated code amount after correction realizes the target generated code amount. Therefore, for example, in the case that relationship between the generated code amount and quantizing parameter of a macro block is changed according to an image, predictive error of a generated code amount caused due to this change is corrected according to the generated code amount calculated by performing pre-encoding at the intra pre-encoding unit 30. Accordingly, even in the case that relationship between the generated code amount and quantizing parameter of a macro block is changed according to an image, prediction of a generated code amount can accurately be performed.
For example, in the case that prediction of a generated code amount is performed by performing the pre-encoding processing, and the quantizing parameter of main encoding is determined from the prediction result, as a cause for generating error of prediction, when the number of high-frequency components is smaller than estimation, the falling way of a generated code amount is changed, and the number of actual generated code amount becomes smaller than prediction. In particular, when difference between the quantizing parameter (p) fixed in the pre-encoding processing and the quantizing parameter QP(t) corresponding to the target generated code amount is great, error is apt to become great. In order to correct this error, the code amount control unit 40 takes advantage of the generated code amount obtained by the intra pre-encoding processing for I pictures. The intra pre-encoding unit 30 applies multiple different quantizing parameters, and accordingly, the generated code amount of a quantizing parameter approximated to the predicted quantizing parameter can be obtained as compared to the pre-encoding unit 20. Therefore, with prediction of an I picture, the predicted generated code amount is corrected according to the generated code amount calculated at the intra pre-encoding unit 30.
Also, error is not allowed to be obtained regarding a non-I picture. However, this error fluctuates due to the state of a high-frequency component in a picture, and accordingly, the state of a high-frequency component is obtained from each picture, and the generated code amount of a non-I picture is corrected according to difference of each picture as to the sate of a high-frequency component in an I picture.
Thus, even in the event that the state of a high-frequency differs from that at the time of obtaining a predictive curve, the generated code amount can be corrected according to the state of a high-frequency component of a picture, and accordingly, the generated code amount can be presumed in a more accurate manner. Accordingly, for example, prediction of 1 GOP worth of generated code amount can accurately be performed.
Also, in the event that the main encoding unit 60 has performed encoding of image data using the basic quantizing parameter determined at the code amount control unit 40, encoded data of which the generated code amount is equal to or smaller than the target generated code amount, having little deterioration in an image, can be output from the main encoding unit 60.
Also, a series of processing described in the present Specification may be executed by hardware, software, or a combined configuration of both. In the case of executing processing by software, a program in which processing sequence is recorded may be executed by being installed in memory within a computer housed in dedicated hardware, or may be executed by being installed in a general-purpose computer capable of executing various types of processing.
For example, the program may be recorded beforehand in a hard disk or ROM (Read Only Memory) serving as a recording medium, or may be temporarily or eternally stored (recorded) in a removable medium such as a flexible disk, CD-ROM (Compact Disc Read Only Memory), MO (Magneto Optical) disk, DVD (Digital Versatile Disc), a magnetic disk, semiconductor memory, or the like. Such a removable medium may be provided as so-called packaged software.
Note that the program may be transferred from a download site to a computer wirelessly, or by cable via a network such as a LAN (Local Area Network), the Internet, or the like in addition to being installed in a computer from a removable recording medium such as described above. The computer can receive the program thus transferred so as to be installed in a recording medium such as a built-in hard disk or the like.
The present application contains subject matter related to that disclosed in Japanese Priority Patent Application JP 2009-173908 filed in the Japan Patent Office on Jul. 27, 2009, the entire content of which is hereby incorporated by reference.
Note that the present invention is not to be interpreted in a manner restricted to the above embodiments of the invention. With the embodiments of the present invention, the present invention has been disclosed in an exemplification mode, and it is apparent that one skilled in the art can conceive various modifications or alternations without departing from the essence and spirit of the present invention. That is to say, in order to understand the essence and spirit of the present invention, the Claims should be referred to.

## Claims

1. An image encoding device comprising:
an image rearrangement unit configured to perform rearrangement of image data in a sequence of pictures from a display sequence to an encoding sequence in accordance with a Group of Picture (GOP) configuration;
a first encoding unit configured to perform:
(a) calculation of a first generated code amount at a time of performing encoding of said rearranged image data using a fixed quantizing parameter, and
(b) block distinction regarding whether a macro block is one of an intra-block for performing temporal prediction and an inter block for performing spatial prediction regarding a picture for performing prediction of a temporal direction;

a code amount control unit configured:
(a) to set a first offset amount of a first quantizing parameter, so as to have a predetermined code amount to be assigned to a non-I picture which references many images, according to a ratio, wherein said ratio is calculated between said intra block for performing temporal prediction and said inter block for performing spatial prediction regarding said picture for performing prediction of said temporal direction based on said block distinction performed at said first encoding unit,
(b) to determine a second quantizing parameter based on said first generated code amount, so that a predicted generated code amount at the time of performing encoding using said first quantizing parameter, realizes a first target generated code amount, wherein said first quantizing parameter is a offset with said first offset amount,
(c) to calculate a high-frequency component cost indicating a state of a high-frequency component in said non-I picture, and
(d) to correct said predicted generated code amount based on said calculated high-frequency component cost; and

a second encoding unit configured to perform encoding of said rearranged image data using said first quantizing parameter for realizing said first target generated code amount.

2. The image encoding device according to claim 1, wherein, with said picture for performing prediction of said temporal direction, said code amount control unit is configured to set, when said ratio of a number of said inter blocks for performing spatial prediction as to a number of said intra blocks for performing temporal prediction is equal to or smaller than a first threshold, a second offset amount so as to reduce a code amount to be assigned to said picture, and
wherein, with said picture for performing prediction of said temporal direction, said code amount control unit is configured to set, when said ratio of said number of said inter blocks for performing spatial prediction as to said number of said intra blocks for performing temporal prediction is equal to or smaller than a second threshold that is greater than said first threshold, a third offset amount smaller than said second offset amount at the time of said ratio being equal to or smaller than said first threshold.

3. The image encoding device according to claim 1, further comprising:
a third encoding unit configured to use plurality of different quantizing parameters to perform encoding for each of said plurality of different quantizing parameters with said rearranged image data as image data of an intra picture to calculate a second generated code amount,
wherein said code amount control unit is configured to perform prediction of a third generated code amount at the time of using a third quantizing parameter for realizing a second target generated code amount, and said first quantizing parameter based on said first generated code amount, correct said third generated code amount according to said second generated code amount, and determine a fourth quantizing parameter so that said third generated code amount after correction realizes said second target generated code amount.

4. The image encoding device according to claim 3, wherein said code amount control unit is configured to perform the setting of an upper limit of said first offset amount according to said first quantizing parameter for realizing said first target generated code amount based on said first generated code amount, and when change in said predicted generated code amount at the time of offsetting said first quantizing parameter is smaller than a first predetermined value, set said upper limit of said first offset amount to a second predetermined value, and when change in said predicted generated code amount is greater than a third predetermined value, set said upper limit of said first offset amount to a fourth predetermined value.

5. The image encoding device according to claim 3, wherein said code amount control unit is configured to determine, from said first and said second generated code amounts of 1 GOP, said fourth quantizing parameter of said 1 GOP.

6. An image encoding method comprising:
rearranging image data in a sequence of pictures from a display sequence to an encoding sequence in accordance with a Group of Picture (GOP) configuration;
calculating a first generated code amount at a time of performing encoding of rearranged image data using a fixed quantizing parameter;
performing block distinction regarding whether a macro block is one of an intra block for performing temporal prediction and an inter block for performing spatial prediction regarding a picture for performing prediction of a temporal direction;
setting an offset amount of a first quantizing parameter, so as to have a predetermined code amount to be assigned to a non-I picture which references many images, according to a ratio, wherein said ratio being calculated between said intra block for performing temporal prediction and said inter block for performing spatial prediction regarding said picture for performing prediction of said temporal direction based on said performed block distinction;
determining a second quantizing parameter based on said first generated code amount, so that a predicted generated code amount at the time of performing encoding using said first quantizing parameter, realizes a target generated code amount, wherein said first quantizing parameter is a offset with said offset amount;
calculating a high-frequency component cost indicating a state of a high-frequency component in said non-I picture;
correcting said predicted generated code amount based on said calculated high-frequency component value; and
encoding said rearranged image data using said first quantizing parameter for realizing said target generated code amount.