Commit Graph

74 Commits

Author SHA1 Message Date
Eugene Kliuchnikov
ab858a9f1e Limit |size| in BrotliSetCustomDictionary 2016-04-27 16:52:24 +02:00
Eugene Kliuchnikov
e7e3849835 Update decoder. Add encoder interface wrapper.
* condense printf in port.h; use BROTLI_LOG everywhere
 * mark non-exported functions with BROTLI_INTERNAL
 * use BROTLI_DUMP instead of (void)(BROTLI_FAILURE())
 * fix problems with CustomDictionary
 * make decode.h independent of state.h
 * fix "double-new-lines"
 * fix some strict compilation warnings
 * fix bro.cc compilation for MSVS
 * added compressor.h as a replacement for encode.h + streams.h
2016-04-19 16:29:10 +02:00
Eugene Kliuchnikov
23934731f5 Update decoder:
* More clear/safe "copy" command stage implementation
 * Enable unaligned memory access only on whitelisted CPUs
 * Remove unused streams.{c|h}
 * Add "default" to all switches
 * Fix includes
 * Fix spacing everywhere
2016-02-18 15:03:44 +01:00
eustas
68f5bbda76 Update decode.c 2016-02-04 15:42:53 +01:00
eustas
37a320dd81 Fix possible pointer underflow 2016-02-04 15:35:44 +01:00
eustas
ee9464e3b0 Remove NO_ASAN annotation 2016-01-28 16:32:38 +01:00
eustas
02c606d444 Make memmove16 safe. 2016-01-28 16:28:36 +01:00
Eugene Kliuchnikov
92e3023914 Update decoder.
* Reduce memory usage
 * Update API documentation
 * Remove deprecated API
 * Move non-API declatarions from decode.h
 * Remove streams
 * Add more debug logging
 * Fix shift in BrotliBitReaderUnload
 * Allocate ringbuffer at later stages
 * Sort / fix includes
 * Fix whitespaces
 * Eliminate dead code
 * Drive-by code simplifications
2016-01-22 10:19:41 +01:00
Eugene Klyuchnikov
24ffa78414 Fix headers 2015-12-11 11:11:51 +01:00
Eugene Klyuchnikov
771eb10798 Update license statement in source files. 2015-11-27 11:27:11 +01:00
Eugene Klyuchnikov
b693812271 Decoder: implement custom allocator feature
Drive-by: conform stricter compilation flags; cleanup shared.mk
2015-11-23 10:21:09 +01:00
eustas
65b4baf0b8 Fix implicit type conversion 2015-11-07 11:52:13 +01:00
Eugene Klyuchnikov
c0ba6d6f5e Brotli decoder: implement new streaming API 2015-11-06 11:46:04 +01:00
Tim Rühsen
b9e413faa6 Make internal decoder functions static
Affected functions: WriteRingBuffer, CopyUncompressedBlockToOutput,
                    BrotliAllocateRingBuffer
2015-10-27 11:22:16 +01:00
Zoltan Szabadka
bacc734997 Fix some more compiler warnings in the decoder. 2015-10-05 10:23:32 +02:00
Zoltan Szabadka
d3eb6ecb9a Add BROTLI_FREE macro, check malloc status after histogram allocations. 2015-10-02 16:19:30 +02:00
Zoltan Szabadka
03c4ab5967 Simplify uncompressed block decoding state machine. 2015-09-28 12:40:39 +02:00
Zoltan Szabadka
5919712922 Avoid undefined behavior from memcpy for the portable build. 2015-09-28 12:38:29 +02:00
Zoltan Szabadka
3cd3a1066a Small speedup of command decoding. 2015-09-28 12:34:40 +02:00
Zoltan Szabadka
85301238ea Fix a bug in CopyUncompressedBlockToOutput(). 2015-09-25 17:43:54 +02:00
Zoltan Szabadka
b04f6248be Fix a bug in uncompressed block handling. 2015-09-25 12:05:39 +02:00
Zoltan Szabadka
0cf3a54422 Update brotli decoder with latest improvements. 2015-09-24 18:35:25 +02:00
Zoltan Szabadka
1216684d0b Merge remote-tracking branch 'upstream/master' 2015-09-23 12:26:07 +02:00
Zoltan Szabadka
a7cedfc26d Update brotli decoder with latest improvements. 2015-09-23 12:24:06 +02:00
Marcin Karpinski
21ac39f7c8 Fix typos. 2015-09-21 21:04:07 +02:00
Eugene Klyuchnikov
127aa48a96 Fix bug in decoder.
Minor cleanup.
2015-09-01 12:18:22 +02:00
Lode Vandevenne
db71549ac5 update brotli decoder with latest improvements 2015-08-28 15:20:24 +02:00
Zoltan Szabadka
944c3b8290 Remove non-standard <malloc.h> from decode.c
The already included <stdlib.h> is enough for the malloc/free calls.
2015-08-11 11:07:26 +02:00
Zoltan Szabadka
4b2fd00e24 Use a single lookup table for insert/copy offsets and extra bits.
Remove safe_malloc.c since all the bounds checking is done inside
decode.c now.
2015-08-10 16:39:50 +02:00
Lode Vandevenne
94cd7085f7 brotli decoder performance improvements 2015-08-10 13:35:23 +02:00
Lode Vandevenne
bad0f4edf1 Brotli Bug Fixes 2015-06-26 17:37:00 +02:00
Zoltan Szabadka
b43df8f699 Brotli custom LZ77 dictionary support.
Adds functions to prepend such dictionary to the
encoder and decoder, and twiddles their internal
parameters to do as if that was a previous part of
the input. This dictionary is just a prefilled LZ77
window, it is not related to the built in transformable
brotli dictionary.
2015-06-12 15:43:54 +02:00
Zoltan Szabadka
641bc15882 Speedups and fixes to the decoder.
* Read data by 4-byte runs.
    This resolves unaligned read (Bus error) on arm-android.

  * Get rid of malloc/free in BrotliBuildHuffmanTable.

  * Tweak order of instructions when reading Huffman codes.
