ed206a9148bc4cd7b170f843475620174e93ada6
1 package IO
::Compress
::Brotli
;
6 use parent qw
/Exporter/;
10 use IO
::Uncompress
::Brotli
;
12 our @EXPORT = qw
/bro/;
13 our @EXPORT_OK = @EXPORT;
15 our $VERSION = '0.004001';
17 my %BROTLI_ENCODER_MODE = ( generic
=> 0, text
=> 1, font
=> 2 );
19 my ($self, $mode) = @_;
21 croak
'Invalid encoder mode'
22 unless $BROTLI_ENCODER_MODE{$mode};
35 IO::Compress::Brotli - Write Brotli buffers/streams
39 use IO::Compress::Brotli;
42 my $encoded = bro $encoded;
45 my $bro = IO::Compress::Brotli->create;
47 my $block = get_input_block();
48 my $encoded_block = $bro->compress($block);
49 handle_output_block($encoded_block);
51 # Need to finish the steam
52 handle_output_block($bro->finish());
56 IO::Compress::Brotli is a module that compressed Brotli buffers
57 and streams. Despite its name, it is not a subclass of
58 L<IO::Compress::Base> and does not implement its interface. This
59 will be rectified in a future release.
61 =head2 One-shot interface
63 If you have the whole buffer in a Perl scalar use the B<bro>
68 =item B<bro>(I<$input>, I<$quality>, I<$window>)
70 Takes a whole uncompressed buffer as input and returns the compressed
71 data using the supplied quality and window parameters. If quality and
72 window parameters are not supplied, default values are used (as
73 described under the object-oriented interface).
79 =head2 Streaming interface
81 If you want to process the data in blocks use the object oriented
82 interface. The available methods are:
86 =item IO::Compress::Brotli->B<create>
88 Returns a IO::Compress::Brotli instance. Please note that a single
89 instance cannot be used to decompress multiple streams.
91 =item $bro->B<window>(I<$window>)
93 Sets the window parameter on the brotli encoder.
94 Defaults to BROTLI_DEFAULT_WINDOW (22).
96 =item $bro->B<quality>(I<$quality>)
98 Sets the quality paremeter on the brotli encoder.
99 Defaults to BROTLI_DEFAULT_QUALITY (11).
101 =item $bro->B<mode>(I<$mode>)
103 Sets the brotli encoder mode, which can be any of "generic",
104 "text" or "font". Defaults to "generic".
106 =item $bro->B<compress>(I<$block>)
108 Takes the a block of uncompressed data and returns a block of
109 compressed data. Dies on error.
111 =item $bro->B<flush>()
113 Flushes any pending output from the encoder.
115 =item $bro->B<finish>()
117 Tells the encoder to start the finish operation, and flushes
118 any remaining compressed output.
120 Once finish is called, the encoder cannot be used to compress
123 B<NOTE>: Calling finish is B<required>, or the output might
124 remain unflushed, and the be missing termination marks.
130 Brotli Compressed Data Format Internet-Draft:
131 L<https://www.ietf.org/id/draft-alakuijala-brotli-08.txt>
133 Brotli source code: L<https://github.com/google/brotli/>
137 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
139 The encoder bindings, modernisation of the decoder bindings and a
140 clean up of the overall project were contributed by:
144 =item Quim Rovira, E<lt>quim@rovira.catE<gt>
146 =item Ævar Arnfjörð Bjarmason, E<lt>avarab@gmail.comE<gt>
148 =item Marcell Szathmári
150 =item Mattia Barbon, E<lt>mattia@barbon.orgE<gt>
154 =head1 COPYRIGHT AND LICENSE
156 Copyright (C) 2015-2018 by Marius Gavrilescu
158 This library is free software; you can redistribute it and/or modify
159 it under the same terms as Perl itself, either Perl version 5.20.2 or,
160 at your option, any later version of Perl 5 you may have available.
This page took 0.026996 seconds and 3 git commands to generate.