static int
looksize(char *file, vlong size, int *pixels, int *lines, int *bits)
{
Biobuf *bp;
uvlong l, p;
char *s, *a[12];
/*
* This may not always work, there could be an alias between file
* sizes of different standards stored in 8bits and 10 bits.
*/
if ((bp = Bopen(file, OREAD)) == nil)
return -1;
while((s = Brdstr(bp, '\n', 1)) != nil){
if (tokenize(s, a, nelem(a)) < 3)
continue;
if (a[0][0] == '#')
continue;
p = atoll(a[3]);
l = atoll(a[5]);
l += atoll(a[7]);
if (l*p*2 == size){
*pixels = p;
*lines = l;
*bits = 8;
break;
}
if ((l*p*20)/8 == size){
*pixels = p;
*lines = l;
*bits = 10;
break;
}
}
Bterm(bp);
if (s == nil)
return -1;
return 0;
}
static int
clip(int x)
{
x >>= (Shift+2); // +2 as we assume all input images are 10 bit
if (x > 255)
return 0xff;
if (x <= 0)
return 0;
return x;
}
Rawimage**
Breadyuv(Biobuf *bp, int colourspace)
{
Dir *d;
uvlong sz;
Rawimage *a, **array;
ushort * mux, *end, *frm;
uchar *buf, *r, *g, *b;
int y1, y2, cb, cr, c, l, w, base;
int bits, lines, pixels;
int F1, F2, F3, F4;