版面规则
提问时请注意:尽量详细描述操作过程、AVS脚本内容等,最好能写出片名,只贴图有时无法看出问题原因。
提示:发布原创内容请尽量使用附件上传。使用网盘会出现过期失效的问题,请注意。
alexz220
帖子: 115
注册时间: 2012-07-21 17:15

Re: O16 mod v2.1.0 - 简易的Bit Depth转换/输出脚本 新增万能转换函数BitDepth

mawen1250 写了:MPP的具体AVS贴出来


MP_Pipeline("""

SetMemoryMax(1500)

DGDecode_mpeg2source("D:\Temp\Baidu\[Leopard-Raws] Hi no Tori 2772 ~Ai no CosmoZone~ 1980 (1440x1080 MPEG2 AAC).d2v")

crop(0, 20, 0, -20)

trim(3905, 221688)

tfm(mode=1).tdecimate()

src=last

#pre=src.GSMC_sbr(r=2, lsb_in=false, lsb=false)

emask=src.RemoveGrain(11, 11).RemoveGrain(11, 11).TCannyMod(mode=1, sigma=1.2).mt_expand()

### export clip: src, emask
### prefetch: 32, 16
### lock threads to cores
### ###

SetMemoryMax(3500)

nr1=src.SMDegrain(tr=2, thSAD=400, RefineMotion=False, contrasharp=False, interlaced=False, plane=4, prefilter=1, chroma=True, lsb=true, lsb_in=False, lsb_out=true, Show=False, globals=2)
nr2=nr1.SMDegrain(tr=2, thSAD=400, RefineMotion=False, contrasharp=False, interlaced=False, plane=4, prefilter=0, chroma=True, lsb=true, lsb_in=true, lsb_out=true, Show=False, globals=1)

### export clip: nr2, emask, src
### prefetch: 16, 0
### lock threads to cores
### ###

SetMemoryMax(2000)

nr3=nr2.Dither_removegrain16(11, 8)
noise=nr2.Dither_sub16(nr3, y=3, u=3, v=3, dif=true)
db=nr3.f3kdb(range=8, Y=48, Cb=36, Cr=36, grainY=0, grainC=0, input_mode=1, output_mode=1)
db=db.f3kdb(range=15, Y=36, Cb=28, Cr=28, grainY=0, grainC=0, input_mode=1, output_mode=1)
db=db.Dither_limit_dif16(nr3, thr=0.3, elast=3, y=3, u=3, v=3)
db=db.Dither_add16(noise, y=3, u=3, v=3, dif=true)

flat=ALMerge(db, nr2, U=3, V=3)

Dither_merge16_8(flat, src.U16, emask, U=3, V=3)

nrdb=last

nrdb8=nrdb.BitDepth(input_depth=8, output_depth=8)
#nrdb8=nrdb.DitherPost(mode=6)

### export clip: nrdb, nrdb8
### prefetch: 16, 0
### lock threads to cores
### ###

SetMemoryMax(1500)

dbl=mt_merge(nrdb8.Deblock(quant=30), nrdb8, TcannyMod(simga=1.2).mt_expand(), U=3, V=3)

m_dbl=mt_lut(nrdb8, "x 70 >= 255 0 ?", U=2, V=2)

dbl8=mt_merge(nrdb8, dbl, m_dbl).FastLineDarkenMOD(strength=38)

difmask=mt_lutxy(nrdb8, dbl8, "x y = 0 255 ?")

Dither_merge16_8(nrdb,dbl8.U16, difmask, Y=3, U=3, V=3)

GrainFL(g1str=7, g2str=5, g3str=3, g1size=1.25, g2size=1.25, g3size=1.25, g1soft=3, g2soft=3, g3soft=3, th1=24, th2=64, th3=96, th4=160, lsb=true, lsb_in=true)

Down10(stack=false)
#Down10(8)

### prefetch: 32, 0
### lock threads to cores
### ###

""")


原AVS刚才已做修改放弃了deblock(deblock应该在deband前做吧...),
根据回忆恢复了一下。
现在的没有问题




