What's new

Worklog LumaDoub: An Open Source Line-Doubler and Transcoder

Shank

Moderator
Staff member
.
.
Joined
Jan 31, 2016
Messages
1,343
Likes
2,882
Portables
6
LumaDoub is a community project with the goal to create an open-source, low cost line doubler and transcoder solution. The vision for this project is not to create a specific product, but a framework and toolkit to be integrated in many other projects.

In its most basic state, LumaDoub should be able to:

Input:
-Accept Composite/Svideo/Component video
-Accept 240p or 480i (no 480p or greater)
-Auto detect NTSC, PAL, SECAM, etc.

Output:
-Component YPbPr
-Analog RGB (RGBS, VGA, etc)
-Simultaneous Composite and SVideo
-Line doubled 480p or passthrough 240p/480i


I expect the board should be quite simple, compact, with a low BOM and low power consumption.

I hope the output stage can be modular. For example, individuals may be able to add a second encoder chip for simultaneous video output of the lag free line doubled 480p to both an internal VGA screen, and a video-out port (like HDMI or possibly USB C).

I have yet to test this, but I hope we could process RGsB as YPbPr on both input and output to line double 15khz RGB to 31khz VGA. Will have to see how effective this is in time.

Once we get the basics working we can then see how far the project can be pushed.

Let's discuss where we are, and why it is needed...

In an ideal world, every portable would use direct drive for video. Direct drive FPGA boards are the endgame for video signal chain in portables. However, they must be custom designed for both for the individual console itself, and for the specific screen. For many builds, a direct drive solution is neither feasible nor practical.

For builds where direct drive isn't feasible, analog video is usually our only option. For the ever popular Wii portable, it's 480p output combined with the VGA patches yield some pretty good results.

But once you dive into 240p consoles, things start to get rough. The Nintendo 64, for example has 3 options for video output: Composite, Svideo, and RGBS. RGBS would be the ideal choice of the three (assuming you have the right revision and perform a mod), but almost no screens accept 15khz (240p) RGBS. Svideo is a step above composite, but suffers the same compatibility issue: almost no screens accept it. This leaves composite as our only viable option for video on most N64 portables. This is applicable for most 240p consoles, like the PS1, SNES, and Genesis.

Composite video is sophisticated under the hood, but in summary, the brightness information (luma) and color information (chroma) are mixed and squished down a single wire. They then need to be separated on the other side, usually through a comb filter. This process is not lossless, and results in a significant loss in fidelity. How much fidelity is lost is also dependent on the quality of the composite encoding and decoding circuitry. In this regard, you are at the mercy of the composite video decoding circuitry of your display, and results can vary.

Your screen has decoded your 240p composite video signal, but the problems don't end there. The standard for composite video is 480i, not 240p. To oversimplify, 240p takes advantage of trickery in the analog domain to send an off-spec video signal to display a progressive, lower resolution image. On old school CRTs, the timings were within tolerance, and the images was blasted onto the screen. For modern digital displays, most screens are not designed to recognize this off-spec 240p signal, and will instead interpret it as 480i. This means the image will be incorrectly processed, and the screen will attempt to deinterlace the image. This can result in persistent visual artifacts as the image is incorrectly scaled, as well as add latency (lag, usually over 1 frame) to your signal chain.

This solution is built using 3 primary chips: a decoder, an encoder, and a microcontroller to control them.

ADV7280A (Analog decoder and line doubler)

This inexpensive and versatile chip is capable of accepting and digitizing Luma-based video signals (Composite, Svideo, and Component) from every region (NTSC, Pal, SECAM, etc). It can pass through the signals as 240p/480i, or line double it to 480p with effectively zero lag (I have played duck hunt on a 480p crt using an ADV7280 based line doubler). The older version of this chip, the ADV7280, is the primary engine under the hood of many products such as the RetroTink 2x line of products. This chip is extremely versatile, with so many settings to tweak and tune through registers.

ADV7391 (Video encoder)

The ADV7280A spits out a digital video signal into the ADV7391. The ADV7391 is capable of converting that digital video stream to either analog RGB, or Component (YPbPr), depending on which register you set. Hsync and Vsync are available as well. The result is you have access to lag free, line doubled 480p Component or VGA output to connect to screens.

Microcontroller (tbd)

Both of the Analog Devices chips are configured using an i2c bus. Therefore, we need a microcontroller to configure them. The chips only require a few commands to get up and running, but have lots of customizability. For early testing and development, my bench setup will be using an RP2040, but it is likely overkill.

This exact same "ADV7280A + ADV7391 + Microcontroller" setup is utilized on Analog Device's evaluation board.
EVAL-ADV7280AEBZTOP-web.png


The evaluation board includes schematics that seem pretty simple and straightforward. This could easily be replicated on a custom PCB.

ADV7280A Schematic (input/decoder/adc)
JMQOelM.png


ADV7391 Schematic (output/encoder/dac)
epdxCqJ.png


The eval board is almost $200, but I have found an alternative. The McBazel ODV2 looks like a retrotink 2x clone from the outside, but on the inside, it's far closer to the original evaluation board. While both use a 7280 for the analog decoder, the ODV utilizes a 7391 for component video output instead of HDMI, as well as a different microcontroller.

PXL_20240906_003829867.jpg

Here is my bench setup.
For now I have lifted the i2c pins of the onboard mcu and run them to a switch. This allows me to switch back from the pico to the onboard MCU to do a "sanity check" and make sure the board is still functional.

For now, the goal is to figure out i2c communication with the chip. Once we can take control and get video output, we can start to experiment with registers, and design a new PCB layout.
 
Last edited:
Joined
Dec 29, 2016
Messages
99
Likes
36
Super excited for this, looking a cheap way to hook Wii’s to VGA for a video game literacy unit in the media arts class I teach
 

Shank

Moderator
Staff member
.
.
Joined
Jan 31, 2016
Messages
1,343
Likes
2,882
Portables
6
Super excited for this, looking a cheap way to hook Wii’s to VGA for a video game literacy unit in the media arts class I teach
This would be a suboptimal way to do so, as it will only accept 480i/240p for the input. You would want a YPbPr to VGA transcoder.

Additionally, the plan for now is an open source project to be integrated and reused elsewhere, rather than a complete product to sell. The primary goal here isn't to make something to sell, but to put some tools out there to push the scene forward.
 

Shank

Moderator
Staff member
.
.
Joined
Jan 31, 2016
Messages
1,343
Likes
2,882
Portables
6
Exciting progress today.

After several days of troubleshooting, we finally have control of the chips through the i2c bus. (We had a very weird issue with the reset pin and command). Once we got the first example script working, and video on the screen, we could finally experiment with flipping registers.
Here we have 480i RGsB output, using the internal color bar test pattern output. This is one of several configurable options for output when no input is recognized.
PXL_20240910_195757634.jpg

RGsB, also known as "Sync on Green" or "SoG" is RGB video, where the sync is, or course, on the green line. This is similar to how, for YPbPr, sync is on the Luma (aka "Y", aka "the green plug") line. This is done because DAC only has 3 outputs. The chips also have a HSync and VSync lines running between them, which can be tapped for RGBHV, also known as VGA. The separate, composite sync for RGBS could be created in a number of ways; such as extracting it from the green line, or combining the separate H and V sync lines.


Flipping a few more registers, we get composite input, RGsB output.

PXL_20240910_202609157.MP.jpg


Neato, what about composite output?
PXL_20240910_211339615.jpg

Trippy! Here's what I think is going on here. When the ADV7391 (DAC, output chup) is outputting 240p composite, something with the chroma phase/timings messes up. 240p component/rgb output are fine. 480i composite output is fine. It's just specifically the output combination of composite output and 240p output.

This can be fixed by flipping a specific register for progressive SD. However, doing so also has the consequences of forcing all 15khz outputs to be 240p. So you would want to only enable this mode specifically when outputting 240p composite signals. I will say, this "forcing 240p" is a feature I have wanted on devices before, so it would be a cool thing to integrate.

We got composite and component inputs working. Also confirmed composite, component, and RGB outputs. Haven't tested svideo yet, but should be no issue.

Excited to mess with the line doubling and the internal anti-aliasing filter that looks like vaseline smeared on the screen. Seems that aa filter works differently than what's documented, so I'll need to look into that.

We have also set up a (private for now) git repository, and I have begun work on a custom dev board for this project. As for why I'm saying "we" for many of these projects, that's because I have a secret weapon working on this project with me. I'll discuss that in a future post.

Super exciting. So much potential in these little chips. Excited to keep working on this.
 

1hedu

.
Joined
Sep 21, 2024
Messages
11
Likes
0
Incredible. Stars really aligned I've been working on this same thing for about as long as this thread. It's kind of shifted and evolved but I'm looking for

-Accept Composite/Svideo/Component video/RGsB/RGBS(csync)
-Accept 240p or 480i (no 480p or greater)
-Auto detect NTSC, PAL, SECAM, etc.

Output:
-Line doubled 480p

I'm pretty much learning as I plan, and have ordred a few versions of BOMs for this, none have arrived, but realized where I thought for a while maybe I could try to just kick up hsync 31khz to make 480i display over vga, I should give up on that. Even if somehow it could work, the uncertainty isn't worth it.

Anyway I'd considered these chips, glad to see you've thought of an elegant solution. Ordered some How can I help?
 

Shank

Moderator
Staff member
.
.
Joined
Jan 31, 2016
Messages
1,343
Likes
2,882
Portables
6
Appreciate the interest! I will likely need help once I get the ball rolling.

For now, I'm finishing up the design of a custom development board. It'll have lots of switches and solder jumpers to test and change all sorts of features and options. Primary pico and dev pico on board, lots of switches, RGB to YPbPr transcoder, regulators with shunt resistors to measure power consumption per rail... Lots of fun stuff. Will be super useful for testing.

RJKJ6NA.png
 

1hedu

.
Joined
Sep 21, 2024
Messages
11
Likes
0
Roger that, I'll be here.

Love the pico. Looking great, very exciting!
 

Shank

Moderator
Staff member
.
.
Joined
Jan 31, 2016
Messages
1,343
Likes
2,882
Portables
6
Hey! Any news?
Hello! Not much news on this front. I have the boards and parts in hand, but need to take the time to finish assembling one. Not sure when I will get around to it, but hopefully soon!
 

1hedu

.
Joined
Sep 21, 2024
Messages
11
Likes
0
I feel that. I'm in the same boat with plenty of things.
 

1hedu

.
Joined
Sep 21, 2024
Messages
11
Likes
0
Meanwhile, wonder if you could help. It's a vga input that I'm working on strapping-on a scart(rgb csync) input to. Basically I need the gbs8200 but it's far too large. I got a sync-splitter ic, so I need to make the most compact rgbhv 15khz to rgbhv 30khz circuit possible.

"I have yet to test this, but I hope we could process RGsB as YPbPr on both input and output to line double 15khz RGB to 31khz VGA."

I thought the adc chip was only for luma-based signals. How did you imagine this working?
 

Shank

Moderator
Staff member
.
.
Joined
Jan 31, 2016
Messages
1,343
Likes
2,882
Portables
6
Meanwhile, wonder if you could help. It's a vga input that I'm working on strapping-on a scart(rgb csync) input to. Basically I need the gbs8200 but it's far too large. I got a sync-splitter ic, so I need to make the most compact rgbhv 15khz to rgbhv 30khz circuit possible.

"I have yet to test this, but I hope we could process RGsB as YPbPr on both input and output to line double 15khz RGB to 31khz VGA."

I thought the adc chip was only for luma-based signals. How did you imagine this working?
YPbPr and RGB are electrically similar and compatible signals. It is the same data, but a matrix calculation away. On RGB equipment, you can pass through YPbPr signals, and vice versa. If you were to send it an RGB signal while it was in YPbPr mode, and try to spit it out as Composite or Svideo, your colors would be incorrect, because it is attempting to convert it, and the "conversion" math is wrong. If you did the same (RGB signal into YPbPr input) with an RGB output, it would still be wrong, because the conversion math would again be wrong. However, if you were to set the BOTH the input AND output to YPbPr, it would not be doing any color or colorspace conversion. So in theory, if you were to configure it this way, and send RGB into the YPbPr input, you SHOULD get RGB out of YPbPr output since it will not be trying to convert the colors, just other non-color-conversion/encoding stuff like line doubling, antialiasing, and sync processing. For line doubling (bob deinterlacing), it is buffering the line and spiting it out twice, and not performing any advanced picture processing on the image.
 

1hedu

.
Joined
Sep 21, 2024
Messages
11
Likes
0
Then on the dac, it'd be rgb in and out right?

Edit: Realized we are feeding it RGsB, so that's^ assuming we can still get H and V from the adc while it's in ypbpr mode. Maybe it does nothing to the sync though. So then I'd need a lmh1980 to split the sync from Gs, feed that into the dac, rgb in and out.
 
Last edited:

Shank

Moderator
Staff member
.
.
Joined
Jan 31, 2016
Messages
1,343
Likes
2,882
Portables
6
Then on the dac, it'd be rgb in and out right?

Edit: Realized we are feeding it RGsB, so that's^ assuming we can still get H and V from the adc while it's in ypbpr mode. Maybe it does nothing to the sync though. So then I'd need a lmh1980 to split the sync from Gs, feed that into the dac, rgb in and out.
Please do not double post. Use the edit button instead if you need to add more after your previous message.

Sync processing takes place regardless of if color processing is taking place. It is necessary for line doubling, after all. If I am correct about the RGB passthrough line doubling working, then RGsB in to RGBHV out should be no issue at all.

If the passthrough doubling does not work, I have other ideas to add full support for RGB. One is a ton of work and may not be possible, while the other would add to the size and BOM. One step at a time though.
 

1hedu

.
Joined
Sep 21, 2024
Messages
11
Likes
0
Ok my bad.

Let me know if I understand correctly. It does have to be RGsB right? Since sync is expected on the Y in YPbPr mode?
 

Shank

Moderator
Staff member
.
.
Joined
Jan 31, 2016
Messages
1,343
Likes
2,882
Portables
6
It does have to be RGsB right? Since sync is expected on the Y in YPbPr mode?
Correct. For my line double passthrough idea to work, it would need to be RGsB, or sync on green. Because it would be treating the "green" line like luma, where sync would be. So you would need to extract sync (assuming its sync on composite/luma), attenuate it with a resistor (assuming its TTL), and inject it into the green line. I think this can be done with a simple capacitor, but I suspect there are probably better means to accomplish this.
 

Shank

Moderator
Staff member
.
.
Joined
Jan 31, 2016
Messages
1,343
Likes
2,882
Portables
6
PXL_20250212_052533231.MP.jpg

Finally sat down to finish assembling the PCB! No obvious issues, so it was time to start on the software side of things.

I have a new secret weapon for this project: a wonderful, brilliant girlfriend who is a full stack software developer.

PXL_20250213_012125471.jpg

Hello World!

It works! So happy I didn't make any major mistakes that require a redesign (at least not yet).

So with that we got to work modifying the code from the previous test fixture to work on this new development board.

I went overkill for this dev board. It has jumpers, headers, and breakouts for pretty much everything I could want to do with these 2 chips. 8 dip switches for features, 8 dip switches for testing stuff like flipping bits in registers, 8 LEDs... Lots of useful stuff for testing. We chose the pico because it is a very easy, versatile, and well documented platform environment. One pico runs the code, the other is for debugging. Once the code is complete and released, porting it over to other MCUs should be pretty straightforward.

PXL_20250213_025008565.jpg

Tonight we were able to get the following working:
-YPbPr input
-SVideo input
-Composite input

-YPbPr Output
-SVideo Output
-Composite Output
-RGsB output (h and v are present but haven't tested)

We also got "Force 240p" working, which makes the output of a 480i image be forced to not alternate fields. I hope to implement auto detection of 240p to force the output to 240p automatically, and keep the ability to force 240p as a feature for the niche applications that demand it.

I was also able to confirm that passing through RGsB input to RGB output works in YPbPr-in/YPbPr-out mode. This means non-transcoding line doubling of 480i/240p RGsB to RGBHV is likely to work on this circuit.

Line doubling, Vaseline mode (the smoothing Anti aliasing filter on this chip some people like) and notch filter settings (for composite video) have not been implemented yet. The current plan is to make our way through the features, getting things working and all that stuff. Once we have that done, we will rebuild the software to be clean, efficient, and easy to parse before releasing it.

Additionally, @YveltalGriffin helped me integrate his open source regulators onto my dev board so I can measure the precise power consumption on each rail individually. I chopped each of the five 1.8v rails between the two to run on five different regulators, allowing me to measure power consumption of each part of each chip precisely. For those curious, I tested 480i-YPbPr to 480i-RGsB, and the total power draw was .63w, not including the raspberry pi picos.

So that's progress this far. An exciting and successful night of progress. I'm really excited to get this out there and see what the scene does with it.
 
Top