Abstract:
A coding apparatus includes a large block forming unit for forming a large block of sample values of an input signal, a small block forming unit for dividing the large block into a plurality of small blocks, a first coding unit for coding the small blocks of the input signal by using a difference signal obtained by subtracting a predicted value from the small blocks of the input signal, a second coding unit for coding the small blocks of the input signal without using the difference signal, and a selecting unit for selecting the first or second coding unit in units of large blocks.

Description:
This application is a continuation of application Ser. No. 08/064,883 filed May 24, 1993 now abandoned. 
    
    
     BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     The present invention relates to a coding apparatus for performing coding by adaptively switching two or more coding systems. 
     2. Related Background Art 
     Conventionally, various coding systems have been proposed in order to reduce the quantity of transmission data in digitally transmitting image information. 
     One of the proposed coding systems is to perform coding by switching intraframe coding and interframe coding. 
     The intraframe compression is a system of reducing the quantity of information by using the characteristic of an image that neighboring pixels have similar brightnesses and similar colors. 
     In the bulk of an actual image, such as a portion of sky or wall of an image, brightnesses and colors respectively continue at substantially the same levels, and so compression of about ⅕ to {fraction (1/10)} is possible even by the use of the intraframe compression alone. 
     The interframe compression is a system of obtaining images from corrected information alone by using analogous images. 
     In normal dynamic images, patterns of adjacent frames are similar to each other although there are some movements or deformations. By taking advantage of this characteristic, the similarity (e.g., movement, color, and brightness) between a frame to be compression-coded and its adjacent frame is calculated. On the basis of this calculation, a “predicted value,” i.e., the value of a frame which is more similar to the “frame to be coded” than the “adjacent frame” is calculated. 
     Subsequently, only information indicating the difference between the frame to be coded and the “predicted value” is coded (recorded and transmitted). For this reason, the quantity of data (the quantity of correction) is reduced. 
     That is, when a person moves to the right in a dynamic image in which only the person is shown, pixels at which the person exists in the immediately preceding frame, including correction information of the movement, correspond to the predicted value, and a value obtained by subtracting the predicted value from the whole pixels which have moved to the right corresponds to the difference. 
     It is generally known that when compression is performed by the interframe processing in conventional coding apparatuses, if an error occurs in a transmission path, this error propagates. Therefore, the intraframe processing is automatically performed after the interframe processing is performed a predetermined number of times. 
     The quantity of data per frame of a coded image is approximately 16K to 25K bytes, in the intraframe processing, and approximately 7K to 10K bytes, in the interframe processing. 
     That is, the quantity of generated data in the intraframe processing is generally larger than that in the interframe processing. 
     When the intraframe coding is performed periodically, therefore, the quantity of generated data abruptly increases if quantization is performed by using the immediately preceding quantization step (the quantization step used in the interframe coding), and this poses a problem of a transmission rate. 
     To reduce the quantity of generated data, however, if coding is performed while changing the quantization step, another problem of degradation in image quality arises. 
     In addition, when compression coding is performed by using DCT (Discrete Cosine Transform), no bias occurs in generated information with respect to a DC (direct current) component in the intraframe compression processing. This makes it impossible to reduce the quantity of information by the use of entropy coding (in which the quantity of information generated is reduced by assigning a short codeword to information which is generated at a high probability and a long codeword to information which is generated at a low probability). 
     The above problems take place in coding apparatuses (having at least a predictive coding mode) for performing coding by adaptively switching a plurality of coding modes. 
     Under these circumstances, the present invention is directed to a coding apparatus which prevents degradation in signals by eliminating the above conventional problems. 
     SUMMARY OF THE INVENTION 
     The present invention has been made in consideration of the above situations and has as its object to provide a coding apparatus which prevents degradation in signals by eliminating the above conventional problems. 
     According to one preferable aspect of the present invention, there is provided a coding apparatus comprising block forming means for forming a block of sample values of an input signal, coding means having a first coding mode, in which the block of the input signal is coded by using a difference signal obtained by subtracting a predicted value from the block of the input signal, and a second coding mode, in which the block of the input signal is coded without using the difference signal, comparing means for comparing a data quantity of the difference signal with a data quantity of the input signal in units of blocks, counting means for counting the number of coding operations performed in the first coding mode, and selecting means for selecting one of the coding modes in accordance with outputs from the comparing means and the counting means. 
     Other objects and advantages of the invention will become apparent from the following detailed description taken in conjunction with the appended claims. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a block diagram showing a coding apparatus of the first embodiment according to the present invention; 
     FIG. 2 is a view for explaining the operation of the apparatus shown in FIG. 1; 
     FIG. 3 is a view for explaining zigzag scan and DCT coefficients; 
     FIG. 4 is a view for explaining DC component coding processing according to the present invention; 
     FIG. 5 is a flow chart showing a switching operation of a coding system of the first embodiment; 
     FIG. 6 is a block diagram showing a coding apparatus of the second embodiment according to the present invention; and 
     FIG. 7 is a flow chart showing a switching operation of a coding system of the second embodiment. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     A coding apparatus of the first embodiment according to the present invention will be described in detail below. 
     FIG. 1 is a block diagram showing the arrangement of the coding apparatus of the first embodiment. 
     Referring to FIG. 1, input digital image data Xi (to be referred to as an intraframe signal hereinafter) from an input terminal  11  is supplied to a subtracter  12 , a discriminator  25 , and a delay unit  24 . 
     The delay unit  24  delays the data intraframe signal Xi by a time that the discriminator  25  (to be described later) requires, and outputs the signal to a terminal a of a switch  14 . 
     The subtracter  12  calculates a difference Xi−Xi{circumflex over ( )} (to be referred to as an interframe difference signal hereinafter) between the input image data Xi from the input terminal  11  and image data Xi{circumflex over ( )} of an immediately preceding frame, which is predicted by a movement compensator  21  and subjected to two-dimensional low-pass filter processing performed by a loop filter  22 . 
     A delay unit  13  delays the interframe difference signal Xi−Xi{circumflex over ( )} by a time that the discriminator  25  requires, and outputs the signal to a terminal b of the switch  14 . 
     The discriminator  25  compares the data quantity of the intraframe signal Xi with that of the interframe difference signal Xi−Xi{circumflex over ( )} and supplies the comparison result to a comparator  28 . Note that the comparison of data quantities is performed in units of macroblocks (to be described later). 
     The value of a counter  26  is set by reading out the value from a memory  27 . If the discriminator  25  discriminates that intraframe compression is to be performed, the value of the counter  26  is reset, and this reset value is stored in the memory  27 . 
     If, on the other hand, the discriminator  25  discriminates that interframe compression is to be performed, the value of the counter  26  is counted up, and this output value from the counter  26  is supplied to the comparator  28  and stored in the memory  27 . 
     If the discriminator  25  discriminates that the intraframe compression processing is to be performed, the comparator  28  causes a switch controller  29  to close the switch  14  and a switch  42  to their respective terminals a. 
     If the discriminator  25  discriminates that the interframe compression processing is to be performed, the comparator  28  compares the output value from the counter  26  with a preset predetermined number N and supplies the comparison result to the switch controller  29 . 
     If the comparator  28  determines that the output value is smaller than the predetermined number N, the switch controller  29  closes the switches  14  and  42  to their respective terminals b. 
     If, on the other hand, the comparator  28  determines that the output value is larger than the predetermined number N, the switch controller  29  closes the switches  14  and  42  to the terminals a, performing the intraframe compression. 
     FIG. 2 is a view for explaining the above operation in detail. 
     Referring to FIG. 2, the intraframe processing is performed each time eight blocks are processed assuming that N=8. 
     The discriminator  25  shown in FIG. 1 discriminates, at t=14, that the intraframe compression processing is to be performed, and, at t=9 and 22, that the intraframe processing is to be forcibly performed each time eight blocks are processed. 
     In FIG. 2, one block is constituted by 64 pixels, eight pixels in each of the row and column directions, and four of these blocks form a large block (to be referred to as a macroblock hereinafter). Switching between the intraframe processing and the interframe processing is performed in units of macroblocks. 
     Assume that a probability at which the intraframe compression processing is discriminated is p(t), and that the intraframe compression processing is forcibly performed once for every N frames. In this case, a total probability P(t) of the intraframe processing is given by: 
     
       
           P ( t )= p ( t )+1 /N   (1) 
       
     
     Assuming that a probability at which the discriminator  25  of this embodiment discriminates that the intraframe compression processing is to be performed is p(t), and that the intraframe processing is performed once for every N frames, a total probability P′(t) of the intraframe processing is given by: 
     
       
         if  p ( t )&lt;1 /N,   
       
     
     
       
           P′ ( t )=1 /N   (2) 
       
     
     and 
     
       
         if  p ( t )&gt;1 /N,   
       
     
     
       
           P′ ( t )= p ( t )  (3) 
       
     
     Equations (1), (2), and (3) above yield: 
     
       
           P′ ( t )&lt; P ( t ) 
       
     
     This demonstrates that the probability of the intraframe compression coding in this embodiment is lower than that in the operation in which the intraframe compression is forcibly performed once for every N frames. 
     Referring back to FIG. 1, the intraframe signal Xi or the interframe difference signal Xi−Xi{circumflex over ( )}, which is selected by the switch  14 , is supplied to a discrete cosine transformer (DCT)  15  and subjected to discrete cosine transform. Note that a block unit that is DCT-processed and coded is an 8×8 block unit. 
     The transform coefficient transformed by the DCT  15  is quantized by a quantizer  16 . The quantized data is supplied to an inverse quantizer  17  and a switch  30 . 
     The inverse quantizer  17  inversely quantizes the data back into the transform coefficient and supplies the coefficient to an inverse discrete cosine transformer (IDCT)  18 . 
     The IDCT  18  transforms the transform coefficient into an intraframe signal Xi′ or an interframe difference signal (Xi−Xi{circumflex over ( )})′ and supplies the signal to an adder  19 . 
     The adder  19  adds a predicted value Xi{circumflex over ( )}, which a delay unit  43  delays by a time that the DCT  15 , the quantizer  16 , the inverse quantizer  17 , and the IDCT  18  require, or value “0”, and the intraframe signal Xi′ or the interframe difference signal (Xi−Xi{circumflex over ( )})′, and supplies the sum to a memory  20 . 
     The output Xi′ from the adder  19  is called a local decoded value, which is decoded image data. 
     The local decoded value Xi′ is stored in the memory  20  and used as predicted data delayed by one frame. 
     A movement vector calculator  40  compares the image data Xi with the image data Xi′ of the immediately preceding frame, which is stored in the memory  20 , thereby calculating the movement vector of the block to be coded. Note that the movement vector is detected in units of macroblocks described above. 
     The movement compensator  21  performs movement compensation for the image data Xi′ of the immediately preceding frame by using the movement vector and outputs movement-compensated data. 
     The loop filter  22  performs two-dimensional low-pass filter processing for the block to be coded, which is subjected to the movement compensation, and outputs the result as the predicted data Xi{circumflex over ( )}. 
     The predicted data Xi{circumflex over ( )} is supplied to a delay unit  41  and the subtracter  12 . The delay unit  41  delays the predicted data Xi{circumflex over ( )} by a time that the discriminator  25  requires to perform processing, and outputs the data to the terminal b of the switch  42 . “0” is set at the terminal a of the switch  42  in order that “0” is added by the adder  19  in the intraframe processing. 
     The switch controller  29  closes the switch  30  to a terminal a for a DC component of the intraframe coding and to a terminal b for an AC component of the interframe or intraframe coding. 
     The DC component and the AC component will be described below with reference to FIG.  3 . 
     In this embodiment, one image block is constituted by a total of 64 pixels, eight pixels in each of the row and column directions, as described above. FIG. 3 shows the correspondence between 64 DCT coefficients obtained by a DCT calculation. Referring to FIG. 3, a DC component at the upper left corner represents a mean value of the 64 pixels in the block and is called a direct current (DC) coefficient. The remaining 63 pixels are called alternate current (AC) coefficients which represent the magnitude of the AC-component electric power in that block. 
     The DC component of the block to be subjected to the intraframe coding processing is output from the terminal a of the switch  30  to a differential pulse-code modulator (DPCM)  31 . 
     The DPCM  31 , as shown in FIG. 4, obtains differences between this DC component and the DC components of the four blocks that constitute the macroblock and supplies the differences to an entropy coder  32 . 
     In general, a probability of the occurrence of “0” increases in a DC component from which differences are removed, and this produces a bias in information generated. 
     The entropy coder  32  assigns a short codeword to information with a high probability of occurrence and a long codeword to information with a low probability of occurrence, thereby reducing the quantity of data to be generated. The data thus reduced in quantity is supplied to a multiplexer  36 . 
     A zigzag scanner  33  scan-transforms the quantized AC components of the block subjected to the intraframe coding processing or the quantized transform coefficients of the block subjected to the interframe coding processing, as shown in FIG.  3 . The transformed coefficients are supplied to a run length coder  34 . 
     The run length coder  34  supplies sets of the number of “0”s and values other than “0” to an entropy coder  35 . 
     The entropy coder  35  assigns short codes to run length codes having high frequencies of occurrence and long codes to those having low frequencies of occurrence, thereby reducing the quantity of data to be generated. The data thus reduced in quantity is supplied to the multiplexer  36 . 
     The multiplexer  36  codes the output movement vector from the movement vector calculator  40  and synthesizes the coded signal and the output signals from the entropy coders  32  and  35 . The multiplexer  36  outputs the result of synthesis to a buffer memory  37 . 
     The buffer memory  37  temporarily stores the coded data and outputs the data at a predetermined transmission rate from an output terminal  38 . 
     Note that in this embodiment, the output data from the output terminal. 38  is controlled so as not to exceed the predetermined transmission rate by monitoring the data storage quantity in the buffer memory  37 . 
     For example, when the data storage quantity in the buffer memory  37  is large, a quantization step controller  39  controls the operation of the quantizer  16  to decrease the generation quantity of data, thereby controlling the quantization step in a way which decreases the data storage quantity to a given value. 
     In contrast, when the data storage quantity in the buffer memory  37  is small, the quantization step controller  39  controls the operation of the quantizer  16  to increase the generation quantity of data, thereby increasing the data quantity to the given value. Note that the quantization step controller  39  similarly controls the inverse quantizer  17 . 
     The switching between the interframe compression coding and the intraframe compression coding of the first embodiment will be described again with reference to the flow chart shown in FIG.  5 . 
     In step S 51 , whether the value of the counter  26  is N (which is a preset value) is checked. 
     If the value of the counter  26  is N in step S 51 , the flow advances to step S 52 ; if not, the flow advances to step S 54 . 
     The counter  26  is reset in step S 52 , and the flow advances to step S 53  to perform intraframe coding. 
     In step S 54 , the data quantity of Xi is compared with that of Xi−Xi{circumflex over ( )} in units of macroblocks described above. 
     If Xi&gt;Xi−Xi{circumflex over ( )} in step S 54 , the flow advances to step S 55 . If Xi&lt;Xi−Xi{circumflex over ( )} in step S 54 , the flow advances to step S 52 . 
     The counter  26  is counted up in step S 55 , and the flow advances to step S 56  to perform interframe coding. 
     In this embodiment, the above coding operations are switched in units of macroblocks described above. 
     As described above, the coding apparatus of the first embodiment according to the present invention has two or more coding systems and adaptively switches these coding systems so that the quantity of data is minimized. In addition, if an error occurs in a transmission path, the apparatus can prevent propagation of the error. Therefore, the quantity of data can be reduced without degrading image quality. 
     A coding apparatus of the second embodiment according to the present invention will be described in detail below. 
     FIG. 6 is a block diagram showing the arrangement of the coding apparatus of the second embodiment. Note that the same reference numerals as in FIG. 1 denote the same parts in FIG. 6 and a detailed description thereof will be omitted. 
     The second embodiment is different from the above first embodiment in that a switch controller  29 ′ controls switching between interframe coding and intraframe coding by also taking into account the data storage quantity in a buffer memory in addition to the switching control of the first embodiment. 
     The switching between interframe compression coding and intraframe compression coding of the second embodiment will be described below with reference to the flow chart shown in FIG.  7 . 
     In step S 71 , the data storage quantity in a buffer memory  37  is detected. If the data storage quantity detected is larger than M (which is a preset quantity) in step S 71 , the flow advances to step S 72 . If the data storage quantity is M or less, the flow advances to step S 74 . 
     The counter  26  is reset in step S 72 , and the flow advances to step S 73  to perform intraframe coding. 
     In step S 74 , whether the counter value is N (which is a preset value) is checked. If the value of the counter  26  is N in step S 74 , the flow advances to step S 72 ; if not, the flow advances to step S 75 . 
     In step S 75 , the data quantity of Xi is compared with that of Xi−Xi{circumflex over ( )} in units of macroblocks described above. 
     If Xi&gt;Xi−Xi{circumflex over ( )} in step S 75 , the flow advances to step S 76 . If Xi≦Xi−Xi{circumflex over ( )} in step S 75 , the flow advances to step S 72 . 
     The counter  26  is counted up in step S 76 , and the flow advances to step S 77  to perform interframe compression coding. 
     In this embodiment, the above coding operations are switched in units of macroblocks described above. 
     Note that the determination in step S 71  is performed on the basis of the data storage quantity in the buffer memory  37 , but this determination may also be performed in accordance with the remaining storage capacity of the buffer memory  37 . 
     As described above, the coding apparatus of the second embodiment according to the present invention performs the switching between the coding systems by also taking into consideration the data quantity in the buffer memory in addition to the switching control of the coding apparatus of the first embodiment. This makes feasible transmission of data with the highest image quality that the apparatus can achieve. 
     Note that the present invention can be practiced in a variety of other forms without departing from the spirit and scope of the invention. 
     For example, the coding apparatus for adaptively switching between interframe coding and intraframe coding has been described in each of the above embodiments. However, the present invention is similarly applicable to a combination of interfield coding and intrafield coding or to a coding system which is a given combination of the coding systems described above. 
     In addition, the present invention can be applied to a coding apparatus for performing signal coding by adaptively switching a plurality of coding modes (including at least predictive coding). 
     Furthermore, although the quantization steps of the quantizer  16  and the inverse quantizer  17  are controlled on the basis of the data storage quantity in the buffer memory  37  in each of the above embodiments, the quantization steps can also be controlled in accordance with the remaining storage capacity of the buffer memory  37 . 
     In other words, the foregoing description of embodiments has been given for illustrative purposes only and not to be construed as imposing any limitation in every respect. 
     The scope of the invention is, therefore, to be determined solely by the following claims and not limited by the text of the specifications and alterations made within a scope equivalent to the scope of the claims fall within the true spirit and scope of the invention.