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. |
14th July 2008, 02:23 | #21 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
well even BD's are 8bit, there's nothing further on the market at this point AFAIK..
oh really 14bit ? I had no idea well I've run some tests this evening, and EVR/VMR9 still can't compete with HR's smoothness... maybe I'm willing to give up some smoothness to get perfect colors lucky you, your projector has a Xenon lamp so you get massive reds, due to my UHP lamp mine are orangey now |
14th July 2008, 10:53 | #22 | Link |
Registered User
Join Date: Dec 2003
Location: MO, US
Posts: 999
|
Whether avisynth is the right place or not, I created a filter to do the conversions. ddcc v1.2. It takes in rgb24 or rgb32, and does the following conversion:
gamma corrected RGB -> linear RGB -> CIE XYZ -> CIE XYZ -> linear RGB -> gamma corrected RGB Chromaticity coordinates and transfer functions of the source and output are fully adjustable... some presets are built in. If white points of chromaticity coordinates differ, then a chromatic adaptation is done using Bradford matrix. More details are in the readme. I tested some, but not enough to really be sure it is correct (I simply implemented the conversions as I understand them). For this to run real time on HD video you're gonna need a processor with SSE3 support (I didn't write SSE or SSE2 routines, so its either SSE3 or the C routine), and probably more than 1 core (using only 1 core on my 2.8Ghz Q6600 doesn't quite make it). Hopefully someone can comment on whether the results are anywhere near correct . Last edited by tritical; 16th July 2008 at 14:30. |
14th July 2008, 11:06 | #23 | Link |
Registered User
Join Date: Sep 2004
Posts: 1,295
|
tritical,
I will take a look and update my AVSForum thread if it's working. It's nice to have other options. Have you think about doing it using the GPU instead of the CPU? Since this is a highly parallelizable task the GPU could speed it up a lot!... The mplayerc Pixel Shader version works great without any cpu overhead... Thanks for your work! Last edited by yesgrey; 14th July 2008 at 11:24. |
14th July 2008, 11:49 | #24 | Link | |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
cool thanks tritical, gonna give it a shot!
wow 32float, hope this will work in realtime I've spoken to a friend of mine who's a PS script coder, and he said PS scripts also work in 32bit float : http://msdn.microsoft.com/en-us/libr...46(VS.85).aspx EDIT : ooh, your plugin is highly technical stuff all I wanna do is map SMPTE-C to my DLP projector gamut, which is Quote:
well I can check very easily if the conversion is done properly, by doing a Color.HCFR calibration using the official test patterns DVD in MPC I could even compare the MPC PS script and your plugin. I'm gonna try to see if it works in realtime, but some little help on the syntax would be much appreciated Last edited by pitch.fr; 14th July 2008 at 16:02. |
|
14th July 2008, 12:54 | #25 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
well it's actually very usable in realtime with HR
man, 32bit gamut correction with HR and Reclock, this is too awesome at this point I'm decoding h264 w/ ffdshow, then it enters the AVS filter in YV12, for 1) LSF 2) multithreaded ConvertToRGB32 conversion and 3) your colorimetry plugin. Last edited by pitch.fr; 14th July 2008 at 19:17. |
14th July 2008, 19:40 | #26 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
oh btw yesgrey3, tritical is using 6 digits after the coma for the xyz coeffs, may wanna update your script ?
for BT470-2 you have more digits after the coma than he does.......but you simply call it "NTSC" so I dunno if it's the same exact matrix. and for "Offset" which is set to 24 in the XLS script, what's a good value ? what does it stand for ? Last edited by pitch.fr; 14th July 2008 at 19:54. |
14th July 2008, 21:53 | #27 | Link |
Registered User
Join Date: Dec 2003
Location: MO, US
Posts: 999
|
@yesgrey3
I'll look into it. Unfortunately, I don't have any experience using pixel shaders... so it may be unlikely. @pitch.fr Not sure if you figured this out already, but to map to a custom set of chromaticity coordinates you'll have to use the ofile parameter: ddcc(ofile="file.txt") file.txt would contain your values as follows: 0.151 0.068 0.781 0.339 0.611 0.050 0.656 0.329 0.015 0.311 0.328 0.361 You also need to specify the 5 values for the transfer function. You can just take one of the sets of values out of the readme, or to match the transfer function of the pixel shader code use the following five values: 1.0 0.0 0.45 0.0 0.0 I set the defaults of the filter to assume SMPTE-C input primaries and BT.709 input transfer function... so you'll probably also need to change the input transfer function depending on what values you use for the output transfer function. Also, I put up v1.1... it fixes one small bug, and adds one new built in transfer function (gam_i/gam_o = 5) which matches the transfer function of the pixel shader code. |
14th July 2008, 22:18 | #28 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
great, thanks!
actually I've spent quite some time trying to find a way to run this thing in realtime in ffdshow I've had to cut quite a lot of my audio enhancements in ffdshow audio(96KHz resample and stuff), because it sucks a lot more CPU to use your script + RGB32 conversion in the AVS filter, than to let ffdshow do the RGB32HQ conversion + using the PS script to fix the gamut what do you think is a good/best transfer function to choose ? any theoritical improvement over the way the PS script works ? and what do you guys think of that SAMSUNG pj that can auto-detect whether the YCbPr input is receiving BT.601 or BT.709 ?! they've got to use some sort of auto-detection algorithm I guess ? or maybe they actually found a way to do that ? AFAIK this is not possible there is already a PS script parser for AVS : http://www.google.com/search?hl=en&q...tnG=Search&lr= maybe there is room for improvement ? only the GPU works on these scripts, that's a good thing because I've always heard ppl saying that CPU's were pretty lousy DSP's Last edited by pitch.fr; 14th July 2008 at 22:21. |
15th July 2008, 02:54 | #30 | Link |
Registered User
Join Date: Dec 2003
Location: MO, US
Posts: 999
|
@yesgrey3
A CUDA implementation would be easy to do, but I was thinking that it would be pretty limiting (in terms of supported video cards) compared to a pixel shader. @pitch.fr The best choice of transfer functions would be the one corresponding to what was originally used to produce the gamma corrected RGB, and the one corresponding to the transfer function of your display. Of course, finding those out may be impossible. The one in the pixel shader code is just a generic one with ~2.222 display gamma and no linear segment... it's a reasonable choice if the true one is not known. I have no idea how autodetection of BT.601 vs BT.709 would work. |
15th July 2008, 03:18 | #31 | Link | |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
yeah, I prefer the PQ of ATi cards........please no nvidia proprietary stuff
so what do u think of the PS AVS plugin, maybe a good starting point ? I'm not sure I understand what you call the "Transfer Function", but it's 4AM here you mean that it's a wild guess at what the gamma curve was before they encoded their RGB master to YV12 ? I know what the gamma curve looks like on my DLP pj, it start at 2.3 and ends at 2.1 BUT the professional broadcasting equipment runs 2.5 gamma, that's the rule.......only consumer equipment is 2.22 do you know what I should change in the PS script generator to reflect this please ? there's also many ways to compute gamma, and there's 2 formulas being used the most. I've spoken about that with the HCFR color engineers, the most widely used formula seems to be this one : Quote:
Last edited by pitch.fr; 15th July 2008 at 03:34. |
|
15th July 2008, 20:27 | #32 | Link |
Registered User
Join Date: Dec 2003
Location: MO, US
Posts: 999
|
When I say 'transfer function' I just mean the function which maps linear RGB to gamma corrected RGB. The inverse of the transfer function maps gamma corrected RGB to linear RGB. In ddcc they are implemented as:
Code:
x = lv*C if C < thresh1 (1.0+av)*pow(C,pv)-av otherwise x = C/lv if C < thresh2 pow((C+av)/(1.0+av),1.0/pv) otherwise Last edited by tritical; 15th July 2008 at 20:31. |
15th July 2008, 22:55 | #33 | Link | |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
humm OK, I will read that slowly again I'm not quite a coder
BTW, what happens to off-gamut colors ? white is my DLP pj, black is SMPTE-C : what happens to the green colors that my pj can't output ? they're clipped ? so they don't appear(banding?), or it still shows yellow instead like it does w/o correction ? and are you sure this can't be done through the CLUT ?! ARGYLLCMS has pretty advanced CLUT capabilities, and it's GPL software. considering you know the formula part, why would that be impossible to generate CLUT entries ? then we can "capture" it with powerstrip, and we're free from any ressource hogging process. of course I will test it in every possible way with my colorimeter Quote:
Last edited by pitch.fr; 16th July 2008 at 02:44. |
|
16th July 2008, 08:27 | #34 | Link | |
Registered User
Join Date: Sep 2004
Posts: 1,295
|
Quote:
As I told you before, in theory could exist banding, in practice, I've never noticed it. As you see, the colors clipped are the more saturated ones, which don't appear too often in a movie... There are two kinds of possible banding, one avoidable and the other not: 1-colors out of display gammut: there is nothing to do, due to the clipping, some colors will be the same. Not many and not very frequent in a movie. 2-colors inside of display gammut: If you perform the correction and have a display with >= 10 bit per color, you could avoid this kind of banding, but in the pc we are currently "limited" by 8 bit per color. Maybe there is any hardware solution... Last edited by yesgrey; 25th December 2008 at 21:45. |
|
16th July 2008, 08:45 | #35 | Link | |
Registered User
Join Date: Sep 2004
Posts: 1,295
|
Quote:
The ATI "CUDA version" is too complicated? I understand that currently it's not very appealing working with these new GPU/CPU APIs, because probably only one will survive or even none of them will survive (a Microsoft one maybe?...) Also, we cannot forget that the currently existing alternative to this, using mplayerc with PS, works in all of them and gives pretty good results. I believe you're solution in theory is better, because you are using the correct gamma functions, but at the end, the result should be very similar... I left the decision in your ends (as it should be). |
|
16th July 2008, 10:01 | #36 | Link | ||
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
Quote:
well CLUT is 30 bit, so no banding I've spoken to Graeme Gill(the author of www.argyllcms.com) and he said this could be achieved through the CLUT. then I could use it on top of Haali's Renderer.............this would be awesome for me coz this is the smoothest renderer ever here's what he told me : Quote:
as I understand it, this should be possible to output an .ICC/.ICM file instead of a realtime correction through PS or AVS ? maybe this PDF would help ? http://www.inventoland.net/imaging/JEI/159.PDF OTOH, I'm trying your AVS plugin in ffdshow....as nothing's as smooth as HR on my box with Reclock in 24/48Hz I've copied this to C:\PJ_SMPTE.txt : Code:
0.151 0.068 0.781 0.339 0.611 0.050 0.656 0.329 0.015 0.311 0.328 0.361 1.0 0.0 0.45 0.0 0.0 Code:
MT("""ConvertToRGB32(matrix="rec709")""",4) ddcc(chr_i=3,ofile="C:\PJ_SMPTE.txt",threads=4,opt=1) Last edited by pitch.fr; 16th July 2008 at 14:16. |
||
16th July 2008, 12:25 | #37 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
@Tritical,
One very minor issue, you min(max(X, 0.0f), 1.0f) in 3 places. The input gamma table, the result of the matrix multiply and again for the output gamma table. I would have expected only the output gamma table which generates the 8bit output pixels needed to be clamped, all the other cases could be free to have temporary head room excursions outside the nominal range. i.e. 1.001*0.55 + 0.7*0.20 + 0.9*0.25 = 0.91555 1.000*0.55 + 0.7*0.20 + 0.9*0.25 = 0.91500 I guess it's a style thing, allow headroom on intermediate results or clamp rigorously at every stage. |
16th July 2008, 14:25 | #38 | Link |
Registered User
Join Date: Dec 2003
Location: MO, US
Posts: 999
|
@IanB
Well, only one of those three clamps is actually doing anything. The first clamp (on building the igamma table) shouldn't ever trigger since the inverse transfer function maps [0,1]->[0,1], and at that point it will only get [0,1] input. The second clamp, after the linear RGB -> XYZ -> linear RGB conversion, will trigger for out-of-gamut colors (i.e. a color in the input gamut is outside of the output gamut). I believe this is the right place to clamp because the final RGB values should be in the range [0,1], and the transfer function is defined as taking [0,1] input. The final clamp (on building the fgamma table) will again never trigger since it maps [0,1]->[0,1] and because of the previous clamp it will only be getting [0,1] input. I put those clamps in the gamma table creation mainly to remind myself that those values should be in the range [0,1], and since it is run only in the constructor the cost is negligible. @pitch.fr Having the filter output a 3D LUT is possible, just need to know the format to use. Also, the dark screen when using the ofile parameter was due to a bug I introduced in v1.1 (a missing multiply if the white points differed causing chromatic adaptation to be used). I put up a fixed version. Last edited by tritical; 16th July 2008 at 14:37. |
16th July 2008, 14:38 | #39 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
well, Graeme Gill's told me that an .ICC file would do the trick! possibly v4 ?
the LUT is 30 bit on ATi cards, dunno with nvidia ? If you could generate an .ICC file, this would be really awesome........as the Avisynth support in ffdshow is too slow(or maybe it's ConvertToRGB32's fault), and this PS script isn't working with HR.. at this point, nothing could be better than a way to generate .ICC profiles I'm actually very happy to hear that it's possible, because getting 1:1 colors with Haali's Renderer and Reclock would be just TOO AWESOME OK I'm gonna try again with the new version there is another slight detail, though. a friend of mine believes that gamut color conversion can only be done on the original 16-235 signal........applying the gamut conversion on 0-255 expanded content would require different coeffs ?! when we do REC.xxx conversions to RGB32 in ffdshow, luma goes from 16-235 to 0-255 and chroma from 16-240 to 1-255.....so are you still able to map the 0-15 and 241-255 colors or should we output in full range and let your ICC do the PC>TV conversion ? or a custom range ? also, here's a very interesting thread about these gamut stories : http://www.avsforum.com/avs-vb/showp...22&postcount=1 and another one on doom9 : http://forum.doom9.org/showthread.php?t=132745 and a PDF about ICC corrections in the movie industry : http://www.color.org/ICC_Chiba_07-06..._DMP_Float.pdf thanks for your help tritical ! Last edited by pitch.fr; 16th July 2008 at 16:55. |
16th July 2008, 21:45 | #40 | Link | |
Registered User
Join Date: Dec 2003
Location: MO, US
Posts: 999
|
I don't know anything about ICC profiles... How exactly would that solve the problem (assuming you had one, how would you use it)? Also, is there a document which describes the format of icc profiles, i.e. how to create one?
Quote:
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|