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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 9th January 2011, 13:07   #1  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
New Script: Read v210 uncompressed 10bit YUV Quicktime/mov files

This just blew me away - a quick guess and it worked!
Here's how to read v210 mov files with rawreader (sashimi):
Code:
fn="G:\project001a\deepcolor\v210.mov"
RawReader (fn, format="y8", width=5120, height=1080, numframes=0, filehead=21192, framehead=0)
In this case, my file is 1920x1080. Each 5120 bytes represents one row. A group of 6 pixels is stored in 4 bytes. 6 Y samples with 3 each of (cb, cr). There's 2 extra bits per byte, btw.
You can easily see an outline of your picture and step through the frames to see motion, even in encoded form, some of the luma looks like picture.

Some work with masktools and this can be decoded completely in script.

My file had no audio, so how do you guess the filehead for your file? It's easy, for HD just use 5120x1080 size per frame, multiply by number of frames, and whatever is leftover is all header! Example, my sample had 3 frames, 16588800, filesize was 16609992, so 16609992-16588800=21192. This was from a Blackmagic declink capture.

Last edited by jmac698; 9th January 2011 at 15:01.
jmac698 is offline   Reply With Quote
Old 9th January 2011, 13:29   #2  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,384
Quote:
Originally Posted by jmac698 View Post
A group of 6 pixels is stored in 4 bytes. 6 Y samples with 3 each of (cb, cr). There's 2 extra bits per byte, btw.
Instead of byte, I think you mean (32-bit) word.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 9th January 2011, 14:35   #3  |  Link
jmac698
Registered User
 
Join Date: Jan 2006
Posts: 1,867
Yes that's right.
So here it is:
Update: Ver 0.4 now reads the complete image in greyscale. Only tested on 1080p, 10bit images. 720p will not work.
Code:
#v210 Reader Ver 0.4 by jmac698
#Read v210 quicktime files with rawreader, by jmac698
#Requires Sashimi 0.74 http://sites.google.com/site/ourenthusiasmsasham/contributions/open-source-software#TOC-Sashimi
#also http://forum.doom9.org/showthread.php?p=1403600
#Masktools 2a48 http://manao4.free.fr/masktools-v2.0a48.zip
#Ver 0.4 - reads full image in 8bit greyscale, with 10bit easily accessible
#Ver 0.3 - reads fully to 8bit greyscale, now requires masktools 2a48
#Ver 0.2 - fixed wrapping bug.  83 pixels *8=664, that would be the trailing bytes
#Ver 0.1 - reads only greyscale, can only read 1/3 of the size, only reads upper 6 bits, wrapped by 83 pixels
fn="G:\project001a\deepcolor\v210.mov"
readv210(fn)

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 readv210(string fn) {#reads 1/3 size, greyscale v210 file
    base=RawReader (fn, format="y8", width=5120, height=1080, numframes=0, filehead=21192-664, framehead=0)#21192 header, 664 trailer
    high6=base.every(4,3).every(2,1)
    low4=base.every(4,2).every(2,1)
    mt_lutxy(low4,high6,yexpr="x 6 >> y 2 << +")
    o1=last
    high4=base.every(4,2).every(2,0)
    low6=base.every(4,1).every(2,0)
    mt_lutxy(low6,high4,yexpr="y 15 &u 4 << x 4 >> +")#x 4 >> y 4 << +
    o0=last
    high2=base.every(4,1).every(2,1)
    low8=base.every(4,0).every(2,1)
    mt_lutxy(low8,high2,yexpr="y 3 &u 6 << x 2 >> +")#x 4 >> y 4 << +
    o2=last
    weave3h(o0,o1,o2)
}

function weave3h(clip a, clip b, clip c) {#horizontally weave 3 clips
  a=a.turnright
  b=b.turnright
  c=c.turnright
  interleave(a,b,a,c)#0 1 2 3->01 23->0213->213 or abc
  assumefieldbased
  assumetff
  weave
  assumefieldbased
  assumetff
  weave
  pointresize(width,height*3/4)#deletes every 4th line offset 0
  turnleft
}
In case you didn't see some other threads, ffvideosource(fn) and qtinput(fn) also work but they are only 8bit, in the case of qtinput you can fudge 9bit with a trick. With this script you can access the full 10bits in script, though it's not used here yet.

Last edited by jmac698; 9th January 2011 at 18:56.
jmac698 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:19.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.