Fix broken importer and add some review findings2
parent
3e09d462fa
commit
52b6c4f7c0
|
@ -175,7 +175,7 @@ void BlenderImporter::InternReadFile(const std::string &pFile,
|
||||||
|
|
||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
Compression compression;
|
Compression compression;
|
||||||
if (compression.open(Compression::Format::Binary, Compression::FlushMode::Finish) ) {
|
if (compression.open(Compression::Format::Binary, Compression::FlushMode::NoFlush, 16 + MAX_WBITS)) {
|
||||||
total = compression.decompress((unsigned char *)reader->GetPtr(), reader->GetRemainingSize(), uncompressed);
|
total = compression.decompress((unsigned char *)reader->GetPtr(), reader->GetRemainingSize(), uncompressed);
|
||||||
compression.close();
|
compression.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,7 +567,7 @@ void ReadBinaryDataArray(char type, uint32_t count, const char*& data, const cha
|
||||||
// zlib/deflate, next comes ZIP head (0x78 0x01)
|
// zlib/deflate, next comes ZIP head (0x78 0x01)
|
||||||
// see http://www.ietf.org/rfc/rfc1950.txt
|
// see http://www.ietf.org/rfc/rfc1950.txt
|
||||||
Compression compress;
|
Compression compress;
|
||||||
if (compress.open(Compression::Format::Binary, Compression::FlushMode::Finish)) {
|
if (compress.open(Compression::Format::Binary, Compression::FlushMode::Finish,0)) {
|
||||||
compress.decompress(data, comp_len, buff);
|
compress.decompress(data, comp_len, buff);
|
||||||
compress.close();
|
compress.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ XFileParser::XFileParser(const std::vector<char> &pBuffer) :
|
||||||
Compression compression;
|
Compression compression;
|
||||||
uncompressed.resize(est_out + 1);
|
uncompressed.resize(est_out + 1);
|
||||||
char *out = &uncompressed.front();
|
char *out = &uncompressed.front();
|
||||||
if (compression.open(mIsBinaryFormat ? Compression::Format::Binary : Compression::Format::ASCII, Compression::FlushMode::SyncFlush)) {
|
if (compression.open(mIsBinaryFormat ? Compression::Format::Binary : Compression::Format::ASCII, Compression::FlushMode::SyncFlush, -MAX_WBITS)) {
|
||||||
while (mP + 3 < mEnd) {
|
while (mP + 3 < mEnd) {
|
||||||
uint16_t ofs = *((uint16_t *)mP);
|
uint16_t ofs = *((uint16_t *)mP);
|
||||||
AI_SWAP2(ofs);
|
AI_SWAP2(ofs);
|
||||||
|
|
|
@ -132,7 +132,7 @@ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
|
|
||||||
Compression compression;
|
Compression compression;
|
||||||
size_t total = 0l;
|
size_t total = 0l;
|
||||||
if (compression.open(Compression::Format::Binary, Compression::FlushMode::NoFlush)) {
|
if (compression.open(Compression::Format::Binary, Compression::FlushMode::NoFlush, -MAX_WBITS)) {
|
||||||
// skip two extra bytes, zgl files do carry a crc16 upfront (I think)
|
// skip two extra bytes, zgl files do carry a crc16 upfront (I think)
|
||||||
raw_reader->IncPtr(2);
|
raw_reader->IncPtr(2);
|
||||||
total = compression.decompress((unsigned char *)raw_reader->GetPtr(), raw_reader->GetRemainingSize(), uncompressed);
|
total = compression.decompress((unsigned char *)raw_reader->GetPtr(), raw_reader->GetRemainingSize(), uncompressed);
|
||||||
|
|
|
@ -43,11 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/ai_assert.h>
|
#include <assimp/ai_assert.h>
|
||||||
#include <assimp/Exceptional.h>
|
#include <assimp/Exceptional.h>
|
||||||
|
|
||||||
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
|
||||||
#include <zlib.h>
|
|
||||||
#else
|
|
||||||
#include "../contrib/zlib/zlib.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
|
@ -73,7 +68,7 @@ Compression::~Compression() {
|
||||||
delete mImpl;
|
delete mImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Compression::open(Format format, FlushMode flush) {
|
bool Compression::open(Format format, FlushMode flush, int windowBits) {
|
||||||
ai_assert(mImpl != nullptr);
|
ai_assert(mImpl != nullptr);
|
||||||
|
|
||||||
if (mImpl->mOpen) {
|
if (mImpl->mOpen) {
|
||||||
|
@ -92,7 +87,11 @@ bool Compression::open(Format format, FlushMode flush) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// raw decompression without a zlib or gzip header
|
// raw decompression without a zlib or gzip header
|
||||||
|
if (windowBits == 0) {
|
||||||
inflateInit(&mImpl->mZSstream);
|
inflateInit(&mImpl->mZSstream);
|
||||||
|
} else {
|
||||||
|
inflateInit2(&mImpl->mZSstream, windowBits);
|
||||||
|
}
|
||||||
mImpl->mOpen = true;
|
mImpl->mOpen = true;
|
||||||
|
|
||||||
return mImpl->mOpen;
|
return mImpl->mOpen;
|
||||||
|
|
|
@ -41,6 +41,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef ASSIMP_BUILD_NO_OWN_ZLIB
|
||||||
|
#include <zlib.h>
|
||||||
|
#else
|
||||||
|
#include "../contrib/zlib/zlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
@ -49,20 +55,20 @@ namespace Assimp {
|
||||||
class Compression {
|
class Compression {
|
||||||
public:
|
public:
|
||||||
enum class Format {
|
enum class Format {
|
||||||
|
InvalidFormat = -1,
|
||||||
Binary = 0,
|
Binary = 0,
|
||||||
ASCII,
|
ASCII,
|
||||||
|
|
||||||
NumFormats,
|
NumFormats
|
||||||
InvalidFormat
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class FlushMode {
|
enum class FlushMode {
|
||||||
|
InvalidFormat = -1,
|
||||||
NoFlush = 0,
|
NoFlush = 0,
|
||||||
SyncFlush,
|
SyncFlush,
|
||||||
Finish,
|
Finish,
|
||||||
|
|
||||||
NumModes,
|
NumModes
|
||||||
InvalidMode
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief The class constructor.
|
/// @brief The class constructor.
|
||||||
|
@ -73,7 +79,7 @@ public:
|
||||||
|
|
||||||
/// @brief Will open the access to the compression.
|
/// @brief Will open the access to the compression.
|
||||||
/// @return true if close was successful, false if not.
|
/// @return true if close was successful, false if not.
|
||||||
bool open(Format format, FlushMode flush);
|
bool open(Format format, FlushMode flush, int windowBits);
|
||||||
|
|
||||||
/// @brief Will return the open state.
|
/// @brief Will return the open state.
|
||||||
/// @return true if the access is opened, false if not.
|
/// @return true if the access is opened, false if not.
|
||||||
|
|
Loading…
Reference in New Issue