2020-11-11 18:48:37 +00:00

12 lines
11 KiB
Go

//
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// This is a commercial product and requires a license to operate.
// A trial license can be obtained at https://unidoc.io
//
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
//
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
package huffman ;import (_db "errors";_aa "fmt";_f "github.com/unidoc/unipdf/v3/internal/bitwise";_d "github.com/unidoc/unipdf/v3/internal/jbig2/internal";_fb "math";_b "strings";);var _ Node =&OutOfBandNode {};func (_fc *OutOfBandNode )String ()string {return _aa .Sprintf ("\u0025\u0030\u00364\u0062",int64 (_fb .MaxInt64 ));};var _abab =[][][]int32 {{{1,4,0},{2,8,16},{3,16,272},{3,32,65808}},{{1,0,0},{2,0,1},{3,0,2},{4,3,3},{5,6,11},{6,32,75},{6,-1,0}},{{8,8,-256},{1,0,0},{2,0,1},{3,0,2},{4,3,3},{5,6,11},{8,32,-257,999},{7,32,75},{6,-1,0}},{{1,0,1},{2,0,2},{3,0,3},{4,3,4},{5,6,12},{5,32,76}},{{7,8,-255},{1,0,1},{2,0,2},{3,0,3},{4,3,4},{5,6,12},{7,32,-256,999},{6,32,76}},{{5,10,-2048},{4,9,-1024},{4,8,-512},{4,7,-256},{5,6,-128},{5,5,-64},{4,5,-32},{2,7,0},{3,7,128},{3,8,256},{4,9,512},{4,10,1024},{6,32,-2049,999},{6,32,2048}},{{4,9,-1024},{3,8,-512},{4,7,-256},{5,6,-128},{5,5,-64},{4,5,-32},{4,5,0},{5,5,32},{5,6,64},{4,7,128},{3,8,256},{3,9,512},{3,10,1024},{5,32,-1025,999},{5,32,2048}},{{8,3,-15},{9,1,-7},{8,1,-5},{9,0,-3},{7,0,-2},{4,0,-1},{2,1,0},{5,0,2},{6,0,3},{3,4,4},{6,1,20},{4,4,22},{4,5,38},{5,6,70},{5,7,134},{6,7,262},{7,8,390},{6,10,646},{9,32,-16,999},{9,32,1670},{2,-1,0}},{{8,4,-31},{9,2,-15},{8,2,-11},{9,1,-7},{7,1,-5},{4,1,-3},{3,1,-1},{3,1,1},{5,1,3},{6,1,5},{3,5,7},{6,2,39},{4,5,43},{4,6,75},{5,7,139},{5,8,267},{6,8,523},{7,9,779},{6,11,1291},{9,32,-32,999},{9,32,3339},{2,-1,0}},{{7,4,-21},{8,0,-5},{7,0,-4},{5,0,-3},{2,2,-2},{5,0,2},{6,0,3},{7,0,4},{8,0,5},{2,6,6},{5,5,70},{6,5,102},{6,6,134},{6,7,198},{6,8,326},{6,9,582},{6,10,1094},{7,11,2118},{8,32,-22,999},{8,32,4166},{2,-1,0}},{{1,0,1},{2,1,2},{4,0,4},{4,1,5},{5,1,7},{5,2,9},{6,2,13},{7,2,17},{7,3,21},{7,4,29},{7,5,45},{7,6,77},{7,32,141}},{{1,0,1},{2,0,2},{3,1,3},{5,0,5},{5,1,6},{6,1,8},{7,0,10},{7,1,11},{7,2,13},{7,3,17},{7,4,25},{8,5,41},{8,32,73}},{{1,0,1},{3,0,2},{4,0,3},{5,0,4},{4,1,5},{3,3,7},{6,1,15},{6,2,17},{6,3,21},{6,4,29},{6,5,45},{7,6,77},{7,32,141}},{{3,0,-2},{3,0,-1},{1,0,0},{3,0,1},{3,0,2}},{{7,4,-24},{6,2,-8},{5,1,-4},{4,0,-2},{3,0,-1},{1,0,0},{3,0,1},{4,0,2},{5,1,3},{6,2,5},{7,4,9},{7,32,-25,999},{7,32,25}}};var _ Node =&ValueNode {};func _ga (_ee *Code )*OutOfBandNode {return &OutOfBandNode {}};func (_dc *FixedSizeTable )Decode (r _f .StreamReader )(int64 ,error ){return _dc ._de .Decode (r )};type StandardTable struct{_cee *InternalNode };func (_bfd *EncodedTable )String ()string {return _bfd ._g .String ()+"\u000a"};func (_fegc *StandardTable )InitTree (codeTable []*Code )error {_dcc (codeTable );for _ ,_gda :=range codeTable {if _ddd :=_fegc ._cee .append (_gda );_ddd !=nil {return _ddd ;};};return nil ;};var _dbbc =make ([]Tabler ,len (_abab ));func (_gg *FixedSizeTable )String ()string {return _gg ._de .String ()+"\u000a"};func NewEncodedTable (table BasicTabler )(*EncodedTable ,error ){_gd :=&EncodedTable {_g :&InternalNode {},BasicTabler :table };if _ff :=_gd .parseTable ();_ff !=nil {return nil ,_ff ;};return _gd ,nil ;};type FixedSizeTable struct{_de *InternalNode };func (_cad *InternalNode )append (_cac *Code )(_ag error ){if _cac ._cba ==0{return nil ;};_da :=_cac ._cba -1-_cad ._cd ;if _da < 0{return _db .New ("\u004e\u0065\u0067\u0061\u0074\u0069\u0076\u0065\u0020\u0073\u0068\u0069\u0066\u0074\u0069n\u0067 \u0069\u0073\u0020\u006e\u006f\u0074\u0020\u0061\u006c\u006c\u006f\u0077\u0065\u0064");};_acg :=(_cac ._gee >>uint (_da ))&0x1;if _da ==0{if _cac ._fee ==-1{if _acg ==1{if _cad ._ffb !=nil {return _aa .Errorf ("O\u004f\u0042\u0020\u0061\u006c\u0072e\u0061\u0064\u0079\u0020\u0073\u0065\u0074\u0020\u0066o\u0072\u0020\u0063o\u0064e\u0020\u0025\u0073",_cac );};_cad ._ffb =_ga (_cac );}else {if _cad ._ed !=nil {return _aa .Errorf ("O\u004f\u0042\u0020\u0061\u006c\u0072e\u0061\u0064\u0079\u0020\u0073\u0065\u0074\u0020\u0066o\u0072\u0020\u0063o\u0064e\u0020\u0025\u0073",_cac );};_cad ._ed =_ga (_cac );};}else {if _acg ==1{if _cad ._ffb !=nil {return _aa .Errorf ("\u0056\u0061\u006cue\u0020\u004e\u006f\u0064\u0065\u0020\u0061\u006c\u0072e\u0061d\u0079 \u0073e\u0074\u0020\u0066\u006f\u0072\u0020\u0063\u006f\u0064\u0065\u0020\u0025\u0073",_cac );};_cad ._ffb =_be (_cac );}else {if _cad ._ed !=nil {return _aa .Errorf ("\u0056\u0061\u006cue\u0020\u004e\u006f\u0064\u0065\u0020\u0061\u006c\u0072e\u0061d\u0079 \u0073e\u0074\u0020\u0066\u006f\u0072\u0020\u0063\u006f\u0064\u0065\u0020\u0025\u0073",_cac );};_cad ._ed =_be (_cac );};};}else {if _acg ==1{if _cad ._ffb ==nil {_cad ._ffb =_bfb (_cad ._cd +1);};if _ag =_cad ._ffb .(*InternalNode ).append (_cac );_ag !=nil {return _ag ;};}else {if _cad ._ed ==nil {_cad ._ed =_bfb (_cad ._cd +1);};if _ag =_cad ._ed .(*InternalNode ).append (_cac );_ag !=nil {return _ag ;};};};return nil ;};var _ Node =&InternalNode {};type Tabler interface{Decode (_dcg _f .StreamReader )(int64 ,error );InitTree (_gfd []*Code )error ;String ()string ;RootNode ()*InternalNode ;};func NewFixedSizeTable (codeTable []*Code )(*FixedSizeTable ,error ){_e :=&FixedSizeTable {_de :&InternalNode {}};if _dfd :=_e .InitTree (codeTable );_dfd !=nil {return nil ,_dfd ;};return _e ,nil ;};type ValueNode struct{_bgb int32 ;_aca int32 ;_gbb bool ;};func (_gbe *InternalNode )String ()string {_cag :=&_b .Builder {};_cag .WriteString ("\u000a");_gbe .pad (_cag );_cag .WriteString ("\u0030\u003a\u0020");_cag .WriteString (_gbe ._ed .String ()+"\u000a");_gbe .pad (_cag );_cag .WriteString ("\u0031\u003a\u0020");_cag .WriteString (_gbe ._ffb .String ()+"\u000a");return _cag .String ();};type OutOfBandNode struct{};func (_c *EncodedTable )InitTree (codeTable []*Code )error {_dcc (codeTable );for _ ,_bf :=range codeTable {if _cg :=_c ._g .append (_bf );_cg !=nil {return _cg ;};};return nil ;};func (_cb *OutOfBandNode )Decode (r _f .StreamReader )(int64 ,error ){return 0,_d .ErrOOB };func _bfb (_cc int32 )*InternalNode {return &InternalNode {_cd :_cc }};func _dcc (_gbbd []*Code ){var _cdb int32 ;for _ ,_eec :=range _gbbd {_cdb =_dabf (_cdb ,_eec ._cba );};_ef :=make ([]int32 ,_cdb +1);for _ ,_cgc :=range _gbbd {_ef [_cgc ._cba ]++;};var _cdbd int32 ;_fab :=make ([]int32 ,len (_ef )+1);_ef [0]=0;for _bffe :=int32 (1);_bffe <=int32 (len (_ef ));_bffe ++{_fab [_bffe ]=(_fab [_bffe -1]+(_ef [_bffe -1]))<<1;_cdbd =_fab [_bffe ];for _ ,_aef :=range _gbbd {if _aef ._cba ==_bffe {_aef ._gee =_cdbd ;_cdbd ++;};};};};type Node interface{Decode (_ea _f .StreamReader )(int64 ,error );String ()string ;};func NewCode (prefixLength ,rangeLength ,rangeLow int32 ,isLowerRange bool )*Code {return &Code {_cba :prefixLength ,_fee :rangeLength ,_cgf :rangeLow ,_dec :isLowerRange ,_gee :-1};};func (_feg *StandardTable )Decode (r _f .StreamReader )(int64 ,error ){return _feg ._cee .Decode (r )};func _dabf (_fg ,_deb int32 )int32 {if _fg > _deb {return _fg ;};return _deb ;};func _acag (_ffe ,_bc int32 )string {var _agc int32 ;_dgg :=make ([]rune ,_bc );for _aee :=int32 (1);_aee <=_bc ;_aee ++{_agc =_ffe >>uint (_bc -_aee )&1;if _agc !=0{_dgg [_aee -1]='1';}else {_dgg [_aee -1]='0';};};return string (_dgg );};type EncodedTable struct{BasicTabler ;_g *InternalNode ;};func (_ab *EncodedTable )RootNode ()*InternalNode {return _ab ._g };func (_fdc *InternalNode )Decode (r _f .StreamReader )(int64 ,error ){_af ,_dg :=r .ReadBit ();if _dg !=nil {return 0,_dg ;};if _af ==0{return _fdc ._ed .Decode (r );};return _fdc ._ffb .Decode (r );};func (_eb *FixedSizeTable )RootNode ()*InternalNode {return _eb ._de };type Code struct{_cba int32 ;_fee int32 ;_cgf int32 ;_dec bool ;_gee int32 ;};func _cgg (_ccg [][]int32 )(*StandardTable ,error ){var _fda []*Code ;for _gad :=0;_gad < len (_ccg );_gad ++{_fde :=_ccg [_gad ][0];_ggee :=_ccg [_gad ][1];_ec :=_ccg [_gad ][2];var _fcg bool ;if len (_ccg [_gad ])> 3{_fcg =true ;};_fda =append (_fda ,NewCode (_fde ,_ggee ,_ec ,_fcg ));};_dgb :=&StandardTable {_cee :_bfb (0)};if _dfc :=_dgb .InitTree (_fda );_dfc !=nil {return nil ,_dfc ;};return _dgb ,nil ;};func (_bfba *Code )String ()string {var _ae string ;if _bfba ._gee !=-1{_ae =_acag (_bfba ._gee ,_bfba ._cba );}else {_ae ="\u003f";};return _aa .Sprintf ("%\u0073\u002f\u0025\u0064\u002f\u0025\u0064\u002f\u0025\u0064",_ae ,_bfba ._cba ,_bfba ._fee ,_bfba ._cgf );};func (_dcf *InternalNode )pad (_dca *_b .Builder ){for _bff :=int32 (0);_bff < _dcf ._cd ;_bff ++{_dca .WriteString ("\u0020\u0020\u0020");};};func (_fcc *ValueNode )Decode (r _f .StreamReader )(int64 ,error ){_def ,_dbb :=r .ReadBits (byte (_fcc ._bgb ));if _dbb !=nil {return 0,_dbb ;};if _fcc ._gbb {_def =-_def ;};return int64 (_fcc ._aca )+int64 (_def ),nil ;};func (_ace *StandardTable )String ()string {return _ace ._cee .String ()+"\u000a"};func (_bg *EncodedTable )Decode (r _f .StreamReader )(int64 ,error ){return _bg ._g .Decode (r )};func _be (_ebg *Code )*ValueNode {return &ValueNode {_bgb :_ebg ._fee ,_aca :_ebg ._cgf ,_gbb :_ebg ._dec }};func (_aba *FixedSizeTable )InitTree (codeTable []*Code )error {_dcc (codeTable );for _ ,_ad :=range codeTable {_faa :=_aba ._de .append (_ad );if _faa !=nil {return _faa ;};};return nil ;};var _ Tabler =&EncodedTable {};type InternalNode struct{_cd int32 ;_ed Node ;_ffb Node ;};func (_aga *StandardTable )RootNode ()*InternalNode {return _aga ._cee };func GetStandardTable (number int )(Tabler ,error ){if number <=0||number > len (_dbbc ){return nil ,_db .New ("\u0049n\u0064e\u0078\u0020\u006f\u0075\u0074 \u006f\u0066 \u0072\u0061\u006e\u0067\u0065");};_dab :=_dbbc [number -1];if _dab ==nil {var _bac error ;_dab ,_bac =_cgg (_abab [number -1]);if _bac !=nil {return nil ,_bac ;};_dbbc [number -1]=_dab ;};return _dab ,nil ;};func (_ac *EncodedTable )parseTable ()error {var (_ffd []*Code ;_ffa ,_fa ,_fd int32 ;_ce uint64 ;_gb error ;);_gf :=_ac .StreamReader ();_cf :=_ac .HtLow ();for _cf < _ac .HtHigh (){_ce ,_gb =_gf .ReadBits (byte (_ac .HtPS ()));if _gb !=nil {return _gb ;};_ffa =int32 (_ce );_ce ,_gb =_gf .ReadBits (byte (_ac .HtRS ()));if _gb !=nil {return _gb ;};_fa =int32 (_ce );_ffd =append (_ffd ,NewCode (_ffa ,_fa ,_fd ,false ));_cf +=1<<uint (_fa );};_ce ,_gb =_gf .ReadBits (byte (_ac .HtPS ()));if _gb !=nil {return _gb ;};_ffa =int32 (_ce );_fa =32;_fd =_ac .HtLow ()-1;_ffd =append (_ffd ,NewCode (_ffa ,_fa ,_fd ,true ));_ce ,_gb =_gf .ReadBits (byte (_ac .HtPS ()));if _gb !=nil {return _gb ;};_ffa =int32 (_ce );_fa =32;_fd =_ac .HtHigh ();_ffd =append (_ffd ,NewCode (_ffa ,_fa ,_fd ,false ));if _ac .HtOOB ()==1{_ce ,_gb =_gf .ReadBits (byte (_ac .HtPS ()));if _gb !=nil {return _gb ;};_ffa =int32 (_ce );_ffd =append (_ffd ,NewCode (_ffa ,-1,-1,false ));};if _gb =_ac .InitTree (_ffd );_gb !=nil {return _gb ;};return nil ;};type BasicTabler interface{HtHigh ()int32 ;HtLow ()int32 ;StreamReader ()_f .StreamReader ;HtPS ()int32 ;HtRS ()int32 ;HtOOB ()int32 ;};func (_ca *ValueNode )String ()string {return _aa .Sprintf ("\u0025\u0064\u002f%\u0064",_ca ._bgb ,_ca ._aca );};