@@ -345,6 +345,13 @@ value: u32) -> i32 {
345
345
params. byte_align = value != 0 ;
346
346
return 1i32 ;
347
347
}
348
+ if p as ( i32 ) == BrotliEncoderParameter :: BROTLI_PARAM_BARE_STREAM as ( i32 ) {
349
+ params. bare_stream = value != 0 ;
350
+ if !params. byte_align {
351
+ params. byte_align = value != 0 ;
352
+ }
353
+ return 1i32 ;
354
+ }
348
355
0i32
349
356
}
350
357
@@ -403,6 +410,7 @@ pub fn BrotliEncoderInitParams() -> BrotliEncoderParams {
403
410
prior_bitmask_detection : 0 ,
404
411
literal_adaptation : [ ( 0 , 0 ) ; 4 ] ,
405
412
byte_align : false ,
413
+ bare_stream : false ,
406
414
catable : false ,
407
415
use_dictionary : true ,
408
416
appendable : false ,
@@ -627,7 +635,10 @@ pub fn SanitizeParams(params: &mut BrotliEncoderParams) {
627
635
}
628
636
}
629
637
if params. catable {
630
- params. appendable = true ;
638
+ params. appendable = true ;
639
+ }
640
+ if params. bare_stream {
641
+ params. byte_align = true ;
631
642
}
632
643
}
633
644
@@ -727,7 +738,9 @@ fn EnsureInitialized<Alloc: BrotliAlloc>
727
738
if ( * s) . params . quality == 0i32 || ( * s) . params . quality == 1i32 {
728
739
lgwin = brotli_max_int ( lgwin, 18i32 ) ;
729
740
}
730
- EncodeWindowBits ( lgwin, s. params . large_window , & mut ( * s) . last_bytes_ , & mut ( * s) . last_bytes_bits_ ) ;
741
+ if !( * s) . params . bare_stream {
742
+ EncodeWindowBits ( lgwin, s. params . large_window , & mut ( * s) . last_bytes_ , & mut ( * s) . last_bytes_bits_ ) ;
743
+ }
731
744
}
732
745
if ( * s) . params . quality == 0i32 {
733
746
InitCommandPrefixCodes ( & mut ( * s) . cmd_depths_ [ ..] ,
@@ -2024,7 +2037,9 @@ fn WriteMetaBlockInternal<Alloc: BrotliAlloc,
2024
2037
if params. byte_align && ( ( * storage_ix & 7u32 as ( usize ) ) != 0 ) {
2025
2038
BrotliStoreSyncMetaBlock ( storage_ix, storage) ;
2026
2039
}
2027
- BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2040
+ if !params. bare_stream {
2041
+ BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2042
+ }
2028
2043
}
2029
2044
return ;
2030
2045
}
@@ -2168,7 +2183,9 @@ fn WriteMetaBlockInternal<Alloc: BrotliAlloc,
2168
2183
if params. byte_align && ( ( * storage_ix & 7u32 as ( usize ) ) != 0 ) {
2169
2184
BrotliStoreSyncMetaBlock ( storage_ix, storage) ;
2170
2185
}
2171
- BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2186
+ if !params. bare_stream {
2187
+ BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2188
+ }
2172
2189
}
2173
2190
}
2174
2191
@@ -2255,7 +2272,7 @@ fn EncodeData<Alloc: BrotliAlloc,
2255
2272
}
2256
2273
let mut catable_header_size = 0 ;
2257
2274
if let IsFirst :: NothingWritten = s. is_first_mb {
2258
- if s. params . magic_number || ( s. params . byte_align && !s. params . catable && !s. params . appendable ) {
2275
+ if s. params . magic_number || ( s. params . byte_align && !s. params . catable && !s. params . appendable && !s . params . bare_stream ) {
2259
2276
if s. params . magic_number {
2260
2277
BrotliWriteMetadataMetaBlock ( & s. params , & mut storage_ix, ( * s) . storage_ . slice_mut ( ) ) ;
2261
2278
} else {
0 commit comments