Git Product home page Git Product logo

inflatecpp's Introduction

Inflate++

Code Size GitHub issues GitHub license

Inflate++ is a single function call (optional), memory-to-memory decompressor for the zlib and deflate bitstream formats:

RFC 1950: ZLIB specification

RFC 1951: DEFLATE specification

RFC 1952: GZIP specification

Inflate++ is less than 1000 lines of C++ (excluding aproximatly 250 lines of the adler checksum implementation), and decompresses faster than the original zlib method.

Decompressing large raw texture file (zlib bitstream, 60,132,846 bytes compressed to 25,614,357):

Decompressor                     Time (microseconds)
zlib inflate 1.2.11              134,245 (100%)
Inflate++ (with checksum)        118,399 (91%)
Inflate++ (without checksum)     110,238 (85%)

Decompressing GZIP format archive (gzip bitstream, 147,120,395 bytes compressed to 53,625,384):

Decompressor                      Time (microseconds) 
zlib inflate 1.2.11               465,567 (100%)
Inflate++ (with checksum)         362,133 (87%)
Inflate++ (without checksum)      265,462 (65%)

Usage

First, you need to include all source files given in this repository to your project. Then include "decompressor.h" in your code and you are ready to go.

You can use the "decompressor.h" as follows:

#include <iostream>
#include <stdio.h>

#include "<dir>\decompressor.h"

int main(int argc, const char *argv[])
{
	Decompressor example_decompressor = Decompressor();

	unsigned int compressed_data_size = ...
	unsigned int max_decompressed_data_size = 200000000; // As an example
	unsigned char *compressed_data = new unsigned char[compressed_data_size];
	unsigned char *decompressed_data = new unsigned char[max_decompressed_data_size];

	// ...
	// assign values to "compressed_data"  
	// ...

	unsigned int decompressed_data_size = example_decompressor.Feed(compressed_data,
		compressed_data_size, decompressed_data, max_decompressed_data_size, true);
		// Use "true" as fifth argument of "Feed()" if you want to use the checksum
		
	if(decompressed_data_size == -1)
	{
		std::cout << "decompression error!" << std::endl;
		delete [] compressed_data;
		delete [] decompressed_data;

		return 0;
	}

	std::cout << "decompressed " << decompressed_data_size << " bytes";

	// ...
	// use the decompressed data stored in "decompressed_data"
	// ...

	return 0;
}

See example NOTE: To build the example just run build.bat in the command prompt (windows).


License

Inflate++ is developed by Artexety inspired by Mark Adlers zlib decompression. The adler checksum compution by Mark Adler. The gzip crc32 checksum by Stephen Brumme. All code is licensed under the permissive free software license (MIT). All mentions are included in the source code aswell.

inflatecpp's People

Contributors

artexety avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

media-kit sergcpp

inflatecpp's Issues

Use of max decompressed.

I was just wondering whether there was a need for max decompressed size at all. I wasn't 100% sure where you needed and or used it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.