-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Zstandard + compression level #1888
Conversation
Hmm, I can't accept a change that "presumes zstd library is installed". Either the zstd source code needs to be shipped or building with zstd support should be optional. |
Hi, fixed |
Appreciate the work done here by both of you, but I would really like this functionality. Is this something that will ever get merged into tiled? Otherwise I'll just fork tiled and keep it up to date myself. |
@Oipo So far I was rather reluctant to add this since I've heard nobody but @alphaonex86 about this and additional options do come at a maintenance cost. But you're the second person asking for this compression format, so maybe it's worth supporting it, especially since apparently the difference between zlib and zstd is significant enough that you'd maintain your own fork for it. That said, this patch makes it an optional build option and zstd will need to be available on the system when compiling Tiled, and probably will also require shipping additional files (unless it's statically linked). Any help getting zstd supported in the macOS, Windows and Linux builds would be very appreciated! |
Hi, I can help you to build with zstd on all OS, it's what's I do (include web assembly). |
Forward compression level to top method Last fix Fix compression method, now the zstd load and save correctly Try fix compression level but failed Try more Fix for gzip Do zstd optional, some improvements
@alphaonex86 I fixed the merge conflicts and pushed some fixes to my fork: https://github.com/Oipo/tiled/commits/master Perhaps you want to include those as well? |
@Oipo I've fixed up the merge conflicts as well and pushed it into @alphaonex86's |
@bjorn Adding zstd to the linux build/travis file is quite easy, but I don't know how to do it for the appveyor file. I assume that's the automated build for windows? Also, where is the build file for mac builds? |
* Preprocessor checks start on first column * Space between "if(" and after comma, "{" not on next line after "if" * Compression level "int" instead of "unsigned int" * Compression level -1 used to mean "default for compression method" * Default compression method back to Zlib * Don't arbitrarily refuse to set compression in Map::setCompressionLevel * "compressionlevel" -> "compressionLevel" * Don't pass member variable as argument to member function call in MapWriterPrivate * Fixed applying of compression level to child layers in Lua export
@Oipo Right, the I've just pushed a bunch of small cleanups. Note that also, the "optional" nature of this patch currently requires commenting out lines in the |
@alphaonex86 Why is a separate buffer allocated here which is then copied from, rather than compressing into a size_t const cBuffSize = ZSTD_compressBound(data.size());
void* const cBuff = malloc(cBuffSize);
if (!cBuff) {
qDebug() << "error to alloc" << cBuffSize;
return QByteArray();
}
size_t const cSize = ZSTD_compress(cBuff, cBuffSize, data.constData(), data.size(), compressionLevel);
if (ZSTD_isError(cSize)) {
qDebug() << "error compressing:" << ZSTD_getErrorName(cSize);
return QByteArray();
}
QByteArray data(static_cast<char *>(cBuff), cSize);
free(cBuff); |
As one can see this PR required still a bit of work, and we're not done yet since it's not trivial to adjust the build scripts on each platform as well as the Windows installer. I have to pause my efforts here, possibly until Tuesday or Thursday next week depending on whether there is time available in the evenings. |
I don't remember why now. I think it should be changed to QByteArray |
* Introduced Tiled::compressionToString to share creation of compression method string based on layer data format. * Hide "Base64 (Zstandard compressed)" in Properties window and in the New Map dialog when this compression method is not supported.
* Make zstd configurable in qbs/qmake * Have linux builds compile with Zstd * Directly use QByteArray for Zstd compression * Linux automated builds * OSX automated build * Windows automated build
Add Zstandard + compression level Closes #1886 Conflicts: src/libtiled/maptovariantconverter.cpp src/libtiled/maptovariantconverter.h src/libtiled/mapwriter.cpp src/plugins/lua/luaplugin.cpp src/tiled/changemapproperty.cpp src/tiled/changemapproperty.h src/tiled/propertybrowser.cpp src/tiled/propertybrowser.h
@Oipo Hmm, something regarding the static linking appears to not work properly. All Windows builds now require a |
That's weird. I'll check around on appveyor. |
I noticed that the output after "compiling static library" is empty in the AppVeyor build output. |
No description provided.