[Scummvm-cvs-logs] scummvm master -> c8826297a4d68fb35aecd7a66257c98fd118dc38

lordhoto lordhoto at gmail.com
Fri Jan 13 18:36:23 CET 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c8826297a4 COMMON: Enhance zlib interface


Commit: c8826297a4d68fb35aecd7a66257c98fd118dc38
    https://github.com/scummvm/scummvm/commit/c8826297a4d68fb35aecd7a66257c98fd118dc38
Author: Andrea Corna (a.corna at campus.unimib.it)
Date: 2012-01-13T09:33:04-08:00

Commit Message:
COMMON: Enhance zlib interface

Changed paths:
    common/zlib.cpp
    common/zlib.h



diff --git a/common/zlib.cpp b/common/zlib.cpp
index 70133fe..7d765fc 100644
--- a/common/zlib.cpp
+++ b/common/zlib.cpp
@@ -49,7 +49,7 @@ bool uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long
 	return Z_OK == ::uncompress(dst, dstLen, src, srcLen);
 }
 
-bool inflateZlibHeaderless(byte *dst, uint dstLen, const byte *src, uint srcLen) {
+bool inflateZlibHeaderless(byte *dst, uint dstLen, const byte *src, uint srcLen, const byte *dict, uint dictLen) {
 	if (!dst || !dstLen || !src || !srcLen)
 		return false;
 
@@ -68,6 +68,13 @@ bool inflateZlibHeaderless(byte *dst, uint dstLen, const byte *src, uint srcLen)
 	if (err != Z_OK)
 		return false;
 
+	// Set the dictionary, if provided
+	if (dict != 0) {
+		err = inflateSetDictionary(&stream, const_cast<byte *>(dict), dictLen);
+		if (err != Z_OK)
+			return false;
+	}
+
 	err = inflate(&stream, Z_SYNC_FLUSH);
 	if (err != Z_OK && err != Z_STREAM_END) {
 		inflateEnd(&stream);
diff --git a/common/zlib.h b/common/zlib.h
index 7af7df0..61322c2 100644
--- a/common/zlib.h
+++ b/common/zlib.h
@@ -37,7 +37,19 @@ class WriteStream;
  * it possible to uncompress data in engines without being forced to link
  * them against zlib, thus simplifying the build system.
  *
- * @return true on success (i.e. Z_OK), false otherwise
+ * Taken from the zlib manual:
+ * Decompresses the src buffer into the dst buffer.
+ * srcLen is the byte length of the source buffer. Upon entry, dstLen is the
+ * total size of the destination buffer, which must be large enough to hold
+ * the entire uncompressed data. Upon exit, dstLen is the actual size of the
+ * compressed buffer.
+ *
+ * @param dst       the buffer to store into.
+ * @param dstLen    a pointer to the size of the destination buffer.
+ * @param src       the data to be decompressed.
+ * @param srcLen    the size of the compressed data.
+ *
+ * @return true on success (i.e. Z_OK), false otherwise.
  */
 bool uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long srcLen);
 
@@ -46,9 +58,24 @@ bool uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long
  * necessary inflate functions to uncompress data compressed with deflate
  * but *not* with the standard zlib header.
  *
- * @return true on success (Z_OK or Z_STREAM_END), false otherwise
+ * Decompresses the src buffer into the dst buffer.
+ * srcLen is the byte length of the source buffer, dstLen is the byte
+ * length of the output buffer.
+ * It decompress as much data as possible, up to dstLen bytes.
+ * If a dictionary is provided through the dict buffer, uses it to initializes
+ * the internal decompression dictionary, before the decompression takes place.
+ *
+ * @param dst       the buffer to store into.
+ * @param dstLen    the size of the destination buffer.
+ * @param src       the data to be decompressed.
+ * @param dstLen    the size of the compressed data.
+ * @param dict      (optional) a decompress dictionary.
+ * @param dictLen   (optional) the size of the dictionary.
+ *                  Mandatory if dict is not 0.
+ *
+ * @return true on success (Z_OK or Z_STREAM_END), false otherwise.
  */
-bool inflateZlibHeaderless(byte *dst, uint dstLen, const byte *src, uint srcLen);
+bool inflateZlibHeaderless(byte *dst, uint dstLen, const byte *src, uint srcLen, const byte *dict = 0, uint dictLen = 0);
 
 #endif
 






More information about the Scummvm-git-logs mailing list