GSLA: seems to be spitting out a file, but is is valid?

This commit is contained in:
JASON-6700K\jandersen 2020-07-19 17:21:04 -04:00
parent 8dfb3028c7
commit 1c0f4d5ae3
3 changed files with 19 additions and 6 deletions

View File

@ -351,6 +351,8 @@ void GSLAFile::SaveToFile(const char* pFilenamePath)
pINIT->I = 'I'; pINIT->N = 'N'; pINIT->i = 'I'; pINIT->T = 'T'; pINIT->I = 'I'; pINIT->N = 'N'; pINIT->i = 'I'; pINIT->T = 'T';
pINIT->chunk_length = 0; // temp chunk size pINIT->chunk_length = 0; // temp chunk size
printf("Save Initial Frame\n");
// Need a place to put compressed data, in theory it could be bigger // Need a place to put compressed data, in theory it could be bigger
// than the original data, I think if that happens, the image was probably // than the original data, I think if that happens, the image was probably
// designed to break this, anyway, give double theoretical max // designed to break this, anyway, give double theoretical max
@ -362,6 +364,8 @@ void GSLAFile::SaveToFile(const char* pFilenamePath)
// dictionary - Also use the best compression we can get here // dictionary - Also use the best compression we can get here
int compressedSize = Old_LZB_Compress(pWorkBuffer, pInitialFrame, m_frameSize); int compressedSize = Old_LZB_Compress(pWorkBuffer, pInitialFrame, m_frameSize);
printf("frameSize = %d\n", compressedSize);
for (int compressedIndex = 0; compressedIndex < compressedSize; ++compressedIndex) for (int compressedIndex = 0; compressedIndex < compressedSize; ++compressedIndex)
{ {
bytes.push_back(pWorkBuffer[ compressedIndex ]); bytes.push_back(pWorkBuffer[ compressedIndex ]);
@ -396,11 +400,11 @@ void GSLAFile::SaveToFile(const char* pFilenamePath)
unsigned char *pCanvas = new unsigned char[ m_frameSize ]; unsigned char *pCanvas = new unsigned char[ m_frameSize ];
memcpy(pCanvas, m_pC1PixelMaps[0], m_frameSize); memcpy(pCanvas, m_pC1PixelMaps[0], m_frameSize);
memcpy(pCanvas, m_pC1PixelMaps[0], m_frameSize);
// Let's encode some frames buddy // Let's encode some frames buddy
for (int frameIndex = 1; frameIndex < m_pC1PixelMaps.size(); ++frameIndex) for (int frameIndex = 1; frameIndex < m_pC1PixelMaps.size(); ++frameIndex)
{ {
printf("Save Frame %d\n", frameIndex+1);
// I don't want random data in the bank gaps, so initialize this // I don't want random data in the bank gaps, so initialize this
// buffer with zero // buffer with zero
//memset(pWorkBuffer, 0, m_frameSize * 2); //memset(pWorkBuffer, 0, m_frameSize * 2);
@ -409,6 +413,9 @@ void GSLAFile::SaveToFile(const char* pFilenamePath)
m_frameSize, pWorkBuffer-bytes.size(), m_frameSize, pWorkBuffer-bytes.size(),
pCanvas, m_frameSize ); pCanvas, m_frameSize );
printf("frameSize = %d\n", frameSize);
for (int frameIndex = 0; frameIndex < frameSize; ++frameIndex) for (int frameIndex = 0; frameIndex < frameSize; ++frameIndex)
{ {
bytes.push_back(pWorkBuffer[ frameIndex ]); bytes.push_back(pWorkBuffer[ frameIndex ]);
@ -418,10 +425,14 @@ void GSLAFile::SaveToFile(const char* pFilenamePath)
// Add the RING Frame // Add the RING Frame
//memset(pWorkBuffer, 0, m_frameSize * 2); //memset(pWorkBuffer, 0, m_frameSize * 2);
printf("Save Ring Frame\n");
int ringSize = LZBA_Compress(pWorkBuffer, m_pC1PixelMaps[ 0 ], int ringSize = LZBA_Compress(pWorkBuffer, m_pC1PixelMaps[ 0 ],
m_frameSize, pWorkBuffer-bytes.size(), m_frameSize, pWorkBuffer-bytes.size(),
pCanvas, m_frameSize ); pCanvas, m_frameSize );
printf("Ring Size %d\n", ringSize);
for (int ringIndex = 0; ringIndex < ringSize; ++ringIndex) for (int ringIndex = 0; ringIndex < ringSize; ++ringIndex)
{ {
bytes.push_back(pWorkBuffer[ ringIndex ]); bytes.push_back(pWorkBuffer[ ringIndex ]);

View File

@ -262,7 +262,7 @@ static int AddDictionary(const DataString& data, int dictionarySize)
pDictionary[ dictionarySize++ ] = data.pData[ dataIndex++ ]; pDictionary[ dictionarySize++ ] = data.pData[ dataIndex++ ];
} }
dictionarySize += data.size; //dictionarySize += data.size;
return dictionarySize; return dictionarySize;
} }
@ -824,7 +824,7 @@ int LZBA_Compress(unsigned char* pDest, unsigned char* pSource, int sourceSize,
int gapCount = 0; int gapCount = 0;
for (; tempCursorPosition < dictionarySize; ++tempCursorPosition) for (; tempCursorPosition < dictionarySize; ++tempCursorPosition)
{ {
if (pSource[ cursorPosition ] != pDictionary[ cursorPosition ]) if (pSource[ tempCursorPosition ] != pDictionary[ tempCursorPosition ])
{ {
gapCount = 0; gapCount = 0;
} }
@ -844,7 +844,9 @@ int LZBA_Compress(unsigned char* pDest, unsigned char* pSource, int sourceSize,
// it from one part of the frame buffer to another part) // it from one part of the frame buffer to another part)
sourceData.pData = &pSource[ cursorPosition ]; sourceData.pData = &pSource[ cursorPosition ];
sourceData.size = tempCursorPosition - cursorPosition; sourceData.size = tempCursorPosition - cursorPosition + 1;
cursorPosition = tempCursorPosition;
while (sourceData.size > 0) while (sourceData.size > 0)
{ {

View File

@ -124,7 +124,7 @@ int main(int argc, char* argv[])
GSLAFile anim(320,200, 0x8000); GSLAFile anim(320,200, 0x8000);
anim.AddImages(c1Datas); anim.AddImages(c1Datas);
anim.SaveToFile(pOutfilePath); anim.SaveToFile(pOutfilePath);
} }