compression

Coroutine demo source

我只是一个虾纸丫 提交于 2019-11-30 19:28:43
问题 Here's an example of a program, where coroutines really help to simplify the algorithm - imho its hardly possible to implement otherwise. I also tried to choose a useful task for the demo - this utility converts a binary file to a sequence of A-Z symbols (and back), without any significant redundancy, and it has an ability to work with any specified alphabet (see M.Init line). Basically its something like generalized base64. The code is tested and worked with MSC,IntelC and gcc/mingw. Update:

LZ4 library decompressed data upper bound size estimation

最后都变了- 提交于 2019-11-30 19:09:36
I'm using LZ4 library and when decompressing data with int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize); I want to estimate maximum decompressed data size. But I can not find reverse function of int LZ4_compressBound(int isize); with which I can determine the upper bound for decompressed data, which to provide to last parameter maxDecompressedSize , of decompressing function. Other compression libraries like snappy for example, provides such function. bool GetUncompressedLength(Source* source, uint32* result); What can I do if I have not

Can compressed javascript be uncompressed

孤街醉人 提交于 2019-11-30 18:54:47
Is it possible to uncompress (if that's the right term even) for code like below? var vote=function(){var k={informModerator:-1,undoMod:0,acceptedByOwner:1,upMod:2,downMod:3,offensive:4,favorite:5,close:6,reopen:7,deletion:10,undeletion:11,spam:12};var f=imagePath+"vote-arrow-down.png";var c=imagePath+"vote-arrow-down-on.png";var x=imagePath+"vote-arrow-up.png";var w=imagePath+"vote-arrow-up-on.png";var A=imagePath+"vote-favorite-on.png";var o=imagePath+"vote-favorite-off.png";var l=function(){var C='<a href="/users/login?returnurl='+escape(document.location)+'">login or register</a>';$("div

Uncompress GZIPed HTTP Response in Java

£可爱£侵袭症+ 提交于 2019-11-30 18:49:28
I'm trying to uncompress a GZIPed HTTP Response by using GZIPInputStream . However I always have the same exception when I try to read the stream : java.util.zip.ZipException: invalid bit length repeat My HTTP Request Header: GET www.myurl.com HTTP/1.0\r\n User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2) Gecko/20100115 Firefox/3.6\r\n Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3\r\n Accept-Encoding: gzip,deflate\r\n Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7\r\n Keep-Alive: 115\r\n

What's the best audio compression library for .NET?

不想你离开。 提交于 2019-11-30 18:02:08
问题 I'm looking for a good audio compression library for .NET. Anything using MP3 is out (because of the licensing issue). Basically I just need to be able to compress regular WAV audio data into some format, and decompress back to WAV. Preferably the code would be all .NET (C# or VB.NET), but I don't think this is likely. It should either be lossless or relatively lossless (as good as 192 MP3s, preferably), with a compression ratio at least as good as 4:1. I'd prefer a buffer-based API, but a

How to tell if a file is gzip compressed?

喜夏-厌秋 提交于 2019-11-30 17:08:32
I have a Python program which is going to take text files as input. However, some of these files may be gzip compressed. Is there a cross-platform, usable from Python way to determine if a file is gzip compressed or not? Is the following reliable or could an ordinary text file 'accidentally' look gzip-like enough for me to get false positives? try: gzip.GzipFile(filename, 'r') # compressed # ... except: # not compressed # ... The magic number for gzip compressed files is 1f 8b . Although testing for this is not 100% reliable, it is highly unlikely that "ordinary text files" start with those

HTTP: What is the preferred Accept-Encoding for “gzip,deflate”?

被刻印的时光 ゝ 提交于 2019-11-30 16:55:48
问题 This question is regarding the order of precedence for the media-types of the HTTP Header "Accept-Encoding" when all are of equal weight and has been prompted by this comment on my blog. Background: The Accept-Encoding header takes a comma separated list of media-types the browser can accept e.g. gzip,deflate A quality factor can also be specified to give preference to other media-types e.g. in the case of "gzip;q=.8,deflate", deflate is preferred - but is not relevant to this question . NB:

Lossless compression method to shorten string before base64 encoding to make it shorter?

孤人 提交于 2019-11-30 16:50:07
问题 just built a small webapp for previewing HTML-documents that generates URL:s containing the HTML (and all inline CSS and Javascript) in base64 encoded data. Problem is, the URL:s quickly get kinda long. What is the "de facto" standard way (preferably by Javascript ) to compress the string first without data loss? PS; I read about Huffman and Lempel-Ziv in school some time ago, and I remember really enjoying LZW :) EDIT: Solution found; seems like rawStr => utf8Str => lzwStr => base64Str is

A simple regex search and replacement in php for minifying/compressing javascript?

血红的双手。 提交于 2019-11-30 15:20:38
问题 Can you post a regex search and replacement in php for minifying/compressing javascript? For example, here's a simple one for CSS header('Content-type: text/css'); ob_start("compress"); function compress($buffer) { /* remove comments */ $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); /* remove tabs, spaces, newlines, etc. */ $buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer); return $buffer; } /* put CSS here */ ob_end_flush(); And here's

Compression of ASCII strings in C

梦想的初衷 提交于 2019-11-30 14:53:41
问题 I have some C code that stores ASCII strings in memory as a four byte length followed by the string. The string lengths are in the range 10-250 bytes. To reduce occupancy I'd like to compress each string individually on the fly, still storing the length (of the compressed string) followed by the compressed string. I don't want to compress at a larger scope than individual strings because any string can be read/written at any time. What libraries/algorithms are available for doing this? Thanks