Skip to content

Commit

Permalink
brotli bit stream was only half done before... paste in the rest and …
Browse files Browse the repository at this point in the history
…start making it build
  • Loading branch information
danielrh committed Mar 30, 2017
1 parent e3efc82 commit e64c9c0
Show file tree
Hide file tree
Showing 10 changed files with 2,837 additions and 169 deletions.
6 changes: 2 additions & 4 deletions corrosion/postprocess/backward_references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2177,8 +2177,7 @@ fn FindLongestMatchH5(mut handle: &mut [u8],
}
}
}
*bucket[((num[(key as (usize))] as (u32) & (*xself).block_mask_) as (usize))..] = cur_ix as
(u32);
bucket[((num[(key as (usize))] as (u32) & (*xself).block_mask_) as (usize))] = cur_ix as (u32);
{
let _rhs = 1;
let _lhs = &mut num[(key as (usize))];
Expand Down Expand Up @@ -2556,8 +2555,7 @@ fn FindLongestMatchH6(mut handle: &mut [u8],
}
}
}
*bucket[((num[(key as (usize))] as (u32) & (*xself).block_mask_) as (usize))..] = cur_ix as
(u32);
bucket[((num[(key as (usize))] as (u32) & (*xself).block_mask_) as (usize))] = cur_ix as (u32);
{
let _rhs = 1;
let _lhs = &mut num[(key as (usize))];
Expand Down
1,357 changes: 1,357 additions & 0 deletions corrosion/postprocess/bit_cost.rs

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions corrosion/postprocess/block_splitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1836,8 +1836,8 @@ fn RemapBlockIdsLiteral(mut block_ids: &mut [u8],
while i < length {
{
0i32;
if *new_id[(block_ids[(i as (usize))] as (usize))..] as (i32) == kInvalidId as (i32) {
*new_id[(block_ids[(i as (usize))] as (usize))..] = {
if new_id[(block_ids[(i as (usize))] as (usize))] as (i32) == kInvalidId as (i32) {
new_id[(block_ids[(i as (usize))] as (usize))] = {
let _old = next_id;
next_id = (next_id as (i32) + 1) as (u16);
_old
Expand All @@ -1849,7 +1849,7 @@ fn RemapBlockIdsLiteral(mut block_ids: &mut [u8],
i = 0usize;
while i < length {
{
block_ids[(i as (usize))] = *new_id[(block_ids[(i as (usize))] as (usize))..] as (u8);
block_ids[(i as (usize))] = new_id[(block_ids[(i as (usize))] as (usize))] as (u8);
0i32;
}
i = i.wrapping_add(1 as (usize));
Expand Down Expand Up @@ -1877,7 +1877,7 @@ fn BuildBlockHistogramsLiteral(mut data: &[u8],
i = 0usize;
while i < length {
{
HistogramAddLiteral(&mut *histograms[(block_ids[(i as (usize))] as (usize))..],
HistogramAddLiteral(&mut histograms[(block_ids[(i as (usize))] as (usize))],
data[(i as (usize))] as (usize));
}
i = i.wrapping_add(1 as (usize));
Expand Down Expand Up @@ -2249,8 +2249,8 @@ fn ClusterBlocksLiteral(mut m: &mut [MemoryManager],
{
let cur_bits: f64 =
BrotliHistogramBitCostDistanceLiteral(&mut histo,
&mut *all_histograms[(clusters[(j as (usize))] as
(usize))..]);
&mut all_histograms[(clusters[(j as (usize))] as
(usize))]);
if cur_bits < best_bits {
best_bits = cur_bits;
best_out = clusters[(j as (usize))];
Expand Down Expand Up @@ -2350,7 +2350,7 @@ fn ClusterBlocksLiteral(mut m: &mut [MemoryManager],
if i.wrapping_add(1usize) == num_blocks ||
histogram_symbols[(i as (usize))] !=
histogram_symbols[(i.wrapping_add(1usize) as (usize))] {
let id: u8 = *new_index[(histogram_symbols[(i as (usize))] as (usize))..] as (u8);
let id: u8 = new_index[(histogram_symbols[(i as (usize))] as (usize))] as (u8);
*(*split).types[(block_idx as (usize))..] = id;
*(*split).lengths[(block_idx as (usize))..] = cur_length;
max_type = brotli_max_uint8_t(max_type, id);
Expand Down Expand Up @@ -2848,8 +2848,8 @@ fn RemapBlockIdsCommand(mut block_ids: &mut [u8],
while i < length {
{
0i32;
if *new_id[(block_ids[(i as (usize))] as (usize))..] as (i32) == kInvalidId as (i32) {
*new_id[(block_ids[(i as (usize))] as (usize))..] = {
if new_id[(block_ids[(i as (usize))] as (usize))] as (i32) == kInvalidId as (i32) {
new_id[(block_ids[(i as (usize))] as (usize))] = {
let _old = next_id;
next_id = (next_id as (i32) + 1) as (u16);
_old
Expand All @@ -2861,7 +2861,7 @@ fn RemapBlockIdsCommand(mut block_ids: &mut [u8],
i = 0usize;
while i < length {
{
block_ids[(i as (usize))] = *new_id[(block_ids[(i as (usize))] as (usize))..] as (u8);
block_ids[(i as (usize))] = new_id[(block_ids[(i as (usize))] as (usize))] as (u8);
0i32;
}
i = i.wrapping_add(1 as (usize));
Expand Down Expand Up @@ -2889,7 +2889,7 @@ fn BuildBlockHistogramsCommand(mut data: &[u16],
i = 0usize;
while i < length {
{
HistogramAddCommand(&mut *histograms[(block_ids[(i as (usize))] as (usize))..],
HistogramAddCommand(&mut histograms[(block_ids[(i as (usize))] as (usize))],
data[(i as (usize))] as (usize));
}
i = i.wrapping_add(1 as (usize));
Expand Down Expand Up @@ -3240,8 +3240,8 @@ fn ClusterBlocksCommand(mut m: &mut [MemoryManager],
{
let cur_bits: f64 =
BrotliHistogramBitCostDistanceCommand(&mut histo,
&mut *all_histograms[(clusters[(j as (usize))] as
(usize))..]);
&mut all_histograms[(clusters[(j as (usize))] as
(usize))]);
if cur_bits < best_bits {
best_bits = cur_bits;
best_out = clusters[(j as (usize))];
Expand Down Expand Up @@ -3341,7 +3341,7 @@ fn ClusterBlocksCommand(mut m: &mut [MemoryManager],
if i.wrapping_add(1usize) == num_blocks ||
histogram_symbols[(i as (usize))] !=
histogram_symbols[(i.wrapping_add(1usize) as (usize))] {
let id: u8 = *new_index[(histogram_symbols[(i as (usize))] as (usize))..] as (u8);
let id: u8 = new_index[(histogram_symbols[(i as (usize))] as (usize))] as (u8);
*(*split).types[(block_idx as (usize))..] = id;
*(*split).lengths[(block_idx as (usize))..] = cur_length;
max_type = brotli_max_uint8_t(max_type, id);
Expand Down Expand Up @@ -3840,8 +3840,8 @@ fn RemapBlockIdsDistance(mut block_ids: &mut [u8],
while i < length {
{
0i32;
if *new_id[(block_ids[(i as (usize))] as (usize))..] as (i32) == kInvalidId as (i32) {
*new_id[(block_ids[(i as (usize))] as (usize))..] = {
if new_id[(block_ids[(i as (usize))] as (usize))] as (i32) == kInvalidId as (i32) {
new_id[(block_ids[(i as (usize))] as (usize))] = {
let _old = next_id;
next_id = (next_id as (i32) + 1) as (u16);
_old
Expand All @@ -3853,7 +3853,7 @@ fn RemapBlockIdsDistance(mut block_ids: &mut [u8],
i = 0usize;
while i < length {
{
block_ids[(i as (usize))] = *new_id[(block_ids[(i as (usize))] as (usize))..] as (u8);
block_ids[(i as (usize))] = new_id[(block_ids[(i as (usize))] as (usize))] as (u8);
0i32;
}
i = i.wrapping_add(1 as (usize));
Expand Down Expand Up @@ -3881,7 +3881,7 @@ fn BuildBlockHistogramsDistance(mut data: &[u16],
i = 0usize;
while i < length {
{
HistogramAddDistance(&mut *histograms[(block_ids[(i as (usize))] as (usize))..],
HistogramAddDistance(&mut histograms[(block_ids[(i as (usize))] as (usize))],
data[(i as (usize))] as (usize));
}
i = i.wrapping_add(1 as (usize));
Expand Down Expand Up @@ -4236,8 +4236,8 @@ fn ClusterBlocksDistance(mut m: &mut [MemoryManager],
{
let cur_bits: f64 =
BrotliHistogramBitCostDistanceDistance(&mut histo,
&mut *all_histograms[(clusters[(j as (usize))] as
(usize))..]);
&mut all_histograms[(clusters[(j as (usize))] as
(usize))]);
if cur_bits < best_bits {
best_bits = cur_bits;
best_out = clusters[(j as (usize))];
Expand Down Expand Up @@ -4337,7 +4337,7 @@ fn ClusterBlocksDistance(mut m: &mut [MemoryManager],
if i.wrapping_add(1usize) == num_blocks ||
histogram_symbols[(i as (usize))] !=
histogram_symbols[(i.wrapping_add(1usize) as (usize))] {
let id: u8 = *new_index[(histogram_symbols[(i as (usize))] as (usize))..] as (u8);
let id: u8 = new_index[(histogram_symbols[(i as (usize))] as (usize))] as (u8);
*(*split).types[(block_idx as (usize))..] = id;
*(*split).lengths[(block_idx as (usize))..] = cur_length;
max_type = brotli_max_uint8_t(max_type, id);
Expand Down
10 changes: 3 additions & 7 deletions corrosion/postprocess/brotli_bit_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4909,10 +4909,6 @@ pub fn BrotliBuildAndStoreHuffmanTreeFast(mut m: &mut [MemoryManager],
bits[(symbols[0usize] as (usize))] = 0i32 as (u16);
return;
}
for depth_elem in depth[..length].iter_mut() {
*depth_elem = 0; // memset
}

memset(depth,
0i32,
length.wrapping_mul(::std::mem::size_of::<u8>()));
Expand Down Expand Up @@ -5349,8 +5345,8 @@ fn StoreSimpleHuffmanTree(mut depths: &[u8],
j = i.wrapping_add(1usize);
while j < num_symbols {
{
if *depths[(symbols[(j as (usize))] as (usize))..] as (i32) <
*depths[(symbols[(i as (usize))] as (usize))..] as (i32) {
if depths[(symbols[(j as (usize))] as (usize))] as (i32) <
depths[(symbols[(i as (usize))] as (usize))] as (i32) {
let mut __brotli_swap_tmp: usize = symbols[(j as (usize))];
symbols[(j as (usize))] = symbols[(i as (usize))];
symbols[(i as (usize))] = __brotli_swap_tmp;
Expand All @@ -5375,7 +5371,7 @@ fn StoreSimpleHuffmanTree(mut depths: &[u8],
BrotliWriteBits(max_bits, symbols[(2usize)], storage_ix, storage);
BrotliWriteBits(max_bits, symbols[(3usize)], storage_ix, storage);
BrotliWriteBits(1usize,
if *depths[(symbols[(0usize)] as (usize))..] as (i32) == 1i32 {
if depths[(symbols[(0usize)] as (usize))] as (i32) == 1i32 {
1i32
} else {
0i32
Expand Down
63 changes: 30 additions & 33 deletions corrosion/postprocess/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1641,10 +1641,9 @@ pub fn BrotliHistogramRemapLiteral(mut inp: &[HistogramLiteral],
j = 0usize;
while j < num_clusters {
{
let cur_bits: f64 = BrotliHistogramBitCostDistanceLiteral(&inp[(i as (usize))],
&mut *out[(clusters[(j as
(usize))] as
(usize))..]);
let cur_bits: f64 =
BrotliHistogramBitCostDistanceLiteral(&inp[(i as (usize))],
&mut out[(clusters[(j as (usize))] as (usize))]);
if cur_bits < best_bits {
best_bits = cur_bits;
best_out = clusters[(j as (usize))];
Expand All @@ -1659,14 +1658,14 @@ pub fn BrotliHistogramRemapLiteral(mut inp: &[HistogramLiteral],
i = 0usize;
while i < num_clusters {
{
HistogramClearLiteral(&mut *out[(clusters[(i as (usize))] as (usize))..]);
HistogramClearLiteral(&mut out[(clusters[(i as (usize))] as (usize))]);
}
i = i.wrapping_add(1 as (usize));
}
i = 0usize;
while i < in_size {
{
HistogramAddHistogramLiteral(&mut *out[(symbols[(i as (usize))] as (usize))..],
HistogramAddHistogramLiteral(&mut out[(symbols[(i as (usize))] as (usize))],
&inp[(i as (usize))]);
}
i = i.wrapping_add(1 as (usize));
Expand Down Expand Up @@ -1710,8 +1709,8 @@ pub fn BrotliHistogramReindexLiteral(mut m: &mut [MemoryManager],
i = 0usize;
while i < length {
{
if *new_index[(symbols[(i as (usize))] as (usize))..] == kInvalidIndex {
*new_index[(symbols[(i as (usize))] as (usize))..] = next_index;
if new_index[(symbols[(i as (usize))] as (usize))] == kInvalidIndex {
new_index[(symbols[(i as (usize))] as (usize))] = next_index;
next_index = next_index.wrapping_add(1 as (u32));
}
}
Expand All @@ -1730,11 +1729,11 @@ pub fn BrotliHistogramReindexLiteral(mut m: &mut [MemoryManager],
i = 0usize;
while i < length {
{
if *new_index[(symbols[(i as (usize))] as (usize))..] == next_index {
tmp[(next_index as (usize))] = *out[(symbols[(i as (usize))] as (usize))..];
if new_index[(symbols[(i as (usize))] as (usize))] == next_index {
tmp[(next_index as (usize))] = out[(symbols[(i as (usize))] as (usize))];
next_index = next_index.wrapping_add(1 as (u32));
}
symbols[(i as (usize))] = *new_index[(symbols[(i as (usize))] as (usize))..];
symbols[(i as (usize))] = new_index[(symbols[(i as (usize))] as (usize))];
}
i = i.wrapping_add(1 as (usize));
}
Expand Down Expand Up @@ -2160,10 +2159,9 @@ pub fn BrotliHistogramRemapCommand(mut inp: &[HistogramCommand],
j = 0usize;
while j < num_clusters {
{
let cur_bits: f64 = BrotliHistogramBitCostDistanceCommand(&inp[(i as (usize))],
&mut *out[(clusters[(j as
(usize))] as
(usize))..]);
let cur_bits: f64 =
BrotliHistogramBitCostDistanceCommand(&inp[(i as (usize))],
&mut out[(clusters[(j as (usize))] as (usize))]);
if cur_bits < best_bits {
best_bits = cur_bits;
best_out = clusters[(j as (usize))];
Expand All @@ -2178,14 +2176,14 @@ pub fn BrotliHistogramRemapCommand(mut inp: &[HistogramCommand],
i = 0usize;
while i < num_clusters {
{
HistogramClearCommand(&mut *out[(clusters[(i as (usize))] as (usize))..]);
HistogramClearCommand(&mut out[(clusters[(i as (usize))] as (usize))]);
}
i = i.wrapping_add(1 as (usize));
}
i = 0usize;
while i < in_size {
{
HistogramAddHistogramCommand(&mut *out[(symbols[(i as (usize))] as (usize))..],
HistogramAddHistogramCommand(&mut out[(symbols[(i as (usize))] as (usize))],
&inp[(i as (usize))]);
}
i = i.wrapping_add(1 as (usize));
Expand Down Expand Up @@ -2221,8 +2219,8 @@ pub fn BrotliHistogramReindexCommand(mut m: &mut [MemoryManager],
i = 0usize;
while i < length {
{
if *new_index[(symbols[(i as (usize))] as (usize))..] == kInvalidIndex {
*new_index[(symbols[(i as (usize))] as (usize))..] = next_index;
if new_index[(symbols[(i as (usize))] as (usize))] == kInvalidIndex {
new_index[(symbols[(i as (usize))] as (usize))] = next_index;
next_index = next_index.wrapping_add(1 as (u32));
}
}
Expand All @@ -2241,11 +2239,11 @@ pub fn BrotliHistogramReindexCommand(mut m: &mut [MemoryManager],
i = 0usize;
while i < length {
{
if *new_index[(symbols[(i as (usize))] as (usize))..] == next_index {
tmp[(next_index as (usize))] = *out[(symbols[(i as (usize))] as (usize))..];
if new_index[(symbols[(i as (usize))] as (usize))] == next_index {
tmp[(next_index as (usize))] = out[(symbols[(i as (usize))] as (usize))];
next_index = next_index.wrapping_add(1 as (u32));
}
symbols[(i as (usize))] = *new_index[(symbols[(i as (usize))] as (usize))..];
symbols[(i as (usize))] = new_index[(symbols[(i as (usize))] as (usize))];
}
i = i.wrapping_add(1 as (usize));
}
Expand Down Expand Up @@ -2667,10 +2665,9 @@ pub fn BrotliHistogramRemapDistance(mut inp: &[HistogramDistance],
j = 0usize;
while j < num_clusters {
{
let cur_bits: f64 = BrotliHistogramBitCostDistanceDistance(&inp[(i as (usize))],
&mut *out[(clusters[(j as
(usize))] as
(usize))..]);
let cur_bits: f64 =
BrotliHistogramBitCostDistanceDistance(&inp[(i as (usize))],
&mut out[(clusters[(j as (usize))] as (usize))]);
if cur_bits < best_bits {
best_bits = cur_bits;
best_out = clusters[(j as (usize))];
Expand All @@ -2685,14 +2682,14 @@ pub fn BrotliHistogramRemapDistance(mut inp: &[HistogramDistance],
i = 0usize;
while i < num_clusters {
{
HistogramClearDistance(&mut *out[(clusters[(i as (usize))] as (usize))..]);
HistogramClearDistance(&mut out[(clusters[(i as (usize))] as (usize))]);
}
i = i.wrapping_add(1 as (usize));
}
i = 0usize;
while i < in_size {
{
HistogramAddHistogramDistance(&mut *out[(symbols[(i as (usize))] as (usize))..],
HistogramAddHistogramDistance(&mut out[(symbols[(i as (usize))] as (usize))],
&inp[(i as (usize))]);
}
i = i.wrapping_add(1 as (usize));
Expand Down Expand Up @@ -2728,8 +2725,8 @@ pub fn BrotliHistogramReindexDistance(mut m: &mut [MemoryManager],
i = 0usize;
while i < length {
{
if *new_index[(symbols[(i as (usize))] as (usize))..] == kInvalidIndex {
*new_index[(symbols[(i as (usize))] as (usize))..] = next_index;
if new_index[(symbols[(i as (usize))] as (usize))] == kInvalidIndex {
new_index[(symbols[(i as (usize))] as (usize))] = next_index;
next_index = next_index.wrapping_add(1 as (u32));
}
}
Expand All @@ -2748,11 +2745,11 @@ pub fn BrotliHistogramReindexDistance(mut m: &mut [MemoryManager],
i = 0usize;
while i < length {
{
if *new_index[(symbols[(i as (usize))] as (usize))..] == next_index {
tmp[(next_index as (usize))] = *out[(symbols[(i as (usize))] as (usize))..];
if new_index[(symbols[(i as (usize))] as (usize))] == next_index {
tmp[(next_index as (usize))] = out[(symbols[(i as (usize))] as (usize))];
next_index = next_index.wrapping_add(1 as (u32));
}
symbols[(i as (usize))] = *new_index[(symbols[(i as (usize))] as (usize))..];
symbols[(i as (usize))] = new_index[(symbols[(i as (usize))] as (usize))];
}
i = i.wrapping_add(1 as (usize));
}
Expand Down
1 change: 0 additions & 1 deletion corrosion/postprocess/compress_fragment_two_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,6 @@ pub struct __sFILE {
}



static kHashMul32: u32 = 0x1e35a7bdu32;


Expand Down
2 changes: 0 additions & 2 deletions corrosion/postprocess/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1553,8 +1553,6 @@ pub struct __sFILE {
}




#[repr(i32)]
pub enum BrotliEncoderParameter {
BROTLI_PARAM_MODE = 0i32,
Expand Down
Loading

0 comments on commit e64c9c0

Please sign in to comment.