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

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 11th December 2019, 17:41   #21  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
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  
Old 11th December 2019, 23:27   #22  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
@Selur:

1) it works if you use core.resize.Bicubic for 32bit (format=vs.RGBS) instead of fmtc . Should be faster than 2 separate operations (resize and fmtc) also

Or,

2) fulls=False, fulld=True for core.fmtc.bitdepth

Not sure if that is intended behaviour for fmtc, since the immediate input was RGB48, but it seems to work


(Another observation is that w2xc.Waifu2x clamps to limited range - ie. superbrights/darks are clamped. If you bypass that step, just go RGBS back to YUV, they are still there)
poisondeathray is offline  
Old 12th December 2019, 05:16   #23  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Adjusted my test script to:
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.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.RGBS, matrix_in_s="470bg", range_s="limited") # adjusting color space from RGBS to RGB48 for Waifu2x-w2xc
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.RGBS, matrix_in_s="470bg", range_s="full") # adjusting color space from YUV420P10 to RGB48 for Waifu2x-w2xc
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()
using RGBS does seem to fix the problem! THANKS!

Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 12th December 2019 at 05:47.
Selur is offline  
Old 26th February 2020, 16:54   #24  |  Link
sl1pkn07
Pajas Mentales...
 
Join Date: Dec 2004
Location: Spanishtán
Posts: 496
Hi

yes, i know this plugin is set to deprecated, but:

Code:
[1/2] Compiling C++ object 'waifu2x-w2xc@sha/Waifu2x-w2xc_Waifu2x-w2xc.cpp.o'.
FAILED: waifu2x-w2xc@sha/Waifu2x-w2xc_Waifu2x-w2xc.cpp.o 
c++ -Iwaifu2x-w2xc@sha -I. -I../waifu2x-w2xc -I/usr/include/vapoursynth -fvisibility=hidden -flto -fdiagnostics-color=always -DNDEBUG -pipe -D_FILE_OFFSET_BITS=64 -std=c++14 -ffast-math -mfpmath=sse -msse2 -march=native -O2 -fno-plt -D_FORTIFY_SOURCE=2 -fPIC -MD -MQ 'waifu2x-w2xc@sha/Waifu2x-w2xc_Waifu2x-w2xc.cpp.o' -MF 'waifu2x-w2xc@sha/Waifu2x-w2xc_Waifu2x-w2xc.cpp.o.d' -o 'waifu2x-w2xc@sha/Waifu2x-w2xc_Waifu2x-w2xc.cpp.o' -c ../waifu2x-w2xc/Waifu2x-w2xc/Waifu2x-w2xc.cpp
../waifu2x-w2xc/Waifu2x-w2xc/Waifu2x-w2xc.cpp: En la función ‘bool filter(const VSFrameRef*, VSFrameRef*, Waifu2xData*, const VSAPI*)’:
../waifu2x-w2xc/Waifu2x-w2xc/Waifu2x-w2xc.cpp:71:9: error: ‘w2xconv_convert_rgb_f32’ no se declaró en este ámbito
   71 |     if (w2xconv_convert_rgb_f32(d->conv,
      |         ^~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
with waifu2x-converter-cpp from Deadsix27 fork (with opencv and cuda activated)

EDIT: fail build with this commit of waifu2x-converter-cpp https://github.com/DeadSix27/waifu2x...d1cc0d112549f4

greetings
__________________
[AUR] Vapoursynth Stuff
[AUR] Avisynth Stuff

Last edited by sl1pkn07; 26th February 2020 at 18:33. Reason: bisecting
sl1pkn07 is offline  
Old 27th February 2020, 07:14   #25  |  Link
HolyWu
Registered User
 
Join Date: Aug 2006
Location: Taiwan
Posts: 392
Quote:
Originally Posted by sl1pkn07 View Post
EDIT: fail build with this commit of waifu2x-converter-cpp https://github.com/DeadSix27/waifu2x...d1cc0d112549f4
Fixed.
HolyWu is offline  
Closed Thread

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 17:08.


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