// // 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 (_da "fmt";_e "github.com/unidoc/unipdf/v3/common";_bc "github.com/unidoc/unipdf/v3/internal/bitwise";_bce "github.com/unidoc/unipdf/v3/internal/jbig2/internal";_c "io";_d "strings";);func New (r *_bc .Reader )(*Decoder ,error ){_cc :=&Decoder {_dd :r ,ContextSize :[]uint32 {16,13,10,10},ReferedToContextSize :[]uint32 {13,10}}; if _fa :=_cc .init ();_fa !=nil {return nil ,_fa ;};return _cc ,nil ;};func (_fc *Decoder )DecodeBit (stats *DecoderStats )(int ,error ){var (_ff int ;_ed =_f [stats .cx ()][0];_ge =int32 (stats .cx ()););defer func (){_fc ._bd ++}();_fc ._dg -=_ed ;if (_fc ._bf >>16)< uint64 (_ed ){_ff =_fc .lpsExchange (stats ,_ge ,_ed ); if _be :=_fc .renormalize ();_be !=nil {return 0,_be ;};}else {_fc ._bf -=uint64 (_ed )<<16;if (_fc ._dg &0x8000)==0{_ff =_fc .mpsExchange (stats ,_ge );if _fg :=_fc .renormalize ();_fg !=nil {return 0,_fg ;};}else {_ff =int (stats .getMps ());};};return _ff ,nil ; };var (_f =[][4]uint32 {{0x5601,1,1,1},{0x3401,2,6,0},{0x1801,3,9,0},{0x0AC1,4,12,0},{0x0521,5,29,0},{0x0221,38,33,0},{0x5601,7,6,1},{0x5401,8,14,0},{0x4801,9,14,0},{0x3801,10,14,0},{0x3001,11,17,0},{0x2401,12,18,0},{0x1C01,13,20,0},{0x1601,29,21,0},{0x5601,15,14,1},{0x5401,16,14,0},{0x5101,17,15,0},{0x4801,18,16,0},{0x3801,19,17,0},{0x3401,20,18,0},{0x3001,21,19,0},{0x2801,22,19,0},{0x2401,23,20,0},{0x2201,24,21,0},{0x1C01,25,22,0},{0x1801,26,23,0},{0x1601,27,24,0},{0x1401,28,25,0},{0x1201,29,26,0},{0x1101,30,27,0},{0x0AC1,31,28,0},{0x09C1,32,29,0},{0x08A1,33,30,0},{0x0521,34,31,0},{0x0441,35,32,0},{0x02A1,36,33,0},{0x0221,37,34,0},{0x0141,38,35,0},{0x0111,39,36,0},{0x0085,40,37,0},{0x0049,41,38,0},{0x0025,42,39,0},{0x0015,43,40,0},{0x0009,44,41,0},{0x0005,45,42,0},{0x0001,45,43,0},{0x5601,46,46,0}}; );type DecoderStats struct{_gd int32 ;_cad int32 ;_dgf []byte ;_eb []byte ;};func (_cb *Decoder )DecodeInt (stats *DecoderStats )(int32 ,error ){var (_fgg ,_gb int32 ;_fb ,_cg ,_bb int ;_bee error ;);if stats ==nil {stats =NewStats (512,1);};_cb ._g =1; _cg ,_bee =_cb .decodeIntBit (stats );if _bee !=nil {return 0,_bee ;};_fb ,_bee =_cb .decodeIntBit (stats );if _bee !=nil {return 0,_bee ;};if _fb ==1{_fb ,_bee =_cb .decodeIntBit (stats );if _bee !=nil {return 0,_bee ;};if _fb ==1{_fb ,_bee =_cb .decodeIntBit (stats ); if _bee !=nil {return 0,_bee ;};if _fb ==1{_fb ,_bee =_cb .decodeIntBit (stats );if _bee !=nil {return 0,_bee ;};if _fb ==1{_fb ,_bee =_cb .decodeIntBit (stats );if _bee !=nil {return 0,_bee ;};if _fb ==1{_bb =32;_gb =4436;}else {_bb =12;_gb =340;};}else {_bb =8; _gb =84;};}else {_bb =6;_gb =20;};}else {_bb =4;_gb =4;};}else {_bb =2;_gb =0;};for _bdg :=0;_bdg < _bb ;_bdg ++{_fb ,_bee =_cb .decodeIntBit (stats );if _bee !=nil {return 0,_bee ;};_fgg =(_fgg <<1)|int32 (_fb );};_fgg +=_gb ;if _cg ==0{return _fgg ,nil ; }else if _cg ==1&&_fgg > 0{return -_fgg ,nil ;};return 0,_bce .ErrOOB ;};func (_cd *Decoder )readByte ()error {if _cd ._dd .AbsolutePosition ()> _cd ._cf {if _ ,_ad :=_cd ._dd .Seek (-1,_c .SeekCurrent );_ad !=nil {return _ad ;};};_fd ,_ca :=_cd ._dd .ReadByte (); if _ca !=nil {return _ca ;};_cd ._bg =_fd ;if _cd ._bg ==0xFF{_gc ,_df :=_cd ._dd .ReadByte ();if _df !=nil {return _df ;};if _gc > 0x8F{_cd ._bf +=0xFF00;_cd ._ce =8;if _ ,_daf :=_cd ._dd .Seek (-2,_c .SeekCurrent );_daf !=nil {return _daf ;};}else {_cd ._bf +=uint64 (_gc )<<9; _cd ._ce =7;};}else {_fd ,_ca =_cd ._dd .ReadByte ();if _ca !=nil {return _ca ;};_cd ._bg =_fd ;_cd ._bf +=uint64 (_cd ._bg )<<8;_cd ._ce =8;};_cd ._bf &=0xFFFFFFFFFF;return nil ;};func (_db *Decoder )init ()error {_db ._cf =_db ._dd .AbsolutePosition (); _dc ,_dgb :=_db ._dd .ReadByte ();if _dgb !=nil {_e .Log .Debug ("B\u0075\u0066\u0066\u0065\u0072\u0030 \u0072\u0065\u0061\u0064\u0042\u0079\u0074\u0065\u0020f\u0061\u0069\u006ce\u0064.\u0020\u0025\u0076",_dgb );return _dgb ;};_db ._bg =_dc ;_db ._bf =uint64 (_dc )<<16; if _dgb =_db .readByte ();_dgb !=nil {return _dgb ;};_db ._bf <<=7;_db ._ce -=7;_db ._dg =0x8000;_db ._bd ++;return nil ;};func (_bbg *DecoderStats )SetIndex (index int32 ){_bbg ._gd =index };type Decoder struct{ContextSize []uint32 ;ReferedToContextSize []uint32 ; _dd *_bc .Reader ;_bg uint8 ;_bf uint64 ;_dg uint32 ;_g int64 ;_ce int32 ;_bd int32 ;_cf int64 ;};func (_ccd *Decoder )decodeIntBit (_dbc *DecoderStats )(int ,error ){_dbc .SetIndex (int32 (_ccd ._g ));_bdf ,_fcc :=_ccd .DecodeBit (_dbc );if _fcc !=nil {_e .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",_fcc ); return _bdf ,_fcc ;};if _ccd ._g < 256{_ccd ._g =((_ccd ._g <