Repository navigation
Rewrite descaling guide from scratch - #56
LightArrowsEXE wants to merge 6 commits into
Conversation
I hated my old write-up, so here's an updated one!
|
Okay, so this was a bit weird to do since it's coming from @LightArrowsEXE 's master branch, but I've rebased this onto the current upstream master, as well as got rid of the
EDIT: not sure how to give Light back the ownership of that commit (if that's even possible) |
|
FWIW, you can set the author of a commit with |
OrangeChannel
left a comment
There was a problem hiding this comment.
I've only gone through this up until the Handling native 1080p content since I know too little of how the credit stuff is done.
| What the difference between downscaling and descaling is | ||
| is a question that gets asked fairly frequently. |
There was a problem hiding this comment.
I don't think this fits here. Just explaining it directly works.
| downscaling is the act of resizing an image | ||
| to a smaller resolution than the original image, |
There was a problem hiding this comment.
I think we should have some mention of how downscaling uses the same kernels as upscaling, while de-scaling reverses the kernel's logic. We can reference the resampling page here as well.
There was a problem hiding this comment.
how downscaling uses the same kernels as upscaling
That's … a pretty general thing to say and doesn't exactly provide more information than what we have currently.
There was a problem hiding this comment.
Hm... 🤔 I guess you're right, a more detailed explanation wouldn't belong here I guess but maybe a ## Descaling section on the resampling page may be something to consider in the future (that better explains the difference mathematically).
| while with descaling you are actively reversing the math | ||
| applied to an upscale, | ||
| reconstructing the original image before upscaling | ||
| (which coincidentally also means you get a smaller image). |
There was a problem hiding this comment.
Probably unnecessary to write this.
There was a problem hiding this comment.
Not entirely unnecessary, but the "coincidentally" is too strong. It was our intention all along to go back to the original information and reduce the amount of superficial information that needs to be included in an encode, or provide better such superficial information.
Actually, I'm missing this kind of explanation for the motivation of descaling. You say that it's better than downscaling, but never mention why we want to do it in the first place, particularly why it's always a good idea to do so (before applying your filter chain), provided it's possible.
There was a problem hiding this comment.
The reason for why you should descale gets mentioned in the next paragraph. I'll build onto that a bit further.
| ```py | ||
| import lvsfunc as lvf | ||
|
|
||
| This picture is also very dark | ||
| and has even more effects over it. | ||
| clip = core.lsmas.LWLibavSource(r"PATH/TO/VIDEO.m2ts") | ||
| clip = fvf.Depth(clip, 32) # Important to note: descale requires a GRAYS clip (or 444, but don't do that). | ||
|
|
||
|  | ||
| clip_y = core.std.ShufflePlanes(clip, 0, vs.GRAY) | ||
| descaled = core.descale.Debicubic(clip_y, width=1280, height=720, b=1/3, c=1/3) | ||
| reupscaled = core.resize.Bicubic(descaled, width=1920, height=1080, filter_param_a=1/3, filter_param_b=1/3) | ||
| merged = core.std.ShufflePlanes([reupscaled, clip], [0, 1, 2], vs.YUV) | ||
|
|
||
| Heavy dynamic grain will almost always give bad results. | ||
| comp = lvf.compare(clip, merged) | ||
| comp.set_output() | ||
| ``` |
There was a problem hiding this comment.
import descale
src = core.lsmas.LWLibavSource(r'/path/to/file.m2ts')
descaled = descale.Debicubic(src, width=1280, height=720, b=1/3, c=1/3)
reupscaled = core.resize.Bicubic(descaled, width=1920, height=1080, filter_param_a=1/3, filter_param_b=1/3)
core.std.Interleave(clips=[src.text.Text('src'), reupscaled.text.Text('scaled', 9)]).set_output()Is there a reason here for changing the bitdepth? And using the python wrapper for descale you don't need to convert the clip or merge the planes back.
There was a problem hiding this comment.
Yup, my bad. These are examples of the plugin, not the wrapper. Will update.
|  | ||
|
|
||
|  |
There was a problem hiding this comment.
Please also add descriptive captions for these two. For the latter, do something like The result of …. I'm not going to repeat this for the cases below.
There was a problem hiding this comment.
I personally find that rather annoying to do when a lot of it is mostly repeats of the same thing and is already pretty evident just by reading the accompanying text. Maybe the first time around, but for others? Ehhh...
| downscaling is the act of resizing an image | ||
| to a smaller resolution than the original image, |
There was a problem hiding this comment.
how downscaling uses the same kernels as upscaling
That's … a pretty general thing to say and doesn't exactly provide more information than what we have currently.
| while with descaling you are actively reversing the math | ||
| applied to an upscale, | ||
| reconstructing the original image before upscaling | ||
| (which coincidentally also means you get a smaller image). |
There was a problem hiding this comment.
Not entirely unnecessary, but the "coincidentally" is too strong. It was our intention all along to go back to the original information and reduce the amount of superficial information that needs to be included in an encode, or provide better such superficial information.
Actually, I'm missing this kind of explanation for the motivation of descaling. You say that it's better than downscaling, but never mention why we want to do it in the first place, particularly why it's always a good idea to do so (before applying your filter chain), provided it's possible.
|  | ||
|
|
||
|  | ||
|  |
There was a problem hiding this comment.
I don't see the image here, but is it a composition or the final frame? In the latter case, the caption can't use imperative.
There was a problem hiding this comment.
I don't quite get what you mean by this. Could you elaborate?
There was a problem hiding this comment.
I think Fichte means the caption should sound more like Original credits merged with a re-upscaled (nnedi3_resample) frame instead of using a command-like phrase.
|
Have updated it with the comments in mind. I may have missed one or two, so another double-check would be appreciated. I've also replied to some comments that I either wanted elaboration on or don't agree with. |
|
@FichteFoll I caught light up with the changes so any further changes shouldn't be a problem (sorry for the double push, git deleted+added files instead of renaming them and i didn't notice). Before merging, just make Light author of 03732ab and 9f0eed5 . |
| This offers a multitude of advantages, | ||
| like for example when dealing with artifacting | ||
| that was a result of a poor upscale. | ||
| You could instead undo the scaling | ||
| and use a better scaler to upscale it instead, | ||
| or keep it at its native resolution and | ||
| have less artifacting to worry about. |
There was a problem hiding this comment.
| This offers a multitude of advantages, | |
| like for example when dealing with artifacting | |
| that was a result of a poor upscale. | |
| You could instead undo the scaling | |
| and use a better scaler to upscale it instead, | |
| or keep it at its native resolution and | |
| have less artifacting to worry about. | |
| This offers many advantages, | |
| one example being the ability to fix artifacting | |
| that was a result of a poor upscale. | |
| You could undo the scaling | |
| and use a better scaler to upscale it instead, | |
| or keep it at its native resolution and | |
| have less artifacting to worry about. |
Are there any other benefits worth mentioning?
| what the native resolution of a frame is. | ||
| One way to do this is by descaling to all potential resolutions, | ||
| upscaling the descaled image with the same kernel, | ||
| and comparing the two. |
There was a problem hiding this comment.
| and comparing the two. | |
| and comparing this result with the original. |
| [getnative.py][getnative] is a common tool | ||
| used for figuring out the native resolution of an image. | ||
| It will return a graph showcasing all the resolutions | ||
| it tried to descale to, |
There was a problem hiding this comment.
Maybe adding a footnote mentioning:
With the default (bicubic 1/3 1/3) usually returning the correct resolution either way...
would satisfy this?
|
|
||
|  | ||
|
|
||
| What you want to look out for are very clear spikes. |
There was a problem hiding this comment.
| What you want to look out for are very clear spikes. | |
| What you want to look out for are very clear downward spikes. |
I've seen a few awful graphs in the #bot channel that have spikes somehow going up, and we'd want to avoid these afaict.
|  | ||
| Once you've figured out the native resolution, | ||
| you can move on to the actual descaling. | ||
| There's two common ways to do this. |
There was a problem hiding this comment.
| There's two common ways to do this. | |
| There's three common ways to do this. |
Whoops, didn't notice that when I added mention of the python functions.
There was a problem hiding this comment.
Should those even be separate entries?
| A fairly common practice is | ||
| to upscale the descaled clip to a standard resolution | ||
| (if it isn't already one, like for example 720p). | ||
| The following scalers are generally recommended for this task. |
There was a problem hiding this comment.
These seems like there's going to be a list after this line, so maybe needs some rewording.
| This is a good result | ||
| for testing out varying kernels. | ||
|
|
||
| Similarly, [nnedi3_resample][] is also used by some people |
There was a problem hiding this comment.
| Similarly, [nnedi3_resample][] is also used by some people | |
| Another scaler, [nnedi3_resample][], is sometimes used |
| of some common kernels and values. | ||
| A couple more extreme examples | ||
| would be using [waifu2x][] or [upscaled_sraa][] | ||
| to upscale it back to 1080p. |
There was a problem hiding this comment.
| to upscale it back to 1080p. | |
| to upscale it back to the original resolution. |
| it's important to be wary of native 1080p elements. | ||
| A common example of this is credits, | ||
| which are usually added after upscaling. | ||
| These will require being masked. |
There was a problem hiding this comment.
| These will require being masked. | |
| These will need to be masked. |
| Since the credits will still be messed up, | ||
| you will need to replace them with a downscaled clip. |
There was a problem hiding this comment.
The differentiation here is that you are going to downscale the credits while descaling the rest of the frame, right? I think better wording would be as follows:
| Since the credits will still be messed up, | |
| you will need to replace them with a downscaled clip. | |
| Since there is no need to *descale* native 1080p elements, | |
| you will need to *downscale* the credits instead. |
|  | ||
|
|
||
|  | ||
| [Here][rescaled] is a link to a comparison. |
There was a problem hiding this comment.
I think that Fichte has said before not to have a link on words like "here" and instead just link the actual thing. i.e.:
| [Here][rescaled] is a link to a comparison. | |
| [Slowpics comparison of the re-upscaled frame.][rescaled] |
|  | ||
|
|
||
| [^1]: Most, if not all, relevant VapourSynth scripts/plug-ins and their functions can be found in the [VapourSynth Database][vsdb]. | ||
| [Here][downscaled] is also a link to a comparison. |
There was a problem hiding this comment.
Same as previous one:
| [Here][downscaled] is also a link to a comparison. | |
| [Slowpics comparison of the descaled frame.][downscaled] |
|
It's nice that github added their review feature, but things quickly become a mess for larger PRs like this. It's not easy to see all unresolved discussions and compare the changes since then to determine whether they have been resolved in code. |
|
This PR is going to be closed now and reworked later. I have a plan for a different page to be added, and will be writing a guide for that instead now. Will revisit updating descaling at a later date. |
I hated my old write-up, so here's an updated one!