From 25bef8e5a317419c31fbacd3ca61c8a59c32c40a Mon Sep 17 00:00:00 2001 From: reimar Date: Tue, 23 Aug 2005 18:03:23 +0000 Subject: Add D-Cinema Audio and Video conversion programs git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16299 b3059339-0415-0410-9bf9-f77b7e298cf2 --- TOOLS/360m_convert.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 TOOLS/360m_convert.c (limited to 'TOOLS/360m_convert.c') diff --git a/TOOLS/360m_convert.c b/TOOLS/360m_convert.c new file mode 100644 index 0000000000..9664d65d05 --- /dev/null +++ b/TOOLS/360m_convert.c @@ -0,0 +1,41 @@ +/** + * convert D-Cinema Video (MPEG2 in GXF, SMPTE 360M) to a + * MPEG-ES file that MPlayer can play (use -demuxer mpeges). + * Usage: 360m_convert + */ +#include +#include + +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; +} + -- cgit v1.2.3