Removed the aviclasses.

This commit is contained in:
Moritz Bunkus 2004-06-12 17:42:42 +00:00
parent 34568cd17e
commit 8e6c006e9b
19 changed files with 12 additions and 4575 deletions

View File

@ -54,8 +54,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
# Variable stuff as set by configure
AVICLASSES_LIBS = @AVICLASSES_LIBS@
AVILIB_LIBS = @AVILIB_LIBS@
BZ2_LIBS = @BZ2_LIBS@
DEBUG_CFLAGS = @DEBUG_CFLAGS@
EBML_CFLAGS = @EBML_CFLAGS@
@ -87,29 +85,18 @@ CFLAGS += -DPACKAGE=\"$(PACKAGE)\" -DVERSION=\"$(VERSION)\"
CXXFLAGS += -DPACKAGE=\"$(PACKAGE)\" -DVERSION=\"$(VERSION)\"
# Which additional stuff to compile
USE_AVICLASSES = @USE_AVICLASSES@
USE_AVILIB0610 = @USE_AVILIB0610@
USE_WXWINDOWS = @USE_WXWINDOWS@
ifeq (yes,$(USE_AVICLASSES))
AVICLASSES_INCLUDES = -Iaviclasses
AVICLASSES_LIBDIRS = -Laviclasses
AVICLASSES_LIBRARIES = -laviclasses
DEP_AVICLASSES = aviclasses/libaviclasses.a
endif
ifeq (yes,$(USE_AVILIB0610))
AVILIB_INCLUDES = -Iavilib-0.6.10
AVILIB_LIBDIRS = -Lavilib-0.6.10
DEP_AVILIB = avilib-0.6.10/libavi.a
endif
DEP_COMMON = src/common/libmtxcommon.a
DEP_EBMLCOMMON = src/common/libmtxebmlcommon.a
DEP_KAXCOMMON = src/common/libmtxkaxcommon.a
DEP_INPUT = src/input/libmtxinput.a
DEP_OUTPUT = src/output/libmtxoutput.a
DEP_AVI = $(DEP_AVILIB) $(DEP_AVICLASSES)
DEP_AVI = $(DEP_AVILIB)
DEP_RMFF = librmff/librmff.a
COMPRESSION_LIBRARIES = $(LZO_LIBS) $(BZ2_LIBS)
@ -144,9 +131,9 @@ install-mans:
$(INSTALL_DATA) $$i $(DESTDIR)$(man1dir)/$$inst; \
done
SYSTEM_INCLUDES = $(AVILIB_INCLUDES) $(AVICLASSES_INCLUDES) \
SYSTEM_INCLUDES = $(AVILIB_INCLUDES) \
-I. -Ilibrmff -Isrc -Isrc/common -Isrc/input -Isrc/output
SYSTEM_LIBDIRS = $(AVILIB_LIBDIRS) $(AVICLASSES_LIBDIRS) \
SYSTEM_LIBDIRS = $(AVILIB_LIBDIRS) \
-Llibrmff -Lsrc/common -Lsrc/input -Lsrc/output
RUNAR = $(AR) rcu
@ -191,18 +178,6 @@ avilib-0.6.10/libavi.a: $(libavi_OBJECTS)
$(RUNAR) $@ $(libavi_OBJECTS)
$(RANLIB) $@
#
# aviclasses
#
libaviclasses_SOURCES = $(wildcard aviclasses/*.cpp)
libaviclasses_OBJECTS := $(patsubst %.cpp,%.o,$(libaviclasses_SOURCES))
aviclasses/libaviclasses.a: $(libaviclasses_OBJECTS)
rm -f $@
$(RUNAR) $@ $(libaviclasses_OBJECTS)
$(RANLIB) $@
#
# librmff
#
@ -266,7 +241,7 @@ mkvmerge_DEPENDENCIES += $(DEP_COMMON) \
$(DEP_COMP) $(DEP_INPUT) $(DEP_OUTPUT) $(DEP_AVI) $(DEP_RMFF)
mkvmerge_LDADD = -lmtxinput -lmtxoutput \
-lmtxcommon -lmatroska -lebml \
-lavi $(AVICLASSES_LIBDIRS) $(AVICLASSES_LIBRARIES) -lrmff \
-lavi -lrmff \
$(FLAC_LIBS) -lvorbis -logg -lz $(COMPRESSION_LIBRARIES) \
-lexpat $(ICONV_LIBS)

View File

@ -9,14 +9,6 @@ CFLAGS += -g -DDEBUG
CXXFLAGS += -g -DDEBUG
endif
ifneq (,$(findstring aviclasses,$(AVILIB)))
CXXFLAGS += -DHAVE_AVICLASSES=1
AVICLASSES_INCLUDES = -Iaviclasses
AVICLASSES_LIBDIRS = -Laviclasses
AVICLASSES_LIBRARIES = -laviclasses
DEP_AVICLASSES = aviclasses/libaviclasses.a
endif
ifneq (,$(findstring bzlib,$(COMPRESSION_LIBS)))
CXXFLAGS += -DHAVE_BZLIB_H=1
COMPRESSION_LIBRARIES = -lbz2
@ -47,25 +39,21 @@ endif
DEP_INPUT = src/input/libmtxinput.a
DEP_OUTPUT = src/output/libmtxoutput.a
DEP_AVILIB = avilib-0.6.10/libavi.a
DEP_AVI = $(DEP_AVILIB) $(DEP_AVICLASSES)
DEP_AVI = $(DEP_AVILIB)
DEP_RMFF = librmff/librmff.a
#
# System settings. Don't change anything below here.
#
ifneq (,$(findstring aviclasses,$(AVILIB)))
SUBDIRS = avilib-0.6.10 aviclasses src
else
SUBDIRS = avilib-0.6.10 src
endif
APPLICATIONS=src/mkvmerge src/mkvinfo src/mkvextract src/base64tool src/mmg
all: config.h $(APPLICATIONS)
SYSTEM_INCLUDES = -Iavilib-0.6.10 $(AVICLASSES_INCLUDES) \
SYSTEM_INCLUDES = -Iavilib-0.6.10 \
-I. -Ilibrmff -Isrc -Isrc/common -Isrc/input -Isrc/output
SYSTEM_LIBDIRS = -Lavilib-0.6.10 $(AVICLASSES_LIBDIRS) \
SYSTEM_LIBDIRS = -Lavilib-0.6.10 \
-Llibrmff -Lsrc/common -Lsrc/input -Lsrc/output
RUNAR = $(AR) rcu
@ -118,18 +106,6 @@ avilib-0.6.10/libavi.a: $(libavi_OBJECTS)
$(RUNAR) $@ $(libavi_OBJECTS)
$(RANLIB) $@
#
# aviclasses
#
libaviclasses_SOURCES = $(wildcard aviclasses/*.cpp)
libaviclasses_OBJECTS := $(patsubst %.cpp,%.o,$(libaviclasses_SOURCES))
aviclasses/libaviclasses.a: $(libaviclasses_OBJECTS)
rm -f $@
$(RUNAR) $@ $(libaviclasses_OBJECTS)
$(RANLIB) $@
#
# librmff
#
@ -193,8 +169,7 @@ mkvmerge_DEPENDENCIES += $(DEP_COMMON) \
$(DEP_COMP) $(DEP_INPUT) $(DEP_OUTPUT) $(DEP_AVI) $(DEP_RMFF)
mkvmerge_LDADD = -lmtxinput -lmtxoutput \
-lmtxcommon -lmatroska -lebml \
-lavi $(AVICLASSES_LIBDIRS) $(AVICLASSES_LIBRARIES) \
-lvorbis -lflac -logg -lz $(COMPRESSION_LIBRARIES) \
-lavi -lvorbis -lflac -logg -lz $(COMPRESSION_LIBRARIES) \
-lexpat -liconv -lrmff
mkvinfo_SOURCES = $(wildcard src/mkvinfo*.cpp)

View File

@ -6,10 +6,6 @@ LIBDIRS = -Lc:/cygwin/usr/local/src/libebml/make/mingw32 \
-Lc:/cygwin/usr/local/src/libmatroska/make/mingw32 \
-Lc:/cygwin/usr/local/lib
# Which AVI libraries should be used for reading AVIs?
# Default is to use aviclasses.
AVILIB = aviclasses
# Which compression libraries should be supported?
# zlib is always used, possible other values are bzlib and lzo.
#COMPRESSION_LIBS = bzlib lzo

View File

@ -1,229 +0,0 @@
// VirtualDub - Video processing and capture application
// Copyright (C) 1998-2001 Avery Lee
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// Modified by Julien 'Cyrius' Coloos
// 20-09-2003
//
#include "AVIIndex.h"
///////////////////////////////////////////////////////////////////////////
class AVIIndexChainNode {
public:
enum { ENTS=2048 };
AVIIndexChainNode *next;
AVIIndexEntry2 ient[ENTS];
int num_ents;
AVIIndexChainNode() {
num_ents = 0;
next = NULL;
}
bool add(uint32_le ckid, sint64 pos, long size, bool is_keyframe) {
if (num_ents < ENTS) {
ient[num_ents].ckid = ckid;
ient[num_ents].pos = pos;
ient[num_ents].size = is_keyframe ? size : 0x80000000+size;
++num_ents;
return true;
}
return false;
}
void put(w32AVIINDEXENTRY *&avieptr) {
int i;
for(i=0; i<num_ents; i++) {
avieptr->ckid = ient[i].ckid;
avieptr->dwFlags = ient[i].size & 0x80000000 ? 0 : AVIIF_KEYFRAME;
avieptr->dwChunkOffset = ient[i].pos;
avieptr->dwChunkLength = ient[i].size & 0x7FFFFFFF;
++avieptr;
}
}
void put(AVIIndexEntry2 *&avie2ptr) {
int i;
for(i=0; i<num_ents; i++)
*avie2ptr++ = ient[i];
}
void put(AVIIndexEntry3 *&avie3ptr, sint64 offset) {
int i;
for(i=0; i<num_ents; i++) {
avie3ptr->dwSizeKeyframe = ient[i].size;
avie3ptr->dwOffset = (uint32)(ient[i].pos - offset);
++avie3ptr;
}
}
};
///////////////////////////////////////////////////////////////////////////
AVIIndexChain::AVIIndexChain() {
head = tail = NULL;
total_ents = 0;
}
void AVIIndexChain::delete_chain() {
AVIIndexChainNode *aicn = head,*aicn2;
while(aicn) {
aicn2 = aicn->next;
delete aicn;
aicn = aicn2;
}
head = tail = NULL;
}
AVIIndexChain::~AVIIndexChain() {
delete_chain();
}
bool AVIIndexChain::add(w32AVIINDEXENTRY *avie) {
if (!tail || !tail->add(avie->ckid, avie->dwChunkOffset, avie->dwChunkLength, !!(avie->dwFlags & AVIIF_KEYFRAME))) {
AVIIndexChainNode *aicn = new AVIIndexChainNode();
if (tail) tail->next = aicn; else head=aicn;
tail = aicn;
if (tail->add(avie->ckid, avie->dwChunkOffset, avie->dwChunkLength, !!(avie->dwFlags & AVIIF_KEYFRAME))) {
++total_ents;
return true;
}
return false;
}
++total_ents;
return true;
}
bool AVIIndexChain::add(AVIIndexEntry2 *avie2) {
return add(avie2->ckid, avie2->pos, avie2->size & 0x7FFFFFFF, !!(avie2->size & 0x80000000));
}
bool AVIIndexChain::add(uint32_le ckid, sint64 pos, long size, bool is_keyframe) {
if (!tail || !tail->add(ckid, pos, size, is_keyframe)) {
AVIIndexChainNode *aicn = new AVIIndexChainNode();
if (tail) tail->next = aicn; else head=aicn;
tail = aicn;
if (tail->add(ckid, pos, size, is_keyframe)) {
++total_ents;
return true;
}
return false;
}
++total_ents;
return true;
}
void AVIIndexChain::put(w32AVIINDEXENTRY *avietbl) {
AVIIndexChainNode *aicn = head;
while(aicn) {
aicn->put(avietbl);
aicn=aicn->next;
}
delete_chain();
}
void AVIIndexChain::put(AVIIndexEntry2 *avie2tbl) {
AVIIndexChainNode *aicn = head;
while(aicn) {
aicn->put(avie2tbl);
aicn=aicn->next;
}
delete_chain();
}
void AVIIndexChain::put(AVIIndexEntry3 *avie3tbl, sint64 offset) {
AVIIndexChainNode *aicn = head;
while(aicn) {
aicn->put(avie3tbl, offset);
aicn=aicn->next;
}
delete_chain();
}
AVIIndex::AVIIndex() {
index = NULL;
index2 = NULL;
index3 = NULL;
}
AVIIndex::~AVIIndex() {
delete[] index;
delete[] index2;
delete[] index3;
}
bool AVIIndex::makeIndex() {
if (!allocateIndex(total_ents)) return false;
put(indexPtr());
return true;
}
bool AVIIndex::makeIndex2() {
if (!allocateIndex2(total_ents)) return false;
put(index2Ptr());
return true;
}
bool AVIIndex::makeIndex3(sint64 offset) {
if (!allocateIndex3(total_ents)) return false;
put(index3Ptr(), offset);
return true;
}
void AVIIndex::clear() {
delete_chain();
delete[] index;
delete[] index2;
delete[] index3;
index = NULL;
index2 = NULL;
index3 = NULL;
total_ents = 0;
}

View File

@ -1,120 +0,0 @@
// VirtualDub - Video processing and capture application
// Copyright (C) 1998-2001 Avery Lee
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// Modified by Julien 'Cyrius' Coloos
// 20-09-2003
//
#ifndef f_AVIINDEX_H
#define f_AVIINDEX_H
#include "common_endian.h"
#include "common_gdivfw.h"
class AVIIndexChainNode;
class AVIIndexEntry2 {
public:
sint64 pos;
union {
uint32_le ckid;
int fileno;
};
sint32 size;
};
class AVIIndexEntry3 {
public:
uint32 dwOffset;
uint32 dwSizeKeyframe;
};
class AVIIndexChain {
protected:
AVIIndexChainNode *head, *tail;
void delete_chain();
public:
int total_ents;
AVIIndexChain();
~AVIIndexChain();
bool add(w32AVIINDEXENTRY *avie);
bool add(AVIIndexEntry2 *avie2);
bool add(uint32_le ckid, sint64 pos, long len, bool is_keyframe);
void put(w32AVIINDEXENTRY *avietbl);
void put(AVIIndexEntry2 *avie2tbl);
void put(AVIIndexEntry3 *avie3tbl, sint64 offset);
};
class AVIIndex : public AVIIndexChain {
protected:
w32AVIINDEXENTRY *index;
AVIIndexEntry2 *index2;
AVIIndexEntry3 *index3;
int index_len;
w32AVIINDEXENTRY *allocateIndex(int total_entries) {
return index = new w32AVIINDEXENTRY[index_len = total_entries];
}
AVIIndexEntry2 *allocateIndex2(int total_entries) {
return index2 = new AVIIndexEntry2[index_len = total_entries];
}
AVIIndexEntry3 *allocateIndex3(int total_entries) {
return index3 = new AVIIndexEntry3[index_len = total_entries];
}
public:
AVIIndex();
~AVIIndex();
bool makeIndex();
bool makeIndex2();
bool makeIndex3(sint64 offset);
void clear();
w32AVIINDEXENTRY *indexPtr() {
return index;
}
AVIIndexEntry2 *index2Ptr() {
return index2;
}
AVIIndexEntry3 *index3Ptr() {
return index3;
}
AVIIndexEntry2 *takeIndex2() {
AVIIndexEntry2 *idx = index2;
index2 = NULL;
return idx;
}
int size() { return total_ents; }
int indexLen() {
return index_len;
}
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,69 +0,0 @@
// VirtualDub - Video processing and capture application
// Copyright (C) 1998-2001 Avery Lee
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// Modified by Julien 'Cyrius' Coloos
// 20-09-2003
//
#ifndef f_AVIREADHANDLER_H
#define f_AVIREADHANDLER_H
#include "mm_io.h"
#include "common_gdivfw.h"
// These are meant as AVIFile replacements. They're not quite to AVIFile
// specs, but they'll do for now.
class IAVIReadStream {
public:
virtual ~IAVIReadStream();
virtual long BeginStreaming(long lStart, long lEnd, long lRate)=0;
virtual long EndStreaming()=0;
virtual long Info(w32AVISTREAMINFO *pasi, long lSize)=0;
virtual bool IsKeyFrame(long lFrame)=0;
virtual long Read(long lStart, long lSamples, void *lpBuffer, long cbBuffer, long *plBytes, long *plSamples)=0;
virtual long Start()=0;
virtual long End()=0;
virtual long PrevKeyFrame(long lFrame)=0;
virtual long NextKeyFrame(long lFrame)=0;
virtual long NearestKeyFrame(long lFrame)=0;
virtual long FormatSize(long lFrame, long *plSize)=0;
virtual long ReadFormat(long lFrame, void *pFormat, long *plSize)=0;
virtual bool isStreaming()=0;
virtual bool isKeyframeOnly()=0;
virtual bool getVBRInfo(double& bitrate_mean, double& bitrate_stddev, double& maxdev)=0;
};
class IAVIReadHandler {
public:
virtual void AddRef()=0;
virtual void Release()=0;
virtual IAVIReadStream *GetStream(uint32 fccType, sint32 lParam)=0;
virtual void EnableFastIO(bool)=0;
virtual bool isOptimizedForRealtime()=0;
virtual bool isStreaming()=0;
virtual bool isIndexFabricated()=0;
//virtual bool AppendFile(const char *pszFile)=0;
//virtual bool getSegmentHint(const char **ppszPath)=0;
};
IAVIReadHandler *CreateAVIReadHandler(mm_io_c *input);
#endif

View File

@ -1,58 +0,0 @@
// VirtualDub - Video processing and capture application
// Copyright (C) 1998-2001 Avery Lee
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// Modified by Julien 'Cyrius' Coloos
// 20-09-2003
//
#ifndef f_FIXES_H
#define f_FIXES_H
#include "common_gdivfw.h"
// Those stupid idiots at Microsoft forgot to change this structure
// when making the VfW headers for Win32. The result is that the
// AVIStreamHeader is correct in 16-bit Windows, but the 32-bit
// headers define RECT as LONGs instead of SHORTs. This creates
// invalid AVI files!!!!
typedef struct {
sint16_le left;
sint16_le top;
sint16_le right;
sint16_le bottom;
} w32RECT16;
typedef struct {
uint32_le fccType;
uint32_le fccHandler;
uint32_le dwFlags;
uint16_le wPriority;
uint16_le wLanguage;
uint32_le dwInitialFrames;
uint32_le dwScale;
uint32_le dwRate;
uint32_le dwStart;
uint32_le dwLength;
uint32_le dwSuggestedBufferSize;
uint32_le dwQuality;
uint32_le dwSampleSize;
w32RECT16 rcFrame;
} AVIStreamHeader_fixed;
#endif

View File

@ -1,2 +0,0 @@
all %:
make -C .. $@

View File

@ -1,5 +0,0 @@
# mkvtoolnix - Makefile for MinGW
# because I was fed up fighting against libtool
all clean:
make -C .. $@

View File

@ -1,173 +0,0 @@
// Some common tools
// Copyright (C) 2003 Julien 'Cyrius' Coloos
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
// or visit http://www.gnu.org/licenses/gpl.html
#ifndef __TOOLS_COMMON_H__
#define __TOOLS_COMMON_H__
#include "os.h"
#include <stdarg.h>
#include <assert.h>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
// Provide the storage class specifier (extern for an .exe file, null
// for DLL) and the __declspec specifier (dllimport for an .exe file,
// dllexport for DLL).
// You must define TOOLS_DLL_EXPORTS when compiling the DLL.
// You can now use this header file in both the .exe file and DLL - a
// much safer means of using common declarations than two different
// header files.
#ifdef TOOLS_DLL
# ifdef TOOLS_DLL_EXPORTS
# define TOOLS_DLL_API __declspec(dllexport)
# define TOOLS_EXPIMP_TEMPLATE
# else
# define TOOLS_DLL_API __declspec(dllimport)
# define TOOLS_EXPIMP_TEMPLATE extern
# endif
#else
# define TOOLS_DLL_API
# define TOOLS_EXPIMP_TEMPLATE
#endif
#ifndef _LL
#ifdef _MSC_VER
#define _LL(i) i ## i64
#else
#define _LL(i) i ## ll
#endif
#endif
// Fix taken from VirtualDub (c) Avery Lee
///////////////////////////////////////////////////////////////////////////
//
// STL fixes
//
///////////////////////////////////////////////////////////////////////////
#ifdef _MSC_VER
#if _MSC_VER < 1300
namespace std {
template<typename T>
inline const T& min(const T& x, const T& y) {
return _cpp_min(x, y);
}
template<class T>
inline const T& max(const T& x, const T& y) {
return _cpp_max(x, y);
}
};
#endif
#endif
#ifdef _MSC_VER
typedef signed __int8 sint8;
typedef signed __int16 sint16;
typedef signed __int32 sint32;
typedef signed __int64 sint64;
typedef unsigned __int8 uint8;
typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32;
typedef unsigned __int64 uint64;
#else
typedef int8_t sint8;
typedef int16_t sint16;
typedef int32_t sint32;
typedef int64_t sint64;
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
#endif
#define RoundToLong(f) (sint32)((f)+0.5)
#define RoundToULong(f) (uint32)((f)+0.5)
typedef enum {
kMsg,
kMsgWarning,
kMsgError
} eMsgType;
#ifdef _DEBUG
#define DEBUG_MESSAGE PrintMessage
#else
#define DEBUG_MESSAGE
#endif
template<class _T>
void Duplicatelist(std::list<_T *> &dst, std::list<_T *> &src) {
int i;
for(i = 0; i < src.size(); i++) {
_T *pNewNode = new _T(*(src[i]));
dst.push_back(pNewNode);
}
}
template<class _T>
void Duplicatevector(std::vector<_T *> &dst, std::vector<_T *> &src) {
int i;
for(i = 0; i < src.size(); i++) {
_T *pNewNode = new _T(*(src[i]));
dst.push_back(pNewNode);
}
}
template<class _T>
void Clearlist(std::list<_T *>& cont) {
int i;
for (i = 0; i < cont.size(); i++)
delete cont[i];
cont.clear();
}
template<class _T>
void Clearvector(std::vector<_T *>& cont) {
int i;
for (i = 0; i < cont.size(); i++)
delete cont[i];
cont.clear();
}
#define CONTAINER_DUPLICATE_0(container, _T, dst, src) \
Duplicate##container<_T>(dst, src);
#define CONTAINER_CLEAR_0(container, _T, cont) \
Clear##container<_T>(cont);
#define LIST_DUPLICATE(_T, src, dst) \
CONTAINER_DUPLICATE_0(list, _T, src, dst)
#define LIST_CLEAR(_T, cont) \
CONTAINER_CLEAR_0(list, _T, cont)
#define VECTOR_DUPLICATE(_T, src, dst) \
CONTAINER_DUPLICATE_0(vector, _T, src, dst)
#define VECTOR_CLEAR(_T, cont) \
CONTAINER_CLEAR_0(vector, _T, cont)
template class std::vector<uint8>;
#endif // __TOOLS_COMMON_H__

View File

@ -1,189 +0,0 @@
// Some common tools
// Copyright (C) 2003 Julien 'Cyrius' Coloos
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
// or visit http://www.gnu.org/licenses/gpl.html
#ifndef __TOOLS_COMMON_ENDIAN_H__
#define __TOOLS_COMMON_ENDIAN_H__
#include "os.h"
#include "ac_common.h"
#undef LIL_ENDIAN
#undef BIG_ENDIAN
#define LIL_ENDIAN 0x0102
#define BIG_ENDIAN 0x0201
#if WORDS_BIGENDIAN == 1
# define AVI_BYTE_ORDER BIG_ENDIAN
#else
# define AVI_BYTE_ORDER LIL_ENDIAN
#endif
typedef enum {
kBigEndian,
kLittleEndian
} eEndianness;
template<class _T, eEndianness _ENDIANNESS>
class EndianValue {
protected:
_T m_Value;
public:
// Defining ctors cause troubles in unions
//EndianValue<_T, _ENDIANNESS>(void) { };
//EndianValue<_T, _ENDIANNESS>(const _T& value) {
// *this = value;
//};
inline operator _T(void) const {
#if AVI_BYTE_ORDER == LIL_ENDIAN
if(_ENDIANNESS == kLittleEndian)
return m_Value;
else {
_T value = m_Value;
std::reverse(reinterpret_cast<uint8 *>(&value), reinterpret_cast<uint8 *>((&value)+1));
return value;
}
#else
if(_ENDIANNESS == kBigEndian)
return m_Value;
else {
_T value = m_Value;
std::reverse(reinterpret_cast<uint8 *>(&value), reinterpret_cast<uint8 *>((&value)+1));
return value;
}
#endif
};
inline EndianValue<_T, _ENDIANNESS>& operator =(const _T& value) {
m_Value = value;
#if AVI_BYTE_ORDER == LIL_ENDIAN
if(_ENDIANNESS == kBigEndian)
std::reverse(reinterpret_cast<uint8 *>(&m_Value), reinterpret_cast<uint8 *>((&m_Value)+1));
#else
if(_ENDIANNESS == kLittleEndian)
std::reverse(reinterpret_cast<uint8 *>(&m_Value), reinterpret_cast<uint8 *>((&m_Value)+1));
#endif
return *this;
};
// If this is defined, we get an error C2622 because union members can't have
// an assignment operator
//inline EndianValue<_T, _ENDIANNESS>& operator =(const EndianValue<_T, _ENDIANNESS>& value) {
// m_Value = value.m_Value;
// return *this;
//};
// The 'conventional' binary operators mustn't be defined (at least
// with MSVC) because a proper conversion is already done by the
// compiler (overloading again the operator generates problems)
#define DEFINE_ENDIANVALUE_BINARY_OPERATOR_1(op) \
inline EndianValue<_T, _ENDIANNESS>& operator op(const _T& value) { \
*this = _T(*this) op value; \
return *this; \
};
#define DEFINE_ENDIANVALUE_BINARY_OPERATOR_2(op) \
inline EndianValue<_T, _ENDIANNESS>& operator op##=(const _T& value) { \
*this = _T(*this) op value; \
return *this; \
};
#define DEFINE_ENDIANVALUE_COMPARISON_OPERATOR(op) \
inline bool operator op(const EndianValue<_T, _ENDIANNESS>& value) const { \
return (m_Value op value.m_Value); \
};
#define DEFINE_ENDIANVALUE_BINARY_OPERATOR(op) \
DEFINE_ENDIANVALUE_BINARY_OPERATOR_2(op)
DEFINE_ENDIANVALUE_BINARY_OPERATOR(+)
DEFINE_ENDIANVALUE_BINARY_OPERATOR(-)
DEFINE_ENDIANVALUE_BINARY_OPERATOR(*)
DEFINE_ENDIANVALUE_BINARY_OPERATOR(/)
DEFINE_ENDIANVALUE_BINARY_OPERATOR(%)
DEFINE_ENDIANVALUE_BINARY_OPERATOR(&)
DEFINE_ENDIANVALUE_BINARY_OPERATOR(|)
DEFINE_ENDIANVALUE_BINARY_OPERATOR(<<)
DEFINE_ENDIANVALUE_BINARY_OPERATOR(>>)
DEFINE_ENDIANVALUE_COMPARISON_OPERATOR(==)
DEFINE_ENDIANVALUE_COMPARISON_OPERATOR(!=)
DEFINE_ENDIANVALUE_COMPARISON_OPERATOR(<)
DEFINE_ENDIANVALUE_COMPARISON_OPERATOR(<=)
DEFINE_ENDIANVALUE_COMPARISON_OPERATOR(>)
DEFINE_ENDIANVALUE_COMPARISON_OPERATOR(>=)
inline EndianValue<_T, _ENDIANNESS>& operator ++(void) {
*this = _T(*this) + 1;
return *this;
};
inline _T operator ++(int) {
_T value = _T(*this);
++*this;
return value;
};
inline EndianValue<_T, _ENDIANNESS>& operator --(void) {
*this = _T(*this) - 1;
return *this;
};
inline _T operator --(int) {
_T value = _T(*this);
--*this;
return value;
};
};
// Instantiate some EndianValue<...> classes
// This does not create an object. It only forces the generation of all of the members
// of the class. It exports them from the DLL and imports them into the .exe file.
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<uint16, kLittleEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<uint32, kLittleEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<uint64, kLittleEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<sint16, kLittleEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<sint32, kLittleEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<sint64, kLittleEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<uint16, kBigEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<uint32, kBigEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<uint64, kBigEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<sint16, kBigEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<sint32, kBigEndian>;
TOOLS_EXPIMP_TEMPLATE template class TOOLS_DLL_API EndianValue<sint64, kBigEndian>;
#if AVI_BYTE_ORDER == BIG_ENDIAN
typedef EndianValue<uint16, kLittleEndian> uint16_le;
typedef EndianValue<uint32, kLittleEndian> uint32_le;
typedef EndianValue<uint64, kLittleEndian> uint64_le;
typedef EndianValue<sint16, kLittleEndian> sint16_le;
typedef EndianValue<sint32, kLittleEndian> sint32_le;
typedef EndianValue<sint64, kLittleEndian> sint64_le;
typedef uint16 uint16_be;
typedef uint32 uint32_be;
typedef uint64 uint64_be;
typedef sint16 sint16_be;
typedef sint32 sint32_be;
typedef sint64 sint64_be;
#elif AVI_BYTE_ORDER == LIL_ENDIAN
typedef uint16 uint16_le;
typedef uint32 uint32_le;
typedef uint64 uint64_le;
typedef sint16 sint16_le;
typedef sint32 sint32_le;
typedef sint64 sint64_le;
typedef EndianValue<uint16, kBigEndian> uint16_be;
typedef EndianValue<uint32, kBigEndian> uint32_be;
typedef EndianValue<uint64, kBigEndian> uint64_be;
typedef EndianValue<sint16, kBigEndian> sint16_be;
typedef EndianValue<sint32, kBigEndian> sint32_be;
typedef EndianValue<sint64, kBigEndian> sint64_be;
#endif
#endif // __TOOLS_COMMON_ENDIAN_H__

View File

@ -1,384 +0,0 @@
// Some common tools
// Copyright (C) 2003 Julien 'Cyrius' Coloos
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
// or visit http://www.gnu.org/licenses/gpl.html
#ifndef __TOOLS_COMMON_GDIVFW_H__
#define __TOOLS_COMMON_GDIVFW_H__
#include "os.h"
#include <ctype.h>
#if defined(SYS_WINDOWS)
#include <windef.h>
#include <winerror.h>
#endif
#include "ac_common.h"
#include "common_endian.h"
//////////////////////////////////////////////////////////////////////
// Some data 'copied' from gdi.h, vfw.h and winerror.h (Microsoft files)
/*
* Video header (BITMAPINFOHEADER)
*/
typedef struct tagw32BITMAPINFOHEADER {
uint32_le biSize;
sint32_le biWidth;
sint32_le biHeight;
uint16_le biPlanes;
uint16_le biBitCount;
uint32_le biCompression;
uint32_le biSizeImage;
sint32_le biXPelsPerMeter;
sint32_le biYPelsPerMeter;
uint32_le biClrUsed;
uint32_le biClrImportant;
} w32BITMAPINFOHEADER;
/*
* AVI headers
*/
typedef struct tagw32RECT {
sint32_le left;
sint32_le top;
sint32_le right;
sint32_le bottom;
} w32RECT;
typedef struct _w32AVISTREAMINFOW {
uint32_le fccType;
uint32_le fccHandler;
uint32_le dwFlags; /* Contains AVITF_* flags */
uint32_le dwCaps;
uint16_le wPriority;
uint16_le wLanguage;
uint32_le dwScale;
uint32_le dwRate; /* dwRate / dwScale == samples/second */
uint32_le dwStart;
uint32_le dwLength; /* In units above... */
uint32_le dwInitialFrames;
uint32_le dwSuggestedBufferSize;
uint32_le dwQuality;
uint32_le dwSampleSize;
w32RECT rcFrame;
uint32_le dwEditCount;
uint32_le dwFormatChangeCount;
char szName[64];
} w32AVISTREAMINFOW;
typedef struct _w32AVISTREAMINFOA {
uint32_le fccType;
uint32_le fccHandler;
uint32_le dwFlags; /* Contains AVITF_* flags */
uint32_le dwCaps;
uint16_le wPriority;
uint16_le wLanguage;
uint32_le dwScale;
uint32_le dwRate; /* dwRate / dwScale == samples/second */
uint32_le dwStart;
uint32_le dwLength; /* In units above... */
uint32_le dwInitialFrames;
uint32_le dwSuggestedBufferSize;
uint32_le dwQuality;
uint32_le dwSampleSize;
w32RECT rcFrame;
uint32_le dwEditCount;
uint32_le dwFormatChangeCount;
char szName[64];
} w32AVISTREAMINFOA;
#ifdef UNICODE
#define w32AVISTREAMINFO w32AVISTREAMINFOW
#else
#define w32AVISTREAMINFO w32AVISTREAMINFOA
#endif
typedef struct {
uint32_le ckid;
uint32_le dwFlags;
uint32_le dwChunkOffset; // Position of chunk
uint32_le dwChunkLength; // Length of chunk
} w32AVIINDEXENTRY;
/* Flags for AVI file index */
//#define AVIIF_LIST 0x00000001L
//#define AVIIF_TWOCC 0x00000002L
#define AVIIF_KEYFRAME 0x00000010L
typedef struct {
uint32_le dwMicroSecPerFrame; // frame display rate (or 0L)
uint32_le dwMaxBytesPerSec; // max. transfer rate
uint32_le dwPaddingGranularity; // pad to multiples of this
// size; normally 2K.
uint32_le dwFlags; // the ever-present flags
uint32_le dwTotalFrames; // # frames in file
uint32_le dwInitialFrames;
uint32_le dwStreams;
uint32_le dwSuggestedBufferSize;
uint32_le dwWidth;
uint32_le dwHeight;
uint32_le dwReserved[4];
} w32MainAVIHeader;
#define AVISTREAMREAD_CONVENIENT (-1L)
/*
* Error codes
*/
#ifndef ICERR_OK
#define ICERR_OK 0L
#define ICERR_UNSUPPORTED -1L
#define ICERR_BADFORMAT -2L
#define ICERR_MEMORY -3L
#define ICERR_INTERNAL -4L
#define ICERR_BADFLAGS -5L
#define ICERR_BADPARAM -6L
#define ICERR_BADSIZE -7L
#define ICERR_BADHANDLE -8L
#define ICERR_CANTUPDATE -9L
#define ICERR_ABORT -10L
#define ICERR_ERROR -100L
#define ICERR_BADBITDEPTH -200L
#define ICERR_BADIMAGESIZE -201L
#define ICERR_CUSTOM -400L // errors less than ICERR_CUSTOM...
#endif
#if !defined(SYS_WINDOWS)
#ifndef MMNOMMIO
#define MMIOERR_BASE 256
#define MMIOERR_FILENOTFOUND (MMIOERR_BASE + 1) /* file not found */
#define MMIOERR_OUTOFMEMORY (MMIOERR_BASE + 2) /* out of memory */
#define MMIOERR_CANNOTOPEN (MMIOERR_BASE + 3) /* cannot open */
#define MMIOERR_CANNOTCLOSE (MMIOERR_BASE + 4) /* cannot close */
#define MMIOERR_CANNOTREAD (MMIOERR_BASE + 5) /* cannot read */
#define MMIOERR_CANNOTWRITE (MMIOERR_BASE + 6) /* cannot write */
#define MMIOERR_CANNOTSEEK (MMIOERR_BASE + 7) /* cannot seek */
#define MMIOERR_CANNOTEXPAND (MMIOERR_BASE + 8) /* cannot expand file */
#define MMIOERR_CHUNKNOTFOUND (MMIOERR_BASE + 9) /* chunk not found */
#define MMIOERR_UNBUFFERED (MMIOERR_BASE + 10) /* */
#define MMIOERR_PATHNOTFOUND (MMIOERR_BASE + 11) /* path incorrect */
#define MMIOERR_ACCESSDENIED (MMIOERR_BASE + 12) /* file was protected */
#define MMIOERR_SHARINGVIOLATION (MMIOERR_BASE + 13) /* file in use */
#define MMIOERR_NETWORKERROR (MMIOERR_BASE + 14) /* network not responding */
#define MMIOERR_TOOMANYOPENFILES (MMIOERR_BASE + 15) /* no more file handles */
#define MMIOERR_INVALIDFILE (MMIOERR_BASE + 16) /* default error file error */
#endif
#endif
/*
* long values
*/
// Values are 32 bit values layed out as follows:
//
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
// +---+-+-+-----------------------+-------------------------------+
// |Sev|C|R| Facility | Code |
// +---+-+-+-----------------------+-------------------------------+
//
// Sev - is the severity code
// 00 - Success
// 01 - Informational
// 10 - Warning
// 11 - Error
//
// C - is the Customer code flag
//
// R - is a reserved bit
//
// Facility - is the facility code
//
// Code - is the facility's status code
//
//
// Define the facility codes
//
#define FACILITY_ITF 4
// longs are 32 bit values layed out as follows:
//
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
// +-+-+-+-+-+---------------------+-------------------------------+
// |S|R|C|N|r| Facility | Code |
// +-+-+-+-+-+---------------------+-------------------------------+
//
// S - Severity - indicates success/fail
// 0 - Success
// 1 - Fail (COERROR)
//
// R - reserved portion of the facility code, corresponds to NT's
// second severity bit.
//
// C - reserved portion of the facility code, corresponds to NT's
// C field.
//
// N - reserved portion of the facility code. Used to indicate a
// mapped NT status value.
//
// r - reserved portion of the facility code. Reserved for internal
// use. Used to indicate long values that are not status
// values, but are instead message ids for display strings.
//
// Facility - is the facility code
//
// Code - is the facility's status code
//
// Severity values
//
//#define SEVERITY_SUCCESS 0
#define SEVERITY_ERROR 1
//
// Success codes
//
#if !defined(S_OK)
#define S_OK ((long)0x00000000L)
#define S_FALSE ((long)0x00000001L)
#endif
#undef MAKE_SCODE
#define MAKE_SCODE(sev,fac,code) \
((sint32) ((uint32(sev)<<31) | (uint32(fac)<<16) | (uint32(code))) )
#ifndef AVIERR_OK
#define AVIERR_OK 0L
#define MAKE_AVIERR(error) MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x4000 + error)
#define AVIERR_UNSUPPORTED MAKE_AVIERR(101)
#define AVIERR_BADFORMAT MAKE_AVIERR(102)
#define AVIERR_MEMORY MAKE_AVIERR(103)
#define AVIERR_INTERNAL MAKE_AVIERR(104)
#define AVIERR_BADFLAGS MAKE_AVIERR(105)
#define AVIERR_BADPARAM MAKE_AVIERR(106)
#define AVIERR_BADSIZE MAKE_AVIERR(107)
#define AVIERR_BADHANDLE MAKE_AVIERR(108)
#define AVIERR_FILEREAD MAKE_AVIERR(109)
#define AVIERR_FILEWRITE MAKE_AVIERR(110)
#define AVIERR_FILEOPEN MAKE_AVIERR(111)
#define AVIERR_COMPRESSOR MAKE_AVIERR(112)
#define AVIERR_NOCOMPRESSOR MAKE_AVIERR(113)
#define AVIERR_READONLY MAKE_AVIERR(114)
#define AVIERR_NODATA MAKE_AVIERR(115)
#define AVIERR_BUFFERTOOSMALL MAKE_AVIERR(116)
#define AVIERR_CANTCOMPRESS MAKE_AVIERR(117)
#define AVIERR_USERABORT MAKE_AVIERR(198)
#define AVIERR_ERROR MAKE_AVIERR(199)
#endif
/*
* FourCC codes
*/
#ifdef mmioFOURCC
# undef mmioFOURCC
#endif
#define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
( (uint32)uint8(ch0) | ( (uint32)uint8(ch1) << 8 ) | \
( (uint32)uint8(ch2) << 16 ) | ( (uint32)uint8(ch3) << 24 ) )
/* Should work for little and big endian architectures
* (you must define your FourCC as uint32_le) :
* mmioFOURCC(a,b,c,d) will give dcba as value
* On little endian architectures, this would be stored as abcd in memory
* Affecting the value to an uint32_le will keep this memory ordering
* On big endian architectures, this would be stored as dcba in memory
* Affecting the value to an uint32_le will swap the byte ordering to abcd in memory
*/
#define bitmapFOURCC mmioFOURCC
inline bool isValidFOURCC(uint32 fcc) {
return isprint(uint8(fcc>>24))
&& isprint(uint8(fcc>>16))
&& isprint(uint8(fcc>> 8))
&& isprint(uint8(fcc ));
}
/* form types, list types, and chunk types */
#define formtypeAVI mmioFOURCC('A', 'V', 'I', ' ')
#define formtypeAVIEXTENDED mmioFOURCC('A', 'V', 'I', 'X')
#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')
#define ckidOPENDMLINDEX mmioFOURCC('i', 'n', 'd', 'x')
/*
** Stream types for the <fccType> 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')
/* Interleaved video/audio stream, used by DV1 format */
#define streamtypeINTERLEAVED mmioFOURCC('i', 'v', 'a', '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')
/* standard four character codes */
#define FOURCC_RIFF mmioFOURCC('R', 'I', 'F', 'F')
#define FOURCC_LIST mmioFOURCC('L', 'I', 'S', 'T')
#ifdef LOWORD
# undef LOWORD
# undef HIWORD
# undef LOBYTE
# undef HIBYTE
#endif
#define LOWORD(l) ((uint16)(uint32(l) & 0xFFFF))
#define HIWORD(l) ((uint16)(uint32(l) >> 16))
#define LOBYTE(w) ((uint8)(uint32(w) & 0xFF))
#define HIBYTE(w) ((uint8)(uint32(w) >> 8))
/* Macro to get stream number out of a FOURCC ckid */
#ifdef FromHex
# undef FromHex
# undef StreamFromFOURCC
#endif
#define FromHex(n) (((n) >= 'A') ? ((n) + 10 - 'A') : ((n) - '0'))
#define StreamFromFOURCC(fcc) ((uint16) ((FromHex(LOBYTE(LOWORD(fcc))) << 4) + \
(FromHex(HIBYTE(LOWORD(fcc))))))
#endif // __TOOLS_COMMON_GDIVFW_H__

View File

@ -1,118 +0,0 @@
// Some common tools
// Copyright (C) 2003 Julien 'Cyrius' Coloos
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
// or visit http://www.gnu.org/licenses/gpl.html
#ifndef __TOOLS_COMMON_MMREG_H__
#define __TOOLS_COMMON_MMREG_H__
#include "os.h"
#include "ac_common.h"
#include "common_endian.h"
//////////////////////////////////////////////////////////////////////
// Some data 'copied' from mmreg.h (Microsoft files)
typedef struct __attribute__((__packed__)) w32waveformat_tag {
uint16_le wFormatTag; /* format type */
uint16_le nChannels; /* number of channels (i.e. mono, stereo...) */
uint32_le nSamplesPerSec; /* sample rate */
uint32_le nAvgBytesPerSec; /* for buffer estimation */
uint16_le nBlockAlign; /* block size of data */
} w32WAVEFORMAT;
#define WAVE_FORMAT_PCM 1
typedef struct __attribute__((__packed__)) w32pcmwaveformat_tag {
w32WAVEFORMAT wf;
uint16_le wBitsPerSample;
} w32PCMWAVEFORMAT;
#undef WAVE_FORMAT_MPEG
#undef WAVE_FORMAT_MPEGLAYER3
#ifndef WAVE_FORMAT_MPEG
# define WAVE_FORMAT_MPEG 0x0050 // Microsoft Corporation
#endif
#ifndef WAVE_FORMAT_MPEGLAYER3
# define WAVE_FORMAT_MPEGLAYER3 0x0055 // ISO/MPEG Layer3 Format Tag
#endif
#define WAVE_FORMAT_AC3 0x2000 // ATSC/A-52 (Dolby AC3)
typedef struct __attribute__((__packed__)) tw32WAVEFORMATEX {
uint16_le wFormatTag; // format type
uint16_le nChannels; // number of channels (i.e. mono, stereo...)
uint32_le nSamplesPerSec; // sample rate
uint32_le nAvgBytesPerSec; // for buffer estimation
uint16_le nBlockAlign; // block size of data
uint16_le wBitsPerSample; // Number of bits per sample of mono data
uint16_le cbSize; // The count in bytes of the size of extra information (after cbSize)
} w32WAVEFORMATEX;
// Microsoft MPEG audio WAV definition
//
// MPEG-1 audio wave format (audio layer only). (0x0050)
typedef struct __attribute__((__packed__)) w32mpeg1waveformat_tag {
w32WAVEFORMATEX wfx;
uint16_le fwHeadLayer;
uint32_le dwHeadBitrate;
uint16_le fwHeadMode;
uint16_le fwHeadModeExt;
uint16_le wHeadEmphasis;
uint16_le fwHeadFlags;
uint32_le dwPTSLow;
uint32_le dwPTSHigh;
} w32MPEG1WAVEFORMAT;
#define ACM_MPEG_LAYER1 (0x0001)
#define ACM_MPEG_LAYER2 (0x0002)
#define ACM_MPEG_LAYER3 (0x0004)
#define ACM_MPEG_STEREO (0x0001)
#define ACM_MPEG_JOINTSTEREO (0x0002)
#define ACM_MPEG_DUALCHANNEL (0x0004)
#define ACM_MPEG_SINGLECHANNEL (0x0008)
#define ACM_MPEG_PRIVATEBIT (0x0001)
#define ACM_MPEG_COPYRIGHT (0x0002)
#define ACM_MPEG_ORIGINALHOME (0x0004)
#define ACM_MPEG_PROTECTIONBIT (0x0008)
#define ACM_MPEG_ID_MPEG1 (0x0010)
// MPEG Layer3 WAVEFORMATEX structure
// for WAVE_FORMAT_MPEGLAYER3 (0x0055)
//
#define MPEGLAYER3_WFX_EXTRA_BYTES 12
// WAVE_FORMAT_MPEGLAYER3 format sructure
//
typedef struct __attribute__((__packed__)) w32mpeglayer3waveformat_tag {
w32WAVEFORMATEX wfx;
uint16_le wID;
uint32_le fdwFlags;
uint16_le nBlockSize;
uint16_le nFramesPerBlock;
uint16_le nCodecDelay;
} w32MPEGLAYER3WAVEFORMAT;
#define MPEGLAYER3_ID_UNKNOWN 0
#define MPEGLAYER3_ID_MPEG 1
#define MPEGLAYER3_ID_CONSTANTFRAMESIZE 2
#define MPEGLAYER3_FLAG_PADDING_ISO 0x00000000
#define MPEGLAYER3_FLAG_PADDING_ON 0x00000001
#define MPEGLAYER3_FLAG_PADDING_OFF 0x00000002
#endif // __TOOLS_COMMON_MMREG_H__

View File

@ -1,93 +0,0 @@
// VirtualDub 2.x (Nina) - Video processing and capture application
// Copyright (C) 1998-2001 Avery Lee, All Rights Reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// Modified by Julien 'Cyrius' Coloos
// 20-09-2003
//
///////////////////////////////////////////////////////////////////////////
//
// For those of you who say this looks familiar... it should. This is
// the same linked-list style that the Amiga Exec uses, with dummy head
// and tail nodes. It's really a very convienent way to implement
// doubly-linked lists.
//
#include <algorithm>
#include "list.h"
List::List() {
Init();
}
void List::Init() {
head.next = tail.prev = 0;
head.prev = &tail;
tail.next = &head;
}
ListNode *List::RemoveHead() {
if (head.prev->prev) {
ListNode *t = head.prev;
head.prev->Remove();
return t;
}
return 0;
}
ListNode *List::RemoveTail() {
if (tail.next->next) {
ListNode *t = tail.next;
tail.next->Remove();
return t;
}
return 0;
}
void List::Take(List &from) {
if (from.IsEmpty())
return;
head.prev = from.head.prev;
tail.next = from.tail.next;
head.prev->next = &head;
tail.next->prev = &tail;
from.Init();
}
void List::Swap(List &dst) {
if (IsEmpty())
Take(dst);
else if (dst.IsEmpty())
dst.Take(*this);
else {
std::swap(head.prev, dst.head.prev);
std::swap(tail.next, dst.tail.next);
head.prev->next = &head;
tail.next->prev = &tail;
dst.head.prev->next = &dst.head;
dst.tail.next->prev = &dst.tail;
}
}

View File

@ -1,272 +0,0 @@
// VirtualDub 2.x (Nina) - Video processing and capture application
// Copyright (C) 1998-2001 Avery Lee, All Rights Reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// Modified by Julien 'Cyrius' Coloos
// 20-09-2003
//
#ifndef f_LIST_H
#define f_LIST_H
class ListNode {
public:
ListNode *next, *prev;
void Remove() {
next->prev = prev;
prev->next = next;
#ifdef _DEBUG
prev = next = 0;
#endif
}
void InsertAfter(ListNode *node) {
next = node;
prev = node->prev;
if (node->prev) node->prev->next = this;
node->prev = this;
}
void InsertBefore(ListNode *node) {
next = node->next;
prev = node;
if (node->next) node->next->prev = this;
node->next = this;
}
ListNode *NextFromHead() const {
return prev;
}
ListNode *NextFromTail() const {
return next;
}
};
class List {
private:
public:
ListNode head, tail;
// <--- next prev --->
//
// head <-> node <-> node <-> tail
List();
List(int) {}
void Init();
void AddHead(ListNode *node) {
node->InsertAfter(&head);
}
void AddTail(ListNode *node) {
node->InsertBefore(&tail);
}
ListNode *RemoveHead();
ListNode *RemoveTail();
bool IsEmpty() const {
return !head.prev->prev;
}
ListNode *AtHead() const {
return head.prev;
}
ListNode *AtTail() const {
return tail.next;
}
void Take(List& from);
void Swap(List& with);
};
// Templated classes... templated classes good.
template<class T> class List2;
template<class T>
class ListNode2 : public ListNode {
friend class List2<T>;
public:
void InsertBefore(ListNode2<T> *node) { ListNode::InsertBefore(node); }
void InsertAfter(ListNode2<T> *node) { ListNode::InsertAfter(node); }
void Remove() { ListNode::Remove(); }
T *NextFromHead() const { return static_cast<T *>(static_cast<ListNode2<T>*>(ListNode::NextFromHead())); }
T *NextFromTail() const { return static_cast<T *>(static_cast<ListNode2<T>*>(ListNode::NextFromTail())); }
};
template<class T>
class List2 : public List {
public:
List2<T>() {}
// This is a really lame, stupid way to postpone initialization of the
// list.
List2<T>(int v) : List(v) {}
void AddHead(ListNode2<T> *node) { List::AddHead(node); }
void AddTail(ListNode2<T> *node) { List::AddTail(node); }
T *RemoveHead() { return static_cast<T *>(static_cast<ListNode2<T>*>(List::RemoveHead())); }
T *RemoveTail() { return static_cast<T *>(static_cast<ListNode2<T>*>(List::RemoveTail())); }
T *AtHead() const { return static_cast<T *>(static_cast<ListNode2<T>*>(List::AtHead())); }
T *AtTail() const { return static_cast<T *>(static_cast<ListNode2<T>*>(List::AtTail())); }
// I must admit to being pampered by STL (end is different though!!)
T *begin() const { return AtHead(); }
T *end() const { return AtTail(); }
void take(List2<T>& from) { List::Take(from); }
class iterator {
protected:
ListNode2<T> *node;
ListNode2<T> *next;
public:
iterator() {}
iterator(const iterator& src) throw() : node(src.node), next(src.next) {}
bool operator!() const throw() { return 0 == next; }
T *operator->() const throw() { return (T *)node; }
operator bool() const throw() { return 0 != next; }
operator T *() const throw() { return (T *)node; }
T& operator *() const throw() { return *(T *)node; }
};
// fwit: forward iterator (SAFE if node disappears)
// rvit: reverse iterator (SAFE if node disappears)
class fwit : public iterator {
public:
fwit() throw() {}
fwit(const fwit& src) throw() : iterator(src) {}
fwit(ListNode2<T> *start) throw() {
iterator::node = start;
iterator::next = start->NextFromHead();
}
const fwit& operator=(ListNode2<T> *start) throw() {
iterator::node = start;
iterator::next = start->NextFromHead();
return *this;
}
fwit& operator++() throw() {
iterator::node = iterator::next;
iterator::next = iterator::node->NextFromHead();
return *this;
}
const fwit& operator+=(int v) throw() {
while(iterator::next && v--) {
iterator::node = iterator::next;
iterator::next = iterator::node->NextFromHead();
}
return *this;
}
fwit operator+(int v) const throw() {
fwit t(*this);
t += v;
return t;
}
// This one's for my sanity.
void operator++(int) throw() {
++*this;
}
};
class rvit : public iterator {
public:
rvit() throw() {}
rvit(ListNode2<T> *start) throw() {
iterator::node = iterator::start;
iterator::next = iterator::start->NextFromTail();
}
const rvit& operator=(ListNode2<T> *start) throw() {
iterator::node = iterator::start;
iterator::next = iterator::start->NextFromTail();
return *this;
}
rvit& operator--() throw() {
iterator::node = iterator::next;
iterator::next = iterator::node->NextFromTail();
return *this;
}
const rvit& operator-=(int v) throw() {
while(iterator::next && v--) {
iterator::node = iterator::next;
iterator::next = iterator::node->NextFromTail();
}
return *this;
}
rvit operator-(int v) const throw() {
rvit t(*this);
t -= v;
return t;
}
// This one's for my sanity.
void operator--(int) throw() {
--*this;
}
};
};
/* template<class T> */
/* class ListAlloc : public List2<T> { */
/* public: */
/* ListAlloc<T>() {} */
/* ~ListAlloc<T>() { */
/* dispose(); */
/* } */
/* void dispose() { */
/* T *node; */
/* while(node = RemoveHead()) */
/* delete node; */
/* } */
/* }; */
#endif

