Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function NRDB( clip input,
- \ string "dither", bool "d_lsb", bool "d_lsb_in",
- \ int "range", int "db_Y", int "db_Cb",
- \ int "db_Cr", int "ditherY", int "ditherC",
- \ bool "dynamic_dither_noise", bool "keep_tv_range",
- \ string "nr", bool "nr_lsb", bool "nr_lsb_in",
- \ bool "nr_Y", bool "nr_U", bool "nr_V",
- \ float "sigma", float "sigma2",
- \ bool "lsb", bool "lsb_in",
- \ int "ditherD", string "ditherCustom" )
- {
- #-----------------------------------------------------------------------------------
- lsb_in = Default( lsb_in, false ) # Input clip is 16-bit stacked or not
- lsb = Default( lsb, false ) # Output clip is 16-bit stacked or not
- src16 = lsb_in ? input : input.Dither_convert_8_to_16()
- src8 = !lsb_in ? input : input.DitherPost(mode=0, ampn=0)
- last = src8
- res = width * height
- ###### "dither" : custom debanding method in string, "nop" for no processing
- d_lsb = Default( d_lsb, false ) # custom debanding method outputs 16-bit stacked clip or not
- d_lsb_in = Default( d_lsb_in, false ) # custom debanding method accepts 16-bit stacked clip or not
- ###### settings in f3kdb
- range = ( res <= 589824 ) ? Default( range, 9 ) :
- \ ( res <= 921600 ) ? Default( range, 12 ) :
- \ Default( range, 15 )
- db_Y = Default( db_Y, 64 )
- db_Cb = Default( db_Cb, 0 )
- db_Cr = Default( db_Cr, 0 )
- ditherY = Default( ditherY, 0 )
- ditherC = Default( ditherC, 0 )
- dynamic_dither_noise = Default( dynamic_dither_noise, false )
- keep_tv_range = Default( keep_tv_range, false )
- ######
- ######
- ###### "nr" : custom denoise method in string, "nop" for no processing
- nr_lsb = Default( nr_lsb, false ) # custom grain generator outputs 16-bit stacked clip or not
- nr_lsb_in = Default( nr_lsb_in, false ) # custom grain generator accepts 16-bit stacked clip or not
- ###### settings in dfttest
- nr_Y = Default( nr_Y, true ) # whether to process Y plane in dfttest
- nr_U = Default( nr_U, false ) # whether to process U plane in dfttest
- nr_V = Default( nr_V, false ) # whether to process V plane in dfttest
- sigma = Default( sigma, 4.0 ) # sigma in dfttest
- sigma2 = Default( sigma2, 4.0 ) # sigma2 in dfttest
- ######
- ######
- ditherD = Default( ditherD, 0 ) # 16-bit to 8-bit dithering method when lsb=false, same as "mode" in DitherPost
- ###### "ditherCustom" : custom dithering method in string, e.g., ditherCustom="DitherPost(mode=2)" gives same result as ditherD=2
- #-----------------------------------------------------------------------------------
- nred = !Defined(nr) ? src8.dfttest( lsb=false, lsb_in=false, dither=0, Y=nr_Y, U=nr_U, V=nr_V, sigma=sigma, sigma2=sigma2 ).Dither_convert_8_to_16()
- \ : ( nr=="nop" || nr=="nop()" ) ? src16
- \ : nr_lsb_in ? nr_lsb ? Eval( "src16." + nr )
- \ : Eval( "src16." + nr + ".Dither_convert_8_to_16()" )
- \ : nr_lsb ? Eval( "src8." + nr )
- \ : Eval( "src8." + nr + ".Dither_convert_8_to_16()" )
- #-----------------------------------------------------------------------------------
- noise = mt_makediff( src16.Dither_get_msb, nred.Dither_get_msb, Y=3, U=3, V=3 )
- #-----------------------------------------------------------------------------------
- nred8 = nred.DitherPost(mode=0, ampn=0)
- db = !Defined(dither) ? nred.f3kdb(range=range, Y=db_Y, Cb=db_Cb, Cr=db_Cr,
- \ ditherY=ditherY, ditherC=ditherC, sample_mode=2,
- \ blur_first=true, dynamic_dither_noise=dynamic_dither_noise, precision_mode=3,
- \ keep_tv_range=keep_tv_range, input_mode=1, output_mode=1 )
- \ : ( dither=="nop" || dither=="nop()" ) ? nred
- \ : d_lsb_in ? d_lsb ? Eval( "nred." + dither )
- \ : Eval( "nred." + dither + ".Dither_convert_8_to_16()" )
- \ : d_lsb ? Eval( "nred8." + dither )
- \ : Eval( "nred8." + dither + ".Dither_convert_8_to_16()" )
- #-----------------------------------------------------------------------------------
- result16 = StackVertical( db.Dither_get_msb.mt_adddiff( noise ), db.Dither_get_lsb )
- result = lsb ? result16 : Defined(ditherCustom) ? Eval("result16."+ditherCustom) : result16.DitherPost(mode=ditherD)
- return result
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement