Interpretation of IMG-> quad in jm8.6 on the peak SNR:
In JMCodeI have encountered the IMG-> quad many times, but only one explanation is provided in the official code:
I did not understand it after reading it several times. Then I can see that there is SNR later. So I think it should be related to SNR.
Then look for SNR in the Code and find that there is a function in the JM code. Then let's look down and suddenly find out
In old Bi's book
We can compare the formula above and find that, with n = 8, we can get the code 65025 = (2 ^ 8-1) = 255 ^ 2, so it is mainly the calculation of MSE, mse is mean square error, so it can be inferred that diff_y should be the square of the error,
Let's look at the calculation of diff_y,
After contacting quad, I suddenly felt a little clear about the meaning of "array containing square values" in the original code comment. Then let's take a look at the assignment of Quad:
Look at the number 511. What a good number does it appear like 512, 256x2 = 512.
Therefore, we can know that the quad array is allocated 511 int space sizes:-255 ~ 0 ~ 255, exactly 511,
Look at the second red box. This sentence moves the pointer quad to the 255 position. You can see
The position indicated by the arrow is the current position of the pointer. let's look at the inside of the for loop. Before that, I couldn't understand why the subscript of the array uses a negative number. What does it mean now. therefore, in the for loop, the corresponding subscript location is stored as its square, and the square actually calculates the square of the error required by the MSE in advance. When the square of the error is calculated, you only need to check the table to improve the speed.
The value in the red box is actually an integer, because this is the difference between the original image pixel and the reconstruction image pixel, so the value can be negative or positive, in this way, the square of the corresponding residual is obtained. so far, I have finally understood the intention of the quad array and the implementation of SNR in the code.