mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-13 19:49:36 +00:00
Merge branch 'master' into mac
# Conflicts: # GpApp/House.cpp
This commit is contained in:
@@ -2,7 +2,7 @@ set INPUT_DIR=../AerofoilPortable
|
||||
set OUTPUT_DIR=obj
|
||||
|
||||
rem set DEBUG_LEVEL_FLAGS=-g4 -O0
|
||||
set DEBUG_LEVEL_FLAGS=-O3
|
||||
set DEBUG_LEVEL_FLAGS=-O3 -DNDEBUG=1
|
||||
|
||||
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../Common/ -s ASYNCIFY %DEBUG_LEVEL_FLAGS% -DGP_DEBUG_CONFIG=0
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
set INPUT_DIR=../AerofoilSDL
|
||||
set OUTPUT_DIR=obj
|
||||
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -s ASYNCIFY -O3 -DGP_DEBUG_CONFIG=0
|
||||
|
||||
rem set DEBUG_LEVEL_FLAGS=-g4 -O0
|
||||
set DEBUG_LEVEL_FLAGS=-O3 -DNDEBUG=1
|
||||
|
||||
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -s ASYNCIFY %DEBUG_LEVEL_FLAGS% -DGP_DEBUG_CONFIG=0
|
||||
|
||||
emcc -c %INPUT_DIR%/AerofoilSDL_Combined.cpp -o %OUTPUT_DIR%/AerofoilSDL_Combined.o %FLAGS%
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ set INPUT_DIR=.
|
||||
set OUTPUT_DIR=obj
|
||||
|
||||
rem set DEBUG_LEVEL_FLAGS=-g4 -O0
|
||||
set DEBUG_LEVEL_FLAGS=-O3
|
||||
set DEBUG_LEVEL_FLAGS=-O3 -DNDEBUG=1
|
||||
|
||||
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -I../AerofoilPortable/ -I../GpShell/ -s ASYNCIFY %DEBUG_LEVEL_FLAGS% -DGP_DEBUG_CONFIG=0
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
set INPUT_DIR=../GpApp
|
||||
set OUTPUT_DIR=obj
|
||||
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -s ASYNCIFY -O3 -DGP_DEBUG_CONFIG=0
|
||||
|
||||
rem set DEBUG_LEVEL_FLAGS=-g4 -O0
|
||||
set DEBUG_LEVEL_FLAGS=-O3 -DNDEBUG=1
|
||||
|
||||
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -s ASYNCIFY %DEBUG_LEVEL_FLAGS% -DGP_DEBUG_CONFIG=0
|
||||
|
||||
emcc -c %INPUT_DIR%/GpApp_Combined.cpp -o %OUTPUT_DIR%/GpApp_Combined.o %FLAGS%
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
set INPUT_DIR=../GpShell
|
||||
set OUTPUT_DIR=obj
|
||||
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -s ASYNCIFY -O3 -DGP_DEBUG_CONFIG=0
|
||||
|
||||
rem set DEBUG_LEVEL_FLAGS=-g4 -O0
|
||||
set DEBUG_LEVEL_FLAGS=-O3 -DNDEBUG=1
|
||||
|
||||
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -s ASYNCIFY %DEBUG_LEVEL_FLAGS% -DGP_DEBUG_CONFIG=0
|
||||
|
||||
emcc -c %INPUT_DIR%/GpShell_Combined.cpp -o %OUTPUT_DIR%/GpShell_Combined.o %FLAGS%
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
set INPUT_DIR=../MacRomanConversion
|
||||
set OUTPUT_DIR=obj
|
||||
set FLAGS=-flto -I../MacRomanConversion/ -s ASYNCIFY -O3
|
||||
|
||||
rem set DEBUG_LEVEL_FLAGS=-g4 -O0
|
||||
set DEBUG_LEVEL_FLAGS=-O3 -DNDEBUG=1
|
||||
|
||||
set FLAGS=-flto -I../MacRomanConversion/ -s ASYNCIFY %DEBUG_LEVEL_FLAGS%
|
||||
|
||||
emcc -c %INPUT_DIR%/MacRomanConversion.cpp -o %OUTPUT_DIR%/MacRomanConversion.o %FLAGS%
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
set INPUT_DIR=../PortabilityLayer
|
||||
set OUTPUT_DIR=obj
|
||||
set FLAGS=-s USE_ZLIB=1 -flto -I../GpCommon/ -I../Common/ -I../PortabilityLayer/ -I../rapidjson/include/ -I../MacRomanConversion/ -I../stb/ -s ASYNCIFY -O3 -DGP_DEBUG_CONFIG=0 -Wno-tautological-constant-out-of-range-compare
|
||||
|
||||
rem set DEBUG_LEVEL_FLAGS=-g4 -O0
|
||||
set DEBUG_LEVEL_FLAGS=-O3 -DNDEBUG=1
|
||||
|
||||
set FLAGS=-s USE_ZLIB=1 -flto -I../GpCommon/ -I../Common/ -I../PortabilityLayer/ -I../rapidjson/include/ -I../MacRomanConversion/ -I../stb/ -s ASYNCIFY %DEBUG_LEVEL_FLAGS% -DGP_DEBUG_CONFIG=0 -Wno-tautological-constant-out-of-range-compare
|
||||
|
||||
emcc -c %INPUT_DIR%/PortabilityLayer_Combined.cpp -o %OUTPUT_DIR%/PortabilityLayer_Combined.o %FLAGS%
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ Boolean InitializeEmptyHouse (void)
|
||||
if (thisHouse != nil)
|
||||
thisHouse.Dispose();
|
||||
|
||||
const size_t houseSizeNoRooms = sizeof(sizeof(houseType) - sizeof(roomType));
|
||||
const size_t houseSizeNoRooms = sizeof(houseType) - sizeof(roomType);
|
||||
thisHouse = NewHandle(houseSizeNoRooms).StaticCast<houseType>();
|
||||
|
||||
if (thisHouse == nil)
|
||||
@@ -224,6 +224,7 @@ Boolean InitializeEmptyHouse (void)
|
||||
}
|
||||
|
||||
thisHousePtr = *thisHouse;
|
||||
memset(thisHousePtr, 0, houseSizeNoRooms);
|
||||
|
||||
thisHousePtr->version = kHouseVersion;
|
||||
thisHousePtr->firstRoom = -1;
|
||||
@@ -264,8 +265,8 @@ Boolean InitializeEmptyHouseInEditor (void)
|
||||
|
||||
UpdateMenus(false);
|
||||
ReflectCurrentRoom(true);
|
||||
|
||||
return (true);
|
||||
|
||||
return (true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -171,6 +171,8 @@ Boolean CreateNewRoom (short h, short v)
|
||||
char wasState;
|
||||
|
||||
CopyThisRoomToRoom(); // save off current room
|
||||
|
||||
memset(thisRoom, 0, sizeof(roomType));
|
||||
|
||||
PasStringCopy(PSTR("Untitled Room"), thisRoom->name);
|
||||
thisRoom->leftStart = 32; // fill out fields of new room
|
||||
|
||||
@@ -182,6 +182,8 @@ void CreatePointers (void)
|
||||
thisRoom = (roomPtr)NewPtr(sizeof(roomType));
|
||||
if (thisRoom == nil)
|
||||
RedAlert(kErrNoMemory);
|
||||
|
||||
memset(thisRoom, 0, sizeof(roomType));
|
||||
|
||||
hotSpots = nil;
|
||||
hotSpots = (hotPtr)NewPtr(sizeof(hotObject) * kMaxHotSpots);
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
#define GP_BUILD_VERSION_MINOR 1
|
||||
#define GP_BUILD_VERSION_UPDATE 0
|
||||
|
||||
#define GP_APPLICATION_VERSION_STRING "1.1.0 rc1"
|
||||
#define GP_APPLICATION_VERSION_STRING "1.1.0 Release Candidate 2"
|
||||
#define GP_APPLICATION_COPYRIGHT_STRING "2019-2021 Gale Force Games LLC"
|
||||
#define GP_APPLICATION_WEBSITE_STRING "https://github.com/elasota/Aerofoil"
|
||||
|
||||
@@ -21,6 +21,7 @@ copy /Y x64\Release\MakeTimestamp.exe ReleasePkg\Aerofoil\Tools
|
||||
copy /Y x64\Release\FTagData.exe ReleasePkg\Aerofoil\Tools
|
||||
copy /Y x64\Release\gpr2gpa.exe ReleasePkg\Aerofoil\Tools
|
||||
copy /Y x64\Release\unpacktool.exe ReleasePkg\Aerofoil\Tools
|
||||
copy /Y x64\Release\MergeGPF.exe ReleasePkg\Aerofoil\Tools
|
||||
|
||||
mkdir ReleasePkg\PDBs
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "BinHex4.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "GpVector.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
|
||||
// See: https://files.stairways.com/other/binhex-40-specs-info.txt
|
||||
@@ -59,7 +59,7 @@ namespace
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
MacFileMem *BinHex4::LoadHQX(GpIOStream *stream)
|
||||
MacFileMem *BinHex4::LoadHQX(GpIOStream *stream, IGpAllocator *alloc)
|
||||
{
|
||||
const uint8_t errCodeChar = 64;
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace PortabilityLayer
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> bytesAfter6To8;
|
||||
GpVector<uint8_t> bytesAfter6To8(alloc);
|
||||
|
||||
if (stream->IsSeekable())
|
||||
{
|
||||
@@ -120,7 +120,10 @@ namespace PortabilityLayer
|
||||
return nullptr;
|
||||
|
||||
if (endPos > filePos && (endPos - filePos) < SIZE_MAX / 6)
|
||||
bytesAfter6To8.reserve(static_cast<size_t>(endPos - filePos) * 6 / 8);
|
||||
{
|
||||
if (!bytesAfter6To8.Reserve(static_cast<size_t>(endPos - filePos) * 6 / 8))
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,19 +173,22 @@ namespace PortabilityLayer
|
||||
break;
|
||||
case 6:
|
||||
decodedByte |= value6Bit;
|
||||
bytesAfter6To8.push_back(decodedByte);
|
||||
if (!bytesAfter6To8.Append(decodedByte))
|
||||
return nullptr;
|
||||
decodedByte = 0;
|
||||
decodedByteBitPos = 8;
|
||||
break;
|
||||
case 4:
|
||||
decodedByte |= (value6Bit >> 2);
|
||||
bytesAfter6To8.push_back(decodedByte);
|
||||
if (!bytesAfter6To8.Append(decodedByte))
|
||||
return nullptr;
|
||||
decodedByte = (value6Bit << 6) & 0xff;
|
||||
decodedByteBitPos = 6;
|
||||
break;
|
||||
case 2:
|
||||
decodedByte |= (value6Bit >> 4);
|
||||
bytesAfter6To8.push_back(decodedByte);
|
||||
if (!bytesAfter6To8.Append(decodedByte))
|
||||
return nullptr;
|
||||
decodedByte = (value6Bit << 4) & 0xff;
|
||||
decodedByteBitPos = 4;
|
||||
break;
|
||||
@@ -191,7 +197,7 @@ namespace PortabilityLayer
|
||||
}
|
||||
}
|
||||
|
||||
const size_t bytesBeforeRLEDec = bytesAfter6To8.size();
|
||||
const size_t bytesBeforeRLEDec = bytesAfter6To8.Count();
|
||||
size_t decodedDataSize = 0;
|
||||
for (size_t i = 0; i < bytesBeforeRLEDec; i++)
|
||||
{
|
||||
@@ -212,8 +218,9 @@ namespace PortabilityLayer
|
||||
decodedDataSize++;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> decodedBytes;
|
||||
decodedBytes.reserve(decodedDataSize);
|
||||
GpVector<uint8_t> decodedBytes(alloc);
|
||||
if (!decodedBytes.Reserve(decodedDataSize))
|
||||
return nullptr;
|
||||
|
||||
for (size_t i = 0; i < bytesBeforeRLEDec; i++)
|
||||
{
|
||||
@@ -224,28 +231,37 @@ namespace PortabilityLayer
|
||||
const uint8_t runLength = bytesAfter6To8[++i];
|
||||
|
||||
if (runLength == 0)
|
||||
decodedBytes.push_back(0x90);
|
||||
{
|
||||
if (!decodedBytes.Append(0x90))
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decodedBytes.size() == 0)
|
||||
if (decodedBytes.Count() == 0)
|
||||
return nullptr;
|
||||
|
||||
const uint8_t lastByte = *(decodedBytes.end() - 1);
|
||||
const uint8_t lastByte = decodedBytes[decodedBytes.Count() - 1];
|
||||
for (size_t r = 1; r < runLength; r++)
|
||||
decodedBytes.push_back(lastByte);
|
||||
{
|
||||
if (!decodedBytes.Append(lastByte))
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
decodedBytes.push_back(b);
|
||||
{
|
||||
if (!decodedBytes.Append(b))
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
assert(decodedBytes.size() == decodedDataSize);
|
||||
assert(decodedBytes.Count() == decodedDataSize);
|
||||
|
||||
if (decodedBytes.size() == 0)
|
||||
if (decodedBytes.Count() == 0)
|
||||
return nullptr;
|
||||
|
||||
const uint8_t nameLength = decodedBytes[0];
|
||||
if (decodedBytes.size() < 22 + nameLength || nameLength > 63)
|
||||
if (decodedBytes.Count() < 22 + nameLength || nameLength > 63)
|
||||
return nullptr;
|
||||
|
||||
// Header format:
|
||||
@@ -272,7 +288,7 @@ namespace PortabilityLayer
|
||||
mfi.m_dataForkSize = ByteUnpack::BigUInt32(&decodedBytes[headerStartLoc + 10]);
|
||||
mfi.m_resourceForkSize = ByteUnpack::BigUInt32(&decodedBytes[headerStartLoc + 14]);
|
||||
|
||||
const size_t availableDataSize = decodedBytes.size() - 26 - nameLength; // +4 bytes for CRCs
|
||||
const size_t availableDataSize = decodedBytes.Count() - 26 - nameLength; // +4 bytes for CRCs
|
||||
|
||||
if (mfi.m_dataForkSize > availableDataSize || availableDataSize - mfi.m_dataForkSize < mfi.m_resourceForkSize)
|
||||
return nullptr;
|
||||
@@ -297,6 +313,6 @@ namespace PortabilityLayer
|
||||
if (expectedResCRC != BinHexCRC(&decodedBytes[resourceForkStart], mfi.m_resourceForkSize))
|
||||
return nullptr;
|
||||
|
||||
return new MacFileMem(&decodedBytes[dataForkStart], &decodedBytes[resourceForkStart], nullptr, mfi);
|
||||
return MacFileMem::Create(alloc, &decodedBytes[dataForkStart], &decodedBytes[resourceForkStart], nullptr, mfi);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __PL_BINHEX4_H__
|
||||
#define __PL_BINHEX4_H__
|
||||
|
||||
class GpIOStream;
|
||||
struct IGpAllocator;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
@@ -11,8 +9,6 @@ namespace PortabilityLayer
|
||||
|
||||
namespace BinHex4
|
||||
{
|
||||
MacFileMem *LoadHQX(GpIOStream *stream);
|
||||
MacFileMem *LoadHQX(GpIOStream *stream, IGpAllocator *alloc);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace PortabilityLayer
|
||||
stream->Write(padding, resourceForkPadding);
|
||||
}
|
||||
|
||||
MacFileMem *MacBinary2::ReadBin(GpIOStream *stream)
|
||||
MacFileMem *MacBinary2::ReadBin(GpIOStream *stream, IGpAllocator *alloc)
|
||||
{
|
||||
MacFileInfo fileInfo;
|
||||
|
||||
@@ -153,37 +153,35 @@ namespace PortabilityLayer
|
||||
if (fileInfo.m_resourceForkSize > SIZE_MAX)
|
||||
return nullptr;
|
||||
|
||||
uint8_t *dataBuffer = nullptr;
|
||||
uint8_t *rsrcBuffer = nullptr;
|
||||
GpVector<uint8_t> dataBuffer(alloc);
|
||||
GpVector<uint8_t> rsrcBuffer(alloc);
|
||||
|
||||
if (fileInfo.m_dataForkSize != 0)
|
||||
dataBuffer = new uint8_t[fileInfo.m_dataForkSize];
|
||||
dataBuffer.Resize(fileInfo.m_dataForkSize);
|
||||
|
||||
if (fileInfo.m_resourceForkSize != 0)
|
||||
rsrcBuffer = new uint8_t[fileInfo.m_resourceForkSize];
|
||||
rsrcBuffer.Resize(fileInfo.m_resourceForkSize);
|
||||
|
||||
ScopedArray<uint8_t> dataContents(dataBuffer);
|
||||
ScopedArray<uint8_t> rsrcContents(rsrcBuffer);
|
||||
|
||||
uint8_t *padding = mb2Header;
|
||||
|
||||
const size_t dataForkPadding = 127 - ((fileInfo.m_dataForkSize + 127) % 128);
|
||||
const size_t resourceForkPadding = 127 - ((fileInfo.m_resourceForkSize + 127) % 128);
|
||||
|
||||
if (stream->Read(dataBuffer, fileInfo.m_dataForkSize) != fileInfo.m_dataForkSize)
|
||||
if (stream->Read(dataBuffer.Buffer(), fileInfo.m_dataForkSize) != fileInfo.m_dataForkSize)
|
||||
return nullptr;
|
||||
|
||||
if (stream->Read(padding, dataForkPadding) != dataForkPadding)
|
||||
return nullptr;
|
||||
|
||||
if (stream->Read(rsrcBuffer, fileInfo.m_resourceForkSize) != fileInfo.m_resourceForkSize)
|
||||
if (stream->Read(rsrcBuffer.Buffer(), fileInfo.m_resourceForkSize) != fileInfo.m_resourceForkSize)
|
||||
return nullptr;
|
||||
|
||||
if (stream->Read(padding, resourceForkPadding) != resourceForkPadding)
|
||||
return nullptr;
|
||||
|
||||
// Ignore comment for now
|
||||
return new MacFileMem(dataBuffer, rsrcBuffer, nullptr, fileInfo);
|
||||
return MacFileMem::Create(alloc, dataBuffer.Buffer(), rsrcBuffer.Buffer(), nullptr, fileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
class GpIOStream;
|
||||
struct IGpAllocator;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
@@ -14,6 +15,6 @@ namespace PortabilityLayer
|
||||
void SerializeHeader(unsigned char *headerBytes, const MacFileInfo &macFileInfo);
|
||||
|
||||
void WriteBin(const MacFileMem *file, GpIOStream *stream);
|
||||
MacFileMem *ReadBin(GpIOStream *stream);
|
||||
MacFileMem *ReadBin(GpIOStream *stream, IGpAllocator *alloc);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,26 +1,59 @@
|
||||
#include "MacFileMem.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
MacFileMem::MacFileMem(const uint8_t *dataFork, const uint8_t *resourceFork, const char* comment, const MacFileInfo &fileInfo)
|
||||
: m_info(fileInfo)
|
||||
{
|
||||
MacFileMem::MacFileMem(IGpAllocator *alloc, const MacFileInfo &fileInfo)
|
||||
: m_alloc(alloc)
|
||||
, m_info(fileInfo)
|
||||
, m_data(alloc)
|
||||
{
|
||||
uint8_t *buffer = new uint8_t[fileInfo.m_dataForkSize + fileInfo.m_resourceForkSize + fileInfo.m_commentSize + 1];
|
||||
m_data.Set(buffer);
|
||||
}
|
||||
|
||||
memcpy(buffer, dataFork, fileInfo.m_dataForkSize);
|
||||
buffer += fileInfo.m_dataForkSize;
|
||||
bool MacFileMem::Init(const uint8_t *dataFork, const uint8_t *resourceFork, const char* comment)
|
||||
{
|
||||
const size_t combinedSize = m_info.m_dataForkSize + m_info.m_resourceForkSize + m_info.m_commentSize + 1;
|
||||
if (!m_data.Resize(combinedSize))
|
||||
return false;
|
||||
|
||||
uint8_t *buffer = m_data.Buffer();
|
||||
memcpy(buffer, dataFork, m_info.m_dataForkSize);
|
||||
buffer += m_info.m_dataForkSize;
|
||||
|
||||
memcpy(buffer, resourceFork, fileInfo.m_resourceForkSize);
|
||||
buffer += fileInfo.m_resourceForkSize;
|
||||
memcpy(buffer, resourceFork, m_info.m_resourceForkSize);
|
||||
buffer += m_info.m_resourceForkSize;
|
||||
|
||||
memcpy(buffer, comment, fileInfo.m_commentSize);
|
||||
buffer += fileInfo.m_commentSize;
|
||||
memcpy(buffer, comment, m_info.m_commentSize);
|
||||
buffer += m_info.m_commentSize;
|
||||
|
||||
*buffer = 0;
|
||||
*buffer = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MacFileMem::~MacFileMem()
|
||||
{
|
||||
}
|
||||
|
||||
MacFileMem *MacFileMem::Create(IGpAllocator *alloc, const uint8_t *dataFork, const uint8_t *resourceFork, const char* comment, const MacFileInfo &fileInfo)
|
||||
{
|
||||
void *storage = alloc->Alloc(sizeof(MacFileMem));
|
||||
if (!storage)
|
||||
return nullptr;
|
||||
|
||||
MacFileMem *result = new (storage) MacFileMem(alloc, fileInfo);
|
||||
if (!result->Init(dataFork, resourceFork, comment))
|
||||
{
|
||||
result->Destroy();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void MacFileMem::Destroy()
|
||||
{
|
||||
IGpAllocator *alloc = m_alloc;
|
||||
this->~MacFileMem();
|
||||
alloc->Release(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __PL_MACFILEMEM_H__
|
||||
#define __PL_MACFILEMEM_H__
|
||||
|
||||
#include "DataTypes.h"
|
||||
#include "MacFileInfo.h"
|
||||
#include "ScopedArray.h"
|
||||
#include "GpVector.h"
|
||||
|
||||
struct IGpAllocator;
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class MacFileMem
|
||||
{
|
||||
public:
|
||||
MacFileMem(const uint8_t *dataFork, const uint8_t *resourceFork, const char* comment, const MacFileInfo &fileInfo);
|
||||
~MacFileMem();
|
||||
|
||||
const MacFileInfo &FileInfo() const;
|
||||
const uint8_t *DataFork() const;
|
||||
const uint8_t *ResourceFork() const;
|
||||
const char *Comment() const;
|
||||
const char *Comment() const;
|
||||
|
||||
static MacFileMem *Create(IGpAllocator *alloc, const uint8_t *dataFork, const uint8_t *resourceFork, const char* comment, const MacFileInfo &fileInfo);
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
ScopedArray<uint8_t> m_data;
|
||||
MacFileInfo m_info;
|
||||
MacFileMem(IGpAllocator *alloc, const MacFileInfo &fileInfo);
|
||||
~MacFileMem();
|
||||
|
||||
bool Init(const uint8_t *dataFork, const uint8_t *resourceFork, const char* comment);
|
||||
|
||||
GpVector<uint8_t> m_data;
|
||||
MacFileInfo m_info;
|
||||
IGpAllocator *m_alloc;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,18 +40,16 @@ namespace PortabilityLayer
|
||||
|
||||
inline const uint8_t *MacFileMem::DataFork() const
|
||||
{
|
||||
return m_data;
|
||||
return m_data.Buffer();
|
||||
}
|
||||
|
||||
inline const uint8_t *MacFileMem::ResourceFork() const
|
||||
{
|
||||
return m_data + m_info.m_dataForkSize;
|
||||
return m_data.Buffer() + m_info.m_dataForkSize;
|
||||
}
|
||||
|
||||
inline const char *MacFileMem::Comment() const
|
||||
{
|
||||
return reinterpret_cast<const char*>(m_data + m_info.m_dataForkSize + m_info.m_resourceForkSize);
|
||||
return reinterpret_cast<const char*>(m_data.Buffer() + m_info.m_dataForkSize + m_info.m_resourceForkSize);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -209,7 +209,6 @@
|
||||
<ClInclude Include="VirtualDirectory.h" />
|
||||
<ClInclude Include="RCPtr.h" />
|
||||
<ClInclude Include="RefCounted.h" />
|
||||
<ClInclude Include="ScopedArray.h" />
|
||||
<ClInclude Include="ScopedPtr.h" />
|
||||
<ClInclude Include="SmallestInt.h" />
|
||||
<ClInclude Include="UnsafePascalStr.h" />
|
||||
|
||||
@@ -42,9 +42,6 @@
|
||||
<ClInclude Include="ScopedPtr.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ScopedArray.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PascalStr.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __PL_SCOPEDARRAY_H__
|
||||
#define __PL_SCOPEDARRAY_H__
|
||||
|
||||
#include "CoreDefs.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
template<class T>
|
||||
class ScopedArray
|
||||
{
|
||||
public:
|
||||
ScopedArray();
|
||||
ScopedArray(T *ref);
|
||||
~ScopedArray();
|
||||
|
||||
void Swap(ScopedArray<T> &other);
|
||||
|
||||
operator T*();
|
||||
operator const T*() const;
|
||||
|
||||
void Set(T *ref);
|
||||
|
||||
private:
|
||||
ScopedArray(const ScopedArray<T> &other) GP_DELETED;
|
||||
void operator=(const ScopedArray<T> &other) GP_DELETED;
|
||||
T *m_ref;
|
||||
};
|
||||
}
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
template<class T>
|
||||
inline ScopedArray<T>::ScopedArray()
|
||||
: m_ref(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline ScopedArray<T>::ScopedArray(T *ref)
|
||||
: m_ref(ref)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline ScopedArray<T>::~ScopedArray()
|
||||
{
|
||||
if (m_ref)
|
||||
delete[] m_ref;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void ScopedArray<T>::Swap(ScopedArray<T> &other)
|
||||
{
|
||||
T *temp = m_ref;
|
||||
m_ref = other.m_ref;
|
||||
other.m_ref = temp;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline ScopedArray<T>::operator T*()
|
||||
{
|
||||
return m_ref;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline ScopedArray<T>::operator const T*() const
|
||||
{
|
||||
return m_ref;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void ScopedArray<T>::Set(T *ref)
|
||||
{
|
||||
if (m_ref && m_ref != ref)
|
||||
delete m_ref;
|
||||
|
||||
m_ref = ref;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __PL_SCOPEDPTR_H__
|
||||
#define __PL_SCOPEDPTR_H__
|
||||
|
||||
#include "CoreDefs.h"
|
||||
|
||||
namespace PortabilityLayer
|
||||
@@ -49,7 +46,7 @@ namespace PortabilityLayer
|
||||
inline ScopedPtr<T>::~ScopedPtr()
|
||||
{
|
||||
if (m_ref)
|
||||
delete m_ref;
|
||||
m_ref->Destroy();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@@ -87,11 +84,9 @@ namespace PortabilityLayer
|
||||
template<class T>
|
||||
inline void ScopedPtr<T>::Set(T *ref)
|
||||
{
|
||||
if (m_ref && m_ref != ref)
|
||||
delete m_ref;
|
||||
if (m_ref && m_ref != ref)
|
||||
m_ref->Destroy();
|
||||
|
||||
m_ref = ref;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,146 +1,147 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
Copyright 2019 Eric Lasota
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
Copyright 2019 Eric Lasota
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "CFileStream.h"
|
||||
#include "CombinedTimestamp.h"
|
||||
#include "ScopedPtr.h"
|
||||
#include "MacBinary2.h"
|
||||
#include "MacFileMem.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace PortabilityLayer;
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
if (argc != 4)
|
||||
{
|
||||
fprintf(stderr, "Usage: bin2gp <input.bin> <input.ts> <output>");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *f = nullptr;
|
||||
if (fopen_s(&f, argv[1], "rb"))
|
||||
f = nullptr;
|
||||
#else
|
||||
FILE *f = fopen(argv[1], "rb");
|
||||
#endif
|
||||
|
||||
if (!f)
|
||||
{
|
||||
fprintf(stderr, "Could not open input file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *tsF = nullptr;
|
||||
if (fopen_s(&tsF, argv[2], "rb"))
|
||||
tsF = nullptr;
|
||||
#else
|
||||
FILE *tsF = fopen(argv[2], "rb");
|
||||
#endif
|
||||
|
||||
if (!tsF)
|
||||
{
|
||||
fprintf(stderr, "Could not open timestamp file");
|
||||
return -1;
|
||||
#include "CombinedTimestamp.h"
|
||||
#include "ScopedPtr.h"
|
||||
#include "MacBinary2.h"
|
||||
#include "MacFileMem.h"
|
||||
#include "GpAllocator_C.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace PortabilityLayer;
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
if (argc != 4)
|
||||
{
|
||||
fprintf(stderr, "Usage: bin2gp <input.bin> <input.ts> <output>");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *f = nullptr;
|
||||
if (fopen_s(&f, argv[1], "rb"))
|
||||
f = nullptr;
|
||||
#else
|
||||
FILE *f = fopen(argv[1], "rb");
|
||||
#endif
|
||||
|
||||
if (!f)
|
||||
{
|
||||
fprintf(stderr, "Could not open input file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *tsF = nullptr;
|
||||
if (fopen_s(&tsF, argv[2], "rb"))
|
||||
tsF = nullptr;
|
||||
#else
|
||||
FILE *tsF = fopen(argv[2], "rb");
|
||||
#endif
|
||||
|
||||
if (!tsF)
|
||||
{
|
||||
fprintf(stderr, "Could not open timestamp file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
PortabilityLayer::CombinedTimestamp ts;
|
||||
if (!fread(&ts, sizeof(ts), 1, tsF))
|
||||
{
|
||||
fprintf(stderr, "Could not read timestamp");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CFileStream fs(f, true, false, true);
|
||||
|
||||
ScopedPtr<MacFileMem> memFile = MacBinary2::ReadBin(&fs);
|
||||
|
||||
fs.Close();
|
||||
|
||||
std::string fname = argv[3];
|
||||
|
||||
const char* extensions[] = { ".gpf", ".gpr", ".gpd", ".gpc" };
|
||||
|
||||
MacFilePropertiesSerialized sp;
|
||||
sp.Serialize(memFile->FileInfo().m_properties);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
const void *bufferToWrite = nullptr;
|
||||
size_t sizeToWrite = 0;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
bufferToWrite = sp.m_data;
|
||||
sizeToWrite = sp.kSize;
|
||||
break;
|
||||
case 1:
|
||||
bufferToWrite = memFile->ResourceFork();
|
||||
sizeToWrite = memFile->FileInfo().m_resourceForkSize;
|
||||
break;
|
||||
case 2:
|
||||
bufferToWrite = memFile->DataFork();
|
||||
sizeToWrite = memFile->FileInfo().m_dataForkSize;
|
||||
break;
|
||||
case 3:
|
||||
bufferToWrite = memFile->Comment();
|
||||
sizeToWrite = memFile->FileInfo().m_commentSize;
|
||||
break;
|
||||
};
|
||||
|
||||
if (sizeToWrite == 0)
|
||||
continue;
|
||||
|
||||
std::string path = fname + extensions[i];
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *outF = nullptr;
|
||||
if (fopen_s(&outF, path.c_str(), "wb"))
|
||||
outF = nullptr;
|
||||
#else
|
||||
FILE *outF = fopen(path.c_str(), "wb");
|
||||
#endif
|
||||
|
||||
if (!outF)
|
||||
return -1;
|
||||
}
|
||||
|
||||
CFileStream fs(f, true, false, true);
|
||||
|
||||
ScopedPtr<MacFileMem> memFile = MacBinary2::ReadBin(&fs, GpAllocator_C::GetInstance());
|
||||
|
||||
fs.Close();
|
||||
|
||||
std::string fname = argv[3];
|
||||
|
||||
const char* extensions[] = { ".gpf", ".gpr", ".gpd", ".gpc" };
|
||||
|
||||
MacFilePropertiesSerialized sp;
|
||||
sp.Serialize(memFile->FileInfo().m_properties);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
const void *bufferToWrite = nullptr;
|
||||
size_t sizeToWrite = 0;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
bufferToWrite = sp.m_data;
|
||||
sizeToWrite = sp.kSize;
|
||||
break;
|
||||
case 1:
|
||||
bufferToWrite = memFile->ResourceFork();
|
||||
sizeToWrite = memFile->FileInfo().m_resourceForkSize;
|
||||
break;
|
||||
case 2:
|
||||
bufferToWrite = memFile->DataFork();
|
||||
sizeToWrite = memFile->FileInfo().m_dataForkSize;
|
||||
break;
|
||||
case 3:
|
||||
bufferToWrite = memFile->Comment();
|
||||
sizeToWrite = memFile->FileInfo().m_commentSize;
|
||||
break;
|
||||
};
|
||||
|
||||
if (sizeToWrite == 0)
|
||||
continue;
|
||||
|
||||
std::string path = fname + extensions[i];
|
||||
|
||||
#ifdef _CRT_INSECURE_DEPRECATE
|
||||
FILE *outF = nullptr;
|
||||
if (fopen_s(&outF, path.c_str(), "wb"))
|
||||
outF = nullptr;
|
||||
#else
|
||||
FILE *outF = fopen(path.c_str(), "wb");
|
||||
#endif
|
||||
|
||||
if (!outF)
|
||||
continue;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
CFileStream stream(outF);
|
||||
sp.WriteAsPackage(stream, ts);
|
||||
stream.Close();
|
||||
stream.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite(bufferToWrite, 1, sizeToWrite, outF);
|
||||
{
|
||||
fwrite(bufferToWrite, 1, sizeToWrite, outF);
|
||||
fclose(outF);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\Debug.props" />
|
||||
<Import Project="..\AerofoilPortable.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
@@ -48,6 +49,7 @@
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\Release.props" />
|
||||
<Import Project="..\AerofoilPortable.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
@@ -74,6 +76,7 @@
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\AerofoilPortable\GpAllocator_C.cpp" />
|
||||
<ClCompile Include="bin2gp.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -18,5 +18,8 @@
|
||||
<ClCompile Include="bin2gp.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\AerofoilPortable\GpAllocator_C.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "MemReaderStream.h"
|
||||
#include "ResourceCompiledTypeList.h"
|
||||
#include "ResourceFile.h"
|
||||
#include "ScopedPtr.h"
|
||||
#include "GpAllocator_C.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -48,15 +50,15 @@ int main(int argc, const char **argv)
|
||||
mfi.m_resourceForkSize = resSize;
|
||||
mfi.m_commentSize = 0;
|
||||
|
||||
PortabilityLayer::MacFileMem memFile(dataFork, resFork, nullptr, mfi);
|
||||
PortabilityLayer::ScopedPtr<PortabilityLayer::MacFileMem> memFile = PortabilityLayer::MacFileMem::Create(GpAllocator_C::GetInstance(), dataFork, resFork, nullptr, mfi);
|
||||
|
||||
delete[] dataFork;
|
||||
delete[] resFork;
|
||||
|
||||
const uint8_t *dataBytes = memFile.DataFork();
|
||||
const uint8_t *dataBytes = memFile->DataFork();
|
||||
if (dataBytes[0] == 0 && dataBytes[1] == 0 && dataBytes[2] == 0 && dataBytes[3] == 0)
|
||||
{
|
||||
uint32_t mdatSize = memFile.FileInfo().m_dataForkSize;
|
||||
uint32_t mdatSize = memFile->FileInfo().m_dataForkSize;
|
||||
uint8_t mdatSizeEncoded[4];
|
||||
mdatSizeEncoded[0] = ((mdatSize >> 24) & 0xff);
|
||||
mdatSizeEncoded[1] = ((mdatSize >> 16) & 0xff);
|
||||
@@ -65,7 +67,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
PortabilityLayer::ResourceFile *rf = PortabilityLayer::ResourceFile::Create();
|
||||
|
||||
PortabilityLayer::MemReaderStream resStream(memFile.ResourceFork(), memFile.FileInfo().m_resourceForkSize);
|
||||
PortabilityLayer::MemReaderStream resStream(memFile->ResourceFork(), memFile->FileInfo().m_resourceForkSize);
|
||||
rf->Load(&resStream);
|
||||
|
||||
const PortabilityLayer::ResourceCompiledTypeList *typeList = rf->GetResourceTypeList(PortabilityLayer::ResTypeID('moov'));
|
||||
@@ -102,7 +104,7 @@ int main(int argc, const char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
fwrite(dataBytes, 1, memFile.FileInfo().m_dataForkSize, outF);
|
||||
fwrite(dataBytes, 1, memFile->FileInfo().m_dataForkSize, outF);
|
||||
fclose(outF);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\Debug.props" />
|
||||
<Import Project="..\AerofoilPortable.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
@@ -48,6 +49,7 @@
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\Release.props" />
|
||||
<Import Project="..\AerofoilPortable.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
@@ -74,6 +76,7 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\AerofoilPortable\GpAllocator_C.cpp" />
|
||||
<ClCompile Include="flattenmov.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -18,5 +18,8 @@
|
||||
<ClCompile Include="flattenmov.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\AerofoilPortable\GpAllocator_C.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,238 +1,238 @@
|
||||
/*
|
||||
/*
|
||||
* MACE decoder
|
||||
* Based on FFmpeg MACE decoder
|
||||
* Copyright (c) 2002 Laszlo Torok <torokl@alpha.dfmk.hu>
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Adapted to libavcodec by Francois Revol <revol@free.fr>
|
||||
* (removed 68k REG stuff, changed types, added some statics and consts,
|
||||
* libavcodec api, context stuff, interlaced stereo out).
|
||||
* Based on FFmpeg MACE decoder
|
||||
* Copyright (c) 2002 Laszlo Torok <torokl@alpha.dfmk.hu>
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Adapted to libavcodec by Francois Revol <revol@free.fr>
|
||||
* (removed 68k REG stuff, changed types, added some statics and consts,
|
||||
* libavcodec api, context stuff, interlaced stereo out).
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "macedec.h"
|
||||
|
||||
static const int16_t MACEtab1[] = {-13, 8, 76, 222, 222, 76, 8, -13};
|
||||
|
||||
static const int16_t MACEtab3[] = {-18, 140, 140, -18};
|
||||
|
||||
static const int16_t MACEtab2[][4] = {
|
||||
{ 37, 116, 206, 330}, { 39, 121, 216, 346},
|
||||
{ 41, 127, 225, 361}, { 42, 132, 235, 377},
|
||||
{ 44, 137, 245, 392}, { 46, 144, 256, 410},
|
||||
{ 48, 150, 267, 428}, { 51, 157, 280, 449},
|
||||
{ 53, 165, 293, 470}, { 55, 172, 306, 490},
|
||||
{ 58, 179, 319, 511}, { 60, 187, 333, 534},
|
||||
{ 63, 195, 348, 557}, { 66, 205, 364, 583},
|
||||
{ 69, 214, 380, 609}, { 72, 223, 396, 635},
|
||||
{ 75, 233, 414, 663}, { 79, 244, 433, 694},
|
||||
{ 82, 254, 453, 725}, { 86, 265, 472, 756},
|
||||
{ 90, 278, 495, 792}, { 94, 290, 516, 826},
|
||||
{ 98, 303, 538, 862}, { 102, 316, 562, 901},
|
||||
{ 107, 331, 588, 942}, { 112, 345, 614, 983},
|
||||
{ 117, 361, 641, 1027}, { 122, 377, 670, 1074},
|
||||
{ 127, 394, 701, 1123}, { 133, 411, 732, 1172},
|
||||
{ 139, 430, 764, 1224}, { 145, 449, 799, 1280},
|
||||
{ 152, 469, 835, 1337}, { 159, 490, 872, 1397},
|
||||
{ 166, 512, 911, 1459}, { 173, 535, 951, 1523},
|
||||
{ 181, 558, 993, 1590}, { 189, 584, 1038, 1663},
|
||||
{ 197, 610, 1085, 1738}, { 206, 637, 1133, 1815},
|
||||
{ 215, 665, 1183, 1895}, { 225, 695, 1237, 1980},
|
||||
{ 235, 726, 1291, 2068}, { 246, 759, 1349, 2161},
|
||||
{ 257, 792, 1409, 2257}, { 268, 828, 1472, 2357},
|
||||
{ 280, 865, 1538, 2463}, { 293, 903, 1606, 2572},
|
||||
{ 306, 944, 1678, 2688}, { 319, 986, 1753, 2807},
|
||||
{ 334, 1030, 1832, 2933}, { 349, 1076, 1914, 3065},
|
||||
{ 364, 1124, 1999, 3202}, { 380, 1174, 2088, 3344},
|
||||
{ 398, 1227, 2182, 3494}, { 415, 1281, 2278, 3649},
|
||||
{ 434, 1339, 2380, 3811}, { 453, 1398, 2486, 3982},
|
||||
{ 473, 1461, 2598, 4160}, { 495, 1526, 2714, 4346},
|
||||
{ 517, 1594, 2835, 4540}, { 540, 1665, 2961, 4741},
|
||||
{ 564, 1740, 3093, 4953}, { 589, 1818, 3232, 5175},
|
||||
{ 615, 1898, 3375, 5405}, { 643, 1984, 3527, 5647},
|
||||
{ 671, 2072, 3683, 5898}, { 701, 2164, 3848, 6161},
|
||||
{ 733, 2261, 4020, 6438}, { 766, 2362, 4199, 6724},
|
||||
{ 800, 2467, 4386, 7024}, { 836, 2578, 4583, 7339},
|
||||
{ 873, 2692, 4786, 7664}, { 912, 2813, 5001, 8008},
|
||||
{ 952, 2938, 5223, 8364}, { 995, 3070, 5457, 8739},
|
||||
{ 1039, 3207, 5701, 9129}, { 1086, 3350, 5956, 9537},
|
||||
{ 1134, 3499, 6220, 9960}, { 1185, 3655, 6497, 10404},
|
||||
{ 1238, 3818, 6788, 10869}, { 1293, 3989, 7091, 11355},
|
||||
{ 1351, 4166, 7407, 11861}, { 1411, 4352, 7738, 12390},
|
||||
{ 1474, 4547, 8084, 12946}, { 1540, 4750, 8444, 13522},
|
||||
{ 1609, 4962, 8821, 14126}, { 1680, 5183, 9215, 14756},
|
||||
{ 1756, 5415, 9626, 15415}, { 1834, 5657, 10057, 16104},
|
||||
{ 1916, 5909, 10505, 16822}, { 2001, 6173, 10975, 17574},
|
||||
{ 2091, 6448, 11463, 18356}, { 2184, 6736, 11974, 19175},
|
||||
{ 2282, 7037, 12510, 20032}, { 2383, 7351, 13068, 20926},
|
||||
{ 2490, 7679, 13652, 21861}, { 2601, 8021, 14260, 22834},
|
||||
{ 2717, 8380, 14897, 23854}, { 2838, 8753, 15561, 24918},
|
||||
{ 2965, 9144, 16256, 26031}, { 3097, 9553, 16982, 27193},
|
||||
{ 3236, 9979, 17740, 28407}, { 3380, 10424, 18532, 29675},
|
||||
{ 3531, 10890, 19359, 31000}, { 3688, 11375, 20222, 32382},
|
||||
{ 3853, 11883, 21125, 32767}, { 4025, 12414, 22069, 32767},
|
||||
{ 4205, 12967, 23053, 32767}, { 4392, 13546, 24082, 32767},
|
||||
{ 4589, 14151, 25157, 32767}, { 4793, 14783, 26280, 32767},
|
||||
{ 5007, 15442, 27452, 32767}, { 5231, 16132, 28678, 32767},
|
||||
{ 5464, 16851, 29957, 32767}, { 5708, 17603, 31294, 32767},
|
||||
{ 5963, 18389, 32691, 32767}, { 6229, 19210, 32767, 32767},
|
||||
{ 6507, 20067, 32767, 32767}, { 6797, 20963, 32767, 32767},
|
||||
{ 7101, 21899, 32767, 32767}, { 7418, 22876, 32767, 32767},
|
||||
{ 7749, 23897, 32767, 32767}, { 8095, 24964, 32767, 32767},
|
||||
{ 8456, 26078, 32767, 32767}, { 8833, 27242, 32767, 32767},
|
||||
{ 9228, 28457, 32767, 32767}, { 9639, 29727, 32767, 32767}
|
||||
};
|
||||
|
||||
static const int16_t MACEtab4[][2] = {
|
||||
{ 64, 216}, { 67, 226}, { 70, 236}, { 74, 246},
|
||||
{ 77, 257}, { 80, 268}, { 84, 280}, { 88, 294},
|
||||
{ 92, 307}, { 96, 321}, { 100, 334}, { 104, 350},
|
||||
{ 109, 365}, { 114, 382}, { 119, 399}, { 124, 416},
|
||||
{ 130, 434}, { 136, 454}, { 142, 475}, { 148, 495},
|
||||
{ 155, 519}, { 162, 541}, { 169, 564}, { 176, 590},
|
||||
{ 185, 617}, { 193, 644}, { 201, 673}, { 210, 703},
|
||||
{ 220, 735}, { 230, 767}, { 240, 801}, { 251, 838},
|
||||
{ 262, 876}, { 274, 914}, { 286, 955}, { 299, 997},
|
||||
{ 312, 1041}, { 326, 1089}, { 341, 1138}, { 356, 1188},
|
||||
{ 372, 1241}, { 388, 1297}, { 406, 1354}, { 424, 1415},
|
||||
{ 443, 1478}, { 462, 1544}, { 483, 1613}, { 505, 1684},
|
||||
{ 527, 1760}, { 551, 1838}, { 576, 1921}, { 601, 2007},
|
||||
{ 628, 2097}, { 656, 2190}, { 686, 2288}, { 716, 2389},
|
||||
{ 748, 2496}, { 781, 2607}, { 816, 2724}, { 853, 2846},
|
||||
{ 891, 2973}, { 930, 3104}, { 972, 3243}, { 1016, 3389},
|
||||
{ 1061, 3539}, { 1108, 3698}, { 1158, 3862}, { 1209, 4035},
|
||||
{ 1264, 4216}, { 1320, 4403}, { 1379, 4599}, { 1441, 4806},
|
||||
{ 1505, 5019}, { 1572, 5244}, { 1642, 5477}, { 1715, 5722},
|
||||
{ 1792, 5978}, { 1872, 6245}, { 1955, 6522}, { 2043, 6813},
|
||||
{ 2134, 7118}, { 2229, 7436}, { 2329, 7767}, { 2432, 8114},
|
||||
{ 2541, 8477}, { 2655, 8854}, { 2773, 9250}, { 2897, 9663},
|
||||
{ 3026, 10094}, { 3162, 10546}, { 3303, 11016}, { 3450, 11508},
|
||||
{ 3604, 12020}, { 3765, 12556}, { 3933, 13118}, { 4108, 13703},
|
||||
{ 4292, 14315}, { 4483, 14953}, { 4683, 15621}, { 4892, 16318},
|
||||
{ 5111, 17046}, { 5339, 17807}, { 5577, 18602}, { 5826, 19433},
|
||||
{ 6086, 20300}, { 6358, 21205}, { 6642, 22152}, { 6938, 23141},
|
||||
{ 7248, 24173}, { 7571, 25252}, { 7909, 26380}, { 8262, 27557},
|
||||
{ 8631, 28786}, { 9016, 30072}, { 9419, 31413}, { 9839, 32767},
|
||||
{ 10278, 32767}, { 10737, 32767}, { 11216, 32767}, { 11717, 32767},
|
||||
{ 12240, 32767}, { 12786, 32767}, { 13356, 32767}, { 13953, 32767},
|
||||
{ 14576, 32767}, { 15226, 32767}, { 15906, 32767}, { 16615, 32767}
|
||||
};
|
||||
|
||||
static const struct {
|
||||
const int16_t *tab1; const int16_t *tab2; int stride;
|
||||
} tabs[] = {
|
||||
{MACEtab1, &MACEtab2[0][0], 4},
|
||||
{MACEtab3, &MACEtab4[0][0], 2},
|
||||
{MACEtab1, &MACEtab2[0][0], 4}
|
||||
#include "macedec.h"
|
||||
|
||||
static const int16_t MACEtab1[] = {-13, 8, 76, 222, 222, 76, 8, -13};
|
||||
|
||||
static const int16_t MACEtab3[] = {-18, 140, 140, -18};
|
||||
|
||||
static const int16_t MACEtab2[][4] = {
|
||||
{ 37, 116, 206, 330}, { 39, 121, 216, 346},
|
||||
{ 41, 127, 225, 361}, { 42, 132, 235, 377},
|
||||
{ 44, 137, 245, 392}, { 46, 144, 256, 410},
|
||||
{ 48, 150, 267, 428}, { 51, 157, 280, 449},
|
||||
{ 53, 165, 293, 470}, { 55, 172, 306, 490},
|
||||
{ 58, 179, 319, 511}, { 60, 187, 333, 534},
|
||||
{ 63, 195, 348, 557}, { 66, 205, 364, 583},
|
||||
{ 69, 214, 380, 609}, { 72, 223, 396, 635},
|
||||
{ 75, 233, 414, 663}, { 79, 244, 433, 694},
|
||||
{ 82, 254, 453, 725}, { 86, 265, 472, 756},
|
||||
{ 90, 278, 495, 792}, { 94, 290, 516, 826},
|
||||
{ 98, 303, 538, 862}, { 102, 316, 562, 901},
|
||||
{ 107, 331, 588, 942}, { 112, 345, 614, 983},
|
||||
{ 117, 361, 641, 1027}, { 122, 377, 670, 1074},
|
||||
{ 127, 394, 701, 1123}, { 133, 411, 732, 1172},
|
||||
{ 139, 430, 764, 1224}, { 145, 449, 799, 1280},
|
||||
{ 152, 469, 835, 1337}, { 159, 490, 872, 1397},
|
||||
{ 166, 512, 911, 1459}, { 173, 535, 951, 1523},
|
||||
{ 181, 558, 993, 1590}, { 189, 584, 1038, 1663},
|
||||
{ 197, 610, 1085, 1738}, { 206, 637, 1133, 1815},
|
||||
{ 215, 665, 1183, 1895}, { 225, 695, 1237, 1980},
|
||||
{ 235, 726, 1291, 2068}, { 246, 759, 1349, 2161},
|
||||
{ 257, 792, 1409, 2257}, { 268, 828, 1472, 2357},
|
||||
{ 280, 865, 1538, 2463}, { 293, 903, 1606, 2572},
|
||||
{ 306, 944, 1678, 2688}, { 319, 986, 1753, 2807},
|
||||
{ 334, 1030, 1832, 2933}, { 349, 1076, 1914, 3065},
|
||||
{ 364, 1124, 1999, 3202}, { 380, 1174, 2088, 3344},
|
||||
{ 398, 1227, 2182, 3494}, { 415, 1281, 2278, 3649},
|
||||
{ 434, 1339, 2380, 3811}, { 453, 1398, 2486, 3982},
|
||||
{ 473, 1461, 2598, 4160}, { 495, 1526, 2714, 4346},
|
||||
{ 517, 1594, 2835, 4540}, { 540, 1665, 2961, 4741},
|
||||
{ 564, 1740, 3093, 4953}, { 589, 1818, 3232, 5175},
|
||||
{ 615, 1898, 3375, 5405}, { 643, 1984, 3527, 5647},
|
||||
{ 671, 2072, 3683, 5898}, { 701, 2164, 3848, 6161},
|
||||
{ 733, 2261, 4020, 6438}, { 766, 2362, 4199, 6724},
|
||||
{ 800, 2467, 4386, 7024}, { 836, 2578, 4583, 7339},
|
||||
{ 873, 2692, 4786, 7664}, { 912, 2813, 5001, 8008},
|
||||
{ 952, 2938, 5223, 8364}, { 995, 3070, 5457, 8739},
|
||||
{ 1039, 3207, 5701, 9129}, { 1086, 3350, 5956, 9537},
|
||||
{ 1134, 3499, 6220, 9960}, { 1185, 3655, 6497, 10404},
|
||||
{ 1238, 3818, 6788, 10869}, { 1293, 3989, 7091, 11355},
|
||||
{ 1351, 4166, 7407, 11861}, { 1411, 4352, 7738, 12390},
|
||||
{ 1474, 4547, 8084, 12946}, { 1540, 4750, 8444, 13522},
|
||||
{ 1609, 4962, 8821, 14126}, { 1680, 5183, 9215, 14756},
|
||||
{ 1756, 5415, 9626, 15415}, { 1834, 5657, 10057, 16104},
|
||||
{ 1916, 5909, 10505, 16822}, { 2001, 6173, 10975, 17574},
|
||||
{ 2091, 6448, 11463, 18356}, { 2184, 6736, 11974, 19175},
|
||||
{ 2282, 7037, 12510, 20032}, { 2383, 7351, 13068, 20926},
|
||||
{ 2490, 7679, 13652, 21861}, { 2601, 8021, 14260, 22834},
|
||||
{ 2717, 8380, 14897, 23854}, { 2838, 8753, 15561, 24918},
|
||||
{ 2965, 9144, 16256, 26031}, { 3097, 9553, 16982, 27193},
|
||||
{ 3236, 9979, 17740, 28407}, { 3380, 10424, 18532, 29675},
|
||||
{ 3531, 10890, 19359, 31000}, { 3688, 11375, 20222, 32382},
|
||||
{ 3853, 11883, 21125, 32767}, { 4025, 12414, 22069, 32767},
|
||||
{ 4205, 12967, 23053, 32767}, { 4392, 13546, 24082, 32767},
|
||||
{ 4589, 14151, 25157, 32767}, { 4793, 14783, 26280, 32767},
|
||||
{ 5007, 15442, 27452, 32767}, { 5231, 16132, 28678, 32767},
|
||||
{ 5464, 16851, 29957, 32767}, { 5708, 17603, 31294, 32767},
|
||||
{ 5963, 18389, 32691, 32767}, { 6229, 19210, 32767, 32767},
|
||||
{ 6507, 20067, 32767, 32767}, { 6797, 20963, 32767, 32767},
|
||||
{ 7101, 21899, 32767, 32767}, { 7418, 22876, 32767, 32767},
|
||||
{ 7749, 23897, 32767, 32767}, { 8095, 24964, 32767, 32767},
|
||||
{ 8456, 26078, 32767, 32767}, { 8833, 27242, 32767, 32767},
|
||||
{ 9228, 28457, 32767, 32767}, { 9639, 29727, 32767, 32767}
|
||||
};
|
||||
|
||||
static const int16_t MACEtab4[][2] = {
|
||||
{ 64, 216}, { 67, 226}, { 70, 236}, { 74, 246},
|
||||
{ 77, 257}, { 80, 268}, { 84, 280}, { 88, 294},
|
||||
{ 92, 307}, { 96, 321}, { 100, 334}, { 104, 350},
|
||||
{ 109, 365}, { 114, 382}, { 119, 399}, { 124, 416},
|
||||
{ 130, 434}, { 136, 454}, { 142, 475}, { 148, 495},
|
||||
{ 155, 519}, { 162, 541}, { 169, 564}, { 176, 590},
|
||||
{ 185, 617}, { 193, 644}, { 201, 673}, { 210, 703},
|
||||
{ 220, 735}, { 230, 767}, { 240, 801}, { 251, 838},
|
||||
{ 262, 876}, { 274, 914}, { 286, 955}, { 299, 997},
|
||||
{ 312, 1041}, { 326, 1089}, { 341, 1138}, { 356, 1188},
|
||||
{ 372, 1241}, { 388, 1297}, { 406, 1354}, { 424, 1415},
|
||||
{ 443, 1478}, { 462, 1544}, { 483, 1613}, { 505, 1684},
|
||||
{ 527, 1760}, { 551, 1838}, { 576, 1921}, { 601, 2007},
|
||||
{ 628, 2097}, { 656, 2190}, { 686, 2288}, { 716, 2389},
|
||||
{ 748, 2496}, { 781, 2607}, { 816, 2724}, { 853, 2846},
|
||||
{ 891, 2973}, { 930, 3104}, { 972, 3243}, { 1016, 3389},
|
||||
{ 1061, 3539}, { 1108, 3698}, { 1158, 3862}, { 1209, 4035},
|
||||
{ 1264, 4216}, { 1320, 4403}, { 1379, 4599}, { 1441, 4806},
|
||||
{ 1505, 5019}, { 1572, 5244}, { 1642, 5477}, { 1715, 5722},
|
||||
{ 1792, 5978}, { 1872, 6245}, { 1955, 6522}, { 2043, 6813},
|
||||
{ 2134, 7118}, { 2229, 7436}, { 2329, 7767}, { 2432, 8114},
|
||||
{ 2541, 8477}, { 2655, 8854}, { 2773, 9250}, { 2897, 9663},
|
||||
{ 3026, 10094}, { 3162, 10546}, { 3303, 11016}, { 3450, 11508},
|
||||
{ 3604, 12020}, { 3765, 12556}, { 3933, 13118}, { 4108, 13703},
|
||||
{ 4292, 14315}, { 4483, 14953}, { 4683, 15621}, { 4892, 16318},
|
||||
{ 5111, 17046}, { 5339, 17807}, { 5577, 18602}, { 5826, 19433},
|
||||
{ 6086, 20300}, { 6358, 21205}, { 6642, 22152}, { 6938, 23141},
|
||||
{ 7248, 24173}, { 7571, 25252}, { 7909, 26380}, { 8262, 27557},
|
||||
{ 8631, 28786}, { 9016, 30072}, { 9419, 31413}, { 9839, 32767},
|
||||
{ 10278, 32767}, { 10737, 32767}, { 11216, 32767}, { 11717, 32767},
|
||||
{ 12240, 32767}, { 12786, 32767}, { 13356, 32767}, { 13953, 32767},
|
||||
{ 14576, 32767}, { 15226, 32767}, { 15906, 32767}, { 16615, 32767}
|
||||
};
|
||||
|
||||
static const struct {
|
||||
const int16_t *tab1; const int16_t *tab2; int stride;
|
||||
} tabs[] = {
|
||||
{MACEtab1, &MACEtab2[0][0], 4},
|
||||
{MACEtab3, &MACEtab4[0][0], 2},
|
||||
{MACEtab1, &MACEtab2[0][0], 4}
|
||||
};
|
||||
|
||||
static uint8_t CompactOutput(int16_t v)
|
||||
{
|
||||
return ((v >> 8) & 0xff) ^ 0x80;
|
||||
}
|
||||
|
||||
/**
|
||||
* MACE version of av_clip_int16(). We have to do this to keep binary
|
||||
* identical output to the binary decoder.
|
||||
*/
|
||||
static inline int16_t mace_broken_clip_int16(int n)
|
||||
{
|
||||
if (n > 32767)
|
||||
return 32767;
|
||||
else if (n < -32768)
|
||||
return -32767;
|
||||
else
|
||||
return n;
|
||||
}
|
||||
|
||||
static int16_t read_table(MaceChannelDecState *chd, uint8_t val, int tab_idx)
|
||||
{
|
||||
int16_t current;
|
||||
|
||||
if (val < tabs[tab_idx].stride)
|
||||
current = tabs[tab_idx].tab2[((chd->index & 0x7f0) >> 4) * tabs[tab_idx].stride + val];
|
||||
else
|
||||
current = - 1 - tabs[tab_idx].tab2[((chd->index & 0x7f0) >> 4)*tabs[tab_idx].stride + 2*tabs[tab_idx].stride-val-1];
|
||||
|
||||
if (( chd->index += tabs[tab_idx].tab1[val]-(chd->index >> 5) ) < 0)
|
||||
chd->index = 0;
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
static void chomp3(MaceChannelDecState *chd, uint8_t *output, uint8_t val, int tab_idx)
|
||||
{
|
||||
|
||||
int16_t current = read_table(chd, val, tab_idx);
|
||||
|
||||
current = mace_broken_clip_int16(current + chd->level);
|
||||
|
||||
chd->level = current - (current >> 3);
|
||||
*output = CompactOutput(current);
|
||||
}
|
||||
|
||||
static void chomp6(MaceChannelDecState *chd, uint8_t *output, uint8_t val, int tab_idx)
|
||||
{
|
||||
int16_t current = read_table(chd, val, tab_idx);
|
||||
|
||||
if ((chd->previous ^ current) >= 0) {
|
||||
chd->factor = std::min<int32_t>(chd->factor + 506, 32767);
|
||||
} else {
|
||||
if (chd->factor - 314 < -32768)
|
||||
chd->factor = -32767;
|
||||
else
|
||||
chd->factor -= 314;
|
||||
}
|
||||
|
||||
current = mace_broken_clip_int16(current + chd->level);
|
||||
|
||||
chd->level = (current*chd->factor) >> 15;
|
||||
current >>= 1;
|
||||
|
||||
output[0] = CompactOutput(chd->previous + chd->prev2 -
|
||||
((chd->prev2-current) >> 2));
|
||||
output[1] = CompactOutput(chd->previous + current +
|
||||
((chd->prev2-current) >> 2));
|
||||
chd->prev2 = chd->previous;
|
||||
chd->previous = current;
|
||||
{
|
||||
return ((v >> 8) & 0xff) ^ 0x80;
|
||||
}
|
||||
|
||||
/**
|
||||
* MACE version of av_clip_int16(). We have to do this to keep binary
|
||||
* identical output to the binary decoder.
|
||||
*/
|
||||
static inline int16_t mace_broken_clip_int16(int n)
|
||||
{
|
||||
if (n > 32767)
|
||||
return 32767;
|
||||
else if (n < -32768)
|
||||
return -32767;
|
||||
else
|
||||
return n;
|
||||
}
|
||||
|
||||
static int16_t read_table(MaceChannelDecState *chd, uint8_t val, int tab_idx)
|
||||
{
|
||||
int16_t current;
|
||||
|
||||
if (val < tabs[tab_idx].stride)
|
||||
current = tabs[tab_idx].tab2[((chd->index & 0x7f0) >> 4) * tabs[tab_idx].stride + val];
|
||||
else
|
||||
current = - 1 - tabs[tab_idx].tab2[((chd->index & 0x7f0) >> 4)*tabs[tab_idx].stride + 2*tabs[tab_idx].stride-val-1];
|
||||
|
||||
if (( chd->index += tabs[tab_idx].tab1[val]-(chd->index >> 5) ) < 0)
|
||||
chd->index = 0;
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
static void chomp3(MaceChannelDecState *chd, uint8_t *output, uint8_t val, int tab_idx)
|
||||
{
|
||||
|
||||
int16_t current = read_table(chd, val, tab_idx);
|
||||
|
||||
current = mace_broken_clip_int16(current + chd->level);
|
||||
|
||||
chd->level = current - (current >> 3);
|
||||
*output = CompactOutput(current);
|
||||
}
|
||||
|
||||
static void chomp6(MaceChannelDecState *chd, uint8_t *output, uint8_t val, int tab_idx)
|
||||
{
|
||||
int16_t current = read_table(chd, val, tab_idx);
|
||||
|
||||
if ((chd->previous ^ current) >= 0) {
|
||||
chd->factor = std::min<int32_t>(chd->factor + 506, 32767);
|
||||
} else {
|
||||
if (chd->factor - 314 < -32768)
|
||||
chd->factor = -32767;
|
||||
else
|
||||
chd->factor -= 314;
|
||||
}
|
||||
|
||||
current = mace_broken_clip_int16(current + chd->level);
|
||||
|
||||
chd->level = (current*chd->factor) >> 15;
|
||||
current >>= 1;
|
||||
|
||||
output[0] = CompactOutput(chd->previous + chd->prev2 -
|
||||
((chd->prev2-current) >> 2));
|
||||
output[1] = CompactOutput(chd->previous + current +
|
||||
((chd->prev2-current) >> 2));
|
||||
chd->prev2 = chd->previous;
|
||||
chd->previous = current;
|
||||
}
|
||||
|
||||
void DecodeMACE3(MaceChannelDecState *chd, uint8_t pkt, uint8_t *output)
|
||||
{
|
||||
uint8_t val[3] = { pkt & 7 , (pkt >> 3) & 3, pkt >> 5 };
|
||||
|
||||
{
|
||||
uint8_t val[3] = { pkt & 7 , (pkt >> 3) & 3, pkt >> 5 };
|
||||
|
||||
for (int l = 0; l < 3; l++)
|
||||
{
|
||||
chomp3(chd, output, val[l], l);
|
||||
output++;
|
||||
}
|
||||
}
|
||||
|
||||
void DecodeMACE6(MaceChannelDecState *chd, uint8_t pkt, uint8_t *output)
|
||||
{
|
||||
uint8_t val[3] = {pkt >> 5, (pkt >> 3) & 3, pkt & 7 };
|
||||
|
||||
{
|
||||
chomp3(chd, output, val[l], l);
|
||||
output++;
|
||||
}
|
||||
}
|
||||
|
||||
void DecodeMACE6(MaceChannelDecState *chd, uint8_t pkt, uint8_t *output)
|
||||
{
|
||||
uint8_t val[3] = {pkt >> 5, (pkt >> 3) & 3, pkt & 7 };
|
||||
|
||||
for (int l = 0; l < 3; l++)
|
||||
{
|
||||
{
|
||||
chomp6(chd, output, val[l], l);
|
||||
output += 2;
|
||||
}
|
||||
}
|
||||
output += 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ SOFTWARE.
|
||||
#include "ScopedPtr.h"
|
||||
#include "BinHex4.h"
|
||||
#include "MacBinary2.h"
|
||||
#include "MacFileMem.h"
|
||||
#include "MacFileMem.h"
|
||||
#include "GpAllocator_C.h"
|
||||
|
||||
using namespace PortabilityLayer;
|
||||
|
||||
@@ -54,7 +55,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
CFileStream fs(f, true, false, true);
|
||||
|
||||
ScopedPtr<MacFileMem> memFile = BinHex4::LoadHQX(&fs);
|
||||
ScopedPtr<MacFileMem> memFile = BinHex4::LoadHQX(&fs, GpAllocator_C::GetInstance());
|
||||
|
||||
fs.Close();
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\Debug.props" />
|
||||
<Import Project="..\AerofoilPortable.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
@@ -48,6 +49,7 @@
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\Release.props" />
|
||||
<Import Project="..\AerofoilPortable.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
@@ -74,6 +76,7 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\AerofoilPortable\GpAllocator_C.cpp" />
|
||||
<ClCompile Include="hqx2bin.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -18,5 +18,8 @@
|
||||
<ClCompile Include="hqx2bin.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\AerofoilPortable\GpAllocator_C.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -25,6 +25,7 @@ SOFTWARE.
|
||||
#include "CFileStream.h"
|
||||
#include "CombinedTimestamp.h"
|
||||
#include "DeflateCodec.h"
|
||||
#include "GpAllocator_C.h"
|
||||
#include "ScopedPtr.h"
|
||||
#include "BinHex4.h"
|
||||
#include "MacBinary2.h"
|
||||
@@ -75,7 +76,7 @@ int toolMain(int argc, const char **argv)
|
||||
|
||||
CFileStream fs(f, true, false, true);
|
||||
|
||||
ScopedPtr<MacFileMem> memFile = BinHex4::LoadHQX(&fs);
|
||||
ScopedPtr<MacFileMem> memFile = BinHex4::LoadHQX(&fs, GpAllocator_C::GetInstance());
|
||||
|
||||
fs.Close();
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\Debug.props" />
|
||||
<Import Project="..\WindowsUnicodeToolShim.props" />
|
||||
<Import Project="..\AerofoilPortable.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
@@ -50,6 +51,7 @@
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\Release.props" />
|
||||
<Import Project="..\WindowsUnicodeToolShim.props" />
|
||||
<Import Project="..\AerofoilPortable.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
@@ -76,6 +78,7 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\AerofoilPortable\GpAllocator_C.cpp" />
|
||||
<ClCompile Include="hqx2gp.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -18,5 +18,8 @@
|
||||
<ClCompile Include="hqx2gp.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\AerofoilPortable\GpAllocator_C.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user