annotate TOOLS/360m_convert.c @ 20596:82a1ee455661

remove accidential ';' (that's what too much C programming does to you ;-) )
author reimar
date Thu, 02 Nov 2006 18:14:12 +0000
parents 78f69659c797
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16298
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
1 /**
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
2 * convert D-Cinema Video (MPEG2 in GXF, SMPTE 360M) to a
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
3 * MPEG-ES file that MPlayer can play (use -demuxer mpeges).
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
4 * Usage: 360m_convert <infile> <outfile>
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
5 */
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
6 #include <stdlib.h>
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
7 #include <stdio.h>
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
8
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
9 int main(int argc, char *argv[]) {
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
10 FILE *in = fopen(argv[1], "r");
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
11 FILE *out = fopen(argv[2], "w");
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
12 int discard = 0;
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
13 unsigned char buf[4];
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
14 if (!in) {
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
15 printf("Could not open %s for reading\n", argv[1]);
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
16 return EXIT_FAILURE;
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
17 }
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
18 if (!out) {
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
19 printf("Could not open %s for writing\n", argv[2]);
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
20 return EXIT_FAILURE;
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
21 }
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
22 fread(buf, 4, 1, in);
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
23 do {
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
24 if (buf[0] == 0 && buf[1] == 0 && buf[2] == 1) {
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
25 // encountered a header
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
26 // skip data between a 0xbf or 0xbc header and the next 0x00 header
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
27 if (buf[3] == 0xbc || buf[3] == 0xbf)
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
28 discard = 1;
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
29 else if (buf[3] == 0)
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
30 discard = 0;
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
31 }
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
32 if (!discard)
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
33 fwrite(&buf[0], 1, 1, out);
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
34 buf[0] = buf[1];
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
35 buf[1] = buf[2];
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
36 buf[2] = buf[3];
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
37 fread(&buf[3], 1, 1, in);
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
38 } while (!feof(in));
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
39 return EXIT_SUCCESS;
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
40 }
78f69659c797 Add D-Cinema Audio and Video conversion programs
reimar
parents:
diff changeset
41