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 > VapourSynth
Register FAQ Calendar Today's Posts Search

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 11th December 2019, 17:41   #19  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,277
Not totally sure whether I make a mistake in using Waifu2x or if this is a bug.
When I use limited range input and feed it to Waifu2x the histogram is compressed.
To illustrate the problem I created the following script:
Code:
# Imports
import vapoursynth as vs
core = vs.get_core()
import ctypes
# Loading Support Files
Dllref = ctypes.windll.LoadLibrary("I:/Hybrid/64bit/vsfilters/ResizeFilter/Waifu2x/w2xc.dll")
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/ResizeFilter/Waifu2x/Waifu2x-w2xc.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# Loading C:\Users\Selur\Desktop\test3.mkv using LWLibavSource
clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/test3.mkv", format="YUV420P10", cache=0, prefer_hw=0)

#limited
limited = clip
limited = core.resize.Point(limited, matrix_in_s="470bg",range_s="limited")
limited = core.std.AssumeFPS(limited, fpsnum=24000, fpsden=1001) # making sure frame rate is set to 23.976
limited = core.std.SetFrameProp(clip=limited, prop="_ColorRange", intval=1) # Setting color range to TV (limited) range.
limited = core.resize.Bicubic(clip=limited, format=vs.RGB48, matrix_in_s="470bg", range_s="limited") # adjusting color space from YUV420P10 to RGB48 for Waifu2x-w2xc
limited = core.resize.Bicubic(clip=limited, format=vs.YUV420P16, matrix_s="470bg", range_s="limited") # to YUV420P16
limited = core.hist.Classic(clip=limited) # add histogram

# limited with waifu2x
limitedw = clip
limitedw = core.resize.Point(limitedw, matrix_in_s="470bg",range_s="limited")
limitedw = core.std.AssumeFPS(limitedw, fpsnum=24000, fpsden=1001) # making sure frame rate is set to 23.976
limitedw = core.std.SetFrameProp(clip=limitedw, prop="_ColorRange", intval=1) # Setting color range to TV (limited) range.
limitedw = core.resize.Bicubic(clip=limitedw, format=vs.RGB48, matrix_in_s="470bg", range_s="limited") # adjusting color space from YUV420P10 to RGB48 for Waifu2x-w2xc
limitedw = core.fmtc.bitdepth(clip=limitedw,bits=32) # adjusting bit depth to 32bit
limitedw = core.w2xc.Waifu2x(clip=limitedw, scale=1) # using Waifu2x
limitedw = core.resize.Bicubic(clip=limitedw, format=vs.YUV420P16, matrix_s="470bg", range_s="limited") # to YUV420P16
limitedw = core.hist.Classic(clip=limitedw) # add histogram

# full
full = clip
full = core.resize.Point(full, matrix_in_s="470bg",range_s="full")
full = core.std.AssumeFPS(full, fpsnum=24000, fpsden=1001) # making sure frame rate is set to 23.976
full = core.std.SetFrameProp(clip=full, prop="_ColorRange", intval=0) # Setting color range to PC (full) range.
full = core.resize.Bicubic(clip=full, format=vs.YUV420P16, matrix_s="470bg", range_s="full") # 16bit
full = core.hist.Classic(clip=full) # add histogram


# full with waifu2x
fullw = clip
fullw = core.resize.Point(fullw, matrix_in_s="470bg",range_s="full")
fullw = core.std.AssumeFPS(fullw, fpsnum=24000, fpsden=1001) # making sure frame rate is set to 23.976
fullw = core.std.SetFrameProp(clip=fullw, prop="_ColorRange", intval=0) # Setting color range to PC (full) range.
fullw = core.resize.Bicubic(clip=fullw, format=vs.RGB48, matrix_in_s="470bg", range_s="full") # adjusting color space from YUV420P10 to RGB48 for Waifu2x-w2xc
fullw = core.fmtc.bitdepth(clip=fullw,bits=32) # adjusting bit depth to 32bit
fullw = core.w2xc.Waifu2x(clip=fullw, scale=1) # using Waifu2x
fullw = core.resize.Bicubic(clip=fullw, format=vs.YUV420P16, matrix_s="470bg", range_s="full") # 16bit
fullw = core.hist.Classic(clip=fullw) # add histogram

limitedstack = core.std.StackHorizontal([limited,limitedw])
fullstack = core.std.StackHorizontal([full,fullw])
clip = core.std.StackVertical([limitedstack,fullstack])

# Output
clip.set_output()
which compares what happens to the histogram if the source is interpreted as 'full' or 'limited', converted to RGB48 and then fed to Waifu2x.

I uploaded the script I used and the source to my GoogleDrive as test.mkv and Waifu2x_Test.vpy

So my question is:
Is this a bug or am I doing something wrong?

In case I'm doing something wrong it would be nice if someone could post how to properly handle limited sources with Waifu2x.
Thanks!

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is offline  
 


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 20:22.


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