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 > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 12th September 2004, 00:29   #1  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,293
ColorMatrix v2.3

ColorMatrix corrects the colors of mpeg2 streams of dvds. More correctly, those mpeg2 streams are encoded using a different set of coefficients as used by AviSynth's color conversion routines or by the XviD/DivX decoders, with the result that DivX/XviD clips or mpeg2 clips encoded by TMPGEnc/CCE using AviSynth or VirtualDub are displayed with slighty off colors (which looks like a small difference in brightness[*]). This can be checked by opening the mpeg2 stream directly in VDubMod. More info can be found in the readme.

This filter recalculates the yuv values assuming the coefficients which are used by AviSynth/VDub/DivX/XviD, with the consequence that your final encoding (mpeg2 or mpeg4) is displayed correctly.
[*] http://forum.doom9.org/showthread.ph...595#post514595

Changelog v2.3 (by tritical),
Code:
- Calculate conversion coefficients for PB/PR rows from luma coefficients
- Added inputFR and outputFR parameters allowing for YUV range expansion/contraction
- Changed the clamp parameter from bool to int to allow specifying only pre clipping or only post clipping or both
more info: http://forum.doom9.org/showthread.ph...227#post887227

http://web.missouri.edu/~kes25c/

Last edited by Wilbert; 17th August 2008 at 20:58.
Wilbert is offline   Reply With Quote
Old 12th September 2004, 01:31   #2  |  Link
malkion
Registered User
 
Join Date: Feb 2004
Posts: 156
Wilbert, if this filter does indeed perform as you intended it, I would like to express some gratitude for future encodes....

Now should I run limiter() before or after colormatrix() ?

Last edited by malkion; 12th September 2004 at 01:33.
malkion is offline   Reply With Quote
Old 12th September 2004, 11:46   #3  |  Link
Teegedeck
Moderator, Ex(viD)-Mascot
 
Teegedeck's Avatar
 
Join Date: Oct 2001
Posts: 2,564
I've waited for this a long time! If only I had time right now to try it out...

A heartfelt 'thank you'.
__________________
It's a man's life in Doom9's 52nd MPEG division.
"The cat sat on the mat."
ATM I'm thoroughly enjoying the Banshee - a fantastic music player/ripper for Linux. Give it a whirl!
Teegedeck is offline   Reply With Quote
Old 12th September 2004, 12:37   #4  |  Link
Boulder
Pig on the wing
 
Boulder's Avatar
 
Join Date: Mar 2002
Location: Hollola, Finland
Posts: 4,293
Thanks, this one will be very useful!
__________________
And if the band you're in starts playing different tunes
I'll see you on the dark side of the Moon...
Boulder is offline   Reply With Quote
Old 12th September 2004, 13:44   #5  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,293
Quote:
Now should I run limiter() before or after colormatrix() ?
If you get v1.1, you don't need to use limiter at all (not before or after the filter). The filter clamps input to [16,235] (and output also).
Wilbert is offline   Reply With Quote
Old 12th September 2004, 19:09   #6  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Made a few (easy) speedups - it should be a couple of times faster now.

Updated source.

- Use float instead of double. They have enough precision and are much faster. It can however be changed back by changing the typedef in ColorMatrix.h

- Simpler algorithms.

- Use internal limiter for output also, instead of very slow if-then.

- Better rounding (adding 0.5 for more exact float to int conversion)

No SSE/MMX this tim, though.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 12th September 2004, 20:07   #7  |  Link
jorel
Guest
 
Posts: n/a

thank you very much Wilbert !

i was "stuck inside a cloud" here trying to find a way for that problems!
now our encodes will get much, much more quality !

downloading and testing!
  Reply With Quote
Old 12th September 2004, 20:47   #8  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,293
@Sh0dan,

Thanks! I updated the version.
Wilbert is offline   Reply With Quote
Old 12th September 2004, 21:18   #9  |  Link
Inc
Squeeze it!
 
Inc's Avatar
 
Join Date: Oct 2003
Location: Germany
Posts: 472
Thanks a lot Wilbert !

Inc is offline   Reply With Quote
Old 12th September 2004, 22:05   #10  |  Link
jorel
Guest
 
Posts: n/a
Quote:
Originally posted by Wilbert
@Sh0dan,

