PDA

View Full Version : Make Rec709 as the default matrix in Avisynth


varunb
30th December 2006, 14:13
Is it possible to do this ? Moreover, is rec709 the default matrix used in converttoyv12() ?

Wilbert
30th December 2006, 14:55
Is it possible to do this ?
Yes, but it isn't going to happen. There is no good reason to change the default behavior.

Moreover, is rec709 the default matrix used in converttoyv12() ?
No. I thought the docs were clear on this.

varunb
30th December 2006, 16:12
Yes, but it isn't going to happen. There is no good reason to change the default behavior.


No. I thought the docs were clear on this.

Can u be bit more detailed as to y I cant do this. The docs say that Converttoyv12(matrix="rec709")is possible but i have noticed that this is true only if ur input video has RGB colorspace. I just want to avoid any color losses while using converttoyv12(). Is it ok to use colormatrix(mode="rec.601->Rec.709") then while working on Apple HD trailers.

Wilbert
30th December 2006, 16:46
The docs say that Converttoyv12(matrix="rec709")is possible but i have noticed that this is true only if ur input video has RGB colorspace.
Can u be bit more detailed as to y I cant do this.
You were asking about the default matrix. ConvertToYV12() is the same as ConvertToYV12(matrix="rec601"). Sure it's possible to use Converttoyv12(matrix="rec709").

Note that those coefficients are used in RGB<->YUV conversions, so rec601/rec709 is only used when requesting a RGB<->YUV conversion.

Is it ok to use colormatrix(mode="rec.601->Rec.709") then while working on Apple HD trailers.
Depends. What does DGIndex/DGdecode tell you about the coefficients (ie info=1) of the source? What's your end format? What's your encoder?

varunb
30th December 2006, 18:10
Sorry I forgot to say that the source is a Quicktime movie (Apple HD trailers). Moreover the info() function didn't help me either in determining the actual colorspace of those mov videos. This is bcos when I changed the colorspace in FFdshow VFW to YV12 & frameserved the avs script to virtualdub, it says 'colorspace:YUY2'. Later on changing colospace to YUY2 & then frameserving to virtualdub, it says YV12. Although, i somewhat believe that the native colorspace of those HD trailers is YUY2, I still wish to confirm this. Just dont know how to.

foxyshadis
30th December 2006, 21:18
Native colorspace is YV12, as with all normal MPEG. If it was YV16 you probably wouldn't be able to decode it. However, switching back and forth between YUY2 and YV12 is a negligible loss in quality, compared to trips into the RGB space and back, so don't worry about the weird behavior too much.

Are you converting to DVD? In that case the opposite of the normal colormatrix is necessary. If you're converting to mpeg-4, ignore it.

Wilbert
30th December 2006, 22:35
@foxyshadis,

Are you sure that Quicktime stuff is Rec.601? I have no idea how to check it.

varunb
31st December 2006, 05:20
Ok foxyshadis, i believe u that its yv12.

Are you sure that Quicktime stuff is Rec.601? I have no idea how to check it.

Same question ? Who's gonna confirm this ?

foxyshadis
31st December 2006, 06:09
Actually, that's a good question; I guess comparing against a real DVD is the only way to test. Mmm, I'll test with Over the Hedge and report back whether the color matches.

varunb
31st December 2006, 06:49
Thanx foxyshadis. Waiting eagerly for your reply.

scharfis_brain
31st December 2006, 12:44
converttoyv12, converttoyuy2 and converttorgb are only able to change the colorimetry, when converting between rgb <-> yuv.

but with yv12 <-> yuy2 these routines won't change colorimetry at all.

varunb
31st December 2006, 13:39
Thanx for sharing your knowledge Scharfis but it wud still b gr8 to know which matrix is used in Apple Trailers: Rec.601 or Rec709 ?

scharfis_brain
31st December 2006, 14:28
I don't care about Quicktime stuff. So I don't know.

varunb
31st December 2006, 16:02
I don't care about Quicktime stuff. So I don't know.

If u didn't know then y did u post this in the 1st place !!!!!

Still waiting for someone's reply on my query posted earlier......

chipzoller
31st December 2006, 18:03
His first post (http://forum.doom9.org/showthread.php?p=923814#post923814) is not Apple-specific but rather refers to general colorspace conversion.

varunb
1st January 2007, 04:47
that i had already understood properly, chipzoller. u need not 2 hav reminded me about his 1st post. Anyways, where's foxyshadis ? He said that wud perform some tests on this. I hope he's got the solution.....

foxyshadis
1st January 2007, 09:40
Same frames on both have totally different luminances, I can't match them up at all. Sorry.

IanB
1st January 2007, 10:24
As with all YUV compressed formats, there is no colorimetry inherent in the image data bytes.

Colorimetry comes into play when converting the YUV data back to RGB data. To correctly convert the data back to RGB one needs to know what matrix was used originally when the compressed stream was created.

If you are lucky the stream container will contain the colorimetry information or there will be a hard specification for the format.

Typically when directly compressing a YUV data stream, like when feed YV12 or YUY2 data out of Avisynth, you need to do the correct thing in your script and when configuring your encoder.

varunb
1st January 2007, 11:46
Its alright, foxyshadis. Atleast u tried. So thanx a lot! Looks like I just have to use ConverttoYV12() as for now.

IanB
1st January 2007, 13:35
@varunb,

On rereading this thread, I feel there is some confusion about Avisynth pixel format, i.e RGB24, RGB32, YUY2 and YV12 and how it relates to colorimetry.

In the core Avisynth colorimetry, i.e Rec601, Rec709, PC.601 and PC.709, is only used in RGB <-> YUV conversions. For this Avisynth uses Rec601 as the default matrix. So existing scripts and application can always continue to function the same way this default will not be changed.

So if you decode a stream into Avisynth as YUY2/YV12, process and edit in YUY2/YV12 and output to another app as YUY2/YV12 there will be no colorimetry change.

There are 3rd party plugins, like ColorMatrix that can directly adjust the colorimetry of YUV data. This is similar to adjusting the saturation, brightness, contrast or hue.

varunb
2nd January 2007, 04:47
Well there's just one doubt in my mind. Its clear that there wont b any colorimetry change while frameserving quicktime H.264 videos using the ConverttoYV12() as foxyshadis quoted that the native colorspace of quicktime videos is YV12. The question is that if Apple H.264 uses a totally different colorimetry then which is the closest colorimetry that it resembles to ?

Mug Funky
2nd January 2007, 06:44
yes, from what i've found, apple uses completely non-standard colorimetry. closest i've found is default avisynth + some luma adjustment.

curse apple.

i could probably go more accurate than just "yes it's different", but i haven't the time. i checked it out long ago when replacing segments in an mpeg-2 encode with raw stuff capped in quicktime.

basically, quicktime appears to use a fixed matrix for converting yuv to rgb, and all it's codecs will convert to RGB by default.

an example i came up against:

digibeta -> uyvy mov -> RGB will be different from digibeta -> mpeg-2 (hardware encode) -> RGB.

however, using tateu's QTsource to grab the uyvy directly out of the mov file, the colours were identical to the mpeg-2 encode (which is good to know :)). likewise, using ffmpeg to transmux the mov to avi and then decode using ffdshow gave the same colours.

so my advice is to find something other than quicktime to decode the h.264 trailers, and do your comparisons from there. the colours will probably have gone through quicktime once already while encoding though, so who knows where the colours will end up?

short answer: quicktime sucks at colours and only gets them right when working in all-yuv or all-rgb.

Wilbert
2nd January 2007, 21:39
I guess that info should be in the mov specs somewhere, but i don't have it.