View File

@ -641,69 +641,10 @@ AC_SUBST(WXWINDOWS_LIBS)
AC_SUBST(MMG_SUBDIRS)
AC_SUBST(USE_WXWINDOWS)
dnl
dnl Option to use the (old) avilib library instead of the AVI classes
dnl
AC_ARG_WITH(avilib,
[ --with-avilib=version Which avilib should be used (noclasses, 0.6.10)],
with_avilib_given=yes, with_avilib_given=no)
AC_MSG_CHECKING(which AVI libraries to use)
# Defaults: use aviclasses and prefer the new avilib.
if test x"`uname -s`" = x"Darwin"; then
have_aviclasses=no
else
have_aviclasses=yes
fi
if test "x$with_avilib_given" = "xyes"; then
set - `echo ${with_avilib} | sed 's/,/ /g'`
while test "x$1" != "x"; do
case "$1" in
noclasses)
have_aviclasses=no
;;
"0.6.10")
have_avilib0_6_10=yes
;;
*)
echo ""
echo "*** Unknown AVI library \"$1\" in \"${with_avilib}\". "
echo "*** Supported values are:"
echo "*** 0.6.10 - the new avilib with OpenDML support"
echo "*** noclasses - Do not use the AVI classes by Cyrius with "
echo "*** OpenDML support"
exit 1
;;
esac
shift
done
fi
if test "x$have_aviclasses" = "xyes"; then
AC_DEFINE(HAVE_AVICLASSES, 1,
[Define if the newer AVIclasses should be used.])
AVICLASSES_LIBS="-laviclasses"
avi_libs_to_use="classes "
USE_AVICLASSES=yes
fi
AC_DEFINE(HAVE_AVILIB0_6_10, 1,
[Define if the newer avilib from transcode 0.6.10 should be used.])
avi_libs_to_use="${avi_libs_to_use}0.6.10 "
have_avilib0_6_10=yes
USE_AVILIB0610=yes
AVILIB_LIBS="-lavi"
AC_MSG_RESULT($avi_libs_to_use)
AC_SUBST(AVILIB_LIBS)
AC_SUBST(AVICLASSES_LIBS)
AC_SUBST(USE_AVILIB0610)
AC_SUBST(USE_AVICLASSES)
CFLAGS="$USER_CPPFLAGS @EXTRA_CFLAGS@ $USER_CFLAGS -Wall -Wno-sign-compare -Wno-comment -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 @EXTRA_CFLAGS@ @DEBUG_CFLAGS@ @PROFILING_CFLAGS@ @MATROSKA_CFLAGS@ @EBML_CFLAGS@"
CXXFLAGS="$USER_CPPFLAGS @EXTRA_CFLAGS@ $USER_CXXFLAGS -Wall -Wno-sign-compare -Wno-comment -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 @EXTRA_CFLAGS@ @DEBUG_CFLAGS@ @PROFILING_CFLAGS@ @MATROSKA_CFLAGS@ @EBML_CFLAGS@ @WXWINDOWS_CFLAGS@"
LDFLAGS="$USER_LDFLAGS @EXTRA_LDFLAGS@"
AC_SUBST(LDFLAGS)
AC_OUTPUT(Makefile avilib-0.6.10/Makefile aviclasses/Makefile librmff/Makefile src/Makefile src/common/Makefile src/input/Makefile src/output/Makefile src/mmg/Makefile)
AC_OUTPUT(Makefile avilib-0.6.10/Makefile librmff/Makefile src/Makefile src/common/Makefile src/input/Makefile src/output/Makefile src/mmg/Makefile)

