12 lines
13 KiB
Go
Raw Normal View History

2020-08-27 21:45:09 +00:00
//
// 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 mmr ;import (_e "errors";_g "fmt";_ac "github.com/unidoc/unipdf/v3/common";_aa "github.com/unidoc/unipdf/v3/internal/bitwise";_b "github.com/unidoc/unipdf/v3/internal/jbig2/bitmap";_d "io";);type runData struct{_dea *_aa .SubstreamReader ;_bgb int ;_acf int ;_ccd int ;_adb []byte ;_gabf int ;_eee int ;};const (EOF =-3;_ba =-2;EOL =-1;_ec =8;_cf =(1<<_ec )-1;_fe =5;_ca =(1<<_fe )-1;);func (_ggda *runData )uncompressGetCode (_cbb []*code )(*code ,error ){return _ggda .uncompressGetCodeLittleEndian (_cbb );};func (_gce *Decoder )detectAndSkipEOL ()error {for {_eaa ,_gbf :=_gce ._bg .uncompressGetCode (_gce ._cfe );if _gbf !=nil {return _gbf ;};if _eaa !=nil &&_eaa ._c ==EOL {_gce ._bg ._bgb +=_eaa ._aca ;}else {return nil ;};};};func (_bdd *Decoder )initTables ()(_gbb error ){if _bdd ._ad ==nil {_bdd ._ad ,_gbb =_bdd .createLittleEndianTable (_de );if _gbb !=nil {return ;};_bdd ._dbe ,_gbb =_bdd .createLittleEndianTable (_fga );if _gbb !=nil {return ;};_bdd ._cfe ,_gbb =_bdd .createLittleEndianTable (_dca );if _gbb !=nil {return ;};};return nil ;};type code struct{_aca int ;_f int ;_c int ;_ff []*code ;_dc bool ;};const (_cbg int =1024<<7;_gea int =3;_cec uint =24;);type Decoder struct{_acc ,_aed int ;_bg *runData ;_ad []*code ;_dbe []*code ;_cfe []*code ;};func (_gcb *runData )align (){_gcb ._bgb =((_gcb ._bgb +7)>>3)<<3};func (_edb *Decoder )createLittleEndianTable (_cg [][3]int )([]*code ,error ){_egb :=make ([]*code ,_cf +1);for _gc :=0;_gc < len (_cg );_gc ++{_eda :=_eg (_cg [_gc ]);if _eda ._aca <=_ec {_cd :=_ec -_eda ._aca ;_dd :=_eda ._f <<uint (_cd );for _bf :=(1<<uint (_cd ))-1;_bf >=0;_bf --{_cbf :=_dd |_bf ;_egb [_cbf ]=_eda ;};}else {_cfg :=_eda ._f >>uint (_eda ._aca -_ec );if _egb [_cfg ]==nil {var _ceg =_eg ([3]int {});_ceg ._ff =make ([]*code ,_ca +1);_egb [_cfg ]=_ceg ;};if _eda ._aca <=_ec +_fe {_cc :=_ec +_fe -_eda ._aca ;_beb :=(_eda ._f <<uint (_cc ))&_ca ;_egb [_cfg ]._dc =true ;for _dae :=(1<<uint (_cc ))-1;_dae >=0;_dae --{_egb [_cfg ]._ff [_beb |_dae ]=_eda ;};}else {return nil ,_e .New ("\u0043\u006f\u0064\u0065\u0020\u0074a\u0062\u006c\u0065\u0020\u006f\u0076\u0065\u0072\u0066\u006c\u006f\u0077\u0020i\u006e\u0020\u004d\u004d\u0052\u0044\u0065c\u006f\u0064\u0065\u0072");};};};return _egb ,nil ;};const (_bd mmrCode =iota ;_gb ;_ef ;_df ;_edd ;_fcc ;_ab ;_db ;_fg ;_eeb ;_ae ;);func _eg (_fff [3]int )*code {return &code {_aca :_fff [0],_f :_fff [1],_c :_fff [2]}};func New (r _aa .StreamReader ,width ,height int ,dataOffset ,dataLength int64 )(*Decoder ,error ){_bb :=&Decoder {_acc :width ,_aed :height };_ea ,_ffa :=_aa .NewSubstreamReader (r ,uint64 (dataOffset ),uint64 (dataLength ));if _ffa !=nil {return nil ,_ffa ;};_dfd ,_ffa :=_gbc (_ea );if _ffa !=nil {return nil ,_ffa ;};_bb ._bg =_dfd ;if _afa :=_bb .initTables ();_afa !=nil {return nil ,_afa ;};return _bb ,nil ;};type mmrCode int ;func (_ded *Decoder )UncompressMMR ()(_be *_b .Bitmap ,_ace error ){_be =_b .New (_ded ._acc ,_ded ._aed );_ead :=make ([]int ,_be .Width +5);_fa :=make ([]int ,_be .Width +5);_fa [0]=_be .Width ;_ga :=1;var _fd int ;for _gg :=0;_gg < _be .Height ;_gg ++{_fd ,_ace =_ded .uncompress2d (_ded ._bg ,_fa ,_ga ,_ead ,_be .Width );if _ace !=nil {return nil ,_ace ;};if _fd ==EOF {break ;};if _fd > 0{_ace =_ded .fillBitmap (_be ,_gg ,_ead ,_fd );if _ace !=nil {return nil ,_ace ;};};_fa ,_ead =_ead ,_fa ;_ga =_fd ;};if _ace =_ded .detectAndSkipEOL ();_ace !=nil {return nil ,_ace ;};_ded ._bg .align ();return _be ,nil ;};func (_fce *runData )uncompressGetCodeLittleEndian (_caee []*code )(*code ,error ){_acac ,_ddbb :=_fce .uncompressGetNextCodeLittleEndian ();if _ddbb !=nil {_ac .Log .Debug ("\u0055n\u0063\u006fm\u0070\u0072\u0065\u0073s\u0047\u0065\u0074N\u0065\u0078\u0074\u0043\u006f\u0064\u0065\u004c\u0069tt\u006c\u0065\u0045n\u0064\u0069a\u006e\u0020\u0066\u0061\u0069\u006ce\u0064\u003a \u0025\u0076",_ddbb );return nil ,_ddbb ;};_acac &=0xffffff;_ddf :=_acac >>(_cec -_ec );_aefg :=_caee [_ddf ];if _aefg !=nil &&_aefg ._dc {_ddf =(_acac >>(_cec -_ec -_fe ))&_ca ;_aefg =_aefg ._ff [_ddf ];};return _aefg ,nil ;};var