@@ -345,6 +345,13 @@ value: u32) -> i32 {
345345 params. byte_align = value != 0 ;
346346 return 1i32 ;
347347 }
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+ }
348355 0i32
349356}
350357
@@ -403,6 +410,7 @@ pub fn BrotliEncoderInitParams() -> BrotliEncoderParams {
403410 prior_bitmask_detection : 0 ,
404411 literal_adaptation : [ ( 0 , 0 ) ; 4 ] ,
405412 byte_align : false ,
413+ bare_stream : false ,
406414 catable : false ,
407415 use_dictionary : true ,
408416 appendable : false ,
@@ -627,7 +635,10 @@ pub fn SanitizeParams(params: &mut BrotliEncoderParams) {
627635 }
628636 }
629637 if params. catable {
630- params. appendable = true ;
638+ params. appendable = true ;
639+ }
640+ if params. bare_stream {
641+ params. byte_align = true ;
631642 }
632643}
633644
@@ -727,7 +738,9 @@ fn EnsureInitialized<Alloc: BrotliAlloc>
727738 if ( * s) . params . quality == 0i32 || ( * s) . params . quality == 1i32 {
728739 lgwin = brotli_max_int ( lgwin, 18i32 ) ;
729740 }
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+ }
731744 }
732745 if ( * s) . params . quality == 0i32 {
733746 InitCommandPrefixCodes ( & mut ( * s) . cmd_depths_ [ ..] ,
@@ -2024,7 +2037,9 @@ fn WriteMetaBlockInternal<Alloc: BrotliAlloc,
20242037 if params. byte_align && ( ( * storage_ix & 7u32 as ( usize ) ) != 0 ) {
20252038 BrotliStoreSyncMetaBlock ( storage_ix, storage) ;
20262039 }
2027- BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2040+ if !params. bare_stream {
2041+ BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2042+ }
20282043 }
20292044 return ;
20302045 }
@@ -2168,7 +2183,9 @@ fn WriteMetaBlockInternal<Alloc: BrotliAlloc,
21682183 if params. byte_align && ( ( * storage_ix & 7u32 as ( usize ) ) != 0 ) {
21692184 BrotliStoreSyncMetaBlock ( storage_ix, storage) ;
21702185 }
2171- BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2186+ if !params. bare_stream {
2187+ BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2188+ }
21722189 }
21732190}
21742191
@@ -2255,7 +2272,7 @@ fn EncodeData<Alloc: BrotliAlloc,
22552272 }
22562273 let mut catable_header_size = 0 ;
22572274 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 ) {
22592276 if s. params . magic_number {
22602277 BrotliWriteMetadataMetaBlock ( & s. params , & mut storage_ix, ( * s) . storage_ . slice_mut ( ) ) ;
22612278 } else {
@@ -2276,7 +2293,7 @@ fn EncodeData<Alloc: BrotliAlloc,
22762293 }
22772294 if let IsFirst :: BothCatableBytesWritten = s. is_first_mb {
22782295 // nothing to do here, move along
2279- } else if !s. params . catable {
2296+ } else if !s. params . catable || s . params . bare_stream {
22802297 s. is_first_mb = IsFirst :: BothCatableBytesWritten ;
22812298 } else if bytes != 0 {
22822299 assert ! ( s. last_processed_pos_ < 2 || s. custom_dictionary) ;
0 commit comments