The invention relates to a method of coding video data and more in particular to the selection of a quantization scale to code the video data. The invention also relates to an apparatus that implements such a method.
U.S. Pat. No. 5,754,236 discloses a method of encoding video data according to the MPEG standard. Such encoding may be used in many different apparatuses, such as camcorders, video recording devices, video transmission devices for broadcast purposes or for telecommunication purposes.
The MPEG standard makes use of quantization to reduce the amount of data needed to encode the video data. MPEG, for example, uses quantization for encoding the DCT coefficients of the image content of macro blocks. Using quantization means that only a limited number of signal values Sm can be encoded (m=0, 1, 2 etc. indexes the different signal value values).
Sm=m*Q+So
Each other signal value S′ is replaced by one of the limited number of values Sm. This is called quantization. The distance Q between successive values that can be encoded is called the quantization scale Q.
The quantization scale Q is a prime parameter for controlling the amount of data that is needed to encode the video data, i.e. the compression rate. The larger the quantization scale Q, the less data is needed. On the other hand, the quantization scale Q affects the image distortion caused by encoding. The encoded image will deviate from the real image when the quantization scale does not have the minimum possible value. Generally, the distortion increases as the quantization scale Q increases.
Selection of the quantization scale Q is therefore based on a compromise between maximizing the compression rate and minimizing the distortion. In practice, the maximum amount of data that may be used to encode the video data is usually a hard parameter, determined by the available bandwidth, storage space etc. The quantization scale is adapted so that the amount of data does not exceed this maximum. A conventional algorithm sets the quantization scale Q to the minimum value that results in less than the maximum amount of data Usually a refinement of this conventional algorithm is used, in which the complexity of different macro-blocks of the image is computed first, an amount of data is allocated to the macro-block based on the complexity of the macro-block and the quantization scales of each different macro-block is set to respective minimum value that results in less than the allocated amount of data.
U.S. Pat. No. 5,754,236 describes an alternative that uses a search algorithm to search for an assignment of a set of quantization scales Q to different macro-blocks that minimizes the amount of data under the constraint that a predetermined compression rate is realized. That is, it does not set the quantization scales so that each macro-block individually realizes a predetermined compression rate. A non-exhaustive search algorithm is used to ensure a computationally feasible search.
The algorithm of U.S. Pat. No. 5,754,236 reaches the optimum quantization scale Q assignment in steps, each step increasing the quantization scale for a selected macro-block, for which a maximum increase of the compression rate can be achieved with a minimum increase in distortion. The steps are repeated, selecting different macro-blocks and increasing the quantization scale in the selected blocks until a predetermined compression rate is realized.
The objective of the present invention is to realize a further reduction of the amount of data needed to encode video data with little or no loss of distortion.
The invention provides for an encoding method according to claim 1. The invention is based on the insight that, although distortion generally increases with increasing quantization scale, this is not always the case. There may be local minima in the distortion as a function of quantization scale. This is the case for example when all signal values are the product of a same greatest common divisor. Accordingly, it has been realized that it is often possible to increase the compression rate without increasing distortion, or even with a decrease of distortion, by selecting a greater quantization scale than minimally needed to realize a given compression rate. Thus after using any algorithm to select quantization scales that ensure sufficient compression rate, additional compression can be realized by applying an optimization step that checks for the possibility of a further quantization scale reduction that substantially does not result in increased distortion.
The invention further relates to a method of finding an optimum quantizing scale by means of a feedback loop comparing the generated errors during quantization with different quantization scales, finding the better i.e. less error-generating quantization scale and proceeding to create an output bitstream utilizing the so found optimum quantization scale.
The invention further relates to a method in which the described optimization of the quantization scale is achieved by determining a common divisor of the quantized coefficients and multiplying the quantization scale with the computed value. The quantization scale is thus increased, resulting in a lower bitrate with the same or less quantization errors being made. Preferably the greatest common divisor of the coefficients is used.
By thus encoding a video sequence according to the encoding method of the invention, less bits are used without additional loss of picture quality by optimizing the quantization scale.
The invention further relates an audiovisual device, a data container device, a computer program and a data carrier device on which a computer program is stored.
Particularly advantageous elaborations of the invention are set forth in the dependent claims.
Further objects, elaborations, modifications, effects, and details of the invention appear from the following description, in which reference is made to the drawing, in which
In operation uncompressed video data is supplied to input 10. Pre-processing unit 11 performs various preprocessing operations. In case of MPEG compression for example, preprocessing unit 11 divides the frames of video data into macro-blocks and computes DCT (Digital Cosine Transform) coefficients of the image data for each block. Quantizer 12 receives the coefficients and replaces them by quantized coefficients equal to a base value So plus an integer multiple of a quantization scale Q. Variable length encoder 13 encodes the quantized coefficients using a variable length code that has been selected to minimize the number of bits needed to encode the video data. Packaging unit 14 packages the encoded coefficients and outputs an MPEG signal, which may be used for transmission, recording etc. and ultimately for decoding and rendering with a television set (not shown) for example.
Quantization scale controller 19 controls the quantization scale used by quantizer 12. Quantization scale controller 19 ensures that the MPEG signal does not contain more bits than can be handled (for example within a given transmission bandwidth or memory space). Quantization scale controller 19 aims to realize a minimum of image distortion for a requested compression factor, or a maximum compression for a given distortion.
Prior art compression techniques are primarily based on the first curve 30. They assume that, once a minimum quantization scale Q has been selected that reduces the amount of encoded data A to the required level with a minimum of distortion, any increase in quantization scale Q will increase the distortion D. However, this is true only on average. As shown by the second curve 32 of
Any method may be used in third step 43. For example, one may measure the complexity of the image data in the different blocks and set an individual target amount of data An for each block (“n” being an index that indicates individual ones of the blocks) dependent on the complexity of each block, so that the aggregate of the target amounts An for all blocks does not exceed the required compression rate R. Subsequently, the quantization scale Qn for each block may be increased until it is measured that the resulting amount of data An′ does not exceed the target amount An. As another example, an algorithm may be used that reduces the quantization scales Qn of selected blocks sequentially until the total amount of data A has been reduced so that the required compression rate R is realized. As a result of the third step a minimum quantization scale values Q are selected that reduce the amount of data A below the level set by the required compression rate R.
In a fourth step 44 the apparatus checks whether an additional reduction of the amount of data A is possible without increasing the distortion D. That is, the apparatus checks whether the distortion D for individual blocks corresponds to a curve 32 with locally decreasing distortion D. If so, the apparatus replaces the quantization scale value Qn (that was selected for the block in the third step 43) by a higher quantization scale value Qn′ that does not increase the distortion.
In the fourth step 44 any method may be used to check whether there are such higher quantization scale values Qn′. In one embodiment, the distortion D′ is computed for all higher quantization scale values Qn′ and the highest quantization scale value Qn′ that leads to the smallest computed distortion D′ is selected if that distortion D′ is not substantially higher than the distortion D for the originally selected quantization scale value Qn.
In another embodiment, it is first determined whether a majority or all of the quantized signal values in a block share a greatest common divisor G bigger than one. If so, a quantization scale value Qn′=G*Qn may be used as new quantization scale value Qn′. This is based on the fact that no further distortion occurs if Qn is replaced by G*Qn when all signal values share a common divisor G. In a further embodiment, the distortion D′ is computed for that quantization scale value G*Qn and quantization scale values surrounding that value G*Qn, at increasing distance from G*Qn until D′ increases. In this case, the quantization scale value Qn′ for which a minimum distortion was thus found is preferably used.
Instead of the greatest common divisor G one may also determine and use a common divisor G′ of the quantized values (which necessarily is at least a divisor of the greatest common divisor), without checking whether it is the greatest common divisor. Under some practical circumstances it may take less computational effort to determine simply some common divisor without striving to determine the greatest common divisor.
In a fifth step 45 the quantization scale values Qn′ found in this way, together with unchanged quantization scale values Qn for blocks for which no new quantization scale value Qn′ was found, are output to quantizer 12 for computation of the final encoded image data.
Although the invention has been described mainly for MPEG encoding, it will be appreciated that it is not limited to MPEG encoding. For example, it may be applied to other forms of image encoding that encode blocks of image data using quantization, such as used for transmission of images over telecommunications networks.
The invention may be applied to transcoding as well, using encoded and compressed image data as input for the fourth step of the flow chart of
Although the invention may be implemented with dedicated hardware such as a quantization scale controller 19, it will be appreciated that the invention may also be implemented using a computer program for running on a computer system, at least including instructions for performing steps of a method according to the invention when run on a computer system or enabling a general propose computer system to perform functions of a computer system according to the invention. Such a computer program may be provided on a data carrier, such as a CD-rom or diskette, stored with data loadable in a memory of a computer system, the data representing the computer program. The data carrier may further be a data connection, such as a telephone cable or a wireless connection transmitting signals representing a computer program according to the invention.
Number | Date | Country | Kind |
---|---|---|---|
02076263.9 | Mar 2002 | EP | regional |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/IB03/01246 | 3/27/2003 | WO |