view TOOLS/360m_convert.c @ 18650:587abd8f3dab

Except for missing cd-dvd.xml and codecs.xml, German xml docs should be complete, synced and corrected :) Here we go: bugreports.xml: * r18600: xml docs: CVS --> Subversion * r18552: URL fix bugs.xml, audio.xml, usage.xml, faq.xml, tvinput.xml, documentation.xml: * fix "in sync with" tag skin.xml: * review * r18600: xml docs: CVS --> Subversion * r17975: Rename the default GUI skins directory from 'Skin' to 'skins' install.xml: * r17975: Rename the default GUI skins directory from 'Skin' to 'skins' * r17707: New website structure, the /homepage subdirectory is gone. * r17462: s/LIVE.COM/LIVE555/ + URL update video.xml: * tiny wording fix mail-lists.xml: * r18606: Fix mailing list name. * r18600: xml docs: CVS --> Subversion
author kraymer
date Thu, 08 Jun 2006 16:20:01 +0000
parents 78f69659c797
children
line wrap: on
line source

/**
 * convert D-Cinema Video (MPEG2 in GXF, SMPTE 360M) to a
 * MPEG-ES file that MPlayer can play (use -demuxer mpeges).
 * Usage: 360m_convert <infile> <outfile>
 */
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
  FILE *in = fopen(argv[1], "r");
  FILE *out = fopen(argv[2], "w");
  int discard = 0;
  unsigned char buf[4];
  if (!in) {
    printf("Could not open %s for reading\n", argv[1]);
    return EXIT_FAILURE;
  }
  if (!out) {
    printf("Could not open %s for writing\n", argv[2]);
    return EXIT_FAILURE;
  }
  fread(buf, 4, 1, in);
  do {
    if (buf[0] == 0 && buf[1] == 0 && buf[2] == 1) {
      // encountered a header
      // skip data between a 0xbf or 0xbc header and the next 0x00 header
      if (buf[3] == 0xbc || buf[3] == 0xbf)
        discard = 1;
      else if (buf[3] == 0)
        discard = 0;
    }
    if (!discard)
      fwrite(&buf[0], 1, 1, out);
    buf[0] = buf[1];
    buf[1] = buf[2];
    buf[2] = buf[3];
    fread(&buf[3], 1, 1, in);
  } while (!feof(in));
  return EXIT_SUCCESS;
}