Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

Pages: (2) [1] 2  ( Go to first unread post )
Wide Color Gamut Compensation For Vd, Video Color Management ?
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
Jam One
Posted: Aug 19 2009, 09:23 PM


Advanced Member


Group: Members
Posts: 580
Member No.: 25518
Joined: 8-May 09



Happening to get 102% NTSC wide color gamut display made me think of "color management for video" in Virtual Dub.

For the pictures it's OK with ACDSee Pro, Firefox 3.5, CorelDraw etc. TV-tuner image also looks brilliant. But VD doesn't =)))

Videos can be played back with perfect sRGB color match by MediaPlayerC.-HC with use of custom pixel shader.
I made a pixel shader in accordance with instructions from over there: http://forums.overclockers.com.au/showthre...ad.php?t=723315


Virtual Dub can use D3D.fx files to get preview video processed by shaders.

My questions are:

1)
Is there an easy way to make d3d.fx file with the MPC-HC shader ?
(given I'm positively not a programmer|software developer=))
CODE


sampler s0 : register(s0);
float4 p0 : register(c0);

static float4x4 r2r =
{
0.65165101527372,0.339654590429908,0.00869439429637275,0,
0.0369531141567577,1.00093150831362,-0.0378846224703816,0,
0.010201491434332,0.0189330342932091,0.97086547427246,0,
0, 0, 0, 0
};

float4 main(float2 tex : TEXCOORD0) : COLOR
{
   float4 c0 = tex2D(s0, tex);
   c0 = pow(c0, 2.2);
   c0 = mul(r2r, c0);
   c0 = saturate(c0);
   c0 = pow(c0, 1/2.2);

   return c0;
}




2)
Would it be possible, at least in the future, to implement "Colorspace awareness" feature in VD that would read the default display icm color profile and adjust preview panes accordingly ?

This post has been edited by Jam One on Aug 22 2009, 04:34 PM
 
     Top
phaeron
Posted: Aug 20 2009, 04:34 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



MPC/MPC-HC shaders can be run unmodified on the CPU through VDShader 1.2:
http://www.virtualdub.org/downloads/vdshader-1.2.zip

This is a decently heavy shader. It's taking about 30% of one core on my 2.5GHz Core 2 at 640x360, 24 fps.

In order to run it as a display shader, it needs some modifications:

CODE

extern sampler s0 : register(s0);

static float4x4 r2r =
{
0.65165101527372,0.339654590429908,0.00869439429637275,0,
0.0369531141567577,1.00093150831362,-0.0378846224703816,0,
0.010201491434332,0.0189330342932091,0.97086547427246,0,
0, 0, 0, 0
};

float4 main(float2 tex : TEXCOORD0) : COLOR
{
  float4 c0 = tex2D(s0, tex);
  c0 = pow(c0, 2.2);
  c0 = mul(r2r, c0);
  c0 = saturate(c0);
  c0 = pow(c0, 1/2.2);

  return c0;
}

void VS(float4 pos : POSITION,
float2 uv : TEXCOORD0,
out float4 oPos : POSITION,
out float2 oT0 : TEXCOORD0)
{
oPos = pos;
oT0 = uv;
}

texture vd_srctexture;

technique {
pass {
 VertexShader = compile vs_2_0 VS();
 PixelShader = compile ps_2_0 main();
 CullMode = none;
 AlphaBlendEnable = false;
 Texture[0] = <vd_srctexture>;
 AddressU[0] = clamp;
 AddressV[0] = clamp;
 MinFilter[0] = linear;
 MagFilter[0] = linear;
}
}


There are a couple things I'm confused on, though.

First, what exactly are your source and target color spaces here?

Second, are you sure you want a straight 1/2.2 curve? sRGB/scRGB, as far as I know, use a 1/2.4 power curve with a linear section.
 
    Top
Dstruct
Posted: Aug 20 2009, 07:32 AM


Advanced Member


Group: Members
Posts: 257
Member No.: 24005
Joined: 8-August 08



Wouldn't it be much easier for the user to be able to select a monitor profile (*.icc) and let VirtualDub do the rest?
 
    Top
phaeron
Posted: Aug 21 2009, 04:46 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



VirtualDub ignores monitor profiles since it uses DirectDraw/Direct3D. Besides, I'm not sure how easy it is to configure a custom monitor profile.
 
    Top
Jam One
Posted: Aug 22 2009, 05:31 PM


Advanced Member


Group: Members
Posts: 580
Member No.: 25518
Joined: 8-May 09



First of all, thank you very much, phaeron, for your help, I am a lot grateful to you!
The shader works.
Pardon my delayed answering, I was checking everything several times.

Now it's clear that VirtualDub is in the not-so-big-yet company of high-grade professional programs capable of working on wide-gamut displays.

---

How did I do checking:

