- my $decoded = read_file( $ifh );
- my $encoded = bro( $decoded, $QUALITY, $WINDOW );
- write_file( $ofh, $encoded );
+ if( $STREAM ) {
+ my $bro = IO::Compress::Brotli->create();
+ $bro->quality( $QUALITY );
+ $bro->window( $WINDOW );
+ while( read $ifh, (my $buf), $STREAM ) {
+ $encoded = $bro->compress($buf);
+ $total_size += bytes::length( $encoded );
+ print $ofh $encoded;
+ }
+ $encoded = $bro->finish();
+ $total_size += bytes::length( $encoded );
+ print $ofh $encoded;
+ }
+ else {
+ my $decoded = read_file( $ifh );
+ my $encoded = bro( $decoded, $QUALITY, $WINDOW );
+ $total_size += bytes::length( $encoded );
+ write_file( $ofh, $encoded );
+ }