Disclosure of Invention
Therefore, in order to solve the technical defects and shortcomings in the prior art, the invention provides a self-adaptive texture gradual change prediction method in bandwidth compression.
Specifically, an embodiment of the present invention provides a method for predicting adaptive texture gradient in bandwidth compression, including:
selecting N sampling modes to sample the pixel components in the current MB;
selecting a prediction mode in M to predict the current MB;
calculating prediction residual error and SAD of the current MB respectively;
and selecting the sampling mode and the prediction mode of the current MB according to the SAD.
In an embodiment of the present invention, selecting N sampling modes to sample the pixel components in the current MB includes: and selecting N non-equidistant sampling modes to sample the pixel components in the current MB, wherein N is an integer greater than 1.
In an embodiment of the present invention, the prediction mode is an angle prediction mode.
In an embodiment of the present invention, the angle prediction method includes: 45 degree texture prediction, 90 degree texture prediction, and 135 degree texture prediction.
In one embodiment of the present invention, calculating the prediction residual and SAD of the current MB separately comprises:
calculating a first prediction residual of the current MB sampling point;
and calculating a second prediction residual of the non-sampling point of the current MB by using a prediction formula.
In one embodiment of the present invention, calculating the prediction residual and SAD of the current MB separately comprises:
calculating a first SAD and a second SAD respectively; wherein the first SAD is a sum of absolute residuals from which the first and second prediction residuals for the current MB are calculated, and the second SAD is a sum of absolute residuals from which the first prediction residual for the current MB is calculated.
In one embodiment of the present invention, calculating the first prediction residual for the current MB sample point comprises:
and respectively subtracting the pixel value of the current MB sampling point from the pixel value of the 45-degree pixel component, the pixel value of the 90-degree pixel component and the pixel value of the 135-degree pixel component of the sampling point in the adjacent MB right above the current MB to obtain the first prediction residual error.
In one embodiment of the present invention, the prediction formula is:
Resi=(sample1-sample0)*(i+1)/(num+1)
sample0 and sample1 are pixel component reconstruction values of consecutive sample points, i is an index of an unsampled point, num is the number of the unsampled points, and Res is a second prediction residual.
In one embodiment of the present invention, a sampling mode corresponding to a minimum value of the first SAD is determined as the sampling mode of the current MB.
In an embodiment of the present invention, a prediction mode corresponding to the determined sampling mode of the current MB is determined as the prediction mode of the current MB.
Based on this, the invention has the following advantages:
the invention calculates the prediction residual error and SAD of the current macro block by defining the sampling mode of MB and the reference mode of pixel component prediction. Compared with the prior art, when the texture of the image to be compressed is complex, the prediction residual error is obtained for the MB at the texture boundary of the current image according to the gradual change principle of the texture without depending on the peripheral MB of the current MB through the texture characteristic of the current MB, so that the precision of solving the prediction residual error value for the complex texture area can be improved, the theoretical limit entropy is further reduced, and the bandwidth compression ratio is increased.
Other aspects and features of the present invention will become apparent from the following detailed description, which proceeds with reference to the accompanying drawings. It is to be understood, however, that the drawings are designed solely for purposes of illustration and not as a definition of the limits of the invention, for which reference should be made to the appended claims. It should be further understood that the drawings are not necessarily drawn to scale and that, unless otherwise indicated, they are merely intended to conceptually illustrate the structures and procedures described herein.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
Example one
Referring to fig. 1, fig. 1 is a schematic flow chart of a method for predicting adaptive texture gradient in bandwidth compression according to an embodiment of the present invention; this embodiment describes a prediction method provided by the present invention in detail, and the prediction method includes the following steps:
step 1, selecting N sampling modes to sample pixel components in a current MB;
step 2, selecting a prediction mode in M to predict the current MB;
step 3, respectively calculating the prediction residual error and the SAD of the current MB;
and 4, selecting the sampling mode and the prediction mode of the current MB according to the SAD.
Wherein, step 1 may include the steps of:
and 11, selecting N non-equidistant sampling modes to sample the pixel components in the current MB, wherein N is an integer greater than 1.
Preferably, the prediction mode is an angle prediction mode.
Preferably, the angle prediction method includes: 45 degree texture prediction, 90 degree texture prediction, and 135 degree texture prediction.
Wherein, step 3 may include the following steps:
step 31, calculating a first prediction residual of the current MB sampling point;
and step 32, calculating a second prediction residual of the current MB non-sampling point by using a prediction formula.
Wherein, step 3 may further include the following steps:
step 33, calculating a first SAD and a second SAD respectively; wherein the first SAD is a sum of absolute residuals from which the first and second prediction residuals for the current MB are calculated, and the second SAD is a sum of absolute residuals from which the first prediction residual for the current MB is calculated.
Wherein, step 31 may comprise the steps of:
step 311, respectively subtracting the pixel value of the sampling point of the current MB from the pixel value of the 45-degree pixel component, the pixel value of the 90-degree pixel component, and the pixel value of the 135-degree pixel component of the sampling point in the adjacent MB directly above the current MB to obtain the first prediction residual error.
Preferably, the prediction formula is:
Resi=(sample1-sample0)*(i+1)/(num+1)
sample0 and sample1 are pixel component reconstruction values of consecutive sample points, i is an index of an unsampled point, num is the number of the unsampled points, and Res is a second prediction residual.
Preferably, a sampling mode corresponding to the minimum value of the first SAD is determined as the sampling mode of the current MB.
Preferably, the prediction mode corresponding to the determined sampling mode of the current MB is determined as the prediction mode of the current MB.
Example two
Referring to fig. 2 and fig. 3, fig. 2 is a schematic diagram illustrating a sampling manner of another adaptive texture gradient prediction method according to an embodiment of the present invention; fig. 3 is a schematic diagram of another adaptive texture gradient prediction method according to an embodiment of the present invention. The present embodiment describes another prediction method proposed by the present invention in detail based on the above embodiments. The prediction method comprises the following steps:
step 1, defining MB size
Defining the size of MB as m × n pixel components, wherein m is more than or equal to 1, and n is more than or equal to 1;
preferably, the size of MB may be defined as 8 × 1 pixel components, 16 × 1 pixel components, 32 × 1 pixel components, 64 × 1 pixel components; in the present embodiment, the size of the MB is 16 × 1 pixel components, and the other MBs with different sizes are the same. The pixel components in the MB are arranged in order from left to right according to ordinal numbers from 0 to 15, and each ordinal number position corresponds to one pixel component.
Step 2, defining sampling mode
According to the texture correlation existing in the MB, the closer the pixel distance in the MB is, the higher the consistency theory of texture gradual change of the MB is, and conversely, the farther the pixel distance in the MB is, the lower the consistency probability of texture gradual change of the MB is, so that the pixel components in the MB are subjected to non-equidistant sampling, and various non-equidistant sampling modes can be selected.
Preferably, as shown in fig. 2, the present embodiment performs non-equidistant sampling on 16 × 1 pixels in the MB, which is illustrated by three non-equidistant sampling manners of sample1, sample 2 and sample 3, and the same applies to other non-equidistant sampling manners, wherein,
sample1 is to sample 3 pixel components of positions corresponding to serial numbers 0, 4 and 15 in the MB;
sample 2 is to sample 4 pixel components at positions corresponding to serial numbers 0, 5, 10, and 15 in the MB;
sample 3 is a sample of 3 pixel components at positions corresponding to the numbers 0, 11, and 15 in the MB.
And 3, processing the multiple non-equidistant sampling modes selected in the step 2 to obtain a prediction residual error.
In this embodiment, a non-equidistant sampling processing procedure is taken as an example, and other types of equidistant sampling processing procedures are the same. The method comprises the following specific steps:
step 31, as shown in fig. 3, for sample1, predicting the 45 degree pixel component point, the 90 degree pixel component point, and the 135 degree pixel component point of the adjacent MB right above the current MB and the sample point respectively, that is, the prediction modes are 135 degree prediction, 45 degree prediction, and 90 degree prediction, solving the prediction residuals of all the sample points under the three angle prediction modes, and calculating the sum of absolute values (SAD for short) of the prediction residuals of all the sample points under each prediction mode, that is, the second SAD. Specifically, a 45-degree pixel component point, a 90-degree pixel component point, and a 135-degree pixel component point corresponding to a sampling point in an adjacent MB directly above the current MB may be subtracted from the sampling point in the current MB, so as to obtain a prediction residual error; and respectively taking absolute values of the prediction residual errors of each sampling point under each prediction mode, and then adding the absolute values to obtain a second SAD. And selecting a prediction mode corresponding to the second SAD minimum value as the prediction mode of the current MB sampling point.
Preferably, the prediction mode can be any combination of 135-degree prediction, 45-degree prediction and 90-degree prediction.
Step 32, obtaining the prediction residual error of the current MB sampling point in the prediction mode selected in step 31, and for the non-sampling point, solving the prediction residual error of the non-sampling point by using a formula, wherein the formula is as follows:
Resi=(sample1-sample0)*(i+1)/(num+1)
sample0 and sample1 in the formula are pixel component reconstruction values of consecutive sample points in the current MB, i is an index of a non-sample point, and num is the number of the non-sample points.
Further, the pixel component reconstruction value may refer to a pixel component value reconstructed by the decoding end of the compressed coded MB.
Finally, the prediction residuals of all pixel component points of the current MB in the prediction mode selected in step 31 are obtained, and the first SAD is calculated.
And step 33, repeating the steps 31 to 32, obtaining the prediction residual errors of all pixel component points of the current MB under the sample 2 and the sample 3, calculating the first SAD, selecting a sampling mode corresponding to the minimum value of the first SAD as the sampling mode of the current MB, and adopting the prediction mode determined in the sampling modes as the prediction mode of the current MB.
And 4, writing the sampling mode, the prediction residual error and the prediction mode of the sampling point in the current MB into the code stream.
In summary, the present invention is described based on the adaptive texture gradient prediction method in bandwidth compression by applying specific examples, and the description of the above embodiments is only used to help understanding the method of the present invention and its core idea; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention, and the scope of the present invention should be subject to the appended claims.