@@ -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_ [ ..] ,
@@ -2020,7 +2033,9 @@ fn WriteMetaBlockInternal<Alloc: BrotliAlloc,
20202033 if params. byte_align && ( ( * storage_ix & 7u32 as ( usize ) ) != 0 ) {
20212034 BrotliStoreSyncMetaBlock ( storage_ix, storage) ;
20222035 }
2023- BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2036+ if !params. bare_stream {
2037+ BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2038+ }
20242039 }
20252040 return ;
20262041 }
@@ -2164,7 +2179,9 @@ fn WriteMetaBlockInternal<Alloc: BrotliAlloc,
21642179 if params. byte_align && ( ( * storage_ix & 7u32 as ( usize ) ) != 0 ) {
21652180 BrotliStoreSyncMetaBlock ( storage_ix, storage) ;
21662181 }
2167- BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2182+ if !params. bare_stream {
2183+ BrotliWriteEmptyLastMetaBlock ( storage_ix, storage)
2184+ }
21682185 }
21692186}
21702187
@@ -2251,7 +2268,7 @@ fn EncodeData<Alloc: BrotliAlloc,
22512268 }
22522269 let mut catable_header_size = 0 ;
22532270 if let IsFirst :: NothingWritten = s. is_first_mb {
2254- if s. params . magic_number || ( s. params . byte_align && !s. params . catable && !s. params . appendable ) {
2271+ if s. params . magic_number || ( s. params . byte_align && !s. params . catable && !s. params . appendable && !s . params . bare_stream ) {
22552272 if s. params . magic_number {
22562273 BrotliWriteMetadataMetaBlock ( & s. params , & mut storage_ix, ( * s) . storage_ . slice_mut ( ) ) ;
22572274 } else {
0 commit comments