Synthetic "ColorBars" test video was generated with AviSynth, a frame of it exported in form of BMP.
Several photo images and frames exported from real videos were opened in ACDSeePro with color management set to treat untagged images as sRGB (default Windows profile and also the reference sRGB profile with blackpoint compensation, taken from here: http://www.color.org/profiles.xalter) ;
Amongst images were some of the photographic test pictures, like: http://www.imaging-resource.com/PRODS/DMCG...SLI0100_NR3.HTM
Images were also opened in CorelDraw (with its own color management engine)(for double-check purposes).
Videos and photos were also being opened in MediaPlayerClassic - Home Cinema and in Virtual Dub.

As a result of all the fun, there is no visible difference between the look of VirtualDub and CorelDraw/ACDSeePro (with black-point corrected sRGB profile). There is, allegedly, some microscopic difference with certain videos between looks of the latter applications and MPC-HC in mid-dark tones. At this very moment I tend to think that "maybe Virtual Dub knows better how to decode those videos" (also, I have little knowledge of how exactly VMR9 acts, so I can blame some deviations on its implementation).

---

About the spreadsheet:

"Your display xy" cells should be filled with x,y coordinates of the display's profile. Not with X,Y,Z.
Since my goal was to have emulation/color-proofing for sRGB monitors, I changed/overwrote BT-709 cells with coordinates of Windows-default sRGB IEC61966-2-1 profile. Coordinates are also x,y for RGB primaries and for the Whitepoint.
CODE

sRGB  IEC61966-2-1

     R                G              B            W
x    0.648451      0.321199      0.155887      0.312699
y    0.33085        0.59784       0.06604       0.329001

z-coordinates are being calculated by Excel.

Regarding white-point, experiments show the best solution is to use sRGB's whitepoint for both input and output colorspaces.
If we set our monitor's whitepoint as "output" we get what I believe is Absolute-Colorimetric Rendering Intent. Which I don't need. I'm sure. I don't need to look at yellowish images nobody will see - because not many users out there tune their monitors to 6500K. Total majority, I'm afraid, look everyday at 9300K or something like this.
(My monitor is set to 7000K to match the ambient lighting/viewing conditions.)

---

About the source and target colorspaces:

The target colorspace is the (custom) colorspace of the monitor. There're no standards for wide gamut displays, so... this colorspace can be defined either by the manufacturer's color profile supplied with driver, or by custom-profiling.
I calibrated&profiled my monitor with hardware colorimeter, so, coordinates of my colorspace came from the "objective reality" (I hope and pray).

The source colorspace in my case is sRGB. Why? Because all I need at the moment is to Emulate/colorproof videos I'm going to edit over here and other people are going to watch over there on their sRGB monitors. I need to know what they will see. That's, actually, it.
sRGB monitors are standard, well, at least to some extent, unlike the wide-gamut ones.
Maybe I will calculate shaders for other source-colorspaces later, but now I'm going to feel myself happy for some days or weeks about being able to emulate sRGB, to squeeze the image-data back into the sRGB gamut triangle.

(Yes, surely, of course, the monitor has got its own "sRGB emulation mode", but... but. But to switch it back-and-forth is not an ideal idea.)

---

About gamma curve:

Well, as far as I can understand, what we deal here with is not sRGB-gamma. According to the author of the method (http://www.avsforum.com/avs-vb/showthread.php?t=912720):
QUOTE
In the PC, the RGB data we have is all at the non-linear domain (called R'G'B'), and the conversion between primaries should be done at the linear domain (called RGB). So, for performing the color correction, we have to convert from R'G'B'->RGB, apply the conversion matrix and then convert back from RGB->R'G'B' - our displays need R'G'B'.

So, the gamma value to be used here is (have to be) the gamma of our display. Since (if) the display was calibrated/profiled to gamma=2.2 this value must be suitable for calculations.
In other words, our task at some step is to suppress the curvature of display's gamma to let the linear correction work correctly. This gamma hardly has something to do with sRGB or any other colorspace in the world except the one of our monitor. The author himself makes a mistake proposing the gamma of BT-709 to be used.
If you know this assumption is erroneous - I'm interested to know it too.

---

Thanks again!!!
 
     Top
Dstruct
Posted: Aug 22 2009, 05:46 PM


Advanced Member


Group: Members
Posts: 257
Member No.: 24005
Joined: 8-August 08



QUOTE (phaeron @ Aug 21 2009, 06:46 AM)
VirtualDub ignores monitor profiles since it uses DirectDraw/Direct3D. Besides, I'm not sure how easy it is to configure a custom monitor profile.

I had something like this in mind:

-> let the user specify a icc file (the one you get from calibration)
-> then with some pixel shader the colors should be adjusted by virtualdub to the screen (only to the screen!) according to the icc file


Not possible?
 
    Top
phaeron
Posted: Aug 22 2009, 09:43 PM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



QUOTE (Dstruct @ Aug 22 2009, 10:46 AM)
I had something like this in mind:

-> let the user specify a icc file (the one you get from calibration)
-> then with some pixel shader the colors should be adjusted by virtualdub to the screen (only to the screen!) according to the icc file

Afraid I don't have any experience with ICC profiles, although Windows GDI does have some functions for dealing with them that could be usable for generating lookup tables. I believe there is a complication in that you have to tell GDI how to do the gamut mapping as well as which profile to use, since there are different algorithms that attempt to preserve saturation, preserve hue, etc.

Color compensation is something I haven't gotten very far in. Probably the first thing I'd do is just add some more test patterns, since I've noticed my external monitor has slightly whacked levels (it's connected via analog).
 
    Top
Loadus
Posted: Oct 22 2009, 10:35 PM


Advanced Member


Group: Members
Posts: 352
Member No.: 10881
Joined: 1-July 04



Using the "max" gamut matrix (1.0 / 0) has the effect on colours that people
usually seek in linear editing. Phaeron is correct about the gamma, the original
CRT response was in the 2.4/2.5 realm. With the flat panels of today, it's getting
pretty flat also at the dark end (true linearized CRT monitor looks twice as dynamic
as LCD TVs of today - and I mean a CGI workstation CRT with 1.0 gamma, not 2.5)

I once asked about calculating the coefficients using a matrix from Phaeron, but
I lost interest in fiddling around with the code. tongue.gif I'll probably tweak this a bit
and post the CIE 1931 equivalent (that gives equal saturation to primaries and
secondaries).

--------------------
deviantART behance
 
       Top
Jam One
Posted: Oct 23 2009, 12:22 PM


Advanced Member


Group: Members
Posts: 580
Member No.: 25518
Joined: 8-May 09



QUOTE
With the flat panels of today, it's getting
pretty flat also at the dark end ...

- Do you mean non-gamma curve, like the one of sRGB, can describe it better than smooth gamma-curve ?
 
     Top
Loadus
Posted: Oct 23 2009, 01:23 PM


Advanced Member


Group: Members
Posts: 352
Member No.: 10881
Joined: 1-July 04



QUOTE (Jam One @ Oct 23 2009, 06:22 AM)
QUOTE
With the flat panels of today, it's getting
pretty flat also at the dark end ...

- Do you mean non-gamma curve, like the one of sRGB, can describe it better than smooth gamma-curve ?

Well, the blackpoint is so high on flatpanels, that the
black levels get washed away (I have Bravia myself, which
has one of the deepest blacks on the market and it still
loses a lot to my trusty CRT and my old TV monitor) : /

And I read on another post that you're only trying to get the
VirtualDub's output to reflect the actual 709 colors, I was
going for the workspace matrix - so my post might seem
a bit "off". lol, sorry about that.

Also, you _will_ need a TV monitor with a proper TV out
to view the colors when editing - Even proper Color
Management won't give you the exact hue errors and
gamma deviations and color gamma with approximated
matrix values. You need to measure the screens and
simulate with absolute/perceptual colorimetric to get close.

Which makes things a bit complicated. tongue.gif

Implementing Color Management to VirtualDub would probably
be semi-simple with existing libs, but it would slow things down
to a crawl.

--------------------
deviantART behance
 
       Top
Jam One
Posted: Oct 23 2009, 04:01 PM


Advanced Member


Group: Members
Posts: 580
Member No.: 25518
Joined: 8-May 09



Ah, thank you, Loadus!


...My intention was (it had been achieved, luckily) to get VirtualDub to emulate the sRGB color space on my Dell-2408...
(To see the picture the way it is supposed to look on sRGB monitors.)
I mostly edit videos to be viewed on PCs.
 
     Top
Loadus
Posted: Oct 24 2009, 03:28 PM


Advanced Member


Group: Members
Posts: 352
Member No.: 10881
Joined: 1-July 04



I tweaked and I tweaked and I think I got it at least semi-right:

http://www.loadusfx.net/virtualdub/CIE%201...20Saturation.fx

Saturation booster that does it equally to Red, Yellow, Green, Cyan, Blue and Magenta.

The code might look ackward, but then again, I'm not a coder, I'm just
a graphics designer. : /

EDIT:

Aaaand few seconds of tweaking reveal that the whitepoint is calculated WRONG.
Back to the ole drawing board. >:(

EDIT Part deux:
Alright, just uploaded the version with equal weights on primaries, should give you
neutral whites .. I hope.

--------------------
deviantART behance
 
       Top
Dstruct
Posted: Aug 24 2010, 09:29 AM


Advanced Member


Group: Members
Posts: 257
Member No.: 24005
Joined: 8-August 08



Bit offtopic, but Media Player Classic Homecinema 1.3.2305.0 now has full color management built in (when using EVR-CP or VMR9 renderer): http://www.xvidvideo.ru/media-player-class...-cinema-x86-x64
 
    Top
Dstruct
Posted: Oct 26 2010, 01:09 PM


Advanced Member


Group: Members
Posts: 257
Member No.: 24005
Joined: 8-August 08



In Media Player Classic Homecinema they use Little CMS: http://www.littlecms.com


Maybe this could be used in VirtualDub too?
 
    Top
phaeron
Posted: Oct 30 2010, 11:02 PM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



Odd. I always thought HC people were picky enough that they wouldn't be willing to sacrifice color precision to do color adjustment in the PC instead of on the display device.
 
    Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
21 replies since Aug 19 2009, 09:23 PM Track this topic | Email this topic | Print this topic
Pages: (2) [1] 2 
<< Back to VirtualDub Development Forum