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 > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 2nd May 2017, 17:13   #1  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Porting SMDegrain to Native High Bit Depth

With Avisynth+ now supporting native high-bit-depth, and MaskTools2 and MvTools2 also supporting high-bit-depth, is anyone interested in modifying SMDegrain to work with full native high-bit-depth?

In the best world, you could simply call SMDegrain with a 16-bit native clip and it would process it all in HBD. In practice, it returns errors. Some side libraries (that probably have HBD replacements) haven't been ported to HBD yet, and a few minor issues can happen along the way.

It shouldn't be very hard but someone's got to do it, sooner or later.

I'll create this thread for those who want to chime in, and let's see where it goes from here.
MysteryX is offline   Reply With Quote
Old 2nd May 2017, 17:21   #2  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
I think real.finder did that already? https://pastebin.com/Mz5taAgN

Quote:
masktools 2.2.5 or up now required in avs26 and avs+ now work basically with new high bit depth in avs+
His Avisynth Stuff
https://forum.doom9.org/showthread.php?t=174121
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database
ChaosKing is offline   Reply With Quote
Old 2nd May 2017, 17:38   #3  |  Link
dipje
Registered User
 
Join Date: Oct 2014
Posts: 268
I know vapoursynth is not avisynth but vapoursynth has a ported smdegrain script with high bitdepth in havsfunc. (I don't know if it's a direct port or takes some liberties ).
Could at least be useful to take a peek how it works in vpy .
dipje is offline   Reply With Quote
Old 2nd May 2017, 17:58   #4  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
I get
Quote:
MDegrain2 : no valid DEGRAINLUMA function for 16x16, pixelsize=2, lsb_flag=1, level=2
MysteryX is offline   Reply With Quote
Old 2nd May 2017, 18:18   #5  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
work fine for me, seems you have old mvtools2 and you try use lsb
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 2nd May 2017, 18:39   #6  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,542
Is there any convenience (and way) to process 8 bit video in 16 bit space and back?
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 2nd May 2017, 19:06   #7  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by tormento View Post
Is there any convenience (and way) to process 8 bit video in 16 bit space and back?
Code:
convertbits(16)
filter1
filter2
filter3
convertbits(8) #without dither, you can set the setting to do dither too
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 2nd May 2017, 19:17   #8  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
Quote:
Originally Posted by real.finder View Post
you try use lsb
Duh!

Works now... but performance isn't good at all!

8-bit
Code:
FPS (min | max | average):      1.874 | 101671 | 18.11
Memory usage (phys | virt):     757 | 775 MiB
Thread count:                   34
CPU usage (average):            77%
16-bit
Code:
FPS (min | max | average):      0.288 | 47.37 | 3.171
Memory usage (phys | virt):     1059 | 1095 MiB
Thread count:                   32
CPU usage (average):            76%
Something is wrong here.
MysteryX is offline   Reply With Quote
Old 5th May 2017, 19:29   #9  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,542
Quote:
Originally Posted by real.finder View Post
Code:
convertbits(16)
filter1
filter2
filter3
convertbits(8) #without dither, you can set the setting to do dither too
  1. How have I to set lsb, lsb_in, lsb_out and mode to let use SMDegrainMOD in full 16 bit mode and leave Avisynth to dither with convertbits(8)?
  2. Is there a way to make SMDegrainMOD work in 16 bit AND output a 8 bit video?
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 5th May 2017, 20:34   #10  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by tormento View Post
How have I to set lsb, lsb_in, lsb_out and mode to let use SMDegrainMOD in full 16 bit mode and leave Avisynth to dither with convertbits(8)?[/LIST]
lsb=hack, just forget it in avs+ HBD

use the lines I post last time will do everything in full 16 bit

Quote:
Originally Posted by tormento View Post
Is there a way to make SMDegrainMOD work in 16 bit AND output a 8 bit video?
yes with add another parameter to do that but why?! it make no sense, stay with lsb will be better and faster
__________________
See My Avisynth Stuff

Last edited by real.finder; 5th May 2017 at 20:37.
real.finder is offline   Reply With Quote
Old 5th May 2017, 20:39   #11  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,542
Quote:
Originally Posted by real.finder View Post
use the lines I post last time will do everything in full 16 bit
Has mode to be set to -1?
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 5th May 2017, 20:43   #12  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by tormento View Post
Has mode to be set to -1?
mode in SMDegrain? will do nothing without lsb things

