INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Beginners guide to MadVR scaling  (Read 24686 times)

tij

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1557
Beginners guide to MadVR scaling
« on: February 09, 2020, 04:45:08 am »

LOG
Feb 9,2020 - Started this with SCALING section
Mar 8, 2020 - Added PRFILING section and corrected some spelling (also added my current setting.bin)
July 18, 2080 - Cancel HDR for this post ... will create separate one just for HDR


This guide will try to simply explain MadVR following settings:

*scaling
*profiling
*HDR

For other MadVR options refer to https://wiki.jriver.com/index.php/MadVR_Expert_Guide.

SCALING

Most of us are used to images being described in RGB colorspace. RGB has 3 channels - Red Green Blue. Together they define each pixel color and brightness.

Video is encoded in YCbCr colorspace. This also has 3 channels - Y (luma) Cb (blue difference) Cr (red difference). Basically Y defines brightness of pixel and it looks like greyscale image. Cb and Cr together define the color/hue of pixel and are referred to as chroma channels. See the attached picture from Wikipedia on how YCbCr channels look and how they are combined to make a whole picture. For more details on YCbCr see https://en.wikipedia.org/wiki/Chroma_subsampling. The point of this is - video to consumers are in formats that have separate channel for brightness and colors.

Video that arrives to us is not "full" resolution, but subsampled. Basically the Luma channel arrives to you at full resolution while Chroma channels arrive at lower resolution.  Subsampling is usually described with 3 numbers. 4:4:4 means no subsampling (all YCbCr channels are at full resolution). For more details on chroma subsampling see https://en.wikipedia.org/wiki/Chroma_subsampling. Video that arrives to us is usually 4:2:0 (see attached picture from Wikipedia for what 4:2:0 look like) - meaning video to consumers has Luma/brightness at full resolution and Chroma/color at half resolution.

So scaling is a 2-step process:
1. upscale Chroma to original full resolution
2. now that you have both Luma and Chroma at original full resolution - scale them to the required resolution if needed (for example if your TV is 1080p and your video is 1080p ... only chroma upscaling is required)

MadVR scaling options are grouped under [scaling algorithms] which further groups options under 4 subcategories

[chroma upscaling] - lets you choose the algorithm for scaling the chroma channel to original full resolution
[image downscaling] - lets you choose the algorithm for downscaling chroma and luma to the required resolution (eg you downsacale 4K for your HD TV)
[image upscaling] - lets you choose the algorithm for upscaling chroma and luma to the required resolution (eg you upscale HD for your 4K TV)
[upscaling refinement] - various options for refining scaling results (I will not explain this here ... options there are self explanatory ... if you are interested, just try them one by one and see if you like the results)

Scaling algorithms for [chroma upscaling], [image downscaling], [image upscaling] are presented in a column.  The simplest algorithms are on top and as you go down the list - complexity/quality of algorithm will increase (there is also a drop box at bottom of the algorithm list that lets you choose settings for your algorithm). There are bars on the right of algorithm list that indicate the quality of each algorithm:

sharpness - how sharp is chosen algorithm (the more green the better)
hide source artifact - how well chosen algorithm hides artifacts that came with video (the more green the better)
aliasing - how much aliasing chosen algorithm produce (the less red the better)
ringing - how much ringing chosen algorithm produce (the less red the better)
other artifacts - how many artifacts the chosen algorithm produces (the less red the better)

