View Full Version : How to build quantization matrix
ticapix
16th June 2008, 16:04
Hi,
I've read quite a lot of papers about the job of the intra quantization matrix in mpeg4 codec, about the Human Visual System and Contrast Sensitivity Function saying that they must be taken into account to build a correct quantization matrix, but still i don't get how these matrix are build. (JPEG, Jawor, HVS best picture, H263, H264)
How people use the Weber's law, the luminance masking and contrast masking, ... to build these matrix ?
If anyone has links or ideas, feel free to share them :)
:thanks:
Dark Shikari
16th June 2008, 16:08
1. Pick a random number between 30 and 255. Call this number B.
2. Pick a random number between 6 and 14. Call this number A.
3. Create a logarithmic distribution of values between A and B. For example, if A is 10 and B is 32:
10 12 15 18 22 26 32
4. Arrange these into a matrix:
10 12 15 18
12 15 18 22
15 18 22 26
18 22 26 32
5. Repeat the process for the 8x8 matrix.
6. You're done! You have yourself a CQM... :devil:
/runs with mp4guy in hot pursuit
Sharktooth
16th June 2008, 17:04
/me prepares and loads the shotty aiming at D_S legs :)
Sagittaire
16th June 2008, 18:14
HVS matrix for exemple use really serious IEEE paper based on HVS luminance study.
http://forum.doom9.org/showthread.php?t=33499&highlight=referencedivx
There are simple rule for CQM: Human eyes are more sensible to global (low frequencies aka gradiant) than detail (high frequencies). For HVS it's better to use higher coefficient for HF and lower coefficient for LF. You obtain intra HVS matrix for MPEG4 ASP like that:
16 16 16 16 17 18 21 24
16 16 16 16 17 19 22 25
16 16 17 18 20 22 25 29
16 16 18 21 24 27 31 36
17 17 20 24 30 35 41 47
18 19 22 27 35 44 54 65
21 22 25 31 41 54 71 88
24 25 29 36 47 65 88 115
Anyway for MPEG4 AVC you have a more complex architecture. High quantisation values for Global (LF) mean blocking and it's a better HVS way to use lower relative coef in CQM in this case. But H264 can use another way against blocking: inloop deblocking. Inloop is really good against blocking but inloop is aggressive with detail level (HF). In conclusion with inloop you change this simple HVS rule.
In fact in practice and IMO for H264, flat16 matrix is really good for "low bitrate" because inloop is really agressive in this case. Have same coef for HF and LF is certainely the best HVS way here. For "high bitrate" inloop is less aggressive. HVS matrix (low coef for LF and high coef for HF) is certainely a better HVS way in this case.
Moreover with implementation like x264 use a matrix radically different than the flat16 can change the codec functioning in bad way. If you want really use CQM with x264 you must IMO use really "soft" HVS matrix like that:
INTRA4X4_LUMA =
12,12,14,16,
12,14,16,20,
14,16,20,25,
16,20,25,32
INTRA4X4_CHROMAU =
12,12,14,16,
12,14,16,20,
14,16,20,25,
16,20,25,32
INTRA4X4_CHROMAV =
12,12,14,16,
12,14,16,20,
14,16,20,25,
16,20,25,32
INTER4X4_LUMA =
14,14,15,16,
14,15,16,17,
15,16,17,18,
16,17,18,19
INTER4X4_CHROMAU =
14,14,15,16,
14,15,16,17,
15,16,17,18,
16,17,18,19
INTER4X4_CHROMAV =
14,14,15,16,
14,15,16,17,
15,16,17,18,
16,17,18,19
INTRA8X8_LUMA =
12,12,12,12,13,14,15,16,
12,12,12,13,14,15,16,17,
12,12,13,14,15,16,17,19,
12,13,14,15,16,18,20,22,
13,14,15,16,18,21,23,27,
14,15,16,18,21,24,28,37,
15,16,17,20,23,28,39,48,
16,17,19,22,27,37,48,68
INTER8X8_LUMA =
14,14,14,14,15,15,15,16,
14,14,14,14,15,15,16,17,
14,14,14,15,15,16,17,18,
14,14,15,15,16,17,18,19,
15,15,15,16,17,18,19,21,
15,15,16,17,18,20,22,26,
15,16,17,18,19,22,27,32,
16,17,18,19,21,26,32,44
xxthink
5th April 2009, 10:23
HVS matrix for exemple use really serious IEEE paper based on HVS luminance study.
http://forum.doom9.org/showthread.php?t=33499&highlight=referencedivx
There are simple rule for CQM: Human eyes are more sensible to global (low frequencies aka gradiant) than detail (high frequencies). For HVS it's better to use higher coefficient for HF and lower coefficient for LF. You obtain intra HVS matrix for MPEG4 ASP like that:
16 16 16 16 17 18 21 24
16 16 16 16 17 19 22 25
16 16 17 18 20 22 25 29
16 16 18 21 24 27 31 36
17 17 20 24 30 35 41 47
18 19 22 27 35 44 54 65
21 22 25 31 41 54 71 88
24 25 29 36 47 65 88 115
Anyway for MPEG4 AVC you have a more complex architecture. High quantisation values for Global (LF) mean blocking and it's a better HVS way to use lower relative coef in CQM in this case. But H264 can use another way against blocking: inloop deblocking. Inloop is really good against blocking but inloop is aggressive with detail level (HF). In conclusion with inloop you change this simple HVS rule.
In fact in practice and IMO for H264, flat16 matrix is really good for "low bitrate" because inloop is really agressive in this case. Have same coef for HF and LF is certainely the best HVS way here. For "high bitrate" inloop is less aggressive. HVS matrix (low coef for LF and high coef for HF) is certainely a better HVS way in this case.
Moreover with implementation like x264 use a matrix radically different than the flat16 can change the codec functioning in bad way. If you want really use CQM with x264 you must IMO use really "soft" HVS matrix like that:
INTRA4X4_LUMA =
12,12,14,16,
12,14,16,20,
14,16,20,25,
16,20,25,32
INTRA4X4_CHROMAU =
12,12,14,16,
12,14,16,20,
14,16,20,25,
16,20,25,32
INTRA4X4_CHROMAV =
12,12,14,16,
12,14,16,20,
14,16,20,25,
16,20,25,32
INTER4X4_LUMA =
14,14,15,16,
14,15,16,17,
15,16,17,18,
16,17,18,19
INTER4X4_CHROMAU =
14,14,15,16,
14,15,16,17,
15,16,17,18,
16,17,18,19
INTER4X4_CHROMAV =
14,14,15,16,
14,15,16,17,
15,16,17,18,
16,17,18,19
INTRA8X8_LUMA =
12,12,12,12,13,14,15,16,
12,12,12,13,14,15,16,17,
12,12,13,14,15,16,17,19,
12,13,14,15,16,18,20,22,
13,14,15,16,18,21,23,27,
14,15,16,18,21,24,28,37,
15,16,17,20,23,28,39,48,
16,17,19,22,27,37,48,68
INTER8X8_LUMA =
14,14,14,14,15,15,15,16,
14,14,14,14,15,15,16,17,
14,14,14,15,15,16,17,18,
14,14,15,15,16,17,18,19,
15,15,15,16,17,18,19,21,
15,15,16,17,18,20,22,26,
15,16,17,18,19,22,27,32,
16,17,18,19,21,26,32,44
Would you like to give the method that these matrixes are deduced?
Sharktooth
5th April 2009, 14:12
they are NOT deduced.
you cant understand or build a (useful) CQM if you do not understand how the quantization works, what are the DCT coefficients, etc...
however, basically for AVC, what Dark_Shikari said is correct or at least, it works... but dont expect good results...
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.