IO-Compress-Brotli

 view release on metacpan or  search on metacpan

brotli/c/dec/state.h  view on Meta::CPAN

/* Copyright 2015 Google Inc. All Rights Reserved.

   Distributed under MIT license.
   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

/* Brotli state for partial streaming decoding. */

#ifndef BROTLI_DEC_STATE_H_
#define BROTLI_DEC_STATE_H_

#include "../common/constants.h"
#include "../common/dictionary.h"
#include "../common/platform.h"
#include "../common/transform.h"
#include <brotli/types.h>
#include "./bit_reader.h"

brotli/c/include/brotli/encode.h  view on Meta::CPAN

  BROTLI_MODE_FONT = 2
} BrotliEncoderMode;

/** Default value for ::BROTLI_PARAM_QUALITY parameter. */
#define BROTLI_DEFAULT_QUALITY 11
/** Default value for ::BROTLI_PARAM_LGWIN parameter. */
#define BROTLI_DEFAULT_WINDOW 22
/** Default value for ::BROTLI_PARAM_MODE parameter. */
#define BROTLI_DEFAULT_MODE BROTLI_MODE_GENERIC

/** Operations that can be performed by streaming encoder. */
typedef enum BrotliEncoderOperation {
  /**
   * Process input.
   *
   * Encoder may postpone producing output, until it has processed enough input.
   */
  BROTLI_OPERATION_PROCESS = 0,
  /**
   * Produce output for all processed input.
   *

brotli/tests/compatibility_test.sh  view on Meta::CPAN

BROTLI=bin/brotli
TMP_DIR=bin/tmp

for file in tests/testdata/*.compressed*; do
  echo "Testing decompression of file $file"
  expected=${file%.compressed*}
  uncompressed=${TMP_DIR}/${expected##*/}.uncompressed
  echo $uncompressed
  $BROTLI $file -fdo $uncompressed
  diff -q $uncompressed $expected
  # Test the streaming version
  cat $file | $BROTLI -dc > $uncompressed
  diff -q $uncompressed $expected
  rm -f $uncompressed
done

brotli/tests/roundtrip_test.sh  view on Meta::CPAN

"""

for file in $INPUTS; do
  for quality in 1 6 9 11; do
    echo "Roundtrip testing $file at quality $quality"
    compressed=${TMP_DIR}/${file##*/}.br
    uncompressed=${TMP_DIR}/${file##*/}.unbr
    $BROTLI -fq $quality $file -o $compressed
    $BROTLI $compressed -fdo $uncompressed
    diff -q $file $uncompressed
    # Test the streaming version
    cat $file | $BROTLI -cq $quality | $BROTLI -cd >$uncompressed
    diff -q $file $uncompressed
  done
done

brotli/tests/testdata/plrabn12.txt  view on Meta::CPAN

Like doubtful hue. But he, his wonted pride 
Soon recollecting, with high words, that bore 
Semblance of worth, not substance, gently raised 
Their fainting courage, and dispelled their fears. 
Then straight commands that, at the warlike sound 
Of trumpets loud and clarions, be upreared 
His mighty standard. That proud honour claimed 
Azazel as his right, a Cherub tall: 
Who forthwith from the glittering staff unfurled 
Th' imperial ensign; which, full high advanced, 
Shone like a meteor streaming to the wind, 
With gems and golden lustre rich emblazed, 
Seraphic arms and trophies; all the while 
Sonorous metal blowing martial sounds: 
At which the universal host up-sent 
A shout that tore Hell's concave, and beyond 
Frighted the reign of Chaos and old Night. 
All in a moment through the gloom were seen 
Ten thousand banners rise into the air, 
With orient colours waving: with them rose 
A forest huge of spears; and thronging helms 

brotli/tests/testdata/plrabn12.txt  view on Meta::CPAN

Dazzled and spent, sunk down; and sought repair 
Of sleep, which instantly fell on me, called 
By Nature as in aid, and closed mine eyes. 
Mine eyes he closed, but open left the cell 
Of fancy, my internal sight; by which, 
Abstract as in a trance, methought I saw, 
Though sleeping, where I lay, and saw the shape 
Still glorious before whom awake I stood: 
Who stooping opened my left side, and took 
From thence a rib, with cordial spirits warm, 
And life-blood streaming fresh; wide was the wound, 
But suddenly with flesh filled up and healed: 
The rib he formed and fashioned with his hands; 
Under his forming hands a creature grew, 
Man-like, but different sex; so lovely fair, 
That what seemed fair in all the world, seemed now 
Mean, or in her summed up, in her contained 
And in her looks; which from that time infused 
Sweetness into my heart, unfelt before, 
And into all things from her air inspired 
The spirit of love and amorous delight. 

t/01-uncompress.t  view on Meta::CPAN

	my $decoded = unbro ((scalar read_binary $test), 1_000_000);
	is $decoded, $expected, "$test";

	open FH, '<', $test;
	my $unbro = IO::Uncompress::Brotli->create;
	my ($buf, $out);
	until (eof FH) {
		read FH, $buf, 100;
		$out .= $unbro->decompress($buf);
	}
	is $out, $expected, "$test (streaming)";
}

t/02-roundtrip.t  view on Meta::CPAN


	for my $quality (1,5,9,11) {
		my $enc = IO::Compress::Brotli->create;
		$enc->quality($quality);
		my $encoded = $enc->compress($source);
		$encoded .= $enc->finish();

		my $dec = IO::Uncompress::Brotli->create;
		my $decoded = $dec->decompress($encoded);

		is $decoded, $source, "$test - streaming / quality $quality";
	}
}



( run in 0.279 second using v1.01-cache-2.11-cpan-4d50c553e7e )