Skip to content

Instantly share code, notes, and snippets.

@line0
Last active December 27, 2015 19:49
Show Gist options
  • Save line0/7380383 to your computer and use it in GitHub Desktop.
Save line0/7380383 to your computer and use it in GitHub Desktop.
function StackedNto16(clip c, int n)
{
Assert(8 <= n <= 15, "StackedNto16: bitdepth should be in range 8-15")
h = c.Height / 2
msb = c.Crop(0,0,0,-h)
lsb = c.Crop(0,h,0,0)
shamt = string(16-n)
msb16 = (n != 8) ? msb.mt_lutxy(lsb, "x " + shamt + " << y 8 " + shamt + " - >> +", v=3, u=3) : lsb
lsb16 = (n != 8) ? lsb.mt_lut("x " + shamt + " << 255 &u", v=3, u=3) : msb
return StackVertical(msb16, lsb16)
}
function InterleavedToStacked(clip c, int bitdepth)
{
c.SeparateColumns(2)
lsb = SelectEven()
msb = SelectOdd()
StackVertical(msb, lsb)
StackedNto16(bitdepth)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment