The present invention relates to an apparatus for compressing/encoding an image code by using a CPU (Central Processing Unit), a DSP (Digital Signal Processor), and the like, and an apparatus for reproducing a compressed image code.
When an image is to be digitized and recorded on a recording medium such as a CD-ROM (Compact Disk-Read Only Memory) or a hard disk, the data amount becomes enormous. For this reason, the image data is generally compressed/encoded to be recorded. Of various types of compressing/encoding schemes, an encoding scheme based on DCT (Discrete Cosine Transform) and designed to compress an image by using its property of having spatial frequencies concentrated at low frequencies is relatively popular. This scheme is used for encoding schemes as international standards such as JPEG (Joint Photographic Experts Group) and MPEG (Moving Picture Experts Group).
FIGS. 1A to 1F show the hierarchical structure of a code format complying with MPEG. An MPEG code has several hierarchical layers as shown in FIGS. 1A to 1F. The uppermost layer is a video sequence, which is constituted by a plurality of GOPs (Group of Picture), as shown in FIG. 1A.
A GOP is constituted by a plurality of pictures. One picture represents one image. As shown in FIG. 1B, there are three types of pictures, i.e., an I-picture which is an intraframe code, a P-picture which is an interframe code based on only forward prediction, and a B-picture which is an interframe code based on bidirectional prediction. As shown in FIG. 1C, a picture is constituted by a plurality of slices obtained by dividing a picture into arbitrary areas. As shown in FIG. 1D, a slice is constituted by a plurality of macroblocks arranged from left to right or from top to bottom.
As shown in FIG. 1E, a macroblock is constituted by six blocks, i.e., luminance components (Y1, Y2, Y3, and Y4) which are blocks obtained by dividing 16.times.16-dot blocks into 8.times.8-dot blocks, and color difference components (Cb and Cr) which are 8.times.8-dot blocks in the area which coincides with the luminance components. The.8.times.8-dot block in FIG. 1F is the minimum encoding unit.
Compression of an image code by the conventional encoding scheme based on DCT will be described below by taking MPEG as an example. FIG. 2 shows a conventional image compressing apparatus which complies with MPEG. This apparatus is constituted by an apparatus control section 1, a CPU 2, a keyboard 3, and an image compression section 4. In the image compression section 4, a Y/C (luminance and chrominance) separating section 5 converts loaded image data into Y/C data, and a motion search section 6 searches for the motion of the image in the previous/subsequent frame and the current frame in units of 8.times.8-block areas. According to MPEG, since a GOP is divided into three types of pictures, i.e., an I-picture which is an intraframe code, a P-picture which is an interframe code based on only forward direction, and a B-picture which is an interframe code based on bidirectional prediction, three types of encoding are performed.
When an I-picture is to be processed, a DCT section 8 performs discrete cosine transform for the values of the pixels in an 8.times.8-block area of the current frame. A quantization section 9 then quantizes the resultant data. A variable-length encoding section 10 performs high-efficiency compression for the quantized data to generate a variable-length Huffman code. To decode the compressed image into a reference frame, a dequantization section 14 dequantizes the quantized data. An IDCT section 13 then performs inverted discrete cosine transform for the dequantized data to calculate the pixel values, and stores them in a reference frame section 11.
When a P-picture is to be processed, a motion prediction section 7 calculates the differences between the values of the pixels in an 8.times.8-block area of the current frame and the values of the pixels in an 8.times.8-block area of the previous frame which is stored in the reference frame section 11 and is referred to with the motion searched out by the motion search section 6. The DCT section 8 performs discrete cosine transform for the calculated difference values. The quantization section 9 then quantizes the resultant data. The variable-length encoding section,10 performs high-efficiency compression for the quantized data to generate a variable-length Huffman code. To decode the compressed image into a reference frame, the dequantization section 14 dequantizes the quantized data, and the IDCT section 13 performs inverted discrete cosine transform to calculate the difference values. Subsequently, a motion compensation section 12 adds the difference values to the values of the pixels in the 8.times.8-block area of the previous frame which is stored in the reference frame section 11 and referred to by the motion prediction section 7, and stores the resultant data in the reference frame section 11.
When a B-picture is to be processed, the motion prediction section 7 calculates the differences between the values of the pixels in an 8.times.8-block area of the current frame and the values of the pixels in an 8.times.8-block area of the previous/subsequent frame which is stored in the reference frame section 11 and referred to with the motion searched out by the motion search section 6. The DCT section 8 performs discrete cosine 5 transform for the calculated difference values. The quantization section 9 then quantizes the resultant data. The variable-length encoding section 10 performs high-efficiency compression for the quantized data to generate a variable-length Huffman code. Since no B-picture is used as a reference frame, no image expansion is performed.
Reproduction of an image code by a conventional encoding scheme based on DCT will be described below with reference to FIG. 3 by taking MPEG as an example. FIG. 3 shows a conventional image reproducing apparatus for reproducing an image code complying with MPEG. Reference numeral 21 denotes an apparatus control section; 22, a CPU; 23, a keyboard; and 24, an image reproducing section. The image reproducing section 24 loads encoded data, and expands three types of codes, i.e., an I-picture which is an intraframe code, a P-picture which is an interframe code based on only forward direction, and a B-picture which is an interframe code based on bidirectional prediction.
When an I-picture is to be processed, a variable-length decoding section 25 decodes the encoded data. A dequantization section 26 dequantizes the data. An IDCT (Inverted DCT) 27 then performs inverted discrete cosine transform for the dequantized data to calculate the values of the pixels in the blocks from the output from the dequantization section 26. An RGB (Red, Green, Blue) conversion section 28 outputs the resultant image.
When a P-picture is to be processed, the variable-length decoding section 25 decodes the encoded data. The dequantization section 26 dequantizes the data. The IDCT 27 then performs inverted discrete cosine transform for the dequantized data to calculate the differences between the blocks from the output from the dequantization section 26. A motion compensation section 30 adds the calculated differences to the motion-compensated blocks of the previous frame stored in a reference frame section 29. The RGB conversion section 28 outputs the resultant image.
When a B-picture is to be processed, the variable-length decoding section 25 decodes the encoded data. The dequantization section 26 dequantizes the data. The IDCT 27 performs inverted discrete cosine transform for the dequantized data to calculate the differences between blocks from the output from the dequantization section 26. The motion compensation section 30 adds the calculated differences to the motion-compensated blocks of the previous frame stored in the reference frame section 29 and the motion-compensated blocks of the previous/subsequent frame stored in the reference frame section 29. The RGB conversion section 28 outputs the resultant image.
When compression and reproduction are performed on the basis of MPEG as an international standard, an image can be compressed and reproduced with high efficiency. Many computations are, however, required for processing such as motion search/motion compensation and DCT/IDCT. For this reason, image compression and reproduction by means of software must be processed by a program optimized to realize the est operation speed in consideration of the characteristics of a CPU. To cope with various types of CPUS, therefore, different programs must be prepared to be switched in accordance with the types of CPUS.
As a conventional method of using optimal programs, a method of compiling programs to generate optimal programs for CPUs is disclosed in Japanese Patent Laid-Open No. 6-282444. In addition, Japanese Patent Laid-Open No. 4-322329 discloses a method of generating an optimal program when the program is installed in a computer. Japanese Patent Laid-Open No. 3-244067 also discloses a method of selecting an optimal CPU in accordance with a program.
According to the above conventional scheme of generating optimal programs, however, a dedicated program must be generated for each computer to be used, and must be installed therein. Such a program cannot be shared among a plurality of computers through a network or the like. In addition, since such a program is not generated in consideration of an available memory capacity, the program may be too large in size to be loaded into the memory. Furthermore, the scheme of selecting an optimal CPU cannot be applied to a computer using a single CPU.