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 Development

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 18th April 2020, 13:32   #5501  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by pinterf View Post
Thanks, seems that there are too many filters for my memory capacity
Suggest 16KB RAM pack upgrade and lump of Bluetack to prevent RAM pack wobble.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline  
Old 24th April 2020, 19:32   #5502  |  Link
dREV
Registered User
 
dREV's Avatar
 
Join Date: Jan 2019
Location: Antarctica
Posts: 74
Hi, I don't know if this is an AviSynth question or a HEVC one. I wanted to ask is it possible to do a script with both chroma shift and chroma upscale (the tattler I think that's what it does) in 4:2:0 encoding in HEVC similarly with a script below?

This is the script I'm currently using:

Code:
dither_convert_8_to_16()
# filter(s)
s16 = last
DitherPost()
# 8 bit filter(s)
dither_convert_8_to_16()
s16.Dither_limit_dif16 (last,)
ly = GradFun3mod(resizer="DebilinearM", lsb_in=true, lsb=true)
lc = nnedi3_resize16(1280*2, 720*2,lsb_in=true,lsb=true,kernel_d="Spline36",kernel_u="Spline36",src_top=0.0,src_left=0.50,nlsb=false)
lu = lc.UtoY()
lv = lc.VtoY()
YtoUV(lu,lv,ly)
Dither_out()
Here's another resize script I also use.

Code:
Y = ConvertToY8().dither_resize16(1280,720,kernel="Spline36")src top and left
U = UToY8().dither_resize16(1280,720,kernel="blackmanminlobe",src_top=0.0,src_left=0.25)
V = VToY8().dither_resize16(1280,720,kernel="blackmanminlobe",src_top=0.0,src_left=0.25)
YToUV(U, V, Y)
I do not understand the language of what it's doing above during resize (ly,lc,lu, yuv) I just like the end results. If someone can either explain or link to an AviSynth wiki so I can sort of understand better I'd appreciate that. I doubt I'll be able to come up with a script.

I get no issues in H264 4:2:0. No issues with HEVC 4:4:4 of course.

Just in case it's asked I am using the correct script in HEVC: --input-depth 16 --profile main10 --input-csp i420 and using AviSynth+ ver 3.5.0. I am also using possibly an out of date avs4x26x if that helps.
dREV is offline  
Old 24th April 2020, 21:06   #5503  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by dREV View Post
Hi, I don't know if this is an AviSynth question or a HEVC one. I wanted to ask is it possible to do a script with both chroma shift and chroma upscale (the tattler I think that's what it does) in 4:2:0 encoding in HEVC similarly with a script below?

This is the script I'm currently using:

Code:
dither_convert_8_to_16()
# filter(s)
s16 = last
DitherPost()
# 8 bit filter(s)
dither_convert_8_to_16()
s16.Dither_limit_dif16 (last,)
ly = GradFun3mod(resizer="DebilinearM", lsb_in=true, lsb=true)
lc = nnedi3_resize16(1280*2, 720*2,lsb_in=true,lsb=true,kernel_d="Spline36",kernel_u="Spline36",src_top=0.0,src_left=0.50,nlsb=false)
lu = lc.UtoY()
lv = lc.VtoY()
YtoUV(lu,lv,ly)
Dither_out()
Here's another resize script I also use.

Code:
Y = ConvertToY8().dither_resize16(1280,720,kernel="Spline36")src top and left
U = UToY8().dither_resize16(1280,720,kernel="blackmanminlobe",src_top=0.0,src_left=0.25)
V = VToY8().dither_resize16(1280,720,kernel="blackmanminlobe",src_top=0.0,src_left=0.25)
YToUV(U, V, Y)
I do not understand the language of what it's doing above during resize (ly,lc,lu, yuv) I just like the end results. If someone can either explain or link to an AviSynth wiki so I can sort of understand better I'd appreciate that. I doubt I'll be able to come up with a script.

I get no issues in H264 4:2:0. No issues with HEVC 4:4:4 of course.

Just in case it's asked I am using the correct script in HEVC: --input-depth 16 --profile main10 --input-csp i420 and using AviSynth+ ver 3.5.0. I am also using possibly an out of date avs4x26x if that helps.
seems you missed this post https://forum.doom9.org/showpost.php...&postcount=405

also this https://forum.doom9.org/showthread.p...65#post1906465
__________________
See My Avisynth Stuff
real.finder is offline  
Old 24th April 2020, 22:09   #5504  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
I find something when I try adding HBD for Ylevels by Didée

Code:
function Ylevels(clip clp,
\                float "input_low", float "gamma", float "input_high",
\                float "output_low", float "output_high", bool "show_function")
{ 
sisavs26 = !(VersionNumber() < 2.60)
    input_low = Default(input_low, 0)
    gamma = Default(gamma, 1.0)
    input_high = Default(input_high, 255)
    output_low = Default(output_low, 0)
    output_high = Default(output_high, 255)
    show_function = Default(show_function, false)
    
    wicked = sisavs26 ? "x " +string(input_low)+ " scalef - " +string(input_high)+ " scalef " +string(input_low)+ " scalef - / 1 " +string(gamma)+
    \        " / ^ " +string(output_high)+ " scalef " +string(output_low)+ " scalef - * " +string(output_low)+ " scalef +"
	\                 : "x " +string(input_low)+ " - " +string(input_high)+ " " +string(input_low)+ " - / 1 " +string(gamma)+
    \        " / ^ " +string(output_high)+ " " +string(output_low)+ " - * " +string(output_low)+ " +"
        
    return( show_function ? clp.subtitle(wicked) : sisavs26 ? clp.mt_lut(Yexpr = wicked, use_expr=2, U=2,V=2) : clp.mt_lut(Yexpr = wicked, U=2,V=2) )  
}

it's ok in 16bit and in float it's ok as I don't set gamma to 1.2

convertbits(32)
Ylevels(40, 1.2, 255, 0, 255, false)
Limiter(0,1,-0.5,0.5)
convertbits(8)

also tried with scale_input="float" but still give white artifacts in dark parts of frame, both with use_expr=2 or without

even if I scale expr with x 255 * and 255 / in the end of expr still same, is there are certain limits if the input is float clip or it's bug?
__________________
See My Avisynth Stuff

Last edited by real.finder; 24th April 2020 at 22:13.
real.finder is offline  
Old 25th April 2020, 06:08   #5505  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
How the formula looks like originally that should be implemented with expr?
pinterf is offline  
Old 25th April 2020, 08:44   #5506  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by pinterf View Post
How the formula looks like originally that should be implemented with expr?
Quote:
output = ( (input - input_low) / (input_high - input_low) )^(1 / gamma) * (output_high - output_low) + output_low
as from http://avisynth.nl/index.php/Levels
__________________
See My Avisynth Stuff
real.finder is offline  
Old 25th April 2020, 11:37   #5507  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Does mt_Infix() no longer work ? [Win7].

Code:
Colorbars(Pixel_type="YV12").ConvertToYV24.ConvertBits(32)
YLevels()
convertToRGB32

# Inside YLevels
    RT_DebugF("Wicked = '%s'",wicked)
    infix = Mt_Infix(wicked)
    RT_DebugF("Infix = '%s'",Infix)
Code:
00000315	0.14433271	[4556] RT_DebugF: Wicked = 'x 0 scalef - 255 scalef 0 scalef - / 1 1.000000 / ^ 255 scalef 0 scalef - * 0 scalef +'	
00000316	0.14450951	[4556] RT_DebugF: Infix = '(0+)'
EDIT: masktools2_x86(NOT_XP)_2.2.18.dll

EDIT: this works so its not totally broken [error in wicked RPN ? (I dont understand that new scalef stuff) ]
Code:
Colorbars
RPN="x y - abs"
IFX=mt_infix(RPN)
RT_DebugF("RPN = '%s'\nIFX = '%s'",RPN,IFX)
Subtitle("RPN = '"+RPN+"'\n"+"IFX = '"+IFX+"'",lsp=0,font="Courier New")

__END__

00000962	0.17500676	[3320] RT_DebugF: RPN = 'x y - abs'
00000963	0.17506003	[3320] RT_DebugF: IFX = 'abs((x-y))'
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 25th April 2020 at 12:25.
StainlessS is offline  
Old 25th April 2020, 12:31   #5508  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
1.) We are at 2.2.21 masktools.
2.) I dont remember is scalef is handled in infix.
3.) Probably power 1 is optimized to do nothing. But 1.00001 should give quite similar result. Does it work?
Cannot check, I'm not near my PC
pinterf is offline  
Old 25th April 2020, 12:47   #5509  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
1) Yeh, its in my Inbox
2.) Seems not in 2.2.18

