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. |
|
|
#1 | Link |
|
Registered User
Join Date: Sep 2009
Posts: 378
|
xvYCC to Wide Gamut RGB Help Please. :-)
I thought I'd better start a new thread rather than go off topic on the "U & V ranges for valid RGB." or "gamut conversion through AVISynth"
http://forum.doom9.org/showthread.php?t=154731&page=2 What I'm trying to get to is suggested in Post's #35 & #39 and this thread: gamut conversions through AVISynth http://forum.doom9.org/showthread.php?t=139389&page=33 Post #644 In a nutshell it's a query about extracting as much data out of a 'full range' video source from a typical HD DSLR video camera shooting h264AVC. xvYCC into a RGB image with a wider gamut than sRGB. My reference to 0 & 1 normalisation is the 'unity cube' and retaining / using / processing negative RGB values and positive RGB values above 1 and then gamut mapping via tonemapping or 3D LUT back to smaller gamuts as/if required. I'm using FFmpegSource2, Avisynth 2.5.8, yesgreys yCMS 3D LUT for xvYCC to AdobeRGB, Triticals t3dlut plugin and AVSPMod 2.0.7 and Wilberts Imagemagick plugin, tried Virtualdub but author informs me Vdub is not suitable for extracting xvYCC to RGB. I've also used CoreAVC Pro and mkvmerge to matroska for Haali as alternative decompression methods incase something is happening right at the start of the process. I'm using The Gimp and ImageJ to check unique color count and histogram values. As some means other than my eyes to quantify, 'quality'. But this is on single frames not motion. I assume 32bit float precision is required to handle negative values. xvYCC explained: http://www.sony.net/SonyInfo/technol.../xvycc_01.html Source video of mine toy gold jewelery to test, deliberately shot full range, badly white balanced under tungsten lighting to give yellow cast and generate a good helping of so called 'out of gamut' colors (for sRGB/Rec601/709 that is) but far less for xvYCC. http://www.yellowspace.webspace.virg....com/Gold.aMOV Rename the .amov extension .MOV ;-) Does anyone have any suggestions as to why I seem to be struggling getting substantial more colour values that would suggest successful xvYCC to RGB conversion. Could this be as a result of normalisation in the chain, just simply not handling negative values? Maybe happening with yv12 to yuy2, or at the t3dlut plugin or is it just happening straight away when processing with Avisynth? I'm not a video tech guy so could well be talking total rubbish, not unusual. :-) Is using ConvertToRGB(matrix="PC.709") all I need to handle xvYCC? I'm getting far more (approx 30%) than a typical Rec709 YCbCr to sRGB conversion which is great but not what I feel is handling xvYCC correctly. Sorry a lot to digest, but I'm sure there's members here who are in the know. Any help, advice or own testing would be great. Also if anyone interested in my plight has access to apps like Nuke, Adobe Premiere CS5 etc that probably handle this query no problem, it would also be very interesting to see a frame from the source (say frame 25 for consistency) to compare interpolation, unique colors against what I'm getting so far. Also slightly separate query but I'll ask :-), regarding interpolation generally in YCbCr to RGB conversions, I've see various interpolation methods used but wonder whether with regard to further RGB image processing, grading etc whether there is good reason to use a basic interpolation in the conversion, than say Bicubic or Lanczos as first hit, the idea of edge refinement later in the chain before encoding, does it make sense to do that or go for a good balance between edge refinement like bicubic against haloing and ringing from something like Lanczos straight off at the conversion, obviously depends on heavy handedness of settings used, not trying to suggest it's the case in general. Last edited by Yellow_; 6th March 2011 at 15:06. |
|
|
|
|
|
#2 | Link |
|
Registered User
Join Date: Sep 2007
Posts: 5,348
|
Isn't this impossible if you are using the native recording format ? I think you would need to access upstream
e.g. if you use a canon dslr, the Rec601 values are "baked in" . The sensor sampling in RGB uses Rec601 to convert to Y'CbCr when recording the MOV . The HDMI feed of canon DSLR's is foobar, but there might be some tweaks you can do with Magic Lantern For other cameras, most use Rec709 , but the HDMI or HD-SDI feed still might be compromised . You have to do some tests to see if the data is valid, and not converted by Rec709 . Some more expensive cameras like the Sony F3 have user definable LUTS and hypergammas. I think that is what you want. This avoids the baked in Rec601/709 issues and you have access to more data. I think you need a dual link HD-SDI recorder. The cheapest one is ~$10K (cinedeck). By the time Rec601/709 has been applied, it's too late. An bad analogy would be "raw" in the photo world; essentially you're accessing data father upstream that has not been processed as much |
|
|
|
|
|
#3 | Link | |||
|
Registered User
Join Date: Sep 2009
Posts: 378
|
Quote:
However when mapping the 16 - 235 range to 0 - 255 RGB the under and overshoot live in the negative RGB range and over 1 ie 255. yesgrey has added xvYCC to RGB or AdobeRGB (which extends gamut by defining wider color primaries) to yCMS. Quote:
Quote:
Also the profiles are all based on some NLE workflow or other, it's then questionable whether that is a full range workflow, a squeezed into 16 - 235 workflow etc, are they making assumptions on what they see after the NLE's had it's way with the data.? No disrespect to what they are doing but left it out of the equation for the time being and concentrated on what the xvYCC spec offers. Thanks for the response. |
|||
|
|
|
|
|
#4 | Link | ||||
|
Registered User
Join Date: Sep 2007
Posts: 5,348
|
Quote:
Quote:
For example, you can work in a wider workspace like AdobeRGB, or wide gamut RGB in after effects, but this doesn't affect your actual asset which is Y'CbCr. It's been recorded that way. Quote:
Quote:
If you're using that gimp analyzer, remember you're only using 8-bit values with the native recorded format. The maximum you can get is 2^8 * 2^8 *2^8 = 16.7M colors (that's if you use full range, standard Rec709 range is less) . If you use 10bit you get trillons of colors 2^10 * 2^10 *2^10 Working in a wider gamut space doesn't mean your actual asset has more colors. If you put honda civic engine in a ferrari body kit, it's still a honda civic engine. Last edited by poisondeathray; 6th March 2011 at 17:38. |
||||
|
|
|
|
|
#5 | Link | ||||||||
|
Registered User
Join Date: Sep 2009
Posts: 378
|
Quote:
Could it be the case that the sensor data gets clipped to 16 - 235 and then encoded to h264 full range? I know that the image off the sensor is less than 1920, 1700 and a bit and resized before encoding. When using something like Avisynths histogram 'classic' mode the waveform shows full 0 - 255 data and that waveform looks well formed, smooth undulations, no gaps or compressed areas and so does the histogram, using matrix PC.601 over Rec 601 appears to provide additional data in the conversion to RGB. And when using Rec601 from a transcode to say Huffy, the histogram compresses and spikes so too the waveform using the same 8bit processing chain as deriving full range RGB but adjusting to suit restricted range. The spiky histogram and compressed waveform suggest the data has been degraded. Quote:
Quote:
Quote:
Quote:
Quote:
There's some nice 'RAW' apps with 32bit wide gamut processing and tonemapping algorithms like in Oloneo's PhotoEngine that might be beneficial even for LDR formats. Quote:
Quote:
This is very a useful discussion for me, cheers. Last edited by Yellow_; 6th March 2011 at 18:30. |
||||||||
|
|
|
|
|
#6 | Link | ||||||
|
Registered User
Join Date: Sep 2007
Posts: 5,348
|
Quote:
You say h.264 supports xvYCC in the specs, but h.264 supports 4:4:4 and 16bit as well. It doesn't mean you have used it. Quote:
Quote:
Do you see what's happening here? When you use libavcodec/ffmpeg, it decodes using full range values, so you're forced to use a PC matrix. If you decode through another decoder e.g. through quicktime API , black is scaled to 16 and white to 235 . (ffmpeg also decodes 1920x1088 uncropped) . Quote:
I think it would help if you had an actual verified sample that conforms to xvYCC Quote:
This bit depth is different concept than the color working space or gamut, but I only bring it up because you're using it to check "unique colors" Quote:
HDMI specs supposedly support xvYCC ; so if you theoretically had a capture card that supports xvYCC, and a camera that outputs xvYCC through HDMI, and a recording format that supports xvYCC (Maybe some subset of h.264), then maybe it would work ? Last edited by poisondeathray; 6th March 2011 at 19:17. |
||||||
|
|
|
|
|
#7 | Link | ||||||||
|
Registered User
Join Date: Sep 2009
Posts: 378
|
Quote:
Quote:
Quote:
Quote:
As you say, QT converts to YUY2 and crops. FFmpeg leaves it 4:2:0 and full range. The source is 4:2:0 and it is 1920x1088 so which route appears to leave the source alone? :-) Quote:
Again for testing I'm assuming full range, but take your point about possibility of in camera levels change negating xvYCC. I've uploaded two images, same frame one decoded with QTSource and the other FFmpeg. Used histogram classic, I know the exposure hard clips at 255 and used it to illustrate which waveform looks the least affected? No conversion to RGB has been done to the source to affect the waveform. http://www.yellowspace.webspace.virg...a.com/boat.zip The same thing happens with transcoding DSLR to intermediates like Huffy, by default ffmpeg will scale the DSLR source into 16 - 235 of huffy's YUY2. Not lossless. :-) Quote:
Quote:
Quote:
It's the rest of the Avisynth chain now I'd like to ascertain can pass xvYCC through and out to RGB and maybe compare against other apps too. Last edited by Yellow_; 6th March 2011 at 20:41. |
||||||||
|
|
|
|
|
#8 | Link | ||||
|
Registered User
Join Date: Sep 2007
Posts: 5,348
|
Quote:
But if you look at how you measured exposure for the shot and the decoded image, which looks more similar to how you shot it? It's really the same thing. You can expand the range of the QT decoded image or compress the range of the ffmpeg decoded image. I know that boat picture was just to show the Y' waveform, but that accompanying screenshot used Rec601 for the RGB conversion. You can tell because of less detail in the superbrights. But if you shot slightly more overexposed, which decoding method might clip more data, and which would leave you more "headroom" so you could recover the data ? ![]() Quote:
If you have Y' 0-255 (e.g. decoded with ffms2) it will pass through Y' 0-255 untouched with those methods If this is true, this would suggest ffmpeg is decoding it differently that ffms2 or libavcodec in other decoders, or you're incurring a Rec601/709 RGB conversion somewhere in your workflow Quote:
If you have a verified sample, then you should be able to use yesgrey's yCMS to go xvYCC <=> RGB , provided you have a format that is able to record xvYCC Quote:
Last edited by poisondeathray; 6th March 2011 at 21:33. |
||||
|
|
|
|
|
#9 | Link | ||||||
|
Registered User
Join Date: Sep 2009
Posts: 378
|
Quote:
Quote:
Quote:
As it's not just the luma to consider, for example in the Gold mov white balance is way off so there's a lot of yellow and that is going to be well out of 'legal' range. According to Gavino's ShowBadRGB script something like 80000 unique colors are out of range based on 16 - 235/240 as legal (that is the sRGB gamut) and 21000 of those are out of range based on 0 - 255 as legal (beyond sRGB gamut), mostly the yellow/orange I'd think. Maybe I'm just using the script wrong. I wonder whether I'm already getting close to xvYCC but topping out because I can't get decode into a wider RGB gamut via Avisynth to see the extent of the additional data. Which makes me question the chain. Which would be the better way to try to correct that white balance? Working on evenly distributed full range colours via ffmpeg where there is undoubtedly a finer gradient or on a squeezed QT decode where it's all got to be teased out or expanded otherwise working on what I'd consider compressed yellow/orange gradient with less unique colours in fewer bins? It's a test I was going to try out, have some very blue/cyan badly white balanced source too which again will surely out of sRGB/Rec709 gamut. Quote:
Quote:
Quote:
But for now I'd really like to establish whether the rest of the tool chain supports xvYCC to RGB. Last edited by Yellow_; 7th March 2011 at 01:06. |
||||||
|
|
|
|
|
#10 | Link | |||
|
Registered User
Join Date: Sep 2007
Posts: 5,348
|
Quote:
Quote:
I know your original question has to do with avisynth, but part of the problem might be the software you're using. For example with AE, you have color management and can assign color profiles and color workspaces and "see" more of the data. You can import avs directly as well. But it doesn't have xvYCC profile , so I don' t know how it compares to Wide Gamut RGB. You can get negative histogram values with some combinations, but the differences don't seem as large as suggested that sony link . You do get more "unique colors" according to gimp - whatever that means - But if you adjusted values in Y'CbCr before RGB conversion, I bet you could increase "unique colors" as well. All you are doing is making sure no channel is clipped (or CbCr aren't too extreme). Tell me if you want the samples uploaded. Quote:
If you're going by the "fewer bin" analogy, I think it's better to use to a higher bit depth intermediate. Then you have even more inbetween "bins" (even though they are interpolated) , and the histogram is even smoother when making adjustments. If you're using RGB, then I would use full range. If using Y'CbCr intermediate then you either have to correct for levels in Y'CbCr space before RGB conversion, or make sure the program you're using doesn't do a Rec601/709 conversion and clip data . You could also use smoothtweak to adjust CbCr into more legal ranges before going to either intermediate format Last edited by poisondeathray; 7th March 2011 at 04:43. |
|||
|
|
|
![]() |
|
|