Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use fmtc/zimg for ssim #82

Closed
NSQY opened this issue Sep 24, 2023 · 1 comment
Closed

use fmtc/zimg for ssim #82

NSQY opened this issue Sep 24, 2023 · 1 comment

Comments

@NSQY
Copy link

NSQY commented Sep 24, 2023

gamma2linear/linear2gamma evil

fmtc fast

yap yap

fastest avs function

Function SSIM_downsample(clip c, int target_width, int target_height, val "smooth", string "kernel", float "epsilon", string "resample_args", string "dither")
{
    smooth = Default(smooth, 1.5)
    kernel = Default(kernel, "z_BicubicResize")
    epsilon = Default(epsilon, 0.000001)
    dither = Default(dither, "none")
    
    c
    _32bits = (BitsPerComponent() == 32)
    
    if (!_32bits)
    {
        ConvertBits(32, fulld=true)
    }   

    resample_args = (Defined(resample_args)) ? ", " + resample_args : ""
    
    l = Eval(kernel + "(" + String(target_width) + "," +  String(target_height) + resample_args + ")")

    if (IsFloat(smooth))
    {
        m = vsTCanny(l, sigmaY=smooth, sigma_vY=smooth, mode=-1)
        r = Expr(vsTCanny(Expr(l, "x dup *"), sigmaY=smooth, sigma_vY=smooth, mode=-1), vsTCanny(Eval(kernel + """(Expr("x x *"),""" + String(target_width) + "," +  String(target_height) + resample_args + ")"), sigmaY=smooth, sigma_vY=smooth, mode=-1), Expr(m, "x dup *"), "x z - "+ String(epsilon) +" < 0 y z - x z - / 0.5 pow ?")
        Expr(vsTCanny(m, sigmaY=smooth, sigma_vY=smooth, mode=-1), vsTCanny(r, sigmaY=smooth, sigma_vY=smooth, mode=-1), l, vsTCanny(Expr(r, m, "x y *"), sigmaY=smooth, sigma_vY=smooth, mode=-1), "x y z * + a -")
    }
    else
    {      
        m = l.Eval(smooth)
        r = Expr(Expr(l, "x dup *").Eval(smooth), Eval(kernel + """(Expr("x x *"),""" + String(target_width) + "," +  String(target_height) + resample_args + ")").Eval(smooth),  Expr(m, "x dup *"), "x z - "+ String(epsilon) +" < 0 y z - x z - / 0.5 pow ?")
        Expr(m.Eval(smooth), r.Eval(smooth), l, Expr(r, m, "x y *").Eval(smooth), "x y z * + a -")        
    }

    if (!_32bits)
    {
        z_ConvertFormat(pixel_type=PixelType(c), dither_type=dither)
    }
}

@Setsugennoao
Copy link
Member

Didn't read but i saw fmtc, avs and yap

@Setsugennoao Setsugennoao closed this as not planned Won't fix, can't repro, duplicate, stale Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants