ref: 0f11e462ff527785f39740913f0067cb962e2bd7
parent: d67f784a8da47413ee31bef4a089b61bb8fd0749
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Dec 16 10:53:17 EST 2020
extra: allow filename specified
--- a/extra/ivf2raw.c
+++ b/extra/ivf2raw.c
@@ -51,7 +51,7 @@
static void
usage(void)
{
- fprint(2, "usage: %s [-h NUM] <file.ivf >file.raw\n", argv0);
+ fprint(2, "usage: %s [-h NUM] [file.ivf] >file.raw\n", argv0);
exits("usage");
}
@@ -59,8 +59,8 @@
main(int argc, char **argv)
{
u64int timestamp, framenum;
+ int n, bufsz, hxsz, fd;
u32int tbnum, tbdenum;
- int n, bufsz, hxsz;
u16int w, h, hlen;
Biobuf in, out;
char tmp[6];
@@ -78,10 +78,14 @@
usage();
}ARGEND
- if(argc != 0)
+ fd = 0;
+ if(argc == 1){
+ if((fd = open(*argv, OREAD)) < 0)
+ sysfatal("%r");
+ }else if(argc != 0)
usage();
- Binit(&in, 0, OREAD);
+ Binit(&in, fd, OREAD);
Binit(&out, 1, OWRITE);
if(Bread(&in, tmp, 6) != 6 || Bu16le(&in, &hlen) < 0)
--- a/extra/mkvdump.c
+++ b/extra/mkvdump.c
@@ -7,7 +7,7 @@
static void
usage(void)
{
- fprint(2, "usage: %s <file.mkv\n", argv0);
+ fprint(2, "usage: %s [file.mkv]\n", argv0);
exits("usage");
}
@@ -14,7 +14,7 @@
void
main(int argc, char **argv)
{
- int n, sti, i, hxsz, lacing;
+ int n, sti, i, hxsz, lacing, fd;
vlong sz, off, x;
uchar *b, t[3];
Biobuf in, out;
@@ -30,7 +30,11 @@
usage();
}ARGEND
- if(argc != 0)
+ fd = 0;
+ if(argc == 1){
+ if((fd = open(*argv, OREAD)) < 0)
+ sysfatal("%r");
+ }else if(argc != 0)
usage();
if((b = malloc(hxsz)) == nil)
@@ -38,7 +42,7 @@
quotefmtinstall();
fmtinstall('H', encodefmt);
- Binit(&in, 0, OREAD);
+ Binit(&in, fd, OREAD);
Binit(&out, 1, OWRITE);
sti = 0;