// // 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 arithmetic ;import (_d "fmt";_cg "github.com/unidoc/unipdf/v3/common";_e "github.com/unidoc/unipdf/v3/internal/bitwise";_de "github.com/unidoc/unipdf/v3/internal/jbig2/internal";_c "io";_ge "strings";);type Decoder struct{ContextSize []uint32 ; ReferedToContextSize []uint32 ;_ga _e .StreamReader ;_f uint8 ;_a uint64 ;_cf uint32 ;_ca int64 ;_ac int32 ;_cff int32 ;_eb int64 ;};func (_dbg *DecoderStats )Overwrite (dNew *DecoderStats ){for _ecc :=0;_ecc < len (_dbg ._ebff );_ecc ++{_dbg ._ebff [_ecc ]=dNew ._ebff [_ecc ]; _dbg ._ffc [_ecc ]=dNew ._ffc [_ecc ];};};func (_bfe *Decoder )renormalize ()error {for {if _bfe ._ac ==0{if _bd :=_bfe .readByte ();_bd !=nil {return _bd ;};};_bfe ._cf <<=1;_bfe ._a <<=1;_bfe ._ac --;if (_bfe ._cf &0x8000)!=0{break ;};};_bfe ._a &=0xffffffff; return nil ;};func (_ebe *DecoderStats )SetIndex (index int32 ){_ebe ._bbf =index };func (_cde *Decoder )decodeIntBit (_dc *DecoderStats )(int ,error ){_dc .SetIndex (int32 (_cde ._ca ));_ebfg ,_bb :=_cde .DecodeBit (_dc );if _bb !=nil {_cg .Log .Debug ("\u0041\u0072\u0069\u0074\u0068\u006d\u0065t\u0069\u0063\u0044e\u0063\u006f\u0064e\u0072\u0020'\u0064\u0065\u0063\u006f\u0064\u0065I\u006etB\u0069\u0074\u0027\u002d\u003e\u0020\u0044\u0065\u0063\u006f\u0064\u0065\u0042\u0069\u0074\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u002e\u0020\u0025\u0076",_bb ); return _ebfg ,_bb ;};if _cde ._ca < 256{_cde ._ca =((_cde ._ca <>16)< uint64 (_fe ){_ed =_b .lpsExchange (stats ,_cb ,_fe );if _bg :=_b .renormalize ();_bg !=nil {return 0,_bg ;};}else {_b ._a -=uint64 (_fe )<<16; if (_b ._cf &0x8000)==0{_ed =_b .mpsExchange (stats ,_cb );if _cfd :=_b .renormalize ();_cfd !=nil {return 0,_cfd ;};}else {_ed =int (stats .getMps ());};};return _ed ,nil ;};func (_dcd *DecoderStats )cx ()byte {return _dcd ._ebff [_dcd ._bbf ]};func (_gd *Decoder )readByte ()error {if _gd ._ga .StreamPosition ()> _gd ._eb {if _ ,_fbd :=_gd ._ga .Seek (-1,_c .SeekCurrent ); _fbd !=nil {return _fbd ;};};_edf ,_fc :=_gd ._ga .ReadByte ();if _fc !=nil {return _fc ;};_gd ._f =_edf ;if _gd ._f ==0xFF{_ce ,_ff :=_gd ._ga .ReadByte ();if _ff !=nil {return _ff ;};if _ce > 0x8F{_gd ._a +=0xFF00;_gd ._ac =8;if _ ,_ceg :=_gd ._ga .Seek (-2,_c .SeekCurrent ); _ceg !=nil {return _ceg ;};}else {_gd ._a +=uint64 (_ce )<<9;_gd ._ac =7;};}else {_edf ,_fc =_gd ._ga .ReadByte ();if _fc !=nil {return _fc ;};_gd ._f =_edf ;_gd ._a +=uint64 (_gd ._f )<<8;_gd ._ac =8;};_gd ._a &=0xFFFFFFFFFF;return nil ;};func (_bed *DecoderStats )toggleMps (){_bed ._ffc [_bed ._bbf ]^=1}; func (_cfg *Decoder )DecodeInt (stats *DecoderStats )(int32 ,error ){var (_ab ,_dec int32 ;_dg ,_dgb ,_cd int ;_bgg error ;);if stats ==nil {stats =NewStats (512,1);};_cfg ._ca =1;_dgb ,_bgg =_cfg .decodeIntBit (stats );if _bgg !=nil {return 0,_bgg ;}; _dg ,_bgg =_cfg .decodeIntBit (stats );if _bgg !=nil {return 0,_bgg ;};if _dg ==1{_dg ,_bgg =_cfg .decodeIntBit (stats );if _bgg !=nil {return 0,_bgg ;};if _dg ==1{_dg ,_bgg =_cfg .decodeIntBit (stats );if _bgg !=nil {return 0,_bgg ;};if _dg ==1{_dg ,_bgg =_cfg .decodeIntBit (stats ); if _bgg !=nil {return 0,_bgg ;};if _dg ==1{_dg ,_bgg =_cfg .decodeIntBit (stats );if _bgg !=nil {return 0,_bgg ;};if _dg ==1{_cd =32;_dec =4436;}else {_cd =12;_dec =340;};}else {_cd =8;_dec =84;};}else {_cd =6;_dec =20;};}else {_cd =4;_dec =4;};}else {_cd =2; _dec =0;};for _df :=0;_df < _cd ;_df ++{_dg ,_bgg =_cfg .decodeIntBit (stats );if _bgg !=nil {return 0,_bgg ;};_ab =(_ab <<1)|int32 (_dg );};_ab +=_dec ;if _dgb ==0{return _ab ,nil ;}else if _dgb ==1&&_ab > 0{return -_ab ,nil ;};return 0,_de .ErrOOB ;}; func (_dd *DecoderStats )Reset (){for _dad :=0;_dad < len (_dd ._ebff );_dad ++{_dd ._ebff [_dad ]=0;_dd ._ffc [_dad ]=0;};};func New (r _e .StreamReader )(*Decoder ,error ){_ag :=&Decoder {_ga :r ,ContextSize :[]uint32 {16,13,10,10},ReferedToContextSize :[]uint32 {13,10}}; if _fb :=_ag .init ();_fb !=nil {return nil ,_fb ;};return _ag ,nil ;};type DecoderStats struct{_bbf int32 ;_fa int32 ;_ebff []byte ;_ffc []byte ;};