| |
ChristopherJam
Registered: Aug 2004 Posts: 1408 |
Christopher Jam's composite video measurements
I spent a month or two back around the start of 2015 measuring the composite video output of a new luminance c64 using a 100MHz USB oscilloscope, then trying to reproduce the output waveform using a simple predictive model.
Before I started, I had this crazy idea that I could use the fragments of chroma signals from each pixel to manufacture new colours, on the assumption that each pixel would be a well defined slice of a sinewave. Ahahahaha. Nothing so simple. Chroma takes several pixels to start up and shut down again, and the luma signal rings visibly for four or five pixels.
I do now however have a pretty accurate model of the luma behaviour, and my chroma model is not far off.
Some pretty graphs and test images at http://jamontoads.net/p/lumachroma.html
Here's a teaser
and a palette :)
jampal=[000000, ffffff, 7d202c, 4fb3a5, 84258c, 339840, 2a1b9d, bfd04a, 7f410d, 4c2e00, b44f5c, 3c3c3c, 646464, 7ce587, 6351db, 939393] |
|
| |
Krill
Registered: Apr 2002 Posts: 2968 |
Good job!
Apart from the palette, can the model you deduced be (easily) included with emulators to improve render fidelity? |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1408 |
Quoting KrillGood job!
Thanks!
Quote:Apart from the palette, can the model you deduced be (easily) included with emulators to improve render fidelity?
Nontrivial in its current state.
I'm pretty sure I can get the signal reproduction down to four table lookups per pixel, each one indexed by a run of three pixels (or one two-byte lookup indexed by the last five pixel indices), but that just generates a two sample per pixel composite signal that would still need converting to YUV, chroma averaged, then RGB converted.
The composite->YUV filters I'm using at the moment are several pixels wide, so a direct translation would be fairly slow. More maths to be done.. |
| |
lft
Registered: Jul 2007 Posts: 369 |
But graphics cards are fast. Sounds like a straightforward job for a pixel shader. |
| |
Jammer
Registered: Nov 2002 Posts: 1335 |
Splendid! So this or Colodore? ;) |
| |
chatGPZ
Registered: Dec 2001 Posts: 11350 |
did you actually use composite? and if yes, why? =)
it would also be interesting to know what video chip exactly you used... and then re-do the measurements on different chips. i am willing to bet there are quite some differences :) |
| |
Oswald
Registered: Apr 2002 Posts: 5086 |
very cool you did that =) in some of the example pictures the "distortion" feels like those on true CRT. |
| |
soci
Registered: Sep 2003 Posts: 479 |
View64's PAL/NTSC mode generates luminance and chrominance "signals" and feeds them it into a decoder. The signal generation part is a bit simplistic currently and this bothered me for a while.
Therefore these measurements are really interesting. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11350 |
the renderers i wrote for testing also work like this... i was lazy though and used some filter implementations i found somewhere on the net which are not really suitable for realtime signal processing so its all really slow =) |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1408 |
Quoting lftBut graphics cards are fast. Sounds like a straightforward job for a pixel shader.
Yes I've been wondering about that. Attempting one has been on my todo list for over 18 months now though, so I should just release a slow reference implementation and let someone else have a bash at making it faster..
Quoting Groepazdid you actually use composite? and if yes, why? =)
haha yes! Um, I wasn't getting any signal at all from the chroma pin on the c64 in question. Besides, composite's the only input on the front of my nicest CRT, so it's how I view things anyway..
Quote:it would also be interesting to know what video chip exactly you used... and then re-do the measurements on different chips. i am willing to bet there are quite some differences :)
Yes, differences seem likely. This was a nine luminance one in an assembly where I'd need to unscrew the keyboard to even get to the heatsink/shielding that's covering the chips.. And that c64 has stopped working properly sometime since I took the measurements.. (powers up and displays " OUT OF MEMORY ERROR IN 0" I'm a bit scared to plug my MMC reader into it..)
Quoting sociView64's PAL/NTSC mode generates luminance and chrominance "signals" and feeds them it into a decoder. The signal generation part is a bit simplistic currently and this bothered me for a while.
Therefore these measurements are really interesting.
Ah, nice. Ok, I will try and finish bundling up the code and data for release. |
| |
pepto Account closed
Registered: Nov 2004 Posts: 35 |
Quoting ChristopherJamI do now however have a pretty accurate model of the luma behaviour, and my chroma model is not far off
These sloppy signal observations are interesting... congrats on finally publishing the results of your experiments. :)
Quoting JammerSplendid! So this or Colodore? ;)
It doesn't really matter that much, as colodore isn't really ONE EXCLUSIVE palette. You may tune it by altering the brightness, contrast and saturation sliders, just like on real equipment. This way you should be able to match captured palettes (there are small lot-to-lot variations). For example here's a quick attempt to tune colodore (47/85/66 - top) by eyesight to somewhat match Christopher's palette (bottom).
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11350 |
kinda funny that christophers palette has this red-ish blue that people used to complain about =D |
| |
soci
Registered: Sep 2003 Posts: 479 |
The "OUT OF MEMORY ERROR IN 0" you'll get if the RAM test fails before reaching $802. Check the DRAM.
Looking at the luminance waveforms I suspect you took them directly at the connector pins with only the scope connected. It should have less overshoot with the TV connected on the measured line. |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1408 |
Quoting sociThe "OUT OF MEMORY ERROR IN 0" you'll get if the RAM test fails before reaching $802. Check the DRAM.
Thanks - I had much the same rec from #c-64 this morning. Sourcing replacement RAM at the moment, then we'll see how my soldering goes..
Quote:Looking at the luminance waveforms I suspect you took them directly at the connector pins with only the scope connected. It should have less overshoot with the TV connected on the measured line.
Hmm, interesting. I recall popping the case and clipping my probes to the back of the video connector, but can no longer remember if I reconnected the TV. I think I actually saw at least some of the ringing on my TV when I looked closely, mind. I'll redo when I get my hardware working again, just to be sure. |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1408 |
Quoting pepto. For example here's a quick attempt to tune colodore (47/85/66 - top) by eyesight to somewhat match Christopher's palette (bottom).
That's really close! Reassuring :) |
| |
soci
Registered: Sep 2003 Posts: 479 |
Some TVs have "sharpness" settings which can cause similar ringing effects if tuned too high.
The termination in the TV or monitor is part of the circuit and needs to be there for proper signal transmission. Assuming that the circuit was properly designed of course.
I still have a "green" monochrome CRT monitor and I don't remember seeing such overshoots on it. But it's last use was a half year ago or so.
Best is to double check it ;) |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1408 |
Ok, I've done some more measurements on the machine I took all the readings from in 2015*.
Sadly it looks like I terminated the signal before measuring after all. A pity; embarrassment aside, it would've been nice to obtain a tidier signal to fit the model to.
Here are some raw captures of eight white pixels in a row, plugged into nothing/a 1084ST/my TV, with none of the frame averaging or band limiting I applied to my measurements before trying to model them.
http://jamontoads.net/csdb/201710/20171105_8pix_white_untermina..
http://jamontoads.net/csdb/201710/20171105_8pix_white_1084ST.png
http://jamontoads.net/csdb/201710/20171105_8pix_white_Sony_KV-2..
Note that
- the first two don't even settle on the correct white level of 1.0v.
- they all take a similar amount of time to transition from black to white.
- the unterminated signal does indeed exhibit marginally more ringing than the other two; it dips back further below white after the overshoot than the others.
So Soci was right on that count; the signal's better behaved with a TV connected.
The above are all at the same scale, here's the TV one again magnified five times vertically.
http://jamontoads.net/csdb/201710/20171105_8pix_white_Sony_KV-2..
I'm now pretty confident my c64 was connected to my TV when I made my recordings.
* it's still waiting for me to solder some new RAM I sourced, but for now I can still type a white reversed space on a black screen. |
| |
soci
Registered: Sep 2003 Posts: 479 |
Thanks for the measurements!
It still overshoots, that's how it is then ;) I've played a bit with the signal modelling and come up with two relatively fast ones.
http://singularcrew.hu/temp/2017-11-05-225255_1360x768_scrot.png
The first one is without overshoot (green) and is simple. I've implemented it in r102.
http://singularcrew.hu/temp/ef27462f275dab5588632ffc6eefc6f2.png
http://singularcrew.hu/temp/a7d7938efdd1f4018ba90beb9e43b4a8.png
Rise and fall times are a bit too fast but otherwise the blur got too much. Anyway it's visible that the dithered part is darker now but not as much as it should.
The red with the overshoot I'll try sometime later. Not sure if it'll make much difference unless on extreme zoom (as on top).
Btw. these were still done on the composite output, right? Is it the same if the luminance is used instead? |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1408 |
Quoting sociThanks for the measurements!
You're welcome; thanks for querying the termination..
Quote:It still overshoots, that's how it is then ;) I've played a bit with the signal modelling and come up with two relatively fast ones.
Ah, nice work.
The overshoot's fairly subtle in practice, but knowing about it can be handy for tuning transitions by hand. I need to play with that some more.
Quote:
Btw. these were still done on the composite output, right? Is it the same if the luminance is used instead?
They were indeed done on composite. I think luminance was the same, but I'll check. |
| |
soci
Registered: Sep 2003 Posts: 479 |
I've checked with luminance only and it is very different it seems.
This is what I get for composite:
http://singularcrew.hu/temp/20171112_composite.jpg
I think it looks familiar. These are 1, 2, 3 and 4 pixel wide white bars on a completely black screen.
And now the same on luminance:
http://singularcrew.hu/temp/20171112_luma.jpg
The overshoot is hard to notice (almost nothing). That's why I was surprised ;)
I'll tune view64 to this as it aims to reproduce s-video (for now). |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1408 |
Thanks for those, Soci.
I finally got around to checking the circuit diagram in the back of the c64 programmer's reference guide (you know, that document I've only had a paper copy of on my bookshelf for thirty years, so it's not like I could check it until recently)...
...and there is indeed a simple RLC low pass filter just before the composite video pin of the audio/video connector. I fed 120Ω/3uH/220pF into http://sim.okawa-denshi.jp/en/RLCtool.php and got a overshoot in the step response very similar to what I'd been measuring.
Interestingly, the input into the RF modulator is from just before that filter is applied, so the output from that will be different again.
ugh, I really should measure the output pins of VIC directly at some point.. then maybe throw the analogue mess of circuitry that follows at a friend who makes digital equivalents of old audio filters for a living. |
| |
soci
Registered: Sep 2003 Posts: 479 |
I remember I've checked the VIC-II LUMA pin and it's similar to what comes out on the back as luminance, so slow ramp up with no overshoot. I didn't looked in detail as that's not what's displayed at the end. Maybe next month I can have another look... |