Log in

View Full Version : req: Dscaler Like Automated Calibration ...


oo_void
20th July 2004, 19:52
So, like most everyone else out there it seems, I'm doing a DVD conversion of certain series of LaserDiscs ;). After many months of tweaking and perusing the various forums, I’ve been able to hobble together a script that does a great job of converting the original source 4:3 source into an extremely clean, anamorphic output ready for compression (special thanks to Didee and his IIP script).

The final step of the process is levels and color correction. I’ve been using the AVIA Home Theater’s Essentials DVD, running it through the same signal chain (I’ve got one of those Pioneer LD/DVD players) to assist in the process. But eyeballing the output and using a simple color picker to help in matching doesn’t exactly give me much confidence in the process overall.

Thanks to Google, I’ve come across an interesting application called DScaler (probably old news to most of you). One feature that really sparked my interest was the auto-calibration functionality. It seems that DScaler will take a known source, including the AVIA disc, and perform automated adjustments to the video stream (Brightness, Contracts, Hue, and Saturation). Unfortunately, DScaler doesn’t support Firewire, my input method of choice.

Getting to the point, I’ve toyed with ‘autogain’ and the AGC scripts out there, but they’re really not suited for my purposes. For instance, is there anyway to display the modifications the ‘autogain’ function is performing to the screen through sub-titles? Anyways… I’m wondering if anyone out there has, or is thinking of taking this to the next level, providing a full suite of calibration functions (if it’s even possible) similar to what DScaler provides.

Though I lack the skills (so far) to put something like this together myself, I’m envisioning, in its simplest form, a script or function that generates a known output, a series of color bars and IRE ramps that you run through your processing and conversion chain, then feedback into AviSynth for analysis. The results of the analysis would be output to the screen, providing a basis for the setting of either a ‘Levels’ or ‘ColorYUV’ functions for the mastering other sources that follow the same input chain. Even better would be a function that took known test patterns, such as those on the AVIA or THX calibration discs, similar to what DScaler seems to do. Any thoughts?

------
oo_void

tedkunich
20th July 2004, 21:43
The problem you will run into is that your video sources can be "all over the map". I have two LD players that are completely different from each other RE brightness, contrast and chroma saturation levels. You will have to factor in your source with whatever calibration process you decide on.

I played around with capping said frames from the Video Essentials LD and creating some scripts to crop the specific regions and then perform the luma and chroma calcs, but that was far beyond my scripting abilities and gave up on that. As I have an analog capture card, I perform the cal with Dscaler and then copy the settings for future reference.

Good luck

t

oo_void
20th July 2004, 22:05
Given that my sources are 'THX Mastered', I'd trust that the initial information as stored on disc is properly balanced. The intent would be to use the script for calibrating a single device and input chain. In my case, it would be Pioneer LD-909 -> SVHS DV Cam Input -> Firewire Canopus YUV Codec -> Nasty Filters that Destroy Color Infomation.

My Pioneer LD does *BOTH* DVD and Laser Disc, so in my specific case, it would be possible for me to either use the AVIA DVD or burn a new DVD with known patterns as generated by AviSynth then use such inputs for calibration. Additionally, another way in which this process could be used is to write the patterns to DV tape, then feed them back through an analog input chain over analog I/O.

Hell, such a process would probably even be useful in the all digital domain with the afore mentioned 'Nasty Filters that Destroy Color Information' ;).

With a little more research on the avisynth site, I uncovered a whole slew of 'keywords' like 'AverageLuma' and the like (yes, I'm new to this stuff). Now, if I can only figure out how to do loops or iterators in avisynth, even I might be able to put something together.

------
oo_void

tedkunich
20th July 2004, 22:33
Originally posted by oo_void
Given that my sources are 'THX Mastered', I'd trust that the initial information as stored on disc is properly balanced. The intent would be to use the script for calibrating a single device and input chain. In my case, it would be Pioneer LD-909 -> SVHS DV Cam Input -> Firewire Canopus YUV Codec -> Nasty Filters that Destroy Color Infomation.


THX mastering has nothing to do with this - if you take the same disc and play it in two different machines, they will NOT look the same. I have the DVL-919 and the picture is really dark when compared to a borrowed Philips LD player. I have found that the Pioneer does some rather ugly dynamic compression in the luma to make it "dark" - when in fact, in dark scenes "AKA Empire" much detail is lost - no post processing tweeks are going to recover it.



My Pioneer LD does *BOTH* DVD and Laser Disc, so in my specific case, it would be possible for me to either use the AVIA DVD or burn a new DVD with known patterns as generated by AviSynth then use such inputs for calibration. Additionally, another way in which this process could be used is to write the patterns to DV tape, then feed them back through an analog input chain over analog I/O.
[/B]

The pioneer combi players have two separate video processing paths - the LD output and DVD output do not correlate very well. I have performed a Dscaler cal using the DVD VE vs. the LD VE and achieved two completely different settings.



T

oo_void
20th July 2004, 23:08
THX mastering has nothing to do with this - if you take the same disc and play it in two different machines, they will NOT look the same. I have the DVL-919 and the picture is really dark when compared to a borrowed Philips LD player. I have found that the Pioneer does some rather ugly dynamic compression in the luma to make it "dark" - when in fact, in dark scenes "AKA Empire" much detail is lost - no post processing tweeks are going to recover it.
T
The luma compression you're seeing on the Pioneer sounds like it's got 'Cinema' mode turned on. I made the mistake of forgetting to turn it off the first time I did captures. :mad:

Yes, I'm aware that I'm going to see some differences between the DVD and LD output because they hit different decoding processes, but I still see a lot of consistancy between them; slight red shift, loss in saturation (BTW... the luma is actually almost perfect before the avisynth filters hit it based on the IRE ramp's I've been using). I'd at least like to catch the degradation that occurs during the analog capture / firewire transfer stage.

That aside... it seems we have a disconnect here. I talking about using the same hardware throughout; calibrate using test patterns coming off the LD (we'll forget the idea about avisynth generated stuff for now), then capture using that same LD hardware and following the same signal chain up into avisynth.

If the color bars on the LD are true colors bars, with the first block being 75% white (or whatever the standard is) and so on, that means we have a know value that the script should match. Anyways... I'll play around with some patterns tonight and see if I can figure this avisynth scripting thing out.

------
oo_void

oo_void
28th July 2004, 18:36
So, I never got around to automating the thing... but here's the process I've been using to calibrate input based off a standard, 75% Color Bar pattern. Given that I'm quite new to this stuff, may math may be way off, so any comments on this process would be appreciated.

With this 75% test pattern, the max on both the U and V planes should be 200, while the min should be 54. Given those known values, we establish a scale of 1.2 (or 240/200) for max value on these planes, and a scale of .296 (or 16/54) for the min value on these planes.

Now that those constants have been identified, we feed AviSynth our captured test pattern, then display the actual Min, Median, and Max values for each color plane on our test pattern capture ...


#video = ColorBars(720, 480)
video = AviSource ("d:\dvd_authoring\colorbars\avia1-7.avi", pixel_type = "YUY2").Trim(0, 450)
video = ConvertToYV12(video)

chroma_u_input = UtoY(video)
# WARING -- Your levels may be different, tweak these values based on the multiplied established...
chroma_u_fixed = levels(chroma_u_input, 14, 1, 251, 16 , 240)

chroma_v_input = VtoY(video)
# WARING -- Your levels may be different, tweak these values based on the multiplied established...
chroma_v_fixed = levels(chroma_V_input, 16, 1, 239, 16 , 240)

# WARING -- Your levels may be different, tweak these values based on the multiplied established...
chroma_y_fixed = levels(video, 15, 1, 255, 16, 235)

# Merge our tweaked color planes back into normal space ...
YtoUV(chroma_u_fixed, chroma_v_fixed)
MergeLuma(chroma_y_fixed)

# Uncomment each line, one by one, then use the value returned to establish your offsets ...
ScriptClip("Subtitle(String(YPlaneMin(chroma_u_input, 50)))")
#ScriptClip("Subtitle(String(YPlaneMedian(chroma_u_input)))")
#ScriptClip("Subtitle(String(YPlaneMax(chroma_u_input, 50)))")

#ScriptClip("Subtitle(String(YPlaneMin(chroma_v_input, 50)))")
#ScriptClip("Subtitle(String(YPlaneMedian(chroma_v_input)))")
#ScriptClip("Subtitle(String(YPlaneMax(chroma_v_input, 50)))")


Keeping track and of values returned, you use the Min, Median, and Max values, multiplied by our established constants to inform the values that should be passed to our levels commands. To determine the gamma correction value, if necessary, use median/1. You'll notice that I needed very little in the way of correction ;).

The whole process takes a little bit of effort, but personally, I've been quite happy with the results. Additionally, if you feed in something like a 10% IRE Scale, you can use a similar process to adjust the Y plane... Just remember the IRE scale runs the range of 16 thru 235 so the constants will be different. As extra credit, I've been using Didee's YLevels functions (http://forum.doom9.org/showthread.php?s=&threadid=79898) in place of the internal Avisynth levels function, especially on the YPlane. Anyways, hope someone finds this stuff useful...

------
oo_void