Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
140
Src/libvp6/include/AC3.hpp
Normal file
140
Src/libvp6/include/AC3.hpp
Normal file
|
@ -0,0 +1,140 @@
|
|||
#ifndef AC3_HPP
|
||||
#define AC3_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// AC3.hpp
|
||||
//
|
||||
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
#include <cstdio>
|
||||
extern "C"
|
||||
{
|
||||
#include "ac3.h"
|
||||
#include "bitstream.h"
|
||||
}
|
||||
|
||||
namespace AC3
|
||||
{
|
||||
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
|
||||
typedef __int64 offset_t;
|
||||
|
||||
//--------------------------------------
|
||||
enum
|
||||
{
|
||||
SamplesPerBlock = 256 * 6
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
class FileError : public std::exception
|
||||
{
|
||||
public:
|
||||
FileError(DWORD messageId);
|
||||
FileError(const char* message);
|
||||
const char* what() const;
|
||||
private:
|
||||
std::string m_strMessage;
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
struct Header
|
||||
{
|
||||
unsigned long m_nBlocks;
|
||||
unsigned long m_ulSamplesPerSecond;
|
||||
unsigned long m_ulSamplesPerBlock;
|
||||
unsigned long m_ulBytesPerBlock; // blockAlign
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Header& h);
|
||||
|
||||
//--------------------------------------
|
||||
struct SyncFrame
|
||||
{
|
||||
syncinfo_t m_si;
|
||||
bsi_t m_bsi;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const SyncFrame& sf);
|
||||
|
||||
//--------------------------------------
|
||||
class File
|
||||
{
|
||||
public:
|
||||
|
||||
enum mode_t {in, out, inout};
|
||||
|
||||
typedef std::vector<SyncFrame> VectorSyncFrame;
|
||||
|
||||
File();
|
||||
File(const char* szName, mode_t mode);
|
||||
|
||||
~File();
|
||||
|
||||
void open(const char* szName, mode_t mode);
|
||||
void close();
|
||||
|
||||
bool isOpen() const;
|
||||
bool eof() const;
|
||||
|
||||
const char* name() const;
|
||||
mode_t mode() const;
|
||||
|
||||
unsigned long blockCount() const;
|
||||
unsigned long samplesPerSecond() const;
|
||||
unsigned long samplesPerBlock() const;
|
||||
|
||||
int samplesPerSec() const;
|
||||
|
||||
const Header& header() const;
|
||||
|
||||
// const SyncFrame& syncFrame(int nSyncFrame) const;
|
||||
// SyncFrame& syncFrame(int nSyncFrame);
|
||||
|
||||
private:
|
||||
|
||||
File(const File& rhs); // Not implemented
|
||||
File& operator=(const File& rhs); // Not implemented
|
||||
|
||||
int readHeader();
|
||||
|
||||
void readSyncFrame(SyncFrame& sf);
|
||||
|
||||
void writeSyncFrame(const SyncFrame& sf);
|
||||
|
||||
void read(void* buffer, size_t size) const;
|
||||
void write(const void* data, size_t size);
|
||||
|
||||
offset_t size() const;
|
||||
void seekCurrent(__int64) const;
|
||||
void seek(offset_t) const;
|
||||
offset_t tell() const;
|
||||
|
||||
|
||||
FILE* m_pFile;
|
||||
int m_hFile;
|
||||
bitstream_t* m_pbs;
|
||||
|
||||
std::string m_strName;
|
||||
mode_t m_mode;
|
||||
|
||||
Header m_header;
|
||||
VectorSyncFrame m_vSyncFrame;
|
||||
|
||||
__int64 m_fileSize;
|
||||
__int64 m_fileOffset;
|
||||
};
|
||||
|
||||
} // namespace AC3
|
||||
|
||||
#endif // AC3_HPP
|
31
Src/libvp6/include/ACM.hpp
Normal file
31
Src/libvp6/include/ACM.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef ACM_HPP
|
||||
#define ACM_HPP
|
||||
|
||||
#include <windows.h>
|
||||
#include <vfw.h>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace ACM
|
||||
{
|
||||
const std::string versionAsStr(DWORD version);
|
||||
const std::string supportAsStr(DWORD support);
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const ACMDRIVERDETAILS&);
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const WAVEFORMATEX&);
|
||||
|
||||
const std::string mmresultAsStr(MMRESULT);
|
||||
|
||||
std::ostream& operator<<(
|
||||
std::ostream&,
|
||||
const ACMFORMATTAGDETAILS&);
|
||||
|
||||
std::ostream& operator<<(
|
||||
std::ostream&,
|
||||
const ACMFORMATDETAILS&);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
29
Src/libvp6/include/AVC.hpp
Normal file
29
Src/libvp6/include/AVC.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef AVC_HPP
|
||||
#define AVC_HPP
|
||||
|
||||
namespace AVC
|
||||
{
|
||||
struct Extra
|
||||
{
|
||||
unsigned __int16 samplesPerBlock;
|
||||
unsigned __int16 blocksPerChunk;
|
||||
unsigned __int32 version;
|
||||
unsigned __int32 datarate;
|
||||
unsigned __int32 flags;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kFormatTag_SingleBlockPerChunk = 0x0500,
|
||||
kFormatTag_MultipleBlocksPerChunk = 0x0501
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kArchaicFlag = 1,
|
||||
kFancyFlag = 2,
|
||||
kLooseFlag = 4
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
984
Src/libvp6/include/AVI.hpp
Normal file
984
Src/libvp6/include/AVI.hpp
Normal file
|
@ -0,0 +1,984 @@
|
|||
//=====================================================================
|
||||
//
|
||||
// Copyright (c) 1999-2003 On2 Technologies Inc. All Rights Reserved.
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// File: $Workfile: AVI.hpp$
|
||||
//
|
||||
// Date: $Date: 2010/07/23 19:10:47 $
|
||||
//
|
||||
// Revision: $Revision: 1.1 $
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
#ifndef AVI_HPP
|
||||
#define AVI_HPP
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
|
||||
#include "FourCC.hpp"
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
#include <list>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
namespace AVI
|
||||
{
|
||||
#if defined WIN32
|
||||
typedef unsigned __int64 size_type;
|
||||
typedef DWORD dword;
|
||||
typedef __int64 offset_t;
|
||||
typedef unsigned __int32 length_t;
|
||||
#elif defined LINUX
|
||||
typedef unsigned long long size_type;
|
||||
typedef unsigned long dword;
|
||||
typedef long long offset_t;
|
||||
typedef unsigned int length_t;
|
||||
#endif
|
||||
|
||||
int asStreamId(const FourCC&);
|
||||
|
||||
enum ChunkType
|
||||
{
|
||||
waveform,
|
||||
waveform_encrypted,
|
||||
DIB_compressed,
|
||||
DIB_uncompressed,
|
||||
DIB_encrypted,
|
||||
kChunkTypeUnknown
|
||||
};
|
||||
|
||||
ChunkType asChunkType(const FourCC&);
|
||||
|
||||
const FourCC asChunkId(int stream, ChunkType type);
|
||||
const FourCC asIndexChunkExId(int stream);
|
||||
|
||||
size_type estimatedFileSize(
|
||||
int width,
|
||||
int height,
|
||||
int frameCount);
|
||||
|
||||
const std::string offtoa(offset_t);
|
||||
|
||||
class FileError : public std::exception
|
||||
{
|
||||
public:
|
||||
FileError(dword messageId);
|
||||
FileError(const char* message);
|
||||
~FileError() throw();
|
||||
const char* what() const throw();
|
||||
dword id() const;
|
||||
private:
|
||||
std::string message;
|
||||
dword m_id;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct MainHeader
|
||||
{
|
||||
enum Flag
|
||||
{
|
||||
hasIndex = 0x00000010,
|
||||
mustUseIndex = 0x00000020,
|
||||
isInterleaved = 0x00000100,
|
||||
indexIsAbsolute = 0x00000800, //? "trust cktype"
|
||||
wasCaptureFile = 0x00010000,
|
||||
copyrighted = 0x00020000
|
||||
};
|
||||
|
||||
dword microSecPerFrame;
|
||||
dword maxBytesPerSec;
|
||||
dword paddingGranularity;
|
||||
dword flags;
|
||||
dword totalFrames;
|
||||
dword initialFrames;
|
||||
dword streams;
|
||||
dword suggestedBufferSize;
|
||||
dword width;
|
||||
dword height;
|
||||
dword reserved[4];
|
||||
|
||||
const std::string flagsAsStr() const;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const MainHeader&);
|
||||
|
||||
|
||||
class Chunk
|
||||
{
|
||||
public:
|
||||
|
||||
Chunk(const FourCC, length_t, const unsigned char* data = 0);
|
||||
|
||||
const FourCC fcc() const;
|
||||
|
||||
length_t length() const;
|
||||
|
||||
const unsigned char* data() const;
|
||||
unsigned char* data();
|
||||
|
||||
void data(const unsigned char* d);
|
||||
|
||||
private:
|
||||
FourCC m_fcc;
|
||||
// length_t m_length;
|
||||
// unsigned char* m_data;
|
||||
|
||||
typedef std::vector<unsigned char> data_t;
|
||||
data_t m_data;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Chunk&);
|
||||
|
||||
typedef std::vector<Chunk> ExtraHeaderVector;
|
||||
|
||||
|
||||
|
||||
struct Rectangle
|
||||
{
|
||||
typedef unsigned short T;
|
||||
|
||||
T left;
|
||||
T top;
|
||||
T right;
|
||||
T bottom;
|
||||
|
||||
Rectangle()
|
||||
: left(0), top(0), right(0), bottom(0)
|
||||
{
|
||||
}
|
||||
|
||||
Rectangle(T l, T t, T r, T b)
|
||||
: left(l), top(t), right(r), bottom(b)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct StreamHeader
|
||||
{
|
||||
enum Flag
|
||||
{
|
||||
disabled = 0x00000001,
|
||||
formatChanges = 0x00010000
|
||||
};
|
||||
|
||||
FourCC fccType;
|
||||
FourCC fccHandler;
|
||||
dword flags;
|
||||
unsigned short priority;
|
||||
unsigned short language;
|
||||
dword initialFrames;
|
||||
dword scale;
|
||||
dword rate;
|
||||
dword start;
|
||||
dword length;
|
||||
dword suggestedBufferSize;
|
||||
long quality;
|
||||
dword sampleSize;
|
||||
Rectangle frame;
|
||||
|
||||
const std::string flagsAsStr() const;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const StreamHeader&);
|
||||
|
||||
|
||||
struct BitmapInfoHeader
|
||||
{
|
||||
dword size;
|
||||
long width;
|
||||
long height;
|
||||
unsigned short planes;
|
||||
unsigned short bitCount;
|
||||
FourCC compression;
|
||||
dword sizeImage;
|
||||
long xPelsPerMeter;
|
||||
long yPelsPerMeter;
|
||||
dword clrUsed;
|
||||
dword clrImportant;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const BitmapInfoHeader&);
|
||||
|
||||
|
||||
// namespace Compression
|
||||
// {
|
||||
// enum CompressionType
|
||||
// {
|
||||
// RGB,
|
||||
// RLE8,
|
||||
// RLE4,
|
||||
// bitfields,
|
||||
// unknown
|
||||
// };
|
||||
//
|
||||
// bool operator==(CompressionType, const FourCC&);
|
||||
// bool operator==(const FourCC&, CompressionType);
|
||||
//
|
||||
// CompressionType asCompression(const FourCC&);
|
||||
// const FourCC asFourCC(CompressionType);
|
||||
//
|
||||
// std::ostream& operator<<(std::ostream&, CompressionType);
|
||||
// }
|
||||
|
||||
|
||||
struct PCMWaveFormat
|
||||
{
|
||||
unsigned short formatTag;
|
||||
unsigned short nChannels;
|
||||
dword samplesPerSec;
|
||||
dword avgBytesPerSec;
|
||||
unsigned short blockAlign;
|
||||
unsigned short bitsPerSample;
|
||||
};
|
||||
|
||||
struct WaveFormatEx : public PCMWaveFormat
|
||||
{
|
||||
typedef std::vector<unsigned char> ByteArray;
|
||||
ByteArray extra;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const WaveFormatEx&);
|
||||
|
||||
|
||||
|
||||
|
||||
//not currently used; it's for palette changes,
|
||||
//which isn't implemented yet
|
||||
struct RGBQuad
|
||||
{
|
||||
unsigned char blue;
|
||||
unsigned char green;
|
||||
unsigned char red;
|
||||
unsigned char reserved;
|
||||
};
|
||||
|
||||
|
||||
struct IndexEntry
|
||||
{
|
||||
enum Flags
|
||||
{
|
||||
list = 0x00000001,
|
||||
keyframe = 0x00000010,
|
||||
notime = 0x00000100,
|
||||
compuse = 0x0FFF0000
|
||||
};
|
||||
|
||||
FourCC chunkId;
|
||||
dword flags;
|
||||
dword chunkOffset;
|
||||
dword chunkLength;
|
||||
|
||||
const std::string flagsAsStr() const;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const IndexEntry&);
|
||||
|
||||
typedef std::vector<IndexEntry> IEVector;
|
||||
|
||||
|
||||
struct FrameIndexEntry
|
||||
{
|
||||
union
|
||||
{
|
||||
offset_t offset;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned long offset_low;
|
||||
unsigned long offset_high;
|
||||
};
|
||||
};
|
||||
|
||||
size_t size;
|
||||
bool keyframe;
|
||||
};
|
||||
|
||||
typedef std::vector<FrameIndexEntry> FrameIEVector;
|
||||
typedef std::list<FrameIndexEntry> FrameIEList;
|
||||
|
||||
typedef std::deque<FrameIndexEntry> FrameIndex;
|
||||
|
||||
|
||||
struct IndexChunkEx
|
||||
{
|
||||
FourCC code;
|
||||
unsigned long length;
|
||||
unsigned short longsPerEntry;
|
||||
unsigned char subtype;
|
||||
unsigned char type;
|
||||
unsigned long entriesInUse;
|
||||
FourCC chunkId;
|
||||
unsigned long reserved[3];
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const IndexChunkEx&);
|
||||
|
||||
|
||||
struct StandardIndexChunk
|
||||
{
|
||||
FourCC code;
|
||||
unsigned long length;
|
||||
unsigned short longsPerEntry;
|
||||
unsigned char subtype;
|
||||
unsigned char type;
|
||||
unsigned long entriesInUse;
|
||||
FourCC chunkId;
|
||||
unsigned long baseOffset_low;
|
||||
unsigned long baseOffset_high;
|
||||
unsigned long reserved;
|
||||
|
||||
struct Entry
|
||||
{
|
||||
unsigned long offset;
|
||||
unsigned long size;
|
||||
} index[1];
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const StandardIndexChunk&);
|
||||
std::ostream& operator<<(std::ostream&, const StandardIndexChunk::Entry&);
|
||||
|
||||
|
||||
struct SuperIndexChunk
|
||||
{
|
||||
FourCC code;
|
||||
unsigned long length;
|
||||
unsigned short longsPerEntry;
|
||||
unsigned char subtype;
|
||||
unsigned char type;
|
||||
unsigned long entriesInUse;
|
||||
FourCC chunkId;
|
||||
unsigned long reserved[3];
|
||||
|
||||
struct Entry
|
||||
{
|
||||
offset_t offset;
|
||||
unsigned long size;
|
||||
unsigned long duration;
|
||||
} index[1];
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const SuperIndexChunk&);
|
||||
std::ostream& operator<<(std::ostream&, const SuperIndexChunk::Entry&);
|
||||
|
||||
|
||||
class File
|
||||
{
|
||||
public:
|
||||
|
||||
enum mode_t {in, out, inout};
|
||||
|
||||
enum OutputType
|
||||
{
|
||||
OT_AVI,
|
||||
OT_On2
|
||||
};
|
||||
|
||||
File();
|
||||
File(const char* name, mode_t mode);
|
||||
|
||||
~File();
|
||||
|
||||
void open(const char* name, mode_t mode, dword flags = 0);
|
||||
void outputType(OutputType ot);
|
||||
|
||||
void close();
|
||||
|
||||
bool isOpen() const;
|
||||
mode_t mode() const;
|
||||
const char* name() const;
|
||||
|
||||
void mapinit();
|
||||
void mapfinal();
|
||||
|
||||
unsigned long map(
|
||||
offset_t offset,
|
||||
length_t size,
|
||||
unsigned char*& base,
|
||||
length_t& baseSize,
|
||||
length_t& offsetInView) const;
|
||||
|
||||
void unmap(unsigned char* base, length_t size) const;
|
||||
|
||||
const MainHeader& mainHeader() const;
|
||||
MainHeader& mainHeader();
|
||||
|
||||
int extraHeaderCount() const;
|
||||
const Chunk& extraHeader(int nChunk) const;
|
||||
|
||||
void extraHeader(FourCC fcc, length_t length, unsigned char* data);
|
||||
void extraHeader(int nStream, FourCC fcc, length_t length, unsigned char* data);
|
||||
|
||||
dword totalFrames() const;
|
||||
dword& totalFrames();
|
||||
|
||||
int streamCount() const;
|
||||
|
||||
int makeStreamHeaderVideo(int superIndexEntryCount = 0);
|
||||
int makeStreamHeaderAudio(int superIndexEntryCount = 0);
|
||||
|
||||
const StreamHeader& streamHeader(int stream) const;
|
||||
StreamHeader& streamHeader(int stream);
|
||||
|
||||
const unsigned char* strf(int nStream) const;
|
||||
size_t strfSize(int nStream) const;
|
||||
|
||||
const BitmapInfoHeader& videoFormat(int stream) const;
|
||||
BitmapInfoHeader& videoFormat(int stream);
|
||||
|
||||
const WaveFormatEx& audioFormat(int stream) const;
|
||||
WaveFormatEx& audioFormat(int stream);
|
||||
|
||||
dword streamDataSize(int stream) const;
|
||||
const unsigned char* streamData(int stream) const;
|
||||
void setStreamData(int nStream, dword sds, const unsigned char* psd);
|
||||
|
||||
const char* streamName(int stream) const;
|
||||
void setStreamName(int nStream, const char* psn);
|
||||
|
||||
SuperIndexChunk& superIndexChunk(int stream);
|
||||
const SuperIndexChunk& superIndexChunk(int stream) const;
|
||||
|
||||
int superIndexEntryCount(int stream) const;
|
||||
|
||||
offset_t tell() const;
|
||||
|
||||
void seek(offset_t) const;
|
||||
|
||||
void seekCurrent(offset_t) const;
|
||||
|
||||
offset_t dataOffset() const;
|
||||
|
||||
offset_t idx1Offset() const;
|
||||
length_t idx1Size() const;
|
||||
|
||||
void rewriteHeaders();
|
||||
//For use by header updaters, throws if position of movi list
|
||||
//changes, positions at beginning of data.
|
||||
|
||||
void seekMainHeader();
|
||||
void writeMainHeader();
|
||||
|
||||
length_t seekStreamHeader(int stream);
|
||||
void writeStreamHeader(int stream);
|
||||
|
||||
void seekVideoFormat(int stream);
|
||||
void writeVideoFormat(int stream);
|
||||
|
||||
void seekAudioFormat(int stream);
|
||||
void writeAudioFormat(int stream);
|
||||
|
||||
void seekStreamData(int stream);
|
||||
void writeStreamData(int stream);
|
||||
|
||||
void seekSuperIndexChunk(int stream);
|
||||
void writeSuperIndexChunk(int stream);
|
||||
|
||||
int indexCount() const;
|
||||
void seekIndex() const;
|
||||
void read(IndexEntry&) const;
|
||||
|
||||
void load(int stream, IEVector& index) const;
|
||||
void load(int stream, FrameIndex& index) const;
|
||||
|
||||
void loadIndex(int, FrameIndex&) const;
|
||||
void loadIndexEx(int, FrameIndex&) const;
|
||||
|
||||
void writeIndexChunkHeader(int number_of_index_entries);
|
||||
|
||||
void write(const IndexEntry&) const;
|
||||
|
||||
void writeIndexChunk(const IEVector& index);
|
||||
|
||||
void writeIndexChunk(
|
||||
const FourCC& chunkId,
|
||||
const FrameIndex& index);
|
||||
|
||||
void writeStandardIndexChunk(
|
||||
int stream,
|
||||
const FrameIndex& index,
|
||||
offset_t baseOffset);
|
||||
|
||||
void writeStandardIndexChunk(
|
||||
int stream,
|
||||
const FrameIndex& index);
|
||||
|
||||
size_t makeSegment();
|
||||
int segmentCount() const;
|
||||
offset_t segmentOffset() const;
|
||||
|
||||
const FourCC readFourCC() const;
|
||||
void writeFourCC(const FourCC&);
|
||||
|
||||
const FourCC testFourCC() const;
|
||||
|
||||
length_t readLength() const;
|
||||
void writeLength(length_t length);
|
||||
|
||||
void read(void* buffer, size_t size) const;
|
||||
void write(const void* data, size_t size, bool adjust = true);
|
||||
|
||||
void writeJunkChunk(length_t);
|
||||
|
||||
int countIndexEntries(int stream) const;
|
||||
|
||||
bool indexIsRelative() const;
|
||||
|
||||
offset_t size() const;
|
||||
|
||||
private:
|
||||
|
||||
File(const File& rhs);
|
||||
File& operator=(const File& rhs);
|
||||
|
||||
//void readUnknownChunk() const;
|
||||
void readJunkChunk() const;
|
||||
|
||||
bool readInit();
|
||||
bool readHeaderList();
|
||||
void readMainHeader();
|
||||
void readExtraHeaders();
|
||||
void readStreamHeaderList();
|
||||
void readStreamHeader(StreamHeader& h);
|
||||
void readStreamVideoFormat(BitmapInfoHeader& f);
|
||||
struct StreamInfoVideo;
|
||||
void readStreamVideoFormat(StreamInfoVideo* psiv);
|
||||
void readStreamAudioFormat(WaveFormatEx& f);
|
||||
void readStreamName(std::string& name);
|
||||
|
||||
void readExtendedAVIHeader();
|
||||
void writeExtendedAVIHeader();
|
||||
|
||||
bool readDataList();
|
||||
void readDataRecChunk() const;
|
||||
void readDataChunk() const;
|
||||
|
||||
void readIndexList();
|
||||
|
||||
void writeInit();
|
||||
void writeFinal();
|
||||
|
||||
void writeHeader();
|
||||
void writeStreamHeaderList(int stream);
|
||||
void writeStreamHeader(const StreamHeader& h);
|
||||
|
||||
void writeStreamVideoFormatChunk(const BitmapInfoHeader& f);
|
||||
void writeStreamVideoFormat(const BitmapInfoHeader& f);
|
||||
|
||||
void writeStreamVideoFormatChunk(const unsigned char* pData, size_t sizeData);
|
||||
void writeStreamVideoFormat(const unsigned char* pData, size_t sizeData);
|
||||
|
||||
void writeStreamAudioFormatChunk(const WaveFormatEx&);
|
||||
void writeStreamAudioFormat(const WaveFormatEx&);
|
||||
|
||||
int headerLength() const;
|
||||
int streamHeaderLength(int stream) const;
|
||||
|
||||
void load(const SuperIndexChunk::Entry&, FrameIndex&) const;
|
||||
|
||||
class handle_t
|
||||
{
|
||||
public:
|
||||
|
||||
handle_t();
|
||||
|
||||
void open(const char*, mode_t, dword) throw (FileError);
|
||||
void close();
|
||||
|
||||
bool isOpen() const;
|
||||
offset_t size() const;
|
||||
|
||||
void read(void*, size_t) const;
|
||||
void write(const void*, size_t) const;
|
||||
|
||||
void truncate() const;
|
||||
|
||||
void seekCurrent(offset_t) const;
|
||||
void seek(offset_t) const;
|
||||
|
||||
offset_t tell() const;
|
||||
|
||||
void mapinit();
|
||||
void mapfinal();
|
||||
|
||||
unsigned long map(
|
||||
offset_t offset,
|
||||
length_t size,
|
||||
unsigned char*& view,
|
||||
length_t& viewSize,
|
||||
length_t& offsetWithinView) const;
|
||||
|
||||
void unmap(unsigned char*, length_t) const;
|
||||
|
||||
private:
|
||||
#if defined WIN32
|
||||
HANDLE m_hFile;
|
||||
HANDLE m_hFileMappingObject;
|
||||
#elif defined LINUX
|
||||
int m_fd;
|
||||
#endif
|
||||
};
|
||||
|
||||
handle_t m_handle;
|
||||
|
||||
mode_t m_mode;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
OutputType m_ot;
|
||||
|
||||
MainHeader m_mainHeader;
|
||||
|
||||
ExtraHeaderVector m_extraHeaderVector;
|
||||
|
||||
class indx_t
|
||||
{
|
||||
public:
|
||||
|
||||
indx_t();
|
||||
indx_t(int entryCount);
|
||||
|
||||
~indx_t();
|
||||
|
||||
int entryCount() const;
|
||||
|
||||
size_t size() const;
|
||||
|
||||
operator SuperIndexChunk&() const;
|
||||
|
||||
void read(File&);
|
||||
void write(File&) const;
|
||||
|
||||
private:
|
||||
|
||||
indx_t(const indx_t&);
|
||||
indx_t& operator=(const indx_t&);
|
||||
|
||||
dword* m_rep;
|
||||
|
||||
};
|
||||
|
||||
struct StreamInfo
|
||||
{
|
||||
virtual ~StreamInfo();
|
||||
|
||||
void write(File&) const;
|
||||
|
||||
int length() const;
|
||||
|
||||
StreamHeader header;
|
||||
|
||||
typedef std::vector<unsigned char> data_t;
|
||||
|
||||
data_t m_data;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
ExtraHeaderVector m_extraHeaderVector;
|
||||
|
||||
indx_t m_indx;
|
||||
|
||||
protected:
|
||||
|
||||
StreamInfo(int);
|
||||
StreamInfo(const StreamHeader&);
|
||||
|
||||
virtual int strf_length() const = 0;
|
||||
virtual void strf_write(File&) const = 0;
|
||||
|
||||
private:
|
||||
|
||||
StreamInfo(const StreamInfo&);
|
||||
StreamInfo& operator=(const StreamInfo&);
|
||||
|
||||
};
|
||||
|
||||
struct StreamInfoVideo : public StreamInfo
|
||||
{
|
||||
StreamInfoVideo(int entryCount);
|
||||
StreamInfoVideo(const StreamHeader&);
|
||||
|
||||
~StreamInfoVideo();
|
||||
|
||||
// BitmapInfoHeader m_strf;
|
||||
unsigned char* m_strf;
|
||||
size_t m_strfSize;
|
||||
protected:
|
||||
int strf_length() const;
|
||||
void strf_write(File&) const;
|
||||
};
|
||||
|
||||
struct StreamInfoAudio : public StreamInfo
|
||||
{
|
||||
StreamInfoAudio(int entryCount);
|
||||
StreamInfoAudio(const StreamHeader&);
|
||||
|
||||
WaveFormatEx m_strf;
|
||||
protected:
|
||||
int strf_length() const;
|
||||
void strf_write(File&) const;
|
||||
};
|
||||
|
||||
friend struct StreamInfo;
|
||||
friend struct StreamInfoVideo;
|
||||
friend struct StreamInfoAudio;
|
||||
|
||||
void readStreamData(StreamInfo::data_t&);
|
||||
|
||||
typedef std::vector<StreamInfo*> infoVector_t;
|
||||
infoVector_t infoVector;
|
||||
|
||||
dword m_totalFrames;
|
||||
|
||||
offset_t m_dataPosn;
|
||||
|
||||
offset_t m_indexPosn;
|
||||
int m_indexCount;
|
||||
length_t m_idx1Size;
|
||||
|
||||
struct SegmentInfo
|
||||
{
|
||||
offset_t offset;
|
||||
size_t size;
|
||||
|
||||
SegmentInfo() {}
|
||||
SegmentInfo(offset_t offset_) : offset(offset_) {}
|
||||
};
|
||||
|
||||
typedef std::vector<SegmentInfo> SegmentInfoVector;
|
||||
SegmentInfoVector m_segmentInfo;
|
||||
};
|
||||
|
||||
#if defined WIN32
|
||||
class MappedFile
|
||||
{
|
||||
public:
|
||||
|
||||
enum { invalid_offset = -1 };
|
||||
|
||||
MappedFile();
|
||||
MappedFile(const char* name);
|
||||
|
||||
~MappedFile();
|
||||
|
||||
void open(const char* name);
|
||||
void close();
|
||||
|
||||
bool isOpen() const;
|
||||
const char* name() const;
|
||||
|
||||
const MainHeader& mainHeader() const;
|
||||
|
||||
const StreamHeader& streamHeader(int stream) const;
|
||||
|
||||
const BitmapInfoHeader& videoFormat(int stream) const;
|
||||
|
||||
const WaveFormatEx& audioFormat(int stream) const;
|
||||
|
||||
const char* streamName(int stream) const;
|
||||
|
||||
dword totalFrames() const;
|
||||
|
||||
offset_t dataOffset() const;
|
||||
|
||||
offset_t indexOffset() const;
|
||||
size_t indexSize() const;
|
||||
|
||||
offset_t indexChunkExOffset(int stream) const;
|
||||
size_t indexChunkExSize(int stream) const;
|
||||
|
||||
const void* map(offset_t, size_t) const;
|
||||
void unmap(const void*) const;
|
||||
|
||||
void load(int stream, FrameIEVector& index) const;
|
||||
|
||||
private:
|
||||
|
||||
MappedFile(const MappedFile&);
|
||||
MappedFile& operator=(const MappedFile&);
|
||||
|
||||
void init();
|
||||
void unmapAllViews();
|
||||
|
||||
offset_t offset() const;
|
||||
void setFilePointerCurrent(LONG) const;
|
||||
|
||||
const FourCC readFourCC() const;
|
||||
const FourCC queryFourCC() const;
|
||||
|
||||
dword readLength() const;
|
||||
|
||||
void readHeaderList();
|
||||
void readDataList();
|
||||
void readIndexList();
|
||||
void readJunkChunk() const;
|
||||
void readUnknownChunk() const;
|
||||
void readMainHeaderChunk();
|
||||
void readStreamHeaderList(int stream);
|
||||
void readStreamHeaderChunk(StreamHeader&) const;
|
||||
void readStreamVideoFormatChunk(BitmapInfoHeader&) const;
|
||||
void readStreamAudioFormatChunk(WaveFormatEx&) const;
|
||||
void readStreamNameChunk(std::string&) const;
|
||||
void readIndexChunkEx(offset_t&, size_t&) const;
|
||||
void readExtendedAVIHeaderList() const;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
HANDLE m_file;
|
||||
HANDLE m_fileMappingObject;
|
||||
|
||||
DWORD m_allocationGranularity;
|
||||
|
||||
MainHeader m_mainHeader;
|
||||
|
||||
struct StreamInfo
|
||||
{
|
||||
StreamHeader streamHeader;
|
||||
|
||||
union
|
||||
{
|
||||
BitmapInfoHeader* videoFormat;
|
||||
WaveFormatEx* audioFormat;
|
||||
};
|
||||
|
||||
std::string name;
|
||||
|
||||
offset_t indexChunkExOffset;
|
||||
size_t indexChunkExSize;
|
||||
};
|
||||
|
||||
|
||||
typedef std::vector<StreamInfo> StreamInfoVector;
|
||||
StreamInfoVector m_streamInfoVector;
|
||||
|
||||
size_t readChunkSize(offset_t) const;
|
||||
int countEntries(int, const IndexEntry*, int) const;
|
||||
int countEntries(const SuperIndexChunk&) const;
|
||||
void loadIndex(int, FrameIEVector&) const;
|
||||
void loadIndexEx(int, FrameIEVector&) const;
|
||||
void load(const SuperIndexChunk::Entry&, FrameIEVector&) const;
|
||||
|
||||
mutable dword m_totalFrames;
|
||||
|
||||
offset_t m_dataOffset;
|
||||
|
||||
offset_t m_indexOffset;
|
||||
size_t m_indexSize;
|
||||
|
||||
struct ViewInfo
|
||||
{
|
||||
unsigned char* pView;
|
||||
unsigned char* pChunk;
|
||||
};
|
||||
|
||||
typedef std::list<ViewInfo> Views;
|
||||
mutable Views m_views;
|
||||
|
||||
Views::iterator findView(const void*) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//inline HANDLE AVI::File::handle() const
|
||||
//{
|
||||
// return m_handle;
|
||||
//}
|
||||
|
||||
inline AVI::Chunk::Chunk(
|
||||
const FourCC fcc,
|
||||
length_t length,
|
||||
const unsigned char* d)
|
||||
: m_fcc(fcc)
|
||||
{
|
||||
// if (m_length > 0)
|
||||
// {
|
||||
// m_data = new unsigned char[m_length];
|
||||
// if (m_data == 0)
|
||||
// {
|
||||
// throw FileError("Error allocating Chunk data.");
|
||||
// }
|
||||
// if (data != 0)
|
||||
// {
|
||||
// memcpy(m_data, data, m_length);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (length)
|
||||
{
|
||||
if (d)
|
||||
{
|
||||
//typedef data_t::const_iterator iter_t;
|
||||
|
||||
//const iter_t first = iter_t(d);
|
||||
|
||||
//const data_t::size_type n = length;
|
||||
|
||||
//const iter_t last = first + n;
|
||||
|
||||
m_data.assign(d, d + length);
|
||||
}
|
||||
else
|
||||
{
|
||||
const data_t::size_type n = length;
|
||||
|
||||
m_data.assign(n, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.assign(data_t::size_type(0), 0);
|
||||
}
|
||||
}
|
||||
|
||||
inline const FourCC AVI::Chunk::fcc() const
|
||||
{
|
||||
return m_fcc;
|
||||
}
|
||||
|
||||
inline AVI::length_t AVI::Chunk::length() const
|
||||
{
|
||||
const data_t::size_type n = m_data.size();
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
inline const unsigned char* AVI::Chunk::data() const
|
||||
{
|
||||
return &m_data[0];
|
||||
}
|
||||
|
||||
inline unsigned char* AVI::Chunk::data()
|
||||
{
|
||||
return &m_data[0];
|
||||
}
|
||||
|
||||
inline void AVI::Chunk::data(const unsigned char* d)
|
||||
{
|
||||
//typedef data_t::const_iterator iter_t;
|
||||
|
||||
//const iter_t first = iter_t(d);
|
||||
|
||||
//const data_t::size_type n = m_data.size();
|
||||
|
||||
//const iter_t last = first + n;
|
||||
|
||||
m_data.assign(d, d + m_data.size());
|
||||
}
|
||||
|
||||
inline AVI::dword AVI::FileError::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
79
Src/libvp6/include/Aud.hpp
Normal file
79
Src/libvp6/include/Aud.hpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
#ifndef AUD_HPP
|
||||
#define AUD_HPP
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <io.h>
|
||||
|
||||
namespace Aud
|
||||
{
|
||||
class FileError : public exception
|
||||
{
|
||||
public:
|
||||
explicit FileError(const char* message);
|
||||
const char* what() const;
|
||||
private:
|
||||
const std::string message;
|
||||
};
|
||||
|
||||
|
||||
enum { samplesPerSec = 48000 };
|
||||
|
||||
enum { sampleSizeInBits = 16, sampleSizeInBytes = 2 };
|
||||
|
||||
enum { numberOfChannels = 2 };
|
||||
|
||||
enum { blockAlign = numberOfChannels * sampleSizeInBytes };
|
||||
|
||||
|
||||
class File
|
||||
{
|
||||
public:
|
||||
|
||||
enum mode_t { in, out };
|
||||
|
||||
File();
|
||||
File(const char* name, mode_t mode);
|
||||
|
||||
~File();
|
||||
|
||||
void open(const char* name, mode_t mode);
|
||||
void close();
|
||||
|
||||
bool isOpen() const;
|
||||
bool eof() const;
|
||||
|
||||
mode_t mode() const;
|
||||
const char* name() const;
|
||||
|
||||
int sampleCount() const;
|
||||
|
||||
void seekSample(int sampleNum) const;
|
||||
|
||||
size_t read(void* buffer, size_t size) const;
|
||||
|
||||
void write(const void* buffer, size_t size);
|
||||
|
||||
typedef __int64 offset_t;
|
||||
offset_t offset() const;
|
||||
|
||||
void seekOffset(offset_t) const;
|
||||
|
||||
private:
|
||||
|
||||
File(const File&);
|
||||
File& operator=(const File&);
|
||||
|
||||
void init();
|
||||
|
||||
int handle_;
|
||||
|
||||
char name_[_MAX_PATH];
|
||||
mode_t mode_;
|
||||
|
||||
int m_sampleCount;
|
||||
};
|
||||
|
||||
} //end namespace Aud
|
||||
|
||||
#endif
|
57
Src/libvp6/include/CPUIdLib.h
Normal file
57
Src/libvp6/include/CPUIdLib.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Module Title : CPUIdLib.h
|
||||
*
|
||||
* Description : CPU specific definitions.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __INC_CPUIDLIB_H
|
||||
#define __INC_CPUIDLIB_H
|
||||
|
||||
/****************************************************************************
|
||||
* Typedefs
|
||||
****************************************************************************/
|
||||
typedef enum PROCTYPE
|
||||
{
|
||||
X86 = 0, /* 486, Pentium plain, or any other x86 compatible */
|
||||
PMMX = 1, /* Pentium with MMX */
|
||||
PPRO = 2, /* Pentium Pro */
|
||||
PII = 3, /* Pentium II */
|
||||
C6X86 = 4,
|
||||
C6X86MX = 5,
|
||||
AMDK63D = 6,
|
||||
AMDK6 = 7,
|
||||
AMDK5 = 8,
|
||||
MACG3 = 9,
|
||||
MAC68K = 10,
|
||||
XMM = 11, /* SIMD instructions */
|
||||
WMT = 12, /* Willamette Processor */
|
||||
SpecialProc = -1 /* Will NEVER be returned by CPUID, function dependent meaning */
|
||||
} PROCTYPE;
|
||||
|
||||
/****************************************************************************
|
||||
* Exports
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : findCPUId
|
||||
*
|
||||
* INPUTS : None
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : PROCTYPE: processor type.
|
||||
*
|
||||
* FUNCTION : Returns type of CPU in your system.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifdef __cplusplus /* this ifdef only works correctly for Microsoft visual C compilers */
|
||||
extern "C" PROCTYPE findCPUId ( void );
|
||||
#else
|
||||
extern PROCTYPE findCPUId ( void );
|
||||
#endif
|
||||
|
||||
#endif
|
85
Src/libvp6/include/DRMInfo.hpp
Normal file
85
Src/libvp6/include/DRMInfo.hpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
#if !defined(DRMINFO_HPP)
|
||||
#define DRMINFO_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// DRMInfo.hpp
|
||||
//
|
||||
|
||||
//______________________________________________________________________________
|
||||
// Include Files and Forward Declarations
|
||||
|
||||
#include <string>
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
#include "FourCC.hpp"
|
||||
|
||||
namespace on2vp
|
||||
{
|
||||
|
||||
//______________________________________________________________________________
|
||||
// Macro, Enumeration, and Constant Definitions
|
||||
|
||||
//______________________________________________________________________________
|
||||
// Type, Struct, and Class Definitions
|
||||
|
||||
//--------------------------------------
|
||||
class DRMInfo
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream& os, const DRMInfo& drmi);
|
||||
|
||||
public:
|
||||
class Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
Exception(const std::string& strText);
|
||||
~Exception() throw();
|
||||
const char* what() const throw();
|
||||
private:
|
||||
std::string m_strText;
|
||||
};
|
||||
DRMInfo();
|
||||
DRMInfo(const DRMInfo& drmi);
|
||||
~DRMInfo();
|
||||
|
||||
DRMInfo& operator=(const DRMInfo& drmi);
|
||||
|
||||
const FourCC scheme() const;
|
||||
long scope() const;
|
||||
long amount() const;
|
||||
const unsigned char* data() const;
|
||||
long dataSize() const;
|
||||
const unsigned char* drmx() const;
|
||||
long drmxSize() const;
|
||||
|
||||
void scheme(FourCC fccScheme);
|
||||
void scope(long lScope);
|
||||
void amount(long lAmount);
|
||||
void data(const unsigned char* pData, long lDataSize);
|
||||
|
||||
void init(FourCC fccScheme, long lScope, long lAmount, const unsigned char* pData, long lDataSize);
|
||||
void drmx(const unsigned char* pDRMX, long lDRMXSize);
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
DRMXHeaderSize = 16
|
||||
};
|
||||
|
||||
FourCC m_fccScheme;
|
||||
long m_lScope;
|
||||
long m_lAmount;
|
||||
unsigned char* m_pData;
|
||||
long m_lDataSize;
|
||||
mutable unsigned char* m_pDRMX;
|
||||
long m_lDRMXSize;
|
||||
};
|
||||
|
||||
//______________________________________________________________________________
|
||||
// Object and Function Declarations
|
||||
|
||||
//______________________________________________________________________________
|
||||
// Object and Function Definitions
|
||||
|
||||
} // namespace on2vp
|
||||
|
||||
#endif // DRMINFO_HPP
|
110
Src/libvp6/include/FourCC.hpp
Normal file
110
Src/libvp6/include/FourCC.hpp
Normal file
|
@ -0,0 +1,110 @@
|
|||
#ifndef FOURCC_HPP
|
||||
#define FOURCC_HPP
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
#if defined(__POWERPC__) || defined(__APPLE__) || defined(__MERKS__)
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
class FourCC
|
||||
{
|
||||
public:
|
||||
|
||||
FourCC();
|
||||
FourCC(const char*);
|
||||
explicit FourCC(unsigned long);
|
||||
|
||||
bool operator==(const FourCC&) const;
|
||||
bool operator!=(const FourCC&) const;
|
||||
|
||||
bool operator==(const char*) const;
|
||||
bool operator!=(const char*) const;
|
||||
|
||||
operator unsigned long() const;
|
||||
unsigned long asLong() const;
|
||||
|
||||
FourCC& operator=(unsigned long);
|
||||
|
||||
char operator[](int) const;
|
||||
|
||||
std::ostream& put(std::ostream&) const;
|
||||
|
||||
bool printable() const;
|
||||
|
||||
private:
|
||||
|
||||
union
|
||||
{
|
||||
char code[4];
|
||||
unsigned long codeAsLong;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline FourCC::FourCC()
|
||||
{
|
||||
}
|
||||
|
||||
inline FourCC::FourCC(unsigned long x)
|
||||
: codeAsLong(x)
|
||||
{
|
||||
}
|
||||
|
||||
inline FourCC::FourCC(const char* str)
|
||||
{
|
||||
memcpy(code, str, 4);
|
||||
}
|
||||
|
||||
|
||||
inline bool FourCC::operator==(const FourCC& rhs) const
|
||||
{
|
||||
return codeAsLong == rhs.codeAsLong;
|
||||
}
|
||||
|
||||
inline bool FourCC::operator!=(const FourCC& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
inline bool FourCC::operator==(const char* rhs) const
|
||||
{
|
||||
return (memcmp(code, rhs, 4) == 0);
|
||||
}
|
||||
|
||||
inline bool FourCC::operator!=(const char* rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
|
||||
inline FourCC::operator unsigned long() const
|
||||
{
|
||||
return codeAsLong;
|
||||
}
|
||||
|
||||
inline unsigned long FourCC::asLong() const
|
||||
{
|
||||
return codeAsLong;
|
||||
}
|
||||
|
||||
inline char FourCC::operator[](int i) const
|
||||
{
|
||||
return code[i];
|
||||
}
|
||||
|
||||
inline FourCC& FourCC::operator=(unsigned long val)
|
||||
{
|
||||
codeAsLong = val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const FourCC& rhs)
|
||||
{
|
||||
return rhs.put(os);
|
||||
}
|
||||
|
||||
#endif
|
43
Src/libvp6/include/IntTypes.cpp
Normal file
43
Src/libvp6/include/IntTypes.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include "IntTypes.hpp"
|
||||
#pragma warning(disable:4710)
|
||||
#pragma warning(push,3)
|
||||
#include <iostream>
|
||||
#pragma warning(pop)
|
||||
|
||||
using std::ostream;
|
||||
|
||||
|
||||
ostream& operator<<(ostream& os, IntTypes::int64_t i)
|
||||
{
|
||||
char buf[65];
|
||||
|
||||
_i64toa(i, buf, 10);
|
||||
|
||||
return os << buf;
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& os, IntTypes::uint64_t i)
|
||||
{
|
||||
char buf[65];
|
||||
|
||||
_ui64toa(i, buf, 10);
|
||||
|
||||
return os << buf;
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& os, IntTypes::uint32_t i)
|
||||
{
|
||||
return os << static_cast<unsigned int>(i);
|
||||
}
|
||||
|
||||
|
||||
ostream& operator<<(ostream& os, IntTypes::uint16_t i)
|
||||
{
|
||||
char buf[33];
|
||||
|
||||
_ultoa(i, buf, 10);
|
||||
|
||||
return os << buf;
|
||||
}
|
||||
|
||||
|
28
Src/libvp6/include/IntTypes.hpp
Normal file
28
Src/libvp6/include/IntTypes.hpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef INTTYPES_HPP
|
||||
#define INTTYPES_HPP
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
namespace IntTypes
|
||||
{
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream&, IntTypes::int64_t);
|
||||
std::ostream& operator<<(std::ostream&, IntTypes::uint64_t);
|
||||
std::ostream& operator<<(std::ostream&, IntTypes::uint32_t);
|
||||
std::ostream& operator<<(std::ostream&, IntTypes::uint16_t);
|
||||
|
||||
#endif
|
||||
|
109
Src/libvp6/include/MP3.hpp
Normal file
109
Src/libvp6/include/MP3.hpp
Normal file
|
@ -0,0 +1,109 @@
|
|||
#ifndef MP3_HPP
|
||||
#define MP3_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// MP3.hpp
|
||||
//
|
||||
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
|
||||
#include "mp3header.hpp"
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace MP3
|
||||
{
|
||||
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
|
||||
typedef __int64 offset_t;
|
||||
|
||||
//--------------------------------------
|
||||
class Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
Exception(DWORD dwMessage);
|
||||
Exception(const char* szMessage);
|
||||
const char* what() const;
|
||||
private:
|
||||
std::string m_strMessage;
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
struct Header
|
||||
{
|
||||
unsigned long m_ulChannels;
|
||||
unsigned long m_ulSamplesPerSecond;
|
||||
unsigned long m_ulSamplesPerBlock;
|
||||
unsigned long m_ulBytesPerBlock;
|
||||
unsigned long m_ulBlocks;
|
||||
|
||||
void clear();
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Header& h);
|
||||
|
||||
//--------------------------------------
|
||||
class File
|
||||
{
|
||||
public:
|
||||
|
||||
enum mode_t {in, out, inout};
|
||||
|
||||
File();
|
||||
File(const char* szName, mode_t mode);
|
||||
|
||||
~File();
|
||||
|
||||
void open(const char* szName, mode_t mode, DWORD dwFlags = 0);
|
||||
void close();
|
||||
|
||||
bool isOpen() const;
|
||||
bool eof() const;
|
||||
|
||||
const char* name() const;
|
||||
mode_t mode() const;
|
||||
|
||||
unsigned long channels() const;
|
||||
unsigned long samplesPerSecond() const;
|
||||
unsigned long samplesPerBlock() const;
|
||||
unsigned long bytesPerBlock() const;
|
||||
unsigned long blocks() const;
|
||||
|
||||
const Header& header() const;
|
||||
|
||||
void read(void* pBuffer, size_t size) const;
|
||||
void write(const void* pBuffer, size_t size);
|
||||
|
||||
void seek(offset_t) const;
|
||||
|
||||
private:
|
||||
|
||||
File(const File& f); // Not implemented
|
||||
File& operator=(const File& f); // Not implemented
|
||||
|
||||
int readHeader();
|
||||
|
||||
offset_t size() const;
|
||||
offset_t tell() const;
|
||||
|
||||
HANDLE m_handle;
|
||||
|
||||
std::string m_strName;
|
||||
mode_t m_mode;
|
||||
|
||||
Header m_header;
|
||||
|
||||
offset_t m_fileSize;
|
||||
offset_t m_fileOffset;
|
||||
};
|
||||
|
||||
} // namespace MP3
|
||||
|
||||
#endif // MP3_HPP
|
87
Src/libvp6/include/MediaInfo.hpp
Normal file
87
Src/libvp6/include/MediaInfo.hpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#if !defined(MEDIAINFO_HPP)
|
||||
#define MEDIAINFO_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// MediaInfo.hpp
|
||||
//
|
||||
|
||||
#include "FourCC.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace on2vp
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
class MediaInfo
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream& os, const MediaInfo& mi);
|
||||
|
||||
public:
|
||||
class Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
Exception(const std::string& strText);
|
||||
~Exception() throw();
|
||||
const char* what() const throw();
|
||||
private:
|
||||
std::string m_strText;
|
||||
};
|
||||
|
||||
MediaInfo();
|
||||
MediaInfo(const MediaInfo& mi);
|
||||
~MediaInfo();
|
||||
|
||||
MediaInfo& operator=(const MediaInfo& mi);
|
||||
|
||||
void parse(const std::string& strMediaInfo);
|
||||
|
||||
const unsigned char* data() const;
|
||||
unsigned long dataSize() const;
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
DataSizeMax = 16384
|
||||
};
|
||||
|
||||
void init_();
|
||||
void copy_(const MediaInfo& mi);
|
||||
void extract_(const std::string& strMediaInfo);
|
||||
void update_();
|
||||
unsigned long append_(FourCC fcc, const std::string& strData, char*& pData);
|
||||
|
||||
std::string m_strArchivalLocation;
|
||||
std::string m_strArtist;
|
||||
std::string m_strCommissioned;
|
||||
std::string m_strComments;
|
||||
std::string m_strCopyright;
|
||||
std::string m_strCreationDate;
|
||||
std::string m_strCropped;
|
||||
std::string m_strDimensions;
|
||||
std::string m_strDotsPerInch;
|
||||
std::string m_strEngineer;
|
||||
std::string m_strGenre;
|
||||
std::string m_strKeywords;
|
||||
std::string m_strLightness;
|
||||
std::string m_strMedium;
|
||||
std::string m_strName;
|
||||
std::string m_strPaletteSetting;
|
||||
std::string m_strProduct;
|
||||
std::string m_strSubject;
|
||||
std::string m_strSoftware;
|
||||
std::string m_strSharpness;
|
||||
std::string m_strSource;
|
||||
std::string m_strSourceForm;
|
||||
std::string m_strTechnician;
|
||||
|
||||
unsigned char* m_pData;
|
||||
unsigned long m_ulDataSize;
|
||||
};
|
||||
|
||||
} // namespace on2vp
|
||||
|
||||
#endif // MEDIAINFO_HPP
|
63
Src/libvp6/include/Mp3Header.hpp
Normal file
63
Src/libvp6/include/Mp3Header.hpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
#if !defined(MP3HEADER_HPP)
|
||||
#define MP3HEADER_HPP
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
class Mp3Header
|
||||
{
|
||||
public:
|
||||
Mp3Header(unsigned long);
|
||||
unsigned long id;
|
||||
unsigned long layer;
|
||||
unsigned long protectionBit;
|
||||
unsigned long bitRateIndex;
|
||||
unsigned long samplingFrequency;
|
||||
unsigned long paddingBit;
|
||||
unsigned long privateBit;
|
||||
unsigned long mode;
|
||||
unsigned long modeExtension;
|
||||
unsigned long copyright;
|
||||
unsigned long originalOrCopy;
|
||||
unsigned long emphasis;
|
||||
unsigned long nch;
|
||||
unsigned long sampleRate;
|
||||
unsigned long bitRate;
|
||||
unsigned long frameSize;
|
||||
unsigned short outFrameSize;
|
||||
|
||||
enum { BITRATE_FREE = 0 };
|
||||
enum { MPEG_FORBIDDEN = -1};
|
||||
enum { SAMPLING_FREQUENCY_RESERVED = -1};
|
||||
|
||||
enum IdTypes
|
||||
{
|
||||
MPEG1 = 1,
|
||||
MPEG2 = 2
|
||||
};
|
||||
|
||||
enum AudioMode
|
||||
{
|
||||
STEREO_MODE = 0,
|
||||
JOINT_STEREO_MODE = 1,
|
||||
DUAL_CHANNEL_MODE = 2,
|
||||
SINGLE_CHANNEL_MODE = 3
|
||||
};
|
||||
|
||||
/* layer code, very bad design */
|
||||
enum AudioLayer
|
||||
{
|
||||
AUDIO_LAYER_1 = 3,
|
||||
AUDIO_LAYER_2 = 2,
|
||||
AUDIO_LAYER_3 = 1,
|
||||
AUDIO_LAYER_RESERVED = 0
|
||||
};
|
||||
friend std::ostream& operator<<(std::ostream& os, const Mp3Header& mp3);
|
||||
|
||||
private:
|
||||
static const unsigned short samplingFrequencyTable[2][4];
|
||||
static const short m1BitRateTable[3][16];
|
||||
static const short m2BitRateTable[3][16];
|
||||
static const unsigned short outFrameSizes[2][4];
|
||||
|
||||
};
|
||||
#endif
|
381
Src/libvp6/include/NSV.hpp
Normal file
381
Src/libvp6/include/NSV.hpp
Normal file
|
@ -0,0 +1,381 @@
|
|||
#if !defined(NSV_HPP)
|
||||
#define NSV_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// NSV.hpp
|
||||
// NSV File I/O Classes
|
||||
|
||||
#include <FourCC.hpp>
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace NSV
|
||||
{
|
||||
|
||||
#if (defined(__POWERPC__) || defined(__APPLE__))
|
||||
typedef long long INT64;
|
||||
typedef long long POS_TYPE;
|
||||
typedef std::ios IOS_BASE;
|
||||
#elif (defined(__linux) || defined(linux))
|
||||
typedef long long INT64; // Assumes WIN32
|
||||
typedef std::ios::pos_type POS_TYPE;
|
||||
typedef std::ios_base IOS_BASE;
|
||||
#else
|
||||
typedef __int64 INT64; // Assumes WIN32
|
||||
typedef std::ios::pos_type POS_TYPE;
|
||||
typedef std::ios_base IOS_BASE;
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
FrameRates = 256
|
||||
};
|
||||
|
||||
double frameRate(int nFrameRate);
|
||||
int frameRate(unsigned int uiRateNum, unsigned int uiRateDenom);
|
||||
bool video(FourCC fccNSV);
|
||||
bool audio(FourCC fccNSV);
|
||||
FourCC videoFormat(FourCC fccCompression);
|
||||
FourCC audioFormat(unsigned short wFormatTag);
|
||||
FourCC videoCompression(FourCC fccNSV);
|
||||
int videoBitCount(FourCC fccNSV);
|
||||
unsigned short audioFormatTag(FourCC fccNSV);
|
||||
|
||||
//--------------------------------------
|
||||
class Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
Exception();
|
||||
Exception(const std::string& strException);
|
||||
Exception(const Exception& e);
|
||||
~Exception() throw();
|
||||
|
||||
Exception& operator=(const Exception& e);
|
||||
|
||||
const char* what() const throw();
|
||||
|
||||
private:
|
||||
std::string m_strException;
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
class IndexEntry
|
||||
{
|
||||
public:
|
||||
IndexEntry(POS_TYPE posOffset = 0, size_t sizeData = -1, bool bKeyFrame = false) :
|
||||
m_posOffset(posOffset),
|
||||
m_sizeData(sizeData),
|
||||
m_bKeyFrame(bKeyFrame)
|
||||
{
|
||||
}
|
||||
|
||||
//private:
|
||||
POS_TYPE m_posOffset;
|
||||
size_t m_sizeData;
|
||||
bool m_bKeyFrame;
|
||||
};
|
||||
|
||||
typedef std::vector<IndexEntry> Index;
|
||||
|
||||
//--------------------------------------
|
||||
class FileHeader
|
||||
{
|
||||
public:
|
||||
friend std::ostream& operator<<(std::ostream& os, const FileHeader& fh);
|
||||
|
||||
FileHeader() :
|
||||
m_fccSignature(0UL),
|
||||
m_sizeHeader(0),
|
||||
m_sizeFile(0),
|
||||
m_iFileSize_ms(0),
|
||||
m_sizeMetaData(0),
|
||||
m_nTOCAlloc(0),
|
||||
m_nTOCSize(0),
|
||||
m_strMetaData(),
|
||||
m_index()
|
||||
{
|
||||
}
|
||||
|
||||
//private:
|
||||
FourCC m_fccSignature;
|
||||
size_t m_sizeHeader;
|
||||
size_t m_sizeFile;
|
||||
int m_iFileSize_ms;
|
||||
size_t m_sizeMetaData;
|
||||
int m_nTOCAlloc;
|
||||
int m_nTOCSize;
|
||||
std::string m_strMetaData;
|
||||
std::vector<size_t> m_index;
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
class FrameHeader
|
||||
{
|
||||
public:
|
||||
friend std::ostream& operator<<(std::ostream& os, const FrameHeader& fh);
|
||||
|
||||
FrameHeader() :
|
||||
m_fccSignature(0UL),
|
||||
m_fccVideo(0UL),
|
||||
m_fccAudio(0UL),
|
||||
m_iWidth(0),
|
||||
m_iHeight(0),
|
||||
m_iFrameRate(0),
|
||||
m_iSyncOffset_ms(0),
|
||||
m_bKeyFrame(false)
|
||||
{
|
||||
}
|
||||
|
||||
//private:
|
||||
FourCC m_fccSignature;
|
||||
FourCC m_fccVideo;
|
||||
FourCC m_fccAudio;
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
int m_iFrameRate;
|
||||
int m_iSyncOffset_ms;
|
||||
bool m_bKeyFrame;
|
||||
};
|
||||
|
||||
class Stream;
|
||||
|
||||
//--------------------------------------
|
||||
class File
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream& os, const File& f);
|
||||
|
||||
public:
|
||||
File();
|
||||
~File();
|
||||
|
||||
// File header
|
||||
void header(const std::string& strMetaData, int nIndexEntries);
|
||||
void metaData(const std::string& strMetaData);
|
||||
const std::string& metaData() const;
|
||||
|
||||
void indexEntry(int nEntry, POS_TYPE posOffset, size_t sizeData = -1, bool bKeyFrame = false);
|
||||
void appendIndexEntry(POS_TYPE posOffset, size_t sizeData = -1, bool bKeyFrame = false);
|
||||
Index& index(); // Relative index
|
||||
int indexEntriesUsed() const;
|
||||
|
||||
// Synchronization frame header
|
||||
FourCC videoFormat() const;
|
||||
FourCC audioFormat() const;
|
||||
|
||||
void size(int iWidth, int iHeight);
|
||||
int width()const;
|
||||
int height() const;
|
||||
|
||||
void frameRate(unsigned char ucFrameRate);
|
||||
unsigned char frameRate() const;
|
||||
|
||||
void rate(unsigned int uiRateNum, unsigned int uiRateDenom);
|
||||
unsigned int rateNum() const;
|
||||
unsigned int rateDenom() const;
|
||||
|
||||
void syncOffset(int iSyncOffset_ms);
|
||||
int syncOffset() const;
|
||||
void finalizeSyncOffset();
|
||||
|
||||
void frames(INT64 nFrames);
|
||||
INT64 frames() const;
|
||||
|
||||
Stream& newStream(FourCC fccDataType, unsigned int uiRateNum = 0, unsigned int uiRateDenom = 0, INT64 nSamples = -1);
|
||||
int streams() const;
|
||||
int streamsAux() const;
|
||||
Stream& stream(int nStream);
|
||||
const Stream& stream(int nStream) const;
|
||||
|
||||
int streamVideo() const;
|
||||
int streamAudio() const;
|
||||
int streamAux(int nAux) const;
|
||||
|
||||
void dataOffset(POS_TYPE posDataOffset);
|
||||
POS_TYPE dataOffset();
|
||||
|
||||
private:
|
||||
File(const File& f); // Not implemented
|
||||
File& operator=(const File& f); // Not implemented
|
||||
|
||||
std::string m_strMetaData;
|
||||
Index m_index;
|
||||
int m_nIndexEntriesUsed;
|
||||
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
|
||||
unsigned int m_uiRateNum;
|
||||
unsigned int m_uiRateDenom;
|
||||
unsigned char m_ucFrameRate;
|
||||
|
||||
int m_iSyncOffset_ms;
|
||||
|
||||
std::vector<Stream> m_vStream;
|
||||
|
||||
POS_TYPE m_posDataOffset;
|
||||
|
||||
int m_nStreamVideo;
|
||||
int m_nStreamAudio;
|
||||
|
||||
INT64 m_nFrames;
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
class Stream
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream& os, const Stream& s);
|
||||
|
||||
public:
|
||||
Stream(File* pFile, int nStream, FourCC fccDataType, unsigned int uiRateNum, unsigned int uiRateDenom, INT64 nSamples);
|
||||
Stream(const Stream& s);
|
||||
~Stream();
|
||||
|
||||
Stream& operator=(const Stream& s);
|
||||
|
||||
void open();
|
||||
void close();
|
||||
|
||||
int stream() const;
|
||||
FourCC type() const; // Returns AVI types, vids, auds, ...
|
||||
FourCC dataType() const;
|
||||
|
||||
void samples(INT64 nSamples);
|
||||
INT64 samples() const;
|
||||
|
||||
void sample(INT64 nSample);
|
||||
INT64 sample() const;
|
||||
|
||||
void rate(unsigned int uiRateNum, unsigned int uiRateDenom);
|
||||
unsigned int rateNum() const;
|
||||
unsigned int rateDenom() const;
|
||||
|
||||
void dataSize(size_t sizeData);
|
||||
void data(const unsigned char* pData, size_t sizeData);
|
||||
unsigned char* data();
|
||||
size_t dataSize() const;
|
||||
|
||||
void keyFrame(bool bKeyFrame);
|
||||
bool keyFrame() const;
|
||||
|
||||
|
||||
private:
|
||||
File* m_pFile;
|
||||
int m_nStream;
|
||||
FourCC m_fccDataType;
|
||||
INT64 m_nSamples;
|
||||
INT64 m_nSample;
|
||||
|
||||
unsigned int m_uiRateNum;
|
||||
unsigned int m_uiRateDenom;
|
||||
|
||||
unsigned char* m_pBuffer;
|
||||
size_t m_sizeBuffer;
|
||||
size_t m_sizeData;
|
||||
|
||||
bool m_bKeyFrame;
|
||||
};
|
||||
|
||||
/*
|
||||
//--------------------------------------
|
||||
class Reader
|
||||
{
|
||||
public:
|
||||
Reader(File& f);
|
||||
Reader(File& f, const std::string& strFile);
|
||||
~Reader();
|
||||
|
||||
void open(const std::string& strFile);
|
||||
void open();
|
||||
void close();
|
||||
|
||||
File& file();
|
||||
const std::string& fileName() const;
|
||||
|
||||
void readFileHeader();
|
||||
void readFrame();
|
||||
void readFrameInfo();
|
||||
void readFrameHeader();
|
||||
void readPayload();
|
||||
void readPayloadInfo();
|
||||
void readPayloadHeader(int& nAux, int& iAuxPlusVideo, int& iAudio);
|
||||
|
||||
INT64 frames() const;
|
||||
INT64 frame() const;
|
||||
void seek(INT64 nFrame);
|
||||
void readSample(int nStream, unsigned char* pData, size_t sizeDataMax, size_t& sizeData, bool& bKeyFrame);
|
||||
bool eof();
|
||||
|
||||
const FileHeader& fileHeader() const;
|
||||
const FrameHeader& frameHeader() const;
|
||||
|
||||
private:
|
||||
Reader(const Reader& r); // Not implemented
|
||||
Reader& operator=(const Reader& r); // Not implemented
|
||||
|
||||
short read_i16();
|
||||
unsigned short read_ui16();
|
||||
int read_i32();
|
||||
unsigned int read_ui32();
|
||||
|
||||
File& m_file;
|
||||
std::string m_strFile;
|
||||
std::ifstream m_ifs;
|
||||
|
||||
FileHeader m_fileHeader;
|
||||
FrameHeader m_frameHeader;
|
||||
bool m_bFrameHeader;
|
||||
|
||||
INT64 m_nFrame;
|
||||
};
|
||||
*/
|
||||
|
||||
//--------------------------------------
|
||||
class Writer
|
||||
{
|
||||
public:
|
||||
Writer(File& f);
|
||||
Writer(File& f, const std::string& strFile);
|
||||
~Writer();
|
||||
|
||||
void open(const std::string& strFile);
|
||||
void open();
|
||||
void close();
|
||||
|
||||
File& file();
|
||||
const std::string& fileName() const;
|
||||
|
||||
INT64 frame() const;
|
||||
void seek(POS_TYPE posOffset);
|
||||
|
||||
void header(const std::string& strMetaData, int nIndexEntries);
|
||||
void sample(int nStream, const unsigned char* pData, size_t sizeData, bool bKeyframe);
|
||||
void writeFrame();
|
||||
|
||||
private:
|
||||
Writer(const Writer& w); // Not implemented
|
||||
Writer& operator=(const Writer& w); // Not implemented
|
||||
|
||||
void writeFileHeader();
|
||||
void writeFrameHeader(bool bKeyFrame);
|
||||
void writePayloadHeader();
|
||||
|
||||
void write_i16(short i16);
|
||||
void write_ui16(unsigned short ui16);
|
||||
void write_i32(int i32);
|
||||
void write_ui32(unsigned int ui32);
|
||||
|
||||
File& m_file;
|
||||
std::string m_strFile;
|
||||
std::ofstream m_ofs;
|
||||
|
||||
INT64 m_nFrame;
|
||||
bool m_bKeyFrame;
|
||||
};
|
||||
|
||||
} // namespace NSV
|
||||
|
||||
#endif // NSV_HPP
|
688
Src/libvp6/include/NSV_Reader.hpp
Normal file
688
Src/libvp6/include/NSV_Reader.hpp
Normal file
|
@ -0,0 +1,688 @@
|
|||
#if !defined(NSV_READER_HPP)
|
||||
#define NSV_READER_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// NSV_Reader.hpp
|
||||
// NSV Reader Class
|
||||
|
||||
#include "NSV.hpp"
|
||||
#include "endian.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
namespace NSV
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
// Defines the interface for the basic_Reader template instantiations
|
||||
class Reader_base
|
||||
{
|
||||
public:
|
||||
virtual ~Reader_base()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void open(const std::string& strFile) = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
virtual File& file() = 0;
|
||||
virtual const std::string& fileName() const = 0;
|
||||
|
||||
virtual void readFileHeader() = 0;
|
||||
virtual void readFrame() = 0;
|
||||
virtual void readFrameInfo() = 0;
|
||||
virtual void readFrameHeader() = 0;
|
||||
virtual void readPayload() = 0;
|
||||
virtual void readPayloadInfo() = 0;
|
||||
virtual void readPayloadHeader(int& nAux, int& iAuxPlusVideo, int& iAudio) = 0;
|
||||
|
||||
virtual void buildIndex(int nIndexEntries) = 0;
|
||||
|
||||
virtual INT64 frames() const = 0;
|
||||
virtual INT64 frame() const = 0;
|
||||
virtual void seek(INT64 nFrame) = 0;
|
||||
virtual void readSample(int nStream, unsigned char* pData, size_t sizeDataMax, size_t& sizeData, bool& bKeyFrame) = 0;
|
||||
virtual bool eof() = 0;
|
||||
|
||||
virtual const FileHeader& fileHeader() const = 0;
|
||||
virtual const FrameHeader& frameHeader() const = 0;
|
||||
|
||||
virtual void* get_ifs() = 0;
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
class basic_Reader : public Reader_base
|
||||
{
|
||||
public:
|
||||
basic_Reader(File& f);
|
||||
~basic_Reader();
|
||||
|
||||
void open(const std::string& strFile);
|
||||
void close();
|
||||
|
||||
File& file();
|
||||
const std::string& fileName() const;
|
||||
|
||||
void readFileHeader();
|
||||
void readFrame();
|
||||
void readFrameInfo();
|
||||
void readFrameHeader();
|
||||
void readPayload();
|
||||
void readPayloadInfo();
|
||||
void readPayloadHeader(int& nAux, int& iAuxPlusVideo, int& iAudio);
|
||||
|
||||
void buildIndex(int nIndexEntries = 0); // index all frames by default
|
||||
|
||||
INT64 frames() const;
|
||||
INT64 frame() const;
|
||||
void seek(INT64 nFrame);
|
||||
void readSample(int nStream, unsigned char* pData, size_t sizeDataMax, size_t& sizeData, bool& bKeyFrame);
|
||||
bool eof();
|
||||
|
||||
const FileHeader& fileHeader() const;
|
||||
const FrameHeader& frameHeader() const;
|
||||
|
||||
void* get_ifs();
|
||||
|
||||
private:
|
||||
basic_Reader(const basic_Reader& r); // Not implemented
|
||||
basic_Reader& operator=(const basic_Reader& r); // Not implemented
|
||||
|
||||
short read_i16();
|
||||
unsigned short read_ui16();
|
||||
int read_i32();
|
||||
unsigned int read_ui32();
|
||||
|
||||
File& m_file;
|
||||
std::string m_strFile;
|
||||
T m_ifs;
|
||||
|
||||
FileHeader m_fileHeader;
|
||||
FrameHeader m_frameHeader;
|
||||
bool m_bFrameHeader;
|
||||
|
||||
INT64 m_nFrame;
|
||||
};
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
basic_Reader<T>::basic_Reader(File& f) :
|
||||
m_file(f),
|
||||
m_strFile(),
|
||||
m_fileHeader(),
|
||||
m_frameHeader(),
|
||||
m_bFrameHeader(false),
|
||||
m_nFrame(0)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
basic_Reader<T>::~basic_Reader()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::open(const std::string& strFile)
|
||||
{
|
||||
m_strFile = strFile;
|
||||
|
||||
m_ifs.open(m_strFile.c_str(), IOS_BASE::binary);
|
||||
if (!m_ifs)
|
||||
{
|
||||
std::ostringstream ossError;
|
||||
ossError << "Error opening file " << m_strFile;
|
||||
throw Exception(ossError.str());
|
||||
}
|
||||
|
||||
readFileHeader();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::close()
|
||||
{
|
||||
if (m_ifs)
|
||||
{
|
||||
m_ifs.close();
|
||||
}
|
||||
|
||||
m_strFile.erase();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
File& basic_Reader<T>::file()
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
const std::string& basic_Reader<T>::fileName() const
|
||||
{
|
||||
return m_strFile;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::readFileHeader()
|
||||
{
|
||||
assert(m_ifs);
|
||||
|
||||
// Read file header signature
|
||||
char cSignature[5];
|
||||
m_ifs.read(cSignature, 4);
|
||||
if (strncmp(cSignature, "NSVf", 4) == 0)
|
||||
{
|
||||
cSignature[4] = '\0';
|
||||
m_fileHeader.m_fccSignature = cSignature;
|
||||
m_fileHeader.m_sizeHeader = read_i32();
|
||||
m_fileHeader.m_sizeFile = read_i32();
|
||||
m_fileHeader.m_iFileSize_ms = read_i32();
|
||||
m_fileHeader.m_sizeMetaData = read_i32();
|
||||
m_fileHeader.m_nTOCAlloc = read_i32();
|
||||
m_fileHeader.m_nTOCSize = read_i32();
|
||||
|
||||
if ((m_fileHeader.m_sizeFile > 0 && m_fileHeader.m_sizeFile < m_fileHeader.m_sizeHeader)
|
||||
|| m_fileHeader.m_nTOCSize > m_fileHeader.m_nTOCAlloc)
|
||||
{
|
||||
throw Exception("Invalid NSV file header");
|
||||
}
|
||||
|
||||
if (m_fileHeader.m_sizeMetaData > 0)
|
||||
{
|
||||
std::auto_ptr<char> apcMetaData(new char[m_fileHeader.m_sizeMetaData + 1]);
|
||||
char* pcMetaData = apcMetaData.get();
|
||||
if (pcMetaData == 0)
|
||||
{
|
||||
throw Exception("Out of memory");
|
||||
}
|
||||
|
||||
m_ifs.read(pcMetaData, m_fileHeader.m_sizeMetaData);
|
||||
pcMetaData[m_fileHeader.m_sizeMetaData] = '\0';
|
||||
|
||||
m_file.header(pcMetaData, m_fileHeader.m_nTOCSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_file.header("", m_fileHeader.m_nTOCSize);
|
||||
}
|
||||
|
||||
for (int nEntry = 0; nEntry < m_fileHeader.m_nTOCSize; ++nEntry)
|
||||
{
|
||||
POS_TYPE posOffset;
|
||||
posOffset = read_ui32();
|
||||
m_file.indexEntry(nEntry, posOffset);
|
||||
}
|
||||
|
||||
m_ifs.ignore((m_fileHeader.m_nTOCAlloc - m_fileHeader.m_nTOCSize) * 4);
|
||||
|
||||
if (m_ifs.tellg() > static_cast<POS_TYPE>(m_fileHeader.m_sizeHeader))
|
||||
{
|
||||
throw Exception("Invalid NSV file header");
|
||||
}
|
||||
|
||||
m_file.dataOffset(m_fileHeader.m_sizeHeader);
|
||||
m_ifs.seekg(m_file.dataOffset());
|
||||
}
|
||||
else // No file header present
|
||||
{
|
||||
m_fileHeader.m_sizeHeader = 0;
|
||||
m_ifs.seekg(0, IOS_BASE::end);
|
||||
m_fileHeader.m_sizeFile = m_ifs.tellg();
|
||||
|
||||
m_fileHeader.m_iFileSize_ms = 0;
|
||||
m_fileHeader.m_nTOCAlloc = 0;
|
||||
m_file.header("", 0);
|
||||
|
||||
m_file.dataOffset(0);
|
||||
m_ifs.seekg(m_file.dataOffset());
|
||||
}
|
||||
|
||||
// Read stream info from first frame header
|
||||
readFrameHeader();
|
||||
int nAux;
|
||||
int iAuxPlusVideo;
|
||||
int iAudio;
|
||||
readPayloadHeader(nAux, iAuxPlusVideo, iAudio);
|
||||
|
||||
m_file.size(m_frameHeader.m_iWidth, m_frameHeader.m_iHeight);
|
||||
m_file.frameRate(m_frameHeader.m_iFrameRate);
|
||||
|
||||
if (m_fileHeader.m_iFileSize_ms > 0)
|
||||
{
|
||||
INT64 nFramesDenom = static_cast<INT64>(m_file.rateDenom()) * 1000;
|
||||
INT64 nFrames = (static_cast<INT64>(m_fileHeader.m_iFileSize_ms) * static_cast<INT64>(m_file.rateNum()) + nFramesDenom / 2) / nFramesDenom;
|
||||
m_file.frames(nFrames);
|
||||
}
|
||||
|
||||
// Set up primary video and audio streams
|
||||
m_file.newStream(m_frameHeader.m_fccVideo);
|
||||
m_file.newStream(m_frameHeader.m_fccAudio);
|
||||
m_file.stream(0).rate(m_file.rateNum(), m_file.rateDenom());
|
||||
m_file.stream(0).samples(m_file.frames());
|
||||
|
||||
// Set up aux streams
|
||||
for (int n = 0; n < nAux; ++n)
|
||||
{
|
||||
unsigned short uh = read_ui16();
|
||||
unsigned long ul = read_ui32();
|
||||
m_ifs.ignore(uh);
|
||||
|
||||
m_file.newStream(FourCC(ul));
|
||||
// More info ...
|
||||
}
|
||||
|
||||
m_ifs.seekg(m_file.dataOffset());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::readFrame()
|
||||
{
|
||||
readFrameHeader();
|
||||
readPayload();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::readFrameInfo()
|
||||
{
|
||||
readFrameHeader();
|
||||
readPayloadInfo();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::readFrameHeader()
|
||||
{
|
||||
assert(m_ifs);
|
||||
|
||||
// Read frame header signature
|
||||
char cSignature[5];
|
||||
m_ifs.read(cSignature, 2);
|
||||
if (strncmp(cSignature, "\xef\xbe", 2) == 0)
|
||||
{
|
||||
m_frameHeader.m_fccSignature = 0UL;
|
||||
m_frameHeader.m_bKeyFrame = false;
|
||||
m_file.syncOffset(0);
|
||||
return;
|
||||
}
|
||||
|
||||
m_ifs.read(&cSignature[2], 2);
|
||||
if (strncmp(cSignature, "NSVs", 4) != 0)
|
||||
{
|
||||
throw Exception("Invalid NSV frame header");
|
||||
}
|
||||
|
||||
cSignature[4] = '\0';
|
||||
m_frameHeader.m_fccSignature = cSignature;
|
||||
m_ifs.read(reinterpret_cast<char*>(&m_frameHeader.m_fccVideo), 4);
|
||||
m_ifs.read(reinterpret_cast<char*>(&m_frameHeader.m_fccAudio), 4);
|
||||
m_frameHeader.m_iWidth = read_i16();
|
||||
m_frameHeader.m_iHeight = read_i16();
|
||||
unsigned char uc;
|
||||
m_ifs.read(reinterpret_cast<char*>(&uc), 1);
|
||||
m_frameHeader.m_iFrameRate = uc;
|
||||
m_frameHeader.m_iSyncOffset_ms = read_i16();
|
||||
m_frameHeader.m_bKeyFrame = true;
|
||||
|
||||
if (!m_bFrameHeader)
|
||||
{
|
||||
// m_file.newStream(m_frameHeader.m_fccVideo);
|
||||
// m_file.newStream(m_frameHeader.m_fccAudio);
|
||||
// m_file.size(m_frameHeader.m_iWidth, m_frameHeader.m_iHeight);
|
||||
// m_file.frameRate(m_frameHeader.m_iFrameRate);
|
||||
|
||||
m_bFrameHeader = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((m_file.streamVideo() >= 0 && m_file.videoFormat() != m_frameHeader.m_fccVideo)
|
||||
|| (m_file.streamAudio() >= 0 && m_file.audioFormat() != m_frameHeader.m_fccAudio)
|
||||
|| m_file.width() != m_frameHeader.m_iWidth
|
||||
|| m_file.height() != m_frameHeader.m_iHeight
|
||||
|| m_file.frameRate() != m_frameHeader.m_iFrameRate)
|
||||
{
|
||||
throw Exception("Invalid NSV frame header");
|
||||
}
|
||||
}
|
||||
|
||||
m_file.syncOffset(m_frameHeader.m_iSyncOffset_ms);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::readPayload()
|
||||
{
|
||||
assert(m_ifs);
|
||||
|
||||
int nAux;
|
||||
int iAuxPlusVideo;
|
||||
int iAudio;
|
||||
readPayloadHeader(nAux, iAuxPlusVideo, iAudio);
|
||||
|
||||
int iAux = 0;
|
||||
|
||||
for (int n = 0; n < nAux; ++n)
|
||||
{
|
||||
unsigned short uh = read_ui16();
|
||||
unsigned int ui = read_ui32();
|
||||
|
||||
Stream& s = m_file.stream(m_file.streamAux(n));
|
||||
s.dataSize(uh);
|
||||
m_ifs.read(reinterpret_cast<char*>(s.data()), uh);
|
||||
|
||||
iAux += uh;
|
||||
}
|
||||
|
||||
if (m_file.streamVideo() >= 0)
|
||||
{
|
||||
int iVideo = iAuxPlusVideo - iAux;
|
||||
Stream& sVideo = m_file.stream(m_file.streamVideo());
|
||||
sVideo.dataSize(iVideo);
|
||||
m_ifs.read(reinterpret_cast<char*>(sVideo.data()), iVideo);
|
||||
sVideo.keyFrame(m_frameHeader.m_bKeyFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ifs.seekg(iAuxPlusVideo - iAux, IOS_BASE::cur);
|
||||
}
|
||||
|
||||
if (m_file.streamAudio() >= 0)
|
||||
{
|
||||
Stream& sAudio = m_file.stream(m_file.streamAudio());
|
||||
sAudio.dataSize(iAudio);
|
||||
m_ifs.read(reinterpret_cast<char*>(sAudio.data()), iAudio);
|
||||
sAudio.keyFrame(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ifs.seekg(iAudio, IOS_BASE::cur);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::readPayloadInfo()
|
||||
{
|
||||
assert(m_ifs);
|
||||
|
||||
int nAux;
|
||||
int iAuxPlusVideo;
|
||||
int iAudio;
|
||||
readPayloadHeader(nAux, iAuxPlusVideo, iAudio);
|
||||
|
||||
int iAux = 0;
|
||||
|
||||
for (int n = 0; n < nAux; ++n)
|
||||
{
|
||||
unsigned short uh = read_ui16();
|
||||
unsigned int ui = read_ui32();
|
||||
m_ifs.ignore(uh);
|
||||
|
||||
Stream& s = m_file.stream(m_file.streamAux(n));
|
||||
s.dataSize(uh);
|
||||
|
||||
iAux += uh;
|
||||
}
|
||||
|
||||
if (m_file.streamVideo() >= 0)
|
||||
{
|
||||
int iVideo = iAuxPlusVideo - iAux;
|
||||
Stream& sVideo = m_file.stream(m_file.streamVideo());
|
||||
sVideo.dataSize(iVideo);
|
||||
sVideo.keyFrame(m_frameHeader.m_bKeyFrame);
|
||||
}
|
||||
|
||||
if (m_file.streamAudio() >= 0)
|
||||
{
|
||||
Stream& sAudio = m_file.stream(m_file.streamAudio());
|
||||
sAudio.dataSize(iAudio);
|
||||
sAudio.keyFrame(true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::readPayloadHeader(int& nAux, int& iAuxPlusVideo, int& iAudio)
|
||||
{
|
||||
assert(m_ifs);
|
||||
|
||||
char c;
|
||||
unsigned short uh;
|
||||
unsigned short uhAudio;
|
||||
|
||||
m_ifs.get(c);
|
||||
uh = read_ui16();
|
||||
uhAudio = read_ui16();
|
||||
|
||||
nAux = c & 0xf;
|
||||
iAuxPlusVideo = (static_cast<int>(uh) << 4) | ((c >> 4) & 0xf);
|
||||
iAudio = uhAudio;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::buildIndex(int nIndexEntries)
|
||||
{
|
||||
assert(nIndexEntries == 0); // Only creates full index for now ...
|
||||
|
||||
m_file.index().clear();
|
||||
m_file.frames(0);
|
||||
|
||||
m_ifs.seekg(m_file.dataOffset());
|
||||
|
||||
INT64 nFrames = 0;
|
||||
for (; !eof(); ++nFrames)
|
||||
{
|
||||
m_file.appendIndexEntry(static_cast<POS_TYPE>(m_ifs.tellg()) - m_file.dataOffset());
|
||||
|
||||
readFrameHeader();
|
||||
int nAux;
|
||||
int iAuxPlusVideo;
|
||||
int iAudio;
|
||||
readPayloadHeader(nAux, iAuxPlusVideo, iAudio);
|
||||
m_ifs.seekg(iAuxPlusVideo + iAudio, IOS_BASE::cur);
|
||||
}
|
||||
|
||||
m_file.frames(nFrames);
|
||||
|
||||
m_ifs.seekg(m_file.dataOffset());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
INT64 basic_Reader<T>::frames() const
|
||||
{
|
||||
return m_file.frames();
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
INT64 basic_Reader<T>::frame() const
|
||||
{
|
||||
return m_nFrame;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::seek(INT64 nFrame)
|
||||
{
|
||||
assert(m_ifs);
|
||||
INT64 nFrames = m_file.frames();
|
||||
assert(nFrame < nFrames || nFrames == -1);
|
||||
|
||||
int nIndexEntries = m_file.index().size();
|
||||
|
||||
if (nIndexEntries > 0)
|
||||
{
|
||||
int nIndexEntry = nIndexEntries * nFrame / nFrames;
|
||||
INT64 nFrameIndex = (nIndexEntry * nFrames + nIndexEntries / 2) / nIndexEntries;
|
||||
|
||||
m_ifs.seekg(m_file.dataOffset() + m_file.index()[nIndexEntry].m_posOffset);
|
||||
|
||||
for (; nFrameIndex < nFrame; ++nFrameIndex)
|
||||
{
|
||||
readFrameHeader();
|
||||
int nAux;
|
||||
int iAuxPlusVideo;
|
||||
int iAudio;
|
||||
readPayloadHeader(nAux, iAuxPlusVideo, iAudio);
|
||||
m_ifs.seekg(iAuxPlusVideo + iAudio, IOS_BASE::cur);
|
||||
}
|
||||
|
||||
m_nFrame = nFrame;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ifs.seekg(m_file.dataOffset());
|
||||
|
||||
for (m_nFrame = 0; m_nFrame < nFrame; ++m_nFrame)
|
||||
{
|
||||
readFrameHeader();
|
||||
int nAux;
|
||||
int iAuxPlusVideo;
|
||||
int iAudio;
|
||||
readPayloadHeader(nAux, iAuxPlusVideo, iAudio);
|
||||
m_ifs.seekg(iAuxPlusVideo + iAudio, IOS_BASE::cur);
|
||||
}
|
||||
|
||||
assert(m_nFrame == nFrame);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void basic_Reader<T>::readSample(int nStream, unsigned char* pData, size_t sizeDataMax, size_t& sizeData, bool& bKeyFrame)
|
||||
{
|
||||
assert(m_ifs);
|
||||
assert(pData != 0);
|
||||
|
||||
readFrame();
|
||||
|
||||
Stream& s = m_file.stream(nStream);
|
||||
|
||||
size_t size = s.dataSize();
|
||||
if (sizeDataMax < s.dataSize())
|
||||
{
|
||||
size = sizeDataMax;
|
||||
}
|
||||
|
||||
memcpy(pData, s.data(), size);
|
||||
sizeData = s.dataSize();
|
||||
|
||||
bKeyFrame = s.keyFrame();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
bool basic_Reader<T>::eof()
|
||||
{
|
||||
return m_ifs.tellg() >= m_fileHeader.m_sizeFile;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
const FileHeader& basic_Reader<T>::fileHeader() const
|
||||
{
|
||||
return m_fileHeader;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
const FrameHeader& basic_Reader<T>::frameHeader() const
|
||||
{
|
||||
return m_frameHeader;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
void* basic_Reader<T>::get_ifs()
|
||||
{
|
||||
return &m_ifs;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
short basic_Reader<T>::read_i16()
|
||||
{
|
||||
assert(m_ifs);
|
||||
|
||||
short i16;
|
||||
m_ifs.read(reinterpret_cast<char*>(&i16), 2);
|
||||
|
||||
return native_endian(i16, false);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
unsigned short basic_Reader<T>::read_ui16()
|
||||
{
|
||||
assert(m_ifs);
|
||||
|
||||
unsigned short ui16;
|
||||
m_ifs.read(reinterpret_cast<char*>(&ui16), 2);
|
||||
|
||||
return native_endian(ui16, false);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
int basic_Reader<T>::read_i32()
|
||||
{
|
||||
assert(m_ifs);
|
||||
|
||||
int i32;
|
||||
m_ifs.read(reinterpret_cast<char*>(&i32), 4);
|
||||
|
||||
return native_endian(i32, false);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
template<typename T>
|
||||
unsigned int basic_Reader<T>::read_ui32()
|
||||
{
|
||||
assert(m_ifs);
|
||||
|
||||
unsigned int ui32;
|
||||
m_ifs.read(reinterpret_cast<char*>(&ui32), 4);
|
||||
|
||||
return native_endian(ui32, false);
|
||||
}
|
||||
|
||||
} // namespace NSV
|
||||
|
||||
#endif // NSV_READER_HPP
|
132
Src/libvp6/include/On2Crypt.h
Normal file
132
Src/libvp6/include/On2Crypt.h
Normal file
|
@ -0,0 +1,132 @@
|
|||
//==========================================================================
|
||||
//
|
||||
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
||||
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
// PURPOSE.
|
||||
//
|
||||
// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
#if !defined(ON2CRYPT_H)
|
||||
#define ON2CRYPT_H
|
||||
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// On2Crypt.h
|
||||
// API to on2comp's encryption dll
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifdef _USRDLL
|
||||
#define DLLExport __declspec(dllexport)
|
||||
#else
|
||||
#define DLLExport
|
||||
#endif
|
||||
|
||||
#define DLLCC __stdcall
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef void* HOn2Encryptor;
|
||||
|
||||
DLLExport int DLLCC MakeEncryptor(unsigned char* pString, int iLength, HOn2Encryptor* phOn2Encryptor);
|
||||
//***************************************************************************************
|
||||
// Name : MakeEncryptor
|
||||
// Description: set up an encryption session
|
||||
// Inputs : pString -> information to be used by encryptor to set up encryption session
|
||||
// iLength -> number of bytes used in pString
|
||||
// Outputs : phOn2Encryptor -> pointer to an encryption session
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
DLLExport int DLLCC GetEncryptionCode(char* pfccCode); // size of szCode must be >= 4
|
||||
//***************************************************************************************
|
||||
// Name : GetEncryptionCode
|
||||
// Description: get the 4 character code to use as a reference for this encryption dll
|
||||
// Inputs :
|
||||
// Outputs : pfccCode 4 character code
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
|
||||
DLLExport int DLLCC GetDRMXLength(HOn2Encryptor hOn2Encryptor, int* piLength);
|
||||
//***************************************************************************************
|
||||
// Name : GetDRMXLength
|
||||
// Description: calculates the length of decryption chunk to be produced
|
||||
// Inputs : hOn2Encryptor -> handle of encryption sesion to use ( from make encryptor)
|
||||
// Outputs : piLength -> filled with length of extra information
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
DLLExport int DLLCC GenerateDRMX(HOn2Encryptor hOn2Encryptor, unsigned char* pBuffer);
|
||||
//***************************************************************************************
|
||||
// Name : GenerateDRMX
|
||||
// Description: generates a decryption chunk
|
||||
// Inputs : hOn2Encryptor -> handle of encryption sesion to use ( from make encryptor)
|
||||
// Outputs : pBuffer is filled with information necessary to decrypt the file we are
|
||||
// encrypting
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
DLLExport int DLLCC EncryptedSize(HOn2Encryptor hOn2Encryptor, int iSizeIn, int* piSizeOut);
|
||||
//***************************************************************************************
|
||||
// Name : EncryptedSize
|
||||
// Description: returns size that an encrypted chunk will be given a size in
|
||||
// Inputs : hOn2Encryptor -> handle of encryption sesion to use ( from make encryptor)
|
||||
// : iSizeIn -> size of input data
|
||||
// Outputs : piSizeOut -> size of output data
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
DLLExport int DLLCC EncryptBytes(HOn2Encryptor hOn2Encryptor, unsigned char* pBufferIn, int iSizeIn, unsigned char* pBufferOut, int iSizeOutMax, int* piSizeOut);
|
||||
//***************************************************************************************
|
||||
// Name : EncryptBytes
|
||||
// Description: encrypts bytes in input buffer and stores them to the output buffer
|
||||
// Inputs : hOn2Encryptor -> handle of encryption sesion to use ( from make encryptor)
|
||||
// : pBufferIn -> buffer holding bytes to encrypt
|
||||
// iSizeIn -> number of bytes to encrypt of that buffer
|
||||
// Outputs : pBufferOut -> buffer for holding encrypted bytes
|
||||
// iSizeOutMax -> maximum number of bytes to write to pBufferOut
|
||||
// piSizeOut -> number of bytes actually written to pbufferout
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
|
||||
DLLExport int DLLCC EncryptorError(char* szError, int nErrorMax);
|
||||
//***************************************************************************************
|
||||
// Name : EncryptorError
|
||||
// Description: gets a string description of the last error
|
||||
// Inputs : szError -> pointer to string
|
||||
// nErrorMax -> the largest number of bytes to fill in in szerror
|
||||
// Outputs :
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
|
||||
DLLExport int DLLCC DeleteEncryptor(HOn2Encryptor hOn2Encryptor);
|
||||
//***************************************************************************************
|
||||
// Name : DeleteEncryptor
|
||||
// Description: ends the encryption session and cleans up
|
||||
// Inputs : hOn2Encryptor -> handle of encryption sesion to use ( from make encryptor)
|
||||
// Outputs :
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
typedef int (DLLCC *PFNMakeEncryptor)(unsigned char* pString, int iLength, HOn2Encryptor* phOn2Encryptor);
|
||||
typedef int (DLLCC *PFNGetEncryptionCode)(char* pfccCode); // size of szCode must be >= 4
|
||||
typedef int (DLLCC *PFNGetDRMXLength)(HOn2Encryptor hOn2Encryptor, int* piLength);
|
||||
typedef int (DLLCC *PFNGenerateDRMX)(HOn2Encryptor hOn2Encryptor, unsigned char* pBuffer);
|
||||
typedef int (DLLCC *PFNEncryptedSize)(HOn2Encryptor hOn2Encryptor, int iSizeIn, int* piSizeOut);
|
||||
typedef int (DLLCC *PFNEncryptBytes)(HOn2Encryptor hOn2Encryptor, unsigned char* pBufferIn, int iSizeIn, unsigned char* pBufferOut, int iSizeOutMax, int* piSizeOut);
|
||||
typedef int (DLLCC *PFNEncryptorError)(char* szError, int nErrorMax);
|
||||
typedef int (DLLCC *PFNDeleteEncryptor)(HOn2Encryptor hOn2Encryptor);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // ON2CRYPT_H
|
75
Src/libvp6/include/On2Decrypt.h
Normal file
75
Src/libvp6/include/On2Decrypt.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
//==========================================================================
|
||||
//
|
||||
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
||||
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
// PURPOSE.
|
||||
//
|
||||
// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
#if !defined(ON2DECRYPT_H)
|
||||
#define ON2DECRYPT_H
|
||||
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// On2Decrypt.h
|
||||
// test api for testing the encryption code in on2crypt.h
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
#ifdef _USRDLL
|
||||
#define DLLExport __declspec(dllexport)
|
||||
#else
|
||||
#define DLLExport
|
||||
#endif
|
||||
|
||||
#define DLLCC __stdcall
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef void* HOn2Decryptor;
|
||||
|
||||
DLLExport int DLLCC MakeDecryptor(unsigned char* pDRMX, int iDRMXLength, HOn2Decryptor* phOn2Decryptor);
|
||||
//***************************************************************************************
|
||||
// Name : MakeDecryptor
|
||||
// Description: set up an decryption session
|
||||
// Inputs : pDRMX -> information to be used by decryptor to set up decryption session
|
||||
// iDRMXLength -> number of bytes used in pDRMX
|
||||
// Outputs : phOn2Decryptor -> pointer to an decryption session
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
DLLExport int DLLCC DecryptBytes(HOn2Decryptor hOn2Decryptor, unsigned char* pBufferIn, int iSizeIn, unsigned char* pBufferOut, int iSizeOutMax, int* piSizeOut);
|
||||
//***************************************************************************************
|
||||
// Name : DecryptBytes
|
||||
// Description: decrypts bytes in input buffer and stores them to the output buffer
|
||||
// Inputs : hOn2Decryptor -> handle of decryption sesion to use ( from make decryptor)
|
||||
// : pBufferIn -> buffer holding bytes to decrypt
|
||||
// iSizeIn -> number of bytes to decrypt of that buffer
|
||||
// Outputs : pBufferOut -> buffer for holding decrypted bytes
|
||||
// iSizeOutMax -> maximum number of bytes to write to pBufferOut
|
||||
// piSizeOut -> number of bytes actually written to pbufferout
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
DLLExport int DLLCC DeleteDecryptor(HOn2Decryptor hOn2Decryptor);
|
||||
//***************************************************************************************
|
||||
// Name : DeleteDecryptor
|
||||
// Description: ends the decryption session and cleans up
|
||||
// Inputs : hOn2Decryptor -> handle of decryption sesion to use ( from make decryptor)
|
||||
// Outputs :
|
||||
// Returns : 0 = success
|
||||
//***************************************************************************************
|
||||
|
||||
typedef int (DLLCC *PFNMakeDecryptor)(unsigned char* pDRMX, int iDRMXLength, HOn2Decryptor* phOn2Decryptor);
|
||||
typedef int (DLLCC *PFNDecryptBytes)(HOn2Decryptor hOn2Decryptor, unsigned char* pBufferIn, int iSizeIn, unsigned char* pBufferOut, int iSizeOutMax, int* piSizeOut);
|
||||
typedef int (DLLCC *PFNDeleteDecryptor)(HOn2Decryptor hOn2Decryptor);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // ON2DECRYPT_H
|
112
Src/libvp6/include/PlayerModel.hpp
Normal file
112
Src/libvp6/include/PlayerModel.hpp
Normal file
|
@ -0,0 +1,112 @@
|
|||
#if !defined(PLAYERMODEL_HPP)
|
||||
#define PLAYERMODEL_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// PlayerModel.hpp
|
||||
//
|
||||
|
||||
#include <string>
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace on2vp
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
class PlayerModel
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream& os, const PlayerModel& pm);
|
||||
|
||||
public:
|
||||
class Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
Exception(const std::string& strText);
|
||||
~Exception() throw();
|
||||
const char* what() const throw();
|
||||
private:
|
||||
std::string m_strText;
|
||||
};
|
||||
|
||||
// Any changes made to AspectRatio need to be reflected in XSAspectRatio defined in On2XS.h and On2XS.bas
|
||||
enum AspectRatio
|
||||
{
|
||||
AR_Null,
|
||||
AR_PC,
|
||||
AR_NTSC,
|
||||
AR_PAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Auto = -2,
|
||||
Null = -1
|
||||
};
|
||||
|
||||
PlayerModel(long lRateNum = 0, long lRateDenom = 0);
|
||||
PlayerModel(const PlayerModel& pm);
|
||||
~PlayerModel();
|
||||
|
||||
PlayerModel& operator=(const PlayerModel& pm);
|
||||
|
||||
long bitrate() const;
|
||||
long bufferMax() const;
|
||||
long prebufferMax() const;
|
||||
bool bufferPad() const;
|
||||
long bufferRequired() const;
|
||||
long prebufferRequired() const;
|
||||
long rebufferRequired() const;
|
||||
AspectRatio sourceAspectRatio() const;
|
||||
int frameWidth() const;
|
||||
int frameHeight() const;
|
||||
|
||||
void bitrate(long lBitrate);
|
||||
void bufferMax(long lBufferMax);
|
||||
void prebufferMax(long lPrebufferMax);
|
||||
void bufferPad(bool bBufferPad);
|
||||
void bufferRequired(long lBufferRequired);
|
||||
void prebufferRequired(long lPrebufferRequired);
|
||||
void rebufferRequired(long lRebufferRequired);
|
||||
void frameSize(AspectRatio arSource, int iFrameWidth, int iFrameHeight);
|
||||
|
||||
void rate(long lRateNum, long lRateDenom);
|
||||
void initialize(int iWidthOrig, int iHeightOrig);
|
||||
void finalize();
|
||||
|
||||
void updateBuffer(long lBytesOut, long nSamples, bool bKeyFrame);
|
||||
long bufferPadding(long lBytesOut, long nSamples);
|
||||
|
||||
private:
|
||||
|
||||
void initializeInternal();
|
||||
|
||||
void updateBuffer0(long lBytesOut, long nSamples, bool bKeyFrame);
|
||||
void updateBuffer1(long lBytesOut, long nSamples, bool bKeyFrame); // Given bitrate, calculate buffer and prebuffer required
|
||||
void updateBuffer2(long lBytesOut, long nSamples, bool bKeyFrame); // Given buffer and prebuffer size, calculate bitrate
|
||||
|
||||
long m_lBitrate;
|
||||
long m_lBufferMax;
|
||||
long m_lPrebufferMax;
|
||||
bool m_bBufferPad;
|
||||
long m_lBufferRequired;
|
||||
long m_lPrebufferRequired;
|
||||
long m_lRebufferRequired;
|
||||
AspectRatio m_arSource;
|
||||
int m_iFrameWidth;
|
||||
int m_iFrameHeight;
|
||||
|
||||
long m_lRateNum;
|
||||
long m_lRateDenom;
|
||||
double m_dBytesIn;
|
||||
double m_dBufferFilled; // Used to calculate buffer required and prebuffer required
|
||||
double m_dBufferFilled2; // Used to calculate rebuffer required
|
||||
bool m_bInitialized;
|
||||
bool m_bInitializedInternal;
|
||||
bool m_bFinalized;
|
||||
|
||||
void (PlayerModel::*m_updateBuffer)(long lBytesOut, long nSamples, bool bKeyFrame);
|
||||
};
|
||||
|
||||
} // namespace on2vp
|
||||
|
||||
#endif // PLAYERMODEL_HPP
|
198
Src/libvp6/include/Rvd.hpp
Normal file
198
Src/libvp6/include/Rvd.hpp
Normal file
|
@ -0,0 +1,198 @@
|
|||
#ifndef RVD_HPP
|
||||
#define RVD_HPP
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
|
||||
#include "FourCC.hpp"
|
||||
//#include <io.h>
|
||||
#include <windows.h>
|
||||
#include <exception>
|
||||
#include <cstdlib>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace Rvd
|
||||
{
|
||||
class FileError : public exception
|
||||
{
|
||||
public:
|
||||
explicit FileError(const char*);
|
||||
explicit FileError(DWORD);
|
||||
const char* what() const;
|
||||
private:
|
||||
std::string message;
|
||||
};
|
||||
|
||||
bool nameIsOK(const char* name);
|
||||
|
||||
enum Format { rgb24, rgb32, yuv12 };
|
||||
const char* asStr(Format f);
|
||||
|
||||
struct Header
|
||||
{
|
||||
FourCC code;
|
||||
__int32 width;
|
||||
__int32 height;
|
||||
__int32 blockSize;
|
||||
FourCC compression;
|
||||
__int32 unknown; //frame count?
|
||||
__int32 rate;
|
||||
__int32 scale;
|
||||
__int8 pad[480];
|
||||
};
|
||||
|
||||
typedef unsigned __int64 size_type;
|
||||
|
||||
size_type estimatedFileSize(
|
||||
int width,
|
||||
int height,
|
||||
Format format,
|
||||
int frameCount);
|
||||
|
||||
|
||||
class File
|
||||
{
|
||||
public:
|
||||
|
||||
enum mode_t {in, out, inout};
|
||||
|
||||
File();
|
||||
File(const char* name, mode_t mode);
|
||||
|
||||
~File();
|
||||
|
||||
void open(const char* name, mode_t mode, DWORD flags = 0);
|
||||
void close();
|
||||
|
||||
void setFormat(Format);
|
||||
|
||||
void setWidth(int w);
|
||||
void setHeight(int h);
|
||||
|
||||
void setRate(int rate);
|
||||
void setScale(int scale);
|
||||
|
||||
void reset(int frameNum) const;
|
||||
void advance(int count) const;
|
||||
|
||||
void read(void* frame) const;
|
||||
void write(const void* frame);
|
||||
|
||||
void writeHeader();
|
||||
|
||||
bool isOpen() const;
|
||||
bool eof() const;
|
||||
|
||||
mode_t mode() const;
|
||||
const char* name() const;
|
||||
|
||||
int frameNum() const;
|
||||
|
||||
int frameCount() const;
|
||||
bool frameCountIsOK() const;
|
||||
|
||||
Format format() const;
|
||||
const FourCC compression() const;
|
||||
|
||||
int width() const;
|
||||
int height() const;
|
||||
|
||||
int rate() const;
|
||||
int scale() const;
|
||||
|
||||
size_t frameSize() const;
|
||||
size_t paddedFrameSize() const;
|
||||
|
||||
private:
|
||||
|
||||
File& operator=(const File&);
|
||||
File(const File&);
|
||||
|
||||
//int file;
|
||||
HANDLE m_handle;
|
||||
|
||||
mutable int frameNum_;
|
||||
int frameCount_;
|
||||
bool frameCountIsOK_;
|
||||
char name_[_MAX_PATH];
|
||||
mode_t mode_;
|
||||
|
||||
Header* const m_header;
|
||||
Format format_;
|
||||
size_t frameSize_;
|
||||
size_t paddedFrameSize_;
|
||||
size_t paddingSize_;
|
||||
|
||||
bool unbuffered;
|
||||
};
|
||||
|
||||
|
||||
class MappedFile
|
||||
{
|
||||
public:
|
||||
|
||||
MappedFile();
|
||||
MappedFile(const char* name);
|
||||
|
||||
~MappedFile();
|
||||
|
||||
void open(const char* name);
|
||||
void close();
|
||||
|
||||
bool isOpen() const;
|
||||
const char* name() const;
|
||||
|
||||
int frameCount() const;
|
||||
|
||||
Format format() const;
|
||||
|
||||
int width() const;
|
||||
int height() const;
|
||||
|
||||
int rate() const;
|
||||
int scale() const;
|
||||
|
||||
size_t frameSize() const;
|
||||
|
||||
void* map(int frameNum) const;
|
||||
|
||||
void unmap(int frameNum) const;
|
||||
void unmap() const;
|
||||
|
||||
bool isMapped(int frameNum) const;
|
||||
|
||||
private:
|
||||
|
||||
MappedFile(const MappedFile&);
|
||||
MappedFile& operator=(const MappedFile&);
|
||||
|
||||
void init();
|
||||
|
||||
Header header;
|
||||
Format m_format;
|
||||
size_t m_frameSize;
|
||||
size_t m_paddedFrameSize;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
HANDLE file;
|
||||
HANDLE mapping;
|
||||
|
||||
DWORD allocationGranularity;
|
||||
|
||||
int m_frameCount;
|
||||
|
||||
struct ViewInfo
|
||||
{
|
||||
void* view;
|
||||
void* frame;
|
||||
};
|
||||
|
||||
typedef std::map<int, ViewInfo> Views;
|
||||
mutable Views views;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
65
Src/libvp6/include/VFWSetting.hpp
Normal file
65
Src/libvp6/include/VFWSetting.hpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
#if !defined(VFWSETTING_HPP)
|
||||
#define VFWSETTING_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// VFWSetting.hpp
|
||||
//
|
||||
|
||||
#include "FourCC.hpp"
|
||||
#include <iosfwd>
|
||||
|
||||
namespace on2vp
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
class VFWSetting
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream& os, const VFWSetting& vfws);
|
||||
|
||||
public:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
M_Setting,
|
||||
M_Config
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HeaderSize = 8,
|
||||
Size = 16
|
||||
};
|
||||
|
||||
VFWSetting(FourCC fcc);
|
||||
~VFWSetting();
|
||||
|
||||
FourCC fcc() const;
|
||||
Mode mode() const;
|
||||
|
||||
int setting() const;
|
||||
int value() const;
|
||||
void settingValue(int iSetting, int iValue); // Sets mode to M_Setting
|
||||
|
||||
long size() const;
|
||||
const void* data() const;
|
||||
int data(const void* pData, unsigned long ulSize);
|
||||
|
||||
private:
|
||||
|
||||
VFWSetting(const VFWSetting& vfws); // Not implemented
|
||||
VFWSetting& operator=(const VFWSetting& vfws); // Not implemented
|
||||
|
||||
int extract_(const void* pData, unsigned long ulSize);
|
||||
void update_() const;
|
||||
|
||||
FourCC m_fcc;
|
||||
Mode m_mode;
|
||||
int m_iSetting;
|
||||
int m_iValue;
|
||||
|
||||
mutable unsigned char m_pData[Size];
|
||||
};
|
||||
|
||||
} // namespace on2vp
|
||||
|
||||
#endif // VFWSETTING_HPP
|
143
Src/libvp6/include/VP6VFWState.hpp
Normal file
143
Src/libvp6/include/VP6VFWState.hpp
Normal file
|
@ -0,0 +1,143 @@
|
|||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 1999-2003 On2 Technologies Inc. All Rights Reserved.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// $Workfile: VP6VFWState.hpp$
|
||||
// $Date: 2010/07/23 19:10:48 $
|
||||
// $Revision: 1.1 $
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if !defined(VP6VFWSTATE_HPP)
|
||||
#define VP6VFWSTATE_HPP
|
||||
|
||||
#include "FourCC.hpp"
|
||||
#include <iosfwd>
|
||||
|
||||
namespace on2vp
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
class VP6VFWState
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream& os, const VP6VFWState& vfws);
|
||||
|
||||
public:
|
||||
|
||||
enum Mode
|
||||
{
|
||||
M_Setting,
|
||||
M_Config
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HeaderSize = 8
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ConfigUsed = 1724
|
||||
};
|
||||
|
||||
struct VPConfig
|
||||
{
|
||||
unsigned int Used;
|
||||
int Width;
|
||||
int Height;
|
||||
int TargetBitRate;
|
||||
int Quality;
|
||||
int RateNum;
|
||||
int RateDenom;
|
||||
int KeyFrameFrequency;
|
||||
int KeyFrameDataTarget;
|
||||
int AutoKeyFrameEnabled;
|
||||
int AutoKeyFrameThreshold;
|
||||
int MinimumDistanceToKeyFrame;
|
||||
int ForceKeyFrameEvery;
|
||||
int NoiseSensitivity;
|
||||
int AllowDF;
|
||||
int AllowSpatialResampling;
|
||||
int HScale;
|
||||
int HRatio;
|
||||
int VScale;
|
||||
int VRatio;
|
||||
int ScalingMode;
|
||||
int QuickCompress;
|
||||
int Speed;
|
||||
int Interlaced;
|
||||
int FixedQ;
|
||||
int StartingBufferLevel;
|
||||
int OptimalBufferLevel;
|
||||
int DropFramesWaterMark;
|
||||
int ResampleDownWaterMark;
|
||||
int ResampleUpWaterMark;
|
||||
int OutputFrameRate;
|
||||
int ErrorResilientMode;
|
||||
int Profile;
|
||||
int DisableGolden;
|
||||
int VBMode;
|
||||
int BestAllowedQ;
|
||||
int UnderShootPct;
|
||||
int MaxAllowedDatarate;
|
||||
int MaximumBufferSize;
|
||||
int TwoPassVBREnabled;
|
||||
int TwoPassVBRBias;
|
||||
int TwoPassVBRMaxSection;
|
||||
int TwoPassVBRMinSection;
|
||||
int Pass;
|
||||
int Mode;
|
||||
int EndUsage;
|
||||
int Sharpness;
|
||||
char FirstPassFile[512];
|
||||
char SettingsFile[512];
|
||||
char RootDirectory[512];
|
||||
|
||||
char Reserved[2048 - ConfigUsed];
|
||||
|
||||
VPConfig() :
|
||||
Used(ConfigUsed)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
VP6VFWState(FourCC fcc);
|
||||
~VP6VFWState();
|
||||
|
||||
FourCC fcc() const;
|
||||
Mode mode() const;
|
||||
|
||||
static size_t nominalSize();
|
||||
|
||||
VPConfig& vpConfig();
|
||||
|
||||
size_t vpStateSize() const;
|
||||
const void* vpState() const;
|
||||
void vpState(const void* pVPState, size_t sizeVPState);
|
||||
|
||||
size_t size() const;
|
||||
const void* data() const;
|
||||
int data(const void* pData, size_t sizeData);
|
||||
|
||||
private:
|
||||
|
||||
VP6VFWState(const VP6VFWState& vfws); // Not implemented
|
||||
VP6VFWState& operator=(const VP6VFWState& vfws); // Not implemented
|
||||
|
||||
int extract_(const void* pData, size_t sizeData);
|
||||
void update_(const void* pVPState, size_t sizeVPState) const;
|
||||
|
||||
FourCC m_fcc;
|
||||
Mode m_mode;
|
||||
|
||||
VPConfig m_vpConfig;
|
||||
|
||||
mutable void* m_pData;
|
||||
mutable size_t m_sizeData;
|
||||
};
|
||||
|
||||
} // namespace on2vp
|
||||
|
||||
#endif // VP6VFWSTATE_HPP
|
117
Src/libvp6/include/VPStreamData.hpp
Normal file
117
Src/libvp6/include/VPStreamData.hpp
Normal file
|
@ -0,0 +1,117 @@
|
|||
#if !defined(VPSTREAMDATA_HPP)
|
||||
#define VPSTREAMDATA_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// VPStreamData.hpp
|
||||
//
|
||||
|
||||
//______________________________________________________________________________
|
||||
// Include Files and Forward Declarations
|
||||
|
||||
#include "PlayerModel.hpp"
|
||||
#include <vector>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace on2vp
|
||||
{
|
||||
|
||||
//______________________________________________________________________________
|
||||
// Macro, Enumeration, and Constant Definitions
|
||||
|
||||
//______________________________________________________________________________
|
||||
// Type, Struct, and Class Definitions
|
||||
|
||||
//--------------------------------------
|
||||
class StreamData
|
||||
{
|
||||
friend std::ostream& operator<<(std::ostream& os, const StreamData& sd);
|
||||
|
||||
public:
|
||||
|
||||
StreamData();
|
||||
StreamData(const unsigned char* const pData, unsigned long ulSize);
|
||||
StreamData(const StreamData& sd);
|
||||
~StreamData();
|
||||
|
||||
StreamData& operator=(const StreamData& sd);
|
||||
|
||||
unsigned long versionOrig() const;
|
||||
unsigned long sizeOrig() const;
|
||||
unsigned long version() const;
|
||||
unsigned long size() const;
|
||||
const unsigned char* data() const;
|
||||
|
||||
int data(const unsigned char* pData, unsigned long ulSize);
|
||||
|
||||
// Interpreted data
|
||||
|
||||
const PlayerModel& playerModel() const;
|
||||
PlayerModel& playerModel();
|
||||
|
||||
bool encrypted() const;
|
||||
void encrypted(bool bEncrypted);
|
||||
|
||||
private:
|
||||
class VersionInfo
|
||||
{
|
||||
public:
|
||||
VersionInfo(long lVersion, long lSize, bool bExtra) :
|
||||
m_lVersion(lVersion),
|
||||
m_lSize(lSize),
|
||||
m_bExtra(bExtra)
|
||||
{
|
||||
}
|
||||
|
||||
long version() const
|
||||
{
|
||||
return m_lVersion;
|
||||
}
|
||||
|
||||
long size() const
|
||||
{
|
||||
return m_lSize;
|
||||
}
|
||||
|
||||
bool extra() const
|
||||
{
|
||||
return m_bExtra;
|
||||
}
|
||||
|
||||
private:
|
||||
long m_lVersion;
|
||||
long m_lSize;
|
||||
bool m_bExtra;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
VersionMax = 6
|
||||
};
|
||||
|
||||
void init_();
|
||||
int extract_(const unsigned char* pData, unsigned long ulSize);
|
||||
void update_();
|
||||
|
||||
static std::vector<VersionInfo> m_vVersionInfo;
|
||||
|
||||
unsigned long m_ulVersionOrig;
|
||||
unsigned long m_ulSizeOrig;
|
||||
|
||||
unsigned char* m_pData;
|
||||
long m_lDataSize;
|
||||
|
||||
// Interpreted data
|
||||
|
||||
PlayerModel m_pm;
|
||||
bool m_bEncrypted;
|
||||
};
|
||||
|
||||
//______________________________________________________________________________
|
||||
// Object and Function Declarations
|
||||
|
||||
//______________________________________________________________________________
|
||||
// Object and Function Definitions
|
||||
|
||||
} // namespace on2vp
|
||||
|
||||
#endif // VPSTREAMDATA_HPP
|
167
Src/libvp6/include/Vid.hpp
Normal file
167
Src/libvp6/include/Vid.hpp
Normal file
|
@ -0,0 +1,167 @@
|
|||
#ifndef VID_HPP
|
||||
#define VID_HPP
|
||||
|
||||
#pragma warning (disable:4786)
|
||||
|
||||
#include <windows.h>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <exception>
|
||||
|
||||
namespace Vid
|
||||
{
|
||||
|
||||
const enum Format { uyvy }; // format = uyvy;
|
||||
|
||||
enum { rate = 2997, scale = 100 };
|
||||
|
||||
class FileError : public exception
|
||||
{
|
||||
public:
|
||||
explicit FileError(const char* message);
|
||||
explicit FileError(DWORD id);
|
||||
const char* what() const;
|
||||
private:
|
||||
std::string message;
|
||||
};
|
||||
|
||||
|
||||
bool nameIsOK(const char* name);
|
||||
|
||||
typedef __int64 offset_type;
|
||||
typedef unsigned __int64 size_type;
|
||||
|
||||
class File
|
||||
{
|
||||
public:
|
||||
|
||||
static const Format format;
|
||||
|
||||
enum mode_t {in, out};
|
||||
|
||||
File();
|
||||
File(const char* name, mode_t mode, int iWidth = 0, int iHeight = 0);
|
||||
~File();
|
||||
|
||||
void open(
|
||||
const char* name,
|
||||
mode_t mode,
|
||||
DWORD flags = FILE_ATTRIBUTE_NORMAL);
|
||||
|
||||
void close();
|
||||
|
||||
void reset(int frameNum) const;
|
||||
void advance(int count) const;
|
||||
|
||||
void read(void* frame) const;
|
||||
void write(const void* frame);
|
||||
|
||||
bool isOpen() const;
|
||||
|
||||
bool eof() const;
|
||||
|
||||
mode_t mode() const;
|
||||
|
||||
const char* name() const;
|
||||
|
||||
int frameNum() const;
|
||||
|
||||
int frameCount() const;
|
||||
|
||||
size_type size() const;
|
||||
|
||||
void dimensions(int iWidth, int iHeight);
|
||||
int width() const;
|
||||
int height() const;
|
||||
int frameSize() const;
|
||||
|
||||
private:
|
||||
|
||||
File& operator=(const File&);
|
||||
File(const File&);
|
||||
|
||||
HANDLE m_handle;
|
||||
|
||||
// When opening for write with FILE_FLAG_OVERLAPPED
|
||||
HANDLE m_hEvent;
|
||||
OVERLAPPED m_overlapped;
|
||||
|
||||
mutable int frameNum_;
|
||||
|
||||
int frameCount_;
|
||||
|
||||
char name_[_MAX_PATH];
|
||||
|
||||
mode_t mode_;
|
||||
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
int m_iFrameSize;
|
||||
};
|
||||
|
||||
|
||||
class MappedFile
|
||||
{
|
||||
public:
|
||||
|
||||
//For now, just implement read-only.
|
||||
|
||||
MappedFile();
|
||||
MappedFile(const char* name, int iWidth = 0, int iHeight = 0);
|
||||
|
||||
~MappedFile();
|
||||
|
||||
void open(const char* name);
|
||||
void close();
|
||||
|
||||
const char* name() const;
|
||||
|
||||
int frameCount() const;
|
||||
|
||||
void* map(int frameNum) const;
|
||||
|
||||
void unmap(int frameNum) const;
|
||||
void unmap() const;
|
||||
|
||||
bool isMapped(int frameNum) const;
|
||||
int mapCount() const;
|
||||
|
||||
void dimensions(int iWidth, int iHeight);
|
||||
int width() const;
|
||||
int height() const;
|
||||
int frameSize() const;
|
||||
|
||||
private:
|
||||
|
||||
MappedFile(const MappedFile&);
|
||||
MappedFile& operator=(const MappedFile&);
|
||||
|
||||
void init(int iWidth = 0, int iHeight = 0);
|
||||
|
||||
HANDLE file;
|
||||
HANDLE mapping;
|
||||
|
||||
DWORD allocationGranularity;
|
||||
|
||||
int m_frameCount;
|
||||
|
||||
struct ViewInfo
|
||||
{
|
||||
void* view;
|
||||
void* frame;
|
||||
};
|
||||
|
||||
typedef std::map<int, ViewInfo> Views;
|
||||
mutable Views views;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
int m_iFrameSize;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
130
Src/libvp6/include/WAV.hpp
Normal file
130
Src/libvp6/include/WAV.hpp
Normal file
|
@ -0,0 +1,130 @@
|
|||
#ifndef WAV_HPP
|
||||
#define WAV_HPP
|
||||
|
||||
#include "FourCC.hpp"
|
||||
#include <io.h>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace WAV
|
||||
{
|
||||
class FileError : public exception
|
||||
{
|
||||
public:
|
||||
explicit FileError(const char* message);
|
||||
const char* what() const;
|
||||
private:
|
||||
const std::string message;
|
||||
};
|
||||
|
||||
|
||||
struct Format
|
||||
{
|
||||
unsigned short formatTag;
|
||||
unsigned short nChannels;
|
||||
unsigned long samplesPerSec;
|
||||
unsigned long avgBytesPerSec;
|
||||
unsigned short blockAlign;
|
||||
unsigned short bitsPerSample;
|
||||
|
||||
typedef std::vector<unsigned char> ByteArray;
|
||||
ByteArray extra;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const Format&);
|
||||
|
||||
typedef __int64 offset_t;
|
||||
|
||||
|
||||
class File
|
||||
{
|
||||
public:
|
||||
|
||||
enum mode_t { in, out, inout };
|
||||
|
||||
File();
|
||||
File(const char* name, mode_t mode);
|
||||
|
||||
~File();
|
||||
|
||||
void open(const char* name, mode_t mode);
|
||||
void close();
|
||||
|
||||
bool isOpen() const;
|
||||
bool eof() const;
|
||||
|
||||
//size_t sampleNum() const;
|
||||
//size_t sampleCount() const;
|
||||
|
||||
//void seekSample(size_t sampleNum) const;
|
||||
|
||||
offset_t offset() const;
|
||||
void seekOffset(offset_t) const;
|
||||
|
||||
size_t read(void* buffer, size_t size) const;
|
||||
void write(const void* buffer, size_t size);
|
||||
|
||||
mode_t mode() const;
|
||||
const char* name() const;
|
||||
|
||||
const Format& format() const;
|
||||
Format& format();
|
||||
|
||||
void seekFormat() const;
|
||||
|
||||
//void readFormat() const;
|
||||
void readFormatChunk() const;
|
||||
|
||||
void readFactChunk() const;
|
||||
|
||||
void setFactSize(size_t);
|
||||
size_t factSize() const;
|
||||
|
||||
void seekFact() const;
|
||||
|
||||
void writeFact(const void*, size_t);
|
||||
void readFact(void* buffer, size_t size) const;
|
||||
|
||||
void writeFormat();
|
||||
void writeFormatChunk();
|
||||
|
||||
size_t dataSize() const;
|
||||
|
||||
private:
|
||||
|
||||
File(const File&);
|
||||
File& operator=(const File&);
|
||||
|
||||
void init();
|
||||
|
||||
void seek(__int64, int) const;
|
||||
|
||||
const FourCC queryId() const;
|
||||
const FourCC readId() const;
|
||||
|
||||
void writeId(const char* id);
|
||||
|
||||
void writeSize(size_t size);
|
||||
size_t readSize() const;
|
||||
|
||||
int handle_;
|
||||
|
||||
__int64 dataPosn;
|
||||
size_t m_dataSize;
|
||||
|
||||
//size_t m_sampleCount;
|
||||
|
||||
char name_[_MAX_PATH];
|
||||
mode_t mode_;
|
||||
|
||||
mutable Format format_;
|
||||
|
||||
mutable size_t m_factSize;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
183
Src/libvp6/include/cclib.h
Normal file
183
Src/libvp6/include/cclib.h
Normal file
|
@ -0,0 +1,183 @@
|
|||
#ifndef _CCLIB_H
|
||||
#define _CCLIB_H
|
||||
#include "cpuidlib.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#if !defined(bool)
|
||||
typedef int bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int InitCCLib( PROCTYPE CpuType );
|
||||
|
||||
void DeInitCCLib( void );
|
||||
|
||||
extern void (*RGB32toYV12)( unsigned char *RGBABuffer, int ImageWidth, int ImageHeight,
|
||||
unsigned char *YBuffer, unsigned char *UBuffer, unsigned char *VBuffer, int SrcPitch,int DstPitch );
|
||||
|
||||
extern void (*RGB24toYV12)( unsigned char *RGBBuffer, int ImageWidth, int ImageHeight,
|
||||
unsigned char *YBuffer, unsigned char *UBuffer, unsigned char *VBuffer, int SrcPitch,int DstPitch );
|
||||
|
||||
extern void (*UYVYtoYV12)( unsigned char *UYVYBuffer, int ImageWidth, int ImageHeight,
|
||||
unsigned char *YBuffer, unsigned char *UBuffer, unsigned char *VBuffer, int SrcPitch,int DstPitch );
|
||||
|
||||
extern void (*YUY2toYV12)( unsigned char *UYVYBuffer, int ImageWidth, int ImageHeight,
|
||||
unsigned char *YBuffer, unsigned char *UBuffer, unsigned char *VBuffer, int SrcPitch,int DstPitch );
|
||||
|
||||
extern void (*YVYUtoYV12)( unsigned char *YVYUBuffer, int ImageWidth, int ImageHeight,
|
||||
unsigned char *YBuffer, unsigned char *UBuffer, unsigned char *VBuffer, int SrcPitch,int DstPitch );
|
||||
|
||||
extern void RGB24toYV12F
|
||||
(
|
||||
unsigned char *RGBBuffer,
|
||||
int ImageWidth,
|
||||
int ImageHeight,
|
||||
unsigned char *YBuffer,
|
||||
unsigned char *UBuffer,
|
||||
unsigned char *VBuffer,
|
||||
int SrcPitch,
|
||||
int DstPitch
|
||||
);
|
||||
|
||||
extern void RGB32toYV12F
|
||||
(
|
||||
unsigned char *RGBBuffer,
|
||||
int ImageWidth,
|
||||
int ImageHeight,
|
||||
unsigned char *YBuffer,
|
||||
unsigned char *UBuffer,
|
||||
unsigned char *VBuffer,
|
||||
int SrcPitch,
|
||||
int DstPitch
|
||||
);
|
||||
|
||||
extern void UYVYtoYV12F
|
||||
(
|
||||
unsigned char *UYVYBuffer,
|
||||
int ImageWidth,
|
||||
int ImageHeight,
|
||||
unsigned char *YBuffer,
|
||||
unsigned char *UBuffer,
|
||||
unsigned char *VBuffer,
|
||||
int SrcPitch,
|
||||
int DstPitch
|
||||
);
|
||||
|
||||
extern void YUY2toYV12F
|
||||
(
|
||||
unsigned char *YUY2Buffer,
|
||||
int ImageWidth,
|
||||
int ImageHeight,
|
||||
unsigned char *YBuffer,
|
||||
unsigned char *UBuffer,
|
||||
unsigned char *VBuffer,
|
||||
int SrcPitch,
|
||||
int DstPitch
|
||||
);
|
||||
|
||||
extern void YVYUtoYV12F
|
||||
(
|
||||
unsigned char *YVYUBuffer,
|
||||
int ImageWidth,
|
||||
int ImageHeight,
|
||||
unsigned char *YBuffer,
|
||||
unsigned char *UBuffer,
|
||||
unsigned char *VBuffer,
|
||||
int SrcPitch,
|
||||
int DstPitch
|
||||
);
|
||||
|
||||
/*
|
||||
* Macros to make it easier to call the needed functions
|
||||
*/
|
||||
#define CC_RGB32toYV12( _RGBABuffer, _ImageWidth, _ImageHeight, _YBuffer, _UBuffer, _VBuffer ) \
|
||||
(*RGB32toYV12)( _RGBABuffer, _ImageWidth, _ImageHeight, _YBuffer, _UBuffer, _VBuffer, _ImageWidth*4, _ImageWidth )
|
||||
|
||||
#define CC_RGB24toYV12( _RGBBuffer, _ImageWidth, _ImageHeight, _YBuffer, _UBuffer, _VBuffer ) \
|
||||
(*RGB24toYV12)( _RGBBuffer, _ImageWidth, _ImageHeight, _YBuffer, _UBuffer, _VBuffer, _ImageWidth*3, _ImageWidth )
|
||||
|
||||
#define CC_UYVYtoYV12( _UYVYBuffer, _ImageWidth, _ImageHeight, _YBuffer, _UBuffer, _VBuffer ) \
|
||||
(*UYVYtoYV12)( _UYVYBuffer, _ImageWidth, _ImageHeight, _YBuffer, _UBuffer, _VBuffer, _ImageWidth*2, _ImageWidth )
|
||||
|
||||
#define CC_YUY2toYV12( _YUY2Buffer, _ImageWidth, _ImageHeight, _YBuffer, _UBuffer, _VBuffer ) \
|
||||
(*YUY2toYV12)( _YUY2Buffer, _ImageWidth, _ImageHeight, _YBuffer, _UBuffer, _VBuffer, _ImageWidth*2, _ImageWidth )
|
||||
|
||||
#define CC_YVYUtoYV12( _YVYUBuffer, _ImageWidth, _ImageHeight, _YBuffer, _UBuffer, _VBuffer ) \
|
||||
(*YVYUtoYV12)( _YVYUBuffer, _ImageWidth, _ImageHeight, _YBuffer, _UBuffer, _VBuffer, _ImageWidth*2, _ImageWidth )
|
||||
|
||||
// super generic rgb to yuv color conversion can handle any rgb to yuv conversion
|
||||
// provided r,g,b components are 1 byte apiece, and that the resulting y is 1 byte
|
||||
extern void ConvertRGBtoYUV(
|
||||
const unsigned char* const pucSourceR, const unsigned char* const pucSourceG, const unsigned char* const pucSourceB,
|
||||
int width, int height, int rgb_step, int rgb_pitch,
|
||||
unsigned char* const pucDestY, unsigned char* const pucDestU, unsigned char* const pucDestV,
|
||||
int uv_width_shift, int uv_height_shift,
|
||||
int y_step, int y_pitch,int uv_step,int uv_pitch);
|
||||
|
||||
extern void ConvertRGBtoYUVI(
|
||||
const unsigned char* const pucSourceR, const unsigned char* const pucSourceG, const unsigned char* const pucSourceB,
|
||||
int iWidth, int iHeight, int iStepRGB, int iStrideRGB,
|
||||
unsigned char* const pucDestY, unsigned char* const pucDestU, unsigned char* const pucDestV,
|
||||
int uv_width_shift, int uv_height_shift,
|
||||
int iStepY, int iStrideY, int iStepUV, int iStrideUV);
|
||||
|
||||
// This assumes 3 byte RGB data with the same component ordering in the source and destination
|
||||
extern void ConvertRGBtoRGB(const unsigned char* const pucSource, long lWidth, long lHeight, long lStepIn, long lStrideIn,
|
||||
unsigned char* const pucDest, long lStepOut, long lStrideOut);
|
||||
|
||||
extern void ConvertYUVtoRGB(
|
||||
const unsigned char* const pucYPlane, const unsigned char* const pucUPlane, const unsigned char* const pucVPlane,
|
||||
long lWidth, long lHeight,
|
||||
long uv_width_shift, long uv_height_shift, // not used, should both be set to 1
|
||||
long lStepY, long lStrideY,long lStepUV, long lStrideUV,
|
||||
unsigned char* const pucRPlane, unsigned char* const pucGPlane, unsigned char* const pucBPlane,
|
||||
long lStepRGB, long lStrideRGB);
|
||||
|
||||
extern void ConvertYUVItoRGB(
|
||||
const unsigned char* const pucYPlane, const unsigned char* const pucUPlane, const unsigned char* const pucVPlane,
|
||||
long lWidth, long lHeight,
|
||||
long uv_width_shift, long uv_height_shift, // not used, should both be set to 1
|
||||
long lStepY, long lStrideY,long lStepUV, long lStrideUV,
|
||||
unsigned char* const pucRPlane, unsigned char* const pucGPlane, unsigned char* const pucBPlane,
|
||||
long lStepRGB, long lStrideRGB);
|
||||
|
||||
extern void ConvertYUVtoRGB2(
|
||||
const unsigned char* const pucYPlane, const unsigned char* const pucUPlane, const unsigned char* const pucVPlane,
|
||||
long lWidth, long lHeight,
|
||||
long uv_width_shift, long uv_height_shift, // not used, should both be set to 1
|
||||
long lStepY, long lStrideY,long lStepUV, long lStrideUV,
|
||||
unsigned char* const pucRPlane, unsigned char* const pucGPlane, unsigned char* const pucBPlane,
|
||||
long lStepRGB, long lStrideRGB,
|
||||
bool bSupersampleHoriz, bool bSupersampleVert);
|
||||
|
||||
extern void ConvertYUVItoRGB2(
|
||||
const unsigned char* const pucYPlane, const unsigned char* const pucUPlane, const unsigned char* const pucVPlane,
|
||||
long lWidth, long lHeight,
|
||||
long uv_width_shift, long uv_height_shift, // not used, should both be set to 1
|
||||
long lStepY, long lStrideY,long lStepUV, long lStrideUV,
|
||||
unsigned char* const pucRPlane, unsigned char* const pucGPlane, unsigned char* const pucBPlane,
|
||||
long lStepRGB, long lStrideRGB,
|
||||
bool bSupersampleHoriz, bool bSupersampleVert);
|
||||
|
||||
// This assumes packed planar data
|
||||
extern void ConvertYUVtoYUV(const unsigned char* const pucYIn, const unsigned char* const pucUV1In, const unsigned char* const pucUV2In,
|
||||
long m_lWidth, long m_lHeight,
|
||||
unsigned char* const pucYOut, unsigned char* const pucUV1Out, unsigned char* const pucUV2Out);
|
||||
|
||||
// This assumes packed planar data
|
||||
extern void ConvertYUVtoYUVI(const unsigned char* const pucYIn, const unsigned char* const pucUV1In, const unsigned char* const pucUV2In,
|
||||
long m_lWidth, long m_lHeight,
|
||||
unsigned char* const pucYOut, unsigned char* const pucUV1Out, unsigned char* const pucUV2Out);
|
||||
|
||||
// This assumes packed planar data
|
||||
extern void ConvertYUVItoYUV(const unsigned char* const pucYIn, const unsigned char* const pucUV1In, const unsigned char* const pucUV2In,
|
||||
long m_lWidth, long m_lHeight,
|
||||
unsigned char* const pucYOut, unsigned char* const pucUV1Out, unsigned char* const pucUV2Out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _CCLIB_H */
|
95
Src/libvp6/include/codec_common_interface.h
Normal file
95
Src/libvp6/include/codec_common_interface.h
Normal file
|
@ -0,0 +1,95 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Module Title : codec_common_if.h
|
||||
*
|
||||
* Description : Common codec definitions.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __INC_CODEC_COMMON_INTERFACE_H
|
||||
#define __INC_CODEC_COMMON_INTERFACE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Macros
|
||||
****************************************************************************/
|
||||
#define __export
|
||||
#define _export
|
||||
#define DllExport __declspec( dllexport )
|
||||
#define DllImport __declspec( dllimport )
|
||||
|
||||
// Playback error codes
|
||||
#define NO_DECODER_ERROR 0
|
||||
#define REMOTE_DECODER_ERROR -1
|
||||
|
||||
#define DFR_BAD_DCT_COEFF -100
|
||||
#define DFR_ZERO_LENGTH_FRAME -101
|
||||
#define DFR_FRAME_SIZE_INVALID -102
|
||||
#define DFR_OUTPUT_BUFFER_OVERFLOW -103
|
||||
#define DFR_INVALID_FRAME_HEADER -104
|
||||
#define FR_INVALID_MODE_TOKEN -110
|
||||
#define ETR_ALLOCATION_ERROR -200
|
||||
#define ETR_INVALID_ROOT_PTR -201
|
||||
#define SYNCH_ERROR -400
|
||||
#define BUFFER_UNDERFLOW_ERROR -500
|
||||
#define PB_IB_OVERFLOW_ERROR -501
|
||||
|
||||
// External error triggers
|
||||
#define PB_HEADER_CHECKSUM_ERROR -601
|
||||
#define PB_DATA_CHECKSUM_ERROR -602
|
||||
|
||||
// DCT Error Codes
|
||||
#define DDCT_EXPANSION_ERROR -700
|
||||
#define DDCT_INVALID_TOKEN_ERROR -701
|
||||
|
||||
// ExceptionErrors
|
||||
#define GEN_EXCEPTIONS -800
|
||||
#define EX_UNQUAL_ERROR -801
|
||||
|
||||
// Unrecoverable error codes
|
||||
#define FATAL_PLAYBACK_ERROR -1000
|
||||
#define GEN_ERROR_CREATING_CDC -1001
|
||||
#define GEN_THREAD_CREATION_ERROR -1002
|
||||
#define DFR_CREATE_BMP_FAILED -1003
|
||||
|
||||
/****************************************************************************
|
||||
* Typedefs
|
||||
****************************************************************************/
|
||||
typedef struct // YUV buffer configuration structure
|
||||
{
|
||||
int YWidth;
|
||||
int YHeight;
|
||||
int YStride;
|
||||
|
||||
int UVWidth;
|
||||
int UVHeight;
|
||||
int UVStride;
|
||||
|
||||
char *YBuffer;
|
||||
char *UBuffer;
|
||||
char *VBuffer;
|
||||
|
||||
} YUV_BUFFER_CONFIG;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
C_SET_KEY_FRAME,
|
||||
C_SET_FIXED_Q,
|
||||
C_SET_FIRSTPASS_FILE,
|
||||
C_SET_EXPERIMENTAL_MIN,
|
||||
C_SET_EXPERIMENTAL_MAX = C_SET_EXPERIMENTAL_MIN + 255,
|
||||
C_SET_CHECKPROTECT,
|
||||
C_SET_TESTMODE,
|
||||
C_SET_INTERNAL_SIZE,
|
||||
C_SET_RECOVERY_FRAME,
|
||||
C_SET_REFERENCEFRAME,
|
||||
C_SET_GOLDENFRAME
|
||||
} C_SETTING;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MAINTAIN_ASPECT_RATIO = 0x0,
|
||||
SCALE_TO_FIT = 0x1,
|
||||
CENTER = 0x2,
|
||||
OTHER = 0x3
|
||||
} SCALE_MODE;
|
||||
|
||||
#endif
|
73
Src/libvp6/include/dkpltfrm.h
Normal file
73
Src/libvp6/include/dkpltfrm.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
//==========================================================================
|
||||
//
|
||||
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
|
||||
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
// PURPOSE.
|
||||
//
|
||||
// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
#ifndef _dkpltfrm_h
|
||||
#define _dkpltfrm_h
|
||||
/********************************************************
|
||||
|
||||
PC for Win95/DOS/etc...
|
||||
|
||||
********************************************************/
|
||||
|
||||
/*
|
||||
#define DX_COUNTERS 0
|
||||
*/
|
||||
|
||||
|
||||
/* #define VOXWARE_WIN32 1 */
|
||||
|
||||
|
||||
#define SUPPORT565 1
|
||||
#define DX_TR20 1
|
||||
#define TINKER 1
|
||||
#define LARGECHUNKS 1
|
||||
|
||||
#define RGBORDER 0
|
||||
#define BGRORDER 1
|
||||
|
||||
|
||||
#define DKTRUE 1
|
||||
#define DKFALSE !DKTRUE
|
||||
|
||||
#define TBLOFFSET 0
|
||||
#define CENTER_TABLE 0
|
||||
|
||||
#define BLACK16X2 0x00000000
|
||||
|
||||
//#include "nofar.h"
|
||||
#include "littlend.h"
|
||||
|
||||
#define LIMITREADS /* limit reads average frame size */
|
||||
#define LIMIT_1_5 /* limit reads to 1.5x the average frame size */
|
||||
#define DISPLAYDIB 0
|
||||
|
||||
#define AUDIOINTERLEAVED 1
|
||||
typedef int GfsHn;
|
||||
#define slow_seek duck_seek
|
||||
#define gooseCD(x,y)
|
||||
|
||||
#define COLORORDER RGBORDER
|
||||
|
||||
#define SWAPENDS 0
|
||||
|
||||
#define HW_CD_BUFFER 0
|
||||
#define CD_ONLY 0
|
||||
|
||||
#define DX24BIT
|
||||
|
||||
|
||||
#if !defined(UINT64)
|
||||
typedef unsigned __int64 UINT64;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* include guards */
|
79
Src/libvp6/include/duck_bmp.h
Normal file
79
Src/libvp6/include/duck_bmp.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
#ifndef _duck_bmp_h
|
||||
#define _duck_bmp_h
|
||||
|
||||
#include "dkpltfrm.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct tDKBITMAP_old
|
||||
{
|
||||
unsigned long ulFormatTag;
|
||||
unsigned long usWidth; /* width */
|
||||
unsigned long usHeight; /* height */
|
||||
unsigned long bmWidthBytes;
|
||||
unsigned short bmPlanes;
|
||||
unsigned short usDepth;
|
||||
unsigned int ulHandler;
|
||||
|
||||
} DKBITMAP_old; /* Depricated please ! */
|
||||
|
||||
|
||||
/* This is the REAL BITMAP */
|
||||
typedef struct tDKBITMAP {
|
||||
unsigned long bmType;
|
||||
unsigned long bmWidth;
|
||||
unsigned long bmHeight;
|
||||
unsigned long bmWidthBytes;
|
||||
unsigned short bmPlanes;
|
||||
unsigned short bmBitsPixel;
|
||||
void* bmBits;
|
||||
} DKBITMAP;
|
||||
|
||||
|
||||
|
||||
#if !defined(DWORD)
|
||||
#define DWORD unsigned int
|
||||
#endif
|
||||
|
||||
#if !defined(WORD)
|
||||
#define WORD unsigned short
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct DK_BITMAPINFOHEADER_t
|
||||
{
|
||||
DWORD biSize;
|
||||
DWORD biWidth;
|
||||
DWORD biHeight;
|
||||
WORD biPlanes;
|
||||
WORD biBitCount;
|
||||
DWORD biCompression;
|
||||
DWORD biSizeImage;
|
||||
DWORD biXPelsPerMeter;
|
||||
DWORD biYPelsPerMeter;
|
||||
DWORD biClrUsed;
|
||||
DWORD biClrImportant;
|
||||
|
||||
DWORD fccHandler; /* hopefully this never matters */
|
||||
DWORD dxFlavor;
|
||||
} DK_BITMAPINFOHEADER;
|
||||
|
||||
|
||||
static int DK_BITMAPINFOHEADER_REFLECT[ ] = { 4,4,4,2,2, 4,4,4,4,4,4,4,4 };
|
||||
|
||||
|
||||
|
||||
#undef WORD
|
||||
#undef DWORD
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
230
Src/libvp6/include/duck_dxa.h
Normal file
230
Src/libvp6/include/duck_dxa.h
Normal file
|
@ -0,0 +1,230 @@
|
|||
#ifndef _duck_dxa_h
|
||||
#define _duck_dxa_h
|
||||
|
||||
|
||||
#include "duck_wav.h"
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct tXAudioSource* DXL_XAUDIOSRC_HANDLE; /* forward looking ! */
|
||||
|
||||
|
||||
#define MAX_AUDIO_REGISTRATIONS 20
|
||||
|
||||
/* Structure used to register DXA plugins with dxa by formatTag. */
|
||||
/*-------------------------------------------------------------------------*/
|
||||
typedef struct tXAudioRegistration {
|
||||
unsigned short formatTag;
|
||||
int (*audio_dxer_init)(DXL_XAUDIOSRC_HANDLE src);
|
||||
int (*audio_dxer_dx)(DXL_XAUDIOSRC_HANDLE src, void *left, void *right, int nSamples);
|
||||
int (*audio_dxer_exit)(DXL_XAUDIOSRC_HANDLE src);
|
||||
int (*audio_dxer_clear)(DXL_XAUDIOSRC_HANDLE src);
|
||||
} DXL_AUDIO_REGISTRATION;
|
||||
|
||||
|
||||
|
||||
/* If it's not documented here, if it's only defined here ... then it's probably not needed by most codec plugins */
|
||||
/* It may only be used internally to dxa . */
|
||||
/*----------------------------------------------------------------------------------------------------------------*/
|
||||
typedef struct tXAudioSource
|
||||
{
|
||||
unsigned char *addr; /* address from which to read compressed audio bytes */
|
||||
int totalPos;
|
||||
int length; /* length of compressed audio bytes to read from buffer */
|
||||
int interleave;
|
||||
short aiSamp[2],aiStepIndex[2];
|
||||
int blockFinished; /* flags audio system that new data in buffer */
|
||||
int samplesRead;
|
||||
UINT64 profileStartTime;
|
||||
UINT64 profileEndTime;
|
||||
UINT64 dxClocks;
|
||||
UINT64 samplesDXed;
|
||||
short iFirstNibble;
|
||||
short iNextInput;
|
||||
short sum,diff,nudiff;
|
||||
DKWAVEFORM wv; /* details of the compressed audio data */
|
||||
DXL_AUDIO_REGISTRATION registration;
|
||||
void* more; /* user data ... plugin data */
|
||||
|
||||
} DXL_XAUDIOSRC;
|
||||
|
||||
|
||||
|
||||
typedef struct tAudioBuff *DXL_AUDIODST_HANDLE;
|
||||
|
||||
|
||||
|
||||
|
||||
/* audio function prototypes */
|
||||
|
||||
/*@
|
||||
@Name DXL_InitAudio
|
||||
@Description Initialize audio decompression services. This function allocates memory for requested object pools.
|
||||
@Return value DXL_OK on success, or negative error code.
|
||||
@*/
|
||||
int DXL_InitAudio(
|
||||
int srcs, /* max number of audio sources to be created. */
|
||||
int dsts /* max number of audio destinations to be created. */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_ExitAudio
|
||||
@Description Shutdown audio decompression services, freeing allocated objects.
|
||||
@Return value none.
|
||||
@*/
|
||||
void DXL_ExitAudio(void);
|
||||
|
||||
|
||||
typedef struct tDKWAVEFORM *DKWAVEFORMPTR; /* place holder pointer */
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_CreateXAudioSrc
|
||||
@Description Create a compressed audio source (decompressor)
|
||||
@Return value returns an DXL_XAUDIOSRC_HANDLE or null unable to create audio source object.
|
||||
@*/
|
||||
DXL_XAUDIOSRC_HANDLE DXL_CreateXAudioSrc(
|
||||
|
||||
DKWAVEFORMPTR wv, /* pointer to compressed waveform struct describing the audio input. */
|
||||
unsigned char *addr, /* address of compressed data */
|
||||
int length /* length of compressed data in bytes. */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_AlterXAudioData
|
||||
@Description Link an audio decompressor to the next unit of compressed data.
|
||||
This function cannot change the type of xSource on the fly. That must remain consistent.
|
||||
Setting the address of the audio data to null causes the xSource to generate an infinate number of "zero" value samples.
|
||||
@Return value void
|
||||
@*/
|
||||
void DXL_AlterXAudioData(
|
||||
DXL_XAUDIOSRC_HANDLE xSource, /* handle to compressed audio source */
|
||||
unsigned char *addr, /* pointer to new compressed audio data */
|
||||
int length /* length of compressed data in bytes. */
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_DestroyXAudioSrc
|
||||
@Description clears an audio decompressor and returns it to the pool.
|
||||
@Return value void
|
||||
@*/
|
||||
void DXL_DestroyXAudioSrc(
|
||||
DXL_XAUDIOSRC_HANDLE xSource /* compressed audio source */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_CreateAudioDst
|
||||
@Description Create a audio destination description. When numChannel equals 2 but addrR is null, it
|
||||
is assumed that multi-channel samples should be interleaved within the dest buffer pointed to by addrL.
|
||||
@Return value returns an object of type DXL_AUDIODST_HANDLE, and audio destination.
|
||||
@*/
|
||||
DXL_AUDIODST_HANDLE DXL_CreateAudioDst(
|
||||
void *addrL, /* pointer to left audio destination channel */
|
||||
void *addrR, /* pointer to right audio destination channel */
|
||||
int length, /* audio buffer size in bytes. */
|
||||
int bitDepth, /* bits per sample */
|
||||
int numChannels, /* number of audio channels */
|
||||
int sampleRate /* samples per second */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_AlterAudioDst
|
||||
@Description Change characteristics of audio destination.
|
||||
Specify 0 or null values for no change.
|
||||
@Return value void
|
||||
@*/
|
||||
void DXL_AlterAudioDst(
|
||||
DXL_AUDIODST_HANDLE dst, /* handle to audio destionation */
|
||||
void *addrL, /* pointer to left audio destination channel */
|
||||
void *addrR, /* pointer to right audio destination channel */
|
||||
int length, /* audio buffer size in bytes. */
|
||||
int bitDepth, /* bits per sample (8 or 16) */
|
||||
int numChannels, /* number of audio channels (1 or 2) */
|
||||
int sampleRate /* samples per second */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_DestroyAudioDst
|
||||
@Description clears and audio destination object and returns it to the pool.
|
||||
@Return value none.
|
||||
@*/
|
||||
void DXL_DestroyAudioDst(
|
||||
DXL_AUDIODST_HANDLE dst /* handle to audio destination */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_dxAudio
|
||||
@Description decompress up to maxSamplesToDecompress. The number of samples transferred is controlled by two factors.
|
||||
One factor is the limit parameter. The other factor is the number of remaining samples in the src (internal buffer).
|
||||
If the function returns less that the desired number of samples, get another audio record (via HFB_GetStreamingData()) for source data and try again.
|
||||
@Return value returns the actual number of samples decompressed
|
||||
@*/
|
||||
int DXL_dxAudio(
|
||||
DXL_XAUDIOSRC_HANDLE src, /* handle to compressed audio source. */
|
||||
DXL_AUDIODST_HANDLE dst, /* handle to uncompressed audio destination */
|
||||
int maxSamplesToDecompress /* Try to decompress up to this many samples to the destination */
|
||||
);
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_ClearAudio
|
||||
@Description Clears any internal audio buffers compressed and/or decompressed data so that playback may start from a new point.
|
||||
@Return value
|
||||
@*/
|
||||
int DXL_ClearAudio(DXL_XAUDIOSRC_HANDLE xSourcePublic);
|
||||
|
||||
|
||||
|
||||
int DXL_RegisteredAudioDXerGet(DXL_AUDIO_REGISTRATION *oneRegistration);
|
||||
|
||||
int DXL_RegisteredAudioDXerSet(
|
||||
unsigned short formatTag,
|
||||
int (*audio_dxer_init) (DXL_XAUDIOSRC_HANDLE src),
|
||||
int (*audio_dxer_dx) (DXL_XAUDIOSRC_HANDLE src, void *left, void *right, int nSamples),
|
||||
int (*audio_dxer_exit) (DXL_XAUDIOSRC_HANDLE src),
|
||||
int (*audio_dxer_clear) (DXL_XAUDIOSRC_HANDLE src)
|
||||
);
|
||||
|
||||
|
||||
|
||||
void DXL_AudioAccurateTime(UINT64* temp);
|
||||
|
||||
|
||||
/* Register one of the On2 dxa plugins */
|
||||
/*-------------------------------------*/
|
||||
int DXL_RegisterAVC(void);
|
||||
int DXL_RegisterAC3(void);
|
||||
int DXL_RegisterQDesign(void);
|
||||
int DXL_RegisterACM(unsigned short formatTag);
|
||||
int DXL_RegisterDK4(void);
|
||||
int DXL_RegisterMP3(void);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* include guards */
|
583
Src/libvp6/include/duck_dxl.h
Normal file
583
Src/libvp6/include/duck_dxl.h
Normal file
|
@ -0,0 +1,583 @@
|
|||
#ifndef _duck_dxl_h
|
||||
#define _duck_dxl_h
|
||||
|
||||
|
||||
#include "duck_bmp.h"
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
<table BGCOLOR=#FFC0C0 border=1 WIDTH=100% ><tr><td><b>
|
||||
duck_dxl.h </b></td><td><b> TrueMotion include file for decompression libraries </b>
|
||||
|
||||
</td></tr><tr><td> </td><td> Version: 6.0.0
|
||||
</td></tr><tr><td> </td><td> Updated: $Date: 2011/06/29 19:50:29 $
|
||||
</td></tr><tr><td> </td><td> Copyright (c) 1994-98, The Duck Corp. All rights reserved.
|
||||
</td></tr><tr><td>Important Objects</td><td>The On2 Decompression services tries to abstract the various objects
|
||||
used to decompress and render both audio and video. This allows the overall API to flex and accomodate new
|
||||
decompression schemes and new destinations.
|
||||
</td></tr><tr><td>DXL_XIMAGE_HANDLE</td><td>Abstract container object used to organize and control compressed
|
||||
video.
|
||||
</td></tr><tr><td>DXL_VSCREEN_HANDLE</td><td>Abstract container object used to organize and control display of
|
||||
uncompressed video to a surface.
|
||||
</td></tr><tr><td>DXL_XAUDIOSRC_HANDLE</td><td>Abstract container object used to organize and control
|
||||
compressed audio.
|
||||
</td></tr><tr><td>DXL_AUDIODST_HANDLE</td><td>Abstract container object used to organize and control
|
||||
rendering / playing of uncompressed audio.
|
||||
</td></tr>
|
||||
</table>
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* enumerated data types */
|
||||
|
||||
typedef enum BLITQUALITY {
|
||||
DXBLIT_SAME = 0, /* Blit directly, w/o stretching */
|
||||
DXBLIT_R1,
|
||||
DXBLIT_R2,
|
||||
DXBLIT_STRETCH, /* double horizontally, skip lines vertically */
|
||||
DXBLIT_R3,
|
||||
DXBLIT_STRETCH_BRIGHT, /* double horizontally, interpolate vertically */
|
||||
DXBLIT_R4,
|
||||
DXBLIT_R5,
|
||||
DXBLIT_R6,
|
||||
DXBLIT_NONE,
|
||||
DXBLITMAX
|
||||
} dxvBlitQuality ;
|
||||
|
||||
typedef enum BITDEPTH {
|
||||
DXRGBNULL = 0,
|
||||
DXRGB8 = 1,
|
||||
|
||||
DXRGB16_555 = 2,
|
||||
DXRGB24 = 3,
|
||||
DXRGB_UNUSED = 4,
|
||||
DXRGB16VESA = 5,
|
||||
DXRGB8VESA = 6,
|
||||
DXRGB16_565 = 7,
|
||||
|
||||
DXYUY2 = 8,
|
||||
DXYVU9 = 9,
|
||||
DXYV12 = 10,
|
||||
DXUYVY = 11,
|
||||
|
||||
DXRGB32 = 12,
|
||||
DXRGB16VESA_565 = 13,
|
||||
DXHALFTONE8 =14,
|
||||
DXI420 = 15,
|
||||
|
||||
DXYVYU = 16,
|
||||
|
||||
DXMAX
|
||||
} dxvBitDepth ;
|
||||
|
||||
#define DXRGB16 DXRGB16_555
|
||||
#define DXRGB24CHAR DXRGB24
|
||||
|
||||
typedef enum OFFSETXY {
|
||||
DXL_ABSOLUTE = 0,
|
||||
DXL_RELATIVE
|
||||
} dxvOffsetMode;
|
||||
|
||||
typedef enum IMAGETYPE {
|
||||
DXL_INTRAFRAME = 0,
|
||||
DXL_INTERFRAME,
|
||||
DXL_SPRITE
|
||||
} dxvImageType;
|
||||
|
||||
|
||||
|
||||
typedef enum DXL_ERR{
|
||||
DXL_LOW_ERR = -32000,
|
||||
DXL_HARDWARE_ERROR = -16002,
|
||||
DXL_HARDWARE_NOT_INITED = -16001,
|
||||
DXL_HARDWARE_BUFFER_FULL = -16000,
|
||||
DXL_INVALID_REQUEST = -9,
|
||||
DXL_VERSION_CONFLICT = -8,
|
||||
DXL_INVALID_DATA = -7,
|
||||
DXL_INVALID_BLIT = -6,
|
||||
DXL_BAD_DATA = -5,
|
||||
DXL_ALLOC_FAILED = -4,
|
||||
DXL_NULL_FRAME = -3,
|
||||
DXL_NULLSOURCE = -2,
|
||||
DXL_NOTINUSE = -1,
|
||||
DXL_OK = 0,
|
||||
DXL_HOLD_FRAME = 1
|
||||
} dxvError ;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum BGMODE /* sprite drawing modes
|
||||
v1.0.2 supports NORM & NO_BACKGROUND */{
|
||||
NORM = 0, /* normal sprite mode, blend edges w/background */
|
||||
NO_BACKGROUND = 1,/* transparant sprite mode 1,
|
||||
sets all background data transparant no blending */
|
||||
NORM_TRANS = 2, /* transparant sprite mode 2,
|
||||
blend edges (alphas) w/separate background buffer,
|
||||
set sprite background to trans */
|
||||
RGB_OPAQUE = 3, /* blend edges to sprColor, set background to sprColor*/
|
||||
RGB_TRANS = 4 /* blend edges w/sprColor, set background to trans */
|
||||
} dxvBackgroundMode ;
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
/* definition of data handles */
|
||||
|
||||
typedef struct vScreen *DXL_VSCREEN_HANDLE;
|
||||
typedef struct tXImage *DXL_XIMAGE_HANDLE;
|
||||
|
||||
/* main video decompression init, exit and query */
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_InitVideo
|
||||
@Description Initialize Video decompression services
|
||||
@Return value DXL_OK on success. -1 unable to initialize library, insufficient memory available.
|
||||
@*/
|
||||
int DXL_InitVideo(
|
||||
int maxScreens, /* max Number of VScreens to allow. Outdated. Please pass zero ! */
|
||||
int maxImages /* max Number of xImages to allow. Outdated. Please pass zero ! */
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_ExitVideo
|
||||
@Description Exit and de-initialize video decompression library. Release any allocated data structures.
|
||||
Always destroy xImages before calling this routine to avoid memory leaks.
|
||||
@Return value none
|
||||
@*/
|
||||
void DXL_ExitVideo(void);
|
||||
|
||||
|
||||
/*get pointer to NULL terminated
|
||||
array of supported fourCCs */
|
||||
unsigned long *DXL_GetFourCCList(void);
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_CreateXImage
|
||||
@Description Create an xImage (decompressor) object, based on the compressed data provided.
|
||||
@Return value returns a DXL_XIMAGE_HANDLE object ... also known as an xImage, or compressed image
|
||||
@*/
|
||||
DXL_XIMAGE_HANDLE DXL_CreateXImage(
|
||||
unsigned char *data /* compressed data */
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_SetXImageCSize
|
||||
@Description Set the size of the current compressed frame
|
||||
@Return value echo back the compressed image size
|
||||
@*/
|
||||
int DXL_SetXImageCSize(
|
||||
DXL_XIMAGE_HANDLE xImage, /* compressed image handle */
|
||||
int compressedSize /* compressed image size */
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_CreateXImageOfType
|
||||
@Description Create an xImage (decompressor) object of a requested type based on a FOURCC.
|
||||
Allocates buffers and initializes structures needed to decompress a source-compressed xImage.
|
||||
@Return value Handle to xImage created by this call , null if cannot create.
|
||||
@*/
|
||||
DXL_XIMAGE_HANDLE DXL_CreateXImageOfType(
|
||||
unsigned char *data, /* pointer to compressed image data */
|
||||
unsigned long fccType /* FOURCC code indicating type of compressed image data */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_CreateXImageFromBMI
|
||||
@Description Create an xImage (decompressor) object of a requested type based on a FOURCC.
|
||||
Allocates buffers and initializes structures needed to decompress a source-compressed xImage.
|
||||
@Return value Handle to xImage created by this call , null if cannot create.
|
||||
@*/
|
||||
DXL_XIMAGE_HANDLE DXL_CreateXImageFromBMI(
|
||||
unsigned char *data, /* pointer to compressed image data */
|
||||
unsigned long biCompression, /* biCompression from BMIH */
|
||||
DK_BITMAPINFOHEADER *srcAndDst /* BMI data from AVI file or elsewhere */
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_DestroyXImage
|
||||
@Description destroy the specified xImage
|
||||
@Return value void
|
||||
@*/
|
||||
void DXL_DestroyXImage(
|
||||
DXL_XIMAGE_HANDLE src /* handle to compressed image */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_AlterXImageData
|
||||
@Description Provides a compressed source with new data to decompress. New xImage attributes can be
|
||||
queried any time after changing the address of the compressed data with this function.
|
||||
@Return value DXL_OK on success or negative error code. -3 indicates that the pointer was passed in as null.
|
||||
Some compression applications (such as Adobe Premiere) use this to indicate that the new frame is the same as
|
||||
the previous frame, and the previous frame is to be held.
|
||||
@*/
|
||||
int DXL_AlterXImageData(
|
||||
DXL_XIMAGE_HANDLE src, /* handle to compressed image source (xImage) */
|
||||
unsigned char *ptrData /* pointer to compressed video data to be associated with xImage */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_AlterXImage
|
||||
@Description Explicitly alter attributes of an xImage. The use of this funtion
|
||||
may affect the state of the xImage's frame buffer. During interframe compression, this can result
|
||||
in corruption of the decompressed image. Make sure to use this function only prior to decompressing a keyframe.
|
||||
@Return value handle to compressed image, or null if error.
|
||||
@*/
|
||||
DXL_XIMAGE_HANDLE DXL_AlterXImage(
|
||||
DXL_XIMAGE_HANDLE xImage, /* handle to compressed image */
|
||||
unsigned char *ptrData, /* pointer to compressed video data. */
|
||||
int xImType, /* new xImage type (DXL_INTRAFRAME, DXL_INTERFRAME). */
|
||||
dxvBitDepth bitDepth , /* bitdepth of decompressed data */
|
||||
int maxWidth, /* width of decompressed image */
|
||||
int maxHeight /* height of decompressed image */
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_GetXImageCSize
|
||||
@Description Get xImage compressed size
|
||||
@Return value returns the compressed size
|
||||
@*/
|
||||
long DXL_GetXImageCSize(
|
||||
DXL_XIMAGE_HANDLE src /* handle to compressed image */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_GetXImageXYWH
|
||||
@Description get application specified x,y offset, and overall decompressed width and height.
|
||||
x and y offsets are legacy fields, ignore.
|
||||
@Return value DXL_OK on success, or negative error code.
|
||||
@*/
|
||||
int DXL_GetXImageXYWH(
|
||||
DXL_XIMAGE_HANDLE src, /* the xImage Handle. */
|
||||
int *x,int *y,int *w, int *h /* x,y,w,h - addresses for offsets and dimensions. */
|
||||
);
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_IsXImageKeyFrame
|
||||
@Description Check keyframe status of current image.
|
||||
Use DXL_AlterXImageData to set the current frame and the use this call to detect keyframe status.
|
||||
@Return value return 1 if this xImage is a keyFrame, 0 if not a keyframe.
|
||||
@*/
|
||||
int DXL_IsXImageKeyFrame(
|
||||
DXL_XIMAGE_HANDLE src /* handle to compressed image */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_dxImageToVScreen
|
||||
@Description Decompress and blit as a single process, according to current source and destination attributes.
|
||||
Passing 0 can be used to skip a blit in order to reduce CPU load as needed (synchronization).
|
||||
@Return value DXL_OK on success. 1 means place-holder frame. Negative means error.
|
||||
@*/
|
||||
int DXL_dxImageToVScreen(
|
||||
DXL_XIMAGE_HANDLE xImage, /* Handle to compresse image source (xImage). */
|
||||
DXL_VSCREEN_HANDLE dst /* Handle to destination surface (vScreen). Null means decompress without blit. */
|
||||
);
|
||||
|
||||
|
||||
/* compatibility check prior between
|
||||
decompressor and destination */
|
||||
int DXL_CheckdxImageToVScreen(
|
||||
DXL_XIMAGE_HANDLE src,
|
||||
DXL_VSCREEN_HANDLE dst
|
||||
);
|
||||
|
||||
/* blit from xImage internal "working area" to vScreen */
|
||||
int DXL_BlitXImageToVScreen(
|
||||
DXL_XIMAGE_HANDLE src,
|
||||
DXL_VSCREEN_HANDLE dst
|
||||
);
|
||||
|
||||
/* vscreen management functions */
|
||||
|
||||
/*@
|
||||
@Name DXL_CreateVScreen
|
||||
@Description Create a virtual screen for rendering, storing decompressed video.
|
||||
@Return value returns a DXL_VSCREEN_HANDLE, or null if none available.
|
||||
@*/
|
||||
DXL_VSCREEN_HANDLE DXL_CreateVScreen(
|
||||
unsigned char *addr, /* The address where pixel data should be written */
|
||||
dxvBitDepth colorMode, /* Determines the colorspace and color depth of VScreen */
|
||||
short bytePitch, /* Offset from one raster to the next measured in bytes. */
|
||||
short height /* Number of rasters in a VScreen */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_AlterVScreen
|
||||
@Description Alter address and attributes associated with a vscreen.
|
||||
@Return value 0 for success or negatibe error code.
|
||||
@*/
|
||||
int DXL_AlterVScreen(
|
||||
DXL_VSCREEN_HANDLE dst, /* handle to a VScreen */
|
||||
unsigned char *addr, /* The address where pixel data should be written, or null for no change. */
|
||||
dxvBitDepth colorMode, /* Determines the colorspace and color depth of VScreen, or -1 for no change. */
|
||||
int bytePitch, /* offset from one raster to the next measured in bytes, or 0 for no change. */
|
||||
int height /* number of rasters in a VScreen, or 0 for no change. */
|
||||
);
|
||||
|
||||
|
||||
void DXL_VScreenSetInfoDotsFlag(DXL_VSCREEN_HANDLE vScreen, int showDots);
|
||||
|
||||
|
||||
/* alter clipping rectangle of vScreen */
|
||||
/* not supported by all decompressors */
|
||||
int DXL_AlterVScreenClip(
|
||||
DXL_VSCREEN_HANDLE dst,
|
||||
int x,int y,
|
||||
int w,int h
|
||||
);
|
||||
|
||||
/* alter viewport rectangle of vScreen */
|
||||
/* width/height not supported by all decompressors */
|
||||
int DXL_AlterVScreenView(
|
||||
DXL_VSCREEN_HANDLE dst,
|
||||
int x,int y,
|
||||
int w,int h
|
||||
);
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_DestroyVScreen
|
||||
@Description Destroy a vScreen object/struct.
|
||||
@Return value None
|
||||
@*/
|
||||
void DXL_DestroyVScreen(
|
||||
DXL_VSCREEN_HANDLE dst /* handle to virtual screen destination */
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_SetVScreenBlitQuality
|
||||
@Description set blit-quality of a vScreen same (normal), stretch (black lined)
|
||||
stretch bright (stretched w/interpolation)
|
||||
@Return value return prior blit-quality value.
|
||||
@*/
|
||||
int DXL_SetVScreenBlitQuality(
|
||||
DXL_VSCREEN_HANDLE dest, /* handle to vScreen */
|
||||
dxvBlitQuality bq /* new blit-quality value */
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/*@
|
||||
@Name DXL_GetVScreenBlitQuality
|
||||
@Description Get vScreens current blit-quality. Blit-quality determines if and how stretching should occur during the blit.
|
||||
@Return value returns member of enum called dxvBlitQuality, blit-quality value.
|
||||
BLIT_SAME is direct transfer; BLIT_STRETCH does double wide pixels and raster skipping; BLIT_STRETCH_BRIGHT stretches in both horizontal and vertical directions.
|
||||
@*/
|
||||
dxvBlitQuality DXL_GetVScreenBlitQuality(
|
||||
DXL_VSCREEN_HANDLE /* handle to vScreen. */
|
||||
);
|
||||
|
||||
|
||||
|
||||
/* alter spite background associated with a vscreen */
|
||||
/* used only by SegaSaturn for hardware sprite support */
|
||||
int DXL_AlterVScreenBackground(
|
||||
DXL_VSCREEN_HANDLE ,
|
||||
unsigned char *,
|
||||
dxvBitDepth bd ,int ,int ,int ,int
|
||||
);
|
||||
|
||||
/* set DOS VESA mode for vScreen (DOS only) */
|
||||
int DXL_AlterVScreenVESAMode(
|
||||
DXL_VSCREEN_HANDLE ,
|
||||
int vesaMode
|
||||
);
|
||||
|
||||
/* set physical screen to vScreen's vesa mode */
|
||||
int DXL_ActivateVScreenVESAMode(DXL_VSCREEN_HANDLE);
|
||||
|
||||
/* get vScreen (generally physical) vesa mode */
|
||||
int DXL_GetVScreenVESAMode(DXL_VSCREEN_HANDLE );
|
||||
|
||||
|
||||
/* copy one vScreen to another */
|
||||
/* provides support for offscreen compositing,
|
||||
16 bit and 8 bit modes only */
|
||||
int DXL_BlitVScreenToVScreen(
|
||||
DXL_VSCREEN_HANDLE fromVScreen,
|
||||
DXL_VSCREEN_HANDLE toVScreen
|
||||
);
|
||||
|
||||
/* get attributes of the vScreen */
|
||||
int DXL_GetVScreenAttributes(
|
||||
DXL_VSCREEN_HANDLE vScreen,
|
||||
void **addr,
|
||||
dxvBlitQuality *bq,
|
||||
dxvBitDepth *bd,
|
||||
short *pitch,
|
||||
short *height
|
||||
);
|
||||
|
||||
char *DXL_GetXImageStats(DXL_XIMAGE_HANDLE xImage,char *storage);
|
||||
|
||||
|
||||
/* get vScreen's current viewport rectangle
|
||||
a viewport represents an x,y, offset and
|
||||
a clipping width and height */
|
||||
int DXL_GetVScreenView(
|
||||
DXL_VSCREEN_HANDLE dst,
|
||||
int *x,int *y,int *w,int *h
|
||||
);
|
||||
|
||||
/* get vScreen's current clipping rectangle */
|
||||
int DXL_GetVScreenClip(
|
||||
DXL_VSCREEN_HANDLE dst,
|
||||
int *x,int *y,int *w,int *h
|
||||
);
|
||||
|
||||
/* provide Color lookup tables for 8 bit support */
|
||||
int DXL_SetVScreenCLUTs(
|
||||
DXL_VSCREEN_HANDLE vScr,
|
||||
unsigned char *clpt,
|
||||
unsigned char *clpt2,
|
||||
int exp
|
||||
);
|
||||
|
||||
/* return the palette currently used */
|
||||
int DXL_GetBitDepthPalette(dxvBitDepth colorMode,
|
||||
unsigned char **pal);
|
||||
|
||||
/* relinquish color lookup table structures */
|
||||
void DXL_ResetVScreenCLUTs(
|
||||
DXL_VSCREEN_HANDLE vScr
|
||||
);
|
||||
|
||||
/* check to see if a blit mode is supported */
|
||||
|
||||
int DXL_CheckVScreenBlit(DXL_VSCREEN_HANDLE dst,unsigned long fourcc);
|
||||
int DXL_CheckVScreenXImageBlit(DXL_VSCREEN_HANDLE dst,DXL_XIMAGE_HANDLE src);
|
||||
|
||||
|
||||
|
||||
/* windows 95 dll system abstraction functions */
|
||||
|
||||
/* set memory allocator function */
|
||||
void DXV_Setmalloc(
|
||||
void *(*mallocFuncPtr)(unsigned int size)
|
||||
);
|
||||
|
||||
/* set cleared memory allocator function */
|
||||
void DXV_Setcalloc(
|
||||
void *(*callocFuncPtr)(unsigned int size, unsigned int number)
|
||||
);
|
||||
|
||||
/*set memory free function */
|
||||
void DXV_Setfree(
|
||||
void (*freeFuncPtr)(void *)
|
||||
);
|
||||
|
||||
/* pass a parameter to the decompressor */
|
||||
void DXL_SetParameter(
|
||||
DXL_XIMAGE_HANDLE src,
|
||||
int Command,
|
||||
unsigned long Parameter
|
||||
);
|
||||
|
||||
/* can only have a max of 32 cpu specific features */
|
||||
typedef enum tCPU_FEATURES
|
||||
{
|
||||
NO_FEATURES = 0,
|
||||
MMX_SUPPORTED = 1
|
||||
} CPU_FEATURES;
|
||||
|
||||
CPU_FEATURES DXL_GetCPUFeatures(void);
|
||||
unsigned long DXL_GetXImageFOURCC(DXL_XIMAGE_HANDLE src);
|
||||
|
||||
|
||||
/* pass a parameter to the decompressor */
|
||||
void DXL_SetParameter(
|
||||
DXL_XIMAGE_HANDLE src,
|
||||
int Command,
|
||||
unsigned long Parameter
|
||||
);
|
||||
|
||||
|
||||
|
||||
/* Temporary hack to dxv to allow calls to get info (jbb) */
|
||||
typedef struct tFrameInfo
|
||||
{
|
||||
int KeyFrame;
|
||||
int Version;
|
||||
int Quality;
|
||||
int vp30Flag;
|
||||
} FrameInfo;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* define this in case we need to interogate before bailing out */
|
||||
typedef struct bmiChunk_t
|
||||
{
|
||||
unsigned long biCompression;
|
||||
unsigned char biBitCount;
|
||||
unsigned char biPlanes;
|
||||
dxvBitDepth bd;
|
||||
|
||||
} BMIMapping;
|
||||
|
||||
|
||||
extern BMIMapping DXL_BMIMap[];
|
||||
|
||||
|
||||
#if !defined(DXL_MKFOURCC)
|
||||
#define DXL_MKFOURCC( ch0, ch1, ch2, ch3 ) \
|
||||
( (unsigned long)(unsigned char)(ch0) | ( (unsigned long)(unsigned char)(ch1) << 8 ) | \
|
||||
( (unsigned long)(unsigned char)(ch2) << 16 ) | ( (unsigned long)(unsigned char)(ch3) << 24 ) )
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* src xImage must actually be a DXL_CODEC_HANDLE */
|
||||
/* you will need a dxvvfw.lib in order to utilize this prototype for now */
|
||||
int DXL_ReportBestBMIMatch(DXL_XIMAGE_HANDLE src, BMIMapping** map, int *maxMaps, int doConsoleReport);
|
||||
|
||||
/* have DXV print DXV/ICM mapping to HTML table */
|
||||
void DXL_ReportBMIMapping(char *filename);
|
||||
|
||||
|
||||
|
||||
|
||||
void vp31_GetInfo(unsigned char * source, FrameInfo * frameInfo);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* include guards */
|
202
Src/libvp6/include/endian.hpp
Normal file
202
Src/libvp6/include/endian.hpp
Normal file
|
@ -0,0 +1,202 @@
|
|||
#if !defined(ENDIAN_HPP)
|
||||
#define ENDIAN_HPP
|
||||
//______________________________________________________________________________
|
||||
//
|
||||
// endian.hpp
|
||||
// Facilitate endian conversions.
|
||||
|
||||
//namespace xxx
|
||||
//{
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
bool big_endian()
|
||||
{
|
||||
long lTest = 1;
|
||||
|
||||
return (reinterpret_cast<char*>(&lTest)[0] == 0);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
short swap_endian(short i16)
|
||||
{
|
||||
return i16 << 8 & 0xff00
|
||||
| i16 >> 8 & 0x00ff;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
unsigned short swap_endian(unsigned short ui16)
|
||||
{
|
||||
return ui16 << 8 & 0xff00
|
||||
| ui16 >> 8 & 0x00ff;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
unsigned int swap_endian(unsigned int i32)
|
||||
{
|
||||
return i32 << 24 & 0xff000000
|
||||
| i32 << 8 & 0x00ff0000
|
||||
| i32 >> 8 & 0x0000ff00
|
||||
| i32 >> 24 & 0x000000ff;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
int swap_endian(int ui32)
|
||||
{
|
||||
return ui32 << 24 & 0xff000000
|
||||
| ui32 << 8 & 0x00ff0000
|
||||
| ui32 >> 8 & 0x0000ff00
|
||||
| ui32 >> 24 & 0x000000ff;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
short big_endian(short i16Native)
|
||||
{
|
||||
if (big_endian())
|
||||
{
|
||||
return i16Native;
|
||||
}
|
||||
|
||||
return swap_endian(i16Native);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
unsigned short big_endian(unsigned short ui16Native)
|
||||
{
|
||||
if (big_endian())
|
||||
{
|
||||
return ui16Native;
|
||||
}
|
||||
|
||||
return swap_endian(ui16Native);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
unsigned int big_endian(unsigned int i32Native)
|
||||
{
|
||||
if (big_endian())
|
||||
{
|
||||
return i32Native;
|
||||
}
|
||||
|
||||
return swap_endian(i32Native);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
int big_endian(int ui32Native)
|
||||
{
|
||||
if (big_endian())
|
||||
{
|
||||
return ui32Native;
|
||||
}
|
||||
|
||||
return swap_endian(ui32Native);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
short little_endian(short i16Native)
|
||||
{
|
||||
if (!big_endian())
|
||||
{
|
||||
return i16Native;
|
||||
}
|
||||
|
||||
return swap_endian(i16Native);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
unsigned short little_endian(unsigned short ui16Native)
|
||||
{
|
||||
if (!big_endian())
|
||||
{
|
||||
return ui16Native;
|
||||
}
|
||||
|
||||
return swap_endian(ui16Native);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
unsigned int little_endian(unsigned int i32Native)
|
||||
{
|
||||
if (!big_endian())
|
||||
{
|
||||
return i32Native;
|
||||
}
|
||||
|
||||
return swap_endian(i32Native);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
int little_endian(int ui32Native)
|
||||
{
|
||||
if (!big_endian())
|
||||
{
|
||||
return ui32Native;
|
||||
}
|
||||
|
||||
return swap_endian(ui32Native);
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
short native_endian(short i16, bool bBigEndian)
|
||||
{
|
||||
if (big_endian() != bBigEndian)
|
||||
{
|
||||
return swap_endian(i16);
|
||||
}
|
||||
|
||||
return i16;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
unsigned short native_endian(unsigned short ui16, bool bBigEndian)
|
||||
{
|
||||
if (big_endian() != bBigEndian)
|
||||
{
|
||||
return swap_endian(ui16);
|
||||
}
|
||||
|
||||
return ui16;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
unsigned int native_endian(unsigned int i32, bool bBigEndian)
|
||||
{
|
||||
if (big_endian() != bBigEndian)
|
||||
{
|
||||
return swap_endian(i32);
|
||||
}
|
||||
|
||||
return i32;
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
inline
|
||||
int native_endian(int ui32, bool bBigEndian)
|
||||
{
|
||||
if (big_endian() != bBigEndian)
|
||||
{
|
||||
return swap_endian(ui32);
|
||||
}
|
||||
|
||||
return ui32;
|
||||
}
|
||||
|
||||
//} // namespace xxx
|
||||
|
||||
#endif // ENDIAN_HPP
|
25
Src/libvp6/include/littlend.h
Normal file
25
Src/libvp6/include/littlend.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef _littlend_h
|
||||
#define _littlend_h
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define invert2(x) (x)
|
||||
#define invert4(x) (x)
|
||||
|
||||
#define lowByte(x) (unsigned char)x
|
||||
#define mid1Byte(x) (unsigned char)(x >> 8)
|
||||
#define mid2Byte(x) (unsigned char)(x >> 16)
|
||||
#define highByte(x) (unsigned char)(x >> 24)
|
||||
|
||||
#define SWAPENDS 0
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
49
Src/libvp6/include/on2cmp.h
Normal file
49
Src/libvp6/include/on2cmp.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef ON2CMP_H
|
||||
#define ON2CMP_H
|
||||
//*********************************************************************
|
||||
// name : on2comp.h
|
||||
// desc : Stand-alone command line compression application
|
||||
// that takes as input rvd files that are in planar yv12 format
|
||||
// and produces as output one ore more files that contain one or
|
||||
// more vp31 compressed video streams, as determined by command
|
||||
// line parameters.
|
||||
// date : 04/21/00
|
||||
// Who : Jim Bankoski
|
||||
// Mods :
|
||||
// Sep 21 2000 Reworked entire structure to be cleaner and more modular
|
||||
//*********************************************************************
|
||||
|
||||
#include <vector>
|
||||
|
||||
typedef int (*ProgressFunction)
|
||||
(
|
||||
int Frame,
|
||||
double SecondsWritten,
|
||||
double PercentComplete,
|
||||
int BytesWritten,
|
||||
std::vector<int> vBytesWritten,
|
||||
std::vector<int> vMinBufferSize
|
||||
);
|
||||
|
||||
class fileCompressor
|
||||
{
|
||||
public:
|
||||
enum fileCompressorType
|
||||
{
|
||||
VP31,
|
||||
VP40,
|
||||
VP50
|
||||
};
|
||||
|
||||
virtual void compress (
|
||||
ProgressFunction pf,
|
||||
int updateEvery,
|
||||
int argc,
|
||||
char* argv[],
|
||||
int outFileType) = 0;
|
||||
|
||||
virtual ~fileCompressor();
|
||||
static fileCompressor* Make(fileCompressorType);
|
||||
};
|
||||
|
||||
#endif // ON2CMP_H
|
58
Src/libvp6/include/on2vpplugin.h
Normal file
58
Src/libvp6/include/on2vpplugin.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
#ifndef ON2VPPLUGIN_H
|
||||
#define ON2VPPLUGIN_H
|
||||
|
||||
#ifdef ON2VPPLUGIN_EXPORTS
|
||||
#define ON2VPPLUGIN_API __declspec(dllexport) WINAPI
|
||||
#else
|
||||
#define ON2VPPLUGIN_API __declspec(dllimport) WINAPI
|
||||
#endif
|
||||
|
||||
|
||||
BOOL ON2VPPLUGIN_API ON2Info(DWORD fccType, DWORD fccHandler, ICINFO FAR * lpicinfo);
|
||||
BOOL ON2VPPLUGIN_API ON2Install(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDesc, UINT wFlags);
|
||||
BOOL ON2VPPLUGIN_API ON2Remove(DWORD fccType, DWORD fccHandler, UINT wFlags);
|
||||
LRESULT ON2VPPLUGIN_API ON2GetInfo(HIC hic, ICINFO FAR *picinfo, DWORD cb);
|
||||
HIC ON2VPPLUGIN_API ON2Open(DWORD fccType, DWORD fccHandler, UINT wMode);
|
||||
HIC ON2VPPLUGIN_API ON2OpenFunction(DWORD fccType, DWORD fccHandler, UINT wMode, FARPROC lpfnHandler);
|
||||
LRESULT ON2VPPLUGIN_API ON2Close(HIC hic);
|
||||
LRESULT ON2VPPLUGIN_API ON2SendMessage(HIC hic, UINT msg, DWORD dw1, DWORD dw2);;
|
||||
LRESULT ON2VPPLUGIN_API ON2QueryAbout(HIC hic) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2About(HIC hic, HWND hwnd) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2QueryConfigure(HIC hic) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2Configure(HIC hic, HWND hwnd) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2GetState(HIC hic, LPVOID pv, DWORD cb) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2SetState(HIC hic, LPVOID pv, DWORD cb) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2GetStateSize(HIC hic) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2GetDefaultQuality(HIC hic) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2GetDefaultKeyFrameRate(HIC hic) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2CompressBegin(HIC hic, BITMAPINFO *lpbiInput, BITMAPINFO *lpbiOutput) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2CompressQuery(HIC hic, BITMAPINFO *lpbiInput, BITMAPINFO *lpbiOutput) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2CompressGetFormat(HIC hic, BITMAPINFO *lpbiInput, BITMAPINFO *lpbiOutput) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2CompressGetFormatSize(HIC hic, BITMAPINFO *lpbi) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2CompressGetSize(HIC hic, BITMAPINFO *lpbiInput, BITMAPINFO *lpbiOutput) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2CompressEnd(HIC hic) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressBegin(HIC hic, BITMAPINFO *lpbiInput, BITMAPINFO *lpbiOutput) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressQuery(HIC hic, BITMAPINFO *lpbiInput, BITMAPINFO *lpbiOutput) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressGetFormat(HIC hic, BITMAPINFO *lpbiInput, BITMAPINFO *lpbiOutput) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressGetFormatSize(HIC hic, BITMAPINFO *lpbi) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressGetPalette(HIC hic, BITMAPINFO *lpbiInput, BITMAPINFO *lpbiOutput) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressSetPalette(HIC hic, BITMAPINFO *lpbiPalette) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressEnd(HIC hic) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressExEnd(HIC hic) ;
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressEx(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiSrc,LPVOID lpSrc,int xSrc,int ySrc,int dxSrc,int dySrc,LPBITMAPINFOHEADER lpbiDst,LPVOID lpDst,int xDst,int yDst,int dxDst,int dyDst);
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressExBegin(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiSrc,LPVOID lpSrc,int xSrc,int ySrc,int dxSrc,int dySrc,LPBITMAPINFOHEADER lpbiDst,LPVOID lpDst,int xDst,int yDst,int dxDst,int dyDst);
|
||||
LRESULT ON2VPPLUGIN_API ON2DecompressExQuery(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiSrc,LPVOID lpSrc,int xSrc,int ySrc,int dxSrc,int dySrc,LPBITMAPINFOHEADER lpbiDst,LPVOID lpDst,int xDst,int yDst,int dxDst,int dyDst);
|
||||
HIC ON2VPPLUGIN_API ON2Open(DWORD fccType, DWORD fccHandler, UINT wMode);
|
||||
LRESULT ON2VPPLUGIN_API ON2Close(HIC hic);
|
||||
DWORD ON2VPPLUGIN_API ON2Decompress(HIC hic,DWORD dwFlags, LPBITMAPINFOHEADER lpbiInput, LPVOID lpInput, LPBITMAPINFOHEADER lpbiOutput,LPVOID lpOutput);
|
||||
DWORD ON2VPPLUGIN_API ON2Compress(HIC hic,DWORD dwFlags,LPBITMAPINFOHEADER lpbiOutput,LPVOID lpOutput,LPBITMAPINFOHEADER lpbiInput,LPVOID lpInput,LPDWORD lpckid,LPDWORD lpdwFlags,LONG lFrameNum,DWORD dwFrameSize,DWORD dwQuality,LPBITMAPINFOHEADER lpbiPrev,LPVOID lpPrev);
|
||||
LRESULT ON2VPPLUGIN_API ON2SendMessage(HIC hic, UINT msg, DWORD dw1, DWORD dw2);
|
||||
LRESULT ON2VPPLUGIN_API ON2SetReference(HIC hic, LPBITMAPINFO lpbiInput, char * buffer);
|
||||
LRESULT ON2VPPLUGIN_API ON2SetRecoveryFrame(HIC hic);
|
||||
LRESULT ON2VPPLUGIN_API ON2SetInternalSize(HIC hic,int wr, int ws, int hr, int hs );
|
||||
LRESULT ON2VPPLUGIN_API ON2SendMessage(HIC hic, UINT msg, DWORD dw1, DWORD dw2);
|
||||
LRESULT ON2VPPLUGIN_API ON2GetReference(HIC hic, LPBITMAPINFO lpbiInput, char * buffer);
|
||||
LRESULT ON2VPPLUGIN_API ON2SetCPUFree(HIC hic, int cpuFree);
|
||||
|
||||
|
||||
#endif
|
75
Src/libvp6/include/type_aliases.h
Normal file
75
Src/libvp6/include/type_aliases.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Module Title : type_aliases.h
|
||||
*
|
||||
* Description : Standard type aliases
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __INC_TYPE_ALIASES_H
|
||||
#define __INC_TYPE_ALIASES_H
|
||||
|
||||
/****************************************************************************
|
||||
* Macros
|
||||
****************************************************************************/
|
||||
#define EXPORT
|
||||
#define IMPORT extern /* Used to declare imported data & routines */
|
||||
#define PRIVATE static /* Used to declare & define module-local data */
|
||||
#define LOCAL static /* Used to define all persistent routine-local data */
|
||||
#define STD_IN_PATH 0 /* Standard input path */
|
||||
#define STD_OUT_PATH 1 /* Standard output path */
|
||||
#define STD_ERR_PATH 2 /* Standard error path */
|
||||
#define STD_IN_FILE stdin /* Standard input file pointer */
|
||||
#define STD_OUT_FILE stdout /* Standard output file pointer */
|
||||
#define STD_ERR_FILE stderr /* Standard error file pointer */
|
||||
#define MAX_int 0x7FFFFFFF
|
||||
|
||||
#define __export
|
||||
#define _export
|
||||
|
||||
#define CCONV
|
||||
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Typedefs
|
||||
****************************************************************************/
|
||||
#ifndef TYPE_INT8
|
||||
#define TYPE_INT8
|
||||
typedef signed char INT8;
|
||||
#endif
|
||||
|
||||
typedef signed short INT16;
|
||||
typedef signed int INT32;
|
||||
|
||||
typedef unsigned char UINT8;
|
||||
typedef unsigned int UINT32;
|
||||
typedef unsigned short UINT16;
|
||||
|
||||
typedef int BOOL;
|
||||
typedef unsigned char BOOLEAN;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef __int64 INT64;
|
||||
#else
|
||||
typedef long long INT64;
|
||||
#endif
|
||||
|
||||
/* Floating point */
|
||||
typedef double FLOAT64;
|
||||
typedef float FLOAT32;
|
||||
|
||||
#endif
|
54
Src/libvp6/include/vp50/comp_interface.h
Normal file
54
Src/libvp6/include/vp50/comp_interface.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
#if !defined(COMP_INTERFACE_H)
|
||||
#define COMP_INTERFACE_H
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : COMP_INTERFACE.H
|
||||
*
|
||||
* Description : Interface to video codec demo compressor DLL
|
||||
*
|
||||
* AUTHOR : Paul Wilkins
|
||||
*
|
||||
*****************************************************************************
|
||||
* Revision History
|
||||
*
|
||||
* 1.04 JBB 26 AUG 00 JBB Added fixed q setting
|
||||
* 1.03 PGW 07/12/99 Retro fit JBB changes
|
||||
* 1.02 PGW 16/09/99 Interface changes to simplify things for command line
|
||||
* compressor.
|
||||
* 1.01 PGW 07/07/99 Added COMP_CONFIG.
|
||||
* 1.00 PGW 28/06/99 New configuration baseline
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
// C4514 Unreferenced inline function has been removed
|
||||
#pragma warning(disable: 4514)
|
||||
|
||||
#include "codec_common_interface.h"
|
||||
#include "type_aliases.h"
|
||||
#include "vp50_comp_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
typedef struct CP_INSTANCE * xCP_INST;
|
||||
extern BOOL CCONV StartEncoder( xCP_INST *cpi, COMP_CONFIG_VP5 * CompConfig );
|
||||
extern void CCONV ChangeCompressorSetting ( xCP_INST cpi, C_SETTING Setting, int Value );
|
||||
extern void CCONV ChangeEncoderConfig ( xCP_INST cpi, COMP_CONFIG_VP5 * CompConfig );
|
||||
extern UINT32 CCONV EncodeFrame( xCP_INST cpi, unsigned char * InBmpIPtr, unsigned char * InBmpPtr, unsigned char * OutPutPtr, unsigned int * is_key );
|
||||
extern UINT32 CCONV EncodeFrameYuv( xCP_INST cpi, YUV_INPUT_BUFFER_CONFIG * YuvInputData, unsigned char * OutPutPtr, unsigned int * is_key );
|
||||
extern BOOL CCONV StopEncoder( xCP_INST *cpi);
|
||||
extern void VPEInitLibrary(void);
|
||||
extern void VPEDeInitLibrary(void);
|
||||
extern const char * CCONV VP50E_GetVersionNumber(void);
|
||||
extern UINT32 CCONV VPGetState(xCP_INST cpi, void * ret);
|
||||
extern void CCONV VPSetState(xCP_INST cpi, void * ret);
|
||||
extern int CCONV VPGetPB(xCP_INST cpi);
|
||||
#ifdef __cplusplus
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
66
Src/libvp6/include/vp50/vfw_pb_interface.h
Normal file
66
Src/libvp6/include/vp50/vfw_pb_interface.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Module Title : VFW_PB_INTERFACE.H
|
||||
*
|
||||
* Description : Interface to video codec demo decompressor DLL
|
||||
*
|
||||
* AUTHOR : Paul Wilkins
|
||||
*
|
||||
*****************************************************************************
|
||||
* Revision History
|
||||
*
|
||||
* 1.03 YWX 17/Dec/02 Added enum for setup DeInteralcedMode
|
||||
* 1.02 JBB 25 AUG 00 Versioning
|
||||
* 1.01 PGW 29/06/99 Interface to DecodeFrame() changed.
|
||||
* 1.00 PGW 07/06/99 Baseline code.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef VFW_PB_INTERFACE
|
||||
#define VFW_PB_INTERFACE
|
||||
|
||||
#include "codec_common_interface.h"
|
||||
|
||||
#include "type_aliases.h"
|
||||
typedef struct PB_INSTANCE * xPB_INST;
|
||||
//#include "pbdll.h"
|
||||
|
||||
|
||||
// Settings Control
|
||||
typedef enum
|
||||
{
|
||||
PBC_SET_POSTPROC,
|
||||
PBC_SET_CPUFREE,
|
||||
PBC_MAX_PARAM,
|
||||
PBC_SET_TESTMODE,
|
||||
PBC_SET_PBSTRUCT,
|
||||
PBC_SET_BLACKCLAMP,
|
||||
PBC_SET_WHITECLAMP,
|
||||
PBC_SET_REFERENCEFRAME,
|
||||
PBC_SET_DEINTERLACEMODE
|
||||
|
||||
} PB_COMMAND_TYPE;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern BOOL CCONV VP5_StartDecoder( xPB_INST *pbi, UINT32 ImageWidth, UINT32 ImageHeight );
|
||||
extern void CCONV VP5_GetPbParam( xPB_INST, PB_COMMAND_TYPE Command, UINT32 *Parameter );
|
||||
extern void CCONV VP5_SetPbParam( xPB_INST, PB_COMMAND_TYPE Command, UINT32 Parameter );
|
||||
extern void CCONV VP5_GetYUVConfig( xPB_INST, YUV_BUFFER_CONFIG * YuvConfig );
|
||||
extern const char * CCONV VP31D_GetVersionNumber(void);
|
||||
|
||||
extern int CCONV VP5_DecodeFrameToYUV( xPB_INST, char * VideoBufferPtr, unsigned int ByteCount,
|
||||
UINT32 ImageWidth, UINT32 ImageHeight );
|
||||
extern BOOL CCONV VP5_StopDecoder(xPB_INST *pbi);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
138
Src/libvp6/include/vp50/vp50_comp_interface.h
Normal file
138
Src/libvp6/include/vp50/vp50_comp_interface.h
Normal file
|
@ -0,0 +1,138 @@
|
|||
#if !defined(VP50_COMP_INTERFACE_H)
|
||||
#define VP50_COMP_INTERFACE_H
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : VFW_COMP_INTERFACE.H
|
||||
*
|
||||
* Description : Interface to video codec demo compressor DLL
|
||||
*
|
||||
* AUTHOR : Paul Wilkins
|
||||
*
|
||||
*****************************************************************************
|
||||
* Revision History
|
||||
*
|
||||
* 1.04 JBB 26 AUG 00 JBB Added fixed q setting
|
||||
* 1.03 PGW 07/12/99 Retro fit JBB changes
|
||||
* 1.02 PGW 16/09/99 Interface changes to simplify things for command line
|
||||
* compressor.
|
||||
* 1.01 PGW 07/07/99 Added COMP_CONFIG.
|
||||
* 1.00 PGW 28/06/99 New configuration baseline
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
// C4514 Unreferenced inline function has been removed
|
||||
#ifndef MACPPC
|
||||
#pragma warning(disable: 4514)
|
||||
#endif
|
||||
|
||||
#include "codec_common_interface.h"
|
||||
#include "type_aliases.h"
|
||||
|
||||
/* Command interface to compressor. */
|
||||
/* Settings Control */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT32 FrameSize;
|
||||
UINT32 TargetBitRate;
|
||||
UINT32 FrameRate;
|
||||
UINT32 KeyFrameFrequency;
|
||||
UINT32 KeyFrameDataTarget;
|
||||
UINT32 Quality;
|
||||
BOOL AllowDF;
|
||||
BOOL QuickCompress;
|
||||
BOOL AutoKeyFrameEnabled;
|
||||
INT32 AutoKeyFrameThreshold;
|
||||
UINT32 MinimumDistanceToKeyFrame;
|
||||
INT32 ForceKeyFrameEvery;
|
||||
INT32 NoiseSensitivity;
|
||||
BOOL AllowSpatialResampling;
|
||||
|
||||
// The Intended Horizontal Scale
|
||||
UINT32 HScale;
|
||||
UINT32 HRatio;
|
||||
|
||||
// The Intended Vertical Scale
|
||||
UINT32 VScale;
|
||||
UINT32 VRatio;
|
||||
|
||||
// The way in which we intended
|
||||
UINT32 ScalingMode;
|
||||
|
||||
// Interlaced (0) means no (1) means Yes
|
||||
UINT32 Interlaced;
|
||||
|
||||
BOOL FixedQ;
|
||||
|
||||
INT32 StartingBufferLevel; // The initial encoder buffer level
|
||||
INT32 OptimalBufferLevel; // The buffer level target we strive to reach / maintain.
|
||||
INT32 DropFramesWaterMark; // Buffer fullness watermark for forced drop frames.
|
||||
INT32 ResampleDownWaterMark; // Buffer fullness watermark for downwards spacial re-sampling
|
||||
INT32 ResampleUpWaterMark; // Buffer fullness watermark where returning to larger image size is consdered
|
||||
INT32 OutputFrameRate;
|
||||
INT32 Speed;
|
||||
|
||||
BOOL ErrorResilientMode; // compress using a mode that won't completely fall apart if we decompress using
|
||||
// the frame after a dropped frame
|
||||
|
||||
} COMP_CONFIG_VP5;
|
||||
|
||||
INLINE
|
||||
void comp_config_default_vp5(COMP_CONFIG_VP5* pcc)
|
||||
{
|
||||
pcc->FrameSize = 0; // No default value
|
||||
pcc->TargetBitRate = 300;
|
||||
pcc->FrameRate = 0; // No default value
|
||||
pcc->KeyFrameFrequency = 120;
|
||||
pcc->KeyFrameDataTarget = 0; // No default value
|
||||
pcc->Quality = 56;
|
||||
pcc->AllowDF = 0;
|
||||
pcc->QuickCompress = 1;
|
||||
pcc->AutoKeyFrameEnabled = 1;
|
||||
pcc->AutoKeyFrameThreshold = 80;
|
||||
pcc->MinimumDistanceToKeyFrame = 8;
|
||||
pcc->ForceKeyFrameEvery = 120;
|
||||
pcc->NoiseSensitivity = 0;
|
||||
pcc->AllowSpatialResampling = 0;
|
||||
pcc->HScale = 1;
|
||||
pcc->HRatio = 1;
|
||||
pcc->VScale = 1;
|
||||
pcc->VRatio = 1;
|
||||
pcc->ScalingMode = MAINTAIN_ASPECT_RATIO;
|
||||
pcc->Interlaced = 0;
|
||||
pcc->FixedQ = 0;
|
||||
|
||||
pcc->StartingBufferLevel = 6;
|
||||
pcc->OptimalBufferLevel = 10;
|
||||
pcc->DropFramesWaterMark = 20;
|
||||
pcc->ResampleDownWaterMark = 35;
|
||||
pcc->ResampleUpWaterMark = 45;
|
||||
|
||||
pcc->OutputFrameRate = 30;
|
||||
pcc->Speed = 12;
|
||||
pcc->ErrorResilientMode = FALSE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef YUVINPUTBUFFERCONFIG
|
||||
#define YUVINPUTBUFFERCONFIG
|
||||
typedef struct
|
||||
{
|
||||
int YWidth;
|
||||
int YHeight;
|
||||
int YStride;
|
||||
|
||||
int UVWidth;
|
||||
int UVHeight;
|
||||
int UVStride;
|
||||
|
||||
char * YBuffer;
|
||||
char * UBuffer;
|
||||
char * VBuffer;
|
||||
|
||||
} YUV_INPUT_BUFFER_CONFIG;
|
||||
#endif
|
||||
|
||||
#endif
|
1
Src/libvp6/include/vp50dversion.h
Normal file
1
Src/libvp6/include/vp50dversion.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define VP50DVERSION "5.0.12.0"
|
13
Src/libvp6/include/vp6.h
Normal file
13
Src/libvp6/include/vp6.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
#include "duck_dxl.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int vp60_decompress(DXL_XIMAGE_HANDLE src);
|
||||
void vp60_SetParameter(DXL_XIMAGE_HANDLE src, int Command, uintptr_t Parameter);
|
||||
int vp60_getWH(DXL_XIMAGE_HANDLE src, int *w, int *h);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
55
Src/libvp6/include/vp60/comp_interface.h
Normal file
55
Src/libvp6/include/vp60/comp_interface.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Module Title : comp_interface.h
|
||||
*
|
||||
* Description : Interface to video codec demo compressor DLL
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __INC_COMP_INTERFACE_H
|
||||
#define __INC_COMP_INTERFACE_H
|
||||
|
||||
/****************************************************************************
|
||||
* Include Files
|
||||
****************************************************************************/
|
||||
#include "type_aliases.h"
|
||||
#include "codec_common_interface.h"
|
||||
#include "vp60_comp_interface.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Macros
|
||||
****************************************************************************/
|
||||
// C4514 Unreferenced inline function has been removed
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4514)
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Typedefs
|
||||
****************************************************************************/
|
||||
typedef struct CP_INSTANCE * xCP_INST;
|
||||
|
||||
/****************************************************************************
|
||||
* Exports
|
||||
****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern BOOL CCONV StartEncoder ( xCP_INST *cpi, COMP_CONFIG_VP6 *CompConfig );
|
||||
extern void CCONV ChangeCompressorSetting ( xCP_INST cpi, C_SETTING Setting, int Value );
|
||||
extern void CCONV ChangeEncoderConfig ( xCP_INST cpi, COMP_CONFIG_VP6 *CompConfig );
|
||||
extern UINT32 CCONV EncodeFrame ( xCP_INST cpi, unsigned char *InBmpIPtr, unsigned char *InBmpPtr, unsigned char *OutPutPtr, unsigned int *is_key );
|
||||
extern UINT32 CCONV EncodeFrameYuv ( xCP_INST cpi, YUV_INPUT_BUFFER_CONFIG *YuvInputData, unsigned char *OutPutPtr, unsigned int *is_key );
|
||||
extern BOOL CCONV StopEncoder ( xCP_INST *cpi );
|
||||
extern void VPEInitLibrary ( void );
|
||||
extern void VPEDeInitLibrary ( void );
|
||||
extern const char *CCONV VP50E_GetVersionNumber ( void );
|
||||
extern UINT32 CCONV VPGetState ( xCP_INST cpi, void *ret );
|
||||
extern void CCONV VPSetState ( xCP_INST cpi, void *ret );
|
||||
extern int CCONV VPGetPB ( xCP_INST cpi );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
62
Src/libvp6/include/vp60/vfw_pb_interface.h
Normal file
62
Src/libvp6/include/vp60/vfw_pb_interface.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Module Title : vfw_pb_interface.h
|
||||
*
|
||||
* Description : Codec interface specification header file.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __INC_VFW_PB_INTERFACE
|
||||
#define __INC_VFW_PB_INTERFACE
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include "codec_common_interface.h"
|
||||
#include "type_aliases.h"
|
||||
#ifdef __GNUC__
|
||||
#include <inttypes.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Typedefs
|
||||
****************************************************************************/
|
||||
typedef struct PB_INSTANCE * xPB_INST;
|
||||
|
||||
// Settings Control
|
||||
typedef enum
|
||||
{
|
||||
PBC_SET_POSTPROC,
|
||||
PBC_SET_CPUFREE,
|
||||
PBC_MAX_PARAM,
|
||||
PBC_SET_TESTMODE,
|
||||
PBC_SET_PBSTRUCT,
|
||||
PBC_SET_BLACKCLAMP,
|
||||
PBC_SET_WHITECLAMP,
|
||||
PBC_SET_REFERENCEFRAME,
|
||||
PBC_SET_DEINTERLACEMODE,
|
||||
PBC_SET_ADDNOISE
|
||||
|
||||
} PB_COMMAND_TYPE;
|
||||
|
||||
/****************************************************************************
|
||||
* Exports
|
||||
****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern BOOL CCONV VP6_StartDecoder ( xPB_INST *pbi, UINT32 ImageWidth, UINT32 ImageHeight );
|
||||
extern void CCONV VP6_GetPbParam ( xPB_INST, PB_COMMAND_TYPE Command, UINT32 *Parameter );
|
||||
extern void CCONV VP6_SetPbParam ( xPB_INST, PB_COMMAND_TYPE Command, uintptr_t Parameter );
|
||||
extern void CCONV VP6_GetYUVConfig ( xPB_INST, YUV_BUFFER_CONFIG * YuvConfig );
|
||||
extern const char * CCONV VP31D_GetVersionNumber ( void );
|
||||
extern int CCONV VP6_DecodeFrameToYUV ( xPB_INST, char * VideoBufferPtr, unsigned int ByteCount);
|
||||
extern BOOL CCONV VP6_StopDecoder ( xPB_INST *pbi );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
211
Src/libvp6/include/vp60/vp60_comp_interface.h
Normal file
211
Src/libvp6/include/vp60/vp60_comp_interface.h
Normal file
|
@ -0,0 +1,211 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Module Title : vp60_comp_interface.h
|
||||
*
|
||||
* Description : Interface to VP60 compressor.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __INC_VP60_COMP_INTERFACE_H
|
||||
#define __INC_VP60_COMP_INTERFACE_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4514) // Disable warning 4514: Unreferenced inline function
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
****************************************************************************/
|
||||
#include "codec_common_interface.h"
|
||||
#include "type_aliases.h"
|
||||
#include "string.h"
|
||||
|
||||
#define DEFAULT_VALUE -999
|
||||
/****************************************************************************
|
||||
* Typedefs
|
||||
****************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
USAGE_STREAM_FROM_SERVER = 0x0, // INTER prediction, (0,0) motion vector implied.
|
||||
USAGE_LOCAL_FILE_PLAYBACK = 0x1 // INTER prediction, (0,0) motion vector implied.
|
||||
} END_USAGE;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MODE_REALTIME = 0x0,
|
||||
MODE_GOODQUALITY = 0x1,
|
||||
MODE_BESTQUALITY = 0x2,
|
||||
MODE_FIRSTPASS = 0x3,
|
||||
MODE_SECONDPASS = 0x4,
|
||||
MODE_SECONDPASS_BEST= 0x5
|
||||
} MODE;
|
||||
|
||||
|
||||
|
||||
/* Command interface to compressor */
|
||||
typedef struct
|
||||
{
|
||||
//UINT32 FourCC;
|
||||
//UINT32 ConfigVersion;
|
||||
UINT32 FrameSize;
|
||||
UINT32 TargetBitRate;
|
||||
UINT32 FrameRate;
|
||||
UINT32 KeyFrameFrequency;
|
||||
UINT32 KeyFrameDataTarget;
|
||||
UINT32 Quality;
|
||||
BOOL AllowDF;
|
||||
BOOL QuickCompress;
|
||||
BOOL AutoKeyFrameEnabled;
|
||||
INT32 AutoKeyFrameThreshold;
|
||||
UINT32 MinimumDistanceToKeyFrame;
|
||||
INT32 ForceKeyFrameEvery;
|
||||
INT32 NoiseSensitivity;
|
||||
BOOL AllowSpatialResampling;
|
||||
|
||||
// The Intended Horizontal Scale
|
||||
UINT32 HScale;
|
||||
UINT32 HRatio;
|
||||
|
||||
// The Intended Vertical Scale
|
||||
UINT32 VScale;
|
||||
UINT32 VRatio;
|
||||
|
||||
// The way in which we intended
|
||||
UINT32 ScalingMode;
|
||||
|
||||
// Interlaced (0) means no (1) means Yes
|
||||
UINT32 Interlaced;
|
||||
|
||||
BOOL FixedQ;
|
||||
|
||||
INT32 StartingBufferLevel; // The initial encoder buffer level
|
||||
INT32 OptimalBufferLevel; // The buffer level target we strive to reach / maintain.
|
||||
INT32 DropFramesWaterMark; // Buffer fullness watermark for forced drop frames.
|
||||
INT32 ResampleDownWaterMark; // Buffer fullness watermark for downwards spacial re-sampling
|
||||
INT32 ResampleUpWaterMark; // Buffer fullness watermark where returning to larger image size is consdered
|
||||
INT32 OutputFrameRate;
|
||||
INT32 Speed;
|
||||
|
||||
BOOL ErrorResilientMode; // compress using a mode that won't completely fall apart if we decompress using
|
||||
// the frame after a dropped frame
|
||||
INT32 Profile;
|
||||
|
||||
BOOL DisableGolden; // disable golden frame updates
|
||||
BOOL VBMode; // run in variable bandwidth 1 pass mode
|
||||
UINT32 BestAllowedQ; // best allowed quality ( save bits by disallowings frames that are too high quality )
|
||||
INT32 UnderShootPct; // target a percentage of the actual frame to allow for sections that go over
|
||||
|
||||
INT32 MaxAllowedDatarate; // maximum the datarate is allowed to go.
|
||||
INT32 MaximumBufferSize; // maximum buffer size.
|
||||
|
||||
BOOL TwoPassVBREnabled; // two pass variable bandwidth enabled
|
||||
INT32 TwoPassVBRBias; // how variable do we want to target?
|
||||
INT32 TwoPassVBRMaxSection; // maximum
|
||||
INT32 TwoPassVBRMinSection; // minimum
|
||||
INT32 Pass; // which pass of the compression are we running.
|
||||
|
||||
MODE Mode;
|
||||
END_USAGE EndUsage;
|
||||
|
||||
char FirstPassFile[512];
|
||||
char SettingsFile[512];
|
||||
char RootDirectory[512];
|
||||
|
||||
INT32 PlaceHolder;
|
||||
INT32 DeleteFirstPassFile;
|
||||
INT32 Sharpness;
|
||||
|
||||
} COMP_CONFIG_VP6;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int YWidth;
|
||||
int YHeight;
|
||||
int YStride;
|
||||
|
||||
int UVWidth;
|
||||
int UVHeight;
|
||||
int UVStride;
|
||||
|
||||
char *YBuffer;
|
||||
char *UBuffer;
|
||||
char *VBuffer;
|
||||
|
||||
} YUV_INPUT_BUFFER_CONFIG;
|
||||
|
||||
/****************************************************************************
|
||||
* Functions
|
||||
****************************************************************************/
|
||||
#ifdef _MSC_VER
|
||||
_inline
|
||||
void comp_config_default_vp6 ( COMP_CONFIG_VP6* pcc )
|
||||
{
|
||||
|
||||
|
||||
pcc->FrameSize = 0; // No default value
|
||||
pcc->TargetBitRate = 300;
|
||||
pcc->FrameRate = 0; // No default value
|
||||
pcc->KeyFrameFrequency = 120;
|
||||
pcc->KeyFrameDataTarget = 0; // No default value
|
||||
pcc->Quality = 56;
|
||||
pcc->AllowDF = 0;
|
||||
pcc->AutoKeyFrameEnabled = 1;
|
||||
pcc->AutoKeyFrameThreshold = 80;
|
||||
pcc->MinimumDistanceToKeyFrame = 4;
|
||||
pcc->ForceKeyFrameEvery = 120;
|
||||
pcc->NoiseSensitivity = 0;
|
||||
pcc->AllowSpatialResampling = 0;
|
||||
pcc->HScale = 1;
|
||||
pcc->HRatio = 1;
|
||||
pcc->VScale = 1;
|
||||
pcc->VRatio = 1;
|
||||
pcc->ScalingMode = MAINTAIN_ASPECT_RATIO;
|
||||
pcc->Interlaced = 0;
|
||||
pcc->FixedQ = 0;
|
||||
|
||||
pcc->StartingBufferLevel = 4;
|
||||
pcc->OptimalBufferLevel = 5;
|
||||
pcc->DropFramesWaterMark = 20;
|
||||
pcc->ResampleDownWaterMark = 35;
|
||||
pcc->ResampleUpWaterMark = 45;
|
||||
|
||||
pcc->OutputFrameRate = 30;
|
||||
pcc->Speed = 4;
|
||||
pcc->ErrorResilientMode = FALSE;
|
||||
|
||||
pcc->Profile = 0;
|
||||
|
||||
pcc->DisableGolden = 0;
|
||||
pcc->BestAllowedQ = 4;
|
||||
pcc->UnderShootPct = 90;
|
||||
|
||||
pcc->MaxAllowedDatarate = 100;
|
||||
pcc->MaximumBufferSize = 6;
|
||||
|
||||
pcc->TwoPassVBRBias = 70;
|
||||
pcc->TwoPassVBRMaxSection = 400;
|
||||
pcc->TwoPassVBRMinSection = 40;
|
||||
|
||||
|
||||
pcc->Mode = MODE_GOODQUALITY;
|
||||
pcc->EndUsage = USAGE_STREAM_FROM_SERVER;
|
||||
|
||||
// DEFAULT means default value as determined by mode and endusage
|
||||
pcc->QuickCompress = DEFAULT_VALUE;
|
||||
pcc->Pass = DEFAULT_VALUE;
|
||||
pcc->VBMode = DEFAULT_VALUE;
|
||||
pcc->TwoPassVBREnabled = DEFAULT_VALUE;
|
||||
|
||||
pcc->SettingsFile[0] = 0;
|
||||
pcc->RootDirectory[0] = 0;
|
||||
pcc->Sharpness = 5;
|
||||
|
||||
strncpy(pcc->FirstPassFile,"firstpass.fpf",512);
|
||||
//pcc->FourCC = '06PV';
|
||||
//pcc->ConfigVersion = 4;
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
1
Src/libvp6/include/vp60dversion.h
Normal file
1
Src/libvp6/include/vp60dversion.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define VP60DVERSION "6.0.12.0"
|
1
Src/libvp6/include/vp60eversion.h
Normal file
1
Src/libvp6/include/vp60eversion.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define VP60EVERSION "6.0.12.0"
|
Loading…
Add table
Add a link
Reference in a new issue