1 /* Convert the first image of a CMIF video movie file to SGI .rgb format.
2 usage: v2i videofile imagefile [planemask]
10 short rb
[1280], gb
[1280], bb
[1280];
13 #define R(comp) ((comp) & 0xff)
14 #define G(comp) (((comp)>>8) & 0xff)
15 #define B(comp) (((comp)>>16) & 0xff)
26 if( argc
!= 3 && argc
!= 4) {
27 fprintf(stderr
, "Usage: v2i videofile imgfile [planemask]\n");
31 pmask
= atoi(argv
[3]);
34 if ( freopen(argv
[1], "r", stdin
) == NULL
) {
38 if (fgets(lbuf
, sizeof lbuf
, stdin
) == NULL
) {
39 fprintf(stderr
, "Immediate EOF\n");
42 if (strncmp(lbuf
, "CMIF", 4) == 0) {
43 /* Skip optional header line */
44 if (fgets(lbuf
, sizeof lbuf
, stdin
) == NULL
) {
45 fprintf(stderr
, "Immediate EOF after header\n");
50 if ( sscanf(lbuf
, "(%d,%d,%d)", &w
, &h
, &pf
) < 2) {
51 fprintf(stderr
, "%s: bad size spec: %s\n", argv
[0], lbuf
);
54 fgets(lbuf
, sizeof lbuf
, stdin
); /* Skip time info */
56 fprintf(stderr
, "%s: Sorry, too wide\n", argv
[0]);
59 if ( (of
=iopen(argv
[2], "w", RLE(1), 3, w
, h
, 3)) == 0) {
64 if( fread(bm
, sizeof(long), w
, stdin
) != w
) {
65 fprintf(stderr
, "%s: short read\n", argv
[0]);
69 if ( pmask
& 1) rb
[x
] = R(bm
[x
]);
70 if ( pmask
& 2) gb
[x
] = G(bm
[x
]);
71 if ( pmask
& 4) bb
[x
] = B(bm
[x
]);