#define USE_QTX_CODECS
// QuickTime MOV file parser by A'rpi
// additional work by Atmos
// based on TOOLS/movinfo.c by A'rpi & Al3x
// compressed header support from moov.c of the openquicktime lib.
// References: http://openquicktime.sf.net/, http://www.heroinewarrior.com/
// http://www.geocities.com/SiliconValley/Lakes/2160/fformats/files/mov.pdf
// (above url no longer works, file mirrored somewhere? ::atmos)
// The QuickTime File Format PDF from Apple:
// http://developer.apple.com/techpubs/quicktime/qtdevdocs/PDF/QTFileFormat.pdf
// (Complete list of documentation at http://developer.apple.com/quicktime/)
// MP4-Lib sources from http://mpeg4ip.sf.net/ might be usefull fot .mp4
// aswell as .mov specific stuff.
// All sort of Stuff about MPEG4:
// http://www.cmlab.csie.ntu.edu.tw/~pkhsiao/thesis.html
// I really recommend N4270-1.doc and N4270-2.doc which are exact specs
// of the MP4-File Format and the MPEG4 Specific extensions. ::atmos
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "stream.h"
#include "demuxer.h"
#include "stheader.h"
#include "bswap.h"
#include "qtpalette.h"
#include "parse_mp4.h" // .MP4 specific stuff
#ifdef USE_QTX_CODECS
#include "../loader/qtx/qtxsdk/components.h"
#endif
#ifdef HAVE_ZLIB
#include <zlib.h>
#endif
// inclusion of fcntl.h cause cygwin gcc crash
#ifndef __CYGWIN__
#include <fcntl.h>
#endif
#define BE_16(x) (((unsigned char *)(x))[0] << 8 | \
((unsigned char *)(x))[1])
#define BE_32(x) (((unsigned char *)(x))[0] << 24 | \
((unsigned char *)(x))[1] << 16 | \
((unsigned char *)(x))[2] << 8 | \
((unsigned char *)(x))[3])
#define char2short(x,y) BE_16(&(x)[(y)])
#define char2int(x,y) BE_32(&(x)[(y)])
typedef struct {
unsigned int pts; // duration
unsigned int size;
off_t pos;
} mov_sample_t;
typedef struct {
unsigned int sample; // number of the first sample in the chunk
unsigned int size; // number of samples in the chunk
int desc; // for multiple codecs mode - not used
off_t pos;
} mov_chunk_t;
typedef struct {
unsigned int first;
unsigned int spc;
unsigned int sdid;
} mov_chunkmap_t;
typedef struct {
unsigned int num;
unsigned int dur;
} mov_durmap_t;
typedef struct {
unsigned int dur;
unsigned int pos;
int speed;
//
int frames;