Log in

View Full Version : different custom quant matrices


spase
3rd December 2004, 06:17
first off, i didnt know where to post this, so i posted it here. sorry if it is in the wrong forum so to speak.

ok i have been playing with different custom quantiser matrices over the past week or so, and i am wondering what each of them is for really.

i know some are for lower bitrates, and some for higher bitrates, and some for CG/anime, but some don't have names that are obvious what they are to be used for.

so far i have come across...

bach1 (or is it bach01?)
Jawor's 1CD
evil .1 (which incidentally won.t work... i think because it has values above 127?)
HVS Good
HVS Better
HVS Best
QLB (obviously lower bitrate... quenc lower bitrate)
KVCD notch


i am pretty much a newb in this area (video encoding in general) so can someone be kind enough to let me know what each matrix was designed for, and when it should be used (what bitrates, resolutions, video types...dark...light...animation...etc.)

i'm sure there are others i have missed. anyone else care to list them? (and what they are used for?)

also, i know most of the matrices (all of them as far as i know... except for qlb?) were created for use with XviD. does this make them less useful for use with QuEnc (or mpeg-2 encoders in general)? or does it kind of change the expected outcome of using the matrices?

lastly, is there some website (or more likely a post on this forum) that already all of this info? i'll admit i didn't look terribly hard or far :eek:

Teegedeck
3rd December 2004, 10:29
Matrices might not at all yield similar results with MPEG-2 as with MPEG-4, as I've come to notice. Also matrices might not at all be destined to be used exclusively in a narrow compressiblity range (like "this matrix for compressing to 30% of the original filesize; the other one for 50%") but their usability can stretch over quite some sector, from high to mid-bitrates/compressibilies for example.

I'm a bit in the dark for most of the matrices you've listed - because I've only used them with XviD. For MPEG-2 I've only tried CCE's and QuEnc's standard matrices and QuEnc with SixOfNine, Fox Home Entertainment and QLB.

An exception are matrices which really, really quantize high frequencies away without mercy, even at lowest quantizers. Among those are Javor's 1CD-matrix and Sharktooth's ULR-matrix. I wouldn't use those for anything but MPEG-4 streaming.

QLB looked very good for high quality encodings with QuEnc to my surprise (though this must be taken with a grain of salt, there is reason to believe that Trellis might have had a negative influence on the other matrices I tested) and is very efficient. The Fox Home Entertainment matrix seems a way to go for relentlessly high-bitrate encodings, but I think you'd better use only 1 audio-track if you go for that one.

Peter Cheat
3rd December 2004, 11:55
You can expect similar improvements (results) when using the matrices that are commonly used for XviD, such as the HVS matrices. The HVS Best matrix produces excellent results at higher bitrates, retaining far more (noticable) detail then the default matrix. Don't worry about the fact that some matrices were designed for use with MPEG-4, the quantisation process is similar between MPEG-2 and MPEG-4 (in fact a lot is the same, most of the improvements in MPEG-4 are motion compensation related), and so different matrices have similar results regardless of codec.

Teegedeck
3rd December 2004, 11:58
Strangely, SixOfNine matrix doesn't act like what I'm used to from XviD (and like one would expect from a high-bitrate matrix) at all with QuEnc 0.56 - Trellis enabled.

Peter Cheat
3rd December 2004, 12:36
There is a "bug" in trellis, the same bug that plagued XviD at one stage. Some matrices can cause a mathematical overflow when using trellis dct.

sysKin told me how to fix it too, I just haven't got around to doing it yet. You should try it without trellis.

dragongodz
3rd December 2004, 12:44
QLB looked very good for high quality encodings with QuEnc
first you raise me up
to my surprise (though this must be taken with a grain of salt, there is reason to believe that Trellis might have had a negative influence on the other matrices I tested)
and knock me back down. :D

There is a "bug" in trellis, the same bug that plagued XviD at one stage. Some matrices can cause a mathematical overflow when using trellis dct.

sysKin told me how to fix it too, I just haven't got around to doing it yet.
there is still a bug with xvids trellis(well use of) aswell.
http://forum.doom9.org/showthread.php?s=&threadid=84999
i mentioned to sysKin the avcodec bug and my finding about dct coefficients with mpeg2's and how i had told you and you were looking at it. :)