2015-06-12 15:12:23 +02:00
Zoltan Szabadka
54f69c9ef7 Support window bits 10 - 15 in the decoder.
The previous window bit value 17 is used to
extend the range, since it has not been used
in any previous encoders.
2015-05-07 17:44:33 +02:00
Zoltan Szabadka
5f39d607ef Decoder optimizations for ARM architecture. 2015-05-07 17:10:27 +02:00
Zoltan Szabadka
83aa24dc86 Speed and memory usage improvements for the decoder.
* Change order of members of bit reader state structure.

* Remove unused includes for assert. Add BROTLI_DCHECK
  macros and use it instead of assert.

* Do not calculate nbits in common case of ReadSymbol.

* Introduce and use PREDICT_TRUE / PREDICT_FALSE macros.

* Allocate less memory in the brotli decoder if it knows
  the result size beforehand. Before this, the decoder
  would always allocate 16MB if the encoder annotated the
  window size as 22 bit (which is the default), even if the
  file is only a few KB uncompressed. Now, it'll only
  allocate a ringbuffer as large as needed for the result file.
  But only if it can know the filesize, it's not possible
  to know that if there are multiple metablocks or too large
  uncompressed metablock.
2015-05-07 16:53:43 +02:00
Zoltan Szabadka
fe14d7b32a Fix an error propagation bug in the decoder. 2015-04-28 10:07:12 +02:00
Zoltan Szabadka
64c261113f Add partial output support to the decoder. 2015-04-22 17:33:21 +02:00
Zoltan Szabadka
28b1f7a6b1 Implement some stricter format checks in the decoder.
- Reject brotli streams where the number of
    nibbles is too large for the size of the
    meta-block
  - Reject brotli streams where the padding
    bits after a meta-block are not all zero
  - Reject brotli streams where the symbol
    in the simple prefix code is not in
    the symbol alphabet
2015-04-22 14:35:21 +02:00
Zoltan Szabadka
a81f2ef433 Decoder support for new empty meta-block format.
This change enforces the new 16MB limit on the
size of the meta-blocks and adds support for
empty meta-blocks with optional ignored metadata.
2015-04-22 14:25:08 +02:00
Zoltan Szabadka
2a7bbfc553 Update the previous two bytes when decoding an
uncompressed metablock.
2015-04-01 16:23:18 +02:00
Zoltan Szabadka
fac8993bef Add a missing state transition to CopyUncompressedBlockToOutput(). 2015-04-01 16:20:16 +02:00
Zoltan Szabadka
fe6e5d1cd9 Faster decoder for data with trivial context maps.
This makes it 20% faster when decoding data with
trivial context map (where the histogram type
depends only on the block type and not the
context).
2015-04-01 16:15:39 +02:00
Lode Vandevenne
f9e5a2d9f2 bugfixes affecting streaming decoding 2015-03-30 18:00:40 +02:00
Zoltan Szabadka
8f3092a0b1 Add some missing state transitions to DecodeContextMap().
Update the states in DecodeContextMap to the next one,
else it would continue at the wrong spot if exactly there
the partial input is split.
2015-03-30 13:39:20 +02:00
Zoltan Szabadka
c5ccd0dff9 Change the return value of decoder functions from integer codes to an enum. 2015-03-27 13:54:43 +01:00
Lode Vandevenne
85abce6c6e Propagate error condition from ReadHuffmanCodeLengths() 2015-03-26 17:40:07 +01:00
Lode Vandevenne
b142207917 a few more tweaks to the streaming support 2015-03-20 17:03:11 +01:00
Lode Vandevenne
8270250b40 support for partial input (streaming) 2015-03-20 16:13:15 +01:00
Zoltan Szabadka
6da0c5c992 Implement a 32-bit bitstream decoder.
The 64-bit bitstream decoder seems to have portability problems
with emscripten/asm.js as it does not compile into working code.
2015-02-25 13:32:17 +01:00