Thanks! I updated the version.
of course....

thank you too Sh0dan.

.seems that we posted at the same time and i saw your post after my last!

  Reply With Quote
Old 13th September 2004, 02:44   #11  |  Link
Dark-Cracker
Registered User
 
Dark-Cracker's Avatar
 
Join Date: Feb 2002
Posts: 1,195
very nice work
just by curiosity does it will harm the final output if u apply this filter on HDTV source or on some raw avi input ?

++
__________________

AutoDub v1.8 : Divx3/4/5 & Xvid Video codec and .OGG/.MP3/.AC3/.WMA audio codec.
AutoRV10 v1.0 : Use RealVideo 10 Codec and support 2 Audio Streams and Subtitles.

Dark-Cracker is offline   Reply With Quote
Old 13th September 2004, 20:24   #12  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,293
Quote:
just by curiosity does it will harm the final output if u apply this filter on HDTV source
I got a few hdtv sources. Marjority of them uses mpeg2 coefficients (checked with the newest GSpot). So, you should also use the filter on those sources.

However, a few of them uses mpeg1 coefficients. You shouldn't apply the filter on those.

Quote:
on some raw avi input
Here, you shouldn't use this filter. DivX/XviD assume mpeg1 coefficients when decoding to RGB.

edit: btw, hdtv is YUV [0,255] of course. So you need to use ColorYUV("PC->TV") first.

Last edited by Wilbert; 14th September 2004 at 09:17.
Wilbert is offline   Reply With Quote
Old 3rd October 2004, 12:10   #13  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
I have a question about colormatrix and speed. I use colormatrix() 1.2 and get the following results

with colormatrix : 16.5 fps
without colormatrix : 44.5 fps

should such a difference be expected or is there any problem ?

My script (source is 720x576) :

LoadPlugin("D:\video\avsfilters\yv12\DGDecode.dll")
LoadPlugin("D:\video\avsfilters\yv12\colormatrix.dll")

mpeg2source("d:\test\test.d2v",idct=6)

trim(30000,33000)
colormatrix()

FuPP
FuPP is offline   Reply With Quote
Old 3rd October 2004, 23:08   #14  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,293
The problem is that the filter is not optimized. Since I'm not a good coder, I don't know how to do that. I hope someone has some time to do that
Wilbert is offline   Reply With Quote
Old 4th October 2004, 21:02   #15  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
I added other easy optimisations ( no more float computations, only integer one ). Results *should* be the same as those given by sh0dan's version. It should be almost twice as fast.

http://jourdan.madism.org/~manao/ColorMatrix.zip
Manao is offline   Reply With Quote
Old 4th October 2004, 21:25   #16  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,293
Thanks! Could you also add the correct source files?
Wilbert is offline   Reply With Quote
Old 4th October 2004, 21:33   #17  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
I copy'n'pasted the wrong files

You can download it again.
Manao is offline   Reply With Quote
Old 4th October 2004, 23:47   #18  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,293
Thanks, I added it to the first post! I didn't have time to test it though
Wilbert is offline   Reply With Quote
Old 5th October 2004, 01:51   #19  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
with colormatrix : 34.5 fps
without colormatrix : 44.5 fps

Far better ! Thanks a lot Manao ! And thanks a lot Wilbert for that filter

FuPP
FuPP is offline   Reply With Quote
Old 8th October 2004, 17:51   #20  |  Link
ltc
Registered User
 
Join Date: Jul 2004
Posts: 6
How to properly use this filter?
Say if I want to re-encode a DVD to DVD-R for TV playing. I assume I should use YUV and TV scale in DVD2AVI. I can find the original matrix coefficient with GSpot which has following type:

I709 = type 1 = MPEG2 default
FCC = type 4 = FCC standard
I470 = type 5 = MPEG1 default
S170 = type 6 = SMPTE 1700M standard
S240 = type 7 = SMPTE 240M standard

I have some DVDs which has S170 coefficient. Should I use ColorMatrix before converting to ConvertToYUY2 for CCE and ConvertToRGB24 for TMPGE?

Some of my encodes are brighter than original. Could it be because I accidentally used RGB PC scale?

Last edited by ltc; 8th October 2004 at 17:53.
ltc is offline   Reply With Quote
Reply

Tags
colormatrix

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 18:10.


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