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. |
|
|
Thread Tools | Search this Thread | Display Modes |
25th May 2010, 19:28 | #1 | Link | |
Architect
Join Date: May 2010
Posts: 57
|
Deblock_QED updated (requires MaskTools 2.0a45 or later)
According to MaskTools 2.0a43 change log:
Quote:
Thus, I have modified Deblock_QED to account for the change. I have also modified Deblock_QED to pad the input clip with borders internally if the clip is not mod 16. The full script is shown below: Code:
# Changes 2008-08-18: (Didée) # - Replaced the ugly stackXXX cascade with mt_LutSpa() (requires MaskTools v2.0a35) # - Changed Quant and Offset defaults to 24,28,2,4,4,8 # Changes 2010-05-25: # - Explicitly specified parameters of mt_LutSpa() # (required due to position of new 'biased' parameter, starting from MaskTools 2.0a43) # - Non mod 16 input is now padded with borders internally # Changes 2010-08-18: # - Replaced AddBorders with PointResize # - Changed Quant and Offset defaults to 18,19,3,4,1,1 to reduce blurring # Changes 2010-10-16: # - Replaced 'relative' with the new 'mode' parameter in mt_LutSpa(), starting from MaskTools 2.0a45 # - Changed Quant and Offset defaults to 24,26,1,1,2,2 to increase effectiveness, but still within sensible limits. # (see for details: http://forum.doom9.org/showthread.php?p=810932#post810932) function Deblock_QED ( clip clp, int "quant1", int "quant2", \ int "aOff1", int "bOff1", int "aOff2", int "bOff2", int "uv" ) { quant1 = default( quant1, 24 ) # Strength of block edge deblocking quant2 = default( quant2, 26 ) # Strength of block internal deblocking aOff1 = default( aOff1, 1 ) # halfway "sensitivity" and halfway a strength modifier for borders aOff2 = default( aOff2, 1 ) # halfway "sensitivity" and halfway a strength modifier for block interiors bOff1 = default( bOff1, 2 ) # "sensitivity to detect blocking" for borders bOff2 = default( bOff2, 2 ) # "sensitivity to detect blocking" for block interiors uv = default( uv, 3 ) # u=3 -> use proposed method for chroma deblocking # u=2 -> no chroma deblocking at all (fastest method) # u=1|-1 -> directly use chroma debl. from the normal|strong deblock() # add borders if clp is not mod 8 padX = clp.width%8 == 0 ? 0 : (8 - clp.width%8) padY = clp.height%8 == 0 ? 0 : (8 - clp.height%8) clp=clp.pointresize(clp.width+padX, clp.height+padY, 0, 0, clp.width+padX, clp.height+padY) # block block = clp.mt_LutSpa(mode="absolute",expr="x 1 + 8 % 1 < x 8 % 1 < y 1 + 8 % 1 < y 8 % 1 < | | | 255 0 ?",U=3,V=3) # create normal deblocking (for block borders) and strong deblocking (for block interiour) normal = clp.deblock(quant=quant1,aOffset=aOff1,bOffset=bOff1) strong = clp.deblock(quant=quant2,aOffset=aOff2,bOffset=bOff2) # build difference maps of both normalD = mt_makediff(clp,normal,chroma=uv>2?"process":"ignore") strongD = mt_makediff(clp,strong,chroma=uv>2?"process":"ignore") # separate border values of the difference maps, and set the interiours to '128' normalD2 = mt_lutxy(normalD,block,expr="y 255 == x 128 ?",U=uv,V=uv) strongD2 = mt_lutxy(StrongD,block,expr="y 255 == x 128 ?",U=uv,V=uv) # interpolate the border values over the whole block: DCTFilter can do it. (Kiss to Tom Barry!) # (Note: this is not fully accurate, but a reasonable approximation.) # add borders if clp is not mod 16 sw=strongD2.width sh=strongD2.height remX = sw%16 == 0 ? 0 : (16 - sw%16) remY = sh%16 == 0 ? 0 : (16 - sh%16) strongD3 = strongD2.pointresize(sw+remX, sh+remY, 0, 0, sw+remX, sh+remY).mt_lut(expr="x 128 - 1.01 * 128 +",U=uv,V=uv)\ .dctfilter(1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0).crop(0,0,-remX,-remY) # apply compensation from "normal" deblocking to the borders of # the full-block-compensations calculated from "strong" deblocking ... strongD4 = mt_lutxy(strongD3,normalD2,expr="y 128 == x y ?",U=uv,V=uv) # ... and apply it. deblocked= mt_makediff(clp,strongD4,chroma=uv>2?"process":"ignore") # simple decisions how to treat chroma deblocked = (uv<0) ? deblocked.mergechroma(strong) : uv<2 ? deblocked.mergechroma(normal) : deblocked deblocked.crop(0,0,-padX,-padY) # remove mod 8 borders } Also, Didée, in your comments you said: Code:
# interpolate the border values over the whole block: DCTFilter can do it. (Kiss to Tom Barry!) # (Note: this is not fully accurate, but a reasonable approximation.) I ask because Deblock requires mod 8 input but DCTFilter requires mod 16 input. EDIT: Since the change to mt_LutSpa will remain in future versions of MaskTools 2.0, Deblock_QED must be updated to continue working with these new versions. I have tested this script with several sources and haven't found any errors. If anyone has problems running the script then please post about it. UPDATE (2010-10-16): Deblock_QED now uses the new 'mode' parameter in mt_LutSpa(), which requires MaskTools 2.0a45 or later. Last edited by Bi11; 16th October 2010 at 22:00. Reason: Updated defaults for greater effectiveness, but still within sensible limits |
|
25th May 2010, 19:51 | #2 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
A better solution, IMHO, would be for Manao to update Masktools, moving the 'biased' parameter to the end of the list. This should be standard practice when introducing new options, to preserve backwards compatibility. |
|
30th May 2010, 22:05 | #4 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
In the given case it is not even clear what a "fully accurate" interpolation actually is. The kind of interpolation I used via DCTFilter certainly is of the sort "it does make sense". If it is "correct" or "accurate", that is playground for arguing.
If anything, I would be more concerned about the 6x6 -> 8x8 transition (which is ugly and can show up with some certain settings), or about why it's not possible to use one Deblock base for both processing paths (deblock is always called two times), or about directed border-postprocessing on the diff's, or .. or .. or ....
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
31st May 2010, 01:23 | #5 | Link | |
Architect
Join Date: May 2010
Posts: 57
|
Code:
# (Note: this is not fully accurate, but a reasonable approximation.) I simply wanted to avoid having a mod 16 restriction on the input because it seems unnecessarily stricter than the mod 8 restriction imposed by Deblock. In any case, thanks for making such a useful deblocking script Didée. Quote:
Off topic: Can someone compile a 64-bit version of DCTFilter please? Thanks. Deblock12_x64 can be found here. |
|
31st May 2010, 07:51 | #6 | Link | |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Quote:
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
|
23rd June 2010, 23:32 | #7 | Link |
Big Bit Savings Now !
Join Date: Feb 2007
Location: close to the wall
Posts: 1,545
|
BTW, many thanks, Bi11 !
I just updated masktools and ran into the mt_lutspa error. And your update helped.
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain) "Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..." |
30th March 2012, 01:10 | #9 | Link |
Registered User
Join Date: Mar 2004
Posts: 889
|
Code:
# Changes 2008-08-18: (Didee) # - Replaced the ugly stackXXX cascade with mt_LutSpa() (requires MaskTools v2.0a35) # - Changed Quant and Offset defaults to 24,28,2,4,4,8 # Changes 2010-05-25: # - Explicitly specified arguments to mt_LutSpa # - Non mod 8 input is now padded with borders internally function Deblock_QED ( clip clp, int "quant1", int "quant2", \ int "aOff1", int "bOff1", int "aOff2", int "bOff2", int "uv" ) { quant1 = default( quant1, 24 ) # Strength of block edge deblocking. quant2 = default( quant2, 28 ) # Strength of block internal deblocking. aOff1 = default( aOff1, 2 ) # halfway "sensitivity" and halfway a strength modifier for borders bOff1 = default( bOff1, 4 ) # "sensitivity to detect blocking" for borders aOff2 = default( aOff2, 4 ) # halfway "sensitivity" and halfway a strength modifier for block interiors bOff2 = default( bOff2, 8 ) # "sensitivity to detect blocking" for block interiors uv = default( uv, 3 ) # u=3 -> use proposed method for chroma deblocking # u=2 -> no chroma deblocking at all (fastest method) # u=1|-1 -> directly use chroma debl. from the normal|strong deblock() # add borders if clp is not mod 8 padX = clp.width%8 == 0 ? 0 : (8 - clp.width%8) padY = clp.height%8 == 0 ? 0 : (8 - clp.height%8) clp=clp.addborders(0, 0, padX, padY) # block block = clp.mt_LutSpa(relative=false, expr="x 1 + 8 % 1 < x 8 % 1 < y 1 + 8 % 1 < y 8 % 1 < | | | 255 0 ?", U=3, V=3) # create normal deblocking (for block borders) and strong deblocking (for block interiour) normal = clp.deblock(quant=quant1,aOffset=aOff1,bOffset=bOff1) strong = clp.deblock(quant=quant2,aOffset=aOff2,bOffset=bOff2) # build difference maps of both normalD = mt_makediff(clp,normal,chroma=uv>2?"process":"ignore") strongD = mt_makediff(clp,strong,chroma=uv>2?"process":"ignore") # separate border values of the difference maps, and set the interiours to '128' normalD2 = mt_lutxy(normalD,block,expr="y 255 == x 128 ?",U=uv,V=uv) strongD2 = mt_lutxy(StrongD,block,expr="y 255 == x 128 ?",U=uv,V=uv) # interpolate the border values over the whole block: DCTFilter can do it. (Kiss to Tom Barry!) # (Note: this is not fully accurate, but a reasonable approximation.) # add borders if clp is not mod 16 remX = strongD2.width%16 == 0 ? 0 : (16 - strongD2.width%16) remY = strongD2.height%16 == 0 ? 0 : (16 - strongD2.height%16) strongD3 = strongD2.addborders(0, 0, remX, remY).mt_lut(expr="x 128 - 1.01 * 128 +",U=uv,V=uv)\ .dctfilter(1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0).crop(0, 0, -remX, -remY) # apply compensation from "normal" deblocking to the borders of # the full-block-compensations calculated from "strong" deblocking ... strongD4 = mt_lutxy(strongD3,normalD2,expr="y 128 == x y ?",U=uv,V=uv) # ... and apply it. deblocked= mt_makediff(clp,strongD4,chroma=uv>2?"process":"ignore") # simple decisions how to treat chroma deblocked = (uv<0) ? deblocked.mergechroma(strong) : uv<2 ? deblocked.mergechroma(normal) : deblocked deblocked.crop(0, 0, -padX, -padY) # remove mod 8 borders return( last ) } |
4th April 2012, 01:18 | #10 | Link |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,666
|
Hello, I came across an updated Deblock_QED (2011-11-29) by 06_taro.
http://www.nmm-hd.org/newbbs/viewtopic.php?f=7&t=475 Code:
# Changes 2008-08-18: (Didée) # - Replaced the ugly stackXXX cascade with mt_LutSpa() (requires MaskTools v2.0a35) # - Changed Quant and Offset defaults to 24,28,2,4,4,8 # Changes 2010-05-25: # - Explicitly specified parameters of mt_LutSpa() # (required due to position of new 'biased' parameter, starting from MaskTools 2.0a43) # - Non mod 16 input is now padded with borders internally # Changes 2010-08-18: # - Replaced AddBorders with PointResize # - Changed Quant and Offset defaults to 18,19,3,4,1,1 to reduce blurring # Changes 2010-10-16: # - Replaced 'relative' with the new 'mode' parameter in mt_LutSpa(), starting from MaskTools 2.0a45 # - Changed Quant and Offset defaults to 24,26,1,1,2,2 to increase effectiveness, but still within sensible limits. # (see for details: http://forum.doom9.org/showthread.php?p=810932#post810932) # Changes 2011-11-29: (06_taro) # - Replaced (chroma=uv>2?"process":"ignore") by (chroma=uv>2?"process":"copy") to avoid garbage clip when uv=2. # The formal parameter is not used by MaskTools2 any more, if ever used. # Foxyshadis once mentioned chroma="ignore" but I had never found a document containing it. function Deblock_QED ( clip clp, int "quant1", int "quant2", \ int "aOff1", int "bOff1", int "aOff2", int "bOff2", int "uv" ) { quant1 = default( quant1, 24 ) # Strength of block edge deblocking quant2 = default( quant2, 26 ) # Strength of block internal deblocking aOff1 = default( aOff1, 1 ) # halfway "sensitivity" and halfway a strength modifier for borders aOff2 = default( aOff2, 1 ) # halfway "sensitivity" and halfway a strength modifier for block interiors bOff1 = default( bOff1, 2 ) # "sensitivity to detect blocking" for borders bOff2 = default( bOff2, 2 ) # "sensitivity to detect blocking" for block interiors uv = default( uv, 3 ) # u=3 -> use proposed method for chroma deblocking # u=2 -> no chroma deblocking at all (fastest method) # u=1|-1 -> directly use chroma debl. from the normal|strong deblock() # add borders if clp is not mod 8 padX = clp.width%8 == 0 ? 0 : (8 - clp.width%8) padY = clp.height%8 == 0 ? 0 : (8 - clp.height%8) clp=clp.pointresize(clp.width+padX, clp.height+padY, 0, 0, clp.width+padX, clp.height+padY) # block block = clp.mt_LutSpa(mode="absolute",expr="x 1 + 8 % 1 < x 8 % 1 < y 1 + 8 % 1 < y 8 % 1 < | | | 255 0 ?",U=3,V=3) # create normal deblocking (for block borders) and strong deblocking (for block interiour) normal = clp.deblock(quant=quant1,aOffset=aOff1,bOffset=bOff1) strong = clp.deblock(quant=quant2,aOffset=aOff2,bOffset=bOff2) # build difference maps of both normalD = mt_makediff(clp,normal,chroma=uv>2?"process":"copy") strongD = mt_makediff(clp,strong,chroma=uv>2?"process":"copy") # separate border values of the difference maps, and set the interiours to '128' normalD2 = mt_lutxy(normalD,block,expr="y 255 == x 128 ?",U=uv,V=uv) strongD2 = mt_lutxy(StrongD,block,expr="y 255 == x 128 ?",U=uv,V=uv) # interpolate the border values over the whole block: DCTFilter can do it. (Kiss to Tom Barry!) # (Note: this is not fully accurate, but a reasonable approximation.) # add borders if clp is not mod 16 sw=strongD2.width sh=strongD2.height remX = sw%16 == 0 ? 0 : (16 - sw%16) remY = sh%16 == 0 ? 0 : (16 - sh%16) strongD3 = strongD2.pointresize(sw+remX, sh+remY, 0, 0, sw+remX, sh+remY).mt_lut(expr="x 128 - 1.01 * 128 +",U=uv,V=uv)\ .dctfilter(1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0).crop(0,0,-remX,-remY) # apply compensation from "normal" deblocking to the borders of # the full-block-compensations calculated from "strong" deblocking ... strongD4 = mt_lutxy(strongD3,normalD2,expr="y 128 == x y ?",U=uv,V=uv) # ... and apply it. deblocked= mt_makediff(clp,strongD4,chroma=uv>2?"process":"copy") # simple decisions how to treat chroma deblocked = (uv<0) ? deblocked.mergechroma(strong) : uv<2 ? deblocked.mergechroma(normal) : deblocked deblocked.crop(0,0,-padX,-padY) # remove mod 8 borders } |
21st October 2014, 00:56 | #13 | Link |
Registered User
Join Date: Apr 2010
Location: I have a statue in Hakodate, Japan
Posts: 744
|
Inadvertently Deblock_QED called indifferently to plugin deblock or function deblock of DGDecode, this could be a problem if a value of 'quant'> 51 is required.
Here is the correction: Code:
# Changes 2008-08-18: (Didée) # - Replaced the ugly stackXXX cascade with mt_LutSpa() (requires MaskTools v2.0a35) # - Changed Quant and Offset defaults to 24,28,2,4,4,8 # Changes 2010-05-25: # - Explicitly specified parameters of mt_LutSpa() # (required due to position of new 'biased' parameter, starting from MaskTools 2.0a43) # - Non mod 16 input is now padded with borders internally # Changes 2010-08-18: # - Replaced AddBorders with PointResize # - Changed Quant and Offset defaults to 18,19,3,4,1,1 to reduce blurring # Changes 2010-10-16: # - Replaced 'relative' with the new 'mode' parameter in mt_LutSpa(), starting from MaskTools 2.0a45 # - Changed Quant and Offset defaults to 24,26,1,1,2,2 to increase effectiveness, but still within sensible limits. # (see for details: http://forum.doom9.org/showthread.php?p=810932#post810932) # Changes 2011-11-29: (06_taro) # - Replaced (chroma=uv>2?"process":"ignore") by (chroma=uv>2?"process":"copy") to avoid garbage clip when uv=2. # The formal parameter is not used by MaskTools2 any more, if ever used. # Foxyshadis once mentioned chroma="ignore" but I had never found a document containing it. # Changes 2014-10-20: # - Now calling to plugin deblock exclusively and not to the older function deblock of DGDecode function Deblock_QED ( clip clp, int "quant1", int "quant2", \ int "aOff1", int "bOff1", int "aOff2", int "bOff2", int "uv" ) { quant1 = default( quant1, 24 ) # Strength of block edge deblocking quant2 = default( quant2, 26 ) # Strength of block internal deblocking aOff1 = default( aOff1, 1 ) # halfway "sensitivity" and halfway a strength modifier for borders aOff2 = default( aOff2, 1 ) # halfway "sensitivity" and halfway a strength modifier for block interiors bOff1 = default( bOff1, 2 ) # "sensitivity to detect blocking" for borders bOff2 = default( bOff2, 2 ) # "sensitivity to detect blocking" for block interiors uv = default( uv, 3 ) # u=3 -> use proposed method for chroma deblocking # u=2 -> no chroma deblocking at all (fastest method) # u=1|-1 -> directly use chroma debl. from the normal|strong deblock() # add borders if clp is not mod 8 padX = clp.width%8 == 0 ? 0 : (8 - clp.width%8) padY = clp.height%8 == 0 ? 0 : (8 - clp.height%8) clp=clp.pointresize(clp.width+padX, clp.height+padY, 0, 0, clp.width+padX, clp.height+padY) # block block = clp.mt_LutSpa(mode="absolute",expr="x 1 + 8 % 1 < x 8 % 1 < y 1 + 8 % 1 < y 8 % 1 < | | | 255 0 ?",U=3,V=3) # create normal deblocking (for block borders) and strong deblocking (for block interiour) normal = clp.Deblock_deblock(quant=quant1,aOffset=aOff1,bOffset=bOff1) strong = clp.Deblock_deblock(quant=quant2,aOffset=aOff2,bOffset=bOff2) # build difference maps of both normalD = mt_makediff(clp,normal,chroma=uv>2?"process":"copy") strongD = mt_makediff(clp,strong,chroma=uv>2?"process":"copy") # separate border values of the difference maps, and set the interiours to '128' normalD2 = mt_lutxy(normalD,block,expr="y 255 == x 128 ?",U=uv,V=uv) strongD2 = mt_lutxy(StrongD,block,expr="y 255 == x 128 ?",U=uv,V=uv) # interpolate the border values over the whole block: DCTFilter can do it. (Kiss to Tom Barry!) # (Note: this is not fully accurate, but a reasonable approximation.) # add borders if clp is not mod 16 sw=strongD2.width sh=strongD2.height remX = sw%16 == 0 ? 0 : (16 - sw%16) remY = sh%16 == 0 ? 0 : (16 - sh%16) strongD3 = strongD2.pointresize(sw+remX, sh+remY, 0, 0, sw+remX, sh+remY).mt_lut(expr="x 128 - 1.01 * 128 +",U=uv,V=uv)\ .dctfilter(1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0).crop(0,0,-remX,-remY) # apply compensation from "normal" deblocking to the borders of # the full-block-compensations calculated from "strong" deblocking ... strongD4 = mt_lutxy(strongD3,normalD2,expr="y 128 == x y ?",U=uv,V=uv) # ... and apply it. deblocked= mt_makediff(clp,strongD4,chroma=uv>2?"process":"copy") # simple decisions how to treat chroma deblocked = (uv<0) ? deblocked.mergechroma(strong) : uv<2 ? deblocked.mergechroma(normal) : deblocked deblocked.crop(0,0,-padX,-padY) # remove mod 8 borders } |
8th May 2016, 23:00 | #14 | Link |
Registered User
Join Date: Jan 2010
Posts: 709
|
modded a bit to avoid useless chroma processing
Code:
# Changes 2008-08-18: (Didée) # - Replaced the ugly stackXXX cascade with mt_LutSpa() (requires MaskTools v2.0a35) # - Changed Quant and Offset defaults to 24,28,2,4,4,8 # Changes 2010-05-25: # - Explicitly specified parameters of mt_LutSpa() # (required due to position of new 'biased' parameter, starting from MaskTools 2.0a43) # - Non mod 16 input is now padded with borders internally # Changes 2010-08-18: # - Replaced AddBorders with PointResize # - Changed Quant and Offset defaults to 18,19,3,4,1,1 to reduce blurring # Changes 2010-10-16: # - Replaced 'relative' with the new 'mode' parameter in mt_LutSpa(), starting from MaskTools 2.0a45 # - Changed Quant and Offset defaults to 24,26,1,1,2,2 to increase effectiveness, but still within sensible limits. # (see for details: http://forum.doom9.org/showthread.php?p=810932#post810932) # Changes 2011-11-29: (06_taro) # - Replaced (chroma=uv>2?"process":"ignore") by (chroma=uv>2?"process":"copy") to avoid garbage clip when uv=2. # The formal parameter is not used by MaskTools2 any more, if ever used. # Foxyshadis once mentioned chroma="ignore" but I had never found a document containing it. # Changes 2014-10-20: # - Now calling to plugin deblock exclusively and not to the older function deblock of DGDecode # Changes 2016-5-8: (Motenai Yoda) # - Added internal variable uvp for skip chroma post processing when uv!=3 # - Replaced most (chroma=uv>2?"process":"copy") and all U=uv,V=uv by U=uvp,V=uvp to trash chroma planes when uv!=3 # - Replaced last (chroma=uv>2?"process":"copy") by (U= uv<2 ? 1 : uv,V= uv<2 ? 1 : uv) to trash chroma planes when uv=1|-1 function Deblock_QED ( clip clp, int "quant1", int "quant2", \ int "aOff1", int "bOff1", int "aOff2", int "bOff2", int "uv" ) { quant1 = default( quant1, 24 ) # Strength of block edge deblocking quant2 = default( quant2, 26 ) # Strength of block internal deblocking aOff1 = default( aOff1, 1 ) # halfway "sensitivity" and halfway a strength modifier for borders aOff2 = default( aOff2, 1 ) # halfway "sensitivity" and halfway a strength modifier for block interiors bOff1 = default( bOff1, 2 ) # "sensitivity to detect blocking" for borders bOff2 = default( bOff2, 2 ) # "sensitivity to detect blocking" for block interiors uv = default( uv, 3 ) # u=3 -> use proposed method for chroma deblocking # u=2 -> no chroma deblocking at all (fastest method) # u=1|-1 -> directly use chroma debl. from the normal|strong deblock() #select once if chroma will be post-processed or not uvp = uv==3 ? 3 : 1 # add borders if clp is not mod 8 padX = clp.width%8 == 0 ? 0 : (8 - clp.width%8) padY = clp.height%8 == 0 ? 0 : (8 - clp.height%8) clp=clp.pointresize(clp.width+padX, clp.height+padY, 0, 0, clp.width+padX, clp.height+padY) # block block = clp.mt_LutSpa(mode="absolute",expr="x 1 + 8 % 1 < x 8 % 1 < y 1 + 8 % 1 < y 8 % 1 < | | | 255 0 ?",U=3,V=3) # create normal deblocking (for block borders) and strong deblocking (for block interiour) normal = clp.Deblock_deblock(quant=quant1,aOffset=aOff1,bOffset=bOff1) strong = clp.Deblock_deblock(quant=quant2,aOffset=aOff2,bOffset=bOff2) # build difference maps of both normalD = mt_makediff(clp,normal,U=uvp,V=uvp) strongD = mt_makediff(clp,strong,U=uvp,V=uvp) # separate border values of the difference maps, and set the interiours to '128' normalD2 = mt_lutxy(normalD,block,expr="y 255 == x 128 ?",U=uvp,V=uvp) strongD2 = mt_lutxy(StrongD,block,expr="y 255 == x 128 ?",U=uvp,V=uvp) # interpolate the border values over the whole block: DCTFilter can do it. (Kiss to Tom Barry!) # (Note: this is not fully accurate, but a reasonable approximation.) # add borders if clp is not mod 16 sw=strongD2.width sh=strongD2.height remX = sw%16 == 0 ? 0 : (16 - sw%16) remY = sh%16 == 0 ? 0 : (16 - sh%16) strongD3 = strongD2.pointresize(sw+remX, sh+remY, 0, 0, sw+remX, sh+remY).mt_lut(expr="x 128 - 1.01 * 128 +",U=uv,V=uv)\ .dctfilter(1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0).crop(0,0,-remX,-remY) # apply compensation from "normal" deblocking to the borders of # the full-block-compensations calculated from "strong" deblocking ... strongD4 = mt_lutxy(strongD3,normalD2,expr="y 128 == x y ?",U=uvp,V=uvp) # ... and apply it. deblocked= mt_makediff(clp,strongD4,U= uv<2 ? 1 : uv,V= uv<2 ? 1 : uv) # simple decisions how to treat chroma deblocked = (uv<0) ? deblocked.mergechroma(strong) : uv<2 ? deblocked.mergechroma(normal) : deblocked deblocked.crop(0,0,-padX,-padY) # remove mod 8 borders }
__________________
powered by Google Translator Last edited by Motenai Yoda; 8th May 2016 at 23:13. |
11th June 2016, 13:30 | #16 | Link |
Registered User
Join Date: Jan 2010
Posts: 709
|
Code:
setmtmode(3) mpeg2source("animaniacs_intro.demuxed.d2v") setmtmode(2) tfm() DctFilter(1, 0, 1, 0, 1, 0, 1, 0) Distributor() https://i.imgur.com/shH5fBA.png https://i.imgur.com/RSzGQ4v.png
__________________
powered by Google Translator |
30th August 2017, 04:19 | #17 | Link | |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Is there a version of Deblock that works in 16-bit?
Running Deblock on its own on 16-bit content adds blocks instead of removing them Quote:
https://github.com/chikuzen/DCTFilter
__________________
FrameRateConverter | AvisynthShader | AvsFilterNet | Natural Grounding Player with Yin Media Encoder, 432hz Player, Powerliminals Player and Audio Video Muxer Last edited by MysteryX; 30th August 2017 at 04:22. |
|
28th September 2018, 22:10 | #18 | Link | |
Registered User
Join Date: Jan 2018
Posts: 33
|
Quote:
Code:
Script error: There is no function named 'Deblock_deblock'. |
|
28th September 2018, 22:59 | #19 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Post output of
Code:
AvsMeter avsinfo EDIT: v1.3 is a v2.60 dll, will not work for avs v2.58. EDIT: Requires "VcRuntime140.dll". Quote:
__________________
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; 28th September 2018 at 23:16. |
|
28th September 2018, 23:39 | #20 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Further to above.
NOTE, Mismatch between docs and actuality. Readme.md Code:
## Deblock Simple deblocking filter by Manao and Fizick. It does a deblocking of the picture, using the deblocking filter of h264. This version has been back-ported from VapourSynth with high-bit-depth support. All credits go to those who wrote the code. ### Usage ``` Deblock (clip, quant=25, aOffset=0, bOffset=0, planes="yuv") ``` * *quant* - the higher the quant, the stronger the deblocking. It can range from 0 to 60. * *aOffset* - quant modifier to the blocking detector threshold. Setting it higher means than more edges will deblocked. * *bOffset* - another quant modifier, for block detecting and for deblocking's strength. There again, the higher, the stronger. * *planes* - specifies which planes to process between y, u and v. Code:
v1.3 (2018-05-29) - Etienne Charland - Back-ported code from VapourSynth - Added high-bit-depth support - Added Planes parameter to specify which planes to process Code:
Deblock_ORDERED_Function_List There follows a list of all function names together with CPP style argument specifiers that inform Avisynth the argument types and optional names. Optional arguments have square brackets surrounding their name as in [name] and are followed by a type specifier character that gives the type. Unnamed arguments are not optional. eg "cc[arg1]b[arg2]i" would be two compulsory unnamed clip args, followed by optional 'arg1' of type bool and optional 'arg2' of type int. # Argument type specifier strings. c - Video Clip i - Integer number f - Float number s - String b - boolean . - Any type (dot) # Array Specifiers i* - Integer Array, zero or more i+ - Integer Array, one or more .* - Any type Array, zero or more .+ - Any type Array, one or more # Etc ################################### Deblock "c[quant]i[aOffset]i[bOffset]i[mmx]b[isse]b" init.cpp Code:
#define WIN32_LEAN_AND_MEAN #include "avisynth.h" #include "deblock.h" AVSValue __cdecl Create_Deblock(AVSValue args, void*, IScriptEnvironment* env) { enum { CLIP, QUANT, AOFFSET, BOFFSET, _PLANES }; PClip input = args[CLIP].AsClip(); VideoInfo vi = input->GetVideoInfo(); const int padWidth = (vi.width & 7) ? 8 - vi.width % 8 : 0; const int padHeight = (vi.height & 7) ? 8 - vi.height % 8 : 0; if (padWidth || padHeight) { AVSValue sargs[5] = { input, vi.width + padWidth, vi.height + padHeight, vi.width + padWidth, vi.height + padHeight }; const char *nargs[5] = { 0, 0, 0, "src_width", "src_height" }; input = env->Invoke("PointResize", AVSValue(sargs, 5), nargs).AsClip(); } return new Deblock(input, args[QUANT].AsInt(25), args[AOFFSET].AsInt(0), args[BOFFSET].AsBool(0), args[_PLANES].AsString(), env); } const AVS_Linkage *AVS_linkage = nullptr; extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) { AVS_linkage = vectors; env->AddFunction("Deblock", "c[quant]i[aOffset]i[bOffset]i[planes]s", Create_Deblock, 0); return "Blocks are kawaii uguu~!"; } EDIT: Perhaps someone with VS2015 can re-compile. EDIT: Looks like 64 bit dll might be correct version, 32 bit borked.
__________________
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; 29th September 2018 at 05:13. |
Tags |
borders, deblock_qed, masktools, mod 8 |
|
|