for [image upscaling] the list of algorithms are presented in two columns
(1) upscaling - the algorithm here scales your video directly to the desired resolution ... for example if 720p needs to be scaled to 1080p ... the algorithm will straight away scale by x1.5
(2) doubling - this algorithm doubles or quadruples the video first (as it'ss very cheap to do in terms of processing power) then downscales the result to the desired resolution ... for example if 720p needs to be scaled to 1080p ... the algorithm here will scale by x2 first then downsale by x0.75

for doubling process you can specify the quality of your luma and chroma doubling/quadrupling

TIP: always choose better algorithms for luma upscaling as it is more noticable.

Your GPU will dictate which algorithms you can use.  The following will describe tuning process. During movie playback, you will need to press CTR+J to bring MadVR OSD info up onto screen (press CTR+R to reset its statistics)

(1) determine how fast your GPU needs to render each frame. Look at OSD [movie] it will tell you frames per second (fps) of your movie. Divide one by that and you get max limit. For example if movie is 60fps, then limit is 1/60=0.016s=16ms.
(2) look at OSD [average stats -> rendering] if times there exceed the limit determined in step 1, then your scaling algorithms are too complex for your GPU to handle in real time. Choose a simpler algorithm. Your aim is to reduce the rendering time to be within the time limit determined in step 1 (give yourself margin ... so if the limit is 16ms ... then aim for around 12ms rendering times)
(3) if the GPU cannot render a frame in the given time, it will drop that frame, resulting in stuttering ... look at your [dropped frames] ... press CTR+R to reset it ... there should be zero dropped frames while the movie is playing (this number can increase when starting movie or fast forwarding ... but during normal playback - there should be no dropped frames)

If you want one setting to "rule them all" ... choose the most complex movie for tuning:

1. Choose a movie with the highest fps
2. Choose a movie without any black bars (madVR is clever and doesn't scale blackbars ... hence your fine tuning on movie with 2.39:1 movie will not work on 16:9 movie)
3. Choose an actual movie, not a cartoon
4. For chroma upsampling choose 4K resolution
5. Once you determine the chroma algorithm ... pick a 1080p movie to determine the luma algorithm ... remember to always choose better algorithms for luma upscaling. So if necessary reduce chroma algorithm determined in step 4 to pick better one for luma

Now if you say ... but I dont want general setting to "rule them all" ... I want the best possible algorithm for different content I have ... thats where PROFILING comes in ... which I will write about next time

PROFILING
Profiling allows you to apply different MadVR settings to different situations. For example chroma upscaling for HD video to 4K can be set much better quality than for 4K videos. With profiling you can use one setting for HD video and another setting for 4K video.

It is very hard to explain this in general terms … so I will walk you through profiling [scaling algorithm] for HD and 4K video and you can apply same principle for your custom profiles

(1) click on [scaling algorithm] … on right there will be button [create profile group] … click on that
(2) choose all four settings [chroma upscaling] [image downscaling] [image upscaling] [upscaling refinement] to be profiled and click OK
(3) [Profile Group 1] will be created with [Profile 1] under it … rename this sensibly so you can make sense of it later …. lets rename [Profile Group 1] to [Video Source] and rename [Profile 1] to [2160p]
(4) click to newly renamed [Video Source] and click [add profile] … [Profile 2] will be created
(5) rename [Profile 2] to [1080p]
(6) repeat step (4) and rename new profile as [Other]
(7) click on [Video Source] and under [profile auto select rules] copy paste following

if ((srcWidth = 3840) or (srcHeight =2160)) "2160p"
else if ((srcWidth = 1920) or (srcHeight =1080)) "1080p"
else "Other"

this tests for conditions and choose appropriate profile … make sure your profile names match exactly what you write in "if, else if, else" statement (in my case its "2160p" and "1080p")

note that I test for both height and width of video … and if any of those match select appropriate profile (in case I choose to "handbrake" my video and remove black bars)

All you have to do now is tweak settings under each profile to maximize the potential of your GPU

Following are things that can be included in condition

srcWidth    … eg srcWidth < 1920 (video height less than 1920)
srcHeight    … eg srcHeight  = 1080 (video width equal to 1080)
deintFps    … eg deintFps  > 30 (frame rate higher than 30fps)
fileName    … eg fileName = "*anime*" (file name contain 'anime')
fileExt    … eg fileExt = "mk*" (file extension starts with 'mk')
filePath    … eg filePath = "*UHD*" (file path contains 'UHD') 

you can form complex conditions with AND and OR operators

Here is what I have for my scaling profile (its work in progress)

if (fileExt = "mk3d") "3D"
else if (((srcWidth = 3840) or (srcHeight =2160)) and (deintFps > 30)) "2D_UHD_HFR"
else if ((srcWidth = 3840) or (srcHeight =2160)) "2D_UHD"
else if (((srcWidth = 1920) or (srcHeight =1080))and (filePath = "*Film*")) "2D_HDiF"
else if (((srcWidth = 1920) or (srcHeight =1080)) and (filePath = "*Video*")) "2D_HDiV"
else if ((srcWidth = 1920) or (srcHeight =1080)) "2D_HD"
else if (((srcWidth < 1920) and (srcHeight < 1080)) and (deintFps < 25)) "2D_SD"
else "2D_SDi"

you can apply above principles to any MadVR settings to profile them … I also attached my MadVR settings (this pushes my 1070 to the limit … so if you have lesser GPU, you will need to use less aggressive settings)
Logged
HTPC: Win11 Pro, MC: latest 31(64b), NV Driver: v425.31, CPU: i9-12900K, 32GB RAM, GeForce: 2080ti
Screen: LG 2016 E6
NAS: FreeNAS 11.1, SuperMicro SSG-5048R-E1CR36L, E5-1620v4, 64GB ECC RAM, 18xUltrastar He12-SAS3 drives, 2x240GB SSD (OS)

rec head

  • Citizen of the Universe
  • *****
  • Posts: 1004
Re: Beginners guide to MadVR scaling
« Reply #1 on: February 09, 2020, 06:47:11 am »

Super helpful. Thanks.
Logged

jorsan

  • World Citizen
  • ***
  • Posts: 221
Re: Beginners guide to MadVR scaling
« Reply #2 on: February 09, 2020, 07:53:48 am »

wow, thanks tij for taking time to help me (us), this guide is really useful. I'm sure there are several people like me that need more simple explanations that we can understand like this one.   
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 71354
  • Where did I put my teeth?
Re: Beginners guide to MadVR scaling
« Reply #3 on: February 09, 2020, 08:22:42 am »

Thanks, tij.

I corrected some spelling and typos.
Logged

tij

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1557
Re: Beginners guide to MadVR scaling
« Reply #4 on: March 08, 2020, 12:47:46 pm »

Added profiling … was trying to write something general … but found it too difficult … so instead wrote specific example and hope ppl can apply that to their custom settings
Logged
HTPC: Win11 Pro, MC: latest 31(64b), NV Driver: v425.31, CPU: i9-12900K, 32GB RAM, GeForce: 2080ti
Screen: LG 2016 E6
NAS: FreeNAS 11.1, SuperMicro SSG-5048R-E1CR36L, E5-1620v4, 64GB ECC RAM, 18xUltrastar He12-SAS3 drives, 2x240GB SSD (OS)

Manfred

  • Citizen of the Universe
  • *****
  • Posts: 1023
Re: Beginners guide to MadVR scaling
« Reply #5 on: March 10, 2020, 05:48:17 am »

I documented my settings as:
Logged
WS (AMD Ryzen 7 5700G, 32 GB DDR4-3200, 2x2 TB SDD, LG 34UC98-W)-USB|ADI-2 DAC FS|Canton AM5 - File Server (i3-3.9 GHz, 16GB ECC DDR4-2400, 46 TB disk space) - Media Renderer (i3-3.8 GHz, 8GB DDR4-2133, GTX 960)-USB|Devialet D220 Pro|Audeze LCD 2|B&W 804S|LG 4K OLED )

Manfred

  • Citizen of the Universe
  • *****
  • Posts: 1023
Re: Beginners guide to MadVR scaling
« Reply #6 on: March 10, 2020, 05:53:38 am »

Some usefull links:

madVR: Which output format (RGB vs YCbCr, 0-255 vs 16-235) should I activate in my GPU control panel?
https://forum.doom9.org/showthread.php?t=146228

Supported NVIDIA VIDEO CODEC's for most NVIDIA GPU's:

https://developer.nvidia.com/nvidia-video-codec-sdk
Logged
WS (AMD Ryzen 7 5700G, 32 GB DDR4-3200, 2x2 TB SDD, LG 34UC98-W)-USB|ADI-2 DAC FS|Canton AM5 - File Server (i3-3.9 GHz, 16GB ECC DDR4-2400, 46 TB disk space) - Media Renderer (i3-3.8 GHz, 8GB DDR4-2133, GTX 960)-USB|Devialet D220 Pro|Audeze LCD 2|B&W 804S|LG 4K OLED )

arcspin

  • Galactic Citizen
  • ****
  • Posts: 378
Re: Beginners guide to MadVR scaling
« Reply #7 on: March 10, 2020, 01:26:11 pm »

Hello,
Here is a link to more info regarding setting up madVR.

https://forum.kodi.tv/showthread.php?tid=259188

Logged
Hardware: Intel Core i5-8600K 16GB RAM, ASUS GeForce RTX 2080 8GB DUAL OC
Software: Windows 10 Home 64-bit, version 2004, JRiver MC 29, MadVr 0.92.17 (Beta 113), NVIDIA driver 457.09
Projector: JVC DLA-I X5500 (RS420, X570R) -
Screen: DNP Supernova 08-85
Processor: Anthem AVM 70
Power amp: XTZ A2-400 for Front & Center - XTZ A2-300 for Surround & Height channels
Speakers: Arendal 1723 S Monitor for Front & Center, Linn Unik for Front Height, Rear Height, Surround & Surround back. Elipson Planet M for Top Middle.
Sub: Arendal 1723 1S

rec head

  • Citizen of the Universe
  • *****
  • Posts: 1004
Re: Beginners guide to MadVR scaling
« Reply #8 on: May 27, 2020, 11:51:35 am »

The MadVR Expert Guide wiki was last edited in 2018 and a bit out of date.

MadVR settings are now available in MC's settings. HDR isn't even covered. Scaling algorithms are different. I'm sure there is way more. I would offer to help but would make more mistakes than improvements. 
Logged
Pages: [1]   Go Up