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. |
|
|
Thread Tools | Search this Thread | Display Modes |
17th July 2021, 18:15 | #1 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,969
|
Resize8 - An updated version of the original resizing function
This is an updated version of Resize8 1.2 2015.02.23 by mawen1250.
Resize8 2024-11-01.zip The initial changes compared to the original Resize8 are listed in the next post. ----------------------------- From version 2024-06-22, it's possible to configure the way the sample/pixel aspect ratio in frame properties is updated: When resizing with most resizers, unless the storage aspect ratio (width / height) for the resized video matches the storage aspect ratio of the source video, the resizing stretches the video in some manner. In order to prevent that a new sample aspect ratio must be calculated manually and used when encoding the video. Some newer resizers such as the AVSResize plugin (or VapourSynth's native resizers) will read the source video's sample aspect ratio in frame properties and update it after resizing, but sometimes you might want to specify a new sample aspect ratio manually in order to stretch the video and correct the way it displays. Therefore.... Three new arguments have been added relating to the SAR written to frame properties after resizing. These arguments have no affect on the resizing, only the SAR written to frame properties. DAR (float - display aspect ratio). The default is 0.0, which means an unspecified DAR. SAR (float - sample aspect ratio). The default is 0.0, which means an unspecified SAR. Keep (bool). The default is false. Keep determines whether Resize8 calculates a new SAR after resizing, keeps the source SAR, or keeps the source DAR after resizing if one is specified and calculates a new SAR accordingly. If neither a DAR or SAR are specified Resize8 takes the source SAR from frame properties, if one exists. If a DAR is specified Resize8 converts it to a SAR and uses it as the source SAR. If a SAR is specified Resize8 uses it as the source SAR. When keep=false (the default) Resize8 always calculates a new SAR after resizing and writes it to frame properties. When keep=true and no DAR is specified, Resize8 writes the source SAR to frame properties after resizing, while calculating a new DAR for the resized video (displayed when Info or Show are true). If a DAR is specified when keep=true, it becomes the DAR for the output video, therefore Resize8 calculates a new SAR for frame properties after resizing (also displayed when Info or Show are true). There's also a new argument named Info. Like the Show argument, Info=true displays the resizing strings as well as the input and output aspect ratios, but instead of displaying that info over a blank clip as Show=true does, Info=true displays it over the resized video. Some examples: Resizing a non-anamorphic 16:9 video to a different aspect ratio and calculating a new SAR. The DAR remains unchanged. Resize8(1048,576, Info=true) Stretching a non-anamorphic 16:9 video while resizing and therefore keeping the original SAR. The video has a new DAR. Resize8(1048,576, keep=true, Info=true) Resizing a 16:9 NTSC DVD to 16:9 PAL dimensions. Resize8(720,576, Info=true) Over-riding the SAR in frame properties for the 16:9 NTSC DVD and resizing to PAL dimensions. Resize8(720,576, SAR=40.0/33.0, Info=true) or Resize8(720,576, DAR=20.0/11.0, Info=true) or Resize8(720,576, SAR=16.0/11.0, keep=true, Info=true) Last edited by hello_hello; 1st November 2024 at 17:20. |
3rd August 2021, 04:47 | #2 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,969
|
Changes compared to the original Resize8.
The default output should be exactly the same as the original. --- There's a help file of sorts. --- All Avisynth+ color spaces and bitdepths are supported. --- Any resizer with the same arguments for cropping as the native Avisynth resizers can be used. --- The Jinc, ResampleMT and SplineResize plugins are added as "known" resizers. The SplineResize plugin kernels are limited to 8 bit video, and don't support all color spaces. For SplineResize the individual planes are converted to YV12 for resizing, so all Avisynth 2.6 colorspaces are supported that way. Support for the SplineResize plugin as a native resizer has been removed since version 2024-06-22. --- The Resize8_Separate() function has been removed, but it's functionality is retained via an additional Resize8 argument "separate", so Resize8(separate=true) can be used instead. --- New arguments, "RStr" and "RStr_c", for specifying named arguments as strings. They can be used instead of the a1 and a2 arguments for "known" resizers. For example: Resize8(1280,720, kernel="Bicubic", RStr="b=0.5,c=0.5") Resize8(1280,720, kernel="Spline36ResizeMT", RStr="prefetch=4, threads=2") --- New "show" argument show=true bypasses the resizing stage and opens a blank clip to display the full resizing strings as subtitles, as well as some other basic info. It might be useful if there's problems using the "RStr" arguments, or just to confirm the function is behaving as expected. --- Resize8 will attempt to use the the ResampleMT plugin for it's default resizing, but if it's not loaded it will use the native Avisynth resizers instead. --- When specifying a luma resizer with the kernel argument, the same kernel is now automatically used for chroma, unless a different chroma resizer is specified with kernel_c. Likewise, the "_c" arguments now default to the same values as their non "_c" counterparts, but only when the same kernel is used for both luma and chroma (when kernel = kernel_c). --- Adaptive ringing repair now works when downscaling, not just upscaling, but it's disabled for downscaling by default. It's also disabled for all "unknown" resizers by default. --- For RGBA, the luma kernel is applied to the R-G-B-A planes, except when a chroma kernel is specified or the default kernels are used, in which case the chroma kernel is used for the alpha plane. For YUVA, the luma kernel is applied to the Y-U-V-A planes, except when a chroma kernel is specified or the default kernels are used, in which case the chroma kernel is used for the U-V planes. --- The "alpha" argument behaves a little differently. If the source has no alpha plane and alpha=true, one will be added to the output when possible. The defaults for alpha are true when an alpha plane exists, and false when it doesn't. --- Added some simple, one line functions to the end of the Resize8 script. They can easily be modified to change the default resizing kernels and set default resizer strings. --- There's a help file of sorts. --- All Avisynth+ color spaces and bitdepths are supported. --- Any resizer with the same arguments for cropping as the native Avisynth resizers can be used. --- The Jinc, ResampleMT and SplineResize plugins are added as "known" resizers. The SplineResize plugin kernels are limited to 8 bit video, and don't support all color spaces. For SplineResize the individual planes are converted to YV12 for resizing, so all Avisynth 2.6 colorspaces are supported that way. --- The Resize8_Separate() function has been removed, but it's functionality is retained via an additional Resize8 argument "separate", so Resize8(separate=true) can be used instead. --- New arguments, "RStr" and "RStr_c", for specifying named arguments as strings. They can be used instead of the a1 and a2 arguments for "known" resizers. For example: Resize8(1280,720, kernel="Bicubic", RStr="b=0.5,c=0.5") Resize8(1280,720, kernel="Spline36ResizeMT", RStr="prefetch=4, threads=2") --- New "show" argument show=true bypasses the resizing stage and opens a blank clip to display the full resizing strings as subtitles, as well as some other basic info. It might be useful if there's problems using the "RStr" arguments, or just to confirm the function is behaving as expected. --- Resize8 will attempt to use the the ResampleMT plugin for it's default resizing, but if it's not loaded it will use the native Avisynth resizers instead. The ResampleMT plugin is no longer used by default from version 2024-06-22. --- When specifying a luma resizer with the kernel argument, the same kernel is now automatically used for chroma, unless a different chroma resizer is specified with kernel_c. Likewise, the "_c" arguments now default to the same values as their non "_c" counterparts, but only when the same kernel is used for both luma and chroma (when kernel = kernel_c). --- Adaptive ringing repair now works when downscaling, not just upscaling, but it's disabled for downscaling by default. It's also disabled for all "unknown" resizers by default. --- For RGBA, the luma kernel is applied to the R-G-B-A planes, except when a chroma kernel is specified or the default kernels are used, in which case the chroma kernel is used for the alpha plane. For YUVA, the luma kernel is applied to the Y-U-V-A planes, except when a chroma kernel is specified or the default kernels are used, in which case the chroma kernel is used for the U-V planes. --- The "alpha" argument behaves a little differently. If the source has no alpha plane and alpha=true, one will be added to the output when possible. The defaults for alpha are true when an alpha plane exists, and false when it doesn't. --- Added some simple, one line functions to the end of the Resize8 script. They can easily be modified to change the default resizing kernels and set default resizer strings. Last edited by hello_hello; 24th June 2024 at 04:42. |
4th August 2021, 07:04 | #3 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,969
|
Sigh.... I realised a did a silly with rounding for a couple of numbers that display when show=true.
There's a link for the fixed version dated 2021-08-06 in the opening post. Last edited by hello_hello; 6th August 2021 at 07:15. |
6th August 2021, 07:14 | #5 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,969
|
I don't know why but it's working now. It's probably just as well as my last fiddle with the way the strings display when show=true caused the right and bottom cropping to display as positive when they should be negative, and the other way around. It's fixed now.
|
7th September 2021, 13:58 | #6 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,969
|
New version dated 2021-09-07 in the opening post.
Resize8 is supposed to fall back to using the internal Avisynth resizers for it's default resizing instead of the MT resizers if the ResampleMT plugin isn't loaded. Instead it was producing an error message unless a non-MT resizer was specified manually. That's fixed now. The default resizing methods haven't changed. |
1st November 2024, 17:15 | #18 | Link | ||
Registered User
Join Date: Mar 2011
Posts: 4,969
|
Quote:
Quote:
Code:
A = last.ConvertToYUV420().Spline36Resize(960,540) B = A.Z_ConvertFormat(1920,1080, resample_filter="Spline36", chromaloc_op="center=>center", pixel_type="YUV420P8").ExtractY() C = A.Spline36Resize(1920,1080).ExtractY() Compare(B, C) Anyhow... it took me enough time to come up with the bright idea of using AVSResize as a resizer for Resize8 to leave little doubt I'm mentally challenged, but once that penny dropped I was able to check Resize8's handling of chroma against AVSResize and they're in agreement. Moving top left chroma to center placement while resizing. Code:
A = last.ConvertToYUV420().Spline36Resize(960,540) B = A.Z_ConvertFormat(1920,1080, resample_filter="Spline36", chromaloc_op="top_left=>center", pixel_type="YUV420P8").ExtractU() C = A.Resize8(1920,1080, kernel="z_Spline36Resize", noring=false, CPlace="top_left", CPlaced="center").ExtractU() Compare(B, C) Upscaling the chroma for YUV444 while downscaling the luma. Code:
A = last.ConvertToYUV420().Spline36Resize(1920,1080) B = A.Z_ConvertFormat(1280,720, resample_filter="Spline36", chromaloc_op="left=>center", pixel_type="YUV444P8") C = A.Resize8(1280,720, kernel="z_Spline36Resize", noring=false, CPlace="left", fullc=true) Compare(B, C) Last edited by hello_hello; 1st November 2024 at 17:34. |
||
2nd November 2024, 18:36 | #19 | Link |
Acid fr0g
Join Date: May 2002
Location: Italy
Posts: 2,848
|
Thank you!
What kind of transformation do you use to go from 420 to 444? I use AIUpscale with KriegBilateral but, as far as you told, you are just applying avsresize, right?
__________________
@turment on Telegram |
3rd November 2024, 18:27 | #20 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,969
|
Upscaling from sub-sampled chroma to 444 is done with the specified resizer, although I used AVSResize to resize for the examples above because there's enough difference between resizers to make it hard to check against AVSResize that Resize8 was fixing the chroma shift correctly when it was resizing with Avisynth. Even AVSResize and FMTConv don't produce the same output according to Compare().
For the record, Resize8 extracts the YUV planes (or RGB planes) and resizes them individually before combining them again, cropping the UV planes as required to correct any chroma shift, so there's no need to use a resizer capable of understanding or correcting chroma placement. It can't make a difference as the resizer doesn't see any UV planes as such. As I was messing around doing some testing I thought I'd post the results. I took 5000 frames from a 720p video, upscaled to 1080p, and ran a speed test with AvsPmod. Resize8 doesn't slow the resizing down by much, but I found it more interesting how much faster Avisynth's native resizing and AVSResize are with multi-threading disabled, although I'm running Avisynth in Wine so maybe on Windows the results would be different. There's two numbers next to each resizing method representing the number of seconds it took to run the test. The first is with multi-threading enabled by adding Prefetch(12) to the end of the script (12 core CPU). The second is without multi-threading enabled. The Resize8 tests were done with ringing repair enabled and disabled (the video is resized twice when noring=true and run through RGTools). Code:
MT - Yes, No Resize8(1920,1080, noring=true, kernel="Spline36Resize") 37, 15 Resize8(1920,1080, noring=false, kernel="Spline36Resize") 38, 7 Spline36Resize(1920,1080) 33, 6 Resize8(1920,1080, noring=true, kernel="Spline36ResizeMT") 31, 32 Resize8(1920,1080, noring=false, kernel="Spline36ResizeMT") 16, 16 Spline36ResizeMT(1920,1080) 10, 11 Resize8(1920,1080, noring=true, kernel="Spline36ResizeMT", RStr="threads=12") 16, 16 Resize8(1920,1080, noring=false, kernel="Spline36ResizeMT", RStr="threads=12") 16, 16 Spline36ResizeMT(1920,1080, threads=12) 11, 11 Resize8(1920,1080, noring=true, kernel="z_Spline36Resize") 36, 14 Resize8(1920,1080, noring=false, kernel="z_Spline36Resize") 33, 6 z_Spline36Resize(1920,1080) 32, 5 Last edited by hello_hello; 3rd November 2024 at 19:30. |
Thread Tools | Search this Thread |
Display Modes | |
|
|