This looks right after doing scalef thing manually [only for defaults]
Code:
Colorbars
RPN="x 0.0 - 1.0 0.0 - / 1 1.0 / ^ 1.0 0.0 - * 0.0 +"
IFX=mt_infix(RPN)
RT_DebugF("RPN = '%s'\nIFX = '%s'",RPN,IFX)
Subtitle("RPN = '"+RPN+"'\n"+"IFX = '"+IFX+"'",lsp=0,font="Courier New")

__END__

00006458    0.14370735  [3704] RT_DebugF: RPN = 'x 0.0 - 1.0 0.0 - / 1 1.0 / ^ 1.0 0.0 - * 0.0 +'
00006459    0.14376387  [3704] RT_DebugF: IFX = '(((((x-0.0)/(1.0-0.0))^(1/1.0))*(1.0-0.0))+0.0)'

#output = ( (input - input_low) / (input_high - input_low) )^(1 / gamma) * (output_high - output_low) + output_low
I'll see bout installing 2.2.21
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline  
Old 25th April 2020, 13:03   #5510  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
(deleted )

Last edited by pinterf; 25th April 2020 at 13:07.
pinterf is offline  
Old 25th April 2020, 13:23   #5511  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
(deleted )
Yeh, probably cursing me for not using 2.2.21, sorry

Seems ok (InFix scalef thing in 2.2.21, not optimized)

SCRIPT DELETED: See post #5519.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 26th April 2020 at 12:46.
StainlessS is offline  
Old 25th April 2020, 13:40   #5512  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Regarding the expression, don't apply gamma on negative numbers. Limit it before. " 0 max "

Last edited by pinterf; 25th April 2020 at 14:18. Reason: Min max
pinterf is offline  
Old 25th April 2020, 13:48   #5513  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
EDIT: Oops did not see P Post.

SCRIPT DELETED: See post #5519. [EDIT: Not because of above P post, P was answering RF]
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 26th April 2020 at 12:47.
StainlessS is offline  
Old 25th April 2020, 16:04   #5514  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Checked the code in Levels, there is a proper guard:

Code:
if(use_gamma)
        p = (float)pow((double)clamp(p, 0.0f, 1.0f), gamma);
pinterf is offline  
Old 25th April 2020, 16:37   #5515  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
SCRIPT DELETED: See post #5519.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 26th April 2020 at 12:47.
StainlessS is offline  
Old 25th April 2020, 17:11   #5516  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
the question is why there are no problem when 8-16 bits?
__________________
See My Avisynth Stuff
real.finder is offline  
Old 25th April 2020, 17:12   #5517  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Masktools and expr is full float inside, there are proper rounding on conversions.
pinterf is offline  
Old 25th April 2020, 17:15   #5518  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Quote:
Originally Posted by real.finder View Post
the question is why there are no problem when 8-16 bits?
Substitute e.g. x=20 and do the same computing as Expr does for both 8 bit and float (20/255.)
pinterf is offline  
Old 25th April 2020, 18:47   #5519  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
As in below Pinterf next post.
Quote:
Originally Posted by pinterf View Post
Just before gamma clamp to 0-1 regardless from the original bit depth. That's why we normalize the range before applying power function.
Just remove these lines to put back the bug [in two places].
Code:
    \     +  "0 max 1 min "                                                                                    [* P = min(max(P , 0.0), 1.0)                      *]
Code:
Function Ylevels(clip clp,
\                float "input_low", float "gamma", float "input_high",
\                float "output_low", float "output_high", bool "show_function")
{
    input_low     = Default(input_low, 0)
    gamma         = Default(gamma, 1.0)
    input_high    = Default(input_high, 255)
    output_low    = Default(output_low, 0)
    output_high   = Default(output_high, 255)
    show_function = Default(show_function, false)
    #
    invGam  = 1.0 / min(max(0.1,Gamma),10.0)                                                                    # Sane range, avoid div by zero
    divisor = (input_high==input_low) ? 1 : input_high-input_low                                                # Avoid divide by zero
    try { bpc = clp.BitsPerComponent }  catch(msg) { bpc=8 }                                                    # Use scalef only if bpc > 8 (ie Avs+)
    #
    wicked = (bpc>8)                                                                                            [* Use scalef only if > 8 bit ie Avs+              *]
    \  ?     "x " +string(input_low)+" scalef - "+string(divisor)+" scalef / "                                  [* P = (input - input_low) / divisor               *]
    \     +  "0 max 1 min "                                                                                     [* P = min(max(P , 0.0), 1.0)                      *]
    \     +  string(invGam) + " ^ "                                                                             [* P = pow(P, 1.0/Gamma)                           *]
    \     +  string(output_high)+" scalef " +string(output_low)+" scalef - * "+string(output_low)+" scalef +"   [* P = P * (output_high - output_low) + output_low *]
    \  :     "x " +string(input_low)+" - "+string(divisor)+" / "
    \     +  "0 max 1 min "
    \     +  string(invGam) + " ^ "
    \     +  string(output_high)+" " +string(output_low)+" - * "+string(output_low)+" +"
    # UnComment next line to explicitly round & clamp to output range, although Masktools will do this anyway. 32 bit Float NOT rounded. Here as documentation.
    # wicked = wicked + ((bpc==32) ? " 0 max 255 scalef min" : (bpc>8) ? " round 0 max 255 scalef min" : " round 0 max 255 min")     [* P = min(max(int(P+0.5) , 0.0), 255.0) *]
    return( show_function ? clp.subtitle(wicked) : (bpc>8) ? clp.mt_lut(Yexpr = wicked, use_expr=2, U=2,V=2) : clp.mt_lut(Yexpr = wicked, U=2,V=2) )
}
From Levels Docs:-
Quote:
This is one of those filters for which it would really be nice to have a GUI.
Since I can't offer a GUI (at least not in AviSynth's current form), I decided I could at least make this filter compatible with VirtualDub's
when the clip is RGB. In that case you should be able to take the numbers from VirtualDub's Levels dialog and pass them as parameters
to the Levels filter and get the same results. However, the input and output parameters can be larger than 255.
EDIT: And also less than 0 too.

Here specifying both input and output coords outside of colorspace range,
Code:
Ylevels(0-32, 1.0, 255+32, 0-32, 255+32, false)


Also, you should not artifically limit input or output args to the YLevels function.
[EDIT: Original v2.58 (and Beta 2.60) avs Levels used PixelClip on RGB ouput, this was an (in some caes failed) attempt to clamp output RGB and was a bug, a simple Min,Max clamp fixed it. ]

Client for similar to above image.
Code:
SHOW=False
Avisource("D:\Parade.avi")
#Colorbars(width=1920,height=1080,pixel_type="YV12")
#convertbits(16)
convertbits(32)
Ylevels(-32, 1.0, 255+32, 0-32, 255+32, SHOW)
convertbits(8)
Code originating from Levels, AutoLevels and others.
Code:
  gamma = min(max(gamma,0.1f),10.0f);                                                   // ssS: Added sane range limiting (& avoid div by zero on gamma)
  gamma = 1/gamma;
  int divisor = (in_max == in_min) ? 1 : (in_max - in_min);                             // avoid zero divide

    if (vi.IsYUV()) {
        for (int i=0; i<256; ++i) {
            float p;
            if (coring)
                p = ((i-16)*(255.0f/219.0f) - in_min) / divisor;
            else
                p = float(i - in_min) / divisor;                                        // range 0.0 -> 1.0 of input range

            p = pow(min(max(p, 0.0f), 1.0f), gamma);                                    // gamma
            p = p * (out_max - out_min) + out_min;                                      // output range with out_min offset
            int pp;

            if (coring)
                pp = int(p*(219.0f/255.0f)+16.5f);
            else
                pp = int(p+0.5f);                                                       // round to nearest luma level

            map[i] = min(max(pp, (coring) ? 16 : 0), (coring) ? 235 : 255);

            int q = ((i-128) * (out_max-out_min) + (divisor>>1)) / divisor + 128;
            mapchroma[i] = min(max(q, (coring) ? 16 : 0), (coring) ? 240 : 255);
        }
    } else if (vi.IsRGB()) {
        for (int i=0; i<256; ++i) {
            float p = float(i - in_min) / divisor;
            p = pow(min(max(p, 0.0f), 1.0f), gamma);
            p = p * (out_max - out_min) + out_min;
            int z=int(p+0.5f);
            map[i] = (z < 0) ? 0 : (z>255) ? 255 : z;                 // # EDIT: Was originally bugged PixelClip clamping
        }
    }
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 26th April 2020 at 13:41.
StainlessS is offline  
Old 25th April 2020, 20:39   #5520  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Just before gamma clamp to 0-1 regardless from the original bit depth. That's why we normalize the range before applying power function.
pinterf 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 13:17.


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