View Single Post
Old 14th September 2011, 11:05   #60  |  Link
SAPikachu
Registered User
 
SAPikachu's Avatar
 
Join Date: Aug 2007
Posts: 218
Just completed the script. I tested it on two samples from http://samples.mplayerhq.hu/V-codecs/v210/ (the 720p one need to be converted to mov container first). Script needs avisynth 2.6.

file_head needs to be manually figured out for other files. Open the file in a hex editor, find last "mdat" tag in ASCII view (won't be too far from start), file_head is offset of the immediately followed byte.

EDIT: There are special cases, see http://forum.doom9.org/showthread.ph...77#post1526877 .

Code:
# modified from http://forum.doom9.org/showthread.php?p=1469679#post1469679

function readv210(string fn, int file_head, int frame_width, int frame_height, bool "flip") {
    
    line_size = (frame_width * 16 / 6 + 127) / 128 * 128 # all lines are padded to 128 bytes boundary
    
    base=RawReader (fn, format="y8", width=line_size, height=frame_height, numframes=0, filehead=file_head, framehead=0, flip=default(flip,false))
    
    
    p0=base.every(4,0)
    p1=base.every(4,1)
    p2=base.every(4,2)
    p3=base.every(4,3)
    
    lsb0=mt_lut(p0,yexpr="x 6 <<u 255 &u")
    msb0=mt_lutxy(p0,p1,yexpr="x 2 >>u y 6 <<u |u 255 &u")
    out0=StackVertical(msb0, lsb0)
    
    lsb1=mt_lut(p1,yexpr="x 2 >>u 6 <<u 255 &u")
    msb1=mt_lutxy(p1,p2,yexpr="x 4 >>u y 4 <<u |u 255 &u")
    out1=StackVertical(msb1, lsb1)
    
    lsb2=mt_lut(p2,yexpr="x 4 >>u 6 <<u 255 &u")
    msb2=mt_lutxy(p2,p3,"x 6 >>u y 2 <<u |u 255 &u")
    out2=StackVertical(msb2,lsb2)
    
    weave3h(out0,out1,out2)
    
    y=last.every(2,1)
    u=last.every(4,0)
    v=last.every(4,2)
    
    # return last
    YToUV(u, v, y)
    
    Crop(0,0,frame_width,0)
    
    f3kdb_dither(stacked=true)


}

function every(clip v, int n, int offset) {#select every n bytes horizontally with offset, works on yv12 only
  v
  w=width
  h=height
  pointresize(v,w*2,h)
  crop(offset*2,0,0,0).addborders(0,0,offset*2,0)#shift left offset pixels
  pointresize(w/n,h)
}

function weave3h(clip a, clip b, clip c) {#horizontally weave 3 clips
  a=a.turnright
  b=b.turnright
  c=c.turnright
  
  interleave(a,c,b,c) # a c b c -> ac bc -> abcc
  assumefieldbased
  assumetff
  weave
  assumefieldbased
  assumetff
  weave
  
  # From http://avisynth.org/mediawiki/Advanced_Scripting_Tips:
  
  # In RGB, PointResize deletes the first of each group of 4 lines. 
  # However, in YUV modes, it deletes the last of each group of 4 lines. 
  pointresize(width,height*3/4)
  turnleft
}


LoadPlugin("flash3kyuu_deband.dll")

# readv210("output.mov", 36, 640, 480, flip=true)

# readv210("coff3.mov", 1103, 176, 144)

readv210("v210_720p.mov", 36, 1280, 720)
__________________
f3kdb 1.5.1 / MP_Pipeline 0.18

ffms2 builds with 10bit output hack:
libav-9a60b1f / ffmpeg-1e4d049 / FFmbc-0.7.1
Built from ffms2 6e0d654 (hack a9fe004)

Mirrors: http://bit.ly/19TwDD3

Last edited by SAPikachu; 17th September 2011 at 02:01.
SAPikachu is offline   Reply With Quote