10l: comparison of char* ptrs with string literals
[mplayer.git] / TOOLS / 360m_convert.c
blob9664d65d0569f10537b0d102109f9b1311fbb731
1 /**
2 * convert D-Cinema Video (MPEG2 in GXF, SMPTE 360M) to a
3 * MPEG-ES file that MPlayer can play (use -demuxer mpeges).
4 * Usage: 360m_convert <infile> <outfile>
5 */
6 #include <stdlib.h>
7 #include <stdio.h>
9 int main(int argc, char *argv[]) {
10 FILE *in = fopen(argv[1], "r");
11 FILE *out = fopen(argv[2], "w");
12 int discard = 0;
13 unsigned char buf[4];
14 if (!in) {
15 printf("Could not open %s for reading\n", argv[1]);
16 return EXIT_FAILURE;
18 if (!out) {
19 printf("Could not open %s for writing\n", argv[2]);
20 return EXIT_FAILURE;
22 fread(buf, 4, 1, in);
23 do {
24 if (buf[0] == 0 && buf[1] == 0 && buf[2] == 1) {
25 // encountered a header
26 // skip data between a 0xbf or 0xbc header and the next 0x00 header
27 if (buf[3] == 0xbc || buf[3] == 0xbf)
28 discard = 1;
29 else if (buf[3] == 0)
30 discard = 0;
32 if (!discard)
33 fwrite(&buf[0], 1, 1, out);
34 buf[0] = buf[1];
35 buf[1] = buf[2];
36 buf[2] = buf[3];
37 fread(&buf[3], 1, 1, in);
38 } while (!feof(in));
39 return EXIT_SUCCESS;