MP_Pipeline("""

SetMemoryMax(1500)

DGDecode_mpeg2source("D:\Temp\Baidu\[Leopard-Raws] Hi no Tori 2772 ~Ai no CosmoZone~ 1980 (1440x1080 MPEG2 AAC).d2v")

crop(0, 20, 0, -20)

trim(3905, 221688)

tfm(mode=1).tdecimate()

src=last

#pre=src.GSMC_sbr(r=2, lsb_in=false, lsb=false)

emask=src.RemoveGrain(11, 11).RemoveGrain(11, 11).TCannyMod(mode=1, sigma=1.2).mt_expand

### export clip: src, emask
### prefetch: 32, 16
### lock threads to cores
### ###

SetMemoryMax(3500)

nr1=src.SMDegrain(tr=2, thSAD=400, RefineMotion=False, contrasharp=False, interlaced=False, plane=4, prefilter=1, chroma=True, lsb=true, lsb_in=False, lsb_out=true, Show=False, globals=2)
nr2=nr1.SMDegrain(tr=2, thSAD=400, RefineMotion=False, contrasharp=False, interlaced=False, plane=4, prefilter=0, chroma=True, lsb=true, lsb_in=true, lsb_out=true, Show=False, globals=1)

### export clip: nr2, emask, src
### prefetch: 16, 0
### lock threads to cores
### ###

SetMemoryMax(2000)

nr3=nr2.Dither_removegrain16(11, 8)
noise=nr2.Dither_sub16(nr3, y=3, u=3, v=3, dif=true)
db=nr3.f3kdb(range=8, Y=48, Cb=36, Cr=36, grainY=0, grainC=0, input_mode=1, output_mode=1)
db=db.f3kdb(range=15, Y=36, Cb=28, Cr=28, grainY=0, grainC=0, input_mode=1, output_mode=1)
db=db.Dither_limit_dif16(nr3, thr=0.3, elast=3, y=3, u=3, v=3)
db=db.Dither_add16(noise, y=3, u=3, v=3, dif=true)

flat=ALMerge(db, nr2, U=3, V=3)

Dither_merge16_8(flat, src.U16, emask, U=3, V=3)

GrainFL(g1str=7, g2str=5, g3str=3, g1size=1.25, g2size=1.25, g3size=1.25, g1soft=3, g2soft=3, g3soft=3, th1=24, th2=64, th3=96, th4=160, lsb=true, lsb_in=true)

Down10(stack=false)
#Down10(8)

### prefetch: 32, 0
### lock threads to cores
### ###

""")
头像
mawen1250
核心会员
核心会员
帖子: 670
注册时间: 2011-07-24 20:33

Re: O16 mod v2.2.0 - 简易的Bit Depth转换/输出脚本 新增万能转换函数BitDepth

v2.2.0
将v2.1.0中CbCr表达式超界的部分通过线性缩放限制在对应Bit Depth的上界,防止CbCr降低Bit Depth且输出为PC Range时导致Overflow。
O16函数中调用的U10由于已删除,用BitDepth代替。
修正O16mod_TestPattern中pixel_type参数无效的问题。
增加O16mod_TestPattern16,O16mod_TestPattern改名为O16mod_TestPattern8。
lwjkk666
帖子: 321
注册时间: 2012-05-29 13:43

Re: O16 mod v2.2.0 - 简易的Bit Depth转换/输出脚本 新增万能转换函数BitDepth

刚更新了win10,开压,提示错误 there is no function named “SmoothCurve16",·插件都是最新版的说。不知道问题出在哪里了,求助,忘记说系统是最新的TH2。

重新覆盖一次又正常。。。。SmoothAdjust这个dll
mrhso
帖子: 33
注册时间: 2016-10-22 17:19

Re: O16 mod v2.2.0 - 简易的Bit Depth转换/输出脚本 新增万能转换函数BitDepth

简单的说,文档中对PC Range下CbCr的定义是以1<<(BitDepth-1)为中值,上下变化范围为[-0.5, 0.5]*(1<<BitDepth-1),所以对于8bit就有了0.5-128-255.5的结果,这是未经量化与Clip的理论值,经过量化与Clip后实际得到的仍然是0-255之间的整数。新版本修正后的结果可能会与原版本有少量区别,但一般都看不出来就是了。
实际上修改并不完全。像是用 BitDepth 去转换 8-bit 到 16-bit 的话,上界是 0.5-0.5 没错,但下界还是 255-65535。
mrhso
帖子: 33
注册时间: 2016-10-22 17:19

Re: O16 mod v2.2.0 - 简易的Bit Depth转换/输出脚本 新增万能转换函数BitDepth

8-bit RGB→16-bit BT.709 (PC) 后,转到 10-bit,再用 BitDepth 转回 16-bit,再回到 8-bit RGB,结果是有问题的。Dither 为 -1,原则上是 Round 没错。
按理来说虽然 RGB 与 YCbCr 转换有损,但是 Round 之后和源是刚好没有差异的。
当然用

代码: 全选

SmoothCurve16(Ycurve="0-0;1023-65535;65535-65535", Ucurve="0-0.5;0.5-0.5;512-32768;1023.5-65535.5;65535-65535.5", Vcurve="0-0.5;0.5-0.5;512-32768;1023.5-65535.5;65535-65535.5", mode=0, interp=0, HQ=False, dither=-1, limiter=False, TVrange=0)
来完成 10-bit→16-bit 没问题,用 BitDepth 就有问题了。我只能认为 BitDepth 的 SmoothCurve 参数计算过程有问题。
考虑到 Down10 的计算与 BitDepth 一样,那就是 Down10 其实也有问题,只不过结果误差小一些所以没明显变化。

回到 “AviSynth”