Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st August 2019, 12:12   #21  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
Hello,

I have a question. I noticed something interesting. It's about a special scaling algorithm that I don't know

It looks like something between PointResize and BilinearResize, but I think it's sharper than a bilinear filter.

Here is a screenshot of the game Sonic Mania with the "None" filter (yes, it is a filter) :



The native resolution of the game is "424 x 240" and then the picture is scaled to a resolution of "1920 x 1080".


I thought that this filter was equivalent to this script :

Quote:
ImageSource("H:\source.png").convertToRGB24
PointResize(1696, 960)
BilinearResize(1920, 1080)



But it's a bit different as you can see here :



Strange no ?

It looks sharper than the bilinear filter, but it's not a nearest neighbor filter. So what could it be ?

Here is the source image :




It's funny, because some days ago, I wanted to ask if it's possible to have something between PointResize and BilinearResize, long before I have noticed this !

So, I wanted someting that it's pefectly egal to PoinResize if I upscale a picture 2X, 3X, etc., but with interpolation (but nos as blurry as a bilinear filter and without ringing) if it's for example 2,5X or 4,8X or anything else. So, a kind of linear point resizer... I was wondering if it's possible. And now, I noticed this ! Strange coincidence !


Thanks for your help !


Edit :

You can see better the difference here !

The picture in-game zoomed to 800% :



My reproduction :



A GIF animation to compare :




So, how does it work ?

Last edited by SuperLumberjack; 21st August 2019 at 13:39.
SuperLumberjack is offline   Reply With Quote
Old 21st August 2019, 15:06   #22  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
The other strange thing is with the fullscreen mode in 720p for example.

In windowed mode with a window size of 3X, the resolution is 1272 x 720 :



So in fullscreen mode, we get a resolution of 1280 x 720. We could have expected that the picture is simply stretched with a bilinear filter. But it isn't exactly the case as you can see here :



Comparison :



They used another technic to keep a natural image I think, instead of only using a horizontal interpolation. I really don't know how they did !

The source image if you have an idea :




Some persons noticed the same thing too :

https://www.reddit.com/r/gamedev/com...s_like_shovel/
https://www.reddit.com/r/gamedev/com...caling_shader/

Edit : It seams that is an association of the Nearest Neighbor filter and the Bilinear filter, as I tried, but it's strange, because the Bilinear filter is different ! And I don't understand the capture of the game in fullscreen mode in 720p, because apparently, there is a horizontal interpolation, but a vertical interpolation too.

Edit 2 : I understood for the 720p in fullscreen. The source image is scaled 4x with Nearest Neighbor (1696 x 960) and then downscaled to the resolution of 1280 x 720. But the bilinear filter still looks different... !


Thanks for your help !

Last edited by SuperLumberjack; 21st August 2019 at 15:46.
SuperLumberjack is offline   Reply With Quote
Old 21st August 2019, 16:14   #23  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
So my only question now is : why are these two Bilinear algorithms different ?

It seems that some pixels are shifted differently in fact.

Shouldn't they be exactly identical ? Because bilinear is... linear no ?

So what is the most correct bilinear filter ?


I'm curious to know !


Thanks for your answer !
SuperLumberjack is offline   Reply With Quote
Old 21st August 2019, 17:01   #24  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
OK. Someone told me that :

"The bilinear filter is handled by the GPU in Sonic Mania, so individual GPUs might have slight differences in how they sample texels."

Solved !
SuperLumberjack is offline   Reply With Quote
Old 22nd August 2019, 19:29   #25  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
I still have a question !

Is there a way to get the exact same bilinear filter than my GPUs use ?

Because apparently, my GPU scaling is exactly the same for the Nvidia GPU of my laptop and the AMD GPU of my desktop computer.

But with the bilinear filter of AviSynth, the blended pixels seems juste shifted with the opposite coordinates trough the X and the Y axes

SuperLumberjack is offline   Reply With Quote
Old 22nd August 2019, 20:05   #26  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
Quote:
Originally Posted by SuperLumberjack View Post
the blended pixels seems juste shifted with the opposite coordinates trough the X and the Y axes
What?
__________________
madVR options explained
Asmodian is offline   Reply With Quote
Old 22nd August 2019, 20:53   #27  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Try:

Code:
PointResize(1696, 960)
BilinearResize(1920, 1080, src_top = 0.5, src_left = 0.5)
with various values, positive and negative, for src_top and src_left.

Though really I think you might be on a fool's errand. There's so little difference between any of these. One sprite when rescaled may already look exactly the same on both, if it happens to occupy a different position on screen at the time.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 22nd August 2019, 21:11   #28  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
Quote:
Originally Posted by Asmodian View Post
What?
Yes, it's a bit hard to explain !

Maybe you will understand better with these 2 images :



The 2nd is a animated GIF :




Quote:
Originally Posted by wonkey_monkey View Post
Try:

Code:
PointResize(1696, 960)
BilinearResize(1920, 1080, src_top = 0.5, src_left = 0.5)
with various values, positive and negative, for src_top and src_left.

Though really I think you might be on a fool's errand. There's so little difference between any of these. One sprite when rescaled may already look exactly the same on both, if it happens to occupy a different position on screen at the time.
Thank you ! I will try

Yes, I know it's a bit absurd. But it's for the quality of the reproduction. The depth looks a bit different.
SuperLumberjack is offline   Reply With Quote
Old 22nd August 2019, 21:36   #29  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
It's almost (minor differences with the RGB values of the interpolated pixels) that with :