Peter Cheat
3rd December 2004, 12:58
I used that MPEGAnalyser tool you sent me (very useful) and noticed that if a DCT was corrupted, it was always the second coefficient on the top row that was fubar. In the case of the KVCD notch matrix, instead of ending up with a large negative, you get a large positive. Trellis should only alter DCT coefficients by a bit up or down. I tested by encoding with and without trellis and comparing DCT coefficients of corrupted DCT blocks, and non-corrupted DCT blocks.

Teegedeck
3rd December 2004, 13:03
Hehe, I would have hardcoded min-quant=2 in XviD and no-one would ever have known of this bug... I wonder whether anyone still remembers Christoph's idea of letting XviD choose a 2nd-pass resolution depending on 1st-pass results. That would be better than simply burning bits IMHO, though connected with a whole new set of problems. :o

And the QLB matrix is great, I cannot recommend it highly enough! OK, I hope that clears up all ambiguities. ;)

dragongodz
3rd December 2004, 13:07
ye i was trying to find out from sysKin if any such tool to display the dct details for xvid was available aswell. that way i could see if it was the same happening. unfortunatly there is no such tool.

And the QLB matrix is great, [i]I cannot recommend it highly enough![i] So, I hope that clears up all ambiguities.
haha thanks mate.

Peter Cheat
4th December 2004, 09:59
I fixed trellis by doubling the precision. Its an easy fix, just change:


#define QMAT_SHIFT 22


to


#define QMAT_SHIFT 20


skal pointed to a solution for trellis bug in XviD:

Note2: there's a #define TL_SHIFT in mbtransquant.c
in XviD's sources that controls the dynamic range
of calcs. Try reducing it...


Just my luck that this fix applies to ffmpeg also.
This fix has been submitted to CVS, hopefully will be committed :D.

Back on topic:
QLB matrix is a very good matrix, produces much less ringing than KVCD matrix, and is even good for anime. Not many matrices are so generic.

dragongodz
4th December 2004, 10:28
skal pointed to a solution for trellis bug in XviD:
bugger. i had only followed the first page and a bit so missed his post. cool that its fixed though. :)

QLB matrix is a very good matrix, produces much less ringing than KVCD matrix, and is even good for anime. Not many matrices are so generic.
at this rate my head wont be able to fit through a door. :D
good to know people are finding it a good allrounder which doesnt do too much harm, that was my aim for it.

Didée
9th December 2004, 16:15
Perhaps someone could post the QLB matrix? It sounds interesting ... I'm nosy how the tables actually look like ;)

dragongodz
9th December 2004, 16:56
Perhaps someone could post the QLB matrix? It sounds interesting ... I'm nosy how the tables actually look like
QLB matrix -
INTRA
8 16 19 22 26 27 29 34
16 16 22 24 27 29 34 37
19 22 26 27 29 34 37 39
22 22 26 27 29 34 38 42
22 26 27 29 32 36 40 50
26 27 29 32 36 40 50 61
26 27 29 35 40 50 59 73
27 29 35 40 50 59 73 87

NON-INTRA
16 17 18 19 20 21 22 23
17 18 19 20 21 22 23 25
18 19 20 21 22 23 24 26
19 20 21 22 23 24 26 28
20 21 22 23 25 26 28 29
21 22 23 24 26 28 29 31
22 23 24 26 28 29 31 32
23 24 25 28 29 31 32 34

please remember this is just meant to be a general purpose lower bitrate matrix. so Didée please be gentle with me. :D

Didée
9th December 2004, 17:19
Originally posted by dragongodz
so Didée please be gentle with me. :D
No, no mercy. Take your pants off, be ready to get spanked :D

I'll try it out next time mpeg-2 encoding made its way to the top of the to-do list.

Thanks for posting it :)

dragongodz
9th December 2004, 17:23
No, no mercy. Take your pants off, be ready to get spanked :D
:eek: :D

I'll try it out next time mpeg-2 encoding made its way to the top of the to-do list.
cool. it would be nice to know your impressions when you do.

ronnylov
13th December 2004, 16:46
I use the matrices listed here (for CCE and TMPGEnc, sorry that the text is German but the numbers might be useful anyway):
http://www.dvd-svcd-forum.de/forum/viewtopic.php?t=7499

DarkFoon
7th January 2005, 09:03
I am working on this (pain in the ass) DV source video that will eventually be put onto DVD and sold.
I tried my first encode to MPEG2 in Quenc (latest version. I think 59a) with the QLB matrix. This is the first situation that I have been disappointed with QLB, but it has been wonderful for everything else, from TV Capture to Anime; the faces had lost some important detail in this encode, which is unacceptable.
Anyways, back to my purpose, I would like a few pointers from people on which matrix I should use, and these are my requirements:
~60 minute video to fit onto 1 4GB DVD with 1 audio track ~512 Kbps AC3.
The paramount here is that the video stays sharp and retains much detail, while still being able to fit onto the DVD, and staying within the DVD standard.
If things were different, I would just do a whole bunch of testing and find it out myself, but I have time contraints, limited harddrive space, and my computer is too slow to do a bunch of encoding.
So, I appeal to the masses of professionals(?) of the Doom9 community to lend me their knowledge! ;)

dragongodz
7th January 2005, 13:30
if you are only trying to get 60 minutes on to 4gb then you will be using a reasonably high bitrate so no need to use a custom matrix really at all. QLB is specifically for lower bitrates so reduces a little bit of very fine detail which you would normally never notice.

it would be interesting to know more about the footage aswell as i havent seen anything that i could tell the detail reduction from unless looking at single frames. even then i had to really look for it. :)

also you mentioned using QLB with a different encoder in the QuEnc thread, which encoder may i ask ?

P.S. [OT] the avatar is Elfin Lied yes ?

DarkFoon
8th January 2005, 06:44
So I dont need a custom matrix? hmm... I don't really like the default MPEG matrix; I consider many of the custom matrices to be better visual quality... Indeed, high bitrate it will be, in that case, should I just use a solid 8/16 matrix?

I think the blurring I saw on my footage was just a result of my computers MPEG decoder, which (bob?) deinterlaces automatically on playback.

The other encoder is TMPEGenc. I like Quenc, but I like TMpeg's adherance to the max bitrate, and since it is a commercial encoder, it is more likely to output a file that is compatable with more DVD players. Or maybe I'm wrong, and its not the encoder that determines compatability, but the parameters set by the user?

[OT]? never seen that before.
No, I believe my ava is from fate/stay night. I don't know anything about it, but I like the picture, see the whole thing on my site http://www.cassumnox.tk

P.S.
I have been curious about your ava for some time? who is it and from where? Looks kinda DB_ish.

DarkFoon
8th January 2005, 08:10
I just remembered that I have DCTune. Is there a guide on how to take the QMs it produces and making them usable in CQME or MPEG? It looks like the three it produces are for each color.

dragongodz
8th January 2005, 11:45
So I dont need a custom matrix? hmm... I don't really like the default MPEG matrix
the "default" matrix in Tmpgenc should be fine for high birate encoding. however there are some other high quality/high bitrate matrices in the xvid section you could try but you will have to search for them. amd i cant say how well they will work with mpeg1/2 encoding since they were designed for mpeg4 ASP(such as xvid). :)

I think the blurring I saw on my footage was just a result of my computers MPEG decoder, which (bob?) deinterlaces automatically on playback.
thats possible. i have seen different decoders give different quality playback aswell.

Or maybe I'm wrong, and its not the encoder that determines compatability, but the parameters set by the user?
yes the settings used play a major part. QuEncs rate control doesnt stick to the max bitrate at the moment though so yes it can go out of spec for things like dvd limits. so in reality its both the encoder and what settings a user sets.

I just remembered that I have DCTune. Is there a guide on how to take the QMs it produces and making them usable in CQME or MPEG?
i remember dctune being talked about in the xvid section quite some time ago. so you may want to do a search there.

[OT]? never seen that before.
it means Off Topic, you will find it used here and there. and thats where i am going now, OT. :)

I believe my ava is from fate/stay night. I don't know anything about it
ahh its from a game. some info about it here
http://www.typemoon.com/fate/index.html
if you ever see Elfen Lied you will understand why i thought it may have been from that.
http://www.anime-source.com/banzai/modules.php?name=Reviews&rop=showcontent&id=891

I have been curious about your ava for some time? who is it and from where?
the character is Kazuma from the series Scryed.
http://www.anime-source.com/banzai/modules.php?name=Reviews&rop=showcontent&id=291

DarkFoon
8th January 2005, 21:38
Thanks for your feedback. I never really liked the "default" matrix in TMpeg, I always thought that it left DCT blocks, and sometimes, if the bitrate gets a little low at all, it blocks really badly.
Funny thing is, right after I posted about DCTune, I searched the forum, and I found this automated script for making QMs, the people there said it sucked, but they were using settings that were way too high for DCTune. To keep from getting solid 255s you need to use numbers that are 0<x<1 like 0.33, produced a high bitrate, but nice looking (untested ATM) intra matrix, and the inter matrix looks swell too. I think I'll test it soon.
Anyways, thanks again. I've always been amazed at the patience and kindness of the "big names" (you are one of them) in the forum here.
[OT] thanks for the links too, they were informative... too bad I cant read japanese T_T

Back on topic, here is the matrix DCTune averaged out of 103 frames from my source:

8 8 8 8 8 8 8 8
8 8 8 8 8 8 8 8
8 8 8 8 8 8 8 8
8 8 8 8 8 8 8 8
8 8 8 8 16 16 16 16
8 8 8 8 16 16 16 24
8 8 8 8 16 24 24 24
8 8 8 8 16 24 24 32

16 16 16 16 16 16 16 24
16 16 16 16 16 16 16 24
16 16 16 16 16 16 24 24
16 16 16 24 24 24 24 32
16 16 16 24 24 48 56 40
16 16 16 24 48 80 104 104
24 16 24 32 80 96 160 255
32 24 32 40 72 104 136 255


Hmmz, maybe it would be better for Xvid... I'll need to test it.
Thanks again!!

ronnylov
10th January 2005, 16:55
Originally posted by DarkFoon
I am working on this (pain in the ass) DV source video that will eventually be put onto DVD and sold.
I tried my first encode to MPEG2 in Quenc (latest version. I think 59a) with the QLB matrix. This is the first situation that I have been disappointed with QLB, but it has been wonderful for everything else, from TV Capture to Anime; the faces had lost some important detail in this encode, which is unacceptable.
Anyways, back to my purpose, I would like a few pointers from people on which matrix I should use, and these are my requirements:
~60 minute video to fit onto 1 4GB DVD with 1 audio track ~512 Kbps AC3.
The paramount here is that the video stays sharp and retains much detail, while still being able to fit onto the DVD, and staying within the DVD standard.
If things were different, I would just do a whole bunch of testing and find it out myself, but I have time contraints, limited harddrive space, and my computer is too slow to do a bunch of encoding.
So, I appeal to the masses of professionals(?) of the Doom9 community to lend me their knowledge! ;)

Did you try this one from the link I posted earlier in this thread? It is intended for interlaced DV source encoded at high bitrate (like 60 minutes of video on DVD). Encode as interlaced (do not deinterlace). I think most other matrices are optimized for progressive video like film sources or deinterlaced video. This matrix was made by mb1 and I use it sometimes with good results.

'mb1 interlaced DV'
8,13,13,17,17,21,21,28,
13,13,17,17,19,21,23,30,
13,17,19,19,21,23,28,34,
13,17,19,19,21,23,28,48,
17,19,19,19,23,28,34,48,
19,19,23,25,28,32,34,48,
19,21,23,25,28,32,34,48,
21,21,25,25,28,32,34,48

8,11,11,15,15,17,17,24,
11,11,15,15,17,17,21,24,
13,15,15,17,21,21,26,34,
13,17,15,17,21,21,26,48,
17,21,21,23,21,30,34,48,
17,21,21,23,28,30,34,48,
19,19,25,26,28,30,48,48,
19,19,25,26,28,30,48,48

movmasty
11th January 2005, 21:14
Originally posted by Peter Cheat
I used that MPEGAnalyser tool you sent me (very useful) and noticed that if a DCT was corrupted, it was always the second coefficient on the top row that was fubar. In the case of the KVCD notch matrix, instead of ending up with a large negative, you get a large positive. Trellis should only alter DCT coefficients by a bit up or down. I tested by encoding with and without trellis and comparing DCT coefficients of corrupted DCT blocks, and non-corrupted DCT blocks.
which tool please?

i need to find out which matrix is used in a video to encode another video with same and paste...

ronnylov
12th January 2005, 13:39
I don't know what tool Peter Cheat is talking about, but you can extract the used matrices from a mpeg2 video stream with the freeware tool ReStream, which can be found here: http://shh.sysh.de

jjseth
13th January 2005, 12:16
What's about PVCD and UPVCD matrix?

PVCD.tk (http://usuarios.lycos.es/pvcd/templates.htm)