PDA

View Full Version : Deblocking


outcomes
5th September 2007, 05:31
For blockyness in the movie..
i know deblocking can be used but what else can be used.
how can i remove blockyness and some black effects etc

please help what plugins i can use excluding Deblock.DLL

another questions how can i do color correction if needed

R3Z
5th September 2007, 05:54
Please use search !

Block problems: Search for "Deblock_QED" and "deband".

Color correction: "Tweak" and "ColorMill"

ficofico
5th September 2007, 22:27
if you have to recode, use x264, it's the best deblocker i have seen....

It's a stupid thing but I've done many recode and x264 seem to deblock as well as avisynth plugins. ( with low bitrate)

TheRyuu
6th September 2007, 02:24
Deblock_QED_MT2 is what you probably need. It's rather conservative though so I'm not sure if it will do what you want it to do.

I'm pretty sure that the version below is the latest version of it.

function Deblock_QED_MT2 ( clip clp, int "quant1", int "quant2",
\ int "aOff1", int "bOff1", int "aOff2", int "bOff2", int "uv" )
{
# MT2 version ( hopefully the right one from http://avisynth.org/mediawiki/Wiki/Deblock_QED )
# 26/01/2007 comments added per http://forum.doom9.org/showthread.php?p=944459#post944459
# 26/01/2007 extra checks added per http://forum.doom9.org/showthread.php?p=933643#post933643

quant1 = default( quant1, 20 )
quant2 = default( quant2, 40 )
aOff1 = default( aOff1, quant1/2 ) # I've no clue if these are clever values or not!
bOff1 = default( bOff1, quant1/4 ) # So:
aOff2 = default( aOff2, quant1/4 ) # Also try all these 4 values @ 0 (zero),
bOff2 = default( bOff2, quant1/8 ) # and quant1=30, quant2=40~45 instead.
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()
#--- 26/01/2007 start per http://forum.doom9.org/showthread.php?p=944459#post944459
# Deblock_QED is fully based on Deblock() (implementation of H.264 deblocking,
# contained in DGDecode / older MVTools / Fizick's stand-alone plugin)
# Deblock() has the parameters "quant", "aOff" and "bOff".
# How these work has been discussed in several threads, do a search.
# In Deblock_QED(), the meaning of these parameters is exactly the same.
# The difference is that Deblock_QED internally uses two different instances of deblock() -
# one for block borders, and one for block interiors.
# That's why the function has those "xxx1" and "xxx2" parameters.
# Very roughly,
# "quant1" can be seen as "strength" for borders
# "quant2" can be seen as "strength" for block interiors
# "bOff1" is "sensitivity to detect blocking" for borders
# "bOff2" is "sensitivity to detect blocking" for block interiors
# "aOff1" is halfway "sensitivity", halfway a strength modifier for borders
# "aOff2" is halfway "sensitivity", halfway a strength modifier for block interiors
#--- 26/01/2007 end

#--- 26/01/2007 start per http://forum.doom9.org/showthread.php?p=933643#post933643
Assert(clp.isplanar(),"Deblock_QED_MT2: Requires planar YUV (YV12, YV16, YV24, Y8).")
Assert(clp.width() % 8 == 0 && clp.height() % 8 == 0,"Deblock_QED_MT2: Requires mod8 video.")
#--- 26/01/2007 end

ox = clp.width()
oy = clp.height()

# With avisynth scripting, there is no information available about the position of the currently
# processed pixel ... there simply is no such thing like an "actual" processed pixel.
# So first I've to build up a grid covering the transitions between all 8x8 blocks,
# and make some LUTmania with it later. Yes, this is cumbersome.

block = blankclip(clp,width=6*4,height=6*4,color=$000000).addborders(4,4,4,4,color=$FFFFFF)
block = stackhorizontal( block,block,block,block)
block = stackvertical( block,block,block,block) .pointresize(32,32) .mt_binarize(upper=false)
block = stackhorizontal( block,block,block,block,block,block,block,block)
block = stackvertical( block,block,block,block,block,block)
block = stackhorizontal( block,block,block)
block = stackvertical( block,block,block)
block = stackhorizontal( block,block,block)
block = stackvertical( block,block)
#return clp.subtitle(string(block.width)+"x"+string(block.height))
block = block .crop(0,0,ox,oy)
block = (uv!=3) ? block
\ : YtoUV(block.crop(0,0,ox/2,oy/2),block.crop(0,0,ox/2,oy/2),block)
block = block.trim(1,1) .loop(framecount(clp))

# 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'
strongD2 = mt_lutxy(StrongD,block,expr="y 255 == x 128 ?",U=uv,V=uv)
normalD2 = mt_lutxy(normalD,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.)
strongD3 = strongD2.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)# .yv12lut("x 128 - 2 / 128 +")

# 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
return( last )
}