Programmers: Realtime 1:1 genlock now possible btwn live capture video and Radeon - AVS Forum | Home Theater Discussions And Reviews
Forum Jump: 
 
Thread Tools
Old 04-05-2004, 04:34 AM - Thread Starter
AVS Forum Special Member
 
Mark Rejhon's Avatar
 
Join Date: Feb 1999
Location: North America
Posts: 5,188
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 9 Post(s)
Liked: 106
[Sent email to dScaler discussion, but this technical information is useful to other programmers such as the Reclock DirectShow filter author, the ffdshow author, other capture card software, etc.]

Updated & expanded version of original email I wrote as follows as of April 5th, 2004, various of which were first sent to the dScaler list, doom9 forum, the Reclock author, and to people like John Adcock. I actually came up with this idea more than a year ago, but I think it's time for me to let the cat out of the bag (this may cause some other people to make money off this idea in certain cases rather than me... but try not to forget about me! ;))

______________________________________________________

Hi,

Long time no talk! There are new developers on this list who don't even remember my involvement, so let me introduce myself first.

You may remember that I helped invent the original algorithmic paper for the 3:2 pulldown algorithm dScaler:
http://archive.avsforum.com/avs-vb/s...threadid=74510
Note, dScaler used to be called dTV. The old version of the algorithm is documented at:
http://www.dscaler.org/32Spec.htm
It was the first 3:2 pulldown algorithm to really work well in dScaler (formerly dTV). Many of you remember that I invented the JudderTerminator algorithm that John Adcock deployed in source code. These two algorithms arguably form the two-pillar dScaler foundation of a pleasant 72 Hz experience with using dScaler to watch NTSC film material. (3:2 deinterlacing combined with JudderTerminator, for watching at 72 Hz)

Now I am about to suggest a new revolutionary suggestion for dScaler. Do software-based realtime genlock (perfect sync between capture card and Radeon). Make dScaler take advantage of the PowerStrip API or something similiar. This could make dScaler broadcaster-quality!

The existence of the PowerStrip API makes it possible to adjust a Radeon graphics card in 0.001 Hz refresh rate increments using an API method, or adding/removing scanlines to the VBI output (this latter method actually works on all Geforce cards going all the way back to the old TNT2 cards!).

By automatically using the PowerStrip API on a realtime basis, it is therefore possible to write a software DirectShow-style filter program that does a realtime genlock (synchronization) between an input (capture card) and the output (Radeon card). This must be done carefully during the VBI (Vertical Blanking Interval) -- in order to avoid disruption. Ideally, PowerStrip would be set as a higher-priority task and a thread waiting on the VBI would be done before doing a PowerStrip API to adjust if the synchronization was "falling behind" or "falling ahead" by microseconds. I did a crude test in a short C++ program, and all monitors I tried didn't show any disruption if I made the PowerStrip API to adjust the display frequencies during the VBI interval. (CRT monitors though). I found that the scanline addition/removal during the VBI produced the best results, and is actually compatible with Geforce. So basically, if you are using a 640x480 computer graphics mode, you usually have 525 scanlines (including VBI scanlines). Using the PowerStrip to alternately dynamically between 524, 525 and 526 scanlines on the Radeon graphics output (ie toggle between 39, 40, and 41 vertical retrace interval scanlines) in realtime, in order to keep the Radeon VGA output perfectly synchronized with the input framerate/fieldrate of a capture card. The existing buffering that DirectShow does, will give approximately a 1/60th of a second safety margin before a singe frame drop/add occurs, so the addition/removal of a few scanlines only adds/removes a few tens of microseconds of delay to a Radeon refresh. This minute delays can already be dynamically manipulated accurately enough to be much smaller than the existing safety margin of the existing DirectShow buffering, for 100% perfect 1:1 framerate synchronization between the capture card and graphics card.

The existing Reclock DirectShow does a similiar process already, but only on prerecorded material for DirectShow based DVD players, and not on live video material. It adds/removes clocks from the audio clock, in order to keep prerecorded file/media/DVD playback in synchronization with the output refresh rate. In the past, it was impossible to do the same thing with live video material on a standard PC system because consumer AGP cards do not synchronize to the clock of a capture card. Now that the PowerStrip API exists, this can now be achieved.

Realtime dotclock synchronization between the capture card and the AGP graphic card!

Genlock is very important for the broadcasting industry, especially if a PC is used as a realtime live video processing machine that is immediately used for broadcast in live video processing by a PC.

An existing filter such as ReClock DirectShow filter (GNU open source) can be retrofitted to use the PowerStrip API, to make realtime software-based genlock possible on live video sources! Ideally, realtime genlock needs to be directly built into the video viewer.

I made proprietary software for some earlier video processor products that has been able to genlock on a 5:4 basis, using a 60 Hz video source with 24fps material. First, a 3:2 pulldown deinterlace (reverse telecine) is done down to 24fps, then the framerate is tripled to 72 Hz by repeating each frame. So basically, a 5:4 genlock for a realtime 72 Hz output from a realtime 60 Hz video source that has embedded 24fps material in 3:2 pulldown.

Even a Microsoft Research paper covered this topic of synchronization:
http://www.microsoft.com/whdc/hwdev/.../VidSynch.mspx

FINALLY, by using the PowerStrip API makes this possible in a VERY easy manner for existing software such as Reclock or dScaler. Your software program is one of the other closest thing on the market that makes this achievable with realtime capture cards, because of dScaler's existing JudderTerminator algorithm. All this needs is a PowerStrip API calling algorithm to be piggybacked on top of this. The PowerStrip API only needs to be called approximately 15 to 30 times per second, all during the VBI interval. Make sure PowerStrip is running at a slightly higher priority than dScaler, to be safe (some adjustment may be needed). It is critical that all PowerStrip adjustments must be done instantaneously during the VBI interval in order to eliminate any visible computer monitor disruptions. (It works on 4 computer monitors I tried -- all of them CRT though) It also works on my DILA projector.

A wait port instruction on the VGA port 0x03DA is all that is needed to wait for the vertical blanking interval (or the appropriate DirectX API call), followed by an immediate PowerStrip API call (maybe wait a few scanlines into the VBI -- but making the call immediately at the beginning of the VBI seems to be fine in most cases). Here, it was possible for me to change the refresh rate in 0.001 Hz increments or add/remove a VBI scanline without ANY VISIBLE disruption to the computer graphics -- the monitor does not even notice the change. On some displays, there may be minor disruptions, and not all displays may be able to handle dynamic refresh rate changes. However, since 50 years ago, VCRs have had variable refresh rates and many displays have been designed to be tolerant of variability in refresh rate. Much of the "raster scanning" methodology for TV's also applies to most computer monitors. Therefore, the use of software-based very-slight varying of refresh or VBI scanlines, can work on most computer monitor displays properly.

The scanline add/remove trick, on a 1920x1080p (assuming 1125 vertical total, 72.0000 Hz) can achieve refresh rate adjustment granularity of 0.000012 Hz on both Radeon and Geforce cards! (1080p with 1125 line vertical total at 72 Hz equals a 81 kilohertz horizontal scanrate, which means 81000 Hz. This means adding and removing scanlines from VBI gives you a ultra precision of 1/81000ths of a single hertz. 1/81000th of a second equals approximately 0.000012 Hz. With this precision, this does not interfere with the display -- most displays are tolerant of such tiny variances. Simply modulating the refresh rate up and down in these tiny increments as needed to make the synchronization "catch up" or "fall behind", it is then subsequently possible to achieve 1:1 perfect genlock between a capture card and a Radeon card.

The PowerStrip API is documented at:
http://www.entechtaiwan.net/forums/viewtopic.php?t=6

By making realtime genlock possible, it should now be possible to have perfect 48 Hz or 72 Hz operation without a single dropped/added refresh during the entire course of a 2-hour DVD movie played through a capture card and then through dScaler out to a Radeon graphics card, on a properly setup computer system. Or perfectly correct 3:2 pulldown at 60 Hz with no stutter in the judder caused by lack of synchronization between the capture card and the output graphics board.

It is true that PowerStrip allows someone to get very very very close to a 1:1 synchronization between the capture card and the Radeon output. However, refresh rate will always differ by a tiny fraction, and this causes 'microstutters' occasionally that some sensitive people like me can notice!

There are certain technical issues regarding PowerStrip performance using the SendMessage API, and the PowerStrip automatic-scanning for clock frequency divisors take up some CPU time during "ultrafine" adjustments -- this may explain why I got better results with the vertical sync scanline addition/removal technique in my crude C++ internal testing of the viability of software-based genlock. The VBI scanline add/remove technique works fine on Geforce cards, so that's another advantage. (Actually incrementing/decrementing the Back Porch or Front Porch actually works too, although sometimes it caused the vertical image position to shift on some displays. So, a consensus should be made which VBI setting should be manipulated to achieve realtime genlock.

Another alternative is a direct Radeon register write to increment/decrement the number of scanlines in a refresh. This would be less portable than the PowerStrip API method, but would be higher performance.

While certain displays have absolutely no effect at all to the dynamic add/removes of scanlines in the VBI, certain types of CRT displays sometimes have a slight one-scanline shift or half-scanline shift if manipulating using the add/remove scanline method. This can be mitigated somewhat by rapidly alternating between two vertical totals that are off by 1 pixels alternatingly (i.e. 1125 versus 1126 for a 1080p graphics display, including VBI lines) to "balance"/"blur" the shifting out on such displays. That is, 1125 scanline vertical total half of the time, with 1126 scanline vertical total during the other half. Rapidly alternate between 1125 and 1126. During genlock synchronization, certain refreshes using 1125 would simply become 1126 instead whenever necessary to "catchup"/"fallback", while every other refresh would have 1126 scanline vertical total. This technique appears to compensate on some displays that has noticeable one-pixel-shift effects to the VBI scanline add/remove. Based on my testing with my DILA projector, it appears that the scanline add/remove has absolutely no perceptable deleterious effect on the DILA, which would mean that the displays that benefit the most from the scanline add/remove technique, would be certain digital displays that don't use a "native refresh rate". (Be noted, that my DILA is able to sync to 48 Hz refresh rate -- not all digital displays can do native refresh rates other than 60 Hz without internal framerate conversion.)

For attempting genlock to more variable-refresh-rate input material such as VCR-based material, this can become more tricky. It may be necessary to have a VBI add/remove scanline system that works automatically at greater amplitudes (i.e. dynamically modulate all the way between 1120 and 1140 vertical total for a 1080p output) or combine with dynamic refresh rate adjustment (if the PowerStrip people can make this faster or more efficient - i.e. precalculated lookup tables of divisors for every 0.001 Hz increments). It is observed that disruption is minimized on CRT displays if you increment 1 scanline at a time between refreshes. (You may be familiar with that some settop video processors that has genlock, sometimes causes CRT projectors to go out of sync when playing from a VCR -- because the refresh rate varies too much). So in essence, it may be necessary to buffer these variances somewhat to avoid display disruption. There is about 1/60th of a second safety margin, so one can keep incrementing/decrementing VBI scanlines every refresh, until fully caught up or fallen behind. Obviously, at the start, it's necessary to try to set the vertical refresh rate as accurately as possible, so that ideally, the VBI scanline add/remove technique of doing genlock, only requires an amplitude of 1 scanline (i.e. switching between 1124 or 1125 scanlines). Playback from external DVD players (and perhap piped through a theoretical genlock-capable dScaler) produce a refresh rate stable enough to be genlocked using only an amplitude of 1 scanline for the VBI add/remove scanline trick, but definitely not from analog VCR's.

Optional extra step: Not necessary at the moment as we can use VBI scanline add/remove technique instead. But to also improve the viability of the other technique using the dynamic refreshrate modulation rather than just scanline add/remove, we may need Entechtaiwan's involvement in improving the performance of the PowerStrip API for the refresh rate changes since it seems to do a display-disruptive scanning process (at the moment, the VBI scanline add/remove trick works best - and works on Geforce cards) Reprogramming the vertical refresh rate without changing the vertical total/horizontal total is much more complicated programming for a graphics card. The refresh rate is calculated indirectly using a math formula containing a divisor, involving the dotclock setting. A computer running for a while might be able to pre-calculate a nice, large table of precomputed clock divisors to be used for direct register writes, for as many possible super-tiny fractional refresh rate increments as possible between say, 59.9 Hz and 60.1 Hz automatically. Then there is less display disruption during refresh rate changes. Certain resolutions at certain dotclocks on certain Radeons may be able to achieve 0.0001 Hz precisions, while other resolutions will not be able to do any better than approximately 0.1 Hz. Anyway, this part is a little too complex to contempate at the moment. The point is that the VBI scanline add/remove trick seems to work just fine for most purposes. Behaviour caused by VBI scanline add/remove is display dependant, but the vast majority of displays are not having noticeable effects with a 1-pixel add/remove scanline, especially with various workarounds possible. Unless refresh rate changes can be made at even tinier fractions, this is not as good as the VBI scanline add/remove technique of doing genlock.

Also, started a thread in the doom9 forum because I am trying to inform the Reclock author of this revolutionary technique that is now possible with the PowerStrip API in my limited testing;

http://forum.doom9.org/showthread.php?s=&postid=469899

I am letting this cat out of the bag to be attacked by all you professional programmers. I am announcing that software-based genlock (synchronization) is now actually pratical on current computer hardware!

[Update: It appears that on some graphics cards, it is not even necessary to wait for the vertical sync interval before doing the PowerStrip API to do a dynamic increment/decrement to the Vertical Total in order to add/remove VBI scanline in a PowerStrip API call. However, this is not guaranteed. More testing is needed. My Radeon 9600 Pro seems perfectly happy with a random Vertical Total increment/decrement with no display disruption. It may actually be automatically buffering that particular register write(s) from PowerStrip, or that certain versions PowerStrip is automatically waiting for VBI itself. This still needs to be as-of-yet determined. The good news is that this may eliminate a requirement, since not all CPU-hungry video capture applications have the luxury of waiting until VBI.]

[Update2: I have heard there are other non-PowerStrip-API's that might be possible for manipulating timings of a graphics card. Those can be used as well, assuming the API is clearly documented somewhere. Direct register writes can be done. One could research the existing Linux XFree86 video timings tweaking source code for such programming information, for example.]

I am obviously pretty busy with my business at http://www.rejtech.com ... so haven't been working with dScaler lately. However, I did not want to keep this idea a top secret and wanted to spread the word about my success on achieving realtime software-based genlock. Please add this innovation to dScaler if you can -- I'd do this in a heartbeat but I've got a work-based deadline to catch. If nobody takes up on this and petition me to contribute this software genlock technology to dScaler, please contact me. (However, I've got people to feed and rent to pay....ouch!) At the very least, I can provide a small snippet of source code that demonstrates realtime display-disruption-free manipulation of PowerStrip timings for

For new users who needs to first verify my credentials, references to magazine articles with my name I've been mentioned in. (SGHT = Stereophile Guide To Home Theater):
- Fortune Magazine, July 24, 2000, Page 210 (HTPC)
- SGHT, May 2001, Page 55 (TAW Rock)
- SGHT, November 2001, Page 38 (dScaler)
- SGHT, December 2001, Page 32-33 (Test Pattern I invented)
- SGHT, October 2002, Page 90 (JudderTerminator)
Google highlighting my name within web version of Forbes article:
http://www.google.com/search?q=forbes.com+Rejhon
Google highlighting my name within web version of SGHT articles:
http://www.google.com/search?q=guide...ter.com+Rejhon
http://www.google.com/search?q=guide...ter.com+Rejohn
Also, my own various personal and business websites at:
www.marky.com
www.marky.com/hometheater
www.rejtech.com

Anyway, all you programmers of software applications that take advantage of live video, now you know how to achieve realtime 1:1 perfect genlock synchronization between any DirectShow-compatible capture cards (even cheap ones) and the graphics card display (pretty much any PowerStrip compatible graphics card)

Thanks,
Mark Rejhon

www.BlurBusters.com

BlurBusters Blog -- Eliminating Motion Blur by 90%+ on LCD for games and computers

Rooting for upcoming low-persistence rolling-scan OLEDs too!

Mark Rejhon is offline  
Sponsored Links
Advertisement
 
Old 04-05-2004, 04:56 AM - Thread Starter
AVS Forum Special Member
 
Mark Rejhon's Avatar
 
Join Date: Feb 1999
Location: North America
Posts: 5,188
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 9 Post(s)
Liked: 106
To address questions coming up about "why is there need for genlock" -- some of us are just plain sensitive to microstutters. (That's why software such as Reclock exists, JudderTest exists, etc.)

Plus, it is frequently critical for the broadcasting industry to have proper genlock (perfect synchronization). This technique can make an relatively inexpensive mass-market computer suitable enough for certain broadcast video processing purposes.

This work has already been researched on before by other people than me. Microsoft Research on this topic. However, this has not been pratical until now, with my recent testing with the PowerStrip API. I am pleased to say that this is finally pratical now, today. My testing on an Athlon XP1800 and XP2600 in my computer laboratory confirms this. It is commercially viable already, regardless of a $30 or $1000 capture card.

Time to add this feature to Reclock, dScaler, etc!

Thanks,
Mark Rejhon

www.BlurBusters.com

BlurBusters Blog -- Eliminating Motion Blur by 90%+ on LCD for games and computers

Rooting for upcoming low-persistence rolling-scan OLEDs too!

Mark Rejhon is offline  
Old 04-05-2004, 05:13 AM
Senior Member
 
voivod84's Avatar
 
Join Date: Jun 2003
Location: Wayland, NY
Posts: 376
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
This sounds like great news. I was using a combo of 9600 fan less pro and compro but the stutter was real bad so I went back to my ATI AIW 9700 Pro where there is still a little bit so stutter where the camera pans across a stationary scene. I use powerstrip to help this but its not perfect. The Compro video capture tv tuner card did have a much better picture. Well I hope someone makes a nice and easy program to utilize all this great info and also make it stupid proof for fools like me that like the install and it works idea. I would pay for this:)

Well be cooolll

Eric

Just remember, No matter where you go there you are
voivod84 is offline  
 
Old 04-05-2004, 07:26 AM - Thread Starter
AVS Forum Special Member
 
Mark Rejhon's Avatar
 
Join Date: Feb 1999
Location: North America
Posts: 5,188
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 9 Post(s)
Liked: 106
Before doing realtime genlock is really pratical, all other factors of judder/stutter needs to be eliminated as much as possible. This is already easily achievable with dScaler at least with 8x8-based cards -- to the point where all stutter/judder is removed with the sole exception of noticing the occasional microstutter caused by the slight disparity between the capture rate and the output refresh rate. By simply adding realtime genlock, perfect sync can be made possible. Somewhat harder with the 2388X-based cards and other types of cards I think, but certainly not impossible.

For DirectShow based cards, one could technically improve the open-source Reclock DirectShow filter to add support for live video sources (using the aboveformentioned PowerStrip API to sync the live capture video to the output refresh using the VBI scanline add/remove technique). Then Reclock will be doing the synchronization work, rather than dScaler.

Ideally, there are multiple avenues of achieving this.

Thanks,
Mark Rejhon

www.BlurBusters.com

BlurBusters Blog -- Eliminating Motion Blur by 90%+ on LCD for games and computers

Rooting for upcoming low-persistence rolling-scan OLEDs too!

Mark Rejhon is offline  
Old 04-06-2004, 02:51 AM - Thread Starter
AVS Forum Special Member
 
Mark Rejhon's Avatar
 
Join Date: Feb 1999
Location: North America
Posts: 5,188
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 9 Post(s)
Liked: 106
Let me know if any developer (who wants to add this feature to their software) needs to ask me any questions. I know this post is kind of technical, and requires a very skilled person to understand much of the terminology in this post.

Thanks,
Mark Rejhon

www.BlurBusters.com

BlurBusters Blog -- Eliminating Motion Blur by 90%+ on LCD for games and computers

Rooting for upcoming low-persistence rolling-scan OLEDs too!

Mark Rejhon is offline  
Old 04-29-2004, 01:22 PM
Member
 
pbelo's Avatar
 
Join Date: Aug 2001
Location: LISBON-PORTUGAL
Posts: 37
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Hi Mark ,

Can you indicate the exact PS timings for
1920x 1080p / 72 hz ?


apprecite yr help .

regards ,Pedro

Peter
pbelo is offline  
Old 05-02-2004, 05:51 AM
AVS Forum Special Member
 
Blight's Avatar
 
Join Date: Jan 2001
Location: Mt. Carmel, Israel
Posts: 2,489
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 7 Post(s)
Liked: 11
Mark:
How healthy is this for the hardware involved... And I believe it would only work with CRT hardware.

Wouldn't it be A LOT simpler to just buffer the last second of video and then use standard reclock-type output to achieve this same synch without any requiring any specific hardware adjustments?

Yaron Gur
Zoom Player . Lead Developer
Blight is offline  
Old 05-04-2004, 01:00 PM
ogo
Member
 
ogo's Avatar
 
Join Date: Feb 2003
Location: Paris, France
Posts: 77
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
Hi Mark,

Sorry for not coming back to you sooner. I've little time to play with reclock those times, released the version 1.4 in a hurry, and only answered a few questions :(

Using Pstrip API is indeed a very good idea. It would give perfect SPDIF playback to reclock, and would make the audio resampler unneeded in most cases. But i'm a little skeptical like Blight, and i doubt it will be easy not to produce artifacts and various problems during playback/genlock. I'm also quite curious to see what it can do in TV out mode.

Anyway, as i have some spare time until friday, i'll make some tests with reclock + pstrip api and post results here ... I'm starting right now :)
ogo is offline  
Old 05-04-2004, 01:08 PM
AVS Forum Club Gold
 
madpoet's Avatar
 
Join Date: Nov 2002
Location: Connecticut
Posts: 14,080
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 0 Post(s)
Liked: 10
I'm very interested to see your results :)

Someday maybe I'll actually WATCH my projector...
madpoet is offline  
Sponsored Links
Advertisement
 
 
Thread Tools


Forum Jump: 

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off