Changes for debug testing in ANIM bitstream encoder

This commit is contained in:
Jack Andersen 2016-08-28 12:29:49 -10:00
parent b4b19d460c
commit 969e2a86de
3 changed files with 29 additions and 22 deletions

View File

@ -452,9 +452,9 @@ BitstreamWriter::write(const std::vector<std::vector<Value>>& chanKeys,
it != kit->end();
++it)
{
QuantizedValue cur = {atInt32(it->v3.vec[0] * rotDivOut),
atInt32(it->v3.vec[1] * rotDivOut),
atInt32(it->v3.vec[2] * rotDivOut)};
QuantizedValue cur = {atInt32(it->v3.vec[0] / scaleMultOut),
atInt32(it->v3.vec[1] / scaleMultOut),
atInt32(it->v3.vec[2] / scaleMultOut)};
chan.q[0] = std::max(chan.q[0], atUint8(ceilf(log2f(cur[0] - last[0]))));
chan.q[1] = std::max(chan.q[1], atUint8(ceilf(log2f(cur[1] - last[1]))));
chan.q[2] = std::max(chan.q[2], atUint8(ceilf(log2f(cur[2] - last[2]))));
@ -469,7 +469,7 @@ BitstreamWriter::write(const std::vector<std::vector<Value>>& chanKeys,
/* Generate Bitstream */
sizeOut = ComputeBitstreamSize(keyFrameCount, channels);
atUint8* newData = new atUint8[sizeOut];
std::unique_ptr<atUint8[]> newData(new atUint8[sizeOut]);
for (size_t f=0 ; f<keyFrameCount ; ++f)
{
kit = chanKeys.begin();
@ -485,10 +485,10 @@ BitstreamWriter::write(const std::vector<std::vector<Value>>& chanKeys,
++it)
{
QuantizedRot qrCur = QuantizeRotation(*it, rotDivOut);
quantizeBit(newData, qrCur.w);
quantize(newData, chan.q[0], qrCur.v[0] - qrLast.v[0]);
quantize(newData, chan.q[1], qrCur.v[1] - qrLast.v[1]);
quantize(newData, chan.q[2], qrCur.v[2] - qrLast.v[2]);
quantizeBit(newData.get(), qrCur.w);
quantize(newData.get(), chan.q[0], qrCur.v[0] - qrLast.v[0]);
quantize(newData.get(), chan.q[1], qrCur.v[1] - qrLast.v[1]);
quantize(newData.get(), chan.q[2], qrCur.v[2] - qrLast.v[2]);
qrLast = qrCur;
}
break;
@ -505,9 +505,9 @@ BitstreamWriter::write(const std::vector<std::vector<Value>>& chanKeys,
QuantizedValue cur = {atInt32(it->v3.vec[0] / transMultOut),
atInt32(it->v3.vec[1] / transMultOut),
atInt32(it->v3.vec[2] / transMultOut)};
quantize(newData, chan.q[0], cur[0] - last[0]);
quantize(newData, chan.q[1], cur[1] - last[1]);
quantize(newData, chan.q[2], cur[2] - last[2]);
quantize(newData.get(), chan.q[0], cur[0] - last[0]);
quantize(newData.get(), chan.q[1], cur[1] - last[1]);
quantize(newData.get(), chan.q[2], cur[2] - last[2]);
last = cur;
}
break;
@ -524,9 +524,9 @@ BitstreamWriter::write(const std::vector<std::vector<Value>>& chanKeys,
QuantizedValue cur = {atInt32(it->v3.vec[0] / scaleMultOut),
atInt32(it->v3.vec[1] / scaleMultOut),
atInt32(it->v3.vec[2] / scaleMultOut)};
quantize(newData, chan.q[0], cur[0] - last[0]);
quantize(newData, chan.q[1], cur[1] - last[1]);
quantize(newData, chan.q[2], cur[2] - last[2]);
quantize(newData.get(), chan.q[0], cur[0] - last[0]);
quantize(newData.get(), chan.q[1], cur[1] - last[1]);
quantize(newData.get(), chan.q[2], cur[2] - last[2]);
last = cur;
}
break;
@ -536,7 +536,7 @@ BitstreamWriter::write(const std::vector<std::vector<Value>>& chanKeys,
++kit;
}
}
return std::unique_ptr<atUint8[]>(newData);
return newData;
}
}

View File

@ -1244,7 +1244,7 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
{
hecl::SystemStringView sysStr(act.name);
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true).ensureAuxInfo(_S("ANIM"));
hecl::ProjectPath cookedOut = inPath.getCookedPath(SpecEntMP1).getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true);
hecl::ProjectPath cookedOut = inPath.getCookedPath(SpecEntMP1PC).getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true);
athena::io::FileWriter w(cookedOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),

View File

@ -10,7 +10,9 @@ void CFBStreamedAnimReaderTotals::Allocate(u32 chanCount)
u32 chan2 = chanCount * 2;
u32 chan32 = chanCount * 32;
x0_buffer.reset(new u8[chan32 + chanCount + chan2 + chan32]);
size_t sz = chan32 + chanCount + chan2 + chan32;
x0_buffer.reset(new u8[sz]);
memset(x0_buffer.get(), 0, sz);
x4_cumulativeInts32 = reinterpret_cast<s32*>(x0_buffer.get());
x8_hasTrans1 = reinterpret_cast<u8*>(x4_cumulativeInts32 + chanCount * 8);
xc_segIds2 = reinterpret_cast<u16*>(x8_hasTrans1 + chanCount);
@ -19,6 +21,7 @@ void CFBStreamedAnimReaderTotals::Allocate(u32 chanCount)
void CFBStreamedAnimReaderTotals::Initialize(const CFBStreamedCompression& source)
{
x20_calculated = false;
const u8* chans = source.GetPerChannelHeaders();
u32 boneChanCount = *reinterpret_cast<const u32*>(chans);
chans += 4;
@ -194,6 +197,10 @@ CFBStreamedPairOfTotals::CFBStreamedPairOfTotals(const TSubAnimTypeToken<CFBStre
void CFBStreamedPairOfTotals::SetTime(CBitLevelLoader& loader, const CCharAnimTime& time)
{
/* Implementation is a bit different than original;
* T evaluated pre-emptively with key indices.
* CalculateDown is also called here as needed. */
const CFBStreamedCompression::Header& header = x0_source->MainHeader();
CCharAnimTime interval(header.interval);
const u32* timeBitmap = x0_source->GetTimes();
@ -262,13 +269,13 @@ u32 CBitLevelLoader::LoadUnsigned(u8 q)
/* Fill 32 bit buffer with region containing bits */
/* Make them least significant */
u32 tempBuf = hecl::SBig(*reinterpret_cast<const u32*>(m_data + byteCur)) >> bitRem;
u32 tempBuf = *reinterpret_cast<const u32*>(m_data + byteCur) >> bitRem;
/* If this shift underflows the value, buffer the next 32 bits */
/* And tack onto shifted buffer */
if ((bitRem + q) > 32)
{
u32 tempBuf2 = hecl::SBig(*reinterpret_cast<const u32*>(m_data + byteCur + 4));
u32 tempBuf2 = *reinterpret_cast<const u32*>(m_data + byteCur + 4);
tempBuf |= (tempBuf2 << (32 - bitRem));
}
@ -288,13 +295,13 @@ s32 CBitLevelLoader::LoadSigned(u8 q)
/* Fill 32 bit buffer with region containing bits */
/* Make them least significant */
u32 tempBuf = hecl::SBig(*reinterpret_cast<const u32*>(m_data + byteCur)) >> bitRem;
u32 tempBuf = *reinterpret_cast<const u32*>(m_data + byteCur) >> bitRem;
/* If this shift underflows the value, buffer the next 32 bits */
/* And tack onto shifted buffer */
if ((bitRem + q) > 32)
{
u32 tempBuf2 = hecl::SBig(*reinterpret_cast<const u32*>(m_data + byteCur + 4));
u32 tempBuf2 = *reinterpret_cast<const u32*>(m_data + byteCur + 4);
tempBuf |= (tempBuf2 << (32 - bitRem));
}
@ -319,7 +326,7 @@ bool CBitLevelLoader::LoadBool()
/* Fill 32 bit buffer with region containing bits */
/* Make them least significant */
u32 tempBuf = hecl::SBig(*reinterpret_cast<const u32*>(m_data + byteCur)) >> bitRem;
u32 tempBuf = *reinterpret_cast<const u32*>(m_data + byteCur) >> bitRem;
/* That's it */
m_bitIdx += 1;