convertbits() in avs+ has dither modes, you can set that when you back to 8 bit
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 5th May 2017, 20:48   #13  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,542
Quote:
Originally Posted by real.finder View Post
mode in SMDegrain? will do nothing without lsb things

convertbits() in avs+ has dither modes, you can set that when you back to 8 bit
My default parameters are
PHP Code:
SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true,lsb=true,mode=0
So I have to modify them as
PHP Code:
SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true
right?
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 5th May 2017, 20:55   #14  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by tormento View Post
My default parameters are
PHP Code:
SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true,lsb=true,mode=0
So I have to modify them as
PHP Code:
SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true
right?
yes, but even if you leave mode=0 it will do nothing without lsb

and set dither=0 in convertbits() will give you dither like mode=0
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Old 5th May 2017, 21:17   #15  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,542
Quick test results

PHP Code:
SetMemoryMax(8000)
SetFilterMTMode("DEFAULT_MT_MODE"2)
SetFilterMTMode("ChangeFPS"3)
SetFilterMTMode("DGSource"3)
LoadPlugin("D:\eseguibili\media\DGDecNV\x64\DGDecodeNV.dll")
DGSource("E:\in\1_55 founder, The\founder.dgi")
CompTest(1)
ChangeFPS(last,last,true)
SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true,lsb=true,mode=0)
Prefetch(6
Code:
[2017-05-05][21:58:43] encoded 1680 frames, 12.38 fps, 3004.32 kb/s, duration 0:02:15.65
[2017-05-05][21:58:43] av2y [info]: E:\in\1_55FO~1\founde~1.avs: 1920x800, YV12, 8-bits, progressive, 24 fps, 1680 frames
[2017-05-05][21:58:43] Final file size is 25.1 MB bytes.
PHP Code:
SetMemoryMax(8000)
SetFilterMTMode("DEFAULT_MT_MODE"2)
SetFilterMTMode("ChangeFPS"3)
SetFilterMTMode("DGSource"3)
LoadPlugin("D:\eseguibili\media\DGDecNV\x64\DGDecodeNV.dll")
DGSource("E:\in\1_55 founder, The\founder.dgi")
CompTest(1)
ChangeFPS(last,last,true)
convertbits(16)
SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true)
convertbits(8)
Prefetch(6
Code:
[2017-05-05][22:01:59] encoded 1680 frames, 9.76 fps, 3343.63 kb/s, duration 0:02:52.06
[2017-05-05][22:01:59] av2y [info]: E:\in\1_55FO~1\founde~2.avs: 1920x800, YV12, 8-bits, progressive, 24 fps, 1680 frames
[2017-05-05][22:01:59] Final file size is 27.9 MB bytes.
PHP Code:
SetMemoryMax(8000)
SetFilterMTMode("DEFAULT_MT_MODE"2)
SetFilterMTMode("ChangeFPS"3)
SetFilterMTMode("DGSource"3)
LoadPlugin("D:\eseguibili\media\DGDecNV\x64\DGDecodeNV.dll")
DGSource("E:\in\1_55 founder, The\founder.dgi")
CompTest(1)
ChangeFPS(last,last,true)
convertbits(16)
SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true)
convertbits(8,dither=0)
Prefetch(6
Code:
[2017-05-05][22:06:02] encoded 1680 frames, 9.70 fps, 3164.08 kb/s, duration 0:02:53.15
[2017-05-05][22:06:02] av2y [info]: E:\in\1_55FO~1\founde~3.avs: 1920x800, YV12, 8-bits, progressive, 24 fps, 1680 frames
[2017-05-05][22:06:02] Final file size is 26.4 MB bytes.
PHP Code:
SetMemoryMax(8000)
SetFilterMTMode("DEFAULT_MT_MODE"2)
SetFilterMTMode("ChangeFPS"3)
SetFilterMTMode("DGSource"3)
LoadPlugin("D:\eseguibili\media\DGDecNV\x64\DGDecodeNV.dll")
DGSource("E:\in\1_55 founder, The\founder.dgi")
CompTest(1)
ChangeFPS(last,last,true)
convertbits(16)
SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true)
convertbits(8,dither=1)
Prefetch(6
Code:
[2017-05-05][22:09:02] encoded 1680 frames, 9.62 fps, 3132.65 kb/s, duration 0:02:54.63
[2017-05-05][22:09:02] av2y [info]: E:\in\1_55FO~1\founde~4.avs: 1920x800, YV12, 8-bits, progressive, 24 fps, 1680 frames
[2017-05-05][22:09:02] Final file size is 26.2 MB bytes.
Regarding plain bitrate, 8 bit + lsb is clearly a winner, both speed and final size.

Regarding visual quality, need time to decide
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 5th May 2017, 21:42   #16  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,542
Tests on more grainy source

The Silence of the Lambs BD

PHP Code:
SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true,lsb=true,mode=0
Code:
[2017-05-05][22:23:48] encoded 1708 frames, 9.44 fps, 4109.46 kb/s, duration 0:03:00.98
[2017-05-05][22:23:48] av2y [info]: E:\in\1_58SI~1\silenz~1.avs: 1920x1032, YV12, 8-bits, progressive, 24000/1001 fps, 1708 frames
[2017-05-05][22:23:48] Final file size is 34.9 MB bytes.
PHP Code:
convertbits(16)
SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true)
convertbits(8,dither=1
Code:
[2017-05-05][22:29:18] encoded 1708 frames, 6.30 fps, 6812.83 kb/s, duration 0:04:31.24
[2017-05-05][22:29:18] av2y [info]: E:\in\1_58SI~1\silenz~2.avs: 1920x1032, YV12, 8-bits, progressive, 24000/1001 fps, 1708 frames
[2017-05-05][22:29:18] Final file size is 57.9 MB bytes.
PHP Code:
SMDegrain (tr=6,PreFilter=4,thSAD=600,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true,lsb=true,mode=0
Code:
[2017-05-05][22:34:43] encoded 1708 frames, 7.59 fps, 3702.49 kb/s, duration 0:03:44.95
[2017-05-05][22:34:43] av2y [info]: E:\in\1_58SI~1\silenz~3.avs: 1920x1032, YV12, 8-bits, progressive, 24000/1001 fps, 1708 frames
[2017-05-05][22:34:43] Final file size is 31.5 MB bytes.
PHP Code:
convertbits(16)
SMDegrain (tr=6,PreFilter=4,thSAD=600,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true)
convertbits(8,dither=1
Code:
[2017-05-05][22:40:39] encoded 1708 frames, 4.88 fps, 6839.06 kb/s, duration 0:05:49.72
[2017-05-05][22:40:39] av2y [info]: E:\in\1_58SI~1\silenz~4.avs: 1920x1032, YV12, 8-bits, progressive, 24000/1001 fps, 1708 frames
[2017-05-05][22:40:39] Final file size is 58.1 MB bytes.
Very strange results about bitrate difference between 8 bit and 16 bit noise reduction. Any idea?
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 5th May 2017, 22:49   #17  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
The noise level has a large impact on the compress-ability of the video and output size.
MysteryX is offline   Reply With Quote
Old 6th May 2017, 19:23   #18  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,542
Quote:
Originally Posted by MysteryX View Post
The noise level has a large impact on the compress-ability of the video and output size.
Ok and why so much difference between processing in 8 or 16 bit?
__________________
@turment on Telegram
tormento is offline   Reply With Quote
Old 8th May 2017, 17:44   #19  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
OK I found the performance problem: MinBlur.
Code:
MinBlur(2,3,true)
8-bit
Code:
FPS (min | max | average):      5.066 | 146152 | 59.99
Memory usage (phys | virt):     155 | 153 MiB
Thread count:                   29
CPU usage (average):            66%
16-bit
Code:
FPS (min | max | average):      0.961 | 66813 | 10.50
Memory usage (phys | virt):     222 | 220 MiB
Thread count:                   29
CPU usage (average):            77%
Considering MedianBlur2's latest version was in 2014, it most certainly doesn't support native high-bit-depth, so I'm surprised it's not crashing, but it's probably not doing what we want.
MysteryX is offline   Reply With Quote
Old 23rd May 2017, 06:37   #20  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,559
real.finder, I believe you said MinBlur was only performed on 8-bit-depth?

Code:
input8h = defined(input8h) && isclip(input8h) ? input8h : lsb_in      ?             inputP. Ditherpost(mode=6, slice=slices)                                                    : nop()
input8y = defined(input8y)                    ? input8y : planar      ? (lsb_in   ? input8h.Dither_YUY2toInterleaved()   :  inputP)                                             : inputP
input8  = defined(input8 )                    ? input8  : lsb_in      ? (planar   ? input8y.Interleaved2planar()         : input8h)                                             : input8y
This converts to 8-bit only when using lsb, and native 16-bit remains in 16-bit. Call SMDegrain_prefilters.Info() in 16-bit and the result is corrupt with vertical bars.
MysteryX is offline   Reply With Quote
Reply

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 06:14.


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