View File

@ -30,15 +30,9 @@
// This one goes out to haali ;)
#include <sys/types.h>
#ifdef HAVE_AVICLASSES
#include "common_mmreg.h"
#include "common_gdivfw.h"
#include "AVIReadHandler.h"
#else
extern "C" {
#include <avilib.h>
}
#endif
#include "mkvmerge.h"
#include "aac_common.h"
@ -90,10 +84,6 @@ avi_reader_c::avi_reader_c(track_info_c *nti)
long fsize, i;
int64_t size, bps;
vector<avi_demuxer_t>::iterator demuxer;
#ifdef HAVE_AVICLASSES
w32AVISTREAMINFO stream_info;
long format_size;
#endif
try {
io = new mm_io_c(ti->fname, MODE_READ);
@ -113,48 +103,6 @@ avi_reader_c::avi_reader_c(track_info_c *nti)
vptzr = -1;
vheaders_set = false;
#ifdef HAVE_AVICLASSES
bih = NULL;
avi = CreateAVIReadHandler(io);
if (avi == NULL)
throw error_c(PFX "Could not initialize the AVI handler.");
s_video = avi->GetStream(streamtypeVIDEO, 0);
if (s_video == NULL)
throw error_c(PFX "No video stream found in file.");
mxverb(2, "1: 0x%08x\n", (unsigned int)s_video);
if (s_video->Info(&stream_info, sizeof(stream_info)) != S_OK)
throw error_c(PFX "Could not get the video stream information.");
s_video->FormatSize(0, &format_size);
mxverb(2, "2: format_size %ld\n", format_size);
bih = (w32BITMAPINFOHEADER *)safemalloc(format_size);
if (s_video->ReadFormat(0, bih, &format_size) != S_OK)
throw error_c(PFX "Could not read the video format information.");
frames = s_video->Start();
maxframes = s_video->End();
mxverb(2, "3: maxframes %d\n", maxframes);
fps = (float)stream_info.dwRate / (float)stream_info.dwScale;
mxverb(2, "4: fps %.3f\n", fps);
max_frame_size = 0;
for (i = 0; i < maxframes; i++) {
if (s_video->Read(i, 1, NULL, 0, &fsize, NULL) != S_OK)
break;
if (fsize > max_frame_size)
max_frame_size = fsize;
}
mxverb(2, "5: max_frame_size %d\n", max_frame_size);
create_packetizers();
foreach(demuxer, ademuxers) {
bps = demuxer->samples_per_second * demuxer->channels *
demuxer->bits_per_sample / 8;
if (bps > max_frame_size)
max_frame_size = bps;
}
#else
frames = 0;
delete io;
if ((avi = AVI_open_input_file(ti->fname, 1)) == NULL) {
@ -181,7 +129,6 @@ avi_reader_c::avi_reader_c(track_info_c *nti)
if (bps > fsize)
fsize = bps;
}
#endif
if (video_fps < 0)
video_fps = fps;
@ -200,14 +147,8 @@ avi_reader_c::avi_reader_c(track_info_c *nti)
// {{{ D'TOR
avi_reader_c::~avi_reader_c() {
#ifdef HAVE_AVICLASSES
avi->Release();
delete io;
safefree(bih);
#else
if (avi != NULL)
AVI_close(avi);
#endif
safefree(chunk);
safefree(old_chunk);
@ -220,47 +161,6 @@ avi_reader_c::~avi_reader_c() {
void
avi_reader_c::create_packetizer(int64_t tid) {
#ifdef HAVE_AVICLASSES
char codec[4];
if ((tid == 0) && demuxing_requested('v', 0) && (vptzr == -1)) {
memcpy(codec, &bih->biCompression, 4);
codec[4] = 0;
if (!strcasecmp(codec, "DIV3") ||
!strcasecmp(codec, "AP41") || // Angel Potion
!strcasecmp(codec, "MPG3") ||
!strcasecmp(codec, "MP43"))
is_divx = RAVI_DIVX3;
else if (!strcasecmp(codec, "MP42") ||
!strcasecmp(codec, "DIV2") ||
!strcasecmp(codec, "DIVX") ||
!strcasecmp(codec, "XVID") ||
!strcasecmp(codec, "DX50"))
is_divx = RAVI_MPEG4;
else
is_divx = 0;
ti->private_data = (unsigned char *)bih;
if (ti->private_data != NULL)
ti->private_size = get_uint32(&bih->biSize);
ti->id = 0; // ID for the video track.
vptzr = add_packetizer(new video_packetizer_c(this, NULL, fps,
get_uint32(&bih->biWidth),
get_uint32(&bih->biHeight),
false, ti));
if (verbose)
mxinfo("+-> Using video output module for video track ID 0.\n");
mxverb(2, "6: width %u, height %u\n", get_uint32(&bih->biWidth),
get_uint32(&bih->biHeight));
}
if (tid == 0)
return;
if ((avi->GetStream(streamtypeAUDIO, tid - 1) != NULL) &&
demuxing_requested('a', tid))
add_audio_demuxer(tid - 1);
#else
char *codec;
if ((tid == 0) && demuxing_requested('v', 0) && (vptzr == -1)) {
@ -296,7 +196,6 @@ avi_reader_c::create_packetizer(int64_t tid) {
if ((tid <= AVI_audio_tracks(avi)) && demuxing_requested('a', tid))
add_audio_demuxer(tid - 1);
#endif
}
void
@ -308,18 +207,8 @@ avi_reader_c::create_packetizers() {
create_packetizer(0);
#ifdef HAVE_AVICLASSES
i = 0;
while (true) {
if (avi->GetStream(streamtypeAUDIO, i) == NULL)
break;
create_packetizer(i + 1);
i++;
}
#else
for (i = 0; i < AVI_audio_tracks(avi); i++)
create_packetizer(i + 1);
#endif
}
// {{{ FUNCTION avi_reader_c::add_audio_demuxer
@ -329,14 +218,7 @@ avi_reader_c::add_audio_demuxer(int aid) {
generic_packetizer_c *packetizer;
vector<avi_demuxer_t>::iterator it;
avi_demuxer_t demuxer;
#ifdef HAVE_AVICLASSES
w32AVISTREAMINFO stream_info;
long format_size;
w32WAVEFORMATEX *wfe;
IAVIReadStream *stream;
#else
alWAVEFORMATEX *wfe;
#endif
uint32_t audio_format;
foreach(it, ademuxers)
@ -348,39 +230,6 @@ avi_reader_c::add_audio_demuxer(int aid) {
demuxer.ptzr = -1;
ti->id = aid + 1; // ID for this audio track.
#ifdef HAVE_AVICLASSES
stream = avi->GetStream(streamtypeAUDIO, aid);
if (stream == NULL)
die(PFX "stream == NULL in add_audio_demuxer. Should not have happened. "
"Please file a bug report.\n");
demuxer.stream = stream;
if (stream->Info(&stream_info, sizeof(w32AVISTREAMINFO)) != S_OK)
mxerror(PFX "Could not read the stream information header for audio track "
"%d.\n", aid + 1);
stream->FormatSize(0, &format_size);
wfe = (w32WAVEFORMATEX *)safemalloc(format_size);
if (stream->ReadFormat(0, wfe, &format_size) != S_OK)
mxerror(PFX "Could not read the format information header for audio track "
"%d.\n", aid + 1);
audio_format = wfe->wFormatTag;
demuxer.samples_per_second = wfe->nSamplesPerSec;
demuxer.channels = wfe->nChannels;
demuxer.bits_per_sample = wfe->wBitsPerSample;
demuxer.frame = stream->Start();
demuxer.maxframes = stream->End();
ti->avi_block_align = wfe->nBlockAlign;
ti->avi_avg_bytes_per_sec = wfe->nAvgBytesPerSec;
mxverb(2, "7: sizeof(w32WAVE...) %d, sps %d, c %d, bps %d, mf %d\n",
sizeof(w32WAVEFORMATEX), demuxer.samples_per_second,
demuxer.channels, demuxer.bits_per_sample, demuxer.maxframes);
if (wfe->cbSize > 0) {
ti->private_data = (unsigned char *)(wfe + 1);
ti->private_size = wfe->cbSize;
} else {
ti->private_data = NULL;
ti->private_size = 0;
}
#else
wfe = avi->wave_format_ex[aid];
AVI_set_audio_track(avi, aid);
if (AVI_read_audio_chunk(avi, NULL) < 0) {
@ -403,7 +252,6 @@ avi_reader_c::add_audio_demuxer(int aid) {
ti->private_data = NULL;
ti->private_size = 0;
}
#endif
ti->avi_samples_per_sec = demuxer.samples_per_second;
switch(audio_format) {
@ -462,10 +310,6 @@ avi_reader_c::add_audio_demuxer(int aid) {
}
demuxer.ptzr = add_packetizer(packetizer);
#ifdef HAVE_AVICLASSES
safefree(wfe);
#endif
ademuxers.push_back(demuxer);
}
@ -515,16 +359,10 @@ avi_reader_c::is_keyframe(unsigned char *data,
int
avi_reader_c::read(generic_packetizer_c *ptzr) {
vector<avi_demuxer_t>::iterator demuxer;
int key, last_frame, frames_read;
int key, last_frame, frames_read, size;
long nread;
bool need_more_data, done;
int64_t duration;
#ifdef HAVE_AVICLASSES
long blread;
int result;
#else
int size;
#endif
key = 0;
if ((vptzr != -1) && !video_done && (PTZR(vptzr) == ptzr)) {
@ -536,17 +374,9 @@ avi_reader_c::read(generic_packetizer_c *ptzr) {
// Make sure we have a frame to work with.
if (old_chunk == NULL) {
#ifdef HAVE_AVICLASSES
debug_enter("aviclasses->Read() video");
key = s_video->IsKeyFrame(frames);
if (s_video->Read(frames, 1, chunk, 0x7FFFFFFF, &nread, &blread) != S_OK)
nread = -1;
debug_leave("aviclasses->Read() video");
#else
debug_enter("AVI_read_frame");
nread = AVI_read_frame(avi, (char *)chunk, &key);
debug_leave("AVI_read_frame");
#endif
if (nread < 0) {
frames = maxframes + 1;
done = true;
@ -563,18 +393,9 @@ avi_reader_c::read(generic_packetizer_c *ptzr) {
frames_read = 1;
// Check whether we have identical frames
while (!done && (frames <= (maxframes - 1))) {
#ifdef HAVE_AVICLASSES
debug_enter("aviclasses->Read() video");
key = s_video->IsKeyFrame(frames);
if (s_video->Read(frames, 1, chunk, 0x7FFFFFFF, &nread, &blread) !=
S_OK)
nread = -1;
debug_leave("aviclasses->Read() video");
#else
debug_enter("AVI_read_frame");
nread = AVI_read_frame(avi, (char *)chunk, &key);
debug_leave("AVI_read_frame");
#endif
if (nread < 0) {
memory_c mem(old_chunk, old_nread, true);
PTZR(vptzr)->process(mem, -1, -1,
@ -636,29 +457,14 @@ avi_reader_c::read(generic_packetizer_c *ptzr) {
}
foreach(demuxer, ademuxers) {
unsigned char *audio_chunk;
if (PTZR(demuxer->ptzr) != ptzr)
continue;
debug_enter("avi_reader_c::read (audio)");
need_more_data = false;
#ifdef HAVE_AVICLASSES
if (demuxer->frame < demuxer->maxframes) {
debug_enter("aviclasses->Read() audio");
result = demuxer->stream->Read(demuxer->frame, AVISTREAMREAD_CONVENIENT,
chunk, chunk_size, &nread, &blread);
debug_leave("aviclasses->Read() audio");
demuxer->frame += blread;
if (result == S_OK) {
memory_c mem(chunk, nread, false);
PTZR(demuxer->ptzr)->add_avi_block_size(nread);
PTZR(demuxer->ptzr)->process(mem);
need_more_data = demuxer->frame < demuxer->maxframes;
} else
demuxer->frame = demuxer->maxframes;
}
#else
unsigned char *audio_chunk;
AVI_set_audio_track(avi, demuxer->aid);
size = AVI_read_audio_chunk(avi, NULL);
@ -679,7 +485,6 @@ avi_reader_c::read(generic_packetizer_c *ptzr) {
} else
safefree(audio_chunk);
}
#endif
debug_leave("avi_reader_c::read (audio)");
@ -781,63 +586,8 @@ avi_reader_c::identify() {
const char *type;
uint32_t par_num, par_den;
bool extended_info_shown;
#ifdef HAVE_AVICLASSES
w32AVISTREAMINFO stream_info;
w32WAVEFORMATEX *wfe;
IAVIReadStream *stream;
long format_size;
char codec[5];
#endif
mxinfo("File '%s': container: AVI\n", ti->fname);
#ifdef HAVE_AVICLASSES
stream = avi->GetStream(streamtypeVIDEO, 0);
if (stream->Info(&stream_info, sizeof(stream_info)) != S_OK)
mxerror(PFX "Could not get the video stream information.");
stream->FormatSize(0, &format_size);
mxverb(2, "2: format_size %ld\n", format_size);
bih = (w32BITMAPINFOHEADER *)safemalloc(format_size);
if (stream->ReadFormat(0, bih, &format_size) != S_OK)
mxerror(PFX "Could not read the video format information.");
memcpy(codec, &bih->biCompression, 4);
safefree(bih);
codec[4] = 0;
mxinfo("Track ID 0: video (%s)\n", codec);
i = 0;
while (true) {
stream = avi->GetStream(streamtypeAUDIO, i);
if (stream == NULL)
break;
if (stream->Info(&stream_info, sizeof(w32AVISTREAMINFO)) != S_OK)
mxerror(PFX "Could not read the stream information header for audio "
"track %d.\n", i + 1);
stream->FormatSize(0, &format_size);
wfe = (w32WAVEFORMATEX *)safemalloc(format_size);
if (stream->ReadFormat(0, wfe, &format_size) != S_OK)
mxerror(PFX "Could not read the format information header for audio "
"track %d.\n", i + 1);
switch (wfe->wFormatTag) {
case 0x0001:
type = "PCM";
break;
case 0x0055:
type = "MP3";
break;
case 0x2000:
type = "AC3";
break;
case 0x00ff:
type = "AAC";
break;
default:
type = "unknown";
}
mxinfo("Track ID %d: audio (%s)\n", i + 1, type);
safefree(wfe);
i++;
}
#else
extended_info_shown = false;
type = AVI_video_compressor(avi);
if (!strncasecmp(type, "MP42", 4) ||
@ -898,7 +648,6 @@ avi_reader_c::identify() {
}
mxinfo("Track ID %d: audio (%s)\n", i + 1, type);
}
#endif
}
// }}}

View File

@ -27,13 +27,9 @@
#include <vector>
#ifdef HAVE_AVICLASSES
#include <AVIReadHandler.h>
#else
extern "C" {
#include <avilib.h>
}
#endif
#include "mm_io.h"
#include "pr_generic.h"
@ -49,21 +45,12 @@ typedef struct avi_demuxer_t {
bool headers_set;
int channels, bits_per_sample, samples_per_second, aid;
int64_t bytes_processed;
#ifdef HAVE_AVICLASSES
IAVIReadStream *stream;
int frame, maxframes;
#endif
} avi_demuxer_t;
class avi_reader_c: public generic_reader_c {
private:
unsigned char *chunk, *old_chunk;
#ifdef HAVE_AVICLASSES
IAVIReadHandler *avi;
IAVIReadStream *s_video;
#else
avi_t *avi;
#endif
mm_io_c *io;
int vptzr;
bool vheaders_set;
@ -71,9 +58,6 @@ private:
double fps;
int frames, max_frame_size, act_wchar, old_key, old_nread, dropped_frames;
int video_done, maxframes, is_divx, rederive_keyframes, chunk_size;
#ifdef HAVE_AVICLASSES
w32BITMAPINFOHEADER *bih;
#endif
public:
avi_reader_c(track_info_c *nti) throw (error_c);