Quote:
PointResize(1696, 960)
BilinearResize(1920, 1080, src_top = -0.25, src_left = -0.25)


But why are they these differences between bilinear algorithms ?

I would like to understand. Which filter is correct ?
SuperLumberjack is offline   Reply With Quote
Old 22nd August 2019, 21:45   #30  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,493
Neither is "correct." A choice has to be made for the "origin" when upscaling like this, and it's pretty much arbitrary. There may be other differences, but those too will probably be arbitrary.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 22nd August 2019, 22:11   #31  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
OK. Thank you for these informations !

In fact, I found the (almost) good values with :

Quote:
BilinearResize(1920, 1080, src_top = -0.20, src_left = -0.20)
It can vary from 1 or 2 units for the RGB values for a same pixel, but I noticed the same thing between the scaling of my Nvidia GPU and my AMD GPU.

But apparently, Nvidia and AMD chose something very close.

So I think it's not very important which values for the bilinear filter !

But I'm glad to have learned something ! Thank you everybody !

Last edited by SuperLumberjack; 22nd August 2019 at 22:14.
SuperLumberjack is offline   Reply With Quote
Old 23rd August 2019, 00:04   #32  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
However, the only thing that surprises me is the fact that Nvidia (or Intel, because maybe the scaling is done by the Intel IGP on my laptop) and AMD, which are rival, decided to use the exact same bilinear algorithm for the scaling...

Do you really think that it is a coincidence ?

Because when I change the values for "src_top" and "src_left", the RGB values can change considerably for the pixels which are impacted, whereas the non interpolated pixels of the image keep the same values as the source.

And so, even if it looks subtle, I personally find that it's the entire depth of the picture which can change.

Shouldn't there be a standard which can be the same for everybody ?

But Nvidia (or Intel) and AMD agree about the values to be used for the bilinear algorithm

Maybe for some of you it's insignificant, but recognize that it's a bit strange !
SuperLumberjack is offline   Reply With Quote
Old 23rd August 2019, 10:08   #33  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
Hello

I compared some bilinear resizers to see if they are different or not, and yes, they are different

I just tested with Photoshop and XnView.

It seems that the bilinear filter of AviSynth is exactly the same as Photoshop (same RGB values too).

But with XnView it's different from my GPU scaling and Photoshop. So I didn't try with other softwares. I have my answer !

I know I'm a bit crazy

Thank you very much !
SuperLumberjack is offline   Reply With Quote
Old 23rd August 2019, 11:19   #34  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
Just a question please !

I often asked myself the question : « If I double a picture with PointResize and then I must convert it from the YV24 colorspace to YV12, why isn't the picture identical ? »

Of course I'm missing something, but in my logic, if I double a picture with PointResize, after having converted the colorspace from YV24 (which is almost identical to RGB24) to YV12 with PointResize for the chroma resampling, the chroma should be identical no ?

But maybe it's because the YUV colorspace doesn't work like the RGB colorspace. Am I wrong ?

But how ?


Edit : No. Excuse me ! I should have talked about the YUV 4:2:2 colorspace instead of YUV 4:2:0. But even here it's not identical. Why ?

Last edited by SuperLumberjack; 23rd August 2019 at 11:37.
SuperLumberjack is offline   Reply With Quote
Old 23rd August 2019, 19:53   #35  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
The resampling during the conversion is using a wider radius bicubic kernel, try setting it to bilinear.

Use chromaresample="bilinear" or even "point" in the ConvertTo.

Edit:
Quote:
Originally Posted by SuperLumberjack View Post
Of course I'm missing something, but in my logic, if I double a picture with PointResize, after having converted the colorspace from YV24 (which is almost identical to RGB24) to YV12 with PointResize for the chroma resampling, the chroma should be identical no ?
Sorry! I missed you already using Point resize for the conversion. In that case it can only be the chroma placement. Chroma placement is a bit odd, both ChromaInPlacement and ChromaOutPlacement should be investigated.

Edit2: How different are they? You cannot do a lossless conversion from RGB to YV24 to RGB (at least when using the same bit depth at each step), there will always be minor differences in the final RGB values.
__________________
madVR options explained

Last edited by Asmodian; 23rd August 2019 at 19:59.
Asmodian is offline   Reply With Quote
Old 23rd August 2019, 21:00   #36  |  Link
SuperLumberjack
French Registered User
 
SuperLumberjack's Avatar
 
Join Date: Aug 2016
Location: France
Posts: 333
OK. So it's a question of chroma placement. Yes, I found strange that the chroma wasn't aligned with the luma. I will explore this settings. Thank you !

And what algorithm do you recommend for the conversion of the colorspace for classic videos (no pixel art) ? Because I suppose that something smoother than PointResize is better in this case.

Have you ever tried the "UtVideo YUV420 BT.709 VCM" ? I always use this codec for the conversion and because it's lossless. But if I compare the conversion of the colorspace with it, it's less clean than the conversion by default with AviSynth, but it's more natural I find.

It's strange, because I don't know how the chroma is subsampled with this codec. It doesn't match with any of the existant algorithms.

Last edited by SuperLumberjack; 23rd August 2019 at 21:03.
SuperLumberjack is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump


All times are GMT +1. The time now is 09:41.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.