Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.


Go Back   Doom9's Forum > Video Encoding > MPEG-2 Encoding

Thread Tools Search this Thread Display Modes
Old 12th February 2005, 18:04   #1  |  Link
Registered User
Join Date: Jan 2005
Posts: 368
Matrix or Matrices for encoding Mpeg-2 - Please explain, help or link

I have noticed Matrices, which are a lot of numbers that I understand help improve the encoding quality in some way

I would like to know the basic information about them (preferably explained simply ) - i.e. what do the numbers mean and what do Matrices do - what's the basic idea of how they work?

if anyone knows a good link and could give a little tutorial if it's worth me making my own if that's an option, even better.

I am interested in Matrices for Mpeg-2 and Mpeg-1.

If it's complicated please explain simply if possible, thanks. Here are a couple of questions too:

Do Matrices alter the picture for percieved qulity or enhancements - I mean like you could have a 'sharpen' effect which might fool the viewer into thinking it's a better quality encoding but it has actually altered the picture further from the original. Or do Matrices really improve the quality by keeping the picture closer to the original than if it was not used.

Is the use of a Matrix permissible if I wanted to encode 'Spec-compliant' Mpeg? I mean, does the decoder have to know about Matrices that were used to encode, or is this not an issue.
Thankyou!, I am grateful for any help
video_magic is offline   Reply With Quote
Old 13th February 2005, 14:47   #2  |  Link
Amnon82's Avatar
Join Date: Oct 2003
Location: Germany
Posts: 1,580
What is a Quantization Matrix?

To quote the explanation here:

The quantization matrix is the 8 by 8 matrix of step sizes (sometimes called quantums)
- one element for each DCT coefficient. It is usually symmetric. Step sizes will be small
in the upper left (low frequencies), and large in the upper right (high frequencies);
a step size of 1 is the most precise. The quantizer divides the DCT coefficient by its
corresponding quantum, then rounds to the nearest integer. Large quantums drive small
coefficients down to zero. The result:
many high frequency coefficients become zero, and therefore easier to code."

To put it short: It's the lossy filter by which you achieve higher compressibility by losing detail. The amount of detail lost is determined by the values of each individual quantum.

More theory about the technical process behind it:
Note: Most of these links are about Jpeg but the process is nearly the same for MPEG-2

Some matrices of mine:

AutoQ#1 Matrix:


(C) 2005 by Amnon82 - You will find it in Auto(C)Q, DRPEncEasy, DRPEncME, DRPEncXP, EasySVCD/DVD.

AutoQ#2 Matrix:


(C) 2005 by Amnon82 - You will find it in Auto(C)Q and HCEncoder

Last edited by Amnon82; 13th February 2005 at 14:55.
Amnon82 is offline   Reply With Quote
Old 13th February 2005, 16:02   #3  |  Link
Join Date: Jan 2002
Posts: 21,923
Suppose you have a number in 8 bits. It has 256 levels. You want to save some bits when sending the value. So you divide it by 2 and send that. It is only 7 bits now. Then when you receive that you multiply it back by 2. You've saved bits but you now only get the even values of the number.

That's just to give you an intuitive idea of what quantizing is for and the effect it has.
Guest is offline   Reply With Quote
Old 13th February 2005, 18:19   #4  |  Link
Registered User
Join Date: Jan 2005
Posts: 368
Thanks guys! I get how they work now

To try and confirm my understanding: This kind of lossy compression (mpeg & jpeg) deals with the picture in blocks, and these matrices can affect the lossy compression of the blocks - using how the eye percieves details.
I guess the options in Mencoder 'lumi_mask', 'dark_mask', 'tcplx_mask', 'scplx_mask' & 'p_mask' work in the this way, in which case I suppose it would be inadvisable to enable them and also use a Matrice?

But wavelet encoding which is becoming popular would not use these matrices because it doesn't use blocks but deals with whole frames at once.

From what I just read lower numbers give the most precision of detail, what's the range of numbers that can be used?
Is it pointless to put them all to '1' to try and get the best quality encode , I suppose that would be too easy! and it doesn't work in that way.

Here's a quick question which might help me solve my main issue with Mpeg - what would be a good matrice to help maintain subtle shades in very dark areas? At the moment I believe it always just makes it all the same black - so people in black suits look like black blobs and not very life-like. It's difficult to tell on the screen, but even so I don't think the details of shade are being retained. I don't suffer from getting blocks in very dark areas though, like some other people complain of as I've read, just it all looks the same black.
Thankyou!, I am grateful for any help
video_magic is offline   Reply With Quote
Old 14th February 2005, 00:26   #5  |  Link
HCenc author
Join Date: Nov 2003
Location: Netherlands
Posts: 570
Is it pointless to put them all to '1' to try and get the best quality encode , I suppose that would be too easy! and it doesn't work in that way.
Too easy indeed
Don't use values < 8 for intra and < 16 for non-intra and also don't use values > 255 (better not use values > 127, some encoders/decoders can't handle it)
There's no perfect matrix, every matrix used is a compromise.
The upper left part (lower frequencies) take care off the general picture, the lower right (high frequencies) take care of the detail.
So if you want to preserve all detail just use all 8 (intra) and 16 (non-intra) but the result will be bad, the lower frequencies will not have enough bits.
The used quantiser (Q-value) can be seen as a factor applied to the matrices.

Hope this helps, but if you really want to know more about it, just Google on DCT or FFT, you will get *alot* more information
hank315 is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 01:49.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.