diff --git a/codec-cfg.c b/codec-cfg.c index 52b7b7c7b4..341fb8446a 100644 --- a/codec-cfg.c +++ b/codec-cfg.c @@ -27,7 +27,7 @@ #include "mp_msg.h" // for mmioFOURCC: -#include "wine/avifmt.h" +#include "libmpdemux/aviheader.h" #include "libvo/img_format.h" #include "codec-cfg.h" diff --git a/libmpdemux/aviheader.h b/libmpdemux/aviheader.h index e5c6fc1c96..552774b72a 100644 --- a/libmpdemux/aviheader.h +++ b/libmpdemux/aviheader.h @@ -4,6 +4,136 @@ //#include "config.h" /* get correct definition WORDS_BIGENDIAN */ #include "bswap.h" +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +#ifndef min +#define min(a,b) (((a)<(b))?(a):(b)) +#endif + +#ifndef max +#define max(a,b) (((a)>(b))?(a):(b)) +#endif + +#ifndef mmioFOURCC +#define mmioFOURCC( ch0, ch1, ch2, ch3 ) \ + ( (uint32_t)(uint8_t)(ch0) | ( (uint32_t)(uint8_t)(ch1) << 8 ) | \ + ( (uint32_t)(uint8_t)(ch2) << 16 ) | ( (uint32_t)(uint8_t)(ch3) << 24 ) ) +#endif + +/* Macro to make a TWOCC out of two characters */ +#ifndef aviTWOCC +#define aviTWOCC(ch0, ch1) ((uint16_t)(uint8_t)(ch0) | ((uint16_t)(uint8_t)(ch1) << 8)) +#endif + +typedef uint16_t TWOCC; +typedef uint32_t FOURCC; + +/* form types, list types, and chunk types */ +#define formtypeAVI mmioFOURCC('A', 'V', 'I', ' ') +#define listtypeAVIHEADER mmioFOURCC('h', 'd', 'r', 'l') +#define ckidAVIMAINHDR mmioFOURCC('a', 'v', 'i', 'h') +#define listtypeSTREAMHEADER mmioFOURCC('s', 't', 'r', 'l') +#define ckidSTREAMHEADER mmioFOURCC('s', 't', 'r', 'h') +#define ckidSTREAMFORMAT mmioFOURCC('s', 't', 'r', 'f') +#define ckidSTREAMHANDLERDATA mmioFOURCC('s', 't', 'r', 'd') +#define ckidSTREAMNAME mmioFOURCC('s', 't', 'r', 'n') + +#define listtypeAVIMOVIE mmioFOURCC('m', 'o', 'v', 'i') +#define listtypeAVIRECORD mmioFOURCC('r', 'e', 'c', ' ') + +#define ckidAVINEWINDEX mmioFOURCC('i', 'd', 'x', '1') + +/* +** Stream types for the field of the stream header. +*/ +#define streamtypeVIDEO mmioFOURCC('v', 'i', 'd', 's') +#define streamtypeAUDIO mmioFOURCC('a', 'u', 'd', 's') +#define streamtypeMIDI mmioFOURCC('m', 'i', 'd', 's') +#define streamtypeTEXT mmioFOURCC('t', 'x', 't', 's') + +/* Basic chunk types */ +#define cktypeDIBbits aviTWOCC('d', 'b') +#define cktypeDIBcompressed aviTWOCC('d', 'c') +#define cktypePALchange aviTWOCC('p', 'c') +#define cktypeWAVEbytes aviTWOCC('w', 'b') + +/* Chunk id to use for extra chunks for padding. */ +#define ckidAVIPADDING mmioFOURCC('J', 'U', 'N', 'K') + +/* flags for use in in AVIFileHdr */ +#define AVIF_HASINDEX 0x00000010 // Index at end of file? +#define AVIF_MUSTUSEINDEX 0x00000020 +#define AVIF_ISINTERLEAVED 0x00000100 +#define AVIF_TRUSTCKTYPE 0x00000800 // Use CKType to find key frames? +#define AVIF_WASCAPTUREFILE 0x00010000 +#define AVIF_COPYRIGHTED 0x00020000 + +typedef struct +{ + uint32_t dwMicroSecPerFrame; // frame display rate (or 0L) + uint32_t dwMaxBytesPerSec; // max. transfer rate + uint32_t dwPaddingGranularity; // pad to multiples of this + // size; normally 2K. + uint32_t dwFlags; // the ever-present flags + uint32_t dwTotalFrames; // # frames in file + uint32_t dwInitialFrames; + uint32_t dwStreams; + uint32_t dwSuggestedBufferSize; + + uint32_t dwWidth; + uint32_t dwHeight; + + uint32_t dwReserved[4]; +} MainAVIHeader; + +/* The RECT structure */ +typedef struct tagRECT +{ + short left; + short top; + short right; + short bottom; +} RECT, *PRECT, *LPRECT; +typedef const RECT *LPCRECT; + +typedef struct { + FOURCC fccType; + FOURCC fccHandler; + uint32_t dwFlags; /* Contains AVITF_* flags */ + uint16_t wPriority; + uint16_t wLanguage; + uint32_t dwInitialFrames; + uint32_t dwScale; + uint32_t dwRate; /* dwRate / dwScale == samples/second */ + uint32_t dwStart; + uint32_t dwLength; /* In units above... */ + uint32_t dwSuggestedBufferSize; + uint32_t dwQuality; + uint32_t dwSampleSize; + RECT rcFrame; +} AVIStreamHeader; + +/* Flags for index */ +#define AVIIF_LIST 0x00000001L // chunk is a 'LIST' +#define AVIIF_KEYFRAME 0x00000010L // this frame is a key frame. + +#define AVIIF_NOTIME 0x00000100L // this frame doesn't take any time +#define AVIIF_COMPUSE 0x0FFF0000L // these bits are for compressor use + +#define FOURCC_RIFF mmioFOURCC('R', 'I', 'F', 'F') +#define FOURCC_LIST mmioFOURCC('L', 'I', 'S', 'T') + +typedef struct +{ + uint32_t ckid; + uint32_t dwFlags; + uint32_t dwChunkOffset; // Position of chunk + uint32_t dwChunkLength; // Length of chunk +} AVIINDEXENTRY; + + typedef struct _avisuperindex_entry { uint64_t qwOffset; // absolute file offset uint32_t dwSize; // size of index chunk at this offset diff --git a/libmpdemux/aviprint.c b/libmpdemux/aviprint.c index da271eae15..9bde59ad5d 100644 --- a/libmpdemux/aviprint.c +++ b/libmpdemux/aviprint.c @@ -9,11 +9,8 @@ #include "stream.h" #include "demuxer.h" -#include "wine/mmreg.h" -#include "wine/avifmt.h" -#include "wine/vfw.h" - #include "aviheader.h" +#include "ms_hdr.h" //#include "codec-cfg.h" //#include "stheader.h" @@ -79,7 +76,7 @@ void print_wave_header(WAVEFORMATEX *h){ uint8_t* p = ((uint8_t*)h) + sizeof(WAVEFORMATEX); printf("Unknown extra header dump: "); for (i = 0; i < h->cbSize; i++) - printf("[%x] ", *(p+i)); + printf("[%x] ", p[i]); printf("\n"); } printf("===========================\n"); diff --git a/libmpdemux/ms_hdr.h b/libmpdemux/ms_hdr.h new file mode 100644 index 0000000000..9af3e7d765 --- /dev/null +++ b/libmpdemux/ms_hdr.h @@ -0,0 +1,78 @@ +#ifndef __MS_HEADER_H +#define __MS_HEADER_H 1 + +#ifndef _WAVEFORMATEX_ +#define _WAVEFORMATEX_ +typedef struct __attribute__((__packed__)) _WAVEFORMATEX { + unsigned short wFormatTag; + unsigned short nChannels; + unsigned int nSamplesPerSec; + unsigned int nAvgBytesPerSec; + unsigned short nBlockAlign; + unsigned short wBitsPerSample; + unsigned short cbSize; +} WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX; +#endif /* _WAVEFORMATEX_ */ + +typedef struct __attribute__((__packed__)) mpeglayer3waveformat_tag { + WAVEFORMATEX wf; + unsigned short wID; + unsigned int fdwFlags; + unsigned short nBlockSize; + unsigned short nFramesPerBlock; + unsigned short nCodecDelay; +} MPEGLAYER3WAVEFORMAT; + +#if !defined(_BITMAPINFOHEADER_) && !defined(_WINGDI_H) +#define _BITMAPINFOHEADER_ +typedef struct __attribute__((__packed__)) +{ + int biSize; + int biWidth; + int biHeight; + short biPlanes; + short biBitCount; + int biCompression; + int biSizeImage; + int biXPelsPerMeter; + int biYPelsPerMeter; + int biClrUsed; + int biClrImportant; +} BITMAPINFOHEADER, *PBITMAPINFOHEADER, *LPBITMAPINFOHEADER; +typedef struct { + BITMAPINFOHEADER bmiHeader; + int bmiColors[1]; +} BITMAPINFO, *LPBITMAPINFO; +#endif + +#ifndef le2me_BITMAPINFOHEADER +#ifdef WORDS_BIGENDIAN +#define le2me_BITMAPINFOHEADER(h) { \ + (h)->biSize = le2me_32((h)->biSize); \ + (h)->biWidth = le2me_32((h)->biWidth); \ + (h)->biHeight = le2me_32((h)->biHeight); \ + (h)->biPlanes = le2me_16((h)->biPlanes); \ + (h)->biBitCount = le2me_16((h)->biBitCount); \ + (h)->biCompression = le2me_32((h)->biCompression); \ + (h)->biSizeImage = le2me_32((h)->biSizeImage); \ + (h)->biXPelsPerMeter = le2me_32((h)->biXPelsPerMeter); \ + (h)->biYPelsPerMeter = le2me_32((h)->biYPelsPerMeter); \ + (h)->biClrUsed = le2me_32((h)->biClrUsed); \ + (h)->biClrImportant = le2me_32((h)->biClrImportant); \ +} +#define le2me_WAVEFORMATEX(h) { \ + (h)->wFormatTag = le2me_16((h)->wFormatTag); \ + (h)->nChannels = le2me_16((h)->nChannels); \ + (h)->nSamplesPerSec = le2me_32((h)->nSamplesPerSec); \ + (h)->nAvgBytesPerSec = le2me_32((h)->nAvgBytesPerSec); \ + (h)->nBlockAlign = le2me_16((h)->nBlockAlign); \ + (h)->wBitsPerSample = le2me_16((h)->wBitsPerSample); \ + (h)->cbSize = le2me_16((h)->cbSize); \ +} +#else +#define le2me_BITMAPINFOHEADER(h) /**/ +#define le2me_WAVEFORMATEX(h) /**/ +#endif +#endif + +#endif diff --git a/libmpdemux/muxer.c b/libmpdemux/muxer.c index 1bf260708f..23fbce98ba 100644 --- a/libmpdemux/muxer.c +++ b/libmpdemux/muxer.c @@ -8,9 +8,8 @@ #include "config.h" #include "../version.h" -#include "wine/mmreg.h" -#include "wine/avifmt.h" -#include "wine/vfw.h" +#include "aviheader.h" +#include "ms_hdr.h" #include "muxer.h" diff --git a/libmpdemux/muxer_avi.c b/libmpdemux/muxer_avi.c index 79116ebc7e..bf837c75da 100644 --- a/libmpdemux/muxer_avi.c +++ b/libmpdemux/muxer_avi.c @@ -12,13 +12,11 @@ #include "demuxer.h" #include "stheader.h" -#include "wine/mmreg.h" -#include "wine/avifmt.h" -#include "wine/vfw.h" #include "bswap.h" #include "muxer.h" #include "aviheader.h" +#include "ms_hdr.h" #include "mp_msg.h" extern char *info_name; diff --git a/libmpdemux/muxer_mpeg.c b/libmpdemux/muxer_mpeg.c index 2c40bc45dc..edf46f31bc 100644 --- a/libmpdemux/muxer_mpeg.c +++ b/libmpdemux/muxer_mpeg.c @@ -8,11 +8,11 @@ #include "../version.h" #include "../mp_msg.h" -#include "wine/mmreg.h" -#include "wine/avifmt.h" -#include "wine/vfw.h" #include "bswap.h" +#include "aviheader.h" +#include "ms_hdr.h" + #include "muxer.h" // 18 bytes reserved for block headers and STD diff --git a/libmpdemux/stheader.h b/libmpdemux/stheader.h index 79a687d216..1de8715b50 100644 --- a/libmpdemux/stheader.h +++ b/libmpdemux/stheader.h @@ -1,43 +1,8 @@ #ifndef __ST_HEADER_H #define __ST_HEADER_H 1 -// for AVIStreamHeader: -#include "wine/avifmt.h" - -#ifndef _WAVEFORMATEX_ -#define _WAVEFORMATEX_ -typedef struct __attribute__((__packed__)) _WAVEFORMATEX { - WORD wFormatTag; - WORD nChannels; - DWORD nSamplesPerSec; - DWORD nAvgBytesPerSec; - WORD nBlockAlign; - WORD wBitsPerSample; - WORD cbSize; -} WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX; -#endif /* _WAVEFORMATEX_ */ - -#ifndef _BITMAPINFOHEADER_ -#define _BITMAPINFOHEADER_ -typedef struct __attribute__((__packed__)) -{ - int biSize; - int biWidth; - int biHeight; - short biPlanes; - short biBitCount; - int biCompression; - int biSizeImage; - int biXPelsPerMeter; - int biYPelsPerMeter; - int biClrUsed; - int biClrImportant; -} BITMAPINFOHEADER, *PBITMAPINFOHEADER, *LPBITMAPINFOHEADER; -typedef struct { - BITMAPINFOHEADER bmiHeader; - int bmiColors[1]; -} BITMAPINFO, *LPBITMAPINFO; -#endif +#include "aviheader.h" +#include "ms_hdr.h" // Stream headers: diff --git a/mencoder.c b/mencoder.c index 069235652c..805541e2d8 100644 --- a/mencoder.c +++ b/mencoder.c @@ -55,7 +55,7 @@ #include "libmpcodecs/vf.h" // for MPEGLAYER3WAVEFORMAT: -#include "loader/wine/mmreg.h" +#include "libmpdemux/ms_hdr.h" #ifdef HAVE_MP3LAME #undef CDECL