お前らのショボイAvisynthスクリプト貼ってくださいpart2

このエントリーをはてなブックマークに追加
272名無しさん@編集中
### {{{ TrueTears
# メイン画面とワイプの周期が異なるときの逆テレシネ用。
# x, y, w, h: 座標 (x, y) から 幅 w, 高さ h の範囲に フィルター string "top" を掛ける。
# 上記の範囲外にはフィルター string "bottom" を掛ける。
# bright: 0 以外の数値を指定すると "top" の範囲外に Tweakの brightが適用される。範囲特定用。YUY2, YV12のみ。
# show: "top" の部分だけ表示する。
# interlaced: YV12 のとき、縦の解像度が 4の倍数でないとき警告を出す。デフォルト true
function TrueTears(clip clp, int "x", int "y", int "w", int "h", string "top", string "bottom",
\ string "pre", float "bright", bool "show", bool "interlaced")
{
x = default( x, 0 )
y = default( y, 0 )
w = default( w, clp.width )
h = default( h, clp.height )
top = default( top, "nul" )
pre = default( pre, "nul" )
bright = default( bright, 0 )
show = default( show, false )
interlaced = default( interlaced, true )
bottom = default( bottom, "nul" )
bottom = (bright != 0) ? bottom + ".Tweak(bright=" + string(bright) + ")" : bottom
273名無しさん@編集中:2008/03/28(金) 01:03:24 ID:DLAr9pAI
x_end = x + w
y_end = y + h
x_end = (x_end >= clp.width) ? clp.width : x_end
y_end = (y_end >= clp.Height) ? clp.Height : y_end
(interlaced == true) && clp.isYV12 ? Assert(y % 4 == 0, "TrueTears: IsYV12 && (y % 4 == 0)") : NOP
(interlaced == true) && clp.isYV12 ? Assert(h % 4 == 0, "TrueTears: IsYV12 && (h % 4 == 0)") : NOP
TTx = "TrueTears_x(start=" + string(x) + ", end=" + string(x_end) + ", filter=" + chr34 + top + chr34
\ + ", filter2=" + chr34 + bottom + chr34 + ", pre=" + chr34 + pre + chr34 + ", show=" + string(show) + ")"
TTy = "TrueTears_y(start=" + string(y) + ", end=" + string(y_end) + ", filter=" + chr34 + top + chr34
\ + ", filter2=" + chr34 + bottom + chr34 + ", pre=" + chr34 + pre + chr34 + ", show=" + string(show) + ")"
#return clp.TrueTears_Y(start=y, end=y_end, filter=TTx, filter2=bottom, pre=pre, show=show)
return clp.TrueTears_X(start=x, end=x_end, filter=TTy, filter2=bottom, pre=pre, show=show)
}

function TrueTears_X(clip clp, int "start", int "end", string "filter",
\ string "filter2", string "pre", bool "show")
{
clp2 = Eval("clp." + filter2)
c1 = (start != 0) ? clp2.Crop( 0, 0, -(clp.width - start), -0) : nop
c2 = Eval("clp." + pre + ".Crop( start, 0, -(clp.width - end), -0 ) " + filter)
c3 = (end < clp.width) ? clp2.Crop( end, 0, -0, -0) : nop
c2 = (c2.Framecount > clp2.FrameCount) ? c2.DeleteFrame(lastFrameOf(clp2))
\ : (c2.Framecount < clp2.FrameCount) ? c2.DuplicateFrame(lastFrameOf(clp2)) : c2
c = (show == false) ? ( (start == 0) ? c2 : StackHorizontal(c1, c2) ) : nop
return (show == true) ? c2 : (end >= clp.width) ? c : StackHorizontal(c, c3)
}
274名無しさん@編集中:2008/03/28(金) 01:05:18 ID:DLAr9pAI
function TrueTears_Y(clip clp, int "start", int "end", string "filter",
\ string "filter2", string "pre", bool "show")
{
clp2 = Eval("clp." + filter2)
c1 = (start != 0) ? clp2.Crop( 0, 0, -0, -(clp.Height - start) ) : nop
c2 = Eval("clp." + pre + ".Crop( 0, start, -0, -(clp.Height - end) ) " + filter)
c3 = (end < clp.Height) ? clp2.Crop( 0, end, -0, -0) : nop
c2 = (c2.Framecount > clp2.FrameCount) ? c2.DeleteFrame(lastFrameOf(clp2))
\ : (c2.Framecount < clp2.FrameCount) ? c2.DuplicateFrame(lastFrameOf(clp2)) : c2
c = (show == false) ? ( (start == 0) ? c2 : StackVertical(c1, c2) ) : nop
return (show == true) ? c2 : (end >= clp.Height) ? c : StackVertical(c, c3)
}

function NulClip(clip src) { return src.BlankClip(length=0) } # >>267氏、Thanks.
function toParityOf(clip clp, clip src) { return src.GetParity ? clp.AssumeTFF : clp.AssumeBFF }
function toFramerateOf(clip clp, clip src) { return clp.AssumeFPS(src.Framerate) }
function lastFrameOf(clip clp) { return clp.Framecount - 1 }
function nul(clip clp) { return clp }
function chr34() { return chr(34) + chr(34) + chr(34) }
function SubtitleFilter(clip clp, string filter){ return Eval( "clp " + filter + " Subtitle(" + chr34 + filter + chr34 + ")" ) }

275名無しさん@編集中:2008/03/28(金) 01:07:11 ID:DLAr9pAI
使用例:
直接、TrueTears()を使うか、下のような関数を作る。

# toTrueTears TrueTears自身をstringに変換。3:2プルダウン用
#return TrueTears(x=458, y=148, w=200, h=288, top="""SelectEvery2("5, 2,4").vinverse""", bottom="""SelectEvery2("5, 0,2").nul""", bright=0, show=false)
#TT = toTrueTears(x=458, y=148, w=200, h=288, top="5, 2,4", bottom="5, 0,2", top_filter="vinverse", bottom_filter="nul", show=false, interlaced=true)
#return Eval(TT)
function toTrueTears(int "x", int "y", int "w", int "h", string "top", string "bottom", string "top_filter",
\ string "bottom_filter", float "bright", bool "show", bool "interlaced")
{
top_filter = default( top_filter, "nul" )
bottom_filter = default( bottom_filter, "nul" )
bright = default( bright, 0 )
show = default( show, false )
interlaced = default( interlaced, true )

# string を渡すフィルタによってこの部分を変える。
return "TrueTears(x=" + string(x) + ", y=" + string(y) + ", w=" + string(w) + ", h=" + string(h)
\ + ", top=" + chr34 + "SelectEvery2(" + chr(34) + top + chr(34) + ")." + top_filter + chr34
\ + ", bottom=" + chr34 + "SelectEvery2(" + chr(34) + bottom + chr(34) + ")." + bottom_filter + chr34
\ + ", bright=" + string(bright) + ", show=" + string(show) + ", interlaced=" + string(interlaced) + ")"
}
276名無しさん@編集中:2008/03/28(金) 01:08:14 ID:DLAr9pAI
string を同期のためのtimecodeを出力する関数に渡す。(ClipArray()はdebug中。)
True Tears のオープニング。
frame 1355から 2100までを 24000/1001 fps, 2101 frameの Framerateのみ修正。
ClipArray( start=1355, end=1519, ivtc="5, 0,2", pre="", post="", ff="em" )

TT1 = toTrueTears(x=60, y=96, w=202, h=292, top="5, 0,3", bottom="5, 0,2")
ClipArray( start=1520, end=1564, ivtc=TT1, pre="", post="", ff="", mode=2 )

ClipArray( start=1565, end=1669, ivtc="5, 0,2", pre="", post="MergeField(frame=82)", ff="e0" )

TT2 = toTrueTears(x=60, y=120, w=360, h=244, top="5, 1,3", bottom="5, 2,4")
ClipArray( start=1669, end=1759, ivtc=TT2, pre="", post="", ff="", mode=2 )

ClipArray( start=1760, end=1794, ivtc="5, 0,2", pre="", post="", ff="" )

TT3 = toTrueTears(x=458, y=144, w=204, h=296, top="5, 1,4", bottom="5, 0,2")
ClipArray( start=1795, end=1911, ivtc=TT3, pre="", post="", ff="", mode=2 )

TT4 = toTrueTears(x=226, y=48, w=270, h=388, top="5, 0,2", bottom="5, 1,3")
ClipArray( start=1912, end=1979, ivtc=TT4, pre="", post="", ff="", mode=2 )

ClipArray( start=1980, end=2101, ivtc="5, 0,2", pre="", post="", ff="" )