Possibility of sharper HDMI output via integer scaling?

https://github.com/MiSTer-devel/Main_MiSTer/wiki

Moderators: Mug UK, Zorro 2, spiny, Greenious, Sorgelig, Moderator Team

cacophony
Atari maniac
Atari maniac
Posts: 98
Joined: Sun Jul 22, 2018 11:14 pm

Possibility of sharper HDMI output via integer scaling?

Postby cacophony » Thu Oct 04, 2018 5:38 pm

Hi,

First, congratulations on an awesome project! It's gotten a lot of attention recently in the Analogue/AVS community, and there's even a bunch of new dedicated MiSTer chatting channels on the Classic Gaming discord. If anybody wants to join you can go here: https://discord.gg/EX57xnF
Many new people in that community have bought a DE10-nano in the past few days and there is a lot of new interest and excitement.

I was wondering if you would consider adding an option to enable purely integer based scaling to allow a sharper hdmi output with crisp (non-interpolated) individual pixels?

For 720p output that mean supporting:
3x tall by 3x wide (it does look a bit skinny)
3x tall by 4x wide (it does look a bit too wide)

For 1080p you could do:
4x tall by 5x wide (doesn't fill entire vertical resolution, but looks correct)
5x tall by 6x wide cropped where the 5x height of 1200 pixels gets cropped on top/bottom to fit in 1080p. In other words, 120 lines (or 12 lines of the original output on the top and 12 lines on the bottom) get cropped. This has the advantage of filling the screen and the image looks pretty close to correct.

Thanks again for the incredible work!

Locutus73
Captain Atari
Captain Atari
Posts: 179
Joined: Wed Feb 07, 2018 6:13 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby Locutus73 » Thu Oct 04, 2018 6:15 pm

I would prefer integer vertical scaling with horizontal interpolated scaling for maintaining correct aspect ratio.

Regards

Locutus73

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3143
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Possibility of sharper HDMI output via integer scaling?

Postby Sorgelig » Thu Oct 04, 2018 6:30 pm

it's more complex than you think.
While vertical resolutions don't vary much and have just few variations, the horizontal resolutions vary significantly.
pixel clock can be 5.5,6,7,8,10 MHz and many other. And regardless amount of pixels in horizontal, roughly aspect ratio is always 4:3.
So, even native resolutions in many cases require non-integer scaling to look proper.

Some time ago i've started to work on option where vertical resolution is set to max integer scaling and let the scaler stretch the horizontal resolution to make 4:3 or 16:9 aspect ratio. Basically it almost eliminates artifacts.
I didn't finish it yet, as i lave little interest in it.

User avatar
SmokeMonster
Atarian
Atarian
Posts: 9
Joined: Wed Oct 03, 2018 2:26 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby SmokeMonster » Thu Oct 04, 2018 7:07 pm

I would love to see this option too. Incredible work with everything you do Sorgelig.

cacophony
Atari maniac
Atari maniac
Posts: 98
Joined: Sun Jul 22, 2018 11:14 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby cacophony » Thu Oct 04, 2018 7:51 pm

Sorgelig wrote:it's more complex than you think.
While vertical resolutions don't vary much and have just few variations, the horizontal resolutions vary significantly.
pixel clock can be 5.5,6,7,8,10 MHz and many other. And regardless amount of pixels in horizontal, roughly aspect ratio is always 4:3.
So, even native resolutions in many cases require non-integer scaling to look proper.

Some time ago i've started to work on option where vertical resolution is set to max integer scaling and let the scaler stretch the horizontal resolution to make 4:3 or 16:9 aspect ratio. Basically it almost eliminates artifacts.
I didn't finish it yet, as i lave little interest in it.


Thanks for the response! It sounds like there would lots of interest in the vertical integer scaling approach you mentioned if that’s something you’d consider revisiting.

Locutus73
Captain Atari
Captain Atari
Posts: 179
Joined: Wed Feb 07, 2018 6:13 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby Locutus73 » Fri Oct 05, 2018 12:22 am

Sorgelig wrote:Some time ago i've started to work on option where vertical resolution is set to max integer scaling and let the scaler stretch the horizontal resolution to make 4:3 or 16:9 aspect ratio. Basically it almost eliminates artifacts.

IMHO that would be terrific, wonderful. Even a max integer scaling +1 option would be cool and would lead to some acceptable overscan.

Sorgelig wrote:I didn't finish it yet, as i lave little interest in it.

But we would love you more than already we do!!! :lol:



Regards.

Locutus73

kitrinx
Atariator
Atariator
Posts: 26
Joined: Wed Sep 26, 2018 6:03 am

Re: Possibility of sharper HDMI output via integer scaling?

Postby kitrinx » Fri Oct 05, 2018 1:36 pm

I also would love to see integer scaling. Right now, to get a good picture I have to use the analog out to my OSSC, only to scale it and convert it back to digital again. I think the quality of the scaling may be a barrier to entry for many, so it may not be a frivolous thing to consider working on. It's going to be especially important for streamers and people who want to show off all the outstanding work that has gone into the MiSTer project already.

cacophony
Atari maniac
Atari maniac
Posts: 98
Joined: Sun Jul 22, 2018 11:14 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby cacophony » Sun Oct 07, 2018 4:50 pm

edit: I posted incorrect info, so I'm removing...

cacophony
Atari maniac
Atari maniac
Posts: 98
Joined: Sun Jul 22, 2018 11:14 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby cacophony » Thu Oct 11, 2018 5:19 pm

I just saw the newest Genesis changelog (two days old), which mentions: "Adjust scaler parameters for clearer picture."
which sounds like it's due to this: https://github.com/MiSTer-devel/Genesis ... c19cc2043d

This has made a huge difference in Genesis HDMI sharpness so thanks!

A couple questions:

1. Is there a nearest neighbor option which might be even better?
2. Would it make sense to do the same type of improvement for any other console releases?

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3143
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Possibility of sharper HDMI output via integer scaling?

Postby Sorgelig » Thu Oct 11, 2018 6:58 pm

nearest neighbor is good only for integer scaling. For non-integer scaling it looks like rubbish.
The quality of scaling increase in this direction: nearest neighbor -> bicubic -> polyphase

Locutus73
Captain Atari
Captain Atari
Posts: 179
Joined: Wed Feb 07, 2018 6:13 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby Locutus73 » Thu Oct 11, 2018 10:47 pm

Discussions about MiSTer are becoming a topic trend on Classic Gaming Discord https://discord.gg/EX57xnF since the platform is getting momentum after some SmokeMonster videos... people observerd that HDMI video quality gets better enabling line doubling, probably because the scaler has to rescale by a littler factor, something coherent with old Sorgelig plan about implementing the maximum possible integer scaling for any resolution. Another thing that is getting noticed is that the scaler seems to introduce “ringing” artifacts as you can see in this picture
9E48D92F-6895-4B52-B1D1-5EDA0AC3BACE.jpeg
Any idea about this issue?

Thank you in advance.
Best regards.

Locutus73
You do not have the required permissions to view the files attached to this post.

cacophony
Atari maniac
Atari maniac
Posts: 98
Joined: Sun Jul 22, 2018 11:14 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby cacophony » Fri Oct 12, 2018 1:52 am

Here's a visual illustration of the differences:
Image
To see the difference, select the image to view at 100%

It really illustrates the massive sharpness improvement of the recent change

Locutus73
Captain Atari
Captain Atari
Posts: 179
Joined: Wed Feb 07, 2018 6:13 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby Locutus73 » Fri Oct 12, 2018 6:58 am

cacophony wrote:It really illustrates the massive sharpness improvement of the recent change

Yes, awesome improvement in the Genesis core, but ringing is still there and seems to be system wide so, probably, related to some filtering in the scaler.

Regards.
Locutus73

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3143
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Possibility of sharper HDMI output via integer scaling?

Postby Sorgelig » Fri Oct 12, 2018 12:04 pm

Artifacts are not avoidable with free scaling. If you want to reduce artifacts, enable force scandoubler in INI and use lowest HDMI resolution. Your monitor/TV will upscale it further with possible better quality.

Locutus73
Captain Atari
Captain Atari
Posts: 179
Joined: Wed Feb 07, 2018 6:13 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby Locutus73 » Fri Oct 12, 2018 3:13 pm

Sorgelig wrote:Artifacts are not avoidable with free scaling. If you want to reduce artifacts, enable force scandoubler in INI and use lowest HDMI resolution. Your monitor/TV will upscale it further with possible better quality.

Yeah, but that specific "ringing" artifact is avoidable with specific implementations of “free” non-integer interpolation scaling. I’m not asking for a new implementation, I know the project is open source and interest driven, I’m just reasoning together. There are documented interpolation implementations (i.e. Analogue Super NT) which don’t introduce ringing artifacts. Ok, it’s not fair, that’s a commercial product, but see above, just reasoning. Regarding TV scaler, I’d prefer to avoid it at all and fetch HDTV with the native panel resolution. HDTV scalers are aimed to movie or TV contents and usually apply processing which looks good for that kind of content, but looks horrible with retro gaming content. So the superiority in picture quality of native panel output from things like OSSC, Analogue Super NT and… MiSTer.

Regards

Locutus73

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3143
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Possibility of sharper HDMI output via integer scaling?

Postby Sorgelig » Fri Oct 12, 2018 3:33 pm

So, you compare Analog Super NT which is tweaked for single core and most likely just use integer scaling? As far as i know it uses HQ2x and HQ3x scaling - both are integer. HQ2x is designed for exactly 2x2 scaling and it's implemented in MiSTer. HQ3x i didn't look - probably it's 3x3 scaling. Even with HQ2x you need 4x pixel clock which for some cores close to maximum possible clock. 3x will need 9x pixel clock which will be beyond the clock possible for core.

And by the way, if someone would contribute his knowledge of scaling in HDL code, then it would appear in the cores if it will be applicable. It won't appear from just wishes.

Locutus73
Captain Atari
Captain Atari
Posts: 179
Joined: Wed Feb 07, 2018 6:13 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby Locutus73 » Fri Oct 12, 2018 5:00 pm

Sorgelig wrote:So, you compare Analog Super NT which is tweaked for single core and most likely just use integer scaling? As far as i know it uses HQ2x and HQ3x scaling - both are integer. HQ2x is designed for exactly 2x2 scaling and it's implemented in MiSTer. HQ3x i didn't look - probably it's 3x3 scaling. Even with HQ2x you need 4x pixel clock which for some cores close to maximum possible clock. 3x will need 9x pixel clock which will be beyond the clock possible for core.

No man, don’t get me wrong, I wasn’t comparing Super NT to MiSTer, it wouldn’t be fair to compare a commercial product to an open source project; don’t be always on your guard and don’t take everything as personal. I was using Super NT as a practical example in order to show that ringing artifacts are not a necessary evil for scaling. Anyway, just in order to clarify some aspects of SNT: it has various optional scaling filters like HQ2X, HQ3X, HQ4X, Scale 2X, Scale 3X, but they’re disabled by default and I don’t think many people use them; and no, it doesn’t just perform integer scaling. SNT takes the original 256x240 PPU image (same as NES) and scales it to an arbitrary user defined window of any width and height; you can choose whatever weird target window both integer scaled or not, and you can optionally activate independent horizontal and vertical interpolation which introduces some softness in the image, but reduces shimmering during scrolling (with non integer scaling factors). In any case you don’t get ringing artifacts.

Sorgelig wrote:And by the way, if someone would contribute his knowledge of scaling in HDL code, then it would appear in the cores if it will be applicable. It won't appear from just wishes.

Fair, read my previous post where I highlighted the open source nature of the project. But anyway, few people code HDL and analyzing things and sharing ideas is always a form of contribution. By the way, just two brain farts of mine:
  1. Which are the parameters and optional settings of the proprietary scaler used by MiSTer? I might be wrong, but I think these ringing artifacts are caused by band limiting filters. I saw such artifacts caused by high pass filters like ones for sharpening images.
  2. Would you be contrary if anyone hypothetically would design a fully open source scaler in order to replace the proprietary one in MiSTer?

Many thanks in advance
Best regards

Locutus73

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3143
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Possibility of sharper HDMI output via integer scaling?

Postby Sorgelig » Fri Oct 12, 2018 6:34 pm

The scaling algo used in MiSTer is Polyphase with LANCZOS_2 coefficients.
Probably, custom coefficients with correct amount of phases and taps can reduce artifacts. There is even adaptive algo which can use different coefficients on detected edges. If someone wants to play with it and find a better coeffs, then i would be glad.
Actually HDL knowledge is almost not required besides the knowing how to start compilation :)
It's mostly math than HDL.

Locutus73 wrote:Would you be contrary if anyone hypothetically would design a fully open source scaler in order to replace the proprietary one in MiSTer?

Why i should be contrary? Of course I'll welcome it if it will be better than current one.

cacophony
Atari maniac
Atari maniac
Posts: 98
Joined: Sun Jul 22, 2018 11:14 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby cacophony » Sat Oct 13, 2018 5:45 pm

Sorgelig wrote:The scaling algo used in MiSTer is Polyphase with LANCZOS_2 coefficients.
Probably, custom coefficients with correct amount of phases and taps can reduce artifacts. There is even adaptive algo which can use different coefficients on detected edges. If someone wants to play with it and find a better coeffs, then i would be glad.
Actually HDL knowledge is almost not required besides the knowing how to start compilation :)
It's mostly math than HDL.


Thanks for the info!

Can you point out specific values that you think might be worthwhile to try tweaking? I've been unable to find documentation on the parameters within this block: <module name="Scaler" kind="alt_vip_cl_scl" version="17.0" enabled="1">
so any guidance on what matters would be helpful.

Are there compilation instructions or a tutorial that can be used by somebody looking to compile a core for the first time?

Random alternative thought: If there was an easy way to temporarily allow the parameters to be adjusted within a config/ini file, then maybe lots of people could experiment with different values without needing to do a recompilation?

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3143
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Possibility of sharper HDMI output via integer scaling?

Postby Sorgelig » Sat Oct 13, 2018 11:54 pm

Do not edit qsys file manually. You have to load QSys designer in Quartus. Usually double click on qsys file inside the Quartus will open the QSys.
It's not easy to provide the quick guide for Quartus/Qsys usage. Please use google and docs provided by Altera/Intel. It's not like 5 mins play and it's ready. You need to spend some time and patience.

Locutus73
Captain Atari
Captain Atari
Posts: 179
Joined: Wed Feb 07, 2018 6:13 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby Locutus73 » Sun Oct 14, 2018 7:48 am

Sorgelig wrote:Do not edit qsys file manually. You have to load QSys designer in Quartus. Usually double click on qsys file inside the Quartus will open the QSys.
It's not easy to provide the quick guide for Quartus/Qsys usage. Please use google and docs provided by Altera/Intel. It's not like 5 mins play and it's ready. You need to spend some time and patience.

Thank you, this is a good hint and starting point. How long it roughly takes to compile a core like NES or Genesis? Just a ballpark.
Is there a little core you suggest to use in order to perform a change scaler parameters-compile-grab a screenshot-evaluate artifacts-repeat test routine minimizing compile time?

Thank you in advance.

Locutus73

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3143
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Possibility of sharper HDMI output via integer scaling?

Postby Sorgelig » Sun Oct 14, 2018 11:04 am

Arcades like pacman should be faster to compile.

cacophony
Atari maniac
Atari maniac
Posts: 98
Joined: Sun Jul 22, 2018 11:14 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby cacophony » Mon Oct 15, 2018 2:14 am

Sorgelig wrote:nearest neighbor is good only for integer scaling. For non-integer scaling it looks like rubbish.
The quality of scaling increase in this direction: nearest neighbor -> bicubic -> polyphase


Rysha on the classic gaming discord compiled a build with nearest neighbor, and the consensus over there is that it looks much better. Razer sharp with no ringing, and shimmer on movement is not noticeable in actual gameplay. I just played with it and it looks spectacular!

Specifically, here is the only change she made:
<parameter name="ALGORITHM_NAME" value="NEAREST_NEIGHBOUR" />

Everything else was left the same.

Here are some comparison shots:

Image
Polyphase with forced scandoubler on
(direct link: https://cdn.discordapp.com/attachments/ ... ewcore.PNG)

Image
Nearest Neighbor with forced scandoubler on
(https://cdn.discordapp.com/attachments/ ... caling.PNG)

Image
Nearest Neighbor with forced scandoubler off
(https://cdn.discordapp.com/attachments/ ... le_off.PNG)

And here's one more nearest neighboor example:
https://cdn.discordapp.com/attachments/ ... 258/s3.PNG

Can we have nearest neighboor be the default? Or maybe an option/toggle/config to use nearest neighbor instead ?

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3143
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Possibility of sharper HDMI output via integer scaling?

Postby Sorgelig » Mon Oct 15, 2018 2:49 am

Scaling algo is set at compile time. There is no way to change it in runtime.
As for quality - it depend on picture. The sample you show is kind of photo where separate pixels aren't matter.
But if HDMI resolution will be smaller and there will be text, then you will see that some scaled pixels are larger than other and picture (text) is distorted.

cacophony
Atari maniac
Atari maniac
Posts: 98
Joined: Sun Jul 22, 2018 11:14 pm

Re: Possibility of sharper HDMI output via integer scaling?

Postby cacophony » Mon Oct 15, 2018 3:05 am

Sorgelig wrote:Scaling algo is set at compile time. There is no way to change it in runtime.
As for quality - it depend on picture. The sample you show is kind of photo where separate pixels aren't matter.
But if HDMI resolution will be smaller and there will be text, then you will see that some scaled pixels are larger than other and picture (text) is distorted.


The number of people using 480p HDMI output is probably tiny, but I would imagine pretty much everyone who uses 720p or 1080p HDMI would appreciate the sharper image with zero ringing :D


Return to “MiSTer”

Who is online

Users browsing this forum: brNX, remowilliams, SegaMan and 9 guests