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-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 30th October 2005, 00:47   #1  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Tool to test & edit AVC CQMs

Hi everyone,

I made an avisynth filter that allows to encode frames directly with x264. It takes custom matrices as input.

Here is the link : http://manao4.free.fr/AVCMatrices-1.0.zip

Here is the short documentation :
Code:
AVCMatrices(clip c, string "luma4x4" , string "chroma4x4" , string "luma8x8",
                    string "pluma4x4", string "pchroma4x4", string "pluma8x8",
                    int "quant", int "deblocking", bool "size", bool "psnr")

The 6 strings correspond to the custom matrices ( 3 intra first, then 3 inter ). If
omitted, a string is defaulted to an all-16 matrix. If no 8x8 matrices are given, 
8x8dct gets disabled in x264. If no inter matrices are given, only intra will be done.

The encoding is done at a constant quantizer ( default 26 ), with a ipratio of 1.4
if there's an inter matrix ( else, ipratio = 1.0, to make all I quantizers equal to the
chosen quantizer ).

Deblocking is disabled by default, specifying a value to "deblocking" will enable it
and set its strength.

Finally, "size" shows each frame size, while "psnr" show each frame psnr ( luma, chroma, both ).
Have fun ( and report bugs )
__________________

Last edited by Manao; 30th October 2005 at 08:19.
Manao is offline   Reply With Quote
Old 31st October 2005, 20:22   #2  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
*Bump*

Nobody seemed to have noticed that filter. Did anybody try it ? Did it work ?

Because it allows easy on the fly CQM comparison ( or other settings, such as deblocking ) :
Code:
source = mpeg2source("foo")

enc1 = source.avcmatrices(deblocking = -4)
enc2 = source.avcmatrices(deblocking = 0)

return interleave(enc1, enc2)
It allows to check the visual difference between two deblocking strength.

PSNR and filesize information are there to help you take into account the change in compressibility that different settings imply, and so on.
__________________
Manao is offline   Reply With Quote
Old 31st October 2005, 20:41   #3  |  Link
Sharktooth
Mr. Sandman
 
Sharktooth's Avatar
 
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
i'll try it in the weekend.
Sharktooth is offline   Reply With Quote
Old 1st November 2005, 00:31   #4  |  Link
Revgen
Registered User
 
Join Date: Sep 2004
Location: Near LA, California, USA
Posts: 1,545
@Manao

I'd like to use your filter but I have some questions.

1) Does the avcmatrices filter use the vfw version of x264 or the cli version? If it uses cli, should it be located in the directory of the cli executible?

2) In your instructions you say that the second string should be the "Intra Chroma 4X4". This is confusing because some matrices like Sharktooths EQM marix are separated into INTRA4X4_CHROMAU and INTRA4X4_CHROMAV. Should I just combine the two values together with INTRA4X4_CHROMAU entered first and INTRA4X4_CHROMAV entered second?

Here's Sharktooths CQM for a better example:

INTRA4X4_LUMA =
6, 9,13,19,
9,14,20,27,
13,20,28,35,
19,27,35,42

INTRA4X4_CHROMAU =
6,10,15,20,
10,16,21,27,
15,21,28,33,
20,27,33,42

INTRA4X4_CHROMAV =
6,10,15,20,
10,16,21,27,
15,21,28,33,
20,27,33,42

INTER4X4_LUMA =
8,11,15,20,
11,16,21,27,
15,21,28,35,
20,27,35,42

INTER4X4_CHROMAU =
8,11,16,21,
11,17,22,27,
16,22,28,35,
21,27,35,42

INTER4X4_CHROMAV =
8,11,16,21,
11,17,22,27,
16,22,28,35,
21,27,35,42

INTRA8X8_LUMA =
6, 7, 8,10,12,14,16,18,
7, 9,11,13,15,16,18,20,
8,11,14,16,17,19,21,22,
10,13,16,18,20,22,24,26,
12,15,17,20,23,25,28,30,
14,16,19,22,25,29,34,38,
16,18,21,24,28,34,46,52,
18,20,22,26,30,38,52,72

INTER8X8_LUMA =
8, 9,10,12,14,16,19,21,
9,11,13,15,17,19,21,23,
10,13,16,18,20,22,23,25,
12,15,18,21,23,24,26,32,
14,17,20,23,25,27,33,40,
16,19,22,24,27,34,41,52,
19,21,23,26,33,41,53,64,
21,23,25,32,40,52,64,80


Thanks.
Revgen is offline   Reply With Quote
Old 1st November 2005, 07:46   #5  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
The filter doesn't allow to use matrices stored in files at the moment ( you have to type the matrices in avisynth ). There's only one chroma matrix because, as you can see, both chroma matrices for U and V are always the same ( which is normal, since both chroma channels should be processed alike ).

The filter is a standalone ( it links statically with libx264.lib ) so you don't have to install x264.

I'll add the possibility to give cqm files in a few hours.
__________________
Manao is offline   Reply With Quote
Old 1st November 2005, 18:43   #6  |  Link
Revgen
Registered User
 
Join Date: Sep 2004
Location: Near LA, California, USA
Posts: 1,545
@manao

I tried comparing two different deblocking strengths as you illustrated above. It works fine.

However when I tried to compare Sharktooths EQM matrix to Flat 16 Vdub would crash on startup.

Here's my script

source=mpeg2source("E:\3s-Goofs and Saddles\goofs.d2v",idct=6)

enc1=source.avcmatrices(luma4x4="16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16",chroma4x4="16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16",luma8x8="16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16",pluma4x4="16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16",pchroma4x4="16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16",pluma8x8="16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16",quant=26,deblocking=0,size=true,psnr=true)
enc2=source.avcmatrices(luma4x4="6,9,13,19,9,14,20,27,13,20,28,35,19,27,35,42",chroma4x4="6,10,15,20,10,16,21,27,15,21,28,33,20,27,33,42",luma8x8="6,7,8,10,12,14,16,18,7,9,11,13,15,16,18,20,8,11,14,16,17,19,21,22,10,13,16,18,20,22,24,26,12,15,17,20,23,25,28,30,14,16,19,22,25,29,34,38,16,18,21,24,28,34,46,52,18,20,22,26,30,38,52,72",pluma4x4="8,11,15,20,11,16,21,27,15,21,28,35,20,27,35,42",pchroma4x4="8,11,16,21,11,17,22,27,16,22,28,35,21,27,35,22",pluma8x8="8,9,10,12,14,16,19,21,9,11,13,15,17,19,21,23,10,13,16,18,20,22,23,25,12,15,18,21,23,24,26,32,14,17,20,23,25,27,33,40,16,19,22,24,27,34,41,52,19,21,23,26,33,41,53,64,21,23,25,32,40,52,64,80",quant=26,deblocking=0,size=true,psnr=true)

return interleave(enc1,enc2)

Is there something I'm doing wrong?

EDIT

I guess I'l just wait for the new version.

Last edited by Revgen; 1st November 2005 at 18:45.
Revgen is offline   Reply With Quote
Old 1st November 2005, 18:57   #7  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Yes, there's something wrong, but it's my fault, I didn't document the filter properly : coefficients have to be separated by spaces, not comma.

Anyway, here's a new version, which can load CQM matrices : http://manao4.free.fr/AVCMatrices-1.1.zip

Oh, and to finish the undocumented 'features', if you want to do a test without CQM, but with PFrames, you'll have to give at least one flat P-matrix, else the filter will encode with only IFrames.
__________________
Manao is offline   Reply With Quote
Old 1st November 2005, 19:35   #8  |  Link
Revgen
Registered User
 
Join Date: Sep 2004
Location: Near LA, California, USA
Posts: 1,545
Just tried the newer version. It works fine.
I was able to compare Sharktooths with Flat 16 and see the differences.


Also, would it be difficult to include SSIM?
Although the PSNR is good to know, It would also be good to know the SSIM differences.

Thanks.
Revgen is offline   Reply With Quote
Old 1st November 2005, 19:53   #9  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Well, I added PSNR because there was nothing to code to add it ( x264 computes PSNR if asked ). SSIM would need me to code it. However, you can compute it with the SSIM.dll filter ( alas, that needs you not to output the size & psnr )

Anyway, if I output PSNR, it's only informative, to know whether things can be compared visually or not : if PSNR / size between two CQMs differ a lot, it means that the matrices don't scale in the same way. Hence, you have to change the quantizer in order size / PSNR to match as closely as possible. Else, comparing the matrices would be quite useless. That's the only reason to output PSNR.

SSIM could serve the same purpose, but wouldn't really bring more information than PSNR already brings : SSIM is as ill suited as PSNR to check CQM quality, and PSNR at least has the advantage of being easy to compute.
__________________
Manao is offline   Reply With Quote
Old 1st November 2005, 19:59   #10  |  Link
Revgen
Registered User
 
Join Date: Sep 2004
Location: Near LA, California, USA
Posts: 1,545
Okay thats fine. I'll just use the .dll instead.

Thanks again.
Revgen is offline   Reply With Quote
Old 5th November 2005, 09:49   #11  |  Link
DaWolfman
Registered User
 
Join Date: Aug 2005
Posts: 7
Well done, Manao. Just a few things-

1. Perhaps my Avisynth scripting skills are lousy, but is there a way to use am input file AND specify quantizer, deblocking, etc. without specifying the individual matrices?

2. Can you include the kb/s as well? I rarely use quantizer as a means of judging my output. It wouldn't matter if I specified it in the .avs file or if it was in the HUD, so long as I had an idea of what it was...

3. Does it support High profile?

Thanks for the kickass filter Manao! Keep up the good work!
DaWolfman is offline   Reply With Quote
Old 5th November 2005, 10:01   #12  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Quote:
1. Perhaps my Avisynth scripting skills are lousy, but is there a way to use am input file AND specify quantizer, deblocking, etc. without specifying the individual matrices?
Code:
result = source.AVCMatrices(file = "my_file.cqm", quant = 20, deblocking = 0)
That should work.
Quote:
Can you include the kb/s as well? I rarely use quantizer as a means of judging my output. It wouldn't matter if I specified it in the .avs file or if it was in the HUD, so long as I had an idea of what it was...
Yes, it can be done, wait a minute. But what HUD means ?
Quote:
Does it support High profile?
You're using cqm, so it does support high profile If you meant 8x8, it's enabled as soon as you give a cqm file or a 8x8 cqm matrix.
__________________
Manao is offline   Reply With Quote
Old 5th November 2005, 10:10   #13  |  Link
akupenguin
x264 developer
 
akupenguin's Avatar
 
Join Date: Sep 2004
Posts: 2,392
HUD = "heads up display". Called OSD in ffdshow.
akupenguin is offline   Reply With Quote
Old 5th November 2005, 13:29   #14  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
OK, here's the new version : http://manao4.free.fr/AVCMatrices-v1.2.zip

Changes :
Quote:
* added a "br" parameter ( in kbps ). If given, the encoding is done in ABR at this bitrate
* added an "intra" bool parameter to force intra encoding ( if not, given, P's are enabled )
* changed parameter names ( to make them shorter ) : quant -> q, deblocking -> dbk, and matrix names have changed ( look at the documentation )
* print local quantizer, and local bitrates ( one frame / one second / ten seconds ).
* fixed internal mistakes
Thanks for the definition of HUD
__________________

Last edited by Manao; 5th November 2005 at 13:35.
Manao is offline   Reply With Quote
Old 31st March 2008, 15:10   #15  |  Link
McCauley
Registered User
 
Join Date: Nov 2006
Posts: 83
Digging for gold

Hi Manao,

first i want to say thank you this PlugIn!

Is there a way to use a user defined x264.exe for testing the matrices?
If yes, how do i tell the PlugIn to use a custom .exe?
In regard of the AQ patched exes, that would be very useful to see how custom matrices behave with those.


Regards and thanks in advance
McCauley

Last edited by McCauley; 31st March 2008 at 15:20.
McCauley is offline   Reply With Quote
Old 31st March 2008, 18:41   #16  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
You can't use x264.exe, you need x264 library. So if you want an update of the core encoder, you need either to fetch the plugin's source code, x264's source code, and build it yourself (don't bother if you've never done any programming).

If there's a real need, I can update the plugin this week end, perhaps earlier.
__________________
Manao is offline   Reply With Quote
Old 31st March 2008, 21:59   #17  |  Link
McCauley
Registered User
 
Join Date: Nov 2006
Posts: 83
Quote:
Originally Posted by Manao View Post
If there's a real need, I can update the plugin this week end, perhaps earlier.
That would be really splendid! But you can take your time.

If i understood the documentation correctly i'm only able too specifiy the deblocking strength, could you add the threshold too, or would that be too much fiddling?

Regards
McCauley


PS: Thanks for your work on your Masktools too, they are really becoming the backbone of Avisynth filtering capabilities!
McCauley is offline   Reply With Quote
Old 1st April 2008, 02:30   #18  |  Link
Sharktooth
Mr. Sandman
 
Sharktooth's Avatar
 
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
Manao, if you do that, can you please add SSIM?
Recent x264 versions can calculate it too.
Sharktooth is offline   Reply With Quote
Old 1st April 2008, 20:38   #19  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
*bump*

http://manao4.free.fr/AVCMatrices-v1.3.7z

I updated x264 to the latest revision, and I allow setting aq (method & strength). SSIM is printed when psnr is asked for.
__________________
Manao is offline   Reply With Quote
Old 1st April 2008, 20:42   #20  |  Link
Sharktooth
Mr. Sandman
 
Sharktooth's Avatar
 
Join Date: Sep 2003
Location: Haddonfield, IL
Posts: 11,768
tnx
Sharktooth is offline   Reply With Quote
Reply